blob: 46820dff6cfab4806d835ce507d53be656fef538 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala9c070ad2013-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 Koyyalamudi3c46b8f2013-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 NGde0b4112013-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 Koyyalamudi56dfbbd2013-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 Nakkala6fee7092013-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 Koyyalamudi3fb3fd62012-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 Koyyalamudife270a12013-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 Girigowda2471d832013-01-25 13:33:11 -0800211#define WE_GET_ROAM_RSSI 7
Chilam Ng659dc3f2013-01-29 01:27:29 -0800212#ifdef FEATURE_WLAN_TDLS
213#define WE_GET_TDLS_PEERS 8
214#endif
Chet Lanctota96bb432013-03-18 10:26:30 -0700215#ifdef WLAN_FEATURE_11W
216#define WE_GET_11W_INFO 9
217#endif
Madan Mohan Koyyalamudi3c46b8f2013-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 Koyyalamudi56dfbbd2013-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 NGde0b4112013-01-19 12:27:36 +0530241#ifdef FEATURE_WLAN_TDLS
242#define WE_TDLS_CONFIG_PARAMS 5
243#endif
244
Chilam Ng66213252013-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 Ng66213252013-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 Koyyalamudi3c46b8f2013-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 Johnsonbb2eccc2013-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 Johnsonbb2eccc2013-02-12 14:23:57 -0800388 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700389
390 --------------------------------------------------------------------------*/
Jeff Johnsonbb2eccc2013-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 Johnsonbb2eccc2013-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 Johnsonbb2eccc2013-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 Johnsonbb2eccc2013-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 Johnsonbb2eccc2013-02-12 14:23:57 -0800418 else
419 {
420 pHWversion = "Unknown";
421 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700422
Jeff Johnsonbb2eccc2013-02-12 14:23:57 -0800423 wrqu->data.length = snprintf(extra, WE_MAX_STR_LEN,
424 "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 Lanctota96bb432013-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 Koyyalamudife270a12013-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 Koyyalamudife270a12013-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 Girigowda2471d832013-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 Lanctota96bb432013-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 Lanctota96bb432013-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 Johnson09097582013-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 Johnson09097582013-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 Johnson09097582013-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 Bhattacharyyae0b30532013-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 Johnson09097582013-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 Johnson09097582013-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 Karmuchid58f7912013-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 Thalappil5d3cbc42013-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 Thalappil5d3cbc42013-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 Thalappil5d3cbc42013-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 Johnson0e7c2332013-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 Johnson0e7c2332013-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 Nakkala11ab4da2013-05-29 15:33:14 +05302467 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala11ab4da2013-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 Nakkala11ab4da2013-05-29 15:33:14 +05302472 VOS_STATUS status;
2473 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002474
Gopichand Nakkala11ab4da2013-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 Thalappil5d3cbc42013-02-21 19:38:16 -08002480 {
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05302481 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2482 return valid;
Sameer Thalappil5d3cbc42013-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 Nakkala11ab4da2013-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 Nakkala11ab4da2013-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 Nakkala11ab4da2013-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 */
2559 rc = snprintf(cmd, len, "OK");
2560 }
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 */
2574 rc = snprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
2575 }
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 Koyyalamudi8bca2fd2012-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 }
Yathishd8713192012-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 Nakkala35dc7db2013-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;
2929 char *ptr = (char*)(cmd + 9);
2930
2931 sscanf(ptr,"%d",&mode);
2932 wlan_hdd_enter_bmps(pAdapter, mode);
2933 /*TODO:Set the power mode*/
2934 }
2935 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
2936 v_U32_t pmc_state;
2937 v_U16_t value;
2938
2939 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
2940 if(pmc_state == BMPS) {
2941 value = DRIVER_POWER_MODE_AUTO;
2942 }
2943 else {
2944 value = DRIVER_POWER_MODE_ACTIVE;
2945 }
2946 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
2947 }
2948 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
2949 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode\n");
2950 /*TODO: set the btcoexmode*/
2951 }
2952 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
2953
2954 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status\n");
2955 /*TODO: Return the btcoex status*/
2956 }
2957 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
2958
2959 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command\n");
2960
2961 /*TODO: Enable Rx data Filter*/
2962 }
2963 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
2964
2965 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command\n");
2966
2967 /*TODO: Disable Rx data Filter*/
2968 }
2969 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
2970
2971 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command\n");
2972 /*TODO: rxfilter-statistics*/
2973 }
2974 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
2975
2976 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add\n");
2977 /*TODO: rxfilter-add*/
2978 }
2979 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
2980
2981 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove\n");
2982 /*TODO: rxfilter-remove*/
2983 }
2984#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07002985 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
2986 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
2987 /*TODO: support pnosetup*/
2988 }
2989 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
2990 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
2991 /*TODO: support pnoforce*/
2992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 else if( strncasecmp(cmd, "pno",3) == 0 ) {
2994
2995 hddLog( VOS_TRACE_LEVEL_INFO, "pno\n");
2996 status = iw_set_pno(dev, info, wrqu, extra, 3);
2997 return status;
2998 }
2999 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
3000
3001 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter\n");
3002 status = iw_set_rssi_filter(dev, info, wrqu, extra, 10);
3003 return status;
3004 }
3005#endif /*FEATURE_WLAN_SCAN_PNO*/
3006 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
3007 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams\n");
3008 status = iw_set_power_params(dev, info, wrqu, extra, 11);
3009 return status;
3010 }
3011 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3012 tSirTxPerTrackingParam tTxPerTrackingParam;
3013 char *ptr = (char*)(cmd + 18);
3014 sscanf(ptr,"%hhu %hhu %hhu %lu",&(tTxPerTrackingParam.ucTxPerTrackingEnable), &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3015 &(tTxPerTrackingParam.ucTxPerTrackingRatio), &(tTxPerTrackingParam.uTxPerTrackingWatermark));
3016
3017 // parameters checking
3018 // period has to be larger than 0
3019 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3020 {
3021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
3022 return VOS_STATUS_E_FAILURE;
3023 }
3024
3025 // use default value 5 is the input is not reasonable. in unit of 10%
3026 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3027 {
3028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3029 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3030 }
3031
3032 // default is 5
3033 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3034 {
3035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3036 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3037 }
3038
3039 status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam);
3040 if(status != eHAL_STATUS_SUCCESS){
3041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
3042 }
3043 }
3044 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003045 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3046 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 }
3048done:
3049 /* many of the commands write information back into the command
3050 string using snprintf(). check the return value here in one
3051 place */
3052 if ((ret < 0) || (ret >= cmd_len))
3053 {
3054 /* there was an encoding error or overflow */
3055 status = -EIO;
3056 }
3057
3058 if (ioctl_debug)
3059 {
3060 pr_info("%s: rsp [%s] len [%d] status %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003061 __func__, cmd, wrqu->data.length, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 }
3063 return status;
3064
3065}
3066
3067static int iw_set_nick(struct net_device *dev,
3068 struct iw_request_info *info,
3069 union iwreq_data *wrqu, char *extra)
3070{
3071 ENTER();
3072 return 0;
3073}
3074
3075static int iw_get_nick(struct net_device *dev,
3076 struct iw_request_info *info,
3077 union iwreq_data *wrqu, char *extra)
3078{
3079 ENTER();
3080 return 0;
3081}
3082
3083static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3084{
3085 ENTER();
3086 return NULL;
3087}
3088
3089static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3090 union iwreq_data *wrqu,char *extra)
3091
3092{
3093 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3094 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3095 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3096 struct iw_point *encoderq = &(wrqu->encoding);
3097 v_U32_t keyId;
3098 v_U8_t key_length;
3099 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3100 v_BOOL_t fKeyPresent = 0;
3101 int i;
3102 eHalStatus status = eHAL_STATUS_SUCCESS;
3103
3104
3105 ENTER();
3106
3107 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3108 {
3109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3110 "%s:LOGP in Progress. Ignore!!!",__func__);
3111 return 0;
3112 }
3113
3114
3115 keyId = encoderq->flags & IW_ENCODE_INDEX;
3116
3117 if(keyId)
3118 {
3119 if(keyId > MAX_WEP_KEYS)
3120 {
3121 return -EINVAL;
3122 }
3123
3124 fKeyPresent = 1;
3125 keyId--;
3126 }
3127 else
3128 {
3129 fKeyPresent = 0;
3130 }
3131
3132
3133 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3134 {
3135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****\n");
3136 if(!fKeyPresent) {
3137
3138 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3139
3140 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3141 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3142 }
3143 }
3144 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3145 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3146 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3147 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3148
3149 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3150 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3151
3152 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3153 {
3154 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3155 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003156 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3158 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3159 }
3160
3161 return status;
3162
3163 }
3164
3165 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3166 {
3167 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3168
3169 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3170
3171 }
3172
3173
3174 if(wrqu->data.length > 0)
3175 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003176 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003177
3178 key_length = wrqu->data.length;
3179
3180 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3181
3182 if(5 == key_length)
3183 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003184 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003185
3186 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3187 {
3188 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3189 }
3190 else
3191 {
3192 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3193 }
3194 }
3195 else if(13 == key_length)
3196 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003197 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003198
3199 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3200 {
3201 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3202 }
3203 else
3204 {
3205 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3206 }
3207 }
3208 else
3209 {
3210 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003211 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 return -EINVAL;
3213 }
3214
3215 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3216 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3217 pWextState->roamProfile.EncryptionType.numEntries = 1;
3218 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3219 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3220 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3221
3222 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3223 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3224 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3225 {
3226
3227 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3228
3229 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3230 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3231
3232 return status;
3233 }
3234 }
3235
3236 return 0;
3237}
3238
3239static int iw_get_encodeext(struct net_device *dev,
3240 struct iw_request_info *info,
3241 struct iw_point *dwrq,
3242 char *extra)
3243{
3244 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3245 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3246 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3247 int keyId;
3248 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3249 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3250 int i;
3251
3252 ENTER();
3253
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08003254 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3255 {
3256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3257 "%s:LOGP in Progress. Ignore!!!", __func__);
3258 return -EBUSY;
3259 }
3260
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 keyId = pRoamProfile->Keys.defaultIndex;
3262
3263 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3264 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003265 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 return -EINVAL;
3267 }
3268
3269 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3270 {
3271 dwrq->flags |= IW_ENCODE_ENABLED;
3272 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachariaa1f1342013-07-24 16:55:34 +05303273 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3274 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 }
3276 else
3277 {
3278 dwrq->flags |= IW_ENCODE_DISABLED;
3279 }
3280
3281 for(i=0; i < MAX_WEP_KEYS; i++)
3282 {
3283 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3284 {
3285 continue;
3286 }
3287 else
3288 {
3289 break;
3290 }
3291 }
3292
3293 if(MAX_WEP_KEYS == i)
3294 {
3295 dwrq->flags |= IW_ENCODE_NOKEY;
3296 }
3297 else
3298 {
3299 dwrq->flags |= IW_ENCODE_ENABLED;
3300 }
3301
3302 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3303
3304 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3305 {
3306 dwrq->flags |= IW_ENCODE_DISABLED;
3307 }
3308
3309 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3310
3311 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3312 {
3313 dwrq->flags |= IW_ENCODE_OPEN;
3314 }
3315 else
3316 {
3317 dwrq->flags |= IW_ENCODE_RESTRICTED;
3318 }
3319 EXIT();
3320 return 0;
3321
3322}
3323
3324static int iw_set_encodeext(struct net_device *dev,
3325 struct iw_request_info *info,
3326 union iwreq_data *wrqu, char *extra)
3327{
3328 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3329 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3330 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3331 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3332
3333 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3334 v_U32_t status = 0;
3335
3336 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3337
3338 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3339
3340 int key_index;
3341 struct iw_point *encoding = &wrqu->encoding;
3342 tCsrRoamSetKey setKey;
3343 v_U32_t roamId= 0xFF;
3344 VOS_STATUS vos_status;
3345
3346 ENTER();
3347
3348 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3349 {
3350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3351 "%s:LOGP in Progress. Ignore!!!",__func__);
3352 return 0;
3353 }
3354
3355 key_index = encoding->flags & IW_ENCODE_INDEX;
3356
3357 if(key_index > 0) {
3358
3359 /*Convert from 1-based to 0-based keying*/
3360 key_index--;
3361 }
3362 if(!ext->key_len) {
3363
3364 /*Set the encrytion type to NONE*/
3365 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3366 return status;
3367 }
3368
3369 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3370 (IW_ENCODE_ALG_WEP == ext->alg))
3371 {
3372 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3373
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003374 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s \n"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 return -EINVAL;
3376 }
3377 else {
3378 /*Static wep, update the roam profile with the keys */
3379 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3380 key_index < CSR_MAX_NUM_KEY) {
3381 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3382 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3383
3384 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3385 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3386
3387 }
3388 }
3389 return status;
3390 }
3391
3392 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3393
3394 setKey.keyId = key_index;
3395 setKey.keyLength = ext->key_len;
3396
3397 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3398 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3399 }
3400
3401 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3402 /*Key direction for group is RX only*/
3403 setKey.keyDirection = eSIR_RX_ONLY;
3404 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3405 }
3406 else {
3407
3408 setKey.keyDirection = eSIR_TX_RX;
3409 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3410 }
3411
3412 /*For supplicant pae role is zero*/
3413 setKey.paeRole = 0;
3414
3415 switch(ext->alg)
3416 {
3417 case IW_ENCODE_ALG_NONE:
3418 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3419 break;
3420
3421 case IW_ENCODE_ALG_WEP:
3422 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3423 break;
3424
3425 case IW_ENCODE_ALG_TKIP:
3426 {
3427 v_U8_t *pKey = &setKey.Key[0];
3428
3429 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3430
3431 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3432
3433 /*Supplicant sends the 32bytes key in this order
3434
3435 |--------------|----------|----------|
3436 | Tk1 |TX-MIC | RX Mic |
3437 |--------------|----------|----------|
3438 <---16bytes---><--8bytes--><--8bytes-->
3439
3440 */
3441 /*Sme expects the 32 bytes key to be in the below order
3442
3443 |--------------|----------|----------|
3444 | Tk1 |RX-MIC | TX Mic |
3445 |--------------|----------|----------|
3446 <---16bytes---><--8bytes--><--8bytes-->
3447 */
3448 /* Copy the Temporal Key 1 (TK1) */
3449 vos_mem_copy(pKey,ext->key,16);
3450
3451 /*Copy the rx mic first*/
3452 vos_mem_copy(&pKey[16],&ext->key[24],8);
3453
3454 /*Copy the tx mic */
3455 vos_mem_copy(&pKey[24],&ext->key[16],8);
3456
3457 }
3458 break;
3459
3460 case IW_ENCODE_ALG_CCMP:
3461 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3462 break;
3463
3464#ifdef FEATURE_WLAN_CCX
3465#define IW_ENCODE_ALG_KRK 6
3466 case IW_ENCODE_ALG_KRK:
3467 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3468 break;
3469#endif /* FEATURE_WLAN_CCX */
3470
3471 default:
3472 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3473 break;
3474 }
3475
3476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003477 ("%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 -07003478
3479#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkalaedddbd92013-05-07 16:19:14 +05303480 /* The supplicant may attempt to set the PTK once pre-authentication
3481 is done. Save the key in the UMAC and include it in the ADD
3482 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkalaedddbd92013-05-07 16:19:14 +05303484 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 {
Gopichand Nakkalaedddbd92013-05-07 16:19:14 +05303486 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3487 "%s: Update PreAuth Key success", __func__);
3488 return 0;
3489 }
3490 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3491 {
3492 hddLog(VOS_TRACE_LEVEL_ERROR,
3493 "%s: Update PreAuth Key failed", __func__);
3494 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 }
3496#endif /* WLAN_FEATURE_VOWIFI_11R */
3497
3498 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3499
3500 vos_status = wlan_hdd_check_ula_done(pAdapter);
3501 if ( vos_status != VOS_STATUS_SUCCESS )
3502 {
3503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3504 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3505 __LINE__, vos_status );
3506
3507 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3508 }
3509
3510 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3511
3512 if ( halStatus != eHAL_STATUS_SUCCESS )
3513 {
3514 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3515 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3516 __LINE__, halStatus );
3517
3518 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3519 }
3520
3521 return halStatus;
3522}
3523
3524static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3525 union iwreq_data *wrqu, char *extra)
3526{
3527 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3528 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3529
3530 ENTER();
3531
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08003532 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3533 {
3534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3535 "%s:LOGP in Progress. Ignore!!!", __func__);
3536 return -EBUSY;
3537 }
3538
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3540 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3541
3542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%ld!!\n"),wrqu->retry.value);
3543
3544 return -EINVAL;
3545 }
3546
3547 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3548
3549 if((wrqu->retry.flags & IW_RETRY_LONG))
3550 {
3551 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3552 {
3553 return -EIO;
3554 }
3555 }
3556 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3557 {
3558 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3559 {
3560 return -EIO;
3561 }
3562 }
3563 }
3564 else
3565 {
3566 return -EOPNOTSUPP;
3567 }
3568
3569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%ld!!\n"),wrqu->retry.value);
3570
3571 EXIT();
3572
3573 return 0;
3574
3575}
3576
3577static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3578 union iwreq_data *wrqu, char *extra)
3579{
3580 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3581 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3582 v_U32_t retry = 0;
3583
3584 ENTER();
3585
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08003586 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3587 {
3588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3589 "%s:LOGP in Progress. Ignore!!!", __func__);
3590 return -EBUSY;
3591 }
3592
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 if((wrqu->retry.flags & IW_RETRY_LONG))
3594 {
3595 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3596
3597 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3598 {
3599 return -EIO;
3600 }
3601
3602 wrqu->retry.value = retry;
3603 }
3604 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3605 {
3606 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3607
3608 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3609 {
3610 return -EIO;
3611 }
3612
3613 wrqu->retry.value = retry;
3614 }
3615 else {
3616 return -EOPNOTSUPP;
3617 }
3618
3619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%ld!!\n"),retry);
3620
3621 EXIT();
3622
3623 return 0;
3624}
3625
3626static int iw_set_mlme(struct net_device *dev,
3627 struct iw_request_info *info,
3628 union iwreq_data *wrqu,
3629 char *extra)
3630{
3631 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3632 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3633 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3634 eHalStatus status = eHAL_STATUS_SUCCESS;
3635
3636 ENTER();
3637
3638 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3639 {
3640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3641 "%s:LOGP in Progress. Ignore!!!",__func__);
3642 return 0;
3643 }
3644
3645 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3646 switch (mlme->cmd) {
3647 case IW_MLME_DISASSOC:
3648 case IW_MLME_DEAUTH:
3649
3650 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3651 {
3652 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3653
3654 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3655 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3656
3657 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3658 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3659
Jeff Johnson43971f52012-07-17 12:26:56 -07003660 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3662 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3663 else
3664 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003665 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003666
3667 /* Resetting authKeyMgmt */
3668 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3669
3670 netif_tx_disable(dev);
3671 netif_carrier_off(dev);
3672
3673 }
3674 else
3675 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003676 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 -07003677 }
3678 break;
3679 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003680 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 return -EINVAL;
3682 }//end of switch
3683
3684 EXIT();
3685
3686 return status;
3687
3688}
3689
3690/* set param sub-ioctls */
3691static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3692 union iwreq_data *wrqu, char *extra)
3693{
3694 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3695 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3696 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3697 int *value = (int *)extra;
3698 int sub_cmd = value[0];
3699 int set_value = value[1];
3700 int ret = 0; /* success */
3701 int enable_pbm, enable_mp;
3702#ifdef CONFIG_HAS_EARLYSUSPEND
3703 v_U8_t nEnableSuspendOld;
3704#endif
3705 INIT_COMPLETION(pWextState->completion_var);
3706
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08003707 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3708 {
3709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3710 "%s:LOGP in Progress. Ignore!!!", __func__);
3711 return -EBUSY;
3712 }
3713
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 switch(sub_cmd)
3715 {
3716 case WE_SET_11D_STATE:
3717 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003718 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3720
3721 sme_GetConfigParam(hHal,&smeConfig);
3722 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3723
3724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),smeConfig.csrConfig.Is11dSupportEnabled);
3725
3726 sme_UpdateConfig(hHal,&smeConfig);
3727 }
3728 else {
3729 return -EINVAL;
3730 }
3731 break;
3732 }
3733
3734 case WE_WOWL:
3735 {
3736 switch (set_value)
3737 {
3738 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003739 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 break;
3741 case 0x01:
3742 case 0x02:
3743 case 0x03:
3744 enable_mp = (set_value & 0x01) ? 1 : 0;
3745 enable_pbm = (set_value & 0x02) ? 1 : 0;
3746 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s\n",
3747 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3748 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3749 break;
3750 default:
3751 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL\n", set_value);
3752 ret = -EINVAL;
3753 break;
3754 }
3755
3756 break;
3757 }
3758 case WE_SET_POWER:
3759 {
3760 switch (set_value)
3761 {
3762 case 0: //Full Power
3763 {
3764 struct statsContext context;
3765 eHalStatus status;
3766
3767 init_completion(&context.completion);
3768
3769 context.pAdapter = pAdapter;
3770 context.magic = POWER_CONTEXT_MAGIC;
3771
3772 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3773 iw_power_callback_fn, &context,
3774 eSME_FULL_PWR_NEEDED_BY_HDD);
3775 if(eHAL_STATUS_PMC_PENDING == status)
3776 {
3777 int lrc = wait_for_completion_interruptible_timeout(
3778 &context.completion,
3779 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3780 context.magic = 0;
3781 if (lrc <= 0)
3782 {
3783 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3784 "requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003785 __func__, (0 == lrc) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 "timeout" : "interrupt");
3787 /* there is a race condition such that the callback
3788 function could be executing at the same time we are. of
3789 primary concern is if the callback function had already
3790 verified the "magic" but hasn't yet set the completion
3791 variable. Since the completion variable is on our
3792 stack, we'll delay just a bit to make sure the data is
3793 still valid if that is the case */
3794 msleep(50);
3795 /* we'll now returned a cached value below */
3796 }
3797 }
3798 hddLog(LOGE, "iwpriv Full Power completed\n");
3799 break;
3800 }
3801 case 1: //Enable BMPS
3802 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3803 break;
3804 case 2: //Disable BMPS
3805 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3806 break;
3807 case 3: //Request Bmps
3808 {
3809 struct statsContext context;
3810 eHalStatus status;
3811
3812 init_completion(&context.completion);
3813
3814 context.pAdapter = pAdapter;
3815 context.magic = POWER_CONTEXT_MAGIC;
3816
3817 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3818 iw_power_callback_fn, &context);
3819 if(eHAL_STATUS_PMC_PENDING == status)
3820 {
3821 int lrc = wait_for_completion_interruptible_timeout(
3822 &context.completion,
3823 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3824 context.magic = 0;
3825 if (lrc <= 0)
3826 {
3827 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3828 "requesting BMPS",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003829 __func__, (0 == lrc) ? "timeout" :
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 "interrupt");
3831 /* there is a race condition such that the callback
3832 function could be executing at the same time we are. of
3833 primary concern is if the callback function had already
3834 verified the "magic" but hasn't yet set the completion
3835 variable. Since the completion variable is on our
3836 stack, we'll delay just a bit to make sure the data is
3837 still valid if that is the case */
3838 msleep(50);
3839 /* we'll now returned a cached value below */
3840 }
3841 }
3842 hddLog(LOGE, "iwpriv Request BMPS completed\n");
3843 break;
3844 }
3845 case 4: //Enable IMPS
3846 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3847 break;
3848 case 5: //Disable IMPS
3849 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3850 break;
3851 case 6: //Enable Standby
3852 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3853 break;
3854 case 7: //Disable Standby
3855 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3856 break;
3857 case 8: //Request Standby
3858#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003859#endif
3860 break;
3861 case 9: //Start Auto Bmps Timer
3862 sme_StartAutoBmpsTimer(hHal);
3863 break;
3864 case 10://Stop Auto BMPS Timer
3865 sme_StopAutoBmpsTimer(hHal);
3866 break;
3867#ifdef CONFIG_HAS_EARLYSUSPEND
3868 case 11://suspend to standby
3869#ifdef CONFIG_HAS_EARLYSUSPEND
3870 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3871 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3873#endif
3874 break;
3875 case 12://suspend to deep sleep
3876#ifdef CONFIG_HAS_EARLYSUSPEND
3877 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3878 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3880#endif
3881 break;
3882 case 13://resume from suspend
3883#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003884#endif
3885 break;
3886#endif
3887 case 14://reset wlan (power down/power up)
3888 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
3889 break;
3890 default:
3891 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL\n", set_value);
3892 ret = -EINVAL;
3893 break;
3894 }
3895 break;
3896 }
3897
3898 case WE_SET_MAX_ASSOC:
3899 {
3900 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
3901 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
3902 {
3903 ret = -EINVAL;
3904 }
3905 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
3906 set_value, NULL, eANI_BOOLEAN_FALSE)
3907 != eHAL_STATUS_SUCCESS )
3908 {
3909 ret = -EIO;
3910 }
3911 break;
3912 }
3913
3914 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
3915 {
3916 if( 0 == set_value )
3917 {
3918 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
3919 }
3920 else if ( 1 == set_value )
3921 {
3922 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
3923 }
3924 else
3925 {
3926 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL\n", set_value);
3927 ret = -EINVAL;
3928 }
3929 break;
3930 }
3931
3932 case WE_SET_DATA_INACTIVITY_TO:
3933 {
3934 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
3935 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
3936 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
3937 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
3938 set_value,
3939 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
3940 {
3941 hddLog(LOGE,"Failure: Could not pass on "
3942 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
3943 "to CCM\n");
3944 ret = -EINVAL;
3945 }
3946 break;
3947 }
3948 case WE_SET_MAX_TX_POWER:
3949 {
3950 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3951 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3952
3953 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
3954 __func__, set_value);
3955 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
3956 eHAL_STATUS_SUCCESS )
3957 {
3958 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
3959 __func__);
3960 return -EIO;
3961 }
3962
3963 break;
3964 }
3965 case WE_SET_HIGHER_DTIM_TRANSITION:
3966 {
3967 if(!((set_value == eANI_BOOLEAN_FALSE) ||
3968 (set_value == eANI_BOOLEAN_TRUE)))
3969 {
3970 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
3971 ret = -EINVAL;
3972 }
3973 else
3974 {
3975 if(pAdapter->higherDtimTransition != set_value)
3976 {
3977 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003978 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 }
3980 }
3981
3982 break;
3983 }
3984
3985 case WE_SET_TM_LEVEL:
3986 {
3987 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
3988 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
3989 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
3990
3991 break;
3992 }
3993
3994 default:
3995 {
3996 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d \n",
3997 sub_cmd, set_value);
3998 break;
3999 }
4000 }
4001
4002 return ret;
4003}
4004
4005/* set param sub-ioctls */
4006static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4007 union iwreq_data *wrqu, char *extra)
4008{
4009 VOS_STATUS vstatus;
4010 int sub_cmd = wrqu->data.flags;
4011 int ret = 0; /* success */
4012 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4013 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4014#ifdef WLAN_FEATURE_VOWIFI
4015 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4016#endif /* WLAN_FEATURE_VOWIFI */
4017
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received length %d", __func__, wrqu->data.length);
4019 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 -07004020
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004021 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4022 {
4023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4024 "%s:LOGP in Progress. Ignore!!!", __func__);
4025 return -EBUSY;
4026 }
4027
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 switch(sub_cmd)
4029 {
4030 case WE_WOWL_ADD_PTRN:
4031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004032 hdd_add_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 break;
4034 case WE_WOWL_DEL_PTRN:
4035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004036 hdd_del_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 break;
4038#if defined WLAN_FEATURE_VOWIFI
4039 case WE_NEIGHBOR_REPORT_REQUEST:
4040 {
4041 tRrmNeighborReq neighborReq;
4042 tRrmNeighborRspCallbackInfo callbackInfo;
4043
4044 if (pConfig->fRrmEnable)
4045 {
4046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request\n");
4047 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4048 if( !neighborReq.no_ssid )
4049 {
4050 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
4051 vos_mem_copy( neighborReq.ssid.ssId, wrqu->data.pointer, neighborReq.ssid.length );
4052 }
4053
4054 callbackInfo.neighborRspCallback = NULL;
4055 callbackInfo.neighborRspCallbackContext = NULL;
4056 callbackInfo.timeout = 5000; //5 seconds
4057 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4058 }
4059 else
4060 {
4061 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled\n", __func__);
4062 ret = -EINVAL;
4063 }
4064 }
4065 break;
4066#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 case WE_SET_AP_WPS_IE:
4068 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), wrqu->data.pointer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 case WE_SET_CONFIG:
4072 vstatus = hdd_execute_config_command(pHddCtx, wrqu->data.pointer);
4073 if (VOS_STATUS_SUCCESS != vstatus)
4074 {
4075 ret = -EINVAL;
4076 }
4077 break;
4078 default:
4079 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004080 hddLog(LOGE, "%s: Invalid sub command %d\n",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 ret = -EINVAL;
4082 break;
4083 }
4084 }
4085 return ret;
4086}
4087
4088/* get param sub-ioctls */
4089static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4090 union iwreq_data *wrqu, char *extra)
4091{
4092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4093 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4094 int *value = (int *)extra;
4095 int ret = 0; /* success */
4096
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004097 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4098 {
4099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4100 "%s:LOGP in Progress. Ignore!!!", __func__);
4101 return -EBUSY;
4102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004103
4104 switch (value[0])
4105 {
4106 case WE_GET_11D_STATE:
4107 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004108 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi3c46b8f2013-07-11 14:59:10 +05304110
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4112
4113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),*value);
4114
4115 break;
4116 }
4117
4118 case WE_IBSS_STATUS:
4119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****\n");
4120 break;
4121
4122 case WE_PMC_STATE:
4123 {
4124 *value = pmcGetPmcState(hHal);
4125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%ld!!\n"),*value);
4126 break;
4127 }
4128 case WE_GET_WLAN_DBG:
4129 {
4130 vos_trace_display();
4131 *value = 0;
4132 break;
4133 }
4134 case WE_MODULE_DOWN_IND:
4135 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4138#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4141#endif
4142 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4143
4144 *value = 0;
4145 break;
4146 }
4147 case WE_GET_MAX_ASSOC:
4148 {
4149 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4150 {
4151 ret = -EIO;
4152 }
4153 break;
4154 }
4155
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 case WE_GET_WDI_DBG:
4157 {
4158 wpalTraceDisplay();
4159 *value = 0;
4160 break;
4161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004162
4163 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4164 {
4165 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4166 break;
4167 }
4168 case WE_GET_CONCURRENCY_MODE:
4169 {
4170 *value = hdd_get_concurrency_mode ( );
4171
4172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d \n"),*value);
4173 break;
4174 }
4175
4176 default:
4177 {
4178 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4179 break;
4180 }
4181 }
4182
4183 return ret;
4184}
4185
4186/* set param sub-ioctls */
4187int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4188 union iwreq_data *wrqu, char *extra)
4189{
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004190 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 int *value = (int *)extra;
4192 int sub_cmd = value[0];
4193 int ret = 0;
4194
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004195 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4196 {
4197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4198 "%s:LOGP in Progress. Ignore!!!", __func__);
4199 return -EBUSY;
4200 }
4201
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 switch(sub_cmd)
4203 {
4204 case WE_SET_WLAN_DBG:
4205 {
4206 vos_trace_setValue( value[1], value[2], value[3]);
4207 break;
4208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 case WE_SET_WDI_DBG:
4210 {
4211 wpalTraceSetLevel( value[1], value[2], value[3]);
4212 break;
4213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 case WE_SET_SAP_CHANNELS:
4215 {
4216 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4217 break;
4218 }
4219
4220 default:
4221 {
4222 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4223 break;
4224 }
4225 }
4226 return ret;
4227}
4228
4229static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4230 union iwreq_data *wrqu, char *extra)
4231{
4232 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4233 int sub_cmd = wrqu->data.flags;
Chet Lanctota96bb432013-03-18 10:26:30 -07004234#ifdef WLAN_FEATURE_11W
4235 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4236#endif
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004237
Yue Ma0bc970b2013-08-29 00:33:26 -07004238 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4239 {
4240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4241 "%s: HDD Context is NULL!", __func__);
4242
4243 return -EINVAL;
4244 }
4245
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004246 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4247 {
4248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4249 "%s:LOGP in Progress. Ignore!!!", __func__);
4250 return -EBUSY;
4251 }
4252
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 switch(sub_cmd)
4254 {
4255 case WE_WLAN_VERSION:
4256 {
Jeff Johnsonbb2eccc2013-02-12 14:23:57 -08004257 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 break;
4259 }
4260
4261 case WE_GET_STATS:
4262 {
4263 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4264 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4265 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4266
4267 snprintf(extra, WE_MAX_STR_LEN,
4268 "\nTransmit"
4269 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4270 "\n dropped BK %u, BE %u, VI %u, VO %u"
4271 "\n classified BK %u, BE %u, VI %u, VO %u"
4272 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4273 "\n queued BK %u, BE %u, VI %u, VO %u"
4274 "\nfetched %u, empty %u, lowres %u, deqerr %u"
4275 "\ndequeued %u, depressured %u, completed %u, flushed %u"
4276 "\n fetched BK %u, BE %u, VI %u, VO %u"
4277 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4278 "\n depressured BK %u, BE %u, VI %u, VO %u"
4279 "\n flushed BK %u, BE %u, VI %u, VO %u"
4280 "\n\nReceive"
4281 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4282 "\n\nResetsStats"
4283 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4284 "\n",
4285 pStats->txXmitCalled,
4286 pStats->txXmitDropped,
4287 pStats->txXmitBackPressured,
4288 pStats->txXmitQueued,
4289
4290 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4291 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4292 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4293 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4294
4295 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4296 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4297 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4298 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4299
4300 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4301 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4302 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4303 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4304
4305 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4306 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4307 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4308 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4309
4310 pStats->txFetched,
4311 pStats->txFetchEmpty,
4312 pStats->txFetchLowResources,
4313 pStats->txFetchDequeueError,
4314
4315 pStats->txFetchDequeued,
4316 pStats->txFetchDePressured,
4317 pStats->txCompleted,
4318 pStats->txFlushed,
4319
4320 pStats->txFetchedAC[WLANTL_AC_BK],
4321 pStats->txFetchedAC[WLANTL_AC_BE],
4322 pStats->txFetchedAC[WLANTL_AC_VI],
4323 pStats->txFetchedAC[WLANTL_AC_VO],
4324
4325 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4326 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4327 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4328 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4329
4330 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4331 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4332 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4333 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4334
4335 pStats->txFlushedAC[WLANTL_AC_BK],
4336 pStats->txFlushedAC[WLANTL_AC_BE],
4337 pStats->txFlushedAC[WLANTL_AC_VI],
4338 pStats->txFlushedAC[WLANTL_AC_VO],
4339
4340 pStats->rxChains,
4341 pStats->rxPackets,
4342 pStats->rxDropped,
4343 pStats->rxDelivered,
4344 pStats->rxRefused,
4345
4346 pResetStats->totalLogpResets,
4347 pResetStats->totalCMD53Failures,
4348 pResetStats->totalMutexReadFailures,
4349 pResetStats->totalMIFErrorFailures,
4350 pResetStats->totalFWHearbeatFailures,
4351 pResetStats->totalUnknownExceptions
4352 );
4353 wrqu->data.length = strlen(extra)+1;
4354 break;
4355 }
4356
Madan Mohan Koyyalamudi3c46b8f2013-07-11 14:59:10 +05304357/* The case prints the current state of the HDD, SME, CSR, PE, TL
4358 *it can be extended for WDI Global State as well.
4359 *And currently it only checks P2P_CLIENT adapter.
4360 *P2P_DEVICE and P2P_GO have not been added as of now.
4361*/
4362 case WE_GET_STATES:
4363 {
4364 int buf = 0, len = 0;
4365 int adapter_num = 0;
4366 int count = 0, check = 1;
4367
4368 tANI_U16 tlState;
4369 tHalHandle hHal;
4370 tpAniSirGlobal pMac;
4371 hdd_station_ctx_t *pHddStaCtx;
4372
4373 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4374 hdd_adapter_t *useAdapter = NULL;
4375
4376 /* Print wlan0 or p2p0 states based on the adapter_num
4377 *by using the correct adapter
4378 */
4379 while ( adapter_num < 2 )
4380 {
4381 if ( WLAN_ADAPTER == adapter_num )
4382 {
4383 useAdapter = pAdapter;
4384 buf = snprintf(extra + len, WE_MAX_STR_LEN - len,
4385 "\n\n wlan0 States:-");
4386 len += buf;
4387 }
4388 else if ( P2P_ADAPTER == adapter_num )
4389 {
4390 buf = snprintf(extra + len, WE_MAX_STR_LEN - len,
4391 "\n\n p2p0 States:-");
4392 len += buf;
4393
4394 if( !pHddCtx )
4395 {
4396 buf = snprintf(extra + len, WE_MAX_STR_LEN - len,
4397 "\n pHddCtx is NULL");
4398 len += buf;
4399 break;
4400 }
4401
4402 /*Printing p2p0 states only in the case when the device is
4403 configured as a p2p_client*/
4404 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4405 if ( !useAdapter )
4406 {
4407 buf = snprintf(extra + len, WE_MAX_STR_LEN - len,
4408 "\n Device not configured as P2P_CLIENT.");
4409 len += buf;
4410 break;
4411 }
4412 }
4413
4414 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
4415 pMac = PMAC_STRUCT( hHal );
4416 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4417 if( !pHddStaCtx )
4418 {
4419 buf = snprintf(extra + len, WE_MAX_STR_LEN - len,
4420 "\n pHddStaCtx is NULL");
4421 len += buf;
4422 break;
4423 }
4424
4425 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4426
4427 buf = snprintf(extra + len, WE_MAX_STR_LEN - len,
4428 "\n HDD Conn State - %s "
4429 "\n \n SME State:"
4430 "\n Neighbour Roam State - %s"
4431 "\n CSR State - %s"
4432 "\n CSR Substate - %s"
4433 "\n \n TL STA %d State: %s",
4434 macTraceGetHDDWlanConnState(
4435 pHddStaCtx->conn_info.connState),
4436 macTraceGetNeighbourRoamState(
4437 pMac->roam.neighborRoamInfo.neighborRoamState),
4438 macTraceGetcsrRoamState(
4439 pMac->roam.curState[useAdapter->sessionId]),
4440 macTraceGetcsrRoamSubState(
4441 pMac->roam.curSubState[useAdapter->sessionId]),
4442 pHddStaCtx->conn_info.staId[0],
4443 macTraceGetTLState(tlState)
4444 );
4445 len += buf;
4446 adapter_num++;
4447 }
4448
4449 /* Printing Lim State starting with global lim states */
4450 buf = snprintf(extra + len, WE_MAX_STR_LEN - len,
4451 "\n \n LIM STATES:-"
4452 "\n Global Sme State - %s "\
4453 "\n Global mlm State - %s "\
4454 "\n",
4455 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4456 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4457 );
4458 len += buf;
4459
4460 /*printing the PE Sme and Mlm states for valid lim sessions*/
4461 while ( check < 3 && count < 255)
4462 {
4463 if ( pMac->lim.gpSession[count].valid )
4464 {
4465 buf = snprintf(extra + len, WE_MAX_STR_LEN - len,
4466 "\n Lim Valid Session %d:-"
4467 "\n PE Sme State - %s "
4468 "\n PE Mlm State - %s "
4469 "\n",
4470 check,
4471 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4472 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4473 );
4474
4475 len += buf;
4476 check++;
4477 }
4478 count++;
4479 }
4480
4481 wrqu->data.length = strlen(extra)+1;
4482 break;
4483 }
4484
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 case WE_GET_CFG:
4486 {
4487 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4488 wrqu->data.length = strlen(extra)+1;
4489 break;
4490 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004491#ifdef WLAN_FEATURE_11AC
4492 case WE_GET_RSSI:
4493 {
4494 v_S7_t s7Rssi = 0;
4495 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4496 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4497 wrqu->data.length = strlen(extra)+1;
4498 break;
4499 }
4500#endif
Madan Mohan Koyyalamudi3c46b8f2013-07-11 14:59:10 +05304501
Srinivas Girigowda2471d832013-01-25 13:33:11 -08004502#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4503 case WE_GET_ROAM_RSSI:
4504 {
4505 v_S7_t s7Rssi = 0;
4506 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4507 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4508 wrqu->data.length = strlen(extra)+1;
4509 break;
4510 }
4511#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 case WE_GET_WMM_STATUS:
4513 {
4514 snprintf(extra, WE_MAX_STR_LEN,
4515 "\nDir: 0=up, 1=down, 3=both\n"
4516 "|------------------------|\n"
4517 "|AC | ACM |Admitted| Dir |\n"
4518 "|------------------------|\n"
4519 "|VO | %d | %3s | %d |\n"
4520 "|VI | %d | %3s | %d |\n"
4521 "|BE | %d | %3s | %d |\n"
4522 "|BK | %d | %3s | %d |\n"
4523 "|------------------------|\n",
4524 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4525 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4526 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4527 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4528 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4529 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4530 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4531 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4532 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4533 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4534 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4535 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4536
Jeff Johnsone7245742012-09-05 17:12:55 -07004537
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 wrqu->data.length = strlen(extra)+1;
4539 break;
4540 }
4541 case WE_GET_CHANNEL_LIST:
4542 {
4543 VOS_STATUS status;
4544 v_U8_t i, len;
4545 char* buf ;
4546 tChannelListInfo channel_list;
4547
4548 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
4549 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4550 {
4551 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!\n",__func__);
4552 return -EINVAL;
4553 }
4554 buf = extra;
4555
4556 /**
4557 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4558 * needed = 5 * number of channels. Check if sufficient buffer is available and
4559 * then proceed to fill the buffer.
4560 */
4561 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4562 {
4563 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Insufficient Buffer to populate channel list\n",__func__);
4564 return -EINVAL;
4565 }
4566 len = snprintf(buf, 5, "%u ", channel_list.num_channels);
4567 buf += len;
4568 for(i = 0 ; i < channel_list.num_channels; i++)
4569 {
4570 len = snprintf(buf, 5,
4571 "%u ", channel_list.channels[i]);
4572 buf += len;
4573 }
4574 wrqu->data.length = strlen(extra)+1;
4575
4576 break;
4577 }
Chilam Ng659dc3f2013-01-29 01:27:29 -08004578#ifdef FEATURE_WLAN_TDLS
4579 case WE_GET_TDLS_PEERS:
4580 {
Gopichand Nakkalacb408cd2013-03-04 23:22:42 -08004581 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng659dc3f2013-01-29 01:27:29 -08004582 break;
4583 }
4584#endif
Chet Lanctota96bb432013-03-18 10:26:30 -07004585#ifdef WLAN_FEATURE_11W
4586 case WE_GET_11W_INFO:
4587 {
4588 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4589
4590 snprintf(extra, WE_MAX_STR_LEN,
4591 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4592 "\n Number of Unprotected Disassocs %d"
4593 "\n Number of Unprotected Deauths %d",
4594 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4595 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4596 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4597 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4598 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4599
4600 wrqu->data.length = strlen(extra)+1;
4601 break;
4602 }
4603#endif
Madan Mohan Koyyalamudi3c46b8f2013-07-11 14:59:10 +05304604 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 {
4606 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4607 break;
4608 }
4609 }
4610
4611 return 0;
4612}
4613
4614/* action sub-ioctls */
4615static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4616 union iwreq_data *wrqu, char *extra)
4617{
4618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4619 int sub_cmd = wrqu->data.flags;
Jeff Johnson3d30ed12012-12-10 14:41:22 -08004620 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004621
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004622 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4623 {
4624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4625 "%s:LOGP in Progress. Ignore!!!", __func__);
4626 return -EBUSY;
4627 }
4628
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 switch (sub_cmd)
4630 {
4631 case WE_CLEAR_STATS:
4632 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4635 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4636 break;
4637 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 case WE_INIT_AP:
4639 {
4640 pr_info("Init AP trigger\n");
4641 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4642 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4643 break;
4644 }
4645 case WE_STOP_AP:
4646 {
4647 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
4648 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
4649 * this is a dead code and need to find the adpater by name rather than mode */
4650 hdd_adapter_t* pAdapter_to_stop =
4651 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
4652 if( pAdapter_to_stop )
4653 {
4654 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4655
4656 pr_info("Stopping AP mode\n");
4657
Gopichand Nakkala6fee7092013-06-10 17:43:37 +05304658 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4659 {
4660 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
4661 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
4662 }
4663
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 /*Make sure that pAdapter cleaned properly*/
4665 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
4666 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
4667 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
4668
4669 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
4670 pAdapter_to_stop->macAddressCurrent.bytes);
4671 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
4672 TRUE);
Gopichand Nakkala6fee7092013-06-10 17:43:37 +05304673
4674 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4675 {
4676 /* put the device back into BMPS */
4677 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
4678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 }
4680 else
4681 {
Madan Mohan Koyyalamudic1275fc2012-12-12 16:49:33 -08004682 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 }
4684
4685 break;
4686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004687#ifdef WLAN_BTAMP_FEATURE
4688 case WE_ENABLE_AMP:
4689 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 WLANBAP_RegisterWithHCI(pAdapter);
4692 break;
4693 }
4694 case WE_DISABLE_AMP:
4695 {
4696 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4697 VOS_STATUS status;
4698
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004700
4701 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4702 status = WLANBAP_StopAmp();
4703 if(VOS_STATUS_SUCCESS != status )
4704 {
4705 pHddCtx->isAmpAllowed = VOS_TRUE;
4706 hddLog(VOS_TRACE_LEVEL_FATAL,
4707 "%s: Failed to stop AMP", __func__);
4708 }
4709 else
4710 {
4711 //a state m/c implementation in PAL is TBD to avoid this delay
4712 msleep(500);
4713 pHddCtx->isAmpAllowed = VOS_FALSE;
4714 WLANBAP_DeregisterFromHCI();
4715 }
4716
4717 break;
4718 }
4719#endif
4720
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004721 case WE_ENABLE_DXE_STALL_DETECT:
4722 {
schang9d993dc2013-03-12 15:31:23 -07004723 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4724 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004725 break;
4726 }
4727 case WE_DISPLAY_DXE_SNAP_SHOT:
4728 {
schang9d993dc2013-03-12 15:31:23 -07004729 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4730 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004731 break;
4732 }
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05304733 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
4734 {
4735 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
4736 hdd_wmm_tx_snapshot(pAdapter);
4737 WLANTL_TLDebugMessage(VOS_TRUE);
4738 break;
4739 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07004740 case WE_SET_REASSOC_TRIGGER:
4741 {
4742 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4743 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
4744 v_U32_t roamId = 0;
4745 tCsrRoamModifyProfileFields modProfileFields;
4746 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
4747 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
4748 return 0;
4749 }
Madan Mohan Koyyalamudi3c46b8f2013-07-11 14:59:10 +05304750
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004751
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 default:
4753 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004754 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 break;
4756 }
4757 }
4758
4759 return ret;
4760}
4761
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05304762void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
4763{
4764 /*
4765 * Function to display HDD WMM information
4766 * for Tx Queues.
4767 * Prints globala as well as per client depending
4768 * whether the clients are registered or not.
4769 */
4770 int i = 0, j = 0;
4771 for ( i=0; i< NUM_TX_QUEUES; i++)
4772 {
Madan Mohan Koyyalamudidfdcd742013-07-25 16:30:37 +05304773 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05304774 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:0x%x, NextAddress:0x%x",
4775 i, pAdapter->wmm_tx_queue[i].count,
4776 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudidfdcd742013-07-25 16:30:37 +05304777 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05304778 }
4779
4780 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
4781 {
4782 if(pAdapter->aStaInfo[i].isUsed)
4783 {
4784 hddLog(LOGE, "******STAIndex: %d*********", i);
4785 for ( j=0; j< NUM_TX_QUEUES; j++)
4786 {
Madan Mohan Koyyalamudidfdcd742013-07-25 16:30:37 +05304787 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05304788 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:0x%x, NextAddress:0x%x",
4789 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
4790 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
4791 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudidfdcd742013-07-25 16:30:37 +05304792 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05304793 }
4794 }
4795 }
4796
4797}
Jeff Johnson295189b2012-06-20 16:38:30 -07004798int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4799 union iwreq_data *wrqu, char *extra)
4800{
4801 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4802 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4803 int sub_cmd = wrqu->data.flags;
4804 int *value = (int*)wrqu->data.pointer;
4805 int apps_args[MAX_VAR_ARGS] = {0};
4806 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004807 hdd_station_ctx_t *pStaCtx = NULL ;
4808 hdd_ap_ctx_t *pAPCtx = NULL;
4809 int cmd = 0;
4810 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004811
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004812 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004813
4814 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4815 {
4816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4817 "%s:LOGP in Progress. Ignore!!!", __func__);
4818 return -EBUSY;
4819 }
4820
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 if (num_args > MAX_VAR_ARGS)
4822 {
4823 num_args = MAX_VAR_ARGS;
4824 }
4825 vos_mem_copy(apps_args, value, (sizeof(int)) * num_args);
4826
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004827 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
4828 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
4829 {
4830 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
4831 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
4832 {
4833 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4834 staId = pStaCtx->conn_info.staId[0];
4835 }
4836 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
4837 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
4838 {
4839 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4840 staId = pAPCtx->uBCStaId;
4841 }
4842 else
4843 {
4844 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
4845 return 0;
4846 }
4847 }
4848
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 switch (sub_cmd)
4850 {
4851 case WE_LOG_DUMP_CMD:
4852 {
4853 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004854 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 apps_args[3], apps_args[4]);
4856
4857 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
4858 apps_args[3], apps_args[4]);
4859
4860 }
4861 break;
4862
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 case WE_P2P_NOA_CMD:
4864 {
4865 p2p_app_setP2pPs_t p2pNoA;
4866
4867 p2pNoA.opp_ps = apps_args[0];
4868 p2pNoA.ctWindow = apps_args[1];
4869 p2pNoA.duration = apps_args[2];
4870 p2pNoA.interval = apps_args[3];
4871 p2pNoA.count = apps_args[4];
4872 p2pNoA.single_noa_duration = apps_args[5];
4873 p2pNoA.psSelection = apps_args[6];
4874
4875 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
4876 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004877 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
4879
4880 hdd_setP2pPs(dev, &p2pNoA);
4881
4882 }
4883 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004884
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004885 case WE_MCC_CONFIG_CREDENTIAL :
4886 {
4887 cmd = 287; //Command should be updated if there is any change
4888 // in the Riva dump command
Kumar Anand817c2a72013-01-18 15:24:47 -08004889 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004890 {
4891 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
4892 }
4893 else
4894 {
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05304895 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160\n", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004896 return 0;
4897 }
4898 }
4899 break;
4900
4901 case WE_MCC_CONFIG_PARAMS :
4902 {
4903 cmd = 288; //command Should be updated if there is any change
4904 // in the Riva dump command
4905 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
4906 }
4907 break;
4908
Chilam NGde0b4112013-01-19 12:27:36 +05304909#ifdef FEATURE_WLAN_TDLS
4910 case WE_TDLS_CONFIG_PARAMS :
4911 {
4912 tdls_config_params_t tdlsParams;
4913
Chilam Ng66213252013-02-19 18:32:21 -08004914 tdlsParams.tdls = apps_args[0];
4915 tdlsParams.tx_period_t = apps_args[1];
4916 tdlsParams.tx_packet_n = apps_args[2];
4917 tdlsParams.discovery_period_t = apps_args[3];
4918 tdlsParams.discovery_tries_n = apps_args[4];
4919 tdlsParams.idle_timeout_t = apps_args[5];
4920 tdlsParams.idle_packet_n = apps_args[6];
4921 tdlsParams.rssi_hysteresis = apps_args[7];
4922 tdlsParams.rssi_trigger_threshold = apps_args[8];
4923 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NGde0b4112013-01-19 12:27:36 +05304924
Chilam Ng66213252013-02-19 18:32:21 -08004925 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NGde0b4112013-01-19 12:27:36 +05304926 }
4927 break;
4928#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 default:
4930 {
4931 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
4932 }
4933 break;
4934 }
4935
4936 return 0;
4937}
4938
4939
4940static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
4941 union iwreq_data *wrqu, char *extra)
4942{
4943 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4944 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4945 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4946 int params[HDD_WLAN_WMM_PARAM_COUNT];
4947 sme_QosWmmTspecInfo tSpec;
4948 v_U32_t handle;
4949
4950 // make sure the application is sufficiently priviledged
4951 // note that the kernel will do this for "set" ioctls, but since
4952 // this ioctl wants to return status to user space it must be
4953 // defined as a "get" ioctl
4954 if (!capable(CAP_NET_ADMIN))
4955 {
4956 return -EPERM;
4957 }
4958
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08004959 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4960 {
4961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4962 "%s:LOGP in Progress. Ignore!!!", __func__);
4963 return -EBUSY;
4964 }
4965
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 // we must be associated in order to add a tspec
4967 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4968 {
4969 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4970 return 0;
4971 }
4972
4973 // since we are defined to be a "get" ioctl, and since the number
4974 // of params exceeds the number of params that wireless extensions
4975 // will pass down in the iwreq_data, we must copy the "set" params
4976 // from user space ourselves
4977 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
4978 {
4979 // hmmm, can't get them
4980 return -EIO;
4981 }
4982
4983 // clear the tspec
4984 memset(&tSpec, 0, sizeof(tSpec));
4985
4986 // validate the handle
4987 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4988 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4989 {
4990 // that one is reserved
4991 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4992 return 0;
4993 }
4994
4995 // validate the TID
4996 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
4997 {
4998 // out of range
4999 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5000 return 0;
5001 }
5002 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5003
5004 // validate the direction
5005 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5006 {
5007 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5008 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5009 break;
5010
5011 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5012 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5013 break;
5014
5015 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5016 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5017 break;
5018
5019 default:
5020 // unknown
5021 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5022 return 0;
5023 }
5024
5025 // validate the user priority
5026 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5027 {
5028 // out of range
5029 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5030 return 0;
5031 }
5032 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
5033
Madan Mohan Koyyalamudi5d396d42013-08-13 23:04:47 +05305034 if ((tSpec.ts_info.up == SME_QOS_WMM_UP_VO) ||
5035 (tSpec.ts_info.up == SME_QOS_WMM_UP_NC))
5036 {
5037 tSpec.ts_info.psb = ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask &
Madan Mohan Koyyalamudic6562df2013-08-16 23:46:14 +05305038 SME_QOS_UAPSD_VO)? 1 : 0;
Madan Mohan Koyyalamudi5d396d42013-08-13 23:04:47 +05305039 }
5040 else if ((tSpec.ts_info.up == SME_QOS_WMM_UP_VI) ||
5041 (tSpec.ts_info.up == SME_QOS_WMM_UP_CL))
5042 {
5043 tSpec.ts_info.psb = ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask &
Madan Mohan Koyyalamudic6562df2013-08-16 23:46:14 +05305044 SME_QOS_UAPSD_VI) ? 1 : 0;
Madan Mohan Koyyalamudi5d396d42013-08-13 23:04:47 +05305045
5046 }
5047 else if (tSpec.ts_info.up == SME_QOS_WMM_UP_BE)
5048 {
5049 tSpec.ts_info.psb = ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask &
Madan Mohan Koyyalamudic6562df2013-08-16 23:46:14 +05305050 SME_QOS_UAPSD_BE)? 1 : 0;
Madan Mohan Koyyalamudi5d396d42013-08-13 23:04:47 +05305051 }
5052 else if (tSpec.ts_info.up == SME_QOS_WMM_UP_BK)
5053 {
5054 tSpec.ts_info.psb = ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask &
Madan Mohan Koyyalamudic6562df2013-08-16 23:46:14 +05305055 SME_QOS_UAPSD_BK)? 1 : 0;
Madan Mohan Koyyalamudi5d396d42013-08-13 23:04:47 +05305056 }
5057
Madan Mohan Koyyalamudic6562df2013-08-16 23:46:14 +05305058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5059 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5060 tSpec.ts_info.psb, tSpec.ts_info.up);
5061
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5063 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5064 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5065 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5066 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5067 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5068 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5069 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5070 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5071 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5072 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5073 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5074
5075 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5076
5077 // validate the ts info ack policy
5078 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5079 {
5080 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5081 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5082 break;
5083
5084 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5085 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5086 break;
5087
5088 default:
5089 // unknown
5090 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5091 return 0;
5092 }
5093
5094 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5095 return 0;
5096}
5097
5098
5099static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5100 union iwreq_data *wrqu, char *extra)
5101{
5102 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5103 int *params = (int *)extra;
5104 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5105 v_U32_t handle;
5106
5107 // make sure the application is sufficiently priviledged
5108 // note that the kernel will do this for "set" ioctls, but since
5109 // this ioctl wants to return status to user space it must be
5110 // defined as a "get" ioctl
5111 if (!capable(CAP_NET_ADMIN))
5112 {
5113 return -EPERM;
5114 }
5115
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005116 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5117 {
5118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5119 "%s:LOGP in Progress. Ignore!!!", __func__);
5120 return -EBUSY;
5121 }
5122
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 // although we are defined to be a "get" ioctl, the params we require
5124 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5125 // is no need to copy the params from user space
5126
5127 // validate the handle
5128 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5129 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5130 {
5131 // that one is reserved
5132 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5133 return 0;
5134 }
5135
5136 *pStatus = hdd_wmm_delts(pAdapter, handle);
5137 return 0;
5138}
5139
5140
5141static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5142 union iwreq_data *wrqu, char *extra)
5143{
5144 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5145 int *params = (int *)extra;
5146 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5147 v_U32_t handle;
5148
5149 // although we are defined to be a "get" ioctl, the params we require
5150 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5151 // is no need to copy the params from user space
5152
5153 // validate the handle
5154 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5155 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5156 {
5157 // that one is reserved
5158 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5159 return 0;
5160 }
5161
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005162 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5163 {
5164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5165 "%s:LOGP in Progress. Ignore!!!", __func__);
5166 return -EBUSY;
5167 }
5168
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5170 return 0;
5171}
5172
5173
5174#ifdef FEATURE_WLAN_WAPI
5175static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5176 union iwreq_data *wrqu, char *extra)
5177{
5178 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5179 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5180 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5181 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5182
5183 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)wrqu->data.pointer;
5184
5185 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005186 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5187 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5188 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005189
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005190 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5191 {
5192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5193 "%s:LOGP in Progress. Ignore!!!", __func__);
5194 return -EBUSY;
5195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005196
5197 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005198 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5200 pRoamProfile->EncryptionType.numEntries = 1;
5201 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5202 pRoamProfile->mcEncryptionType.numEntries = 1;
5203 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5204
5205 pRoamProfile->AuthType.numEntries = 1;
5206 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5207 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5208 }
5209 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005210 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 }
5212 else
5213 return -EINVAL;
5214
5215 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5216
5217 return 0;
5218}
5219
5220static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5221 union iwreq_data *wrqu, char *extra)
5222{
5223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5224 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5225
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005226 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5227 {
5228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5229 "%s:LOGP in Progress. Ignore!!!", __func__);
5230 return -EBUSY;
5231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5233
5234 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005235 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
5237 return 0;
5238}
5239
5240static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5241 union iwreq_data *wrqu, char *extra)
5242{
5243 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5244// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5245 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5246 int i = 0, j = 0;
5247 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005248 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5249 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5250 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005251
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005252 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5253 {
5254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5255 "%s:LOGP in Progress. Ignore!!!", __func__);
5256 return -EBUSY;
5257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 VOS_ASSERT(pWapiAssocInfo);
5259
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005260 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x\n",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
5261 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 for(i =0 ; i < 16 ; i++)
5263 hddLog(LOG1,"akm suite[%02d]:0x%08lx",i,pWapiAssocInfo->akmSuite[i]);
5264
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005265 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 for(i =0 ; i < 16 ; i++)
5267 hddLog(LOG1, "Unicast suite[%02d]:0x%08lx",i,pWapiAssocInfo->unicastSuite[i]);
5268
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005269 hddLog(LOG1,"%s: Multicast suite:0x%08lx Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
5270 hddLog(LOG1, "%s: BKID Cnt:0x%04x\n",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 for(i = 0 ; i < 16 ; i++) {
5272 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5273 for(j = 0 ; j < 16 ; j++)
5274 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5275 }
5276
5277 /* We are not using the entire IE as provided by the supplicant.
5278 * This is being calculated by SME. This is the same as in the
5279 * case of WPA. Only the auth mode information needs to be
5280 * extracted here*/
5281 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005282 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5284 }
5285
5286 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005287 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5289 }
5290 return 0;
5291}
5292
5293static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5294 union iwreq_data *wrqu, char *extra)
5295{
5296 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5297 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5298 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5299 tANI_U32 roamId = 0xFF;
5300 tANI_U8 *pKeyPtr = NULL;
5301 v_BOOL_t isConnected = TRUE;
5302 tCsrRoamSetKey setKey;
5303 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5305
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005306 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5307 {
5308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5309 "%s:LOGP in Progress. Ignore!!!", __func__);
5310 return -EBUSY;
5311 }
5312
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005314 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5315 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5316 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005317
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05305318 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 -07005319 hddLog(LOG1,"Add Index:0x");
5320 for(i =0 ; i < 12 ; i++)
5321 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5322
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005323 hddLog(LOG1,"\n%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5325 for(i =0 ; i < 16 ; i++)
5326 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5327
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005328 hddLog(LOG1,"\n%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5330 for(i =0 ; i < 16 ; i++)
5331 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5332
5333 hddLog(LOG1,"\nWAPI PN NUMBER:0x");
5334 for(i = 0 ; i < 16 ; i++)
5335 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5336
5337 // Clear the setkey memory
5338 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5339 // Store Key ID
5340 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5341 // SET WAPI Encryption
5342 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5343 // Key Directionn both TX and RX
5344 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5345 // the PAE role
5346 setKey.paeRole = 0 ;
5347
5348 switch ( pWapiKey->keyType )
5349 {
Chilam Ng20b2cb92013-04-01 15:37:32 -07005350 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 {
5352 isConnected = hdd_connIsConnected(pHddStaCtx);
5353 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5354 break;
5355 }
Chilam Ng20b2cb92013-04-01 15:37:32 -07005356 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 {
5358 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5359 break;
5360 }
5361 default:
5362 {
5363 //Any other option is invalid.
5364 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005365 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005366
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005367 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5369 break; // NEED RETURN FROM HERE ????
5370 }
5371 }
5372
5373 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5374 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5375 pKeyPtr = setKey.Key;
5376 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5377 pKeyPtr += pWapiKey->wpiekLen;
5378 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5379
5380 // Set the new key with SME.
5381 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5382
5383 if ( isConnected ) {
5384 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5385 if ( halStatus != eHAL_STATUS_SUCCESS )
5386 {
5387 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5388 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5389
5390 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5391 }
5392 }
5393#if 0 /// NEED TO CHECK ON THIS
5394 else
5395 {
5396 // Store the keys in the adapter to be moved to the profile & passed to
5397 // SME in the ConnectRequest if we are not yet in connected state.
5398 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5399 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5400
5401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5402 " Saving key [idx= %d] to apply when moving to connected state ",
5403 setKey.keyId );
5404
5405 }
5406#endif
5407 return halStatus;
5408}
5409
5410static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5411 union iwreq_data *wrqu, char *extra)
5412{
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005413 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005414#ifdef WLAN_DEBUG
5415 int i = 0;
5416 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) (wrqu->data.pointer);
5417#endif
5418
5419 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005420 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5421 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5422 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005423
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005424 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08lx\n", __func__,pBkid->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 hddLog(LOG1,"%s: BKID Cnt:0x%04lx",pBkid->BKIDCount);
5426
5427 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005428
5429 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5430 {
5431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5432 "%s:LOGP in Progress. Ignore!!!", __func__);
5433 return -EBUSY;
5434 }
5435
Jeff Johnson295189b2012-06-20 16:38:30 -07005436#ifdef WLAN_DEBUG
5437 for(i =0 ; i < 16 ; i++)
5438 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5439#endif
5440
5441 return 0;
5442}
5443
5444static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5445 union iwreq_data *wrqu, char *extra)
5446{
5447 /* Yet to implement this function, 19th April 2010 */
5448 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5449
5450 return 0;
5451}
5452#endif /* FEATURE_WLAN_WAPI */
5453
5454#ifdef WLAN_FEATURE_VOWIFI_11R
5455//
5456//
5457// Each time the supplicant has the auth_request or reassoc request
5458// IEs ready. This is pushed to the driver. The driver will inturn use
5459// it to send out the auth req and reassoc req for 11r FT Assoc.
5460//
5461static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5462 union iwreq_data *wrqu, char *extra)
5463{
5464 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5465 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5466 //v_CONTEXT_t pVosContext;
5467
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005468 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5469 {
5470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5471 "%s:LOGP in Progress. Ignore!!!", __func__);
5472 return -EBUSY;
5473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 if (!wrqu->data.length)
5475 {
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05305476 hddLog(LOGE, FL("called with 0 length IEs\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 return -EINVAL;
5478 }
5479 if (wrqu->data.pointer == NULL)
5480 {
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05305481 hddLog(LOGE, FL("called with NULL IE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 return -EINVAL;
5483 }
5484
5485 // Added for debug on reception of Re-assoc Req.
5486 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5487 {
5488 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
5489 wrqu->data.length);
5490 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
5491 }
5492
5493#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
5494 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, wrqu->data.length);
5495#endif
5496
5497 // Pass the received FT IEs to SME
5498 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, wrqu->data.pointer,
5499 wrqu->data.length);
5500
5501 return 0;
5502}
5503#endif
5504
Amar Singhal201550f2013-02-19 15:06:50 -08005505static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005506 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 union iwreq_data *wrqu, char *extra)
Amar Singhal201550f2013-02-19 15:06:50 -08005508{
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Amar Singhal201550f2013-02-19 15:06:50 -08005510 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)wrqu->data.pointer;
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005512 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhal201550f2013-02-19 15:06:50 -08005513 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhal201550f2013-02-19 15:06:50 -08005514 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5515 int idx;
5516 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005517
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005518 if (pHddCtx->isLogpInProgress)
5519 {
5520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5521 "%s:LOGP in Progress. Ignore!!!", __func__);
5522 return -EBUSY;
5523 }
5524
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305525 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5526 {
Gopichand Nakkalaf69cf802013-05-30 18:09:25 +05305527#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005528
Amar Singhal201550f2013-02-19 15:06:50 -08005529 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5530 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005531 {
Amar Singhal201550f2013-02-19 15:06:50 -08005532 hddLog(VOS_TRACE_LEVEL_ERROR,
5533 "%s: vos_mem_alloc failed", __func__);
5534 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005535 }
Amar Singhal201550f2013-02-19 15:06:50 -08005536
5537 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5538
5539 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5540 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5541
5542 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5543 mc_addr_list_ptr->ulMulticastAddrCnt);
5544
5545 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005546 {
Amar Singhal201550f2013-02-19 15:06:50 -08005547 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5548 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5549
5550 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5551 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005552 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005553
Amar Singhal201550f2013-02-19 15:06:50 -08005554 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5555 vos_mem_free(mc_addr_list_ptr);
5556 if (eHAL_STATUS_SUCCESS != ret_val)
5557 {
5558 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5559 __func__);
5560 return -EINVAL;
5561 }
Gopichand Nakkalaf69cf802013-05-30 18:09:25 +05305562#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305563 }
5564 else
5565 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005566
Amar Singhal201550f2013-02-19 15:06:50 -08005567 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5568 "%s: Set MC BC Filter Config request: %d suspend %d",
5569 __func__, pRequest->mcastBcastFilterSetting,
5570 pHddCtx->hdd_wlan_suspended);
5571
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305572 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhal201550f2013-02-19 15:06:50 -08005573
5574 if (pHddCtx->hdd_wlan_suspended)
5575 {
Jeff Johnsonbbb1aff2013-04-05 22:34:54 -07005576 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5577 if (NULL == wlanRxpFilterParam)
5578 {
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305579 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonbbb1aff2013-04-05 22:34:54 -07005580 "%s: vos_mem_alloc failed", __func__);
5581 return -EINVAL;
5582 }
5583
Amar Singhal201550f2013-02-19 15:06:50 -08005584 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5585 pRequest->mcastBcastFilterSetting;
5586 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5587
Gopichand Nakkalaf69cf802013-05-30 18:09:25 +05305588 hdd_conf_hostoffload(pAdapter, TRUE);
5589 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5590 pHddCtx->configuredMcastBcastFilter;
Amar Singhal201550f2013-02-19 15:06:50 -08005591
5592 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5593 __func__,
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305594 pHddCtx->configuredMcastBcastFilter,
Amar Singhal201550f2013-02-19 15:06:50 -08005595 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5596 wlanRxpFilterParam->setMcstBcstFilter);
5597
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305598 if (eHAL_STATUS_SUCCESS !=
5599 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5600 wlanRxpFilterParam))
Amar Singhal201550f2013-02-19 15:06:50 -08005601 {
5602 hddLog(VOS_TRACE_LEVEL_ERROR,
5603 "%s: Failure to execute set HW MC/BC Filter request",
5604 __func__);
Chilam Ng20b2cb92013-04-01 15:37:32 -07005605 vos_mem_free(wlanRxpFilterParam);
Amar Singhal201550f2013-02-19 15:06:50 -08005606 return -EINVAL;
5607 }
5608
Amar Singhal201550f2013-02-19 15:06:50 -08005609 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005611
5612 return 0;
5613}
5614
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005615static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
5616 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 union iwreq_data *wrqu, char *extra)
5618{
5619 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5620 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305621 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005622 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005623
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305624 //Reset the filter to INI value as we have to clear the dynamic filter
5625 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005626
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305627 //Configure FW with new setting
5628 if (pHddCtx->hdd_wlan_suspended)
5629 {
5630 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5631 if (NULL == wlanRxpFilterParam)
5632 {
5633 hddLog(VOS_TRACE_LEVEL_ERROR,
5634 "%s: vos_mem_alloc failed", __func__);
5635 return -EINVAL;
5636 }
5637
5638 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5639 pHddCtx->configuredMcastBcastFilter;
5640 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5641
Gopichand Nakkalaf69cf802013-05-30 18:09:25 +05305642 hdd_conf_hostoffload(pAdapter, TRUE);
5643 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5644 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalaac54ad02013-05-23 18:19:48 +05305645
5646 if (eHAL_STATUS_SUCCESS !=
5647 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5648 wlanRxpFilterParam))
5649 {
5650 hddLog(VOS_TRACE_LEVEL_ERROR,
5651 "%s: Failure to execute set HW MC/BC Filter request",
5652 __func__);
5653 vos_mem_free(wlanRxpFilterParam);
5654 return -EINVAL;
5655 }
5656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 return 0;
5658}
5659
5660static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
5661 union iwreq_data *wrqu, char *extra)
5662{
5663 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5664 tpHostOffloadRequest pRequest = (tpHostOffloadRequest)wrqu->data.pointer;
5665 tSirHostOffloadReq offloadRequest;
5666
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005667 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5668 {
5669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5670 "%s:LOGP in Progress. Ignore!!!", __func__);
5671 return -EBUSY;
5672 }
5673
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 /* Debug display of request components. */
5675 switch (pRequest->offloadType)
5676 {
5677 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005678 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 switch (pRequest->enableOrDisable)
5680 {
5681 case WLAN_OFFLOAD_DISABLE:
5682 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
5683 break;
5684 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
5685 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
5686 case WLAN_OFFLOAD_ENABLE:
5687 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
5688 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
5689 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
5690 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
5691 }
5692 break;
5693
5694 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
5695 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005696 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005697 switch (pRequest->enableOrDisable)
5698 {
5699 case WLAN_OFFLOAD_DISABLE:
5700 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
5701 break;
5702 case WLAN_OFFLOAD_ENABLE:
5703 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
5704 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
5705 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
5706 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
5707 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
5708 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
5709 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
5710 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
5711 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
5712 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
5713 }
5714 }
5715
5716 /* Execute offload request. The reason that we can copy the request information
5717 from the ioctl structure to the SME structure is that they are laid out
5718 exactly the same. Otherwise, each piece of information would have to be
5719 copied individually. */
5720 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07005721 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
5722 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 {
5724 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request\n",
5725 __func__);
5726 return -EINVAL;
5727 }
5728
5729 return 0;
5730}
5731
5732static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
5733 union iwreq_data *wrqu, char *extra)
5734{
5735 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5736 tpKeepAliveRequest pRequest = (tpKeepAliveRequest)wrqu->data.pointer;
5737 tSirKeepAliveReq keepaliveRequest;
5738
5739 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5740 {
5741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005742 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 return 0;
5744 }
5745
5746 /* Debug display of request components. */
5747 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Keep Alive Request : TimePeriod %d size %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005748 __func__,pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005749
5750 switch (pRequest->packetType)
5751 {
5752 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005753 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 break;
5755
5756 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
5757
5758 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005759 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005760
5761 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
5762 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
5763 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
5764
5765 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
5766 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
5767 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
5768
5769 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
5770 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
5771 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
5772 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
5773 break;
5774
5775 }
5776
5777 /* Execute keep alive request. The reason that we can copy the request information
5778 from the ioctl structure to the SME structure is that they are laid out
5779 exactly the same. Otherwise, each piece of information would have to be
5780 copied individually. */
5781 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
5782
5783 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d\n", keepaliveRequest.timePeriod);
5784
Jeff Johnsone7245742012-09-05 17:12:55 -07005785 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
5786 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 {
5788 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive\n",
5789 __func__);
5790 return -EINVAL;
5791 }
5792
5793 return 0;
5794}
5795
5796#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -07005797int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
5798 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005799{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005800 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5801 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 int i=0;
5803
5804 if (pHddCtx->cfg_ini->disablePacketFilter)
5805 {
5806 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005807 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 return 0;
5809 }
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08005810 if (pHddCtx->isLogpInProgress)
5811 {
5812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5813 "%s:LOGP in Progress. Ignore!!!", __func__);
5814 return -EBUSY;
5815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 /* Debug display of request components. */
5817 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005818 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07005819
5820 switch (pRequest->filterAction)
5821 {
5822 case HDD_RCV_FILTER_SET:
5823 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005824 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005825
5826 packetFilterSetReq.filterId = pRequest->filterId;
5827 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
5828 {
5829 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d\n",
5830 __func__, pRequest->numParams);
5831 return -EINVAL;
5832 }
5833 packetFilterSetReq.numFieldParams = pRequest->numParams;
5834 packetFilterSetReq.coalesceTime = 0;
5835 packetFilterSetReq.filterType = 1;
5836 for (i=0; i < pRequest->numParams; i++)
5837 {
5838 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
5839 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
5840 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
5841 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
5842 packetFilterSetReq.paramsData[i].reserved = 0;
5843
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05305844 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
5846 packetFilterSetReq.filterType);
5847
5848 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d\n",
5849 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
5850
5851 memcpy(&packetFilterSetReq.paramsData[i].compareData,
5852 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
5853 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
5854 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
5855
5856 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d\n",
5857 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
5858 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
5859 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
5860
5861 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d\n",
5862 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
5863 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
5864 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
5865 }
5866
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005867 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 {
5869 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter\n",
5870 __func__);
5871 return -EINVAL;
5872 }
5873
5874 break;
5875
5876 case HDD_RCV_FILTER_CLEAR:
5877
5878 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005879 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005881 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 {
5883 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter\n",
5884 __func__);
5885 return -EINVAL;
5886 }
5887 break;
5888
5889 default :
5890 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005891 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 return -EINVAL;
5893 }
5894 return 0;
5895}
5896
Gopichand Nakkala4995daa2013-06-26 22:44:57 +05305897int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
5898 tANI_U8 sessionId)
5899{
5900 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5901 tSirRcvFltPktClearParam packetFilterClrReq = {0};
5902
5903 if (NULL == pHddCtx)
5904 {
5905 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
5906 return -EINVAL;
5907 }
5908
5909 if (pHddCtx->isLogpInProgress)
5910 {
5911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5912 "%s:LOGP in Progress. Ignore!!!", __func__);
5913 return -EBUSY;
5914 }
5915
5916 if (pHddCtx->cfg_ini->disablePacketFilter)
5917 {
5918 hddLog(VOS_TRACE_LEVEL_ERROR,
5919 "%s: Packet Filtering Disabled. Returning ",
5920 __func__ );
5921 return -EINVAL;
5922 }
5923
5924 switch (filterType)
5925 {
5926 /* For setting IPV6 MC and UC Filter we need to configure
5927 * 2 filters, one for MC and one for UC.
5928 * The Filter ID shouldn't be swapped, which results in making
5929 * UC Filter ineffective.
5930 * We have Hardcode all the values
5931 *
5932 * Reason for a seperate UC filter is because, driver need to
5933 * specify the FW that the specific filter is for unicast
5934 * otherwise FW will not pass the unicast frames by default
5935 * through the filter. This is required to avoid any performance
5936 * hits when no unicast filter is set and only MC/BC are set.
5937 * The way driver informs host is by using the MAC protocol
5938 * layer, CMP flag set to MAX, CMP Data set to 1.
5939 */
5940
5941 case HDD_FILTER_IPV6_MC_UC:
5942 /* Setting IPV6 MC Filter below
5943 */
5944 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
5945 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
5946 packetFilterSetReq.numFieldParams = 2;
5947 packetFilterSetReq.paramsData[0].protocolLayer =
5948 HDD_FILTER_PROTO_TYPE_MAC;
5949 packetFilterSetReq.paramsData[0].cmpFlag =
5950 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
5951 packetFilterSetReq.paramsData[0].dataOffset =
5952 WLAN_HDD_80211_FRM_DA_OFFSET;
5953 packetFilterSetReq.paramsData[0].dataLength = 1;
5954 packetFilterSetReq.paramsData[0].compareData[0] =
5955 HDD_IPV6_MC_CMP_DATA;
5956
5957 packetFilterSetReq.paramsData[1].protocolLayer =
5958 HDD_FILTER_PROTO_TYPE_ARP;
5959 packetFilterSetReq.paramsData[1].cmpFlag =
5960 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
5961 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
5962 packetFilterSetReq.paramsData[1].dataLength = 2;
5963 packetFilterSetReq.paramsData[1].compareData[0] =
5964 HDD_IPV6_CMP_DATA_0;
5965 packetFilterSetReq.paramsData[1].compareData[1] =
5966 HDD_IPV6_CMP_DATA_1;
5967
5968
5969 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
5970 &packetFilterSetReq, sessionId))
5971 {
5972 hddLog(VOS_TRACE_LEVEL_ERROR,
5973 "%s: Failure to execute Set IPv6 Mulicast Filter",
5974 __func__);
5975 return -EINVAL;
5976 }
5977
5978 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
5979
5980 /*
5981 * Setting IPV6 UC Filter below
5982 */
5983 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
5984 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
5985 packetFilterSetReq.numFieldParams = 2;
5986 packetFilterSetReq.paramsData[0].protocolLayer =
5987 HDD_FILTER_PROTO_TYPE_MAC;
5988 packetFilterSetReq.paramsData[0].cmpFlag =
5989 HDD_FILTER_CMP_TYPE_MAX;
5990 packetFilterSetReq.paramsData[0].dataOffset = 0;
5991 packetFilterSetReq.paramsData[0].dataLength = 1;
5992 packetFilterSetReq.paramsData[0].compareData[0] =
5993 HDD_IPV6_UC_CMP_DATA;
5994
5995 packetFilterSetReq.paramsData[1].protocolLayer =
5996 HDD_FILTER_PROTO_TYPE_ARP;
5997 packetFilterSetReq.paramsData[1].cmpFlag =
5998 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
5999 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6000 packetFilterSetReq.paramsData[1].dataLength = 2;
6001 packetFilterSetReq.paramsData[1].compareData[0] =
6002 HDD_IPV6_CMP_DATA_0;
6003 packetFilterSetReq.paramsData[1].compareData[1] =
6004 HDD_IPV6_CMP_DATA_1;
6005
6006 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6007 &packetFilterSetReq, sessionId))
6008 {
6009 hddLog(VOS_TRACE_LEVEL_ERROR,
6010 "%s: Failure to execute Set IPv6 Unicast Filter",
6011 __func__);
6012 return -EINVAL;
6013 }
6014
6015 break;
6016
6017 case HDD_FILTER_IPV6_MC:
6018 /*
6019 * IPV6 UC Filter might be already set,
6020 * clear the UC Filter. As the Filter
6021 * IDs are static, we can directly clear it.
6022 */
6023 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6024 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6025 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6026 &packetFilterClrReq, sessionId))
6027 {
6028 hddLog(VOS_TRACE_LEVEL_ERROR,
6029 "%s: Failure to execute Clear IPv6 Unicast Filter",
6030 __func__);
6031 return -EINVAL;
6032 }
6033
6034 /*
6035 * Setting IPV6 MC Filter below
6036 */
6037 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6038 packetFilterSetReq.numFieldParams = 2;
6039 packetFilterSetReq.paramsData[0].protocolLayer =
6040 HDD_FILTER_PROTO_TYPE_MAC;
6041 packetFilterSetReq.paramsData[0].cmpFlag =
6042 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6043 packetFilterSetReq.paramsData[0].dataOffset =
6044 WLAN_HDD_80211_FRM_DA_OFFSET;
6045 packetFilterSetReq.paramsData[0].dataLength = 1;
6046 packetFilterSetReq.paramsData[0].compareData[0] =
6047 HDD_IPV6_MC_CMP_DATA;
6048
6049 packetFilterSetReq.paramsData[1].protocolLayer =
6050 HDD_FILTER_PROTO_TYPE_ARP;
6051 packetFilterSetReq.paramsData[1].cmpFlag =
6052 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6053 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6054 packetFilterSetReq.paramsData[1].dataLength = 2;
6055 packetFilterSetReq.paramsData[1].compareData[0] =
6056 HDD_IPV6_CMP_DATA_0;
6057 packetFilterSetReq.paramsData[1].compareData[1] =
6058 HDD_IPV6_CMP_DATA_1;
6059
6060
6061 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6062 &packetFilterSetReq, sessionId))
6063 {
6064 hddLog(VOS_TRACE_LEVEL_ERROR,
6065 "%s: Failure to execute Set IPv6 Multicast Filter",
6066 __func__);
6067 return -EINVAL;
6068 }
6069 break;
6070
6071 default :
6072 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6073 "%s: Packet Filter Request: Invalid",
6074 __func__);
6075 return -EINVAL;
6076 }
6077 return 0;
6078}
6079
Gopichand Nakkala859a3412013-02-24 14:45:51 +05306080void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006081{
Gopichand Nakkala859a3412013-02-24 14:45:51 +05306082 v_U8_t i;
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306083 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma0bc970b2013-08-29 00:33:26 -07006084 tHalHandle hHal = NULL;
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306085 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006086
Yue Ma0bc970b2013-08-29 00:33:26 -07006087 if (NULL == pHddCtx)
6088 {
6089 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6090 return;
6091 }
6092
6093 hHal = pHddCtx->hHal;
6094
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306095 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 {
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306097 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6098 return;
6099 }
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306100
6101 /* Check if INI is enabled or not, other wise just return
6102 */
Madan Mohan Koyyalamudi8a2e5da2013-08-12 09:37:34 +05306103 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306104 {
6105 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6106 if (NULL == pMulticastAddrs)
6107 {
6108 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6109 return;
6110 }
6111
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 if (set)
6113 {
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306114 /* Following pre-conditions should be satisfied before wei
6115 * configure the MC address list.
6116 */
6117 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6118 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6119 && pAdapter->mc_addr_list.mc_cnt
6120 && (eConnectionState_Associated ==
6121 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6122 {
6123 pMulticastAddrs->ulMulticastAddrCnt =
6124 pAdapter->mc_addr_list.mc_cnt;
6125 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6126 {
6127 memcpy(&(pMulticastAddrs->multicastAddr[i][0]),
6128 &(pAdapter->mc_addr_list.addr[i][0]),
6129 sizeof(pAdapter->mc_addr_list.addr[i]));
6130 hddLog(VOS_TRACE_LEVEL_INFO,
6131 "%s: %s multicast filter: addr ="
6132 MAC_ADDRESS_STR,
6133 __func__, set ? "setting" : "clearing",
6134 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6135 }
6136 /* Set multicast filter */
6137 sme_8023MulticastList(hHal, pAdapter->sessionId,
6138 pMulticastAddrs);
6139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 }
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306141 else
6142 {
6143 /* Need to clear only if it was previously configured
6144 */
6145 if (pAdapter->mc_addr_list.isFilterApplied)
6146 {
6147 pMulticastAddrs->ulMulticastAddrCnt = 0;
6148 sme_8023MulticastList(hHal, pAdapter->sessionId,
6149 pMulticastAddrs);
6150 }
6151
6152 }
6153 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 }
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306155 else
6156 {
6157 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi8a2e5da2013-08-12 09:37:34 +05306158 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306159 }
6160 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006161}
6162
6163static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6164 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudideaabc92013-07-01 18:39:37 +05306165{
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6167 tpPacketFilterCfg pRequest = (tpPacketFilterCfg)wrqu->data.pointer;
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08006168
Jeff Johnsone7245742012-09-05 17:12:55 -07006169 return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006170}
6171#endif
6172static int iw_get_statistics(struct net_device *dev,
6173 struct iw_request_info *info,
6174 union iwreq_data *wrqu, char *extra)
6175{
6176
6177 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6178 eHalStatus status = eHAL_STATUS_SUCCESS;
6179 hdd_wext_state_t *pWextState;
6180 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6181 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6182 char *p = extra;
6183 int tlen = 0;
6184 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6185
6186 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6187 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6188
6189 ENTER();
6190
6191 if (pHddCtx->isLogpInProgress) {
6192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6193 return -EINVAL;
6194 }
6195
6196 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6197
6198 wrqu->txpower.value = 0;
6199 }
6200 else {
6201 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6202 SME_SUMMARY_STATS |
6203 SME_GLOBAL_CLASSA_STATS |
6204 SME_GLOBAL_CLASSB_STATS |
6205 SME_GLOBAL_CLASSC_STATS |
6206 SME_GLOBAL_CLASSD_STATS |
6207 SME_PER_STA_STATS,
6208 hdd_StatisticsCB, 0, FALSE,
6209 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6210
6211 if (eHAL_STATUS_SUCCESS != status)
6212 {
6213 hddLog(VOS_TRACE_LEVEL_ERROR,
6214 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006215 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 return -EINVAL;
6217 }
6218
6219 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6220
6221 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6222 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6223 {
6224 hddLog(VOS_TRACE_LEVEL_ERROR,
6225 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006226 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 /*Remove the SME statistics list by passing NULL in callback argument*/
6228 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6229 SME_SUMMARY_STATS |
6230 SME_GLOBAL_CLASSA_STATS |
6231 SME_GLOBAL_CLASSB_STATS |
6232 SME_GLOBAL_CLASSC_STATS |
6233 SME_GLOBAL_CLASSD_STATS |
6234 SME_PER_STA_STATS,
6235 NULL, 0, FALSE,
6236 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6237
6238 return -EINVAL;
6239 }
6240 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6241 (tANI_U8) sizeof (pStats->retry_cnt),
6242 (char*) &(pStats->retry_cnt[0]),
6243 tlen);
6244
6245 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6246 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6247 (char*) &(pStats->multiple_retry_cnt[0]),
6248 tlen);
6249
6250 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6251 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6252 (char*) &(pStats->tx_frm_cnt[0]),
6253 tlen);
6254
6255 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6256 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6257 (char*) &(pStats->rx_frm_cnt),
6258 tlen);
6259
6260 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6261 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6262 (char*) &(pStats->frm_dup_cnt),
6263 tlen);
6264
6265 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6266 (tANI_U8) sizeof (pStats->fail_cnt),
6267 (char*) &(pStats->fail_cnt[0]),
6268 tlen);
6269
6270 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6271 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6272 (char*) &(pStats->rts_fail_cnt),
6273 tlen);
6274
6275 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6276 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6277 (char*) &(pStats->ack_fail_cnt),
6278 tlen);
6279
6280 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6281 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6282 (char*) &(pStats->rts_succ_cnt),
6283 tlen);
6284
6285 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6286 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6287 (char*) &(pStats->rx_discard_cnt),
6288 tlen);
6289
6290 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6291 (tANI_U8) sizeof (pStats->rx_error_cnt),
6292 (char*) &(pStats->rx_error_cnt),
6293 tlen);
6294
Jeff Johnsone7245742012-09-05 17:12:55 -07006295 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
6296 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6297 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 tlen);
6299
6300 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6301 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6302 (char*) &(dStats->rx_byte_cnt),
6303 tlen);
6304
6305 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6306 (tANI_U8) sizeof (dStats->rx_rate),
6307 (char*) &(dStats->rx_rate),
6308 tlen);
6309
6310 /* Transmit rate, in units of 500 kbit/sec */
6311 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6312 (tANI_U8) sizeof (aStats->tx_rate),
6313 (char*) &(aStats->tx_rate),
6314 tlen);
6315
Jeff Johnsone7245742012-09-05 17:12:55 -07006316 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6317 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6318 (char*) &(dStats->rx_uc_byte_cnt[0]),
6319 tlen);
6320 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6321 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6322 (char*) &(dStats->rx_mc_byte_cnt),
6323 tlen);
6324 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6325 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6326 (char*) &(dStats->rx_bc_byte_cnt),
6327 tlen);
6328 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6329 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6330 (char*) &(dStats->tx_uc_byte_cnt[0]),
6331 tlen);
6332 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6333 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6334 (char*) &(dStats->tx_mc_byte_cnt),
6335 tlen);
6336 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6337 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6338 (char*) &(dStats->tx_bc_byte_cnt),
6339 tlen);
6340
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 wrqu->data.length = tlen;
6342
6343 }
6344
6345 EXIT();
6346
6347 return 0;
6348}
6349
6350
6351#ifdef FEATURE_WLAN_SCAN_PNO
6352
6353/*Max Len for PNO notification*/
6354#define MAX_PNO_NOTIFY_LEN 100
6355void found_pref_network_cb (void *callbackContext,
6356 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6357{
6358 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6359 union iwreq_data wrqu;
6360 char buf[MAX_PNO_NOTIFY_LEN+1];
6361
6362 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6363 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6364
6365 // create the event
6366 memset(&wrqu, 0, sizeof(wrqu));
6367 memset(buf, 0, sizeof(buf));
6368
6369 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6370 pPrefNetworkFoundInd->ssId.ssId,
6371 (unsigned int)pPrefNetworkFoundInd->rssi);
6372
6373 wrqu.data.pointer = buf;
6374 wrqu.data.length = strlen(buf);
6375
6376 // send the event
6377
6378 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6379
6380}
6381
6382
6383/*string based input*/
6384VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6385 union iwreq_data *wrqu, char *extra, int nOffset)
6386{
6387 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006388 /* pnoRequest is a large struct, so we make it static to avoid stack
6389 overflow. This API is only invoked via ioctl, so it is
6390 serialized by the kernel rtnl_lock and hence does not need to be
6391 reentrant */
6392 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 char *ptr;
6394 v_U8_t i,j, ucParams, ucMode;
6395 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6396
6397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6398 "PNO data len %d data %s",
6399 wrqu->data.length,
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05306400 (char *)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006401
6402 if (wrqu->data.length <= nOffset )
6403 {
6404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6405 return VOS_STATUS_E_FAILURE;
6406 }
6407
6408 pnoRequest.enable = 0;
6409 pnoRequest.ucNetworksCount = 0;
6410 /*-----------------------------------------------------------------------
6411 Input is string based and expected to be like this:
6412
6413 <enabled> <netw_count>
6414 for each network:
6415 <ssid_len> <ssid> <authentication> <encryption>
6416 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6417 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6418
6419 e.g:
Jeff Johnson380f74e2013-03-28 14:27:29 -07006420 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 -07006421
6422 this translates into:
6423 -----------------------------
6424 enable PNO
6425 look for 2 networks:
6426 test - with authentication type 0 and encryption type 0,
6427 that can be found on 3 channels: 1 6 and 11 ,
6428 SSID bcast type is unknown (directed probe will be sent if AP not found)
6429 and must meet -40dBm RSSI
6430
6431 test2 - with auth and enrytption type 4/4
6432 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6433 bcast type is non-bcast (directed probe will be sent)
6434 and must not meet any RSSI threshold
6435
Jeff Johnson380f74e2013-03-28 14:27:29 -07006436 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 -----------------------------------------------------------------------*/
6438 ptr = (char*)(wrqu->data.pointer + nOffset);
6439
6440 sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset);
6441
6442 if ( 0 == pnoRequest.enable )
6443 {
6444 /*Disable PNO*/
6445 memset(&pnoRequest, 0, sizeof(pnoRequest));
6446 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6447 pAdapter->sessionId,
6448 found_pref_network_cb, pAdapter);
6449 return VOS_STATUS_SUCCESS;
6450 }
6451
6452 ptr += nOffset;
6453 sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset);
6454
6455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6456 "PNO enable %d networks count %d offset %d",
6457 pnoRequest.enable,
6458 pnoRequest.ucNetworksCount,
6459 nOffset);
6460
6461 /* Parameters checking:
6462 ucNetworksCount has to be larger than 0*/
6463 if (( 0 == pnoRequest.ucNetworksCount ) ||
6464 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6465 {
6466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6467 return VOS_STATUS_E_FAILURE;
6468 }
6469
6470 ptr += nOffset;
6471
6472 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6473 {
6474
6475 pnoRequest.aNetworks[i].ssId.length = 0;
6476
6477 sscanf(ptr,"%hhu %n",
6478 &(pnoRequest.aNetworks[i].ssId.length), &nOffset);
6479
6480 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6481 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6482 {
6483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6484 "SSID Len %d is not correct for network %d",
6485 pnoRequest.aNetworks[i].ssId.length, i);
6486 return VOS_STATUS_E_FAILURE;
6487 }
6488
6489 /*Advance to SSID*/
6490 ptr += nOffset;
6491
Jeff Johnson380f74e2013-03-28 14:27:29 -07006492 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal07dbbc92013-01-24 16:02:56 -08006493 pnoRequest.aNetworks[i].ssId.length);
6494 ptr += pnoRequest.aNetworks[i].ssId.length;
6495
6496 ucParams = sscanf(ptr,"%lu %lu %hhu %n",
6497 &(pnoRequest.aNetworks[i].authentication),
6498 &(pnoRequest.aNetworks[i].encryption),
6499 &(pnoRequest.aNetworks[i].ucChannelCount),
6500 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006501
6502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal07dbbc92013-01-24 16:02:56 -08006503 "PNO len %d ssid 0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx"
6504 "auth %d encry %d channel count %d offset %d",
6505 pnoRequest.aNetworks[i].ssId.length,
6506 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6507 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6508 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6509 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6510 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6511 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6512 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6513 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6514 pnoRequest.aNetworks[i].authentication,
6515 pnoRequest.aNetworks[i].encryption,
6516 pnoRequest.aNetworks[i].ucChannelCount,
6517 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006518
Amar Singhal07dbbc92013-01-24 16:02:56 -08006519 if ( 3 != ucParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 {
6521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6522 "Incorrect cmd");
6523 return VOS_STATUS_E_FAILURE;
6524 }
6525
6526 /*Advance to channel list*/
6527 ptr += nOffset;
6528
6529 if ( SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount )
6530 {
6531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6532 "Incorrect number of channels");
6533 return VOS_STATUS_E_FAILURE;
6534 }
6535
6536 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6537 {
6538 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6539 {
6540 sscanf(ptr,"%hhu %n",
6541 &(pnoRequest.aNetworks[i].aChannels[j]), &nOffset);
6542 /*Advance to next channel number*/
6543 ptr += nOffset;
6544 }
6545 }
6546
6547 sscanf(ptr,"%lu %n",
6548 &(pnoRequest.aNetworks[i].bcastNetwType), &nOffset);
6549
6550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6551 "PNO bcastNetwType %d offset %d",
6552 pnoRequest.aNetworks[i].bcastNetwType,
6553 nOffset );
6554
6555 /*Advance to rssi Threshold*/
6556 ptr += nOffset;
6557
6558 sscanf(ptr,"%hhu %n",
6559 &(pnoRequest.aNetworks[i].rssiThreshold), &nOffset);
6560
6561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6562 "PNO rssi %d offset %d",
6563 pnoRequest.aNetworks[i].rssiThreshold,
6564 nOffset );
6565 /*Advance to next network*/
6566 ptr += nOffset;
6567 }/*For ucNetworkCount*/
6568
6569 ucParams = sscanf(ptr,"%hhu %n",
6570 &(pnoRequest.scanTimers.ucScanTimersCount), &nOffset);
6571
6572 /*Read the scan timers*/
Jeff Johnson380f74e2013-03-28 14:27:29 -07006573 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 {
6575 ptr += nOffset;
6576
Jeff Johnson380f74e2013-03-28 14:27:29 -07006577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6578 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 pnoRequest.scanTimers.ucScanTimersCount,
6580 nOffset );
6581
6582 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
6583 {
Jeff Johnson380f74e2013-03-28 14:27:29 -07006584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 "Incorrect cmd - too many scan timers");
6586 return VOS_STATUS_E_FAILURE;
6587 }
6588
6589 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
6590 {
6591 ucParams = sscanf(ptr,"%lu %lu %n",
6592 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
6593 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
6594 &nOffset);
6595
Jeff Johnson380f74e2013-03-28 14:27:29 -07006596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6597 "PNO Timer value %d Timer repeat %d offset %d",
6598 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
6600 nOffset );
6601
6602 if ( 2 != ucParams )
6603 {
Jeff Johnson380f74e2013-03-28 14:27:29 -07006604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 "Incorrect cmd - diff params then expected %d", ucParams);
6606 return VOS_STATUS_E_FAILURE;
6607 }
6608
6609 ptr += nOffset;
6610 }
6611
6612 }
6613 else
6614 {
Jeff Johnson380f74e2013-03-28 14:27:29 -07006615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6616 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
6618
6619 /*Scan timers defaults to 5 minutes*/
6620 pnoRequest.scanTimers.ucScanTimersCount = 1;
6621 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
6622 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
6623 }
6624
6625 ucParams = sscanf(ptr,"%hhu %n",
6626 &(ucMode), &nOffset);
6627
6628 pnoRequest.modePNO = ucMode;
6629 /*for LA we just expose suspend option*/
6630 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
6631 {
6632 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
6633 }
6634
6635 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6636 pAdapter->sessionId,
6637 found_pref_network_cb, pAdapter);
6638
6639 return VOS_STATUS_SUCCESS;
6640}/*iw_set_pno*/
6641
6642VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
6643 union iwreq_data *wrqu, char *extra, int nOffset)
6644{
6645 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6646 v_U8_t rssiThreshold = 0;
6647 v_U8_t nRead;
6648
6649 nRead = sscanf(wrqu->data.pointer + nOffset,"%hhu",
6650 &rssiThreshold);
6651
6652 if ( 1 != nRead )
6653 {
6654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6655 "Incorrect format");
6656 return VOS_STATUS_E_FAILURE;
6657 }
6658
6659 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
6660 return VOS_STATUS_SUCCESS;
6661}
6662
6663
6664static int iw_set_pno_priv(struct net_device *dev,
6665 struct iw_request_info *info,
6666 union iwreq_data *wrqu, char *extra)
6667{
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08006668 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6669
6670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 "Set PNO Private");
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08006672
6673 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6674 {
6675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6676 "%s:LOGP in Progress. Ignore!!!", __func__);
6677 return -EBUSY;
6678 }
6679 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006680}
6681#endif /*FEATURE_WLAN_SCAN_PNO*/
6682
6683//Common function to SetBand
6684int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
6685{
6686 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6687 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6688 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6689 tANI_U8 band = 0;
6690 eCsrBand currBand = eCSR_BAND_MAX;
6691
6692 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
6693
6694 switch(band)
6695 {
6696 case WLAN_HDD_UI_BAND_AUTO:
6697 band = eCSR_BAND_ALL;
6698 break;
6699 case WLAN_HDD_UI_BAND_5_GHZ:
6700 band = eCSR_BAND_5G;
6701 break;
6702 case WLAN_HDD_UI_BAND_2_4_GHZ:
6703 band = eCSR_BAND_24;
6704 break;
6705 default:
6706 band = eCSR_BAND_MAX;
6707 }
6708
6709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006710 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006711
6712 if (band == eCSR_BAND_MAX)
6713 {
6714 /* Received change band request with invalid band value */
6715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006716 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 return -EIO;
6718 }
6719
Madan Mohan Koyyalamudi3c46b8f2013-07-11 14:59:10 +05306720 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
6721 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
6722 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
6723 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006725 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006726 band, pHddCtx->cfg_ini->nBandCapability);
6727 return -EIO;
6728 }
6729
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
6731 {
6732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6733 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006734 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 return -EIO;
6736 }
6737
6738 if (currBand != band)
6739 {
6740 /* Change band request received.
6741 * Abort pending scan requests, flush the existing scan results,
6742 * and change the band capability
6743 */
6744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6745 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006746 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006747
6748 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6749 {
6750 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
6751 eHalStatus status = eHAL_STATUS_SUCCESS;
6752 long lrc;
6753
6754 /* STA already connected on current band, So issue disconnect first,
6755 * then change the band*/
6756
6757 hddLog(VOS_TRACE_LEVEL_INFO,
6758 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
6759 __func__, csrGetCurrentBand(hHal), band);
6760
6761 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6762 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6763
6764 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6765 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6766
Jeff Johnson43971f52012-07-17 12:26:56 -07006767 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 {
6769 hddLog(VOS_TRACE_LEVEL_ERROR,
6770 "%s csrRoamDisconnect failure, returned %d \n",
6771 __func__, (int)status );
6772 return -EINVAL;
6773 }
6774
6775 lrc = wait_for_completion_interruptible_timeout(
6776 &pAdapter->disconnect_comp_var,
6777 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6778
Madan Mohan Koyyalamudid1958d62013-04-12 22:00:48 +05306779 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07006780
Srinivas Girigowdad05fe352013-07-02 10:19:12 -07006781 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006782 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006783
6784 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6785 }
6786 }
6787
Madan Mohan Koyyalamudi78f17402013-06-13 14:47:55 +05306788 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08006790#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6791 sme_UpdateBgScanConfigIniChannelList(hHal, (eCsrBand) band);
6792#endif
Madan Mohan Koyyalamudid1958d62013-04-12 22:00:48 +05306793 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 {
6795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6796 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006797 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 return -EINVAL;
6799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 }
6802 return 0;
6803}
6804
6805static int iw_set_band_config(struct net_device *dev,
6806 struct iw_request_info *info,
6807 union iwreq_data *wrqu, char *extra)
6808{
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08006809 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 tANI_U8 *ptr = (tANI_U8*)wrqu->data.pointer;
6811 int ret = 0;
6812
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006814
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08006815 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6816 {
6817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6818 "%s:LOGP in Progress. Ignore!!!", __func__);
6819 return -EBUSY;
6820 }
6821
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 if (memcmp(ptr, "SETBAND ", 8) == 0)
6823 {
6824 /* Change band request received */
6825 ret = hdd_setBand_helper(dev, ptr);
6826 return ret;
6827
6828 }
6829 return 0;
6830}
6831
6832static int iw_set_power_params_priv(struct net_device *dev,
6833 struct iw_request_info *info,
6834 union iwreq_data *wrqu, char *extra)
6835{
6836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6837 "Set power params Private");
6838 return iw_set_power_params(dev,info,wrqu,extra,0);
6839}
6840
6841
6842
6843/*string based input*/
6844VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
6845 union iwreq_data *wrqu, char *extra, int nOffset)
6846{
6847 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6848 tSirSetPowerParamsReq powerRequest;
6849 char *ptr;
6850 v_U8_t ucType;
6851 v_U32_t uTotalSize, uValue;
6852 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6853
6854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6855 "Power Params data len %d data %s",
6856 wrqu->data.length,
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05306857 (char *)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006858
Sameer Thalappil5d3cbc42013-02-21 19:38:16 -08006859 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6860 {
6861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6862 "%s:LOGP in Progress. Ignore!!!", __func__);
6863 return -EBUSY;
6864 }
6865
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 if (wrqu->data.length <= nOffset )
6867 {
6868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
6869 return VOS_STATUS_E_FAILURE;
6870 }
6871
6872 uTotalSize = wrqu->data.length - nOffset;
6873
6874 /*-----------------------------------------------------------------------
6875 Input is string based and expected to be like this:
6876
6877 <param_type> <param_value> <param_type> <param_value> ...
6878
6879 e.g:
6880 1 2 2 3 3 0 4 1 5 1
6881
6882 e.g. setting just a few:
6883 1 2 4 1
6884
6885 parameter types:
6886 -----------------------------
6887 1 - Ignore DTIM
6888 2 - Listen Interval
6889 3 - Broadcast Multicas Filter
6890 4 - Beacon Early Termination
6891 5 - Beacon Early Termination Interval
6892 -----------------------------------------------------------------------*/
6893 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
6894 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
6895 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
6896 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
6897 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
6898
6899 ptr = (char*)(wrqu->data.pointer + nOffset);
6900
6901 while ( uTotalSize )
6902 {
6903 sscanf(ptr,"%hhu %n", &(ucType), &nOffset);
6904
6905 uTotalSize -= nOffset;
6906
6907 if (!uTotalSize)
6908 {
6909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudic1275fc2012-12-12 16:49:33 -08006910 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 ucType, nOffset);
6912 return VOS_STATUS_E_FAILURE;
6913 }
6914
6915 ptr += nOffset;
6916 sscanf(ptr,"%lu %n", &(uValue), &nOffset);
6917
6918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6919 "Power request parameter %d value %d offset %d",
6920 ucType, uValue, nOffset);
6921
6922 switch (ucType)
6923 {
6924 case eSIR_IGNORE_DTIM:
6925 powerRequest.uIgnoreDTIM = uValue;
6926 break;
6927 case eSIR_LISTEN_INTERVAL:
6928 powerRequest.uListenInterval = uValue;
6929 break;
6930 case eSIR_MCAST_BCAST_FILTER:
6931 powerRequest.uBcastMcastFilter = uValue;
6932 break;
6933 case eSIR_ENABLE_BET:
6934 powerRequest.uEnableBET = uValue;
6935 break;
6936 case eSIR_BET_INTERVAL:
6937 powerRequest.uBETInterval = uValue;
6938 break;
6939 default:
6940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudic1275fc2012-12-12 16:49:33 -08006941 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 ucType, uValue, nOffset);
6943 return VOS_STATUS_E_FAILURE;
6944 }
6945
6946 uTotalSize -= nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07006947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6948 "Power request parameter %d Total size",
6949 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07006951 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
6952 if(!(uTotalSize - nOffset) &&
6953 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
6954 {
6955 uTotalSize = 0;
6956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006957
6958 }/*Go for as long as we have a valid string*/
6959
6960 /* put the device into full power*/
6961 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6962
6963 /* Apply the power save params*/
Tushnim Bhattacharyyacb8cda82013-02-24 11:11:15 -08006964 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006965
6966 /* put the device back to power save*/
6967 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6968
6969 return VOS_STATUS_SUCCESS;
6970}/*iw_set_power_params*/
6971
6972
6973// Define the Wireless Extensions to the Linux Network Device structure
6974// A number of these routines are NULL (meaning they are not implemented.)
6975
6976static const iw_handler we_handler[] =
6977{
6978 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
6979 (iw_handler) iw_get_name, /* SIOCGIWNAME */
6980 (iw_handler) NULL, /* SIOCSIWNWID */
6981 (iw_handler) NULL, /* SIOCGIWNWID */
6982 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
6983 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
6984 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
6985 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
6986 (iw_handler) NULL, /* SIOCSIWSENS */
6987 (iw_handler) NULL, /* SIOCGIWSENS */
6988 (iw_handler) NULL, /* SIOCSIWRANGE */
6989 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
6990 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
6991 (iw_handler) NULL, /* SIOCGIWPRIV */
6992 (iw_handler) NULL, /* SIOCSIWSTATS */
6993 (iw_handler) NULL, /* SIOCGIWSTATS */
6994 iw_handler_set_spy, /* SIOCSIWSPY */
6995 iw_handler_get_spy, /* SIOCGIWSPY */
6996 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
6997 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
6998 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
6999 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7000 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7001 (iw_handler) NULL, /* SIOCGIWAPLIST */
7002 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7003 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7004 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7005 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7006 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7007 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7008 (iw_handler) NULL, /* -- hole -- */
7009 (iw_handler) NULL, /* -- hole -- */
7010 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7011 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7012 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7013 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7014 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7015 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7016 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7017 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7018 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7019 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7020 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7021 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7022 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7023 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7024 (iw_handler) NULL, /* -- hole -- */
7025 (iw_handler) NULL, /* -- hole -- */
7026 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7027 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7028 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7029 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7030 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7031 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7032 (iw_handler) NULL, /* SIOCSIWPMKSA */
7033};
7034
7035static const iw_handler we_private[] = {
7036
7037 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7038 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7039 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7040 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7041 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7042 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7043 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7044 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7045 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7046 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007047#ifdef FEATURE_OEM_DATA_SUPPORT
7048 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7049 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7050#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007051
7052#ifdef FEATURE_WLAN_WAPI
7053 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7054 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7055 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7056 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7057 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7058 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7059#endif /* FEATURE_WLAN_WAPI */
7060#ifdef WLAN_FEATURE_VOWIFI_11R
7061 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7062#endif
7063 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7064 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7065 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7066#ifdef WLAN_FEATURE_PACKET_FILTERING
7067 ,
7068 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7069#endif
7070#ifdef FEATURE_WLAN_SCAN_PNO
7071 ,
7072 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7073#endif
7074 ,
7075 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7076 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7077 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7078 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007079 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007080};
7081
7082/*Maximum command length can be only 15 */
7083static const struct iw_priv_args we_private_args[] = {
7084
7085 /* handlers for main ioctl */
7086 { WLAN_PRIV_SET_INT_GET_NONE,
7087 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7088 0,
7089 "" },
7090
7091 /* handlers for sub-ioctl */
7092 { WE_SET_11D_STATE,
7093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7094 0,
7095 "set11Dstate" },
7096
7097 { WE_WOWL,
7098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7099 0,
7100 "wowl" },
7101
7102 { WE_SET_POWER,
7103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7104 0,
7105 "setPower" },
7106
7107 { WE_SET_MAX_ASSOC,
7108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7109 0,
7110 "setMaxAssoc" },
7111
7112 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7114 0,
7115 "setAutoChannel" },
7116
7117 { WE_SET_DATA_INACTIVITY_TO,
7118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7119 0,
7120 "inactivityTO" },
7121
7122 { WE_SET_MAX_TX_POWER,
7123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7124 0,
7125 "setMaxTxPower" },
Rajesh Chauhan31f11ee2013-07-16 18:50:29 -07007126
7127 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7128 * as well to keep same syntax as in SAP. Now onwards, STA
7129 * will support both */
7130 { WE_SET_MAX_TX_POWER,
7131 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7132 0,
7133 "setTxMaxPower" },
7134
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7136 * 1 = enable and 0 = disable */
7137 {
7138 WE_SET_HIGHER_DTIM_TRANSITION,
7139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7140 0,
7141 "setHDtimTransn" },
7142
7143 { WE_SET_TM_LEVEL,
7144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7145 0,
7146 "setTmLevel" },
7147
7148 /* handlers for main ioctl */
7149 { WLAN_PRIV_SET_NONE_GET_INT,
7150 0,
7151 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7152 "" },
7153
7154 /* handlers for sub-ioctl */
7155 { WE_GET_11D_STATE,
7156 0,
7157 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7158 "get11Dstate" },
7159
7160 { WE_IBSS_STATUS,
7161 0,
7162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7163 "getAdhocStatus" },
7164
7165 { WE_PMC_STATE,
7166 0,
7167 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7168 "pmcState" },
7169
7170 { WE_GET_WLAN_DBG,
7171 0,
7172 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7173 "getwlandbg" },
7174
7175 { WE_MODULE_DOWN_IND,
7176 0,
7177 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7178 "moduleDownInd" },
7179
7180 { WE_GET_MAX_ASSOC,
7181 0,
7182 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7183 "getMaxAssoc" },
7184
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 { WE_GET_WDI_DBG,
7186 0,
7187 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7188 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007189
7190 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7191 0,
7192 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7193 "getAutoChannel" },
7194
7195 { WE_GET_CONCURRENCY_MODE,
7196 0,
7197 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7198 "getconcurrency" },
7199
7200 /* handlers for main ioctl */
7201 { WLAN_PRIV_SET_CHAR_GET_NONE,
7202 IW_PRIV_TYPE_CHAR| 512,
7203 0,
7204 "" },
7205
7206 /* handlers for sub-ioctl */
7207 { WE_WOWL_ADD_PTRN,
7208 IW_PRIV_TYPE_CHAR| 512,
7209 0,
7210 "wowlAddPtrn" },
7211
7212 { WE_WOWL_DEL_PTRN,
7213 IW_PRIV_TYPE_CHAR| 512,
7214 0,
7215 "wowlDelPtrn" },
7216
7217#if defined WLAN_FEATURE_VOWIFI
7218 /* handlers for sub-ioctl */
7219 { WE_NEIGHBOR_REPORT_REQUEST,
7220 IW_PRIV_TYPE_CHAR | 512,
7221 0,
7222 "neighbor" },
7223#endif
7224 { WE_SET_AP_WPS_IE,
7225 IW_PRIV_TYPE_CHAR| 512,
7226 0,
7227 "set_ap_wps_ie" },
7228
7229 { WE_SET_CONFIG,
7230 IW_PRIV_TYPE_CHAR| 512,
7231 0,
7232 "setConfig" },
7233
7234 /* handlers for main ioctl */
7235 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7236 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7237 0,
7238 "" },
7239
7240 /* handlers for sub-ioctl */
7241 { WE_SET_WLAN_DBG,
7242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7243 0,
7244 "setwlandbg" },
7245
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 { WE_SET_WDI_DBG,
7247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7248 0,
7249 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007250
7251 { WE_SET_SAP_CHANNELS,
7252 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7253 0,
7254 "setsapchannels" },
7255
7256 /* handlers for main ioctl */
7257 { WLAN_PRIV_GET_CHAR_SET_NONE,
7258 0,
7259 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7260 "" },
7261
7262 /* handlers for sub-ioctl */
7263 { WE_WLAN_VERSION,
7264 0,
7265 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7266 "version" },
7267 { WE_GET_STATS,
7268 0,
7269 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7270 "getStats" },
Madan Mohan Koyyalamudi3c46b8f2013-07-11 14:59:10 +05307271 { WE_GET_STATES,
7272 0,
7273 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7274 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 { WE_GET_CFG,
7276 0,
7277 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7278 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007279#ifdef WLAN_FEATURE_11AC
7280 { WE_GET_RSSI,
7281 0,
7282 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7283 "getRSSI" },
7284#endif
Srinivas Girigowda2471d832013-01-25 13:33:11 -08007285#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
7286 { WE_GET_ROAM_RSSI,
7287 0,
7288 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7289 "getRoamRSSI" },
7290#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 { WE_GET_WMM_STATUS,
7292 0,
7293 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7294 "getWmmStatus" },
7295 {
7296 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi3c46b8f2013-07-11 14:59:10 +05307297 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7299 "getChannelList" },
Chilam Ng659dc3f2013-01-29 01:27:29 -08007300#ifdef FEATURE_WLAN_TDLS
7301 {
7302 WE_GET_TDLS_PEERS,
7303 0,
7304 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7305 "getTdlsPeers" },
7306#endif
Chet Lanctota96bb432013-03-18 10:26:30 -07007307#ifdef WLAN_FEATURE_11W
7308 {
7309 WE_GET_11W_INFO,
7310 0,
7311 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7312 "getPMFInfo" },
7313#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 /* handlers for main ioctl */
7315 { WLAN_PRIV_SET_NONE_GET_NONE,
7316 0,
7317 0,
7318 "" },
7319
7320 /* handlers for sub-ioctl */
7321 { WE_CLEAR_STATS,
7322 0,
7323 0,
7324 "clearStats" },
7325 { WE_INIT_AP,
7326 0,
7327 0,
7328 "initAP" },
7329 { WE_STOP_AP,
7330 0,
7331 0,
7332 "exitAP" },
7333 { WE_ENABLE_AMP,
7334 0,
7335 0,
7336 "enableAMP" },
7337 { WE_DISABLE_AMP,
7338 0,
7339 0,
7340 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007341 { WE_ENABLE_DXE_STALL_DETECT,
7342 0,
7343 0,
7344 "dxeStallDetect" },
7345 { WE_DISPLAY_DXE_SNAP_SHOT,
7346 0,
7347 0,
7348 "dxeSnapshot" },
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05307349 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7350 0,
7351 0,
7352 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007353 {
7354 WE_SET_REASSOC_TRIGGER,
7355 0,
7356 0,
7357 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007358
7359 /* handlers for main ioctl */
7360 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7361 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7362 0,
7363 "" },
7364
7365 /* handlers for sub-ioctl */
7366 { WE_LOG_DUMP_CMD,
7367 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7368 0,
7369 "dump" },
7370
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007371 /* handlers for sub ioctl */
7372 {
7373 WE_MCC_CONFIG_CREDENTIAL,
7374 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7375 0,
7376 "setMccCrdnl" },
7377
7378 /* handlers for sub ioctl */
7379 {
7380 WE_MCC_CONFIG_PARAMS,
7381 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7382 0,
7383 "setMccConfig" },
7384
Chilam NGde0b4112013-01-19 12:27:36 +05307385#ifdef FEATURE_WLAN_TDLS
7386 /* handlers for sub ioctl */
7387 {
7388 WE_TDLS_CONFIG_PARAMS,
7389 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7390 0,
7391 "setTdlsConfig" },
7392#endif
7393
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 /* handlers for main ioctl */
7395 { WLAN_PRIV_ADD_TSPEC,
7396 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7398 "addTspec" },
7399
7400 /* handlers for main ioctl */
7401 { WLAN_PRIV_DEL_TSPEC,
7402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7404 "delTspec" },
7405
7406 /* handlers for main ioctl */
7407 { WLAN_PRIV_GET_TSPEC,
7408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7410 "getTspec" },
7411
Jeff Johnsone7245742012-09-05 17:12:55 -07007412#ifdef FEATURE_OEM_DATA_SUPPORT
7413 /* handlers for main ioctl - OEM DATA */
7414 {
7415 WLAN_PRIV_SET_OEM_DATA_REQ,
7416 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7417 0,
7418 "set_oem_data_req" },
7419
7420 /* handlers for main ioctl - OEM DATA */
7421 {
7422 WLAN_PRIV_GET_OEM_DATA_RSP,
7423 0,
7424 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7425 "get_oem_data_rsp" },
7426#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007427
7428#ifdef FEATURE_WLAN_WAPI
7429 /* handlers for main ioctl SET_WAPI_MODE */
7430 { WLAN_PRIV_SET_WAPI_MODE,
7431 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7432 0,
7433 "SET_WAPI_MODE" },
7434
7435 /* handlers for main ioctl GET_WAPI_MODE */
7436 { WLAN_PRIV_GET_WAPI_MODE,
7437 0,
7438 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7439 "GET_WAPI_MODE" },
7440
7441 /* handlers for main ioctl SET_ASSOC_INFO */
7442 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
7443 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
7444 0,
7445 "SET_WAPI_ASSOC" },
7446
7447 /* handlers for main ioctl SET_WAPI_KEY */
7448 { WLAN_PRIV_SET_WAPI_KEY,
7449 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
7450 0,
7451 "SET_WAPI_KEY" },
7452
7453 /* handlers for main ioctl SET_WAPI_BKID */
7454 { WLAN_PRIV_SET_WAPI_BKID,
7455 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7456 0,
7457 "SET_WAPI_BKID" },
7458
7459 /* handlers for main ioctl GET_WAPI_BKID */
7460 { WLAN_PRIV_GET_WAPI_BKID,
7461 0,
7462 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7463 "GET_WAPI_BKID" },
7464#endif /* FEATURE_WLAN_WAPI */
7465
7466 /* handlers for main ioctl - host offload */
7467 {
7468 WLAN_PRIV_SET_HOST_OFFLOAD,
7469 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
7470 0,
7471 "setHostOffload" },
7472
7473 {
7474 WLAN_GET_WLAN_STATISTICS,
7475 0,
7476 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
7477 "getWlanStats" },
7478
7479 {
7480 WLAN_SET_KEEPALIVE_PARAMS,
7481 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
7482 0,
7483 "setKeepAlive" },
7484#ifdef WLAN_FEATURE_PACKET_FILTERING
7485 {
7486 WLAN_SET_PACKET_FILTER_PARAMS,
7487 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
7488 0,
7489 "setPktFilter" },
7490#endif
7491#ifdef FEATURE_WLAN_SCAN_PNO
7492 {
7493 WLAN_SET_PNO,
7494 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7495 0,
7496 "setpno" },
7497#endif
7498 {
7499 WLAN_SET_BAND_CONFIG,
7500 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7501 0,
7502 "SETBAND" },
7503 /* handlers for dynamic MC BC ioctl */
7504 {
7505 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhal201550f2013-02-19 15:06:50 -08007506 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 0,
7508 "setMCBCFilter" },
7509 {
7510 WLAN_PRIV_CLEAR_MCBC_FILTER,
7511 0,
7512 0,
7513 "clearMCBCFilter" },
7514 {
7515 WLAN_SET_POWER_PARAMS,
7516 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7517 0,
7518 "setpowerparams" },
7519 {
7520 WLAN_GET_LINK_SPEED,
7521 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05307522 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007523};
7524
7525
7526
7527const struct iw_handler_def we_handler_def = {
7528 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
7529 .num_private = sizeof(we_private) / sizeof(we_private[0]),
7530 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
7531
7532 .standard = (iw_handler *)we_handler,
7533 .private = (iw_handler *)we_private,
7534 .private_args = we_private_args,
7535 .get_wireless_stats = get_wireless_stats,
7536};
7537
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007538int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
7539{
7540 v_U32_t cmd = 288; //Command to RIVA
7541 hdd_context_t *pHddCtx = NULL;
7542 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7543 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7544 /*
7545 *configMccParam : specify the bit which needs to be modified
7546 *allowed to update based on wlan_qcom_cfg.ini
7547 * configuration
7548 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
7549 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
7550 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
7551 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
7552 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
7553 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
7554 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
7555 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
7556 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
7557 * Bit 9 : Reserved
7558 */
7559 switch (arg1)
7560 {
7561 //Update MCC SCHEDULE_TIME_SLICE parameter
7562 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
7563 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
7564 {
7565 if((arg2 >= 5) && (arg2 <= 20))
7566 {
7567 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7568 }
7569 else
7570 {
7571 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7572 return 0;
7573 }
7574 }
7575 break;
7576
7577 //Update MCC MAX_NULL_SEND_TIME parameter
7578 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
7579 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
7580 {
7581 if((arg2 >= 1) && (arg2 <= 10))
7582 {
7583 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7584 }
7585 else
7586 {
7587 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7588 return 0;
7589 }
7590 }
7591 break;
7592
7593 //Update MCC TX_EARLY_STOP_TIME parameter
7594 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
7595 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
7596 {
7597 if((arg2 >= 1) && (arg2 <= 10))
7598 {
7599 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7600 }
7601 else
7602 {
7603 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7604 return 0;
7605 }
7606 }
7607 break;
7608
7609 //Update MCC RX_DRAIN_TIME parameter
7610 case MCC_RX_DRAIN_TIME_CFG_PARAM :
7611 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
7612 {
7613 if((arg2 >= 1) && (arg2 <= 10))
7614 {
7615 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7616 }
7617 else
7618 {
7619 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7620 return 0;
7621 }
7622 }
7623 break;
7624
7625 //Update MCC CHANNEL_SWITCH_TIME parameter
7626 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
7627 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
7628 {
7629 if((arg2 >= 1) && (arg2 <= 20))
7630 {
7631 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7632 }
7633 else
7634 {
7635 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7636 return 0;
7637 }
7638 }
7639 break;
7640
7641 //Update MCC MIN_CHANNEL_TIME parameter
7642 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
7643 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
7644 {
7645 if((arg2 >= 5) && (arg2 <= 20))
7646 {
7647 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7648 }
7649 else
7650 {
7651 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7652 return 0;
7653 }
7654 }
7655 break;
7656
7657 //Update MCC PARK_BEFORE_TBTT parameter
7658 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
7659 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
7660 {
7661 if((arg2 >= 1) && (arg2 <= 5))
7662 {
7663 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7664 }
7665 else
7666 {
7667 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7668 return 0;
7669 }
7670 }
7671 break;
7672
7673 //Update MCC MIN_AFTER_DTIM parameter
7674 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
7675 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
7676 {
7677 if((arg2 >= 5) && (arg2 <= 15))
7678 {
7679 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7680 }
7681 else
7682 {
7683 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7684 return 0;
7685 }
7686 }
7687 break;
7688
7689 //Update MCC TOO_CLOSE_MARGIN parameter
7690 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
7691 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
7692 {
7693 if((arg2 >= 1) && (arg2 <= 3))
7694 {
7695 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7696 }
7697 else
7698 {
7699 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7700 return 0;
7701 }
7702 }
7703 break;
7704
7705 default :
7706 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d\n",
7707 __FUNCTION__,arg1);
7708 break;
7709 }
7710 return 0;
7711}
7712
Jeff Johnson295189b2012-06-20 16:38:30 -07007713int hdd_set_wext(hdd_adapter_t *pAdapter)
7714{
7715 hdd_wext_state_t *pwextBuf;
7716 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007717 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007718
7719 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7720
7721 // Now configure the roaming profile links. To SSID and bssid.
7722 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
7723 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
7724
7725 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
7726 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
7727
7728 /*Set the numOfChannels to zero to scan all the channels*/
7729 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
7730 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
7731
7732 /* Default is no encryption */
7733 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
7734 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7735
7736 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
7737 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7738
7739 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
7740
7741 /* Default is no authentication */
7742 pwextBuf->roamProfile.AuthType.numEntries = 1;
7743 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
7744
7745 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
7746 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
7747
7748 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007749 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07007750
7751 hdd_clearRoamProfileIe(pAdapter);
7752
7753 return VOS_STATUS_SUCCESS;
7754
7755 }
7756
7757int hdd_register_wext(struct net_device *dev)
7758 {
7759 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7760 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7761 VOS_STATUS status;
7762
7763 ENTER();
7764
7765 // Zero the memory. This zeros the profile structure.
7766 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
7767
7768 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
7769
7770
7771 status = hdd_set_wext(pAdapter);
7772
7773 if(!VOS_IS_STATUS_SUCCESS(status)) {
7774
7775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!\n"));
7776 return eHAL_STATUS_FAILURE;
7777 }
7778
7779 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
7780 {
7781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!\n"));
7782 return eHAL_STATUS_FAILURE;
7783 }
7784
7785 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
7786 {
7787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!\n"));
7788 return eHAL_STATUS_FAILURE;
7789 }
7790
7791 // Register as a wireless device
7792 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
7793
7794 EXIT();
7795 return 0;
7796}
7797
7798int hdd_UnregisterWext(struct net_device *dev)
7799{
7800#if 0
7801 hdd_wext_state_t *wextBuf;
7802 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7803
7804 ENTER();
7805 // Set up the pointer to the Wireless Extensions state structure
7806 wextBuf = pAdapter->pWextState;
7807
7808 // De-allocate the Wireless Extensions state structure
7809 kfree(wextBuf);
7810
7811 // Clear out the pointer to the Wireless Extensions state structure
7812 pAdapter->pWextState = NULL;
7813
7814 EXIT();
7815#endif
7816 dev->wireless_handlers = NULL;
7817 return 0;
7818}
7819
7820