blob: 619adb9f99823a6a087bb94ef5c5775d5249577c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/** ------------------------------------------------------------------------ *
43 ------------------------------------------------------------------------ *
44
45
46 \file wlan_hdd_wext.c
47
48 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
49 interfaces.
50
51 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
52
53 Copyright (C) 2007 Airgo Networks, Incorporated
54
55 This file defines all of the types that are utilized by the CCP module
56 of the "Portable" HDD. This file also includes the underlying Linux
57 Wireless Extensions Data types referred to by CCP.
58
59 ======================================================================== */
60
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053066#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include <wlan_hdd_includes.h>
68#include <wlan_btc_svc.h>
69#include <wlan_nlink_common.h>
70#ifdef WLAN_BTAMP_FEATURE
71#include <bap_hdd_main.h>
72#endif
73#include <vos_api.h>
74#include <net/arp.h>
75#include "ccmApi.h"
76#include "sirParams.h"
77#include "csrApi.h"
78#include "csrInsideApi.h"
79#if defined WLAN_FEATURE_VOWIFI
80#include "smeRrmInternal.h"
81#endif
82#include <aniGlobal.h>
83#include "dot11f.h"
84#include <wlan_hdd_wowl.h>
85#include <wlan_hdd_cfg.h>
86#include <wlan_hdd_wmm.h>
87#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070088#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053089#ifdef FEATURE_WLAN_TDLS
90#include "wlan_hdd_tdls.h"
91#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070092
93#ifdef CONFIG_HAS_EARLYSUSPEND
94#include <linux/earlysuspend.h>
95#endif
96#include "wlan_hdd_power.h"
97#include "qwlan_version.h"
98#include <vos_power.h>
99#include "wlan_hdd_host_offload.h"
100#include "wlan_hdd_keep_alive.h"
101#ifdef WLAN_FEATURE_PACKET_FILTERING
102#include "wlan_hdd_packet_filtering.h"
103#endif
104
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#include <linux/wireless.h>
106#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530108#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
110#include "wlan_hdd_misc.h"
111#include "bap_hdd_misc.h"
112
113#include "wlan_hdd_dev_pwr.h"
114#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530115#include "sme_Api.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700116
117#ifdef CONFIG_HAS_EARLYSUSPEND
118extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
119extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
120#endif
121
Jeff Johnsone7245742012-09-05 17:12:55 -0700122#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800123#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700124#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700125
126#define HDD_FINISH_ULA_TIME_OUT 800
127
128extern 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
134struct statsContext
135{
136 struct completion completion;
137 hdd_adapter_t *pAdapter;
138 unsigned int magic;
139};
140
141#define STATS_CONTEXT_MAGIC 0x53544154 //STAT
142#define RSSI_CONTEXT_MAGIC 0x52535349 //RSSI
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530143#define POWER_CONTEXT_MAGIC 0x504F5752 //POWR
144#define SNR_CONTEXT_MAGIC 0x534E5200 //SNR
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
146/* To Validate Channel against the Frequency and Vice-Versa */
147static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
148 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
149 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
150 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
151 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
152 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
153 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
154 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
155 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
156
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800157#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700158
159/* Private ioctls and their sub-ioctls */
160#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
161#define WE_SET_11D_STATE 1
162#define WE_WOWL 2
163#define WE_SET_POWER 3
164#define WE_SET_MAX_ASSOC 4
165#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
166#define WE_SET_DATA_INACTIVITY_TO 6
167#define WE_SET_MAX_TX_POWER 7
168#define WE_SET_HIGHER_DTIM_TRANSITION 8
169#define WE_SET_TM_LEVEL 9
170
171/* Private ioctls and their sub-ioctls */
172#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
173#define WE_GET_11D_STATE 1
174#define WE_IBSS_STATUS 2
175#define WE_PMC_STATE 3
176#define WE_GET_WLAN_DBG 4
177#define WE_MODULE_DOWN_IND 5
178#define WE_GET_MAX_ASSOC 6
179#define WE_GET_WDI_DBG 7
180#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
181#define WE_GET_CONCURRENCY_MODE 9
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
184
185/* Private ioctls and their sub-ioctls */
186#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
187#define WE_WOWL_ADD_PTRN 1
188#define WE_WOWL_DEL_PTRN 2
189#if defined WLAN_FEATURE_VOWIFI
190#define WE_NEIGHBOR_REPORT_REQUEST 3
191#endif
192#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
193#define WE_SET_CONFIG 5
194
195/* Private ioctls and their sub-ioctls */
196#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
197#define WE_SET_WLAN_DBG 1
198#define WE_SET_WDI_DBG 2
199#define WE_SET_SAP_CHANNELS 3
200
201/* Private ioctls and their sub-ioctls */
202#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
203#define WE_WLAN_VERSION 1
204#define WE_GET_STATS 2
205#define WE_GET_CFG 3
206#define WE_GET_WMM_STATUS 4
207#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700208#ifdef WLAN_FEATURE_11AC
209#define WE_GET_RSSI 6
210#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800211#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800212#ifdef FEATURE_WLAN_TDLS
213#define WE_GET_TDLS_PEERS 8
214#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700215#ifdef WLAN_FEATURE_11W
216#define WE_GET_11W_INFO 9
217#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530218#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700219
220/* Private ioctls and their sub-ioctls */
221#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
222#define WE_CLEAR_STATS 1
223#define WE_INIT_AP 2
224#define WE_STOP_AP 3
225#define WE_ENABLE_AMP 4
226#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700227#define WE_ENABLE_DXE_STALL_DETECT 6
228#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530229#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700230#define WE_SET_REASSOC_TRIGGER 8
Jeff Johnson295189b2012-06-20 16:38:30 -0700231
232/* Private ioctls and their sub-ioctls */
233#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
234#define WE_LOG_DUMP_CMD 1
235
Jeff Johnson295189b2012-06-20 16:38:30 -0700236#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800237//IOCTL to configure MCC params
238#define WE_MCC_CONFIG_CREDENTIAL 3
239#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700240
Chilam NG571c65a2013-01-19 12:27:36 +0530241#ifdef FEATURE_WLAN_TDLS
242#define WE_TDLS_CONFIG_PARAMS 5
243#endif
244
Chilam Ng01120412013-02-19 18:32:21 -0800245#ifdef FEATURE_WLAN_TDLS
246#undef MAX_VAR_ARGS
247#define MAX_VAR_ARGS 10
248#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700249#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800250#endif
251
Jeff Johnson295189b2012-06-20 16:38:30 -0700252
253/* Private ioctls (with no sub-ioctls) */
254/* note that they must be odd so that they have "get" semantics */
255#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
256#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
257#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
258
259#ifdef FEATURE_WLAN_WAPI
260/* Private ioctls EVEN NO: SET, ODD NO:GET */
261#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
262#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
263#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
264#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
265#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
266#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
267#define WAPI_PSK_AKM_SUITE 0x02721400
268#define WAPI_CERT_AKM_SUITE 0x01721400
269#endif
270
Jeff Johnsone7245742012-09-05 17:12:55 -0700271#ifdef FEATURE_OEM_DATA_SUPPORT
272/* Private ioctls for setting the measurement configuration */
273#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
274#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
275#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700276
277#ifdef WLAN_FEATURE_VOWIFI_11R
278#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
279#endif
280
281/* Private ioctl for setting the host offload feature */
282#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
283
284/* Private ioctl to get the statistics */
285#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
286
287/* Private ioctl to set the Keep Alive Params */
288#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
289#ifdef WLAN_FEATURE_PACKET_FILTERING
290/* Private ioctl to set the Packet Filtering Params */
291#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
292#endif
293
294#ifdef FEATURE_WLAN_SCAN_PNO
295/* Private ioctl to get the statistics */
296#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
297#endif
298
299#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
300
301#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
302#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700303/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700304
Jeff Johnson295189b2012-06-20 16:38:30 -0700305#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
306#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
307
308#define WLAN_STATS_INVALID 0
309#define WLAN_STATS_RETRY_CNT 1
310#define WLAN_STATS_MUL_RETRY_CNT 2
311#define WLAN_STATS_TX_FRM_CNT 3
312#define WLAN_STATS_RX_FRM_CNT 4
313#define WLAN_STATS_FRM_DUP_CNT 5
314#define WLAN_STATS_FAIL_CNT 6
315#define WLAN_STATS_RTS_FAIL_CNT 7
316#define WLAN_STATS_ACK_FAIL_CNT 8
317#define WLAN_STATS_RTS_SUC_CNT 9
318#define WLAN_STATS_RX_DISCARD_CNT 10
319#define WLAN_STATS_RX_ERROR_CNT 11
320#define WLAN_STATS_TX_BYTE_CNT 12
321
322#define WLAN_STATS_RX_BYTE_CNT 13
323#define WLAN_STATS_RX_RATE 14
324#define WLAN_STATS_TX_RATE 15
325
Jeff Johnsone7245742012-09-05 17:12:55 -0700326#define WLAN_STATS_RX_UC_BYTE_CNT 16
327#define WLAN_STATS_RX_MC_BYTE_CNT 17
328#define WLAN_STATS_RX_BC_BYTE_CNT 18
329#define WLAN_STATS_TX_UC_BYTE_CNT 19
330#define WLAN_STATS_TX_MC_BYTE_CNT 20
331#define WLAN_STATS_TX_BC_BYTE_CNT 21
332
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800333#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
334 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
335 { \
336 *__p++ = __type; \
337 *__p++ = __size; \
338 memcpy(__p, __val, __size); \
339 __p += __size; \
340 __tlen += __size + 2; \
341 } \
342 else \
343 { \
344 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!\n"); \
345 } \
346 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700347
348#define VERSION_VALUE_MAX_LEN 32
349
350#define TX_PER_TRACKING_DEFAULT_RATIO 5
351#define TX_PER_TRACKING_MAX_RATIO 10
352#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
353
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530354#define WLAN_ADAPTER 0
355#define P2P_ADAPTER 1
356
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800357/*MCC Configuration parameters */
358enum {
359 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
360 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
361 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
362 MCC_RX_DRAIN_TIME_CFG_PARAM,
363 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
364 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
365 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
366 MCC_MIN_AFTER_DTIM_CFG_PARAM,
367 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
368};
369
370int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
371 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
372
Jeff Johnson295189b2012-06-20 16:38:30 -0700373#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -0700374int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
375 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700376#endif
377
Jeff Johnson295189b2012-06-20 16:38:30 -0700378/**---------------------------------------------------------------------------
379
380 \brief hdd_wlan_get_version() -
381
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800382 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700383
384 \param - pAdapter Pointer to the adapter.
385 wrqu - Pointer to IOCTL REQUEST Data.
386 extra - Pointer to char
387
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800388 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700389
390 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800391void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
392 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700393{
394 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800395 tSirVersionString wcnss_SW_version;
396 tSirVersionString wcnss_HW_version;
397 char *pSWversion;
398 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700400
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800401 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
402 sizeof(wcnss_SW_version));
403 if (VOS_IS_STATUS_SUCCESS(status))
404 {
405 pSWversion = wcnss_SW_version;
406 }
407 else
408 {
409 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700410 }
411
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800412 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
413 sizeof(wcnss_HW_version));
414 if (VOS_IS_STATUS_SUCCESS(status))
415 {
416 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800418 else
419 {
420 pHWversion = "Unknown";
421 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700422
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700423 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800424 "Host SW:%s, FW:%s, HW:%s",
425 QWLAN_VERSIONSTR,
426 pSWversion,
427 pHWversion);
428
429 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700430}
431
Jeff Johnson295189b2012-06-20 16:38:30 -0700432int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
433{
434 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
435 v_U32_t threshold = 0,status = 0;
436
437 ENTER();
438
439 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
441 "%s:LOGP in Progress. Ignore!!!",__func__);
442 return status;
443 }
444
445 if ( eHAL_STATUS_SUCCESS !=
446 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
447 {
448 return -EIO;
449 }
450 wrqu->rts.value = threshold;
451
452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
453 ("Rts-Threshold=%ld!!\n"), wrqu->rts.value);
454
455 EXIT();
456
457 return 0;
458}
459
460int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
461{
462 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
463 v_U32_t threshold = 0,status = 0;
464
465 ENTER();
466
467 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
469 "%s:LOGP in Progress. Ignore!!!",__func__);
470 return status;
471 }
472
473 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
474 != eHAL_STATUS_SUCCESS )
475 {
476 return -EIO;
477 }
478 wrqu->frag.value = threshold;
479
480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
481 ("Frag-Threshold=%ld!!\n"), wrqu->frag.value);
482
483 EXIT();
484
485 return 0;
486}
487
488int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
489{
Jeff Johnsone7245742012-09-05 17:12:55 -0700490 int i;
491 if (channel > 0)
492 {
493 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
494 {
495 if (channel == freq_chan_map[i].chan)
496 {
497 *pfreq = freq_chan_map[i].freq;
498 return 1;
499 }
500 }
501 }
502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
503 ("Invalid channel no=%d!!\n"), channel);
504 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700505}
506
507static v_BOOL_t
508hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
509{
510 v_BOOL_t rsnType = VOS_FALSE;
511 // is the authType supported?
512 switch (authType)
513 {
514 case eCSR_AUTH_TYPE_NONE: //never used
515 rsnType = eANI_BOOLEAN_FALSE;
516 break;
517 // MAC layer authentication types
518 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
519 rsnType = eANI_BOOLEAN_FALSE;
520 break;
521 case eCSR_AUTH_TYPE_SHARED_KEY:
522 rsnType = eANI_BOOLEAN_FALSE;
523 break;
524 case eCSR_AUTH_TYPE_AUTOSWITCH:
525 rsnType = eANI_BOOLEAN_FALSE;
526 break;
527
528 // Upper layer authentication types
529 case eCSR_AUTH_TYPE_WPA:
530 rsnType = eANI_BOOLEAN_TRUE;
531 break;
532 case eCSR_AUTH_TYPE_WPA_PSK:
533 rsnType = eANI_BOOLEAN_TRUE;
534 break;
535 case eCSR_AUTH_TYPE_WPA_NONE:
536 rsnType = eANI_BOOLEAN_TRUE;
537 break;
538#ifdef WLAN_FEATURE_VOWIFI_11R
539 case eCSR_AUTH_TYPE_FT_RSN:
540#endif
541 case eCSR_AUTH_TYPE_RSN:
542 rsnType = eANI_BOOLEAN_TRUE;
543 break;
544#ifdef WLAN_FEATURE_VOWIFI_11R
545 case eCSR_AUTH_TYPE_FT_RSN_PSK:
546#endif
547 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700548#ifdef WLAN_FEATURE_11W
549 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
550#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 rsnType = eANI_BOOLEAN_TRUE;
552 break;
553 //case eCSR_AUTH_TYPE_FAILED:
554 case eCSR_AUTH_TYPE_UNKNOWN:
555 rsnType = eANI_BOOLEAN_FALSE;
556 break;
557 default:
558 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700559 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 rsnType = eANI_BOOLEAN_FALSE;
561 break;
562 }
563 hddLog(LOGE, FL("%s called with authType: %d, returned: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700564 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 return rsnType;
566}
567
568static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
569{
570 struct statsContext *pStatsContext;
571 hdd_adapter_t *pAdapter;
572
573 if (ioctl_debug)
574 {
575 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700576 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 }
578
579 if (NULL == pContext)
580 {
581 hddLog(VOS_TRACE_LEVEL_ERROR,
582 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700583 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 return;
585 }
586
587 /* there is a race condition that exists between this callback function
588 and the caller since the caller could time out either before or
589 while this code is executing. we'll assume the timeout hasn't
590 occurred, but we'll verify that right before we save our work */
591
592 pStatsContext = pContext;
593 pAdapter = pStatsContext->pAdapter;
594 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
595 {
596 /* the caller presumably timed out so there is nothing we can do */
597 hddLog(VOS_TRACE_LEVEL_WARN,
598 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700599 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 if (ioctl_debug)
601 {
602 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700603 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 }
605 return;
606 }
607
608 /* the race is on. caller could have timed out immediately after
609 we verified the magic, but if so, caller will wait a short time
610 for us to copy over the rssi */
611 pAdapter->rssi = rssi;
612
613 /* and notify the caller */
614 complete(&pStatsContext->completion);
615}
616
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530617static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
618{
619 struct statsContext *pStatsContext;
620 hdd_adapter_t *pAdapter;
621
622 if (ioctl_debug)
623 {
624 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
625 __func__, (int)snr, (int)staId, pContext);
626 }
627
628 if (NULL == pContext)
629 {
630 hddLog(VOS_TRACE_LEVEL_ERROR,
631 "%s: Bad param, pContext [%p]",
632 __func__, pContext);
633 return;
634 }
635
636 /* there is a race condition that exists between this callback function
637 * and the caller since the caller could time out either before or
638 * while this code is executing. we'll assume the timeout hasn't
639 * occurred, but we'll verify that right before we save our work
640 */
641
642 pStatsContext = pContext;
643 pAdapter = pStatsContext->pAdapter;
644 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
645 {
646 /* the caller presumably timed out so there is nothing we can do */
647 hddLog(VOS_TRACE_LEVEL_WARN,
648 "%s: Invalid context, pAdapter [%p] magic [%08x]",
649 __func__, pAdapter, pStatsContext->magic);
650 if (ioctl_debug)
651 {
652 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
653 __func__, pAdapter, pStatsContext->magic);
654 }
655 return;
656 }
657
658 /* the race is on. caller could have timed out immediately after
659 * we verified the magic, but if so, caller will wait a short time
660 * for us to copy over the snr
661 */
662 pAdapter->snr = snr;
663
664 /* and notify the caller */
665 complete(&pStatsContext->completion);
666}
667
Jeff Johnson295189b2012-06-20 16:38:30 -0700668VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
669{
670 struct statsContext context;
671 hdd_context_t *pHddCtx;
672 hdd_station_ctx_t *pHddStaCtx;
673 eHalStatus hstatus;
674 long lrc;
675
676 if (NULL == pAdapter)
677 {
678 hddLog(VOS_TRACE_LEVEL_WARN,
679 "%s: Invalid context, pAdapter", __func__);
680 return VOS_STATUS_E_FAULT;
681 }
682 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
683 {
684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
685 /* return a cached value */
686 *rssi_value = pAdapter->rssi;
687 return VOS_STATUS_SUCCESS;
688 }
689
690 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
691 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
692
693 init_completion(&context.completion);
694 context.pAdapter = pAdapter;
695 context.magic = RSSI_CONTEXT_MAGIC;
696
697 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
698 pHddStaCtx->conn_info.staId[ 0 ],
699 pHddStaCtx->conn_info.bssId,
700 &context, pHddCtx->pvosContext);
701 if (eHAL_STATUS_SUCCESS != hstatus)
702 {
703 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700704 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 /* we'll returned a cached value below */
706 }
707 else
708 {
709 /* request was sent -- wait for the response */
710 lrc = wait_for_completion_interruptible_timeout(&context.completion,
711 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
712 /* either we have a response or we timed out
713 either way, first invalidate our magic */
714 context.magic = 0;
715 if (lrc <= 0)
716 {
717 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700718 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 /* there is a race condition such that the callback
720 function could be executing at the same time we are. of
721 primary concern is if the callback function had already
722 verified the "magic" but hasn't yet set the completion
723 variable. Since the completion variable is on our
724 stack, we'll delay just a bit to make sure the data is
725 still valid if that is the case */
726 msleep(50);
727 /* we'll now returned a cached value below */
728 }
729 }
730 *rssi_value = pAdapter->rssi;
731
732 return VOS_STATUS_SUCCESS;
733}
734
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530735VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
736{
737 struct statsContext context;
738 hdd_context_t *pHddCtx;
739 hdd_station_ctx_t *pHddStaCtx;
740 eHalStatus hstatus;
741 long lrc;
742 int valid;
743
744 if (NULL == pAdapter)
745 {
746 hddLog(VOS_TRACE_LEVEL_ERROR,
747 "%s: Invalid context, pAdapter", __func__);
748 return VOS_STATUS_E_FAULT;
749 }
750
751 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
752
753 valid = wlan_hdd_validate_context(pHddCtx);
754 if (0 != valid)
755 {
756 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
757 return VOS_STATUS_E_FAULT;
758 }
759
760 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
761 if (NULL == pHddStaCtx)
762 {
763 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
764 return VOS_STATUS_E_FAULT;
765 }
766
767 init_completion(&context.completion);
768 context.pAdapter = pAdapter;
769 context.magic = SNR_CONTEXT_MAGIC;
770
771 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
772 pHddStaCtx->conn_info.staId[ 0 ],
773 pHddStaCtx->conn_info.bssId,
774 &context);
775 if (eHAL_STATUS_SUCCESS != hstatus)
776 {
777 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
778 __func__);
779 /* we'll returned a cached value below */
780 }
781 else
782 {
783 /* request was sent -- wait for the response */
784 lrc = wait_for_completion_interruptible_timeout(&context.completion,
785 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
786 /* either we have a response or we timed out
787 * either way, first invalidate our magic
788 */
789 context.magic = 0;
790 if (lrc <= 0)
791 {
792 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving SNR ",
793 __func__, (0 == lrc) ? "timeout" : "interrupt");
794 /* there is a race condition such that the callback
795 * function could be executing at the same time we are. Of
796 * primary concern is if the callback function had already
797 * verified the "magic" but hasn't yet set the completion
798 * variable. Since the completion variable is on our
799 * stack, we'll delay just a bit to make sure the data is
800 * still valid if that is the case
801 */
802 msleep(50);
803 /* we'll now returned a cached value below */
804 }
805 }
806 *snr = pAdapter->snr;
807
808 return VOS_STATUS_SUCCESS;
809}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800810#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
811
812static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
813{
814 struct statsContext *pStatsContext;
815 hdd_adapter_t *pAdapter;
816 if (ioctl_debug)
817 {
818 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
819 __func__, (int)rssi, (int)staId, pContext);
820 }
821
822 if (NULL == pContext)
823 {
824 hddLog(VOS_TRACE_LEVEL_ERROR,
825 "%s: Bad param, pContext [%p]",
826 __func__, pContext);
827 return;
828 }
829
830 /* there is a race condition that exists between this callback function
831 and the caller since the caller could time out either before or
832 while this code is executing. we'll assume the timeout hasn't
833 occurred, but we'll verify that right before we save our work */
834
835 pStatsContext = pContext;
836 pAdapter = pStatsContext->pAdapter;
837 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
838 {
839 /* the caller presumably timed out so there is nothing we can do */
840 hddLog(VOS_TRACE_LEVEL_WARN,
841 "%s: Invalid context, pAdapter [%p] magic [%08x]",
842 __func__, pAdapter, pStatsContext->magic);
843 if (ioctl_debug)
844 {
845 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
846 __func__, pAdapter, pStatsContext->magic);
847 }
848 return;
849 }
850
851 /* the race is on. caller could have timed out immediately after
852 we verified the magic, but if so, caller will wait a short time
853 for us to copy over the rssi */
854 pAdapter->rssi = rssi;
855
856 /* and notify the caller */
857 complete(&pStatsContext->completion);
858}
859
860
861
862VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
863{
864 struct statsContext context;
865 hdd_context_t *pHddCtx = NULL;
866 hdd_station_ctx_t *pHddStaCtx = NULL;
867 eHalStatus hstatus;
868 long lrc;
869
870 if (NULL == pAdapter)
871 {
872 hddLog(VOS_TRACE_LEVEL_WARN,
873 "%s: Invalid context, pAdapter", __func__);
874 return VOS_STATUS_E_FAULT;
875 }
876 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
877 {
878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
879 /* return a cached value */
880 *rssi_value = pAdapter->rssi;
881 return VOS_STATUS_SUCCESS;
882 }
883
884 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
885 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
886
887 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
888 {
889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
890 /* return a cached value */
891 *rssi_value = 0;
892 return VOS_STATUS_SUCCESS;
893 }
894 init_completion(&context.completion);
895 context.pAdapter = pAdapter;
896 context.magic = RSSI_CONTEXT_MAGIC;
897
898 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
899 pHddStaCtx->conn_info.staId[ 0 ],
900 pHddStaCtx->conn_info.bssId,
901 &context, pHddCtx->pvosContext);
902 if (eHAL_STATUS_SUCCESS != hstatus)
903 {
904 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
905 __func__);
906 /* we'll returned a cached value below */
907 }
908 else
909 {
910 /* request was sent -- wait for the response */
911 lrc = wait_for_completion_interruptible_timeout(&context.completion,
912 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
913 /* either we have a response or we timed out
914 either way, first invalidate our magic */
915 context.magic = 0;
916 if (lrc <= 0)
917 {
918 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
919 __func__, (0 == lrc) ? "timeout" : "interrupt");
920 /* there is a race condition such that the callback
921 function could be executing at the same time we are. of
922 primary concern is if the callback function had already
923 verified the "magic" but hasn't yet set the completion
924 variable. Since the completion variable is on our
925 stack, we'll delay just a bit to make sure the data is
926 still valid if that is the case */
927 msleep(50);
928 /* we'll now returned a cached value below */
929 }
930 }
931 *rssi_value = pAdapter->rssi;
932
933 return VOS_STATUS_SUCCESS;
934}
935#endif
936
937
Jeff Johnson295189b2012-06-20 16:38:30 -0700938void hdd_StatisticsCB( void *pStats, void *pContext )
939{
940 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
941 hdd_stats_t *pStatsCache = NULL;
942 hdd_wext_state_t *pWextState;
943 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
944
945 tCsrSummaryStatsInfo *pSummaryStats = NULL;
946 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
947 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
948 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
949 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
950 tCsrPerStaStatsInfo *pPerStaStats = NULL;
951
952 if (pAdapter!= NULL)
953 pStatsCache = &pAdapter->hdd_stats;
954
955
956 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
957 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
958 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
959 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
960 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
961 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
962
963 if (pStatsCache!=NULL)
964 {
965 // and copy the stats into the cache we keep in the adapter instance structure
966 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
967 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
968 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
969 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
970 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
971 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
972 }
973
974 if(pAdapter)
975 {
976 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
977 if(pWextState)
978 {
979 vos_status = vos_event_set(&pWextState->vosevent);
980 if (!VOS_IS_STATUS_SUCCESS(vos_status))
981 {
982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700983 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 return;
985 }
986 }
987 }
988}
989
990void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
991{
992 v_CONTEXT_t pVosContext;
993 hdd_context_t *pHddCtx;
994 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
995#if 0
996 hdd_wext_state_t *pWextState;
997 v_U32_t roamId;
998#endif
999
1000 ENTER();
1001
1002 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1003
1004 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1005 if (NULL == pHddCtx)
1006 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001007 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 return;
1009 }
1010#if 0
1011 pWextState = pAdapter->pWextState;
1012#endif
1013
1014 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1015 {
1016 //TODO Verify is this is really used. If yes need to fix it.
1017 hdd_reconnect_all_adapters( pHddCtx );
1018#if 0
1019 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1020 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1021 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1022
1023 if(VOS_STATUS_SUCCESS == vosStatus)
1024 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1025 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1026
1027 sme_RoamConnect(halHandle,
1028 pAdapter->sessionId, &(pWextState->roamProfile),
1029 &roamId);
1030#endif
1031 }
1032
1033 EXIT();
1034
1035}
1036
1037void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1038{
1039 int i = 0;
1040 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1041
1042 /* clear WPA/RSN/WSC IE information in the profile */
1043 pWextState->roamProfile.nWPAReqIELength = 0;
1044 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1045 pWextState->roamProfile.nRSNReqIELength = 0;
1046 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1047
Chet Lanctot186b5732013-03-18 10:26:30 -07001048#ifdef FEATURE_WLAN_WAPI
1049 pWextState->roamProfile.nWAPIReqIELength = 0;
1050 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1051#endif
1052
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
1054 pWextState->roamProfile.pAddIEScan = (tANI_U8 *)NULL;
1055 pWextState->roamProfile.nAddIEScanLength = 0;
1056 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1057 pWextState->roamProfile.nAddIEAssocLength = 0;
1058
1059 pWextState->roamProfile.EncryptionType.numEntries = 1;
1060 pWextState->roamProfile.EncryptionType.encryptionType[0]
1061 = eCSR_ENCRYPT_TYPE_NONE;
1062
1063 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1064 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1065 = eCSR_ENCRYPT_TYPE_NONE;
1066
1067 pWextState->roamProfile.AuthType.numEntries = 1;
1068 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1069
Chet Lanctot186b5732013-03-18 10:26:30 -07001070#ifdef WLAN_FEATURE_11W
1071 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1072 pWextState->roamProfile.MFPRequired = 0;
1073 pWextState->roamProfile.MFPCapable = 0;
1074#endif
1075
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 pWextState->authKeyMgmt = 0;
1077
1078 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1079 {
1080 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1081 {
1082 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1083 }
1084 }
1085#ifdef FEATURE_WLAN_WAPI
1086 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1087 pAdapter->wapi_info.nWapiMode = 0;
1088#endif
1089
1090 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1091
1092}
1093
1094void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1095{
1096 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001097
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001098 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1099 {
1100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1101 "%s: Invalid pAdapter magic", __func__);
1102 }
1103 else
1104 {
1105 complete(&pAdapter->ula_complete);
1106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001107}
1108
1109VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1110{
1111 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001113 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001114
1115 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1116 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001117 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001118
1119 /*To avoid race condition between the set key and the last EAPOL
1120 packet, notify TL to finish upper layer authentication incase if the
1121 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001122 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001123
1124 if ( vos_status != VOS_STATUS_SUCCESS )
1125 {
1126 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1127 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1128 __LINE__, vos_status );
1129 return vos_status;
1130
1131 }
1132
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001133 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001135 if (0 == rc)
1136 {
1137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1138 "%s: Timeout waiting for ULA to complete", __func__);
1139 /* we'll still fall through and return success since the
1140 * connection may still get established but is just taking
1141 * too long for us to wait */
1142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 }
1144 return VOS_STATUS_SUCCESS;
1145}
1146
1147v_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)
1148{
1149
1150 int left = ie_len;
1151 v_U8_t *ptr = ie;
1152 v_U8_t elem_id,elem_len;
1153 v_U8_t eid = 0xDD;
1154
1155 if ( NULL == ie || 0 == ie_len )
1156 return NULL;
1157
1158 while(left >= 2)
1159 {
1160 elem_id = ptr[0];
1161 elem_len = ptr[1];
1162 left -= 2;
1163 if(elem_len > left)
1164 {
1165 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001166 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 eid,elem_len,left);
1168 return NULL;
1169 }
1170 if (elem_id == eid)
1171 {
1172 if(memcmp( &ptr[2], oui, oui_size)==0)
1173 return ptr;
1174 }
1175
1176 left -= elem_len;
1177 ptr += (elem_len + 2);
1178 }
1179 return NULL;
1180}
1181
1182static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1183 union iwreq_data *wrqu, char *extra)
1184{
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001185 hddLog( LOG1, "In %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 /* Do nothing for now */
1187 return 0;
1188}
1189
1190static int iw_get_name(struct net_device *dev,
1191 struct iw_request_info *info,
1192 char *wrqu, char *extra)
1193{
1194
1195 ENTER();
1196 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1197 EXIT();
1198 return 0;
1199}
1200
1201static int iw_set_mode(struct net_device *dev,
1202 struct iw_request_info *info,
1203 union iwreq_data *wrqu, char *extra)
1204{
1205 hdd_wext_state_t *pWextState;
1206 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1207 tCsrRoamProfile *pRoamProfile;
1208 eCsrRoamBssType LastBSSType;
1209 eMib_dot11DesiredBssType connectedBssType;
1210 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001212
1213 ENTER();
1214
1215 if (NULL == pAdapter)
1216 {
1217 hddLog(VOS_TRACE_LEVEL_WARN,
1218 "%s: Invalid context, pAdapter", __func__);
1219 return 0;
1220 }
1221
1222 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1224 return 0;
1225 }
1226
1227 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1228 if (pWextState == NULL)
1229 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001230 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 return -EINVAL;
1232 }
1233
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 pRoamProfile = &pWextState->roamProfile;
1236 LastBSSType = pRoamProfile->BSSType;
1237
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001238 hddLog( LOG1,"%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001239
1240 switch (wrqu->mode)
1241 {
1242 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001243 hddLog( LOG1,"%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1245 // Set the phymode correctly for IBSS.
1246 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1247 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001248 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 break;
1251 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001252 hddLog( LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 break;
1256 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001257 hddLog(LOG1,"%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1259 break;
1260 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001261 hddLog(LOG1,"%s Unknown AP Mode value", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 return -EOPNOTSUPP;
1263 }
1264
1265 if ( LastBSSType != pRoamProfile->BSSType )
1266 {
1267 //the BSS mode changed
1268 // We need to issue disconnect if connected or in IBSS disconnect state
1269 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1270 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1271 {
1272 VOS_STATUS vosStatus;
1273 // need to issue a disconnect to CSR.
1274 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1275 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1276 pAdapter->sessionId,
1277 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1278 if(VOS_STATUS_SUCCESS == vosStatus)
1279 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1280 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1281 }
1282 }
1283
1284
1285
1286 EXIT();
1287 return 0;
1288}
1289
1290
1291static int iw_get_mode(struct net_device *dev,
1292 struct iw_request_info *info,
1293 v_U32_t *uwrq, char *extra)
1294{
1295
1296 hdd_wext_state_t *pWextState;
1297 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1298
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001299 hddLog (LOG1, "In %s",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001300
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) {
1309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1310 return 0;
1311 }
1312
1313 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1314 if (pWextState == NULL)
1315 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001316 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 return -EINVAL;
1318 }
1319
1320 switch (pWextState->roamProfile.BSSType)
1321 {
1322 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001323 hddLog(LOG1, "%s returns IW_MODE_INFRA\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 *uwrq = IW_MODE_INFRA ;
1325 break;
1326 case eCSR_BSS_TYPE_IBSS:
1327 case eCSR_BSS_TYPE_START_IBSS:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001328 hddLog( LOG1,"%s returns IW_MODE_ADHOC\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 *uwrq= IW_MODE_ADHOC;
1330 break;
1331 case eCSR_BSS_TYPE_ANY:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001332 hddLog( LOG1,"%s returns IW_MODE_AUTO\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 *uwrq= IW_MODE_AUTO;
1334 break;
1335 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001336 hddLog( LOG1,"%s returns APMODE_UNKNOWN\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 break;
1338 }
1339 return 0;
1340}
1341
1342static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1343 union iwreq_data *wrqu, char *extra)
1344{
1345 v_U32_t numChans = 0;
1346 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1347 v_U32_t indx = 0;
1348 v_U32_t status = 0;
1349
1350 hdd_wext_state_t *pWextState;
1351 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1352 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1353 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1354 tCsrRoamProfile * pRoamProfile;
1355 ENTER();
1356
1357 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1359 return status;
1360 }
1361
1362 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1363
1364 pRoamProfile = &pWextState->roamProfile;
1365
1366 hddLog(LOG1,"setCHANNEL ioctl\n");
1367
1368 /* Link is up then return cant set channel*/
1369 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1370 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1371 {
1372 hddLog( LOGE, "IBSS Associated\n");
1373 return -EOPNOTSUPP;
1374 }
1375
1376 /* Settings by Frequency as input */
1377 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1378 (wrqu->freq.m <= (tANI_U32)5.825e8))
1379 {
1380 tANI_U32 freq = wrqu->freq.m / 100000;
1381
1382 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1383 indx++;
1384 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1385 {
1386 return -EINVAL;
1387 }
1388 wrqu->freq.e = 0;
1389 wrqu->freq.m = freq_chan_map[indx].chan;
1390
1391 }
1392
1393 if (wrqu->freq.e == 0)
1394 {
1395 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1396 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1397 {
1398 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001399 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1401 return -EINVAL;
1402 }
1403
1404 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1405
1406 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1407 validChan, &numChans) != eHAL_STATUS_SUCCESS){
1408 return -EIO;
1409 }
1410
1411 for (indx = 0; indx < numChans; indx++) {
1412 if (wrqu->freq.m == validChan[indx]){
1413 break;
1414 }
1415 }
1416 }
1417 else{
1418
1419 return -EINVAL;
1420 }
1421
1422 if(indx >= numChans)
1423 {
1424 return -EINVAL;
1425 }
1426
1427 /* Set the Operational Channel */
1428 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1429 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1430 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1431
1432 hddLog(LOG1,"pRoamProfile->operationChannel = %d\n", wrqu->freq.m);
1433
1434 EXIT();
1435
1436 return status;
1437}
1438
1439static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1440 struct iw_freq *fwrq, char *extra)
1441{
Jeff Johnsone7245742012-09-05 17:12:55 -07001442 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1444 tHalHandle hHal;
1445 hdd_wext_state_t *pWextState;
1446 tCsrRoamProfile * pRoamProfile;
1447 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1448
1449 ENTER();
1450
1451 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1453 return status;
1454 }
1455
1456 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1457 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1458
1459 pRoamProfile = &pWextState->roamProfile;
1460
1461 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1462 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001463 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 {
1465 return -EIO;
1466 }
1467 else
1468 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001469 status = hdd_wlan_get_freq(channel, &freq);
1470 if( TRUE == status )
1471 {
1472 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1473 * iwlist & iwconfig command shows frequency into proper
1474 * format (2.412 GHz instead of 246.2 MHz)*/
1475 fwrq->m = freq;
1476 fwrq->e = MHZ;
1477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 }
1479 }
1480 else
1481 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001482 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1483 * iwlist & iwconfig command shows frequency into proper
1484 * format (2.412 GHz instead of 246.2 MHz)*/
1485 fwrq->m = 0;
1486 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001488 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001489}
1490
1491static int iw_get_tx_power(struct net_device *dev,
1492 struct iw_request_info *info,
1493 union iwreq_data *wrqu, char *extra)
1494{
1495
1496 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1497 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1498 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1499
1500 if (pHddCtx->isLogpInProgress)
1501 {
1502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1503 "%s:LOGP in Progress. Ignore!!!",__func__);
1504 return -EBUSY;
1505 }
1506
1507 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1508 {
1509 wrqu->txpower.value = 0;
1510 return 0;
1511 }
1512 wlan_hdd_get_classAstats(pAdapter);
1513 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1514
1515 return 0;
1516}
1517
1518static int iw_set_tx_power(struct net_device *dev,
1519 struct iw_request_info *info,
1520 union iwreq_data *wrqu, char *extra)
1521{
1522 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1523 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1524
1525 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1526 {
1527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1528 return 0;
1529 }
1530
1531 ENTER();
1532
1533 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1534 {
1535 return -EIO;
1536 }
1537
1538 EXIT();
1539
1540 return 0;
1541}
1542
1543static int iw_get_bitrate(struct net_device *dev,
1544 struct iw_request_info *info,
1545 union iwreq_data *wrqu, char *extra)
1546{
1547 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1548 eHalStatus status = eHAL_STATUS_SUCCESS;
1549 hdd_wext_state_t *pWextState;
1550 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1551 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1552
1553 ENTER();
1554
1555 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1557 return status;
1558 }
1559
1560 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1561 wrqu->bitrate.value = 0;
1562 }
1563 else {
1564 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1565 SME_SUMMARY_STATS |
1566 SME_GLOBAL_CLASSA_STATS |
1567 SME_GLOBAL_CLASSB_STATS |
1568 SME_GLOBAL_CLASSC_STATS |
1569 SME_GLOBAL_CLASSD_STATS |
1570 SME_PER_STA_STATS,
1571 hdd_StatisticsCB, 0, FALSE,
1572 pHddStaCtx->conn_info.staId[0], pAdapter );
1573
1574 if(eHAL_STATUS_SUCCESS != status)
1575 {
1576 hddLog(VOS_TRACE_LEVEL_ERROR,
1577 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001578 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 return status;
1580 }
1581
1582 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1583
1584 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1585
1586 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1587 {
1588 hddLog(VOS_TRACE_LEVEL_ERROR,
1589 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001590 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 return VOS_STATUS_E_FAILURE;
1592 }
1593
1594 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1595 }
1596
1597 EXIT();
1598
1599 return vos_status;
1600}
1601/* ccm call back function */
1602
1603static int iw_set_bitrate(struct net_device *dev,
1604 struct iw_request_info *info,
1605 union iwreq_data *wrqu,
1606 char *extra)
1607{
1608 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1609 hdd_wext_state_t *pWextState;
1610 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1611 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1612 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1613 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1614 v_U32_t i, rate;
1615 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1616
1617 ENTER();
1618
1619 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1621 return 0;
1622 }
1623
1624 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1625
1626 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1627 {
1628 return -ENXIO ;
1629 }
1630
1631 rate = wrqu->bitrate.value;
1632
1633 if (rate == -1)
1634 {
1635 rate = WNI_CFG_FIXED_RATE_AUTO;
1636 valid_rate = TRUE;
1637 }
1638 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1639 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1640 {
1641 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1642 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1643 {
1644 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1645 WNI_CFG_SUPPORTED_RATES_11A,
1646 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1647 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1648 WNI_CFG_SUPPORTED_RATES_11B,
1649 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1650 {
1651 for (i = 0; i < (b_len + a_len); ++i)
1652 {
1653 /* supported rates returned is double the actual rate so we divide it by 2 */
1654 if ((supp_rates[i]&0x7F)/2 == rate)
1655 {
1656 valid_rate = TRUE;
1657 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1658 break;
1659 }
1660 }
1661 }
1662 }
1663 }
1664 if (valid_rate != TRUE)
1665 {
1666 return -EINVAL;
1667 }
1668 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1669 WNI_CFG_FIXED_RATE, rate,
1670 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1671 {
1672 return -EIO;
1673 }
1674 return 0;
1675}
1676
1677
1678static int iw_set_genie(struct net_device *dev,
1679 struct iw_request_info *info,
1680 union iwreq_data *wrqu,
1681 char *extra)
1682{
1683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1684 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1685 u_int8_t *genie;
1686 v_U16_t remLen;
1687
1688 ENTER();
1689 if(!wrqu->data.length) {
1690 hdd_clearRoamProfileIe(pAdapter);
1691 EXIT();
1692 return 0;
1693 }
1694
1695 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1697 return 0;
1698 }
1699
1700 genie = wrqu->data.pointer;
1701 remLen = wrqu->data.length;
1702
1703 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]\n", genie[0], genie[1]);
1704
1705 /* clear any previous genIE before this call */
1706 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1707
1708 while (remLen >= 2)
1709 {
1710 v_U16_t eLen = 0;
1711 v_U8_t elementId;
1712 elementId = *genie++;
1713 eLen = *genie++;
1714 remLen -= 2;
1715
1716 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
1717 __func__, elementId, eLen);
1718
1719 switch ( elementId )
1720 {
1721 case IE_EID_VENDOR:
1722 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
1723 return -EINVAL;
1724
1725 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1726 {
1727 v_U16_t curGenIELen = pWextState->genIE.length;
1728 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1729 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1730
1731 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1732 {
1733 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1734 "Need bigger buffer space\n");
1735 VOS_ASSERT(0);
1736 return -ENOMEM;
1737 }
1738 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1739 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1740 pWextState->genIE.length += eLen + 2;
1741 }
1742 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1743 {
1744 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1745 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1746 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1747 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1748 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1749 }
1750 else /* any vendorId except WPA IE should be accumulated to genIE */
1751 {
1752 v_U16_t curGenIELen = pWextState->genIE.length;
1753 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1754 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1755
1756 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1757 {
1758 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1759 "Need bigger buffer space\n");
1760 VOS_ASSERT(0);
1761 return -ENOMEM;
1762 }
1763 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1764 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1765 pWextState->genIE.length += eLen + 2;
1766 }
1767 break;
1768 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001769 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1771 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1772 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1773 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1774 break;
1775
1776 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001777 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 return 0;
1779 }
1780 genie += eLen;
1781 remLen -= eLen;
1782 }
1783 EXIT();
1784 return 0;
1785}
1786
1787static int iw_get_genie(struct net_device *dev,
1788 struct iw_request_info *info,
1789 union iwreq_data *wrqu,
1790 char *extra)
1791{
1792 hdd_wext_state_t *pWextState;
1793 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1794 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1795 eHalStatus status;
1796 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1797 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1798
1799 ENTER();
1800
1801 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1803 return 0;
1804 }
1805
1806
1807 hddLog(LOG1,"getGEN_IE ioctl\n");
1808
1809 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1810
1811 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1812 {
1813 return -ENXIO;
1814 }
1815
1816 // Return something ONLY if we are associated with an RSN or WPA network
1817 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1818 pWextState->roamProfile.negotiatedAuthType))
1819 {
1820 return -ENXIO;
1821 }
1822
1823 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1824 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1825 pAdapter->sessionId,
1826 &length,
1827 genIeBytes);
1828 wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1829
1830 vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length);
1831
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001832 hddLog(LOG1,"%s: RSN IE of %d bytes returned\n", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001833
1834 EXIT();
1835
1836 return 0;
1837}
1838
1839static int iw_get_encode(struct net_device *dev,
1840 struct iw_request_info *info,
1841 struct iw_point *dwrq, char *extra)
1842{
1843 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1844 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1845 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1846 int keyId;
1847 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1848 int i;
1849
1850 ENTER();
1851
1852 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1854 return 0;
1855 }
1856
1857 keyId = pRoamProfile->Keys.defaultIndex;
1858
1859 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1860 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001861 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001862 return -EINVAL;
1863 }
1864
1865 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1866 {
1867 dwrq->flags |= IW_ENCODE_ENABLED;
1868 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1869 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1870
1871 dwrq->flags |= (keyId + 1);
1872
1873 }
1874 else
1875 {
1876 dwrq->flags |= IW_ENCODE_DISABLED;
1877 }
1878
1879 for(i=0; i < MAX_WEP_KEYS; i++)
1880 {
1881 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
1882 {
1883 continue;
1884 }
1885 else
1886 {
1887 break;
1888 }
1889 }
1890
1891 if(MAX_WEP_KEYS == i)
1892 {
1893 dwrq->flags |= IW_ENCODE_NOKEY;
1894 }
1895
1896 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
1897
1898 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
1899 {
1900 dwrq->flags |= IW_ENCODE_OPEN;
1901 }
1902 else
1903 {
1904 dwrq->flags |= IW_ENCODE_RESTRICTED;
1905 }
1906 EXIT();
1907 return 0;
1908}
1909
1910#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
1911#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
1912
1913
1914/*
1915 * This function sends a single 'key' to LIM at all time.
1916 */
1917
1918static int iw_get_rts_threshold(struct net_device *dev,
1919 struct iw_request_info *info,
1920 union iwreq_data *wrqu, char *extra)
1921{
1922 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1923 v_U32_t status = 0;
1924
1925 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
1926
1927 return status;
1928}
1929
1930static int iw_set_rts_threshold(struct net_device *dev,
1931 struct iw_request_info *info,
1932 union iwreq_data *wrqu, char *extra)
1933{
1934 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1935 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1936
1937 ENTER();
1938
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001939 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1940 {
1941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1942 "%s:LOGP in Progress. Ignore!!!", __func__);
1943 return -EAGAIN;
1944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
1946 {
1947 return -EINVAL;
1948 }
1949
1950 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1951 {
1952 return -EIO;
1953 }
1954
1955 EXIT();
1956
1957 return 0;
1958}
1959
1960static int iw_get_frag_threshold(struct net_device *dev,
1961 struct iw_request_info *info,
1962 union iwreq_data *wrqu, char *extra)
1963{
1964 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1965 v_U32_t status = 0;
1966
1967 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
1968
1969 return status;
1970}
1971
1972static int iw_set_frag_threshold(struct net_device *dev,
1973 struct iw_request_info *info,
1974 union iwreq_data *wrqu, char *extra)
1975{
1976 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1977 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1978
1979 ENTER();
1980
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001981 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1982 {
1983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1984 "%s:LOGP in Progress. Ignore!!!", __func__);
1985 return -EBUSY;
1986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
1988 {
1989 return -EINVAL;
1990 }
1991
1992 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1993 {
1994 return -EIO;
1995 }
1996
1997 EXIT();
1998
1999 return 0;
2000}
2001
2002static int iw_get_power_mode(struct net_device *dev,
2003 struct iw_request_info *info,
2004 union iwreq_data *wrqu, char *extra)
2005{
2006 ENTER();
2007 return -EOPNOTSUPP;
2008}
2009
2010static int iw_set_power_mode(struct net_device *dev,
2011 struct iw_request_info *info,
2012 union iwreq_data *wrqu, char *extra)
2013{
2014 ENTER();
2015 return -EOPNOTSUPP;
2016}
2017
2018static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2019 union iwreq_data *wrqu, char *extra)
2020{
2021 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2022 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2023 struct iw_range *range = (struct iw_range *) extra;
2024
2025 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2026
2027 v_U32_t num_channels = sizeof(channels);
2028 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2029 v_U32_t a_len;
2030 v_U32_t b_len;
2031 v_U32_t active_phy_mode = 0;
2032 v_U8_t index = 0, i;
2033
2034 ENTER();
2035
2036 wrqu->data.length = sizeof(struct iw_range);
2037 memset(range, 0, sizeof(struct iw_range));
2038
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002039 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2040 {
2041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2042 "%s:LOGP in Progress. Ignore!!!", __func__);
2043 return -EBUSY;
2044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002045
2046 /*Get the phy mode*/
2047 if (ccmCfgGetInt(hHal,
2048 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2049 {
2050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2051 "active_phy_mode = %ld", active_phy_mode);
2052
2053 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2054 {
2055 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002056 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 if (ccmCfgGetStr(hHal,
2058 WNI_CFG_SUPPORTED_RATES_11A,
2059 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2060 {
2061 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2062 {
2063 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2064 }
2065 for (i = 0; i < a_len; i++)
2066 {
2067 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2068 }
2069 range->num_bitrates = a_len;
2070 }
2071 else
2072 {
2073 return -EIO;
2074 }
2075 }
2076 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2077 {
2078 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002079 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 if (ccmCfgGetStr(hHal,
2081 WNI_CFG_SUPPORTED_RATES_11B,
2082 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2083 {
2084 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2085 {
2086 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2087 }
2088 for (i = 0; i < b_len; i++)
2089 {
2090 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2091 }
2092 range->num_bitrates = b_len;
2093 }
2094 else
2095 {
2096 return -EIO;
2097 }
2098 }
2099 }
2100
2101 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2102 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2103 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2104
2105 range->encoding_size[0] = 5;
2106 range->encoding_size[1] = 13;
2107 range->num_encoding_sizes = 2;
2108 range->max_encoding_tokens = MAX_WEP_KEYS;
2109
2110 // we support through Wireless Extensions 22
2111 range->we_version_compiled = WIRELESS_EXT;
2112 range->we_version_source = 22;
2113
2114 /*Supported Channels and Frequencies*/
2115 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2116 {
2117 return -EIO;
2118 }
2119 if (num_channels > IW_MAX_FREQUENCIES)
2120 {
2121 num_channels = IW_MAX_FREQUENCIES;
2122 }
2123
2124 range->num_channels = num_channels;
2125 range->num_frequency = num_channels;
2126
2127 for (index=0; index < num_channels; index++)
2128 {
2129 v_U32_t frq_indx = 0;
2130
2131 range->freq[index].i = channels[index];
2132 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2133 {
2134 if(channels[index] == freq_chan_map[frq_indx].chan)
2135 {
2136 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2137 range->freq[index].e = 1;
2138 break;
2139 }
2140 frq_indx++;
2141 }
2142 }
2143
2144 /* Event capability (kernel + driver) */
2145 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2146 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2147 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2148 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2149
2150 /*Encryption capability*/
2151 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2152 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2153
2154 /* Txpower capability */
2155 range->txpower_capa = IW_TXPOW_MWATT;
2156
2157 /*Scanning capability*/
2158 #if WIRELESS_EXT >= 22
2159 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2160 #endif
2161
2162 EXIT();
2163 return 0;
2164}
2165
2166/* Callback function registered with PMC to know status of PMC request */
2167static void iw_power_callback_fn (void *pContext, eHalStatus status)
2168{
2169 struct statsContext *pStatsContext;
2170 hdd_adapter_t *pAdapter;
2171
2172 if (NULL == pContext)
2173 {
2174 hddLog(VOS_TRACE_LEVEL_ERROR,
2175 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002176 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 return;
2178 }
2179
2180 /* there is a race condition that exists between this callback function
2181 and the caller since the caller could time out either before or
2182 while this code is executing. we'll assume the timeout hasn't
2183 occurred, but we'll verify that right before we save our work */
2184
2185 pStatsContext = (struct statsContext *)pContext;
2186 pAdapter = pStatsContext->pAdapter;
2187
2188 if ((NULL == pAdapter) || (POWER_CONTEXT_MAGIC != pStatsContext->magic))
2189 {
2190 /* the caller presumably timed out so there is nothing we can do */
2191 hddLog(VOS_TRACE_LEVEL_WARN,
2192 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002193 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002194
2195 if (ioctl_debug)
2196 {
2197 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002198 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 }
2200 return;
2201 }
2202
2203 /* and notify the caller */
2204 complete(&pStatsContext->completion);
2205}
2206
2207/* Callback function for tx per hit */
2208void hdd_tx_per_hit_cb (void *pCallbackContext)
2209{
2210 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2211 unsigned char tx_fail[16];
2212 union iwreq_data wrqu;
2213
2214 if (NULL == pAdapter)
2215 {
2216 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL\n");
2217 return;
2218 }
2219 memset(&wrqu, 0, sizeof(wrqu));
2220 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2221 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2222}
2223
2224void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2225{
2226 struct statsContext *pStatsContext;
2227 tCsrGlobalClassAStatsInfo *pClassAStats;
2228 hdd_adapter_t *pAdapter;
2229
2230 if (ioctl_debug)
2231 {
2232 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002233 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 }
2235
2236 if ((NULL == pStats) || (NULL == pContext))
2237 {
2238 hddLog(VOS_TRACE_LEVEL_ERROR,
2239 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002240 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 return;
2242 }
2243
2244 /* there is a race condition that exists between this callback function
2245 and the caller since the caller could time out either before or
2246 while this code is executing. we'll assume the timeout hasn't
2247 occurred, but we'll verify that right before we save our work */
2248
2249 pClassAStats = pStats;
2250 pStatsContext = pContext;
2251 pAdapter = pStatsContext->pAdapter;
2252 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2253 {
2254 /* the caller presumably timed out so there is nothing we can do */
2255 hddLog(VOS_TRACE_LEVEL_WARN,
2256 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002257 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 if (ioctl_debug)
2259 {
2260 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002261 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 }
2263 return;
2264 }
2265
2266 /* the race is on. caller could have timed out immediately after
2267 we verified the magic, but if so, caller will wait a short time
2268 for us to copy over the stats. do so as a struct copy */
2269 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2270
2271 /* and notify the caller */
2272 complete(&pStatsContext->completion);
2273}
2274
2275VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2276{
2277 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2278 eHalStatus hstatus;
2279 long lrc;
2280 struct statsContext context;
2281
2282 if (NULL == pAdapter)
2283 {
2284 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2285 return VOS_STATUS_E_FAULT;
2286 }
2287 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2288 {
2289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2290 return VOS_STATUS_SUCCESS;
2291 }
2292
2293 /* we are connected
2294 prepare our callback context */
2295 init_completion(&context.completion);
2296 context.pAdapter = pAdapter;
2297 context.magic = STATS_CONTEXT_MAGIC;
2298 /* query only for Class A statistics (which include link speed) */
2299 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2300 eCSR_HDD,
2301 SME_GLOBAL_CLASSA_STATS,
2302 hdd_GetClassA_statisticsCB,
2303 0, // not periodic
2304 FALSE, //non-cached results
2305 pHddStaCtx->conn_info.staId[0],
2306 &context);
2307 if (eHAL_STATUS_SUCCESS != hstatus)
2308 {
2309 hddLog(VOS_TRACE_LEVEL_ERROR,
2310 "%s: Unable to retrieve Class A statistics ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002311 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 /* we'll returned a cached value below */
2313 }
2314 else
2315 {
2316 /* request was sent -- wait for the response */
2317 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2318 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2319 /* either we have a response or we timed out
2320 either way, first invalidate our magic */
2321 context.magic = 0;
2322 if (lrc <= 0)
2323 {
2324 hddLog(VOS_TRACE_LEVEL_ERROR,
2325 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002326 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 /* there is a race condition such that the callback
2328 function could be executing at the same time we are. of
2329 primary concern is if the callback function had already
2330 verified the "magic" but hasn't yet set the completion
2331 variable. Since the completion variable is on our
2332 stack, we'll delay just a bit to make sure the data is
2333 still valid if that is the case */
2334 msleep(50);
2335 }
2336 }
2337 return VOS_STATUS_SUCCESS;
2338}
2339
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002340static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2341{
2342 struct statsContext *pStatsContext;
2343 tCsrSummaryStatsInfo *pSummaryStats;
2344 tCsrGlobalClassAStatsInfo *pClassAStats;
2345 hdd_adapter_t *pAdapter;
2346
2347 if (ioctl_debug)
2348 {
2349 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002350 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002351 }
2352
2353 if ((NULL == pStats) || (NULL == pContext))
2354 {
2355 hddLog(VOS_TRACE_LEVEL_ERROR,
2356 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002357 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002358 return;
2359 }
2360
2361 /* there is a race condition that exists between this callback function
2362 and the caller since the caller could time out either before or
2363 while this code is executing. we'll assume the timeout hasn't
2364 occurred, but we'll verify that right before we save our work */
2365
2366 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2367 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2368 pStatsContext = pContext;
2369 pAdapter = pStatsContext->pAdapter;
2370 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2371 {
2372 /* the caller presumably timed out so there is nothing we can do */
2373 hddLog(VOS_TRACE_LEVEL_WARN,
2374 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002375 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002376 if (ioctl_debug)
2377 {
2378 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002379 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002380 }
2381 return;
2382 }
2383
2384 /* the race is on. caller could have timed out immediately after
2385 we verified the magic, but if so, caller will wait a short time
2386 for us to copy over the stats. do so as a struct copy */
2387 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2388 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2389
2390 /* and notify the caller */
2391 complete(&pStatsContext->completion);
2392}
2393
2394VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2395{
2396 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2397 eHalStatus hstatus;
2398 long lrc;
2399 struct statsContext context;
2400
2401 if (NULL == pAdapter)
2402 {
2403 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2404 return VOS_STATUS_SUCCESS;
2405 }
2406
2407 /* we are connected
2408 prepare our callback context */
2409 init_completion(&context.completion);
2410 context.pAdapter = pAdapter;
2411 context.magic = STATS_CONTEXT_MAGIC;
2412
2413 /* query only for Summary & Class A statistics */
2414 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2415 eCSR_HDD,
2416 SME_SUMMARY_STATS |
2417 SME_GLOBAL_CLASSA_STATS,
2418 hdd_get_station_statisticsCB,
2419 0, // not periodic
2420 FALSE, //non-cached results
2421 pHddStaCtx->conn_info.staId[0],
2422 &context);
2423 if (eHAL_STATUS_SUCCESS != hstatus)
2424 {
2425 hddLog(VOS_TRACE_LEVEL_ERROR,
2426 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002427 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002428 /* we'll return with cached values */
2429 }
2430 else
2431 {
2432 /* request was sent -- wait for the response */
2433 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2434 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2435 /* either we have a response or we timed out
2436 either way, first invalidate our magic */
2437 context.magic = 0;
2438 if (lrc <= 0)
2439 {
2440 hddLog(VOS_TRACE_LEVEL_ERROR,
2441 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002442 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002443 /* there is a race condition such that the callback
2444 function could be executing at the same time we are. of
2445 primary concern is if the callback function had already
2446 verified the "magic" but hasn't yet set the completion
2447 variable. Since the completion variable is on our
2448 stack, we'll delay just a bit to make sure the data is
2449 still valid if that is the case */
2450 msleep(50);
2451 }
2452 }
2453 return VOS_STATUS_SUCCESS;
2454}
2455
2456
Jeff Johnson295189b2012-06-20 16:38:30 -07002457/*
2458 * Support for the LINKSPEED private command
2459 * Per the WiFi framework the response must be of the form
2460 * "LinkSpeed xx"
2461 */
2462static int iw_get_linkspeed(struct net_device *dev,
2463 struct iw_request_info *info,
2464 union iwreq_data *wrqu, char *extra)
2465{
2466 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302467 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302469 int len = sizeof(v_U32_t) + 1;
2470 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302472 VOS_STATUS status;
2473 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002474
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302475 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2476
2477 valid = wlan_hdd_validate_context(pHddCtx);
2478
2479 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002480 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2482 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002483 }
2484
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2486 {
2487 /* we are not connected so we don't have a classAstats */
2488 link_speed = 0;
2489 }
2490 else
2491 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302492 status = wlan_hdd_get_classAstats(pAdapter);
2493
2494 if (!VOS_IS_STATUS_SUCCESS(status ))
2495 {
2496 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2497 return -EINVAL;
2498 }
2499
2500 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2501 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2502 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2503 &link_speed);
2504
2505 link_speed = link_speed / 10;
2506
2507 if (0 == link_speed)
2508 {
2509 /* The linkspeed returned by HAL is in units of 500kbps.
2510 * converting it to mbps.
2511 * This is required to support legacy firmware which does
2512 * not return link capacity.
2513 */
2514 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2515 }
2516
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 }
2518
2519 wrqu->data.length = len;
2520 // return the linkspeed in the format required by the WiFi Framework
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302521 rc = snprintf(pLinkSpeed, len, "%lu", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 if ((rc < 0) || (rc >= len))
2523 {
2524 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302525 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 return -EIO;
2527 }
2528
2529 /* a value is being successfully returned */
2530 return 0;
2531}
2532
2533
2534/*
2535 * Support for the RSSI & RSSI-APPROX private commands
2536 * Per the WiFi framework the response must be of the form
2537 * "<ssid> rssi <xx>"
2538 * unless we are not associated, in which case the response is
2539 * "OK"
2540 */
2541static int iw_get_rssi(struct net_device *dev,
2542 struct iw_request_info *info,
2543 union iwreq_data *wrqu, char *extra)
2544{
2545 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2546 char *cmd = (char*)wrqu->data.pointer;
2547 int len = wrqu->data.length;
2548 v_S7_t s7Rssi = 0;
2549 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2550 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2551 VOS_STATUS vosStatus;
2552 int rc;
2553
2554 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2555 (0 == ssidlen) || (ssidlen >= len))
2556 {
2557 /* we are not connected or our SSID is too long
2558 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002559 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 }
2561 else
2562 {
2563 /* we are connected with a valid SSID
2564 so we can write the SSID into the return buffer
2565 (note that it is not NUL-terminated) */
2566 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2567
2568 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2569
2570 if (VOS_STATUS_SUCCESS == vosStatus)
2571 {
2572 /* append the rssi to the ssid in the format required by
2573 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002574 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 }
2576 else
2577 {
2578 rc = -1;
2579 }
2580 }
2581
2582 /* verify that we wrote a valid response */
2583 if ((rc < 0) || (rc >= len))
2584 {
2585 // encoding or length error?
2586 hddLog(VOS_TRACE_LEVEL_ERROR,
2587 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002588 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 return -EIO;
2590 }
2591
2592 /* a value is being successfully returned */
2593 return 0;
2594}
2595
2596/*
2597 * Support for SoftAP channel range private command
2598 */
2599static int iw_softap_set_channel_range( struct net_device *dev,
2600 int startChannel,
2601 int endChannel,
2602 int band)
2603{
Jeff Johnson43971f52012-07-17 12:26:56 -07002604 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 int ret = 0;
2606 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2607 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002608 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2609
Jeff Johnson295189b2012-06-20 16:38:30 -07002610
2611 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2612 if (VOS_STATUS_SUCCESS != status)
2613 {
2614 ret = -EINVAL;
2615 }
Yathish9f22e662012-12-10 14:21:35 -08002616 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 return ret;
2618}
2619
2620VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2621{
2622 struct statsContext context;
2623 eHalStatus status;
2624 hdd_context_t *pHddCtx;
2625
2626 if (NULL == pAdapter)
2627 {
2628 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2629 return VOS_STATUS_E_FAULT;
2630 }
2631
2632 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2634 init_completion(&context.completion);
2635
2636 context.pAdapter = pAdapter;
2637 context.magic = POWER_CONTEXT_MAGIC;
2638
2639 if (DRIVER_POWER_MODE_ACTIVE == mode)
2640 {
2641 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2642 "Full Power", __func__);
2643 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2644 iw_power_callback_fn, &context,
2645 eSME_FULL_PWR_NEEDED_BY_HDD);
2646 // Enter Full power command received from GUI this means we are disconnected
2647 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2648 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2649 if (eHAL_STATUS_PMC_PENDING == status)
2650 {
2651 int lrc = wait_for_completion_interruptible_timeout(
2652 &context.completion,
2653 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2654 context.magic = 0;
2655 if (lrc <= 0)
2656 {
2657 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002658 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 /* there is a race condition such that the callback
2660 function could be executing at the same time we are. of
2661 primary concern is if the callback function had already
2662 verified the "magic" but hasn't yet set the completion
2663 variable. Since the completion variable is on our
2664 stack, we'll delay just a bit to make sure the data is
2665 still valid if that is the case */
2666 msleep(50);
2667 /* we'll now returned a cached value below */
2668 }
2669 }
2670 }
2671 else if (DRIVER_POWER_MODE_AUTO == mode)
2672 {
2673 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2674 {
2675 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2676 __func__);
2677 // Enter BMPS command received from GUI this means DHCP is completed
2678 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2679 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2680 FALSE);
2681 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2682 iw_power_callback_fn, &context);
2683 if (eHAL_STATUS_PMC_PENDING == status)
2684 {
2685 int lrc = wait_for_completion_interruptible_timeout(
2686 &context.completion,
2687 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2688 context.magic = 0;
2689 if (lrc <= 0)
2690 {
2691 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting BMPS ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002692 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 /* there is a race condition such that the callback
2694 function could be executing at the same time we are. of
2695 primary concern is if the callback function had already
2696 verified the "magic" but hasn't yet set the completion
2697 variable. Since the completion variable is on our
2698 stack, we'll delay just a bit to make sure the data is
2699 still valid if that is the case */
2700 msleep(50);
2701 /* we'll now returned a cached value below */
2702 }
2703 }
2704 }
2705 else
2706 {
2707 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2708 "enabled in the cfg");
2709 }
2710 }
2711 return VOS_STATUS_SUCCESS;
2712}
2713
2714VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2715 hdd_adapter_t *pAdapter)
2716{
2717 VOS_STATUS vos_Status;
2718
2719 if ((NULL == pAdapter) || (NULL == pHddCtx))
2720 {
2721 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2722 return VOS_STATUS_E_FAULT;
2723 }
2724
2725 /**Exit from Deep sleep or standby if we get the driver
2726 START cmd from android GUI
2727 */
2728 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2729 {
2730 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2731 "from Stand by",__func__);
2732 vos_Status = hdd_exit_standby(pHddCtx);
2733 }
2734 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2735 {
2736 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2737 "from deep sleep",__func__);
2738 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2739 }
2740 else
2741 {
2742 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2743 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2744 vos_Status = VOS_STATUS_SUCCESS;
2745 }
2746
2747 return vos_Status;
2748}
2749
2750VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2751{
2752 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2753
2754 if (NULL == pHddCtx)
2755 {
2756 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "HDD context NULL");
2757 return VOS_STATUS_E_FAULT;
2758 }
2759
2760 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2761 {
2762 //Execute standby procedure.
2763 //Executing standby procedure will cause the STA to
2764 //disassociate first and then the chip will be put into standby.
2765 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2766 vos_Status = hdd_enter_standby(pHddCtx);
2767 }
2768 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2769 pHddCtx->cfg_ini->nEnableDriverStop)
2770 {
2771 //Execute deep sleep procedure
2772 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
2773 "deep sleep mode\n");
2774 //Deep sleep not supported
2775 vos_Status = hdd_enter_standby(pHddCtx);
2776 }
2777 else
2778 {
2779 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2780 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2781 vos_Status = VOS_STATUS_SUCCESS;
2782 }
2783
2784 return vos_Status;
2785}
2786
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002787
2788void* wlan_hdd_change_country_code_callback(void *pAdapter)
2789{
2790
2791 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002792 complete(&call_back_pAdapter->change_country_code);
2793
2794 return NULL;
2795}
2796
Jeff Johnson295189b2012-06-20 16:38:30 -07002797static int iw_set_priv(struct net_device *dev,
2798 struct iw_request_info *info,
2799 union iwreq_data *wrqu, char *extra)
2800{
2801 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2802 char *cmd = (char*)wrqu->data.pointer;
2803 int cmd_len = wrqu->data.length;
2804 int ret = 0;
2805 int status = 0;
2806 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2807
2808 ENTER();
2809
2810 if (ioctl_debug)
2811 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002812 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 }
2814
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002815 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2816 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002817
2818 if (pHddCtx->isLogpInProgress) {
2819 if (ioctl_debug)
2820 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002821 pr_info("%s: RESTART in progress\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 }
2823
2824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2825 "%s:LOGP in Progress. Ignore!!!",__func__);
2826 return status;
2827 }
2828
2829 if(strncmp(cmd, "CSCAN",5) == 0 )
2830 {
2831 status = iw_set_cscan(dev, info, wrqu, extra);
2832 }
2833 else if( strcasecmp(cmd, "start") == 0 ) {
2834
2835 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command\n");
2836 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
2837 status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
2838
2839 if(status == VOS_STATUS_SUCCESS)
2840 {
2841 union iwreq_data wrqu;
2842 char buf[10];
2843
2844 memset(&wrqu, 0, sizeof(wrqu));
2845 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
2846 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2847 }
2848 else
2849 {
2850 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: START CMD Status %d", __func__, status);
2851 }
2852 goto done;
2853 }
2854 else if( strcasecmp(cmd, "stop") == 0 )
2855 {
2856 union iwreq_data wrqu;
2857 char buf[10];
2858
2859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command\n");
2860
2861 wlan_hdd_enter_lowpower(pHddCtx);
2862 memset(&wrqu, 0, sizeof(wrqu));
2863 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
2864 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2865 status = VOS_STATUS_SUCCESS;
2866 goto done;
2867 }
2868 else if (strcasecmp(cmd, "macaddr") == 0)
2869 {
2870 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
2871 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
2872 }
2873 else if (strcasecmp(cmd, "scan-active") == 0)
2874 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002875 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 ret = snprintf(cmd, cmd_len, "OK");
2877 }
2878 else if (strcasecmp(cmd, "scan-passive") == 0)
2879 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002880 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 ret = snprintf(cmd, cmd_len, "OK");
2882 }
2883 else if( strcasecmp(cmd, "scan-mode") == 0 )
2884 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002885 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 }
2887 else if( strcasecmp(cmd, "linkspeed") == 0 )
2888 {
2889 status = iw_get_linkspeed(dev, info, wrqu, extra);
2890 }
2891 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
2892 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002893 long lrc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002894
2895 country_code = cmd + 8;
2896
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002897 init_completion(&pAdapter->change_country_code);
2898
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002900 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 country_code,
2902 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05302903 pHddCtx->pvosContext,
2904 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002905
2906 /* Wait for completion */
2907 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
2908 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2909
2910 if (lrc <= 0)
2911 {
2912 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002913 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002914 }
2915
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 if( 0 != status )
2917 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002918 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2919 "%s: SME Change Country code fail \n",__func__);
2920 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 }
2922 }
2923 else if( strncasecmp(cmd, "rssi", 4) == 0 )
2924 {
2925 status = iw_get_rssi(dev, info, wrqu, extra);
2926 }
2927 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
2928 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07002929 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002930
Wilson Yang1be3e652013-10-09 15:18:31 -07002931 if (9 < cmd_len)
2932 {
2933 ptr = (char*)(cmd + 9);
2934
2935 }else{
2936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2937 "CMD LENGTH %d is not correct",cmd_len);
2938 return VOS_STATUS_E_FAILURE;
2939 }
2940
2941 if (1 != sscanf(ptr,"%d",&mode))
2942 {
2943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2944 "powermode input %s is not correct",ptr);
2945 return VOS_STATUS_E_FAILURE;
2946 }
2947
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 wlan_hdd_enter_bmps(pAdapter, mode);
2949 /*TODO:Set the power mode*/
2950 }
2951 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
2952 v_U32_t pmc_state;
2953 v_U16_t value;
2954
2955 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
2956 if(pmc_state == BMPS) {
2957 value = DRIVER_POWER_MODE_AUTO;
2958 }
2959 else {
2960 value = DRIVER_POWER_MODE_ACTIVE;
2961 }
2962 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
2963 }
2964 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
2965 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode\n");
2966 /*TODO: set the btcoexmode*/
2967 }
2968 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
2969
2970 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status\n");
2971 /*TODO: Return the btcoex status*/
2972 }
2973 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
2974
2975 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command\n");
2976
2977 /*TODO: Enable Rx data Filter*/
2978 }
2979 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
2980
2981 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command\n");
2982
2983 /*TODO: Disable Rx data Filter*/
2984 }
2985 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
2986
2987 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command\n");
2988 /*TODO: rxfilter-statistics*/
2989 }
2990 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
2991
2992 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add\n");
2993 /*TODO: rxfilter-add*/
2994 }
2995 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
2996
2997 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove\n");
2998 /*TODO: rxfilter-remove*/
2999 }
3000#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003001 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3002 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3003 /*TODO: support pnosetup*/
3004 }
3005 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3006 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3007 /*TODO: support pnoforce*/
3008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3010
3011 hddLog( VOS_TRACE_LEVEL_INFO, "pno\n");
3012 status = iw_set_pno(dev, info, wrqu, extra, 3);
3013 return status;
3014 }
3015 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
3016
3017 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter\n");
3018 status = iw_set_rssi_filter(dev, info, wrqu, extra, 10);
3019 return status;
3020 }
3021#endif /*FEATURE_WLAN_SCAN_PNO*/
3022 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
3023 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams\n");
3024 status = iw_set_power_params(dev, info, wrqu, extra, 11);
3025 return status;
3026 }
3027 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3028 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003029 char *ptr;
3030
3031 if (18 < cmd_len)
3032 {
3033 ptr = (char*)(cmd + 18);
3034 }else{
3035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3036 "CMD LENGTH %d is not correct",cmd_len);
3037 return VOS_STATUS_E_FAILURE;
3038 }
3039
3040 if (4 != sscanf(ptr,"%hhu %hhu %hhu %lu",
3041 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3042 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3043 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3044 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3045 {
3046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3047 "CONFIG-TX-TRACKING %s input is not correct",ptr);
3048 return VOS_STATUS_E_FAILURE;
3049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003050
3051 // parameters checking
3052 // period has to be larger than 0
3053 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3054 {
3055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
3056 return VOS_STATUS_E_FAILURE;
3057 }
3058
3059 // use default value 5 is the input is not reasonable. in unit of 10%
3060 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3061 {
3062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3063 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3064 }
3065
3066 // default is 5
3067 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3068 {
3069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3070 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3071 }
3072
3073 status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam);
3074 if(status != eHAL_STATUS_SUCCESS){
3075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
3076 }
3077 }
3078 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003079 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3080 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 }
3082done:
3083 /* many of the commands write information back into the command
3084 string using snprintf(). check the return value here in one
3085 place */
3086 if ((ret < 0) || (ret >= cmd_len))
3087 {
3088 /* there was an encoding error or overflow */
3089 status = -EIO;
3090 }
3091
3092 if (ioctl_debug)
3093 {
3094 pr_info("%s: rsp [%s] len [%d] status %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003095 __func__, cmd, wrqu->data.length, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 }
3097 return status;
3098
3099}
3100
3101static int iw_set_nick(struct net_device *dev,
3102 struct iw_request_info *info,
3103 union iwreq_data *wrqu, char *extra)
3104{
3105 ENTER();
3106 return 0;
3107}
3108
3109static int iw_get_nick(struct net_device *dev,
3110 struct iw_request_info *info,
3111 union iwreq_data *wrqu, char *extra)
3112{
3113 ENTER();
3114 return 0;
3115}
3116
3117static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3118{
3119 ENTER();
3120 return NULL;
3121}
3122
3123static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3124 union iwreq_data *wrqu,char *extra)
3125
3126{
3127 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3128 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3129 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3130 struct iw_point *encoderq = &(wrqu->encoding);
3131 v_U32_t keyId;
3132 v_U8_t key_length;
3133 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3134 v_BOOL_t fKeyPresent = 0;
3135 int i;
3136 eHalStatus status = eHAL_STATUS_SUCCESS;
3137
3138
3139 ENTER();
3140
3141 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3142 {
3143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3144 "%s:LOGP in Progress. Ignore!!!",__func__);
3145 return 0;
3146 }
3147
3148
3149 keyId = encoderq->flags & IW_ENCODE_INDEX;
3150
3151 if(keyId)
3152 {
3153 if(keyId > MAX_WEP_KEYS)
3154 {
3155 return -EINVAL;
3156 }
3157
3158 fKeyPresent = 1;
3159 keyId--;
3160 }
3161 else
3162 {
3163 fKeyPresent = 0;
3164 }
3165
3166
3167 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3168 {
3169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****\n");
3170 if(!fKeyPresent) {
3171
3172 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3173
3174 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3175 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3176 }
3177 }
3178 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3179 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3180 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3181 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3182
3183 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3184 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3185
3186 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3187 {
3188 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3189 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003190 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3192 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3193 }
3194
3195 return status;
3196
3197 }
3198
3199 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3200 {
3201 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3202
3203 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3204
3205 }
3206
3207
3208 if(wrqu->data.length > 0)
3209 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003210 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003211
3212 key_length = wrqu->data.length;
3213
3214 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3215
3216 if(5 == key_length)
3217 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003218 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003219
3220 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3221 {
3222 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3223 }
3224 else
3225 {
3226 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3227 }
3228 }
3229 else if(13 == key_length)
3230 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003231 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003232
3233 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3234 {
3235 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3236 }
3237 else
3238 {
3239 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3240 }
3241 }
3242 else
3243 {
3244 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003245 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 return -EINVAL;
3247 }
3248
3249 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3250 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3251 pWextState->roamProfile.EncryptionType.numEntries = 1;
3252 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3253 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3254 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3255
3256 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3257 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3258 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3259 {
3260
3261 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3262
3263 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3264 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3265
3266 return status;
3267 }
3268 }
3269
3270 return 0;
3271}
3272
3273static int iw_get_encodeext(struct net_device *dev,
3274 struct iw_request_info *info,
3275 struct iw_point *dwrq,
3276 char *extra)
3277{
3278 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3279 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3280 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3281 int keyId;
3282 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3283 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3284 int i;
3285
3286 ENTER();
3287
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003288 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3289 {
3290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3291 "%s:LOGP in Progress. Ignore!!!", __func__);
3292 return -EBUSY;
3293 }
3294
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 keyId = pRoamProfile->Keys.defaultIndex;
3296
3297 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3298 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003299 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 return -EINVAL;
3301 }
3302
3303 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3304 {
3305 dwrq->flags |= IW_ENCODE_ENABLED;
3306 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303307 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3308 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 }
3310 else
3311 {
3312 dwrq->flags |= IW_ENCODE_DISABLED;
3313 }
3314
3315 for(i=0; i < MAX_WEP_KEYS; i++)
3316 {
3317 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3318 {
3319 continue;
3320 }
3321 else
3322 {
3323 break;
3324 }
3325 }
3326
3327 if(MAX_WEP_KEYS == i)
3328 {
3329 dwrq->flags |= IW_ENCODE_NOKEY;
3330 }
3331 else
3332 {
3333 dwrq->flags |= IW_ENCODE_ENABLED;
3334 }
3335
3336 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3337
3338 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3339 {
3340 dwrq->flags |= IW_ENCODE_DISABLED;
3341 }
3342
3343 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3344
3345 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3346 {
3347 dwrq->flags |= IW_ENCODE_OPEN;
3348 }
3349 else
3350 {
3351 dwrq->flags |= IW_ENCODE_RESTRICTED;
3352 }
3353 EXIT();
3354 return 0;
3355
3356}
3357
3358static int iw_set_encodeext(struct net_device *dev,
3359 struct iw_request_info *info,
3360 union iwreq_data *wrqu, char *extra)
3361{
3362 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3363 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3364 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3365 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3366
3367 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3368 v_U32_t status = 0;
3369
3370 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3371
3372 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3373
3374 int key_index;
3375 struct iw_point *encoding = &wrqu->encoding;
3376 tCsrRoamSetKey setKey;
3377 v_U32_t roamId= 0xFF;
3378 VOS_STATUS vos_status;
3379
3380 ENTER();
3381
3382 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3383 {
3384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3385 "%s:LOGP in Progress. Ignore!!!",__func__);
3386 return 0;
3387 }
3388
3389 key_index = encoding->flags & IW_ENCODE_INDEX;
3390
3391 if(key_index > 0) {
3392
3393 /*Convert from 1-based to 0-based keying*/
3394 key_index--;
3395 }
3396 if(!ext->key_len) {
3397
3398 /*Set the encrytion type to NONE*/
3399 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3400 return status;
3401 }
3402
3403 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3404 (IW_ENCODE_ALG_WEP == ext->alg))
3405 {
3406 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3407
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003408 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s \n"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 return -EINVAL;
3410 }
3411 else {
3412 /*Static wep, update the roam profile with the keys */
3413 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3414 key_index < CSR_MAX_NUM_KEY) {
3415 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3416 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3417
3418 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3419 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3420
3421 }
3422 }
3423 return status;
3424 }
3425
3426 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3427
3428 setKey.keyId = key_index;
3429 setKey.keyLength = ext->key_len;
3430
3431 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3432 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3433 }
3434
3435 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3436 /*Key direction for group is RX only*/
3437 setKey.keyDirection = eSIR_RX_ONLY;
3438 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3439 }
3440 else {
3441
3442 setKey.keyDirection = eSIR_TX_RX;
3443 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3444 }
3445
3446 /*For supplicant pae role is zero*/
3447 setKey.paeRole = 0;
3448
3449 switch(ext->alg)
3450 {
3451 case IW_ENCODE_ALG_NONE:
3452 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3453 break;
3454
3455 case IW_ENCODE_ALG_WEP:
3456 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3457 break;
3458
3459 case IW_ENCODE_ALG_TKIP:
3460 {
3461 v_U8_t *pKey = &setKey.Key[0];
3462
3463 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3464
3465 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3466
3467 /*Supplicant sends the 32bytes key in this order
3468
3469 |--------------|----------|----------|
3470 | Tk1 |TX-MIC | RX Mic |
3471 |--------------|----------|----------|
3472 <---16bytes---><--8bytes--><--8bytes-->
3473
3474 */
3475 /*Sme expects the 32 bytes key to be in the below order
3476
3477 |--------------|----------|----------|
3478 | Tk1 |RX-MIC | TX Mic |
3479 |--------------|----------|----------|
3480 <---16bytes---><--8bytes--><--8bytes-->
3481 */
3482 /* Copy the Temporal Key 1 (TK1) */
3483 vos_mem_copy(pKey,ext->key,16);
3484
3485 /*Copy the rx mic first*/
3486 vos_mem_copy(&pKey[16],&ext->key[24],8);
3487
3488 /*Copy the tx mic */
3489 vos_mem_copy(&pKey[24],&ext->key[16],8);
3490
3491 }
3492 break;
3493
3494 case IW_ENCODE_ALG_CCMP:
3495 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3496 break;
3497
3498#ifdef FEATURE_WLAN_CCX
3499#define IW_ENCODE_ALG_KRK 6
3500 case IW_ENCODE_ALG_KRK:
3501 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3502 break;
3503#endif /* FEATURE_WLAN_CCX */
3504
3505 default:
3506 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3507 break;
3508 }
3509
3510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003511 ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d \n"),__func__,(int)ext->alg,(int)ext->key_len,setKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003512
3513#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303514 /* The supplicant may attempt to set the PTK once pre-authentication
3515 is done. Save the key in the UMAC and include it in the ADD
3516 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303518 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303520 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3521 "%s: Update PreAuth Key success", __func__);
3522 return 0;
3523 }
3524 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3525 {
3526 hddLog(VOS_TRACE_LEVEL_ERROR,
3527 "%s: Update PreAuth Key failed", __func__);
3528 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 }
3530#endif /* WLAN_FEATURE_VOWIFI_11R */
3531
3532 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3533
3534 vos_status = wlan_hdd_check_ula_done(pAdapter);
3535 if ( vos_status != VOS_STATUS_SUCCESS )
3536 {
3537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3538 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3539 __LINE__, vos_status );
3540
3541 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3542 }
3543
3544 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3545
3546 if ( halStatus != eHAL_STATUS_SUCCESS )
3547 {
3548 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3549 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3550 __LINE__, halStatus );
3551
3552 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3553 }
3554
3555 return halStatus;
3556}
3557
3558static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3559 union iwreq_data *wrqu, char *extra)
3560{
3561 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3562 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3563
3564 ENTER();
3565
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003566 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3567 {
3568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3569 "%s:LOGP in Progress. Ignore!!!", __func__);
3570 return -EBUSY;
3571 }
3572
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3574 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3575
3576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%ld!!\n"),wrqu->retry.value);
3577
3578 return -EINVAL;
3579 }
3580
3581 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3582
3583 if((wrqu->retry.flags & IW_RETRY_LONG))
3584 {
3585 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3586 {
3587 return -EIO;
3588 }
3589 }
3590 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3591 {
3592 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3593 {
3594 return -EIO;
3595 }
3596 }
3597 }
3598 else
3599 {
3600 return -EOPNOTSUPP;
3601 }
3602
3603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%ld!!\n"),wrqu->retry.value);
3604
3605 EXIT();
3606
3607 return 0;
3608
3609}
3610
3611static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3612 union iwreq_data *wrqu, char *extra)
3613{
3614 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3615 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3616 v_U32_t retry = 0;
3617
3618 ENTER();
3619
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003620 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3621 {
3622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3623 "%s:LOGP in Progress. Ignore!!!", __func__);
3624 return -EBUSY;
3625 }
3626
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 if((wrqu->retry.flags & IW_RETRY_LONG))
3628 {
3629 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3630
3631 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3632 {
3633 return -EIO;
3634 }
3635
3636 wrqu->retry.value = retry;
3637 }
3638 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3639 {
3640 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3641
3642 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3643 {
3644 return -EIO;
3645 }
3646
3647 wrqu->retry.value = retry;
3648 }
3649 else {
3650 return -EOPNOTSUPP;
3651 }
3652
3653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%ld!!\n"),retry);
3654
3655 EXIT();
3656
3657 return 0;
3658}
3659
3660static int iw_set_mlme(struct net_device *dev,
3661 struct iw_request_info *info,
3662 union iwreq_data *wrqu,
3663 char *extra)
3664{
3665 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3666 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3667 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3668 eHalStatus status = eHAL_STATUS_SUCCESS;
3669
3670 ENTER();
3671
3672 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3673 {
3674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3675 "%s:LOGP in Progress. Ignore!!!",__func__);
3676 return 0;
3677 }
3678
3679 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3680 switch (mlme->cmd) {
3681 case IW_MLME_DISASSOC:
3682 case IW_MLME_DEAUTH:
3683
3684 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3685 {
3686 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3687
3688 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3689 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3690
3691 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3692 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3693
Jeff Johnson43971f52012-07-17 12:26:56 -07003694 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3696 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3697 else
3698 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003699 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003700
3701 /* Resetting authKeyMgmt */
3702 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3703
3704 netif_tx_disable(dev);
3705 netif_carrier_off(dev);
3706
3707 }
3708 else
3709 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003710 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 }
3712 break;
3713 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003714 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 return -EINVAL;
3716 }//end of switch
3717
3718 EXIT();
3719
3720 return status;
3721
3722}
3723
3724/* set param sub-ioctls */
3725static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3726 union iwreq_data *wrqu, char *extra)
3727{
3728 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3729 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3730 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3731 int *value = (int *)extra;
3732 int sub_cmd = value[0];
3733 int set_value = value[1];
3734 int ret = 0; /* success */
3735 int enable_pbm, enable_mp;
3736#ifdef CONFIG_HAS_EARLYSUSPEND
3737 v_U8_t nEnableSuspendOld;
3738#endif
3739 INIT_COMPLETION(pWextState->completion_var);
3740
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003741 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3742 {
3743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3744 "%s:LOGP in Progress. Ignore!!!", __func__);
3745 return -EBUSY;
3746 }
3747
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 switch(sub_cmd)
3749 {
3750 case WE_SET_11D_STATE:
3751 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003752 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07003753 memset(&smeConfig, 0x00, sizeof(smeConfig));
3754
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3756
3757 sme_GetConfigParam(hHal,&smeConfig);
3758 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3759
3760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),smeConfig.csrConfig.Is11dSupportEnabled);
3761
3762 sme_UpdateConfig(hHal,&smeConfig);
3763 }
3764 else {
3765 return -EINVAL;
3766 }
3767 break;
3768 }
3769
3770 case WE_WOWL:
3771 {
3772 switch (set_value)
3773 {
3774 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003775 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 break;
3777 case 0x01:
3778 case 0x02:
3779 case 0x03:
3780 enable_mp = (set_value & 0x01) ? 1 : 0;
3781 enable_pbm = (set_value & 0x02) ? 1 : 0;
3782 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s\n",
3783 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3784 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3785 break;
3786 default:
3787 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL\n", set_value);
3788 ret = -EINVAL;
3789 break;
3790 }
3791
3792 break;
3793 }
3794 case WE_SET_POWER:
3795 {
3796 switch (set_value)
3797 {
3798 case 0: //Full Power
3799 {
3800 struct statsContext context;
3801 eHalStatus status;
3802
3803 init_completion(&context.completion);
3804
3805 context.pAdapter = pAdapter;
3806 context.magic = POWER_CONTEXT_MAGIC;
3807
3808 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3809 iw_power_callback_fn, &context,
3810 eSME_FULL_PWR_NEEDED_BY_HDD);
3811 if(eHAL_STATUS_PMC_PENDING == status)
3812 {
3813 int lrc = wait_for_completion_interruptible_timeout(
3814 &context.completion,
3815 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3816 context.magic = 0;
3817 if (lrc <= 0)
3818 {
3819 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3820 "requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003821 __func__, (0 == lrc) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 "timeout" : "interrupt");
3823 /* there is a race condition such that the callback
3824 function could be executing at the same time we are. of
3825 primary concern is if the callback function had already
3826 verified the "magic" but hasn't yet set the completion
3827 variable. Since the completion variable is on our
3828 stack, we'll delay just a bit to make sure the data is
3829 still valid if that is the case */
3830 msleep(50);
3831 /* we'll now returned a cached value below */
3832 }
3833 }
3834 hddLog(LOGE, "iwpriv Full Power completed\n");
3835 break;
3836 }
3837 case 1: //Enable BMPS
3838 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3839 break;
3840 case 2: //Disable BMPS
3841 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3842 break;
3843 case 3: //Request Bmps
3844 {
3845 struct statsContext context;
3846 eHalStatus status;
3847
3848 init_completion(&context.completion);
3849
3850 context.pAdapter = pAdapter;
3851 context.magic = POWER_CONTEXT_MAGIC;
3852
3853 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3854 iw_power_callback_fn, &context);
3855 if(eHAL_STATUS_PMC_PENDING == status)
3856 {
3857 int lrc = wait_for_completion_interruptible_timeout(
3858 &context.completion,
3859 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3860 context.magic = 0;
3861 if (lrc <= 0)
3862 {
3863 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3864 "requesting BMPS",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003865 __func__, (0 == lrc) ? "timeout" :
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 "interrupt");
3867 /* there is a race condition such that the callback
3868 function could be executing at the same time we are. of
3869 primary concern is if the callback function had already
3870 verified the "magic" but hasn't yet set the completion
3871 variable. Since the completion variable is on our
3872 stack, we'll delay just a bit to make sure the data is
3873 still valid if that is the case */
3874 msleep(50);
3875 /* we'll now returned a cached value below */
3876 }
3877 }
3878 hddLog(LOGE, "iwpriv Request BMPS completed\n");
3879 break;
3880 }
3881 case 4: //Enable IMPS
3882 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3883 break;
3884 case 5: //Disable IMPS
3885 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3886 break;
3887 case 6: //Enable Standby
3888 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3889 break;
3890 case 7: //Disable Standby
3891 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3892 break;
3893 case 8: //Request Standby
3894#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003895#endif
3896 break;
3897 case 9: //Start Auto Bmps Timer
3898 sme_StartAutoBmpsTimer(hHal);
3899 break;
3900 case 10://Stop Auto BMPS Timer
3901 sme_StopAutoBmpsTimer(hHal);
3902 break;
3903#ifdef CONFIG_HAS_EARLYSUSPEND
3904 case 11://suspend to standby
3905#ifdef CONFIG_HAS_EARLYSUSPEND
3906 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3907 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3909#endif
3910 break;
3911 case 12://suspend to deep sleep
3912#ifdef CONFIG_HAS_EARLYSUSPEND
3913 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3914 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3916#endif
3917 break;
3918 case 13://resume from suspend
3919#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003920#endif
3921 break;
3922#endif
3923 case 14://reset wlan (power down/power up)
3924 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
3925 break;
3926 default:
3927 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL\n", set_value);
3928 ret = -EINVAL;
3929 break;
3930 }
3931 break;
3932 }
3933
3934 case WE_SET_MAX_ASSOC:
3935 {
3936 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
3937 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
3938 {
3939 ret = -EINVAL;
3940 }
3941 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
3942 set_value, NULL, eANI_BOOLEAN_FALSE)
3943 != eHAL_STATUS_SUCCESS )
3944 {
3945 ret = -EIO;
3946 }
3947 break;
3948 }
3949
3950 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
3951 {
3952 if( 0 == set_value )
3953 {
3954 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
3955 }
3956 else if ( 1 == set_value )
3957 {
3958 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
3959 }
3960 else
3961 {
3962 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL\n", set_value);
3963 ret = -EINVAL;
3964 }
3965 break;
3966 }
3967
3968 case WE_SET_DATA_INACTIVITY_TO:
3969 {
3970 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
3971 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
3972 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
3973 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
3974 set_value,
3975 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
3976 {
3977 hddLog(LOGE,"Failure: Could not pass on "
3978 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
3979 "to CCM\n");
3980 ret = -EINVAL;
3981 }
3982 break;
3983 }
3984 case WE_SET_MAX_TX_POWER:
3985 {
3986 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3987 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3988
3989 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
3990 __func__, set_value);
3991 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
3992 eHAL_STATUS_SUCCESS )
3993 {
3994 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
3995 __func__);
3996 return -EIO;
3997 }
3998
3999 break;
4000 }
4001 case WE_SET_HIGHER_DTIM_TRANSITION:
4002 {
4003 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4004 (set_value == eANI_BOOLEAN_TRUE)))
4005 {
4006 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4007 ret = -EINVAL;
4008 }
4009 else
4010 {
4011 if(pAdapter->higherDtimTransition != set_value)
4012 {
4013 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004014 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 }
4016 }
4017
4018 break;
4019 }
4020
4021 case WE_SET_TM_LEVEL:
4022 {
4023 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4024 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
4025 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4026
4027 break;
4028 }
4029
4030 default:
4031 {
4032 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d \n",
4033 sub_cmd, set_value);
4034 break;
4035 }
4036 }
4037
4038 return ret;
4039}
4040
4041/* set param sub-ioctls */
4042static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4043 union iwreq_data *wrqu, char *extra)
4044{
4045 VOS_STATUS vstatus;
4046 int sub_cmd = wrqu->data.flags;
4047 int ret = 0; /* success */
4048 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4049 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4050#ifdef WLAN_FEATURE_VOWIFI
4051 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4052#endif /* WLAN_FEATURE_VOWIFI */
4053
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received length %d", __func__, wrqu->data.length);
4055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004056
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004057 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4058 {
4059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4060 "%s:LOGP in Progress. Ignore!!!", __func__);
4061 return -EBUSY;
4062 }
4063
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 switch(sub_cmd)
4065 {
4066 case WE_WOWL_ADD_PTRN:
4067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004068 hdd_add_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 break;
4070 case WE_WOWL_DEL_PTRN:
4071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004072 hdd_del_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 break;
4074#if defined WLAN_FEATURE_VOWIFI
4075 case WE_NEIGHBOR_REPORT_REQUEST:
4076 {
4077 tRrmNeighborReq neighborReq;
4078 tRrmNeighborRspCallbackInfo callbackInfo;
4079
4080 if (pConfig->fRrmEnable)
4081 {
4082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request\n");
4083 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4084 if( !neighborReq.no_ssid )
4085 {
4086 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
4087 vos_mem_copy( neighborReq.ssid.ssId, wrqu->data.pointer, neighborReq.ssid.length );
4088 }
4089
4090 callbackInfo.neighborRspCallback = NULL;
4091 callbackInfo.neighborRspCallbackContext = NULL;
4092 callbackInfo.timeout = 5000; //5 seconds
4093 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4094 }
4095 else
4096 {
4097 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled\n", __func__);
4098 ret = -EINVAL;
4099 }
4100 }
4101 break;
4102#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 case WE_SET_AP_WPS_IE:
4104 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), wrqu->data.pointer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 case WE_SET_CONFIG:
4108 vstatus = hdd_execute_config_command(pHddCtx, wrqu->data.pointer);
4109 if (VOS_STATUS_SUCCESS != vstatus)
4110 {
4111 ret = -EINVAL;
4112 }
4113 break;
4114 default:
4115 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004116 hddLog(LOGE, "%s: Invalid sub command %d\n",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 ret = -EINVAL;
4118 break;
4119 }
4120 }
4121 return ret;
4122}
4123
4124/* get param sub-ioctls */
4125static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4126 union iwreq_data *wrqu, char *extra)
4127{
4128 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4129 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4130 int *value = (int *)extra;
4131 int ret = 0; /* success */
4132
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004133 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4134 {
4135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4136 "%s:LOGP in Progress. Ignore!!!", __func__);
4137 return -EBUSY;
4138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004139
4140 switch (value[0])
4141 {
4142 case WE_GET_11D_STATE:
4143 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004144 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304146
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4148
4149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),*value);
4150
4151 break;
4152 }
4153
4154 case WE_IBSS_STATUS:
4155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****\n");
4156 break;
4157
4158 case WE_PMC_STATE:
4159 {
4160 *value = pmcGetPmcState(hHal);
4161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%ld!!\n"),*value);
4162 break;
4163 }
4164 case WE_GET_WLAN_DBG:
4165 {
4166 vos_trace_display();
4167 *value = 0;
4168 break;
4169 }
4170 case WE_MODULE_DOWN_IND:
4171 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4174#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4177#endif
4178 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4179
4180 *value = 0;
4181 break;
4182 }
4183 case WE_GET_MAX_ASSOC:
4184 {
4185 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4186 {
4187 ret = -EIO;
4188 }
4189 break;
4190 }
4191
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 case WE_GET_WDI_DBG:
4193 {
4194 wpalTraceDisplay();
4195 *value = 0;
4196 break;
4197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004198
4199 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4200 {
4201 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4202 break;
4203 }
4204 case WE_GET_CONCURRENCY_MODE:
4205 {
4206 *value = hdd_get_concurrency_mode ( );
4207
4208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d \n"),*value);
4209 break;
4210 }
4211
4212 default:
4213 {
4214 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4215 break;
4216 }
4217 }
4218
4219 return ret;
4220}
4221
4222/* set param sub-ioctls */
4223int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4224 union iwreq_data *wrqu, char *extra)
4225{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004226 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 int *value = (int *)extra;
4228 int sub_cmd = value[0];
4229 int ret = 0;
4230
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004231 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4232 {
4233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4234 "%s:LOGP in Progress. Ignore!!!", __func__);
4235 return -EBUSY;
4236 }
4237
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 switch(sub_cmd)
4239 {
4240 case WE_SET_WLAN_DBG:
4241 {
4242 vos_trace_setValue( value[1], value[2], value[3]);
4243 break;
4244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 case WE_SET_WDI_DBG:
4246 {
4247 wpalTraceSetLevel( value[1], value[2], value[3]);
4248 break;
4249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 case WE_SET_SAP_CHANNELS:
4251 {
4252 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4253 break;
4254 }
4255
4256 default:
4257 {
4258 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4259 break;
4260 }
4261 }
4262 return ret;
4263}
4264
4265static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4266 union iwreq_data *wrqu, char *extra)
4267{
4268 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4269 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004270#ifdef WLAN_FEATURE_11W
4271 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4272#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004273
Yue Ma3ede6052013-08-29 00:33:26 -07004274 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4275 {
4276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4277 "%s: HDD Context is NULL!", __func__);
4278
4279 return -EINVAL;
4280 }
4281
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004282 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4283 {
4284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4285 "%s:LOGP in Progress. Ignore!!!", __func__);
4286 return -EBUSY;
4287 }
4288
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 switch(sub_cmd)
4290 {
4291 case WE_WLAN_VERSION:
4292 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004293 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 break;
4295 }
4296
4297 case WE_GET_STATS:
4298 {
4299 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4300 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4301 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4302
4303 snprintf(extra, WE_MAX_STR_LEN,
4304 "\nTransmit"
4305 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4306 "\n dropped BK %u, BE %u, VI %u, VO %u"
4307 "\n classified BK %u, BE %u, VI %u, VO %u"
4308 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4309 "\n queued BK %u, BE %u, VI %u, VO %u"
4310 "\nfetched %u, empty %u, lowres %u, deqerr %u"
4311 "\ndequeued %u, depressured %u, completed %u, flushed %u"
4312 "\n fetched BK %u, BE %u, VI %u, VO %u"
4313 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4314 "\n depressured BK %u, BE %u, VI %u, VO %u"
4315 "\n flushed BK %u, BE %u, VI %u, VO %u"
4316 "\n\nReceive"
4317 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4318 "\n\nResetsStats"
4319 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4320 "\n",
4321 pStats->txXmitCalled,
4322 pStats->txXmitDropped,
4323 pStats->txXmitBackPressured,
4324 pStats->txXmitQueued,
4325
4326 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4327 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4328 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4329 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4330
4331 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4332 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4333 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4334 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4335
4336 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4337 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4338 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4339 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4340
4341 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4342 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4343 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4344 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4345
4346 pStats->txFetched,
4347 pStats->txFetchEmpty,
4348 pStats->txFetchLowResources,
4349 pStats->txFetchDequeueError,
4350
4351 pStats->txFetchDequeued,
4352 pStats->txFetchDePressured,
4353 pStats->txCompleted,
4354 pStats->txFlushed,
4355
4356 pStats->txFetchedAC[WLANTL_AC_BK],
4357 pStats->txFetchedAC[WLANTL_AC_BE],
4358 pStats->txFetchedAC[WLANTL_AC_VI],
4359 pStats->txFetchedAC[WLANTL_AC_VO],
4360
4361 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4362 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4363 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4364 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4365
4366 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4367 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4368 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4369 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4370
4371 pStats->txFlushedAC[WLANTL_AC_BK],
4372 pStats->txFlushedAC[WLANTL_AC_BE],
4373 pStats->txFlushedAC[WLANTL_AC_VI],
4374 pStats->txFlushedAC[WLANTL_AC_VO],
4375
4376 pStats->rxChains,
4377 pStats->rxPackets,
4378 pStats->rxDropped,
4379 pStats->rxDelivered,
4380 pStats->rxRefused,
4381
4382 pResetStats->totalLogpResets,
4383 pResetStats->totalCMD53Failures,
4384 pResetStats->totalMutexReadFailures,
4385 pResetStats->totalMIFErrorFailures,
4386 pResetStats->totalFWHearbeatFailures,
4387 pResetStats->totalUnknownExceptions
4388 );
4389 wrqu->data.length = strlen(extra)+1;
4390 break;
4391 }
4392
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304393/* The case prints the current state of the HDD, SME, CSR, PE, TL
4394 *it can be extended for WDI Global State as well.
4395 *And currently it only checks P2P_CLIENT adapter.
4396 *P2P_DEVICE and P2P_GO have not been added as of now.
4397*/
4398 case WE_GET_STATES:
4399 {
4400 int buf = 0, len = 0;
4401 int adapter_num = 0;
4402 int count = 0, check = 1;
4403
4404 tANI_U16 tlState;
4405 tHalHandle hHal;
4406 tpAniSirGlobal pMac;
4407 hdd_station_ctx_t *pHddStaCtx;
4408
4409 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4410 hdd_adapter_t *useAdapter = NULL;
4411
4412 /* Print wlan0 or p2p0 states based on the adapter_num
4413 *by using the correct adapter
4414 */
4415 while ( adapter_num < 2 )
4416 {
4417 if ( WLAN_ADAPTER == adapter_num )
4418 {
4419 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004420 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304421 "\n\n wlan0 States:-");
4422 len += buf;
4423 }
4424 else if ( P2P_ADAPTER == adapter_num )
4425 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004426 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304427 "\n\n p2p0 States:-");
4428 len += buf;
4429
4430 if( !pHddCtx )
4431 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004432 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304433 "\n pHddCtx is NULL");
4434 len += buf;
4435 break;
4436 }
4437
4438 /*Printing p2p0 states only in the case when the device is
4439 configured as a p2p_client*/
4440 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4441 if ( !useAdapter )
4442 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004443 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304444 "\n Device not configured as P2P_CLIENT.");
4445 len += buf;
4446 break;
4447 }
4448 }
4449
4450 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
4451 pMac = PMAC_STRUCT( hHal );
4452 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4453 if( !pHddStaCtx )
4454 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004455 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304456 "\n pHddStaCtx is NULL");
4457 len += buf;
4458 break;
4459 }
4460
4461 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4462
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004463 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304464 "\n HDD Conn State - %s "
4465 "\n \n SME State:"
4466 "\n Neighbour Roam State - %s"
4467 "\n CSR State - %s"
4468 "\n CSR Substate - %s"
4469 "\n \n TL STA %d State: %s",
4470 macTraceGetHDDWlanConnState(
4471 pHddStaCtx->conn_info.connState),
4472 macTraceGetNeighbourRoamState(
4473 pMac->roam.neighborRoamInfo.neighborRoamState),
4474 macTraceGetcsrRoamState(
4475 pMac->roam.curState[useAdapter->sessionId]),
4476 macTraceGetcsrRoamSubState(
4477 pMac->roam.curSubState[useAdapter->sessionId]),
4478 pHddStaCtx->conn_info.staId[0],
4479 macTraceGetTLState(tlState)
4480 );
4481 len += buf;
4482 adapter_num++;
4483 }
4484
4485 /* Printing Lim State starting with global lim states */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004486 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304487 "\n \n LIM STATES:-"
4488 "\n Global Sme State - %s "\
4489 "\n Global mlm State - %s "\
4490 "\n",
4491 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4492 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4493 );
4494 len += buf;
4495
4496 /*printing the PE Sme and Mlm states for valid lim sessions*/
4497 while ( check < 3 && count < 255)
4498 {
4499 if ( pMac->lim.gpSession[count].valid )
4500 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004501 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304502 "\n Lim Valid Session %d:-"
4503 "\n PE Sme State - %s "
4504 "\n PE Mlm State - %s "
4505 "\n",
4506 check,
4507 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4508 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4509 );
4510
4511 len += buf;
4512 check++;
4513 }
4514 count++;
4515 }
4516
4517 wrqu->data.length = strlen(extra)+1;
4518 break;
4519 }
4520
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 case WE_GET_CFG:
4522 {
4523 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4524 wrqu->data.length = strlen(extra)+1;
4525 break;
4526 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004527#ifdef WLAN_FEATURE_11AC
4528 case WE_GET_RSSI:
4529 {
4530 v_S7_t s7Rssi = 0;
4531 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4532 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4533 wrqu->data.length = strlen(extra)+1;
4534 break;
4535 }
4536#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304537
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004538#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4539 case WE_GET_ROAM_RSSI:
4540 {
4541 v_S7_t s7Rssi = 0;
4542 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4543 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4544 wrqu->data.length = strlen(extra)+1;
4545 break;
4546 }
4547#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 case WE_GET_WMM_STATUS:
4549 {
4550 snprintf(extra, WE_MAX_STR_LEN,
4551 "\nDir: 0=up, 1=down, 3=both\n"
4552 "|------------------------|\n"
4553 "|AC | ACM |Admitted| Dir |\n"
4554 "|------------------------|\n"
4555 "|VO | %d | %3s | %d |\n"
4556 "|VI | %d | %3s | %d |\n"
4557 "|BE | %d | %3s | %d |\n"
4558 "|BK | %d | %3s | %d |\n"
4559 "|------------------------|\n",
4560 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4561 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4562 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4563 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4564 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4565 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4566 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4567 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4568 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4569 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4570 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4571 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4572
Jeff Johnsone7245742012-09-05 17:12:55 -07004573
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 wrqu->data.length = strlen(extra)+1;
4575 break;
4576 }
4577 case WE_GET_CHANNEL_LIST:
4578 {
4579 VOS_STATUS status;
4580 v_U8_t i, len;
4581 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004582
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 tChannelListInfo channel_list;
4584
4585 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
4586 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4587 {
4588 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!\n",__func__);
4589 return -EINVAL;
4590 }
4591 buf = extra;
4592
4593 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004594 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4595 * needed = 5 * number of channels. Check ifsufficient
4596 * buffer is available and then proceed to fill the buffer.
4597 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4599 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004600 hddLog(VOS_TRACE_LEVEL_ERROR,
4601 "%s Insufficient Buffer to populate channel list\n",
4602 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 return -EINVAL;
4604 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004605 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4606 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 for(i = 0 ; i < channel_list.num_channels; i++)
4608 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004609 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 }
4612 wrqu->data.length = strlen(extra)+1;
4613
4614 break;
4615 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004616#ifdef FEATURE_WLAN_TDLS
4617 case WE_GET_TDLS_PEERS:
4618 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004619 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004620 break;
4621 }
4622#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004623#ifdef WLAN_FEATURE_11W
4624 case WE_GET_11W_INFO:
4625 {
4626 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4627
4628 snprintf(extra, WE_MAX_STR_LEN,
4629 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4630 "\n Number of Unprotected Disassocs %d"
4631 "\n Number of Unprotected Deauths %d",
4632 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4633 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4634 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4635 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4636 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4637
4638 wrqu->data.length = strlen(extra)+1;
4639 break;
4640 }
4641#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304642 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 {
4644 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4645 break;
4646 }
4647 }
4648
4649 return 0;
4650}
4651
4652/* action sub-ioctls */
4653static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4654 union iwreq_data *wrqu, char *extra)
4655{
4656 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4657 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004658 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004659
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004660 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4661 {
4662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4663 "%s:LOGP in Progress. Ignore!!!", __func__);
4664 return -EBUSY;
4665 }
4666
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 switch (sub_cmd)
4668 {
4669 case WE_CLEAR_STATS:
4670 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4673 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4674 break;
4675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 case WE_INIT_AP:
4677 {
4678 pr_info("Init AP trigger\n");
4679 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4680 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4681 break;
4682 }
4683 case WE_STOP_AP:
4684 {
4685 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
4686 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
4687 * this is a dead code and need to find the adpater by name rather than mode */
4688 hdd_adapter_t* pAdapter_to_stop =
4689 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
4690 if( pAdapter_to_stop )
4691 {
4692 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4693
4694 pr_info("Stopping AP mode\n");
4695
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05304696 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4697 {
4698 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
4699 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
4700 }
4701
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 /*Make sure that pAdapter cleaned properly*/
4703 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
4704 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
4705 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
4706
4707 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
4708 pAdapter_to_stop->macAddressCurrent.bytes);
4709 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
4710 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05304711
4712 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4713 {
4714 /* put the device back into BMPS */
4715 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
4716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 }
4718 else
4719 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08004720 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 }
4722
4723 break;
4724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004725#ifdef WLAN_BTAMP_FEATURE
4726 case WE_ENABLE_AMP:
4727 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 WLANBAP_RegisterWithHCI(pAdapter);
4730 break;
4731 }
4732 case WE_DISABLE_AMP:
4733 {
4734 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4735 VOS_STATUS status;
4736
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004738
4739 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4740 status = WLANBAP_StopAmp();
4741 if(VOS_STATUS_SUCCESS != status )
4742 {
4743 pHddCtx->isAmpAllowed = VOS_TRUE;
4744 hddLog(VOS_TRACE_LEVEL_FATAL,
4745 "%s: Failed to stop AMP", __func__);
4746 }
4747 else
4748 {
4749 //a state m/c implementation in PAL is TBD to avoid this delay
4750 msleep(500);
4751 pHddCtx->isAmpAllowed = VOS_FALSE;
4752 WLANBAP_DeregisterFromHCI();
4753 }
4754
4755 break;
4756 }
4757#endif
4758
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004759 case WE_ENABLE_DXE_STALL_DETECT:
4760 {
schang6295e542013-03-12 15:31:23 -07004761 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4762 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004763 break;
4764 }
4765 case WE_DISPLAY_DXE_SNAP_SHOT:
4766 {
schang6295e542013-03-12 15:31:23 -07004767 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4768 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004769 break;
4770 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304771 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
4772 {
4773 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
4774 hdd_wmm_tx_snapshot(pAdapter);
4775 WLANTL_TLDebugMessage(VOS_TRUE);
4776 break;
4777 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07004778 case WE_SET_REASSOC_TRIGGER:
4779 {
4780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4781 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
4782 v_U32_t roamId = 0;
4783 tCsrRoamModifyProfileFields modProfileFields;
4784 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
4785 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
4786 return 0;
4787 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304788
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004789
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 default:
4791 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004792 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 break;
4794 }
4795 }
4796
4797 return ret;
4798}
4799
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304800void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
4801{
4802 /*
4803 * Function to display HDD WMM information
4804 * for Tx Queues.
4805 * Prints globala as well as per client depending
4806 * whether the clients are registered or not.
4807 */
4808 int i = 0, j = 0;
4809 for ( i=0; i< NUM_TX_QUEUES; i++)
4810 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304811 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304812 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:0x%x, NextAddress:0x%x",
4813 i, pAdapter->wmm_tx_queue[i].count,
4814 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304815 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304816 }
4817
4818 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
4819 {
4820 if(pAdapter->aStaInfo[i].isUsed)
4821 {
4822 hddLog(LOGE, "******STAIndex: %d*********", i);
4823 for ( j=0; j< NUM_TX_QUEUES; j++)
4824 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304825 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304826 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:0x%x, NextAddress:0x%x",
4827 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
4828 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
4829 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304830 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304831 }
4832 }
4833 }
4834
4835}
Jeff Johnson295189b2012-06-20 16:38:30 -07004836int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4837 union iwreq_data *wrqu, char *extra)
4838{
4839 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4840 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4841 int sub_cmd = wrqu->data.flags;
4842 int *value = (int*)wrqu->data.pointer;
4843 int apps_args[MAX_VAR_ARGS] = {0};
4844 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004845 hdd_station_ctx_t *pStaCtx = NULL ;
4846 hdd_ap_ctx_t *pAPCtx = NULL;
4847 int cmd = 0;
4848 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004849
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004850 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004851
4852 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4853 {
4854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4855 "%s:LOGP in Progress. Ignore!!!", __func__);
4856 return -EBUSY;
4857 }
4858
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 if (num_args > MAX_VAR_ARGS)
4860 {
4861 num_args = MAX_VAR_ARGS;
4862 }
4863 vos_mem_copy(apps_args, value, (sizeof(int)) * num_args);
4864
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004865 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
4866 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
4867 {
4868 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
4869 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
4870 {
4871 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4872 staId = pStaCtx->conn_info.staId[0];
4873 }
4874 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
4875 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
4876 {
4877 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4878 staId = pAPCtx->uBCStaId;
4879 }
4880 else
4881 {
4882 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
4883 return 0;
4884 }
4885 }
4886
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 switch (sub_cmd)
4888 {
4889 case WE_LOG_DUMP_CMD:
4890 {
4891 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004892 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 apps_args[3], apps_args[4]);
4894
4895 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
4896 apps_args[3], apps_args[4]);
4897
4898 }
4899 break;
4900
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 case WE_P2P_NOA_CMD:
4902 {
4903 p2p_app_setP2pPs_t p2pNoA;
4904
4905 p2pNoA.opp_ps = apps_args[0];
4906 p2pNoA.ctWindow = apps_args[1];
4907 p2pNoA.duration = apps_args[2];
4908 p2pNoA.interval = apps_args[3];
4909 p2pNoA.count = apps_args[4];
4910 p2pNoA.single_noa_duration = apps_args[5];
4911 p2pNoA.psSelection = apps_args[6];
4912
4913 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
4914 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004915 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
4917
4918 hdd_setP2pPs(dev, &p2pNoA);
4919
4920 }
4921 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004922
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004923 case WE_MCC_CONFIG_CREDENTIAL :
4924 {
4925 cmd = 287; //Command should be updated if there is any change
4926 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08004927 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004928 {
4929 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
4930 }
4931 else
4932 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304933 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160\n", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004934 return 0;
4935 }
4936 }
4937 break;
4938
4939 case WE_MCC_CONFIG_PARAMS :
4940 {
4941 cmd = 288; //command Should be updated if there is any change
4942 // in the Riva dump command
4943 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
4944 }
4945 break;
4946
Chilam NG571c65a2013-01-19 12:27:36 +05304947#ifdef FEATURE_WLAN_TDLS
4948 case WE_TDLS_CONFIG_PARAMS :
4949 {
4950 tdls_config_params_t tdlsParams;
4951
Chilam Ng01120412013-02-19 18:32:21 -08004952 tdlsParams.tdls = apps_args[0];
4953 tdlsParams.tx_period_t = apps_args[1];
4954 tdlsParams.tx_packet_n = apps_args[2];
4955 tdlsParams.discovery_period_t = apps_args[3];
4956 tdlsParams.discovery_tries_n = apps_args[4];
4957 tdlsParams.idle_timeout_t = apps_args[5];
4958 tdlsParams.idle_packet_n = apps_args[6];
4959 tdlsParams.rssi_hysteresis = apps_args[7];
4960 tdlsParams.rssi_trigger_threshold = apps_args[8];
4961 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05304962
Chilam Ng01120412013-02-19 18:32:21 -08004963 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05304964 }
4965 break;
4966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 default:
4968 {
4969 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
4970 }
4971 break;
4972 }
4973
4974 return 0;
4975}
4976
4977
4978static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
4979 union iwreq_data *wrqu, char *extra)
4980{
4981 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4982 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4983 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4984 int params[HDD_WLAN_WMM_PARAM_COUNT];
4985 sme_QosWmmTspecInfo tSpec;
4986 v_U32_t handle;
4987
4988 // make sure the application is sufficiently priviledged
4989 // note that the kernel will do this for "set" ioctls, but since
4990 // this ioctl wants to return status to user space it must be
4991 // defined as a "get" ioctl
4992 if (!capable(CAP_NET_ADMIN))
4993 {
4994 return -EPERM;
4995 }
4996
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004997 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4998 {
4999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5000 "%s:LOGP in Progress. Ignore!!!", __func__);
5001 return -EBUSY;
5002 }
5003
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 // we must be associated in order to add a tspec
5005 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5006 {
5007 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5008 return 0;
5009 }
5010
5011 // since we are defined to be a "get" ioctl, and since the number
5012 // of params exceeds the number of params that wireless extensions
5013 // will pass down in the iwreq_data, we must copy the "set" params
5014 // from user space ourselves
5015 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5016 {
5017 // hmmm, can't get them
5018 return -EIO;
5019 }
5020
5021 // clear the tspec
5022 memset(&tSpec, 0, sizeof(tSpec));
5023
5024 // validate the handle
5025 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5026 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5027 {
5028 // that one is reserved
5029 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5030 return 0;
5031 }
5032
5033 // validate the TID
5034 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5035 {
5036 // out of range
5037 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5038 return 0;
5039 }
5040 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5041
5042 // validate the direction
5043 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5044 {
5045 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5046 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5047 break;
5048
5049 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5050 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5051 break;
5052
5053 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5054 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5055 break;
5056
5057 default:
5058 // unknown
5059 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5060 return 0;
5061 }
5062
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305063 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5064
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 // validate the user priority
5066 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5067 {
5068 // out of range
5069 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5070 return 0;
5071 }
5072 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
5073
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5075 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5076 tSpec.ts_info.psb, tSpec.ts_info.up);
5077
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5079 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5080 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5081 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5082 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5083 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5084 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5085 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5086 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5087 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5088 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5089 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5090
5091 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5092
5093 // validate the ts info ack policy
5094 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5095 {
5096 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5097 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5098 break;
5099
5100 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5101 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5102 break;
5103
5104 default:
5105 // unknown
5106 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5107 return 0;
5108 }
5109
5110 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5111 return 0;
5112}
5113
5114
5115static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5116 union iwreq_data *wrqu, char *extra)
5117{
5118 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5119 int *params = (int *)extra;
5120 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5121 v_U32_t handle;
5122
5123 // make sure the application is sufficiently priviledged
5124 // note that the kernel will do this for "set" ioctls, but since
5125 // this ioctl wants to return status to user space it must be
5126 // defined as a "get" ioctl
5127 if (!capable(CAP_NET_ADMIN))
5128 {
5129 return -EPERM;
5130 }
5131
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005132 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5133 {
5134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5135 "%s:LOGP in Progress. Ignore!!!", __func__);
5136 return -EBUSY;
5137 }
5138
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 // although we are defined to be a "get" ioctl, the params we require
5140 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5141 // is no need to copy the params from user space
5142
5143 // validate the handle
5144 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5145 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5146 {
5147 // that one is reserved
5148 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5149 return 0;
5150 }
5151
5152 *pStatus = hdd_wmm_delts(pAdapter, handle);
5153 return 0;
5154}
5155
5156
5157static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5158 union iwreq_data *wrqu, char *extra)
5159{
5160 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5161 int *params = (int *)extra;
5162 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5163 v_U32_t handle;
5164
5165 // although we are defined to be a "get" ioctl, the params we require
5166 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5167 // is no need to copy the params from user space
5168
5169 // validate the handle
5170 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5171 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5172 {
5173 // that one is reserved
5174 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5175 return 0;
5176 }
5177
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005178 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5179 {
5180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5181 "%s:LOGP in Progress. Ignore!!!", __func__);
5182 return -EBUSY;
5183 }
5184
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5186 return 0;
5187}
5188
5189
5190#ifdef FEATURE_WLAN_WAPI
5191static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5192 union iwreq_data *wrqu, char *extra)
5193{
5194 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5195 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5196 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5197 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5198
5199 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)wrqu->data.pointer;
5200
5201 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005202 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5203 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5204 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005206 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5207 {
5208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5209 "%s:LOGP in Progress. Ignore!!!", __func__);
5210 return -EBUSY;
5211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005212
5213 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005214 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5216 pRoamProfile->EncryptionType.numEntries = 1;
5217 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5218 pRoamProfile->mcEncryptionType.numEntries = 1;
5219 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5220
5221 pRoamProfile->AuthType.numEntries = 1;
5222 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5223 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5224 }
5225 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005226 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 }
5228 else
5229 return -EINVAL;
5230
5231 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5232
5233 return 0;
5234}
5235
5236static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5237 union iwreq_data *wrqu, char *extra)
5238{
5239 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5240 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5241
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005242 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5243 {
5244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5245 "%s:LOGP in Progress. Ignore!!!", __func__);
5246 return -EBUSY;
5247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5249
5250 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005251 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
5253 return 0;
5254}
5255
5256static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5257 union iwreq_data *wrqu, char *extra)
5258{
5259 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5260// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5261 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5262 int i = 0, j = 0;
5263 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005264 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5265 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5266 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005267
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005268 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5269 {
5270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5271 "%s:LOGP in Progress. Ignore!!!", __func__);
5272 return -EBUSY;
5273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 VOS_ASSERT(pWapiAssocInfo);
5275
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005276 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x\n",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
5277 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 for(i =0 ; i < 16 ; i++)
5279 hddLog(LOG1,"akm suite[%02d]:0x%08lx",i,pWapiAssocInfo->akmSuite[i]);
5280
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005281 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 for(i =0 ; i < 16 ; i++)
5283 hddLog(LOG1, "Unicast suite[%02d]:0x%08lx",i,pWapiAssocInfo->unicastSuite[i]);
5284
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005285 hddLog(LOG1,"%s: Multicast suite:0x%08lx Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
5286 hddLog(LOG1, "%s: BKID Cnt:0x%04x\n",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 for(i = 0 ; i < 16 ; i++) {
5288 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5289 for(j = 0 ; j < 16 ; j++)
5290 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5291 }
5292
5293 /* We are not using the entire IE as provided by the supplicant.
5294 * This is being calculated by SME. This is the same as in the
5295 * case of WPA. Only the auth mode information needs to be
5296 * extracted here*/
5297 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005298 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5300 }
5301
5302 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005303 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5305 }
5306 return 0;
5307}
5308
5309static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5310 union iwreq_data *wrqu, char *extra)
5311{
5312 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5313 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5314 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5315 tANI_U32 roamId = 0xFF;
5316 tANI_U8 *pKeyPtr = NULL;
5317 v_BOOL_t isConnected = TRUE;
5318 tCsrRoamSetKey setKey;
5319 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5321
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005322 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5323 {
5324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5325 "%s:LOGP in Progress. Ignore!!!", __func__);
5326 return -EBUSY;
5327 }
5328
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005330 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5331 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5332 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005333
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305334 hddLog(LOG1,":%s: INPUT DATA:\nKey Type:0x%02x Key Direction:0x%02x KEY ID:0x%02x\n", __func__, pWapiKey->keyType, pWapiKey->keyDirection, pWapiKey->keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 hddLog(LOG1,"Add Index:0x");
5336 for(i =0 ; i < 12 ; i++)
5337 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5338
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005339 hddLog(LOG1,"\n%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5341 for(i =0 ; i < 16 ; i++)
5342 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5343
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005344 hddLog(LOG1,"\n%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5346 for(i =0 ; i < 16 ; i++)
5347 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5348
5349 hddLog(LOG1,"\nWAPI PN NUMBER:0x");
5350 for(i = 0 ; i < 16 ; i++)
5351 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5352
5353 // Clear the setkey memory
5354 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5355 // Store Key ID
5356 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5357 // SET WAPI Encryption
5358 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5359 // Key Directionn both TX and RX
5360 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5361 // the PAE role
5362 setKey.paeRole = 0 ;
5363
5364 switch ( pWapiKey->keyType )
5365 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005366 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 {
5368 isConnected = hdd_connIsConnected(pHddStaCtx);
5369 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5370 break;
5371 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005372 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 {
5374 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5375 break;
5376 }
5377 default:
5378 {
5379 //Any other option is invalid.
5380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005381 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005382
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005383 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5385 break; // NEED RETURN FROM HERE ????
5386 }
5387 }
5388
5389 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5390 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5391 pKeyPtr = setKey.Key;
5392 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5393 pKeyPtr += pWapiKey->wpiekLen;
5394 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5395
5396 // Set the new key with SME.
5397 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5398
5399 if ( isConnected ) {
5400 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5401 if ( halStatus != eHAL_STATUS_SUCCESS )
5402 {
5403 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5404 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5405
5406 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5407 }
5408 }
5409#if 0 /// NEED TO CHECK ON THIS
5410 else
5411 {
5412 // Store the keys in the adapter to be moved to the profile & passed to
5413 // SME in the ConnectRequest if we are not yet in connected state.
5414 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5415 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5416
5417 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5418 " Saving key [idx= %d] to apply when moving to connected state ",
5419 setKey.keyId );
5420
5421 }
5422#endif
5423 return halStatus;
5424}
5425
5426static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5427 union iwreq_data *wrqu, char *extra)
5428{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005430#ifdef WLAN_DEBUG
5431 int i = 0;
5432 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) (wrqu->data.pointer);
5433#endif
5434
5435 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005436 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5437 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5438 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005439
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005440 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08lx\n", __func__,pBkid->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 hddLog(LOG1,"%s: BKID Cnt:0x%04lx",pBkid->BKIDCount);
5442
5443 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005444
5445 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5446 {
5447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5448 "%s:LOGP in Progress. Ignore!!!", __func__);
5449 return -EBUSY;
5450 }
5451
Jeff Johnson295189b2012-06-20 16:38:30 -07005452#ifdef WLAN_DEBUG
5453 for(i =0 ; i < 16 ; i++)
5454 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5455#endif
5456
5457 return 0;
5458}
5459
5460static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5461 union iwreq_data *wrqu, char *extra)
5462{
5463 /* Yet to implement this function, 19th April 2010 */
5464 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5465
5466 return 0;
5467}
5468#endif /* FEATURE_WLAN_WAPI */
5469
5470#ifdef WLAN_FEATURE_VOWIFI_11R
5471//
5472//
5473// Each time the supplicant has the auth_request or reassoc request
5474// IEs ready. This is pushed to the driver. The driver will inturn use
5475// it to send out the auth req and reassoc req for 11r FT Assoc.
5476//
5477static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5478 union iwreq_data *wrqu, char *extra)
5479{
5480 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5481 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5482 //v_CONTEXT_t pVosContext;
5483
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005484 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5485 {
5486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5487 "%s:LOGP in Progress. Ignore!!!", __func__);
5488 return -EBUSY;
5489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 if (!wrqu->data.length)
5491 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305492 hddLog(LOGE, FL("called with 0 length IEs\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 return -EINVAL;
5494 }
5495 if (wrqu->data.pointer == NULL)
5496 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305497 hddLog(LOGE, FL("called with NULL IE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 return -EINVAL;
5499 }
5500
5501 // Added for debug on reception of Re-assoc Req.
5502 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5503 {
5504 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
5505 wrqu->data.length);
5506 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
5507 }
5508
5509#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
5510 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, wrqu->data.length);
5511#endif
5512
5513 // Pass the received FT IEs to SME
5514 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, wrqu->data.pointer,
5515 wrqu->data.length);
5516
5517 return 0;
5518}
5519#endif
5520
Amar Singhalf3a6e762013-02-19 15:06:50 -08005521static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005522 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005524{
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005526 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)wrqu->data.pointer;
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005528 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005529 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005530 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5531 int idx;
5532 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005533
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005534 if (pHddCtx->isLogpInProgress)
5535 {
5536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5537 "%s:LOGP in Progress. Ignore!!!", __func__);
5538 return -EBUSY;
5539 }
5540
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305541 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5542 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305543#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005544
Amar Singhalf3a6e762013-02-19 15:06:50 -08005545 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5546 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005547 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005548 hddLog(VOS_TRACE_LEVEL_ERROR,
5549 "%s: vos_mem_alloc failed", __func__);
5550 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005551 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005552
5553 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5554
5555 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5556 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5557
5558 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5559 mc_addr_list_ptr->ulMulticastAddrCnt);
5560
5561 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005562 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005563 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5564 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5565
5566 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5567 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005568 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005569
Amar Singhalf3a6e762013-02-19 15:06:50 -08005570 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5571 vos_mem_free(mc_addr_list_ptr);
5572 if (eHAL_STATUS_SUCCESS != ret_val)
5573 {
5574 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5575 __func__);
5576 return -EINVAL;
5577 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305578#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305579 }
5580 else
5581 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005582
Amar Singhalf3a6e762013-02-19 15:06:50 -08005583 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5584 "%s: Set MC BC Filter Config request: %d suspend %d",
5585 __func__, pRequest->mcastBcastFilterSetting,
5586 pHddCtx->hdd_wlan_suspended);
5587
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305588 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005589
5590 if (pHddCtx->hdd_wlan_suspended)
5591 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005592 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5593 if (NULL == wlanRxpFilterParam)
5594 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305595 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005596 "%s: vos_mem_alloc failed", __func__);
5597 return -EINVAL;
5598 }
5599
Amar Singhalf3a6e762013-02-19 15:06:50 -08005600 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5601 pRequest->mcastBcastFilterSetting;
5602 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5603
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305604 hdd_conf_hostoffload(pAdapter, TRUE);
5605 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5606 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005607
5608 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5609 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305610 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08005611 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5612 wlanRxpFilterParam->setMcstBcstFilter);
5613
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305614 if (eHAL_STATUS_SUCCESS !=
5615 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5616 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08005617 {
5618 hddLog(VOS_TRACE_LEVEL_ERROR,
5619 "%s: Failure to execute set HW MC/BC Filter request",
5620 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005621 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005622 return -EINVAL;
5623 }
5624
Amar Singhalf3a6e762013-02-19 15:06:50 -08005625 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005627
5628 return 0;
5629}
5630
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005631static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
5632 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 union iwreq_data *wrqu, char *extra)
5634{
5635 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5636 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305637 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005638 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005639
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305640 //Reset the filter to INI value as we have to clear the dynamic filter
5641 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005642
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305643 //Configure FW with new setting
5644 if (pHddCtx->hdd_wlan_suspended)
5645 {
5646 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5647 if (NULL == wlanRxpFilterParam)
5648 {
5649 hddLog(VOS_TRACE_LEVEL_ERROR,
5650 "%s: vos_mem_alloc failed", __func__);
5651 return -EINVAL;
5652 }
5653
5654 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5655 pHddCtx->configuredMcastBcastFilter;
5656 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5657
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305658 hdd_conf_hostoffload(pAdapter, TRUE);
5659 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5660 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305661
5662 if (eHAL_STATUS_SUCCESS !=
5663 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5664 wlanRxpFilterParam))
5665 {
5666 hddLog(VOS_TRACE_LEVEL_ERROR,
5667 "%s: Failure to execute set HW MC/BC Filter request",
5668 __func__);
5669 vos_mem_free(wlanRxpFilterParam);
5670 return -EINVAL;
5671 }
5672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 return 0;
5674}
5675
5676static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
5677 union iwreq_data *wrqu, char *extra)
5678{
5679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5680 tpHostOffloadRequest pRequest = (tpHostOffloadRequest)wrqu->data.pointer;
5681 tSirHostOffloadReq offloadRequest;
5682
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005683 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5684 {
5685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5686 "%s:LOGP in Progress. Ignore!!!", __func__);
5687 return -EBUSY;
5688 }
5689
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 /* Debug display of request components. */
5691 switch (pRequest->offloadType)
5692 {
5693 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005694 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 switch (pRequest->enableOrDisable)
5696 {
5697 case WLAN_OFFLOAD_DISABLE:
5698 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
5699 break;
5700 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
5701 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
5702 case WLAN_OFFLOAD_ENABLE:
5703 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
5704 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
5705 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
5706 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
5707 }
5708 break;
5709
5710 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
5711 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005712 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 switch (pRequest->enableOrDisable)
5714 {
5715 case WLAN_OFFLOAD_DISABLE:
5716 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
5717 break;
5718 case WLAN_OFFLOAD_ENABLE:
5719 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
5720 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
5721 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
5722 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
5723 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
5724 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
5725 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
5726 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
5727 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
5728 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
5729 }
5730 }
5731
5732 /* Execute offload request. The reason that we can copy the request information
5733 from the ioctl structure to the SME structure is that they are laid out
5734 exactly the same. Otherwise, each piece of information would have to be
5735 copied individually. */
5736 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07005737 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
5738 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 {
5740 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request\n",
5741 __func__);
5742 return -EINVAL;
5743 }
5744
5745 return 0;
5746}
5747
5748static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
5749 union iwreq_data *wrqu, char *extra)
5750{
5751 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5752 tpKeepAliveRequest pRequest = (tpKeepAliveRequest)wrqu->data.pointer;
5753 tSirKeepAliveReq keepaliveRequest;
5754
5755 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5756 {
5757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005758 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 return 0;
5760 }
5761
5762 /* Debug display of request components. */
5763 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Keep Alive Request : TimePeriod %d size %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005764 __func__,pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005765
5766 switch (pRequest->packetType)
5767 {
5768 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005769 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 break;
5771
5772 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
5773
5774 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005775 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005776
5777 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
5778 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
5779 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
5780
5781 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
5782 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
5783 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
5784
5785 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
5786 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
5787 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
5788 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
5789 break;
5790
5791 }
5792
5793 /* Execute keep alive request. The reason that we can copy the request information
5794 from the ioctl structure to the SME structure is that they are laid out
5795 exactly the same. Otherwise, each piece of information would have to be
5796 copied individually. */
5797 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
5798
5799 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d\n", keepaliveRequest.timePeriod);
5800
Jeff Johnsone7245742012-09-05 17:12:55 -07005801 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
5802 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005803 {
5804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive\n",
5805 __func__);
5806 return -EINVAL;
5807 }
5808
5809 return 0;
5810}
5811
5812#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -07005813int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
5814 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005815{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005816 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5817 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 int i=0;
5819
5820 if (pHddCtx->cfg_ini->disablePacketFilter)
5821 {
5822 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005823 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 return 0;
5825 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005826 if (pHddCtx->isLogpInProgress)
5827 {
5828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5829 "%s:LOGP in Progress. Ignore!!!", __func__);
5830 return -EBUSY;
5831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 /* Debug display of request components. */
5833 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005834 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07005835
5836 switch (pRequest->filterAction)
5837 {
5838 case HDD_RCV_FILTER_SET:
5839 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005840 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005841
5842 packetFilterSetReq.filterId = pRequest->filterId;
5843 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
5844 {
5845 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d\n",
5846 __func__, pRequest->numParams);
5847 return -EINVAL;
5848 }
5849 packetFilterSetReq.numFieldParams = pRequest->numParams;
5850 packetFilterSetReq.coalesceTime = 0;
5851 packetFilterSetReq.filterType = 1;
5852 for (i=0; i < pRequest->numParams; i++)
5853 {
5854 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
5855 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
5856 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
5857 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
5858 packetFilterSetReq.paramsData[i].reserved = 0;
5859
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305860 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
5862 packetFilterSetReq.filterType);
5863
5864 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d\n",
5865 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
5866
5867 memcpy(&packetFilterSetReq.paramsData[i].compareData,
5868 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
5869 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
5870 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
5871
5872 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d\n",
5873 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
5874 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
5875 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
5876
5877 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d\n",
5878 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
5879 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
5880 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
5881 }
5882
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005883 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 {
5885 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter\n",
5886 __func__);
5887 return -EINVAL;
5888 }
5889
5890 break;
5891
5892 case HDD_RCV_FILTER_CLEAR:
5893
5894 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005895 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005897 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 {
5899 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter\n",
5900 __func__);
5901 return -EINVAL;
5902 }
5903 break;
5904
5905 default :
5906 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005907 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 return -EINVAL;
5909 }
5910 return 0;
5911}
5912
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05305913int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
5914 tANI_U8 sessionId)
5915{
5916 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5917 tSirRcvFltPktClearParam packetFilterClrReq = {0};
5918
5919 if (NULL == pHddCtx)
5920 {
5921 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
5922 return -EINVAL;
5923 }
5924
5925 if (pHddCtx->isLogpInProgress)
5926 {
5927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5928 "%s:LOGP in Progress. Ignore!!!", __func__);
5929 return -EBUSY;
5930 }
5931
5932 if (pHddCtx->cfg_ini->disablePacketFilter)
5933 {
5934 hddLog(VOS_TRACE_LEVEL_ERROR,
5935 "%s: Packet Filtering Disabled. Returning ",
5936 __func__ );
5937 return -EINVAL;
5938 }
5939
5940 switch (filterType)
5941 {
5942 /* For setting IPV6 MC and UC Filter we need to configure
5943 * 2 filters, one for MC and one for UC.
5944 * The Filter ID shouldn't be swapped, which results in making
5945 * UC Filter ineffective.
5946 * We have Hardcode all the values
5947 *
5948 * Reason for a seperate UC filter is because, driver need to
5949 * specify the FW that the specific filter is for unicast
5950 * otherwise FW will not pass the unicast frames by default
5951 * through the filter. This is required to avoid any performance
5952 * hits when no unicast filter is set and only MC/BC are set.
5953 * The way driver informs host is by using the MAC protocol
5954 * layer, CMP flag set to MAX, CMP Data set to 1.
5955 */
5956
5957 case HDD_FILTER_IPV6_MC_UC:
5958 /* Setting IPV6 MC Filter below
5959 */
5960 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
5961 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
5962 packetFilterSetReq.numFieldParams = 2;
5963 packetFilterSetReq.paramsData[0].protocolLayer =
5964 HDD_FILTER_PROTO_TYPE_MAC;
5965 packetFilterSetReq.paramsData[0].cmpFlag =
5966 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
5967 packetFilterSetReq.paramsData[0].dataOffset =
5968 WLAN_HDD_80211_FRM_DA_OFFSET;
5969 packetFilterSetReq.paramsData[0].dataLength = 1;
5970 packetFilterSetReq.paramsData[0].compareData[0] =
5971 HDD_IPV6_MC_CMP_DATA;
5972
5973 packetFilterSetReq.paramsData[1].protocolLayer =
5974 HDD_FILTER_PROTO_TYPE_ARP;
5975 packetFilterSetReq.paramsData[1].cmpFlag =
5976 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
5977 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
5978 packetFilterSetReq.paramsData[1].dataLength = 2;
5979 packetFilterSetReq.paramsData[1].compareData[0] =
5980 HDD_IPV6_CMP_DATA_0;
5981 packetFilterSetReq.paramsData[1].compareData[1] =
5982 HDD_IPV6_CMP_DATA_1;
5983
5984
5985 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
5986 &packetFilterSetReq, sessionId))
5987 {
5988 hddLog(VOS_TRACE_LEVEL_ERROR,
5989 "%s: Failure to execute Set IPv6 Mulicast Filter",
5990 __func__);
5991 return -EINVAL;
5992 }
5993
5994 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
5995
5996 /*
5997 * Setting IPV6 UC Filter below
5998 */
5999 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6000 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6001 packetFilterSetReq.numFieldParams = 2;
6002 packetFilterSetReq.paramsData[0].protocolLayer =
6003 HDD_FILTER_PROTO_TYPE_MAC;
6004 packetFilterSetReq.paramsData[0].cmpFlag =
6005 HDD_FILTER_CMP_TYPE_MAX;
6006 packetFilterSetReq.paramsData[0].dataOffset = 0;
6007 packetFilterSetReq.paramsData[0].dataLength = 1;
6008 packetFilterSetReq.paramsData[0].compareData[0] =
6009 HDD_IPV6_UC_CMP_DATA;
6010
6011 packetFilterSetReq.paramsData[1].protocolLayer =
6012 HDD_FILTER_PROTO_TYPE_ARP;
6013 packetFilterSetReq.paramsData[1].cmpFlag =
6014 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6015 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6016 packetFilterSetReq.paramsData[1].dataLength = 2;
6017 packetFilterSetReq.paramsData[1].compareData[0] =
6018 HDD_IPV6_CMP_DATA_0;
6019 packetFilterSetReq.paramsData[1].compareData[1] =
6020 HDD_IPV6_CMP_DATA_1;
6021
6022 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6023 &packetFilterSetReq, sessionId))
6024 {
6025 hddLog(VOS_TRACE_LEVEL_ERROR,
6026 "%s: Failure to execute Set IPv6 Unicast Filter",
6027 __func__);
6028 return -EINVAL;
6029 }
6030
6031 break;
6032
6033 case HDD_FILTER_IPV6_MC:
6034 /*
6035 * IPV6 UC Filter might be already set,
6036 * clear the UC Filter. As the Filter
6037 * IDs are static, we can directly clear it.
6038 */
6039 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6040 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6041 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6042 &packetFilterClrReq, sessionId))
6043 {
6044 hddLog(VOS_TRACE_LEVEL_ERROR,
6045 "%s: Failure to execute Clear IPv6 Unicast Filter",
6046 __func__);
6047 return -EINVAL;
6048 }
6049
6050 /*
6051 * Setting IPV6 MC Filter below
6052 */
6053 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6054 packetFilterSetReq.numFieldParams = 2;
6055 packetFilterSetReq.paramsData[0].protocolLayer =
6056 HDD_FILTER_PROTO_TYPE_MAC;
6057 packetFilterSetReq.paramsData[0].cmpFlag =
6058 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6059 packetFilterSetReq.paramsData[0].dataOffset =
6060 WLAN_HDD_80211_FRM_DA_OFFSET;
6061 packetFilterSetReq.paramsData[0].dataLength = 1;
6062 packetFilterSetReq.paramsData[0].compareData[0] =
6063 HDD_IPV6_MC_CMP_DATA;
6064
6065 packetFilterSetReq.paramsData[1].protocolLayer =
6066 HDD_FILTER_PROTO_TYPE_ARP;
6067 packetFilterSetReq.paramsData[1].cmpFlag =
6068 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6069 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6070 packetFilterSetReq.paramsData[1].dataLength = 2;
6071 packetFilterSetReq.paramsData[1].compareData[0] =
6072 HDD_IPV6_CMP_DATA_0;
6073 packetFilterSetReq.paramsData[1].compareData[1] =
6074 HDD_IPV6_CMP_DATA_1;
6075
6076
6077 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6078 &packetFilterSetReq, sessionId))
6079 {
6080 hddLog(VOS_TRACE_LEVEL_ERROR,
6081 "%s: Failure to execute Set IPv6 Multicast Filter",
6082 __func__);
6083 return -EINVAL;
6084 }
6085 break;
6086
6087 default :
6088 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6089 "%s: Packet Filter Request: Invalid",
6090 __func__);
6091 return -EINVAL;
6092 }
6093 return 0;
6094}
6095
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306096void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006097{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306098 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306099 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006100 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306101 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006102
Yue Ma3ede6052013-08-29 00:33:26 -07006103 if (NULL == pHddCtx)
6104 {
6105 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6106 return;
6107 }
6108
6109 hHal = pHddCtx->hHal;
6110
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306111 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306113 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6114 return;
6115 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306116
6117 /* Check if INI is enabled or not, other wise just return
6118 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306119 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306120 {
6121 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6122 if (NULL == pMulticastAddrs)
6123 {
6124 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6125 return;
6126 }
6127
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 if (set)
6129 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306130 /* Following pre-conditions should be satisfied before wei
6131 * configure the MC address list.
6132 */
6133 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6134 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6135 && pAdapter->mc_addr_list.mc_cnt
6136 && (eConnectionState_Associated ==
6137 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6138 {
6139 pMulticastAddrs->ulMulticastAddrCnt =
6140 pAdapter->mc_addr_list.mc_cnt;
6141 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6142 {
6143 memcpy(&(pMulticastAddrs->multicastAddr[i][0]),
6144 &(pAdapter->mc_addr_list.addr[i][0]),
6145 sizeof(pAdapter->mc_addr_list.addr[i]));
6146 hddLog(VOS_TRACE_LEVEL_INFO,
6147 "%s: %s multicast filter: addr ="
6148 MAC_ADDRESS_STR,
6149 __func__, set ? "setting" : "clearing",
6150 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6151 }
6152 /* Set multicast filter */
6153 sme_8023MulticastList(hHal, pAdapter->sessionId,
6154 pMulticastAddrs);
6155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306157 else
6158 {
6159 /* Need to clear only if it was previously configured
6160 */
6161 if (pAdapter->mc_addr_list.isFilterApplied)
6162 {
6163 pMulticastAddrs->ulMulticastAddrCnt = 0;
6164 sme_8023MulticastList(hHal, pAdapter->sessionId,
6165 pMulticastAddrs);
6166 }
6167
6168 }
6169 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306171 else
6172 {
6173 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306174 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306175 }
6176 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006177}
6178
6179static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6180 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306181{
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6183 tpPacketFilterCfg pRequest = (tpPacketFilterCfg)wrqu->data.pointer;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006184
Jeff Johnsone7245742012-09-05 17:12:55 -07006185 return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186}
6187#endif
6188static int iw_get_statistics(struct net_device *dev,
6189 struct iw_request_info *info,
6190 union iwreq_data *wrqu, char *extra)
6191{
6192
6193 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6194 eHalStatus status = eHAL_STATUS_SUCCESS;
6195 hdd_wext_state_t *pWextState;
6196 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6197 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6198 char *p = extra;
6199 int tlen = 0;
6200 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6201
6202 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6203 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6204
6205 ENTER();
6206
6207 if (pHddCtx->isLogpInProgress) {
6208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6209 return -EINVAL;
6210 }
6211
6212 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6213
6214 wrqu->txpower.value = 0;
6215 }
6216 else {
6217 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6218 SME_SUMMARY_STATS |
6219 SME_GLOBAL_CLASSA_STATS |
6220 SME_GLOBAL_CLASSB_STATS |
6221 SME_GLOBAL_CLASSC_STATS |
6222 SME_GLOBAL_CLASSD_STATS |
6223 SME_PER_STA_STATS,
6224 hdd_StatisticsCB, 0, FALSE,
6225 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6226
6227 if (eHAL_STATUS_SUCCESS != status)
6228 {
6229 hddLog(VOS_TRACE_LEVEL_ERROR,
6230 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006231 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 return -EINVAL;
6233 }
6234
6235 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6236
6237 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6238 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6239 {
6240 hddLog(VOS_TRACE_LEVEL_ERROR,
6241 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006242 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 /*Remove the SME statistics list by passing NULL in callback argument*/
6244 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6245 SME_SUMMARY_STATS |
6246 SME_GLOBAL_CLASSA_STATS |
6247 SME_GLOBAL_CLASSB_STATS |
6248 SME_GLOBAL_CLASSC_STATS |
6249 SME_GLOBAL_CLASSD_STATS |
6250 SME_PER_STA_STATS,
6251 NULL, 0, FALSE,
6252 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6253
6254 return -EINVAL;
6255 }
6256 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6257 (tANI_U8) sizeof (pStats->retry_cnt),
6258 (char*) &(pStats->retry_cnt[0]),
6259 tlen);
6260
6261 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6262 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6263 (char*) &(pStats->multiple_retry_cnt[0]),
6264 tlen);
6265
6266 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6267 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6268 (char*) &(pStats->tx_frm_cnt[0]),
6269 tlen);
6270
6271 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6272 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6273 (char*) &(pStats->rx_frm_cnt),
6274 tlen);
6275
6276 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6277 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6278 (char*) &(pStats->frm_dup_cnt),
6279 tlen);
6280
6281 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6282 (tANI_U8) sizeof (pStats->fail_cnt),
6283 (char*) &(pStats->fail_cnt[0]),
6284 tlen);
6285
6286 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6287 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6288 (char*) &(pStats->rts_fail_cnt),
6289 tlen);
6290
6291 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6292 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6293 (char*) &(pStats->ack_fail_cnt),
6294 tlen);
6295
6296 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6297 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6298 (char*) &(pStats->rts_succ_cnt),
6299 tlen);
6300
6301 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6302 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6303 (char*) &(pStats->rx_discard_cnt),
6304 tlen);
6305
6306 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6307 (tANI_U8) sizeof (pStats->rx_error_cnt),
6308 (char*) &(pStats->rx_error_cnt),
6309 tlen);
6310
Jeff Johnsone7245742012-09-05 17:12:55 -07006311 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
6312 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6313 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 tlen);
6315
6316 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6317 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6318 (char*) &(dStats->rx_byte_cnt),
6319 tlen);
6320
6321 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6322 (tANI_U8) sizeof (dStats->rx_rate),
6323 (char*) &(dStats->rx_rate),
6324 tlen);
6325
6326 /* Transmit rate, in units of 500 kbit/sec */
6327 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6328 (tANI_U8) sizeof (aStats->tx_rate),
6329 (char*) &(aStats->tx_rate),
6330 tlen);
6331
Jeff Johnsone7245742012-09-05 17:12:55 -07006332 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6333 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6334 (char*) &(dStats->rx_uc_byte_cnt[0]),
6335 tlen);
6336 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6337 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6338 (char*) &(dStats->rx_mc_byte_cnt),
6339 tlen);
6340 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6341 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6342 (char*) &(dStats->rx_bc_byte_cnt),
6343 tlen);
6344 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6345 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6346 (char*) &(dStats->tx_uc_byte_cnt[0]),
6347 tlen);
6348 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6349 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6350 (char*) &(dStats->tx_mc_byte_cnt),
6351 tlen);
6352 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6353 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6354 (char*) &(dStats->tx_bc_byte_cnt),
6355 tlen);
6356
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 wrqu->data.length = tlen;
6358
6359 }
6360
6361 EXIT();
6362
6363 return 0;
6364}
6365
6366
6367#ifdef FEATURE_WLAN_SCAN_PNO
6368
6369/*Max Len for PNO notification*/
6370#define MAX_PNO_NOTIFY_LEN 100
6371void found_pref_network_cb (void *callbackContext,
6372 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6373{
6374 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6375 union iwreq_data wrqu;
6376 char buf[MAX_PNO_NOTIFY_LEN+1];
6377
6378 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6379 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6380
6381 // create the event
6382 memset(&wrqu, 0, sizeof(wrqu));
6383 memset(buf, 0, sizeof(buf));
6384
6385 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6386 pPrefNetworkFoundInd->ssId.ssId,
6387 (unsigned int)pPrefNetworkFoundInd->rssi);
6388
6389 wrqu.data.pointer = buf;
6390 wrqu.data.length = strlen(buf);
6391
6392 // send the event
6393
6394 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6395
6396}
6397
6398
6399/*string based input*/
6400VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6401 union iwreq_data *wrqu, char *extra, int nOffset)
6402{
6403 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006404 /* pnoRequest is a large struct, so we make it static to avoid stack
6405 overflow. This API is only invoked via ioctl, so it is
6406 serialized by the kernel rtnl_lock and hence does not need to be
6407 reentrant */
6408 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 char *ptr;
6410 v_U8_t i,j, ucParams, ucMode;
6411 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6412
6413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6414 "PNO data len %d data %s",
6415 wrqu->data.length,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306416 (char *)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006417
6418 if (wrqu->data.length <= nOffset )
6419 {
6420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6421 return VOS_STATUS_E_FAILURE;
6422 }
6423
6424 pnoRequest.enable = 0;
6425 pnoRequest.ucNetworksCount = 0;
6426 /*-----------------------------------------------------------------------
6427 Input is string based and expected to be like this:
6428
6429 <enabled> <netw_count>
6430 for each network:
6431 <ssid_len> <ssid> <authentication> <encryption>
6432 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6433 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6434
6435 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006436 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 -07006437
6438 this translates into:
6439 -----------------------------
6440 enable PNO
6441 look for 2 networks:
6442 test - with authentication type 0 and encryption type 0,
6443 that can be found on 3 channels: 1 6 and 11 ,
6444 SSID bcast type is unknown (directed probe will be sent if AP not found)
6445 and must meet -40dBm RSSI
6446
6447 test2 - with auth and enrytption type 4/4
6448 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6449 bcast type is non-bcast (directed probe will be sent)
6450 and must not meet any RSSI threshold
6451
Jeff Johnson8301aa12013-03-28 14:27:29 -07006452 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 -----------------------------------------------------------------------*/
6454 ptr = (char*)(wrqu->data.pointer + nOffset);
6455
Wilson Yang623f6592013-10-08 16:33:37 -07006456 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6457 {
6458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6459 "PNO enable input is not valid %s",ptr);
6460 return VOS_STATUS_E_FAILURE;
6461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006462
6463 if ( 0 == pnoRequest.enable )
6464 {
6465 /*Disable PNO*/
6466 memset(&pnoRequest, 0, sizeof(pnoRequest));
6467 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6468 pAdapter->sessionId,
6469 found_pref_network_cb, pAdapter);
6470 return VOS_STATUS_SUCCESS;
6471 }
6472
6473 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006474
6475 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6476 {
6477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6478 "PNO count input not valid %s",ptr);
6479 return VOS_STATUS_E_FAILURE;
6480
6481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006482
6483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6484 "PNO enable %d networks count %d offset %d",
6485 pnoRequest.enable,
6486 pnoRequest.ucNetworksCount,
6487 nOffset);
6488
6489 /* Parameters checking:
6490 ucNetworksCount has to be larger than 0*/
6491 if (( 0 == pnoRequest.ucNetworksCount ) ||
6492 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6493 {
6494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6495 return VOS_STATUS_E_FAILURE;
6496 }
6497
6498 ptr += nOffset;
6499
6500 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6501 {
6502
6503 pnoRequest.aNetworks[i].ssId.length = 0;
6504
Wilson Yang623f6592013-10-08 16:33:37 -07006505 ucParams = sscanf(ptr,"%hhu %n",
6506 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6507
6508 if (1 != ucParams)
6509 {
6510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6511 "PNO ssid length input is not valid %s",ptr);
6512 return VOS_STATUS_E_FAILURE;
6513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006514
6515 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6516 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6517 {
6518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6519 "SSID Len %d is not correct for network %d",
6520 pnoRequest.aNetworks[i].ssId.length, i);
6521 return VOS_STATUS_E_FAILURE;
6522 }
6523
6524 /*Advance to SSID*/
6525 ptr += nOffset;
6526
Jeff Johnson8301aa12013-03-28 14:27:29 -07006527 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006528 pnoRequest.aNetworks[i].ssId.length);
6529 ptr += pnoRequest.aNetworks[i].ssId.length;
6530
6531 ucParams = sscanf(ptr,"%lu %lu %hhu %n",
6532 &(pnoRequest.aNetworks[i].authentication),
6533 &(pnoRequest.aNetworks[i].encryption),
6534 &(pnoRequest.aNetworks[i].ucChannelCount),
6535 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006536
Wilson Yang623f6592013-10-08 16:33:37 -07006537 if ( 3 != ucParams )
6538 {
6539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6540 "Incorrect cmd %s",ptr);
6541 return VOS_STATUS_E_FAILURE;
6542 }
6543
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal751e6072013-01-24 16:02:56 -08006545 "PNO len %d ssid 0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx"
6546 "auth %d encry %d channel count %d offset %d",
6547 pnoRequest.aNetworks[i].ssId.length,
6548 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6549 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6550 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6551 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6552 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6553 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6554 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6555 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6556 pnoRequest.aNetworks[i].authentication,
6557 pnoRequest.aNetworks[i].encryption,
6558 pnoRequest.aNetworks[i].ucChannelCount,
6559 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006560
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 /*Advance to channel list*/
6562 ptr += nOffset;
6563
Wilson Yang623f6592013-10-08 16:33:37 -07006564 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 {
6566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6567 "Incorrect number of channels");
6568 return VOS_STATUS_E_FAILURE;
6569 }
6570
6571 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6572 {
6573 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6574 {
Wilson Yang623f6592013-10-08 16:33:37 -07006575 if (1 != sscanf(ptr,"%hhu %n",
6576 &(pnoRequest.aNetworks[i].aChannels[j]),
6577 &nOffset))
6578 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6579 "PNO network channel input is not valid %s",ptr);
6580 return VOS_STATUS_E_FAILURE;
6581 }
6582 /*Advance to next channel number*/
6583 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 }
6585 }
6586
Wilson Yang623f6592013-10-08 16:33:37 -07006587 if (1 != sscanf(ptr,"%lu %n",
6588 &(pnoRequest.aNetworks[i].bcastNetwType),
6589 &nOffset))
6590 {
6591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6592 "PNO broadcast network type input is not valid %s",ptr);
6593 return VOS_STATUS_E_FAILURE;
6594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006595
6596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6597 "PNO bcastNetwType %d offset %d",
6598 pnoRequest.aNetworks[i].bcastNetwType,
6599 nOffset );
6600
6601 /*Advance to rssi Threshold*/
6602 ptr += nOffset;
6603
Wilson Yang623f6592013-10-08 16:33:37 -07006604 if (1 != sscanf(ptr,"%hhu %n",
6605 &(pnoRequest.aNetworks[i].rssiThreshold),
6606 &nOffset))
6607 {
6608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6609 "PNO rssi threshold input is not valid %s",ptr);
6610 return VOS_STATUS_E_FAILURE;
6611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006612
6613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6614 "PNO rssi %d offset %d",
6615 pnoRequest.aNetworks[i].rssiThreshold,
6616 nOffset );
6617 /*Advance to next network*/
6618 ptr += nOffset;
6619 }/*For ucNetworkCount*/
6620
6621 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006622 &(pnoRequest.scanTimers.ucScanTimersCount),
6623 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006624
6625 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07006626 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 {
6628 ptr += nOffset;
6629
Jeff Johnson8301aa12013-03-28 14:27:29 -07006630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6631 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 pnoRequest.scanTimers.ucScanTimersCount,
6633 nOffset );
6634
6635 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
6636 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 "Incorrect cmd - too many scan timers");
6639 return VOS_STATUS_E_FAILURE;
6640 }
6641
6642 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
6643 {
6644 ucParams = sscanf(ptr,"%lu %lu %n",
6645 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
6646 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
6647 &nOffset);
6648
Wilson Yang623f6592013-10-08 16:33:37 -07006649 if (2 != ucParams)
6650 {
6651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6652 "Incorrect cmd - diff params then expected %d", ucParams);
6653 return VOS_STATUS_E_FAILURE;
6654 }
6655
Jeff Johnson8301aa12013-03-28 14:27:29 -07006656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6657 "PNO Timer value %d Timer repeat %d offset %d",
6658 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
6660 nOffset );
6661
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 ptr += nOffset;
6663 }
6664
6665 }
6666 else
6667 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6669 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
6671
6672 /*Scan timers defaults to 5 minutes*/
6673 pnoRequest.scanTimers.ucScanTimersCount = 1;
6674 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
6675 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
6676 }
6677
Wilson Yang623f6592013-10-08 16:33:37 -07006678 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006679
6680 pnoRequest.modePNO = ucMode;
6681 /*for LA we just expose suspend option*/
6682 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
6683 {
6684 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
6685 }
6686
6687 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6688 pAdapter->sessionId,
6689 found_pref_network_cb, pAdapter);
6690
6691 return VOS_STATUS_SUCCESS;
6692}/*iw_set_pno*/
6693
6694VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
6695 union iwreq_data *wrqu, char *extra, int nOffset)
6696{
6697 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6698 v_U8_t rssiThreshold = 0;
6699 v_U8_t nRead;
6700
6701 nRead = sscanf(wrqu->data.pointer + nOffset,"%hhu",
6702 &rssiThreshold);
6703
6704 if ( 1 != nRead )
6705 {
6706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6707 "Incorrect format");
6708 return VOS_STATUS_E_FAILURE;
6709 }
6710
6711 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
6712 return VOS_STATUS_SUCCESS;
6713}
6714
6715
6716static int iw_set_pno_priv(struct net_device *dev,
6717 struct iw_request_info *info,
6718 union iwreq_data *wrqu, char *extra)
6719{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006720 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6721
6722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006724
6725 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6726 {
6727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6728 "%s:LOGP in Progress. Ignore!!!", __func__);
6729 return -EBUSY;
6730 }
6731 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006732}
6733#endif /*FEATURE_WLAN_SCAN_PNO*/
6734
6735//Common function to SetBand
6736int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
6737{
6738 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6739 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6740 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6741 tANI_U8 band = 0;
6742 eCsrBand currBand = eCSR_BAND_MAX;
6743
6744 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
6745
6746 switch(band)
6747 {
6748 case WLAN_HDD_UI_BAND_AUTO:
6749 band = eCSR_BAND_ALL;
6750 break;
6751 case WLAN_HDD_UI_BAND_5_GHZ:
6752 band = eCSR_BAND_5G;
6753 break;
6754 case WLAN_HDD_UI_BAND_2_4_GHZ:
6755 band = eCSR_BAND_24;
6756 break;
6757 default:
6758 band = eCSR_BAND_MAX;
6759 }
6760
6761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006762 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006763
6764 if (band == eCSR_BAND_MAX)
6765 {
6766 /* Received change band request with invalid band value */
6767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006768 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 return -EIO;
6770 }
6771
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306772 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
6773 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
6774 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
6775 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006777 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006778 band, pHddCtx->cfg_ini->nBandCapability);
6779 return -EIO;
6780 }
6781
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
6783 {
6784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6785 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006786 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006787 return -EIO;
6788 }
6789
6790 if (currBand != band)
6791 {
6792 /* Change band request received.
6793 * Abort pending scan requests, flush the existing scan results,
6794 * and change the band capability
6795 */
6796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6797 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006798 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006799
6800 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6801 {
6802 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
6803 eHalStatus status = eHAL_STATUS_SUCCESS;
6804 long lrc;
6805
6806 /* STA already connected on current band, So issue disconnect first,
6807 * then change the band*/
6808
6809 hddLog(VOS_TRACE_LEVEL_INFO,
6810 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
6811 __func__, csrGetCurrentBand(hHal), band);
6812
6813 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6814 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6815
6816 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6817 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6818
Jeff Johnson43971f52012-07-17 12:26:56 -07006819 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006820 {
6821 hddLog(VOS_TRACE_LEVEL_ERROR,
6822 "%s csrRoamDisconnect failure, returned %d \n",
6823 __func__, (int)status );
6824 return -EINVAL;
6825 }
6826
6827 lrc = wait_for_completion_interruptible_timeout(
6828 &pAdapter->disconnect_comp_var,
6829 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6830
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306831 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07006832
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07006833 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006834 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006835
6836 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6837 }
6838 }
6839
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306840 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Srinivas Girigowdade697412013-02-14 16:31:48 -08006842#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6843 sme_UpdateBgScanConfigIniChannelList(hHal, (eCsrBand) band);
6844#endif
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306845 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 {
6847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6848 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006849 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 return -EINVAL;
6851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 }
6854 return 0;
6855}
6856
6857static int iw_set_band_config(struct net_device *dev,
6858 struct iw_request_info *info,
6859 union iwreq_data *wrqu, char *extra)
6860{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006861 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 tANI_U8 *ptr = (tANI_U8*)wrqu->data.pointer;
6863 int ret = 0;
6864
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006866
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006867 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6868 {
6869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6870 "%s:LOGP in Progress. Ignore!!!", __func__);
6871 return -EBUSY;
6872 }
6873
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 if (memcmp(ptr, "SETBAND ", 8) == 0)
6875 {
6876 /* Change band request received */
6877 ret = hdd_setBand_helper(dev, ptr);
6878 return ret;
6879
6880 }
6881 return 0;
6882}
6883
6884static int iw_set_power_params_priv(struct net_device *dev,
6885 struct iw_request_info *info,
6886 union iwreq_data *wrqu, char *extra)
6887{
6888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6889 "Set power params Private");
6890 return iw_set_power_params(dev,info,wrqu,extra,0);
6891}
6892
6893
6894
6895/*string based input*/
6896VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
6897 union iwreq_data *wrqu, char *extra, int nOffset)
6898{
6899 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6900 tSirSetPowerParamsReq powerRequest;
6901 char *ptr;
6902 v_U8_t ucType;
6903 v_U32_t uTotalSize, uValue;
6904 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6905
6906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6907 "Power Params data len %d data %s",
6908 wrqu->data.length,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306909 (char *)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006910
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006911 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6912 {
6913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6914 "%s:LOGP in Progress. Ignore!!!", __func__);
6915 return -EBUSY;
6916 }
6917
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 if (wrqu->data.length <= nOffset )
6919 {
6920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
6921 return VOS_STATUS_E_FAILURE;
6922 }
6923
6924 uTotalSize = wrqu->data.length - nOffset;
6925
6926 /*-----------------------------------------------------------------------
6927 Input is string based and expected to be like this:
6928
6929 <param_type> <param_value> <param_type> <param_value> ...
6930
6931 e.g:
6932 1 2 2 3 3 0 4 1 5 1
6933
6934 e.g. setting just a few:
6935 1 2 4 1
6936
6937 parameter types:
6938 -----------------------------
6939 1 - Ignore DTIM
6940 2 - Listen Interval
6941 3 - Broadcast Multicas Filter
6942 4 - Beacon Early Termination
6943 5 - Beacon Early Termination Interval
6944 -----------------------------------------------------------------------*/
6945 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
6946 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
6947 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
6948 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
6949 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
6950
6951 ptr = (char*)(wrqu->data.pointer + nOffset);
6952
6953 while ( uTotalSize )
6954 {
Wilson Yang6f971452013-10-08 15:00:00 -07006955 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
6956 {
6957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6958 "Invalid input parameter type %s",ptr);
6959 return VOS_STATUS_E_FAILURE;
6960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006961
6962 uTotalSize -= nOffset;
6963
6964 if (!uTotalSize)
6965 {
6966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006967 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 ucType, nOffset);
6969 return VOS_STATUS_E_FAILURE;
6970 }
6971
6972 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07006973
6974 if (1 != sscanf(ptr,"%lu %n", &(uValue), &nOffset))
6975 {
6976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6977 "Invalid input parameter value %s",ptr);
6978 return VOS_STATUS_E_FAILURE;
6979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006980
6981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6982 "Power request parameter %d value %d offset %d",
6983 ucType, uValue, nOffset);
6984
6985 switch (ucType)
6986 {
6987 case eSIR_IGNORE_DTIM:
6988 powerRequest.uIgnoreDTIM = uValue;
6989 break;
6990 case eSIR_LISTEN_INTERVAL:
6991 powerRequest.uListenInterval = uValue;
6992 break;
6993 case eSIR_MCAST_BCAST_FILTER:
6994 powerRequest.uBcastMcastFilter = uValue;
6995 break;
6996 case eSIR_ENABLE_BET:
6997 powerRequest.uEnableBET = uValue;
6998 break;
6999 case eSIR_BET_INTERVAL:
7000 powerRequest.uBETInterval = uValue;
7001 break;
7002 default:
7003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007004 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 ucType, uValue, nOffset);
7006 return VOS_STATUS_E_FAILURE;
7007 }
7008
7009 uTotalSize -= nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7011 "Power request parameter %d Total size",
7012 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007014 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
7015 if(!(uTotalSize - nOffset) &&
7016 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7017 {
7018 uTotalSize = 0;
7019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007020
7021 }/*Go for as long as we have a valid string*/
7022
7023 /* put the device into full power*/
7024 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7025
7026 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007027 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007028
7029 /* put the device back to power save*/
7030 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7031
7032 return VOS_STATUS_SUCCESS;
7033}/*iw_set_power_params*/
7034
7035
7036// Define the Wireless Extensions to the Linux Network Device structure
7037// A number of these routines are NULL (meaning they are not implemented.)
7038
7039static const iw_handler we_handler[] =
7040{
7041 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7042 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7043 (iw_handler) NULL, /* SIOCSIWNWID */
7044 (iw_handler) NULL, /* SIOCGIWNWID */
7045 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7046 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7047 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7048 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7049 (iw_handler) NULL, /* SIOCSIWSENS */
7050 (iw_handler) NULL, /* SIOCGIWSENS */
7051 (iw_handler) NULL, /* SIOCSIWRANGE */
7052 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7053 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7054 (iw_handler) NULL, /* SIOCGIWPRIV */
7055 (iw_handler) NULL, /* SIOCSIWSTATS */
7056 (iw_handler) NULL, /* SIOCGIWSTATS */
7057 iw_handler_set_spy, /* SIOCSIWSPY */
7058 iw_handler_get_spy, /* SIOCGIWSPY */
7059 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7060 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7061 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7062 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7063 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7064 (iw_handler) NULL, /* SIOCGIWAPLIST */
7065 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7066 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7067 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7068 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7069 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7070 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7071 (iw_handler) NULL, /* -- hole -- */
7072 (iw_handler) NULL, /* -- hole -- */
7073 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7074 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7075 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7076 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7077 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7078 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7079 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7080 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7081 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7082 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7083 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7084 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7085 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7086 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7087 (iw_handler) NULL, /* -- hole -- */
7088 (iw_handler) NULL, /* -- hole -- */
7089 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7090 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7091 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7092 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7093 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7094 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7095 (iw_handler) NULL, /* SIOCSIWPMKSA */
7096};
7097
7098static const iw_handler we_private[] = {
7099
7100 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7101 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7102 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7103 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7104 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7105 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7106 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7107 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7108 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7109 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007110#ifdef FEATURE_OEM_DATA_SUPPORT
7111 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7112 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7113#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007114
7115#ifdef FEATURE_WLAN_WAPI
7116 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7117 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7118 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7119 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7120 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7121 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7122#endif /* FEATURE_WLAN_WAPI */
7123#ifdef WLAN_FEATURE_VOWIFI_11R
7124 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7125#endif
7126 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7127 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7128 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7129#ifdef WLAN_FEATURE_PACKET_FILTERING
7130 ,
7131 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7132#endif
7133#ifdef FEATURE_WLAN_SCAN_PNO
7134 ,
7135 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7136#endif
7137 ,
7138 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7139 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7140 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7141 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007142 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007143};
7144
7145/*Maximum command length can be only 15 */
7146static const struct iw_priv_args we_private_args[] = {
7147
7148 /* handlers for main ioctl */
7149 { WLAN_PRIV_SET_INT_GET_NONE,
7150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7151 0,
7152 "" },
7153
7154 /* handlers for sub-ioctl */
7155 { WE_SET_11D_STATE,
7156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7157 0,
7158 "set11Dstate" },
7159
7160 { WE_WOWL,
7161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7162 0,
7163 "wowl" },
7164
7165 { WE_SET_POWER,
7166 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7167 0,
7168 "setPower" },
7169
7170 { WE_SET_MAX_ASSOC,
7171 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7172 0,
7173 "setMaxAssoc" },
7174
7175 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7176 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7177 0,
7178 "setAutoChannel" },
7179
7180 { WE_SET_DATA_INACTIVITY_TO,
7181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7182 0,
7183 "inactivityTO" },
7184
7185 { WE_SET_MAX_TX_POWER,
7186 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7187 0,
7188 "setMaxTxPower" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007189
7190 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7191 * as well to keep same syntax as in SAP. Now onwards, STA
7192 * will support both */
7193 { WE_SET_MAX_TX_POWER,
7194 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7195 0,
7196 "setTxMaxPower" },
7197
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7199 * 1 = enable and 0 = disable */
7200 {
7201 WE_SET_HIGHER_DTIM_TRANSITION,
7202 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7203 0,
7204 "setHDtimTransn" },
7205
7206 { WE_SET_TM_LEVEL,
7207 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7208 0,
7209 "setTmLevel" },
7210
7211 /* handlers for main ioctl */
7212 { WLAN_PRIV_SET_NONE_GET_INT,
7213 0,
7214 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7215 "" },
7216
7217 /* handlers for sub-ioctl */
7218 { WE_GET_11D_STATE,
7219 0,
7220 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7221 "get11Dstate" },
7222
7223 { WE_IBSS_STATUS,
7224 0,
7225 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7226 "getAdhocStatus" },
7227
7228 { WE_PMC_STATE,
7229 0,
7230 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7231 "pmcState" },
7232
7233 { WE_GET_WLAN_DBG,
7234 0,
7235 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7236 "getwlandbg" },
7237
7238 { WE_MODULE_DOWN_IND,
7239 0,
7240 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7241 "moduleDownInd" },
7242
7243 { WE_GET_MAX_ASSOC,
7244 0,
7245 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7246 "getMaxAssoc" },
7247
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 { WE_GET_WDI_DBG,
7249 0,
7250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7251 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007252
7253 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7254 0,
7255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7256 "getAutoChannel" },
7257
7258 { WE_GET_CONCURRENCY_MODE,
7259 0,
7260 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7261 "getconcurrency" },
7262
7263 /* handlers for main ioctl */
7264 { WLAN_PRIV_SET_CHAR_GET_NONE,
7265 IW_PRIV_TYPE_CHAR| 512,
7266 0,
7267 "" },
7268
7269 /* handlers for sub-ioctl */
7270 { WE_WOWL_ADD_PTRN,
7271 IW_PRIV_TYPE_CHAR| 512,
7272 0,
7273 "wowlAddPtrn" },
7274
7275 { WE_WOWL_DEL_PTRN,
7276 IW_PRIV_TYPE_CHAR| 512,
7277 0,
7278 "wowlDelPtrn" },
7279
7280#if defined WLAN_FEATURE_VOWIFI
7281 /* handlers for sub-ioctl */
7282 { WE_NEIGHBOR_REPORT_REQUEST,
7283 IW_PRIV_TYPE_CHAR | 512,
7284 0,
7285 "neighbor" },
7286#endif
7287 { WE_SET_AP_WPS_IE,
7288 IW_PRIV_TYPE_CHAR| 512,
7289 0,
7290 "set_ap_wps_ie" },
7291
7292 { WE_SET_CONFIG,
7293 IW_PRIV_TYPE_CHAR| 512,
7294 0,
7295 "setConfig" },
7296
7297 /* handlers for main ioctl */
7298 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7299 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7300 0,
7301 "" },
7302
7303 /* handlers for sub-ioctl */
7304 { WE_SET_WLAN_DBG,
7305 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7306 0,
7307 "setwlandbg" },
7308
Jeff Johnson295189b2012-06-20 16:38:30 -07007309 { WE_SET_WDI_DBG,
7310 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7311 0,
7312 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007313
7314 { WE_SET_SAP_CHANNELS,
7315 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7316 0,
7317 "setsapchannels" },
7318
7319 /* handlers for main ioctl */
7320 { WLAN_PRIV_GET_CHAR_SET_NONE,
7321 0,
7322 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7323 "" },
7324
7325 /* handlers for sub-ioctl */
7326 { WE_WLAN_VERSION,
7327 0,
7328 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7329 "version" },
7330 { WE_GET_STATS,
7331 0,
7332 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7333 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307334 { WE_GET_STATES,
7335 0,
7336 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7337 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 { WE_GET_CFG,
7339 0,
7340 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7341 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007342#ifdef WLAN_FEATURE_11AC
7343 { WE_GET_RSSI,
7344 0,
7345 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7346 "getRSSI" },
7347#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007348#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
7349 { WE_GET_ROAM_RSSI,
7350 0,
7351 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7352 "getRoamRSSI" },
7353#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 { WE_GET_WMM_STATUS,
7355 0,
7356 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7357 "getWmmStatus" },
7358 {
7359 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307360 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7362 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007363#ifdef FEATURE_WLAN_TDLS
7364 {
7365 WE_GET_TDLS_PEERS,
7366 0,
7367 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7368 "getTdlsPeers" },
7369#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007370#ifdef WLAN_FEATURE_11W
7371 {
7372 WE_GET_11W_INFO,
7373 0,
7374 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7375 "getPMFInfo" },
7376#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 /* handlers for main ioctl */
7378 { WLAN_PRIV_SET_NONE_GET_NONE,
7379 0,
7380 0,
7381 "" },
7382
7383 /* handlers for sub-ioctl */
7384 { WE_CLEAR_STATS,
7385 0,
7386 0,
7387 "clearStats" },
7388 { WE_INIT_AP,
7389 0,
7390 0,
7391 "initAP" },
7392 { WE_STOP_AP,
7393 0,
7394 0,
7395 "exitAP" },
7396 { WE_ENABLE_AMP,
7397 0,
7398 0,
7399 "enableAMP" },
7400 { WE_DISABLE_AMP,
7401 0,
7402 0,
7403 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007404 { WE_ENABLE_DXE_STALL_DETECT,
7405 0,
7406 0,
7407 "dxeStallDetect" },
7408 { WE_DISPLAY_DXE_SNAP_SHOT,
7409 0,
7410 0,
7411 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307412 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7413 0,
7414 0,
7415 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007416 {
7417 WE_SET_REASSOC_TRIGGER,
7418 0,
7419 0,
7420 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007421
7422 /* handlers for main ioctl */
7423 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7424 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7425 0,
7426 "" },
7427
7428 /* handlers for sub-ioctl */
7429 { WE_LOG_DUMP_CMD,
7430 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7431 0,
7432 "dump" },
7433
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007434 /* handlers for sub ioctl */
7435 {
7436 WE_MCC_CONFIG_CREDENTIAL,
7437 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7438 0,
7439 "setMccCrdnl" },
7440
7441 /* handlers for sub ioctl */
7442 {
7443 WE_MCC_CONFIG_PARAMS,
7444 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7445 0,
7446 "setMccConfig" },
7447
Chilam NG571c65a2013-01-19 12:27:36 +05307448#ifdef FEATURE_WLAN_TDLS
7449 /* handlers for sub ioctl */
7450 {
7451 WE_TDLS_CONFIG_PARAMS,
7452 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7453 0,
7454 "setTdlsConfig" },
7455#endif
7456
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 /* handlers for main ioctl */
7458 { WLAN_PRIV_ADD_TSPEC,
7459 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7460 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7461 "addTspec" },
7462
7463 /* handlers for main ioctl */
7464 { WLAN_PRIV_DEL_TSPEC,
7465 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7466 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7467 "delTspec" },
7468
7469 /* handlers for main ioctl */
7470 { WLAN_PRIV_GET_TSPEC,
7471 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7472 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7473 "getTspec" },
7474
Jeff Johnsone7245742012-09-05 17:12:55 -07007475#ifdef FEATURE_OEM_DATA_SUPPORT
7476 /* handlers for main ioctl - OEM DATA */
7477 {
7478 WLAN_PRIV_SET_OEM_DATA_REQ,
7479 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7480 0,
7481 "set_oem_data_req" },
7482
7483 /* handlers for main ioctl - OEM DATA */
7484 {
7485 WLAN_PRIV_GET_OEM_DATA_RSP,
7486 0,
7487 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7488 "get_oem_data_rsp" },
7489#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007490
7491#ifdef FEATURE_WLAN_WAPI
7492 /* handlers for main ioctl SET_WAPI_MODE */
7493 { WLAN_PRIV_SET_WAPI_MODE,
7494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7495 0,
7496 "SET_WAPI_MODE" },
7497
7498 /* handlers for main ioctl GET_WAPI_MODE */
7499 { WLAN_PRIV_GET_WAPI_MODE,
7500 0,
7501 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7502 "GET_WAPI_MODE" },
7503
7504 /* handlers for main ioctl SET_ASSOC_INFO */
7505 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
7506 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
7507 0,
7508 "SET_WAPI_ASSOC" },
7509
7510 /* handlers for main ioctl SET_WAPI_KEY */
7511 { WLAN_PRIV_SET_WAPI_KEY,
7512 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
7513 0,
7514 "SET_WAPI_KEY" },
7515
7516 /* handlers for main ioctl SET_WAPI_BKID */
7517 { WLAN_PRIV_SET_WAPI_BKID,
7518 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7519 0,
7520 "SET_WAPI_BKID" },
7521
7522 /* handlers for main ioctl GET_WAPI_BKID */
7523 { WLAN_PRIV_GET_WAPI_BKID,
7524 0,
7525 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7526 "GET_WAPI_BKID" },
7527#endif /* FEATURE_WLAN_WAPI */
7528
7529 /* handlers for main ioctl - host offload */
7530 {
7531 WLAN_PRIV_SET_HOST_OFFLOAD,
7532 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
7533 0,
7534 "setHostOffload" },
7535
7536 {
7537 WLAN_GET_WLAN_STATISTICS,
7538 0,
7539 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
7540 "getWlanStats" },
7541
7542 {
7543 WLAN_SET_KEEPALIVE_PARAMS,
7544 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
7545 0,
7546 "setKeepAlive" },
7547#ifdef WLAN_FEATURE_PACKET_FILTERING
7548 {
7549 WLAN_SET_PACKET_FILTER_PARAMS,
7550 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
7551 0,
7552 "setPktFilter" },
7553#endif
7554#ifdef FEATURE_WLAN_SCAN_PNO
7555 {
7556 WLAN_SET_PNO,
7557 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7558 0,
7559 "setpno" },
7560#endif
7561 {
7562 WLAN_SET_BAND_CONFIG,
7563 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7564 0,
7565 "SETBAND" },
7566 /* handlers for dynamic MC BC ioctl */
7567 {
7568 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007569 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 0,
7571 "setMCBCFilter" },
7572 {
7573 WLAN_PRIV_CLEAR_MCBC_FILTER,
7574 0,
7575 0,
7576 "clearMCBCFilter" },
7577 {
7578 WLAN_SET_POWER_PARAMS,
7579 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7580 0,
7581 "setpowerparams" },
7582 {
7583 WLAN_GET_LINK_SPEED,
7584 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05307585 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007586};
7587
7588
7589
7590const struct iw_handler_def we_handler_def = {
7591 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
7592 .num_private = sizeof(we_private) / sizeof(we_private[0]),
7593 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
7594
7595 .standard = (iw_handler *)we_handler,
7596 .private = (iw_handler *)we_private,
7597 .private_args = we_private_args,
7598 .get_wireless_stats = get_wireless_stats,
7599};
7600
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007601int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
7602{
7603 v_U32_t cmd = 288; //Command to RIVA
7604 hdd_context_t *pHddCtx = NULL;
7605 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7606 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7607 /*
7608 *configMccParam : specify the bit which needs to be modified
7609 *allowed to update based on wlan_qcom_cfg.ini
7610 * configuration
7611 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
7612 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
7613 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
7614 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
7615 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
7616 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
7617 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
7618 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
7619 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
7620 * Bit 9 : Reserved
7621 */
7622 switch (arg1)
7623 {
7624 //Update MCC SCHEDULE_TIME_SLICE parameter
7625 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
7626 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
7627 {
7628 if((arg2 >= 5) && (arg2 <= 20))
7629 {
7630 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7631 }
7632 else
7633 {
7634 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7635 return 0;
7636 }
7637 }
7638 break;
7639
7640 //Update MCC MAX_NULL_SEND_TIME parameter
7641 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
7642 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
7643 {
7644 if((arg2 >= 1) && (arg2 <= 10))
7645 {
7646 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7647 }
7648 else
7649 {
7650 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7651 return 0;
7652 }
7653 }
7654 break;
7655
7656 //Update MCC TX_EARLY_STOP_TIME parameter
7657 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
7658 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
7659 {
7660 if((arg2 >= 1) && (arg2 <= 10))
7661 {
7662 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7663 }
7664 else
7665 {
7666 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7667 return 0;
7668 }
7669 }
7670 break;
7671
7672 //Update MCC RX_DRAIN_TIME parameter
7673 case MCC_RX_DRAIN_TIME_CFG_PARAM :
7674 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
7675 {
7676 if((arg2 >= 1) && (arg2 <= 10))
7677 {
7678 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7679 }
7680 else
7681 {
7682 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7683 return 0;
7684 }
7685 }
7686 break;
7687
7688 //Update MCC CHANNEL_SWITCH_TIME parameter
7689 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
7690 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
7691 {
7692 if((arg2 >= 1) && (arg2 <= 20))
7693 {
7694 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7695 }
7696 else
7697 {
7698 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7699 return 0;
7700 }
7701 }
7702 break;
7703
7704 //Update MCC MIN_CHANNEL_TIME parameter
7705 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
7706 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
7707 {
7708 if((arg2 >= 5) && (arg2 <= 20))
7709 {
7710 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7711 }
7712 else
7713 {
7714 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7715 return 0;
7716 }
7717 }
7718 break;
7719
7720 //Update MCC PARK_BEFORE_TBTT parameter
7721 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
7722 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
7723 {
7724 if((arg2 >= 1) && (arg2 <= 5))
7725 {
7726 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7727 }
7728 else
7729 {
7730 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7731 return 0;
7732 }
7733 }
7734 break;
7735
7736 //Update MCC MIN_AFTER_DTIM parameter
7737 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
7738 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
7739 {
7740 if((arg2 >= 5) && (arg2 <= 15))
7741 {
7742 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7743 }
7744 else
7745 {
7746 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7747 return 0;
7748 }
7749 }
7750 break;
7751
7752 //Update MCC TOO_CLOSE_MARGIN parameter
7753 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
7754 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
7755 {
7756 if((arg2 >= 1) && (arg2 <= 3))
7757 {
7758 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7759 }
7760 else
7761 {
7762 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7763 return 0;
7764 }
7765 }
7766 break;
7767
7768 default :
7769 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d\n",
7770 __FUNCTION__,arg1);
7771 break;
7772 }
7773 return 0;
7774}
7775
Jeff Johnson295189b2012-06-20 16:38:30 -07007776int hdd_set_wext(hdd_adapter_t *pAdapter)
7777{
7778 hdd_wext_state_t *pwextBuf;
7779 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007780 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007781
7782 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7783
7784 // Now configure the roaming profile links. To SSID and bssid.
7785 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
7786 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
7787
7788 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
7789 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
7790
7791 /*Set the numOfChannels to zero to scan all the channels*/
7792 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
7793 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
7794
7795 /* Default is no encryption */
7796 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
7797 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7798
7799 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
7800 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7801
7802 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
7803
7804 /* Default is no authentication */
7805 pwextBuf->roamProfile.AuthType.numEntries = 1;
7806 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
7807
7808 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
7809 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
7810
7811 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007812 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07007813
7814 hdd_clearRoamProfileIe(pAdapter);
7815
7816 return VOS_STATUS_SUCCESS;
7817
7818 }
7819
7820int hdd_register_wext(struct net_device *dev)
7821 {
7822 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7823 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7824 VOS_STATUS status;
7825
7826 ENTER();
7827
7828 // Zero the memory. This zeros the profile structure.
7829 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
7830
7831 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
7832
7833
7834 status = hdd_set_wext(pAdapter);
7835
7836 if(!VOS_IS_STATUS_SUCCESS(status)) {
7837
7838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!\n"));
7839 return eHAL_STATUS_FAILURE;
7840 }
7841
7842 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
7843 {
7844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!\n"));
7845 return eHAL_STATUS_FAILURE;
7846 }
7847
7848 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
7849 {
7850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!\n"));
7851 return eHAL_STATUS_FAILURE;
7852 }
7853
7854 // Register as a wireless device
7855 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
7856
7857 EXIT();
7858 return 0;
7859}
7860
7861int hdd_UnregisterWext(struct net_device *dev)
7862{
7863#if 0
7864 hdd_wext_state_t *wextBuf;
7865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7866
7867 ENTER();
7868 // Set up the pointer to the Wireless Extensions state structure
7869 wextBuf = pAdapter->pWextState;
7870
7871 // De-allocate the Wireless Extensions state structure
7872 kfree(wextBuf);
7873
7874 // Clear out the pointer to the Wireless Extensions state structure
7875 pAdapter->pWextState = NULL;
7876
7877 EXIT();
7878#endif
7879 dev->wireless_handlers = NULL;
7880 return 0;
7881}
7882
7883