blob: 2ae0d3f8dfdd76952777bfa0ff34e038560657af [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/** ------------------------------------------------------------------------ *
43 ------------------------------------------------------------------------ *
44
45
46 \file wlan_hdd_wext.c
47
48 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
49 interfaces.
50
51 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
52
53 Copyright (C) 2007 Airgo Networks, Incorporated
54
55 This file defines all of the types that are utilized by the CCP module
56 of the "Portable" HDD. This file also includes the underlying Linux
57 Wireless Extensions Data types referred to by CCP.
58
59 ======================================================================== */
60
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053066#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include <wlan_hdd_includes.h>
68#include <wlan_btc_svc.h>
69#include <wlan_nlink_common.h>
70#ifdef WLAN_BTAMP_FEATURE
71#include <bap_hdd_main.h>
72#endif
73#include <vos_api.h>
74#include <net/arp.h>
75#include "ccmApi.h"
76#include "sirParams.h"
77#include "csrApi.h"
78#include "csrInsideApi.h"
79#if defined WLAN_FEATURE_VOWIFI
80#include "smeRrmInternal.h"
81#endif
82#include <aniGlobal.h>
83#include "dot11f.h"
84#include <wlan_hdd_wowl.h>
85#include <wlan_hdd_cfg.h>
86#include <wlan_hdd_wmm.h>
87#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070088#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053089#ifdef FEATURE_WLAN_TDLS
90#include "wlan_hdd_tdls.h"
91#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070092
93#ifdef CONFIG_HAS_EARLYSUSPEND
94#include <linux/earlysuspend.h>
95#endif
96#include "wlan_hdd_power.h"
97#include "qwlan_version.h"
98#include <vos_power.h>
99#include "wlan_hdd_host_offload.h"
100#include "wlan_hdd_keep_alive.h"
101#ifdef WLAN_FEATURE_PACKET_FILTERING
102#include "wlan_hdd_packet_filtering.h"
103#endif
104
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#include <linux/wireless.h>
106#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530108#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
110#include "wlan_hdd_misc.h"
111#include "bap_hdd_misc.h"
112
113#include "wlan_hdd_dev_pwr.h"
114#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530115#include "sme_Api.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700116
117#ifdef CONFIG_HAS_EARLYSUSPEND
118extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
119extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
120#endif
121
Jeff Johnsone7245742012-09-05 17:12:55 -0700122#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800123#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700124#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700125
126#define HDD_FINISH_ULA_TIME_OUT 800
127
128extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
129int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
130
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700131static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
133
Jeff Johnson295189b2012-06-20 16:38:30 -0700134#define STATS_CONTEXT_MAGIC 0x53544154 //STAT
135#define RSSI_CONTEXT_MAGIC 0x52535349 //RSSI
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530136#define POWER_CONTEXT_MAGIC 0x504F5752 //POWR
137#define SNR_CONTEXT_MAGIC 0x534E5200 //SNR
Jeff Johnson295189b2012-06-20 16:38:30 -0700138
139/* To Validate Channel against the Frequency and Vice-Versa */
140static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
141 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
142 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
143 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
144 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
145 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
146 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
147 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
148 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
149
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800150#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700151
152/* Private ioctls and their sub-ioctls */
153#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
154#define WE_SET_11D_STATE 1
155#define WE_WOWL 2
156#define WE_SET_POWER 3
157#define WE_SET_MAX_ASSOC 4
158#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
159#define WE_SET_DATA_INACTIVITY_TO 6
160#define WE_SET_MAX_TX_POWER 7
161#define WE_SET_HIGHER_DTIM_TRANSITION 8
162#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530163#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700164#define WE_SET_MAX_TX_POWER_2_4 11
165#define WE_SET_MAX_TX_POWER_5_0 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700166
167/* Private ioctls and their sub-ioctls */
168#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
169#define WE_GET_11D_STATE 1
170#define WE_IBSS_STATUS 2
171#define WE_PMC_STATE 3
172#define WE_GET_WLAN_DBG 4
173#define WE_MODULE_DOWN_IND 5
174#define WE_GET_MAX_ASSOC 6
175#define WE_GET_WDI_DBG 7
176#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
177#define WE_GET_CONCURRENCY_MODE 9
178/* Private ioctls and their sub-ioctls */
179#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
180
181/* Private ioctls and their sub-ioctls */
182#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
183#define WE_WOWL_ADD_PTRN 1
184#define WE_WOWL_DEL_PTRN 2
185#if defined WLAN_FEATURE_VOWIFI
186#define WE_NEIGHBOR_REPORT_REQUEST 3
187#endif
188#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
189#define WE_SET_CONFIG 5
190
191/* Private ioctls and their sub-ioctls */
192#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
193#define WE_SET_WLAN_DBG 1
194#define WE_SET_WDI_DBG 2
195#define WE_SET_SAP_CHANNELS 3
196
197/* Private ioctls and their sub-ioctls */
198#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
199#define WE_WLAN_VERSION 1
200#define WE_GET_STATS 2
201#define WE_GET_CFG 3
202#define WE_GET_WMM_STATUS 4
203#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700204#ifdef WLAN_FEATURE_11AC
205#define WE_GET_RSSI 6
206#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800207#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800208#ifdef FEATURE_WLAN_TDLS
209#define WE_GET_TDLS_PEERS 8
210#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700211#ifdef WLAN_FEATURE_11W
212#define WE_GET_11W_INFO 9
213#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530214#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700215
216/* Private ioctls and their sub-ioctls */
217#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
218#define WE_CLEAR_STATS 1
219#define WE_INIT_AP 2
220#define WE_STOP_AP 3
221#define WE_ENABLE_AMP 4
222#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700223#define WE_ENABLE_DXE_STALL_DETECT 6
224#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530225#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700226#define WE_SET_REASSOC_TRIGGER 8
Jeff Johnson295189b2012-06-20 16:38:30 -0700227
228/* Private ioctls and their sub-ioctls */
229#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
230#define WE_LOG_DUMP_CMD 1
231
Jeff Johnson295189b2012-06-20 16:38:30 -0700232#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800233//IOCTL to configure MCC params
234#define WE_MCC_CONFIG_CREDENTIAL 3
235#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700236
Chilam NG571c65a2013-01-19 12:27:36 +0530237#ifdef FEATURE_WLAN_TDLS
238#define WE_TDLS_CONFIG_PARAMS 5
239#endif
240
Chilam Ng01120412013-02-19 18:32:21 -0800241#ifdef FEATURE_WLAN_TDLS
242#undef MAX_VAR_ARGS
243#define MAX_VAR_ARGS 10
244#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700245#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800246#endif
247
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
249/* Private ioctls (with no sub-ioctls) */
250/* note that they must be odd so that they have "get" semantics */
251#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
252#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
253#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
254
255#ifdef FEATURE_WLAN_WAPI
256/* Private ioctls EVEN NO: SET, ODD NO:GET */
257#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
258#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
259#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
260#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
261#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
262#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
263#define WAPI_PSK_AKM_SUITE 0x02721400
264#define WAPI_CERT_AKM_SUITE 0x01721400
265#endif
266
Jeff Johnsone7245742012-09-05 17:12:55 -0700267#ifdef FEATURE_OEM_DATA_SUPPORT
268/* Private ioctls for setting the measurement configuration */
269#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
270#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
271#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700272
273#ifdef WLAN_FEATURE_VOWIFI_11R
274#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
275#endif
276
277/* Private ioctl for setting the host offload feature */
278#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
279
280/* Private ioctl to get the statistics */
281#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
282
283/* Private ioctl to set the Keep Alive Params */
284#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
285#ifdef WLAN_FEATURE_PACKET_FILTERING
286/* Private ioctl to set the Packet Filtering Params */
287#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
288#endif
289
290#ifdef FEATURE_WLAN_SCAN_PNO
291/* Private ioctl to get the statistics */
292#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
293#endif
294
295#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
296
297#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
298#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700299/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700300
Jeff Johnson295189b2012-06-20 16:38:30 -0700301#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
302#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
303
304#define WLAN_STATS_INVALID 0
305#define WLAN_STATS_RETRY_CNT 1
306#define WLAN_STATS_MUL_RETRY_CNT 2
307#define WLAN_STATS_TX_FRM_CNT 3
308#define WLAN_STATS_RX_FRM_CNT 4
309#define WLAN_STATS_FRM_DUP_CNT 5
310#define WLAN_STATS_FAIL_CNT 6
311#define WLAN_STATS_RTS_FAIL_CNT 7
312#define WLAN_STATS_ACK_FAIL_CNT 8
313#define WLAN_STATS_RTS_SUC_CNT 9
314#define WLAN_STATS_RX_DISCARD_CNT 10
315#define WLAN_STATS_RX_ERROR_CNT 11
316#define WLAN_STATS_TX_BYTE_CNT 12
317
318#define WLAN_STATS_RX_BYTE_CNT 13
319#define WLAN_STATS_RX_RATE 14
320#define WLAN_STATS_TX_RATE 15
321
Jeff Johnsone7245742012-09-05 17:12:55 -0700322#define WLAN_STATS_RX_UC_BYTE_CNT 16
323#define WLAN_STATS_RX_MC_BYTE_CNT 17
324#define WLAN_STATS_RX_BC_BYTE_CNT 18
325#define WLAN_STATS_TX_UC_BYTE_CNT 19
326#define WLAN_STATS_TX_MC_BYTE_CNT 20
327#define WLAN_STATS_TX_BC_BYTE_CNT 21
328
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800329#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
330 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
331 { \
332 *__p++ = __type; \
333 *__p++ = __size; \
334 memcpy(__p, __val, __size); \
335 __p += __size; \
336 __tlen += __size + 2; \
337 } \
338 else \
339 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800340 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800341 } \
342 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700343
344#define VERSION_VALUE_MAX_LEN 32
345
346#define TX_PER_TRACKING_DEFAULT_RATIO 5
347#define TX_PER_TRACKING_MAX_RATIO 10
348#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
349
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530350#define WLAN_ADAPTER 0
351#define P2P_ADAPTER 1
352
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800353/*MCC Configuration parameters */
354enum {
355 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
356 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
357 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
358 MCC_RX_DRAIN_TIME_CFG_PARAM,
359 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
360 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
361 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
362 MCC_MIN_AFTER_DTIM_CFG_PARAM,
363 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
364};
365
366int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
367 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
368
Jeff Johnson295189b2012-06-20 16:38:30 -0700369#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -0700370int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
371 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700372#endif
373
Jeff Johnson295189b2012-06-20 16:38:30 -0700374/**---------------------------------------------------------------------------
375
376 \brief hdd_wlan_get_version() -
377
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800378 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
380 \param - pAdapter Pointer to the adapter.
381 wrqu - Pointer to IOCTL REQUEST Data.
382 extra - Pointer to char
383
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800384 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700385
386 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800387void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
388 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700389{
390 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800391 tSirVersionString wcnss_SW_version;
392 tSirVersionString wcnss_HW_version;
393 char *pSWversion;
394 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700396
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800397 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
398 sizeof(wcnss_SW_version));
399 if (VOS_IS_STATUS_SUCCESS(status))
400 {
401 pSWversion = wcnss_SW_version;
402 }
403 else
404 {
405 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 }
407
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800408 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
409 sizeof(wcnss_HW_version));
410 if (VOS_IS_STATUS_SUCCESS(status))
411 {
412 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800414 else
415 {
416 pHWversion = "Unknown";
417 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700418
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700419 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800420 "Host SW:%s, FW:%s, HW:%s",
421 QWLAN_VERSIONSTR,
422 pSWversion,
423 pHWversion);
424
425 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700426}
427
Jeff Johnson295189b2012-06-20 16:38:30 -0700428int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
429{
430 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
431 v_U32_t threshold = 0,status = 0;
432
433 ENTER();
434
435 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
437 "%s:LOGP in Progress. Ignore!!!",__func__);
438 return status;
439 }
440
441 if ( eHAL_STATUS_SUCCESS !=
442 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
443 {
444 return -EIO;
445 }
446 wrqu->rts.value = threshold;
447
448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800449 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700450
451 EXIT();
452
453 return 0;
454}
455
456int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
457{
458 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
459 v_U32_t threshold = 0,status = 0;
460
461 ENTER();
462
463 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
465 "%s:LOGP in Progress. Ignore!!!",__func__);
466 return status;
467 }
468
469 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
470 != eHAL_STATUS_SUCCESS )
471 {
472 return -EIO;
473 }
474 wrqu->frag.value = threshold;
475
476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800477 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700478
479 EXIT();
480
481 return 0;
482}
483
484int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
485{
Jeff Johnsone7245742012-09-05 17:12:55 -0700486 int i;
487 if (channel > 0)
488 {
489 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
490 {
491 if (channel == freq_chan_map[i].chan)
492 {
493 *pfreq = freq_chan_map[i].freq;
494 return 1;
495 }
496 }
497 }
498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800499 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700500 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700501}
502
503static v_BOOL_t
504hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
505{
506 v_BOOL_t rsnType = VOS_FALSE;
507 // is the authType supported?
508 switch (authType)
509 {
510 case eCSR_AUTH_TYPE_NONE: //never used
511 rsnType = eANI_BOOLEAN_FALSE;
512 break;
513 // MAC layer authentication types
514 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
515 rsnType = eANI_BOOLEAN_FALSE;
516 break;
517 case eCSR_AUTH_TYPE_SHARED_KEY:
518 rsnType = eANI_BOOLEAN_FALSE;
519 break;
520 case eCSR_AUTH_TYPE_AUTOSWITCH:
521 rsnType = eANI_BOOLEAN_FALSE;
522 break;
523
524 // Upper layer authentication types
525 case eCSR_AUTH_TYPE_WPA:
526 rsnType = eANI_BOOLEAN_TRUE;
527 break;
528 case eCSR_AUTH_TYPE_WPA_PSK:
529 rsnType = eANI_BOOLEAN_TRUE;
530 break;
531 case eCSR_AUTH_TYPE_WPA_NONE:
532 rsnType = eANI_BOOLEAN_TRUE;
533 break;
534#ifdef WLAN_FEATURE_VOWIFI_11R
535 case eCSR_AUTH_TYPE_FT_RSN:
536#endif
537 case eCSR_AUTH_TYPE_RSN:
538 rsnType = eANI_BOOLEAN_TRUE;
539 break;
540#ifdef WLAN_FEATURE_VOWIFI_11R
541 case eCSR_AUTH_TYPE_FT_RSN_PSK:
542#endif
543 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700544#ifdef WLAN_FEATURE_11W
545 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
546#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 rsnType = eANI_BOOLEAN_TRUE;
548 break;
549 //case eCSR_AUTH_TYPE_FAILED:
550 case eCSR_AUTH_TYPE_UNKNOWN:
551 rsnType = eANI_BOOLEAN_FALSE;
552 break;
553 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800554 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
555 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 rsnType = eANI_BOOLEAN_FALSE;
557 break;
558 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800559 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700560 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 return rsnType;
562}
563
564static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
565{
566 struct statsContext *pStatsContext;
567 hdd_adapter_t *pAdapter;
568
569 if (ioctl_debug)
570 {
571 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700572 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 }
574
575 if (NULL == pContext)
576 {
577 hddLog(VOS_TRACE_LEVEL_ERROR,
578 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700579 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 return;
581 }
582
583 /* there is a race condition that exists between this callback function
584 and the caller since the caller could time out either before or
585 while this code is executing. we'll assume the timeout hasn't
586 occurred, but we'll verify that right before we save our work */
587
588 pStatsContext = pContext;
589 pAdapter = pStatsContext->pAdapter;
590 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
591 {
592 /* the caller presumably timed out so there is nothing we can do */
593 hddLog(VOS_TRACE_LEVEL_WARN,
594 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700595 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 if (ioctl_debug)
597 {
598 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700599 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 }
601 return;
602 }
603
604 /* the race is on. caller could have timed out immediately after
605 we verified the magic, but if so, caller will wait a short time
606 for us to copy over the rssi */
607 pAdapter->rssi = rssi;
608
609 /* and notify the caller */
610 complete(&pStatsContext->completion);
611}
612
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530613static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
614{
615 struct statsContext *pStatsContext;
616 hdd_adapter_t *pAdapter;
617
618 if (ioctl_debug)
619 {
620 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
621 __func__, (int)snr, (int)staId, pContext);
622 }
623
624 if (NULL == pContext)
625 {
626 hddLog(VOS_TRACE_LEVEL_ERROR,
627 "%s: Bad param, pContext [%p]",
628 __func__, pContext);
629 return;
630 }
631
632 /* there is a race condition that exists between this callback function
633 * and the caller since the caller could time out either before or
634 * while this code is executing. we'll assume the timeout hasn't
635 * occurred, but we'll verify that right before we save our work
636 */
637
638 pStatsContext = pContext;
639 pAdapter = pStatsContext->pAdapter;
640 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
641 {
642 /* the caller presumably timed out so there is nothing we can do */
643 hddLog(VOS_TRACE_LEVEL_WARN,
644 "%s: Invalid context, pAdapter [%p] magic [%08x]",
645 __func__, pAdapter, pStatsContext->magic);
646 if (ioctl_debug)
647 {
648 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
649 __func__, pAdapter, pStatsContext->magic);
650 }
651 return;
652 }
653
654 /* the race is on. caller could have timed out immediately after
655 * we verified the magic, but if so, caller will wait a short time
656 * for us to copy over the snr
657 */
658 pAdapter->snr = snr;
659
660 /* and notify the caller */
661 complete(&pStatsContext->completion);
662}
663
Jeff Johnson295189b2012-06-20 16:38:30 -0700664VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
665{
666 struct statsContext context;
667 hdd_context_t *pHddCtx;
668 hdd_station_ctx_t *pHddStaCtx;
669 eHalStatus hstatus;
670 long lrc;
671
672 if (NULL == pAdapter)
673 {
674 hddLog(VOS_TRACE_LEVEL_WARN,
675 "%s: Invalid context, pAdapter", __func__);
676 return VOS_STATUS_E_FAULT;
677 }
678 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
679 {
680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
681 /* return a cached value */
682 *rssi_value = pAdapter->rssi;
683 return VOS_STATUS_SUCCESS;
684 }
685
686 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
687 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
688
689 init_completion(&context.completion);
690 context.pAdapter = pAdapter;
691 context.magic = RSSI_CONTEXT_MAGIC;
692
693 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
694 pHddStaCtx->conn_info.staId[ 0 ],
695 pHddStaCtx->conn_info.bssId,
696 &context, pHddCtx->pvosContext);
697 if (eHAL_STATUS_SUCCESS != hstatus)
698 {
699 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700700 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 /* we'll returned a cached value below */
702 }
703 else
704 {
705 /* request was sent -- wait for the response */
706 lrc = wait_for_completion_interruptible_timeout(&context.completion,
707 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
708 /* either we have a response or we timed out
709 either way, first invalidate our magic */
710 context.magic = 0;
711 if (lrc <= 0)
712 {
713 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700714 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 /* there is a race condition such that the callback
716 function could be executing at the same time we are. of
717 primary concern is if the callback function had already
718 verified the "magic" but hasn't yet set the completion
719 variable. Since the completion variable is on our
720 stack, we'll delay just a bit to make sure the data is
721 still valid if that is the case */
722 msleep(50);
723 /* we'll now returned a cached value below */
724 }
725 }
726 *rssi_value = pAdapter->rssi;
727
728 return VOS_STATUS_SUCCESS;
729}
730
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530731VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
732{
733 struct statsContext context;
734 hdd_context_t *pHddCtx;
735 hdd_station_ctx_t *pHddStaCtx;
736 eHalStatus hstatus;
737 long lrc;
738 int valid;
739
740 if (NULL == pAdapter)
741 {
742 hddLog(VOS_TRACE_LEVEL_ERROR,
743 "%s: Invalid context, pAdapter", __func__);
744 return VOS_STATUS_E_FAULT;
745 }
746
747 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
748
749 valid = wlan_hdd_validate_context(pHddCtx);
750 if (0 != valid)
751 {
752 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
753 return VOS_STATUS_E_FAULT;
754 }
755
756 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
757 if (NULL == pHddStaCtx)
758 {
759 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
760 return VOS_STATUS_E_FAULT;
761 }
762
763 init_completion(&context.completion);
764 context.pAdapter = pAdapter;
765 context.magic = SNR_CONTEXT_MAGIC;
766
767 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
768 pHddStaCtx->conn_info.staId[ 0 ],
769 pHddStaCtx->conn_info.bssId,
770 &context);
771 if (eHAL_STATUS_SUCCESS != hstatus)
772 {
773 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
774 __func__);
775 /* we'll returned a cached value below */
776 }
777 else
778 {
779 /* request was sent -- wait for the response */
780 lrc = wait_for_completion_interruptible_timeout(&context.completion,
781 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
782 /* either we have a response or we timed out
783 * either way, first invalidate our magic
784 */
785 context.magic = 0;
786 if (lrc <= 0)
787 {
788 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving SNR ",
789 __func__, (0 == lrc) ? "timeout" : "interrupt");
790 /* there is a race condition such that the callback
791 * function could be executing at the same time we are. Of
792 * primary concern is if the callback function had already
793 * verified the "magic" but hasn't yet set the completion
794 * variable. Since the completion variable is on our
795 * stack, we'll delay just a bit to make sure the data is
796 * still valid if that is the case
797 */
798 msleep(50);
799 /* we'll now returned a cached value below */
800 }
801 }
802 *snr = pAdapter->snr;
803
804 return VOS_STATUS_SUCCESS;
805}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800806#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
807
808static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
809{
810 struct statsContext *pStatsContext;
811 hdd_adapter_t *pAdapter;
812 if (ioctl_debug)
813 {
814 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
815 __func__, (int)rssi, (int)staId, pContext);
816 }
817
818 if (NULL == pContext)
819 {
820 hddLog(VOS_TRACE_LEVEL_ERROR,
821 "%s: Bad param, pContext [%p]",
822 __func__, pContext);
823 return;
824 }
825
826 /* there is a race condition that exists between this callback function
827 and the caller since the caller could time out either before or
828 while this code is executing. we'll assume the timeout hasn't
829 occurred, but we'll verify that right before we save our work */
830
831 pStatsContext = pContext;
832 pAdapter = pStatsContext->pAdapter;
833 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
834 {
835 /* the caller presumably timed out so there is nothing we can do */
836 hddLog(VOS_TRACE_LEVEL_WARN,
837 "%s: Invalid context, pAdapter [%p] magic [%08x]",
838 __func__, pAdapter, pStatsContext->magic);
839 if (ioctl_debug)
840 {
841 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
842 __func__, pAdapter, pStatsContext->magic);
843 }
844 return;
845 }
846
847 /* the race is on. caller could have timed out immediately after
848 we verified the magic, but if so, caller will wait a short time
849 for us to copy over the rssi */
850 pAdapter->rssi = rssi;
851
852 /* and notify the caller */
853 complete(&pStatsContext->completion);
854}
855
856
857
858VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
859{
860 struct statsContext context;
861 hdd_context_t *pHddCtx = NULL;
862 hdd_station_ctx_t *pHddStaCtx = NULL;
863 eHalStatus hstatus;
864 long lrc;
865
866 if (NULL == pAdapter)
867 {
868 hddLog(VOS_TRACE_LEVEL_WARN,
869 "%s: Invalid context, pAdapter", __func__);
870 return VOS_STATUS_E_FAULT;
871 }
872 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
873 {
874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
875 /* return a cached value */
876 *rssi_value = pAdapter->rssi;
877 return VOS_STATUS_SUCCESS;
878 }
879
880 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
881 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
882
883 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
884 {
885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
886 /* return a cached value */
887 *rssi_value = 0;
888 return VOS_STATUS_SUCCESS;
889 }
890 init_completion(&context.completion);
891 context.pAdapter = pAdapter;
892 context.magic = RSSI_CONTEXT_MAGIC;
893
894 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
895 pHddStaCtx->conn_info.staId[ 0 ],
896 pHddStaCtx->conn_info.bssId,
897 &context, pHddCtx->pvosContext);
898 if (eHAL_STATUS_SUCCESS != hstatus)
899 {
900 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
901 __func__);
902 /* we'll returned a cached value below */
903 }
904 else
905 {
906 /* request was sent -- wait for the response */
907 lrc = wait_for_completion_interruptible_timeout(&context.completion,
908 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
909 /* either we have a response or we timed out
910 either way, first invalidate our magic */
911 context.magic = 0;
912 if (lrc <= 0)
913 {
914 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
915 __func__, (0 == lrc) ? "timeout" : "interrupt");
916 /* there is a race condition such that the callback
917 function could be executing at the same time we are. of
918 primary concern is if the callback function had already
919 verified the "magic" but hasn't yet set the completion
920 variable. Since the completion variable is on our
921 stack, we'll delay just a bit to make sure the data is
922 still valid if that is the case */
923 msleep(50);
924 /* we'll now returned a cached value below */
925 }
926 }
927 *rssi_value = pAdapter->rssi;
928
929 return VOS_STATUS_SUCCESS;
930}
931#endif
932
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934void hdd_StatisticsCB( void *pStats, void *pContext )
935{
936 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
937 hdd_stats_t *pStatsCache = NULL;
938 hdd_wext_state_t *pWextState;
939 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
940
941 tCsrSummaryStatsInfo *pSummaryStats = NULL;
942 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
943 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
944 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
945 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
946 tCsrPerStaStatsInfo *pPerStaStats = NULL;
947
948 if (pAdapter!= NULL)
949 pStatsCache = &pAdapter->hdd_stats;
950
951
952 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
953 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
954 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
955 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
956 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
957 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
958
959 if (pStatsCache!=NULL)
960 {
961 // and copy the stats into the cache we keep in the adapter instance structure
962 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
963 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
964 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
965 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
966 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
967 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
968 }
969
970 if(pAdapter)
971 {
972 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
973 if(pWextState)
974 {
975 vos_status = vos_event_set(&pWextState->vosevent);
976 if (!VOS_IS_STATUS_SUCCESS(vos_status))
977 {
978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700979 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 return;
981 }
982 }
983 }
984}
985
986void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
987{
988 v_CONTEXT_t pVosContext;
989 hdd_context_t *pHddCtx;
990 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
991#if 0
992 hdd_wext_state_t *pWextState;
993 v_U32_t roamId;
994#endif
995
996 ENTER();
997
998 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
999
1000 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1001 if (NULL == pHddCtx)
1002 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001003 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 return;
1005 }
1006#if 0
1007 pWextState = pAdapter->pWextState;
1008#endif
1009
1010 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1011 {
1012 //TODO Verify is this is really used. If yes need to fix it.
1013 hdd_reconnect_all_adapters( pHddCtx );
1014#if 0
1015 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1016 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1017 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1018
1019 if(VOS_STATUS_SUCCESS == vosStatus)
1020 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1021 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1022
1023 sme_RoamConnect(halHandle,
1024 pAdapter->sessionId, &(pWextState->roamProfile),
1025 &roamId);
1026#endif
1027 }
1028
1029 EXIT();
1030
1031}
1032
1033void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1034{
1035 int i = 0;
1036 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1037
1038 /* clear WPA/RSN/WSC IE information in the profile */
1039 pWextState->roamProfile.nWPAReqIELength = 0;
1040 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1041 pWextState->roamProfile.nRSNReqIELength = 0;
1042 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1043
Chet Lanctot186b5732013-03-18 10:26:30 -07001044#ifdef FEATURE_WLAN_WAPI
1045 pWextState->roamProfile.nWAPIReqIELength = 0;
1046 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1047#endif
1048
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
1050 pWextState->roamProfile.pAddIEScan = (tANI_U8 *)NULL;
1051 pWextState->roamProfile.nAddIEScanLength = 0;
1052 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1053 pWextState->roamProfile.nAddIEAssocLength = 0;
1054
1055 pWextState->roamProfile.EncryptionType.numEntries = 1;
1056 pWextState->roamProfile.EncryptionType.encryptionType[0]
1057 = eCSR_ENCRYPT_TYPE_NONE;
1058
1059 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1060 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1061 = eCSR_ENCRYPT_TYPE_NONE;
1062
1063 pWextState->roamProfile.AuthType.numEntries = 1;
1064 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1065
Chet Lanctot186b5732013-03-18 10:26:30 -07001066#ifdef WLAN_FEATURE_11W
1067 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1068 pWextState->roamProfile.MFPRequired = 0;
1069 pWextState->roamProfile.MFPCapable = 0;
1070#endif
1071
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 pWextState->authKeyMgmt = 0;
1073
1074 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1075 {
1076 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1077 {
1078 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1079 }
1080 }
1081#ifdef FEATURE_WLAN_WAPI
1082 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1083 pAdapter->wapi_info.nWapiMode = 0;
1084#endif
1085
1086 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1087
1088}
1089
1090void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1091{
1092 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001093
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001094 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1095 {
1096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1097 "%s: Invalid pAdapter magic", __func__);
1098 }
1099 else
1100 {
1101 complete(&pAdapter->ula_complete);
1102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001103}
1104
1105VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1106{
1107 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001109 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001110
1111 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1112 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001113 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001114
1115 /*To avoid race condition between the set key and the last EAPOL
1116 packet, notify TL to finish upper layer authentication incase if the
1117 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001118 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001119
1120 if ( vos_status != VOS_STATUS_SUCCESS )
1121 {
1122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1123 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1124 __LINE__, vos_status );
1125 return vos_status;
1126
1127 }
1128
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001129 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001131 if (0 == rc)
1132 {
1133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1134 "%s: Timeout waiting for ULA to complete", __func__);
1135 /* we'll still fall through and return success since the
1136 * connection may still get established but is just taking
1137 * too long for us to wait */
1138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 }
1140 return VOS_STATUS_SUCCESS;
1141}
1142
1143v_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)
1144{
1145
1146 int left = ie_len;
1147 v_U8_t *ptr = ie;
1148 v_U8_t elem_id,elem_len;
1149 v_U8_t eid = 0xDD;
1150
1151 if ( NULL == ie || 0 == ie_len )
1152 return NULL;
1153
1154 while(left >= 2)
1155 {
1156 elem_id = ptr[0];
1157 elem_len = ptr[1];
1158 left -= 2;
1159 if(elem_len > left)
1160 {
1161 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001162 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 eid,elem_len,left);
1164 return NULL;
1165 }
1166 if (elem_id == eid)
1167 {
1168 if(memcmp( &ptr[2], oui, oui_size)==0)
1169 return ptr;
1170 }
1171
1172 left -= elem_len;
1173 ptr += (elem_len + 2);
1174 }
1175 return NULL;
1176}
1177
1178static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1179 union iwreq_data *wrqu, char *extra)
1180{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001181 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 /* Do nothing for now */
1183 return 0;
1184}
1185
1186static int iw_get_name(struct net_device *dev,
1187 struct iw_request_info *info,
1188 char *wrqu, char *extra)
1189{
1190
1191 ENTER();
1192 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1193 EXIT();
1194 return 0;
1195}
1196
1197static int iw_set_mode(struct net_device *dev,
1198 struct iw_request_info *info,
1199 union iwreq_data *wrqu, char *extra)
1200{
1201 hdd_wext_state_t *pWextState;
1202 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1203 tCsrRoamProfile *pRoamProfile;
1204 eCsrRoamBssType LastBSSType;
1205 eMib_dot11DesiredBssType connectedBssType;
1206 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001208
1209 ENTER();
1210
1211 if (NULL == pAdapter)
1212 {
1213 hddLog(VOS_TRACE_LEVEL_WARN,
1214 "%s: Invalid context, pAdapter", __func__);
1215 return 0;
1216 }
1217
1218 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1220 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 return 0;
1222 }
1223
1224 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1225 if (pWextState == NULL)
1226 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301227 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 return -EINVAL;
1229 }
1230
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 pRoamProfile = &pWextState->roamProfile;
1233 LastBSSType = pRoamProfile->BSSType;
1234
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301235 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001236
1237 switch (wrqu->mode)
1238 {
1239 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301240 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1242 // Set the phymode correctly for IBSS.
1243 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1244 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001245 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 break;
1248 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301249 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 break;
1253 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301254 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1256 break;
1257 default:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301258 hddLog(LOG1, "%s Unknown AP Mode value", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 return -EOPNOTSUPP;
1260 }
1261
1262 if ( LastBSSType != pRoamProfile->BSSType )
1263 {
1264 //the BSS mode changed
1265 // We need to issue disconnect if connected or in IBSS disconnect state
1266 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1267 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1268 {
1269 VOS_STATUS vosStatus;
1270 // need to issue a disconnect to CSR.
1271 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1272 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1273 pAdapter->sessionId,
1274 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1275 if(VOS_STATUS_SUCCESS == vosStatus)
1276 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1277 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1278 }
1279 }
1280
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 EXIT();
1282 return 0;
1283}
1284
1285
1286static int iw_get_mode(struct net_device *dev,
1287 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301288 union iwreq_data *wrqu,
1289 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001290{
1291
1292 hdd_wext_state_t *pWextState;
1293 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1294
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301295 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001296
1297 if (NULL == pAdapter)
1298 {
1299 hddLog(VOS_TRACE_LEVEL_WARN,
1300 "%s: Invalid context, pAdapter", __func__);
1301 return 0;
1302 }
1303
1304 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1306 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 return 0;
1308 }
1309
1310 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1311 if (pWextState == NULL)
1312 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301313 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 return -EINVAL;
1315 }
1316
1317 switch (pWextState->roamProfile.BSSType)
1318 {
1319 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001320 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301321 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 break;
1323 case eCSR_BSS_TYPE_IBSS:
1324 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001325 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301326 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 break;
1328 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001329 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301330 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 break;
1332 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001333 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 break;
1335 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301336
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 return 0;
1338}
1339
1340static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1341 union iwreq_data *wrqu, char *extra)
1342{
1343 v_U32_t numChans = 0;
1344 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1345 v_U32_t indx = 0;
1346 v_U32_t status = 0;
1347
1348 hdd_wext_state_t *pWextState;
1349 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1350 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1351 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1352 tCsrRoamProfile * pRoamProfile;
1353 ENTER();
1354
1355 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1357 return status;
1358 }
1359
1360 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1361
1362 pRoamProfile = &pWextState->roamProfile;
1363
Arif Hussain6d2a3322013-11-17 19:50:10 -08001364 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366 /* Link is up then return cant set channel*/
1367 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1368 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1369 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001370 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 return -EOPNOTSUPP;
1372 }
1373
1374 /* Settings by Frequency as input */
1375 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1376 (wrqu->freq.m <= (tANI_U32)5.825e8))
1377 {
1378 tANI_U32 freq = wrqu->freq.m / 100000;
1379
1380 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1381 indx++;
1382 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1383 {
1384 return -EINVAL;
1385 }
1386 wrqu->freq.e = 0;
1387 wrqu->freq.m = freq_chan_map[indx].chan;
1388
1389 }
1390
1391 if (wrqu->freq.e == 0)
1392 {
1393 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1394 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1395 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001396 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001397 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001398 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1399 return -EINVAL;
1400 }
1401
1402 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1403
1404 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1405 validChan, &numChans) != eHAL_STATUS_SUCCESS){
1406 return -EIO;
1407 }
1408
1409 for (indx = 0; indx < numChans; indx++) {
1410 if (wrqu->freq.m == validChan[indx]){
1411 break;
1412 }
1413 }
1414 }
1415 else{
1416
1417 return -EINVAL;
1418 }
1419
1420 if(indx >= numChans)
1421 {
1422 return -EINVAL;
1423 }
1424
1425 /* Set the Operational Channel */
1426 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1427 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1428 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1429
Arif Hussain6d2a3322013-11-17 19:50:10 -08001430 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001431
1432 EXIT();
1433
1434 return status;
1435}
1436
1437static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1438 struct iw_freq *fwrq, char *extra)
1439{
Jeff Johnsone7245742012-09-05 17:12:55 -07001440 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1442 tHalHandle hHal;
1443 hdd_wext_state_t *pWextState;
1444 tCsrRoamProfile * pRoamProfile;
1445 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1446
1447 ENTER();
1448
1449 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1451 return status;
1452 }
1453
1454 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1455 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1456
1457 pRoamProfile = &pWextState->roamProfile;
1458
1459 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1460 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001461 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 {
1463 return -EIO;
1464 }
1465 else
1466 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001467 status = hdd_wlan_get_freq(channel, &freq);
1468 if( TRUE == status )
1469 {
1470 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1471 * iwlist & iwconfig command shows frequency into proper
1472 * format (2.412 GHz instead of 246.2 MHz)*/
1473 fwrq->m = freq;
1474 fwrq->e = MHZ;
1475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 }
1477 }
1478 else
1479 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001480 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1481 * iwlist & iwconfig command shows frequency into proper
1482 * format (2.412 GHz instead of 246.2 MHz)*/
1483 fwrq->m = 0;
1484 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001486 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001487}
1488
1489static int iw_get_tx_power(struct net_device *dev,
1490 struct iw_request_info *info,
1491 union iwreq_data *wrqu, char *extra)
1492{
1493
1494 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1495 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1496 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1497
1498 if (pHddCtx->isLogpInProgress)
1499 {
1500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1501 "%s:LOGP in Progress. Ignore!!!",__func__);
1502 return -EBUSY;
1503 }
1504
1505 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1506 {
1507 wrqu->txpower.value = 0;
1508 return 0;
1509 }
1510 wlan_hdd_get_classAstats(pAdapter);
1511 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1512
1513 return 0;
1514}
1515
1516static int iw_set_tx_power(struct net_device *dev,
1517 struct iw_request_info *info,
1518 union iwreq_data *wrqu, char *extra)
1519{
1520 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1521 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1522
1523 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1524 {
1525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1526 return 0;
1527 }
1528
1529 ENTER();
1530
1531 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1532 {
1533 return -EIO;
1534 }
1535
1536 EXIT();
1537
1538 return 0;
1539}
1540
1541static int iw_get_bitrate(struct net_device *dev,
1542 struct iw_request_info *info,
1543 union iwreq_data *wrqu, char *extra)
1544{
1545 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1546 eHalStatus status = eHAL_STATUS_SUCCESS;
1547 hdd_wext_state_t *pWextState;
1548 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1549 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1550
1551 ENTER();
1552
1553 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1555 return status;
1556 }
1557
1558 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1559 wrqu->bitrate.value = 0;
1560 }
1561 else {
1562 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1563 SME_SUMMARY_STATS |
1564 SME_GLOBAL_CLASSA_STATS |
1565 SME_GLOBAL_CLASSB_STATS |
1566 SME_GLOBAL_CLASSC_STATS |
1567 SME_GLOBAL_CLASSD_STATS |
1568 SME_PER_STA_STATS,
1569 hdd_StatisticsCB, 0, FALSE,
1570 pHddStaCtx->conn_info.staId[0], pAdapter );
1571
1572 if(eHAL_STATUS_SUCCESS != status)
1573 {
1574 hddLog(VOS_TRACE_LEVEL_ERROR,
1575 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001576 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 return status;
1578 }
1579
1580 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1581
1582 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1583
1584 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1585 {
1586 hddLog(VOS_TRACE_LEVEL_ERROR,
1587 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001588 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 return VOS_STATUS_E_FAILURE;
1590 }
1591
1592 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1593 }
1594
1595 EXIT();
1596
1597 return vos_status;
1598}
1599/* ccm call back function */
1600
1601static int iw_set_bitrate(struct net_device *dev,
1602 struct iw_request_info *info,
1603 union iwreq_data *wrqu,
1604 char *extra)
1605{
1606 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1607 hdd_wext_state_t *pWextState;
1608 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1609 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1610 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1611 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1612 v_U32_t i, rate;
1613 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1614
1615 ENTER();
1616
1617 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1619 return 0;
1620 }
1621
1622 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1623
1624 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1625 {
1626 return -ENXIO ;
1627 }
1628
1629 rate = wrqu->bitrate.value;
1630
1631 if (rate == -1)
1632 {
1633 rate = WNI_CFG_FIXED_RATE_AUTO;
1634 valid_rate = TRUE;
1635 }
1636 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1637 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1638 {
1639 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1640 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1641 {
1642 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1643 WNI_CFG_SUPPORTED_RATES_11A,
1644 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1645 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1646 WNI_CFG_SUPPORTED_RATES_11B,
1647 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1648 {
1649 for (i = 0; i < (b_len + a_len); ++i)
1650 {
1651 /* supported rates returned is double the actual rate so we divide it by 2 */
1652 if ((supp_rates[i]&0x7F)/2 == rate)
1653 {
1654 valid_rate = TRUE;
1655 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1656 break;
1657 }
1658 }
1659 }
1660 }
1661 }
1662 if (valid_rate != TRUE)
1663 {
1664 return -EINVAL;
1665 }
1666 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1667 WNI_CFG_FIXED_RATE, rate,
1668 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1669 {
1670 return -EIO;
1671 }
1672 return 0;
1673}
1674
1675
1676static int iw_set_genie(struct net_device *dev,
1677 struct iw_request_info *info,
1678 union iwreq_data *wrqu,
1679 char *extra)
1680{
1681 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1682 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001683 u_int8_t *genie = (u_int8_t *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 v_U16_t remLen;
1685
1686 ENTER();
1687 if(!wrqu->data.length) {
1688 hdd_clearRoamProfileIe(pAdapter);
1689 EXIT();
1690 return 0;
1691 }
1692
1693 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1695 return 0;
1696 }
1697
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 remLen = wrqu->data.length;
1699
Arif Hussain6d2a3322013-11-17 19:50:10 -08001700 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001701
1702 /* clear any previous genIE before this call */
1703 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1704
1705 while (remLen >= 2)
1706 {
1707 v_U16_t eLen = 0;
1708 v_U8_t elementId;
1709 elementId = *genie++;
1710 eLen = *genie++;
1711 remLen -= 2;
1712
Arif Hussain6d2a3322013-11-17 19:50:10 -08001713 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 __func__, elementId, eLen);
1715
1716 switch ( elementId )
1717 {
1718 case IE_EID_VENDOR:
1719 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
1720 return -EINVAL;
1721
1722 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1723 {
1724 v_U16_t curGenIELen = pWextState->genIE.length;
1725 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1726 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1727
1728 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1729 {
1730 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001731 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 VOS_ASSERT(0);
1733 return -ENOMEM;
1734 }
1735 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1736 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1737 pWextState->genIE.length += eLen + 2;
1738 }
1739 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1740 {
1741 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1742 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1743 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1744 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1745 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1746 }
1747 else /* any vendorId except WPA IE should be accumulated to genIE */
1748 {
1749 v_U16_t curGenIELen = pWextState->genIE.length;
1750 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1751 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1752
1753 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1754 {
1755 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001756 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 VOS_ASSERT(0);
1758 return -ENOMEM;
1759 }
1760 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1761 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1762 pWextState->genIE.length += eLen + 2;
1763 }
1764 break;
1765 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001766 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1768 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1769 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1770 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1771 break;
1772
1773 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001774 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 return 0;
1776 }
1777 genie += eLen;
1778 remLen -= eLen;
1779 }
1780 EXIT();
1781 return 0;
1782}
1783
1784static int iw_get_genie(struct net_device *dev,
1785 struct iw_request_info *info,
1786 union iwreq_data *wrqu,
1787 char *extra)
1788{
1789 hdd_wext_state_t *pWextState;
1790 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1791 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1792 eHalStatus status;
1793 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1794 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1795
1796 ENTER();
1797
1798 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1800 return 0;
1801 }
1802
1803
Arif Hussain6d2a3322013-11-17 19:50:10 -08001804 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001805
1806 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1807
1808 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1809 {
1810 return -ENXIO;
1811 }
1812
1813 // Return something ONLY if we are associated with an RSN or WPA network
1814 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1815 pWextState->roamProfile.negotiatedAuthType))
1816 {
1817 return -ENXIO;
1818 }
1819
1820 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1821 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1822 pAdapter->sessionId,
1823 &length,
1824 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001825 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1826 if (wrqu->data.length < length)
1827 {
1828 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1829 return -EFAULT;
1830 }
1831 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, wrqu->data.length);
1832 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001833
Arif Hussain6d2a3322013-11-17 19:50:10 -08001834 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001835
1836 EXIT();
1837
1838 return 0;
1839}
1840
1841static int iw_get_encode(struct net_device *dev,
1842 struct iw_request_info *info,
1843 struct iw_point *dwrq, char *extra)
1844{
1845 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1846 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1847 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1848 int keyId;
1849 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1850 int i;
1851
1852 ENTER();
1853
1854 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1856 return 0;
1857 }
1858
1859 keyId = pRoamProfile->Keys.defaultIndex;
1860
1861 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1862 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001863 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 return -EINVAL;
1865 }
1866
1867 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1868 {
1869 dwrq->flags |= IW_ENCODE_ENABLED;
1870 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1871 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1872
1873 dwrq->flags |= (keyId + 1);
1874
1875 }
1876 else
1877 {
1878 dwrq->flags |= IW_ENCODE_DISABLED;
1879 }
1880
1881 for(i=0; i < MAX_WEP_KEYS; i++)
1882 {
1883 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
1884 {
1885 continue;
1886 }
1887 else
1888 {
1889 break;
1890 }
1891 }
1892
1893 if(MAX_WEP_KEYS == i)
1894 {
1895 dwrq->flags |= IW_ENCODE_NOKEY;
1896 }
1897
1898 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
1899
1900 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
1901 {
1902 dwrq->flags |= IW_ENCODE_OPEN;
1903 }
1904 else
1905 {
1906 dwrq->flags |= IW_ENCODE_RESTRICTED;
1907 }
1908 EXIT();
1909 return 0;
1910}
1911
1912#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
1913#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
1914
1915
1916/*
1917 * This function sends a single 'key' to LIM at all time.
1918 */
1919
1920static int iw_get_rts_threshold(struct net_device *dev,
1921 struct iw_request_info *info,
1922 union iwreq_data *wrqu, char *extra)
1923{
1924 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1925 v_U32_t status = 0;
1926
1927 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
1928
1929 return status;
1930}
1931
1932static int iw_set_rts_threshold(struct net_device *dev,
1933 struct iw_request_info *info,
1934 union iwreq_data *wrqu, char *extra)
1935{
1936 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1937 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1938
1939 ENTER();
1940
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001941 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1942 {
1943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1944 "%s:LOGP in Progress. Ignore!!!", __func__);
1945 return -EAGAIN;
1946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
1948 {
1949 return -EINVAL;
1950 }
1951
1952 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1953 {
1954 return -EIO;
1955 }
1956
1957 EXIT();
1958
1959 return 0;
1960}
1961
1962static int iw_get_frag_threshold(struct net_device *dev,
1963 struct iw_request_info *info,
1964 union iwreq_data *wrqu, char *extra)
1965{
1966 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1967 v_U32_t status = 0;
1968
1969 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
1970
1971 return status;
1972}
1973
1974static int iw_set_frag_threshold(struct net_device *dev,
1975 struct iw_request_info *info,
1976 union iwreq_data *wrqu, char *extra)
1977{
1978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1979 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1980
1981 ENTER();
1982
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001983 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1984 {
1985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1986 "%s:LOGP in Progress. Ignore!!!", __func__);
1987 return -EBUSY;
1988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
1990 {
1991 return -EINVAL;
1992 }
1993
1994 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1995 {
1996 return -EIO;
1997 }
1998
1999 EXIT();
2000
2001 return 0;
2002}
2003
2004static int iw_get_power_mode(struct net_device *dev,
2005 struct iw_request_info *info,
2006 union iwreq_data *wrqu, char *extra)
2007{
2008 ENTER();
2009 return -EOPNOTSUPP;
2010}
2011
2012static int iw_set_power_mode(struct net_device *dev,
2013 struct iw_request_info *info,
2014 union iwreq_data *wrqu, char *extra)
2015{
2016 ENTER();
2017 return -EOPNOTSUPP;
2018}
2019
2020static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2021 union iwreq_data *wrqu, char *extra)
2022{
2023 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2024 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2025 struct iw_range *range = (struct iw_range *) extra;
2026
2027 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2028
2029 v_U32_t num_channels = sizeof(channels);
2030 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2031 v_U32_t a_len;
2032 v_U32_t b_len;
2033 v_U32_t active_phy_mode = 0;
2034 v_U8_t index = 0, i;
2035
2036 ENTER();
2037
2038 wrqu->data.length = sizeof(struct iw_range);
2039 memset(range, 0, sizeof(struct iw_range));
2040
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002041 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2042 {
2043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2044 "%s:LOGP in Progress. Ignore!!!", __func__);
2045 return -EBUSY;
2046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002047
2048 /*Get the phy mode*/
2049 if (ccmCfgGetInt(hHal,
2050 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2051 {
2052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002053 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002054
2055 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2056 {
2057 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002058 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 if (ccmCfgGetStr(hHal,
2060 WNI_CFG_SUPPORTED_RATES_11A,
2061 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2062 {
2063 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2064 {
2065 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2066 }
2067 for (i = 0; i < a_len; i++)
2068 {
2069 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2070 }
2071 range->num_bitrates = a_len;
2072 }
2073 else
2074 {
2075 return -EIO;
2076 }
2077 }
2078 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2079 {
2080 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002081 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 if (ccmCfgGetStr(hHal,
2083 WNI_CFG_SUPPORTED_RATES_11B,
2084 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2085 {
2086 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2087 {
2088 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2089 }
2090 for (i = 0; i < b_len; i++)
2091 {
2092 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2093 }
2094 range->num_bitrates = b_len;
2095 }
2096 else
2097 {
2098 return -EIO;
2099 }
2100 }
2101 }
2102
2103 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2104 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2105 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2106
2107 range->encoding_size[0] = 5;
2108 range->encoding_size[1] = 13;
2109 range->num_encoding_sizes = 2;
2110 range->max_encoding_tokens = MAX_WEP_KEYS;
2111
2112 // we support through Wireless Extensions 22
2113 range->we_version_compiled = WIRELESS_EXT;
2114 range->we_version_source = 22;
2115
2116 /*Supported Channels and Frequencies*/
2117 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2118 {
2119 return -EIO;
2120 }
2121 if (num_channels > IW_MAX_FREQUENCIES)
2122 {
2123 num_channels = IW_MAX_FREQUENCIES;
2124 }
2125
2126 range->num_channels = num_channels;
2127 range->num_frequency = num_channels;
2128
2129 for (index=0; index < num_channels; index++)
2130 {
2131 v_U32_t frq_indx = 0;
2132
2133 range->freq[index].i = channels[index];
2134 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2135 {
2136 if(channels[index] == freq_chan_map[frq_indx].chan)
2137 {
2138 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2139 range->freq[index].e = 1;
2140 break;
2141 }
2142 frq_indx++;
2143 }
2144 }
2145
2146 /* Event capability (kernel + driver) */
2147 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2148 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2149 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2150 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2151
2152 /*Encryption capability*/
2153 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2154 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2155
2156 /* Txpower capability */
2157 range->txpower_capa = IW_TXPOW_MWATT;
2158
2159 /*Scanning capability*/
2160 #if WIRELESS_EXT >= 22
2161 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2162 #endif
2163
2164 EXIT();
2165 return 0;
2166}
2167
2168/* Callback function registered with PMC to know status of PMC request */
2169static void iw_power_callback_fn (void *pContext, eHalStatus status)
2170{
2171 struct statsContext *pStatsContext;
2172 hdd_adapter_t *pAdapter;
2173
2174 if (NULL == pContext)
2175 {
2176 hddLog(VOS_TRACE_LEVEL_ERROR,
2177 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002178 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 return;
2180 }
2181
2182 /* there is a race condition that exists between this callback function
2183 and the caller since the caller could time out either before or
2184 while this code is executing. we'll assume the timeout hasn't
2185 occurred, but we'll verify that right before we save our work */
2186
2187 pStatsContext = (struct statsContext *)pContext;
2188 pAdapter = pStatsContext->pAdapter;
2189
2190 if ((NULL == pAdapter) || (POWER_CONTEXT_MAGIC != pStatsContext->magic))
2191 {
2192 /* the caller presumably timed out so there is nothing we can do */
2193 hddLog(VOS_TRACE_LEVEL_WARN,
2194 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002195 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002196
2197 if (ioctl_debug)
2198 {
2199 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002200 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 }
2202 return;
2203 }
2204
2205 /* and notify the caller */
2206 complete(&pStatsContext->completion);
2207}
2208
2209/* Callback function for tx per hit */
2210void hdd_tx_per_hit_cb (void *pCallbackContext)
2211{
2212 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2213 unsigned char tx_fail[16];
2214 union iwreq_data wrqu;
2215
2216 if (NULL == pAdapter)
2217 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002218 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 return;
2220 }
2221 memset(&wrqu, 0, sizeof(wrqu));
2222 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2223 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2224}
2225
2226void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2227{
2228 struct statsContext *pStatsContext;
2229 tCsrGlobalClassAStatsInfo *pClassAStats;
2230 hdd_adapter_t *pAdapter;
2231
2232 if (ioctl_debug)
2233 {
2234 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002235 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 }
2237
2238 if ((NULL == pStats) || (NULL == pContext))
2239 {
2240 hddLog(VOS_TRACE_LEVEL_ERROR,
2241 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002242 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 return;
2244 }
2245
2246 /* there is a race condition that exists between this callback function
2247 and the caller since the caller could time out either before or
2248 while this code is executing. we'll assume the timeout hasn't
2249 occurred, but we'll verify that right before we save our work */
2250
2251 pClassAStats = pStats;
2252 pStatsContext = pContext;
2253 pAdapter = pStatsContext->pAdapter;
2254 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2255 {
2256 /* the caller presumably timed out so there is nothing we can do */
2257 hddLog(VOS_TRACE_LEVEL_WARN,
2258 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002259 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 if (ioctl_debug)
2261 {
2262 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002263 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 }
2265 return;
2266 }
2267
2268 /* the race is on. caller could have timed out immediately after
2269 we verified the magic, but if so, caller will wait a short time
2270 for us to copy over the stats. do so as a struct copy */
2271 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2272
2273 /* and notify the caller */
2274 complete(&pStatsContext->completion);
2275}
2276
2277VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2278{
2279 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2280 eHalStatus hstatus;
2281 long lrc;
2282 struct statsContext context;
2283
2284 if (NULL == pAdapter)
2285 {
2286 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2287 return VOS_STATUS_E_FAULT;
2288 }
2289 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2290 {
2291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2292 return VOS_STATUS_SUCCESS;
2293 }
2294
2295 /* we are connected
2296 prepare our callback context */
2297 init_completion(&context.completion);
2298 context.pAdapter = pAdapter;
2299 context.magic = STATS_CONTEXT_MAGIC;
2300 /* query only for Class A statistics (which include link speed) */
2301 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2302 eCSR_HDD,
2303 SME_GLOBAL_CLASSA_STATS,
2304 hdd_GetClassA_statisticsCB,
2305 0, // not periodic
2306 FALSE, //non-cached results
2307 pHddStaCtx->conn_info.staId[0],
2308 &context);
2309 if (eHAL_STATUS_SUCCESS != hstatus)
2310 {
2311 hddLog(VOS_TRACE_LEVEL_ERROR,
2312 "%s: Unable to retrieve Class A statistics ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002313 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 /* we'll returned a cached value below */
2315 }
2316 else
2317 {
2318 /* request was sent -- wait for the response */
2319 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2320 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2321 /* either we have a response or we timed out
2322 either way, first invalidate our magic */
2323 context.magic = 0;
2324 if (lrc <= 0)
2325 {
2326 hddLog(VOS_TRACE_LEVEL_ERROR,
2327 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002328 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 /* there is a race condition such that the callback
2330 function could be executing at the same time we are. of
2331 primary concern is if the callback function had already
2332 verified the "magic" but hasn't yet set the completion
2333 variable. Since the completion variable is on our
2334 stack, we'll delay just a bit to make sure the data is
2335 still valid if that is the case */
2336 msleep(50);
2337 }
2338 }
2339 return VOS_STATUS_SUCCESS;
2340}
2341
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002342static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2343{
2344 struct statsContext *pStatsContext;
2345 tCsrSummaryStatsInfo *pSummaryStats;
2346 tCsrGlobalClassAStatsInfo *pClassAStats;
2347 hdd_adapter_t *pAdapter;
2348
2349 if (ioctl_debug)
2350 {
2351 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002352 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002353 }
2354
2355 if ((NULL == pStats) || (NULL == pContext))
2356 {
2357 hddLog(VOS_TRACE_LEVEL_ERROR,
2358 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002359 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002360 return;
2361 }
2362
2363 /* there is a race condition that exists between this callback function
2364 and the caller since the caller could time out either before or
2365 while this code is executing. we'll assume the timeout hasn't
2366 occurred, but we'll verify that right before we save our work */
2367
2368 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2369 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2370 pStatsContext = pContext;
2371 pAdapter = pStatsContext->pAdapter;
2372 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2373 {
2374 /* the caller presumably timed out so there is nothing we can do */
2375 hddLog(VOS_TRACE_LEVEL_WARN,
2376 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002377 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002378 if (ioctl_debug)
2379 {
2380 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002381 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002382 }
2383 return;
2384 }
2385
2386 /* the race is on. caller could have timed out immediately after
2387 we verified the magic, but if so, caller will wait a short time
2388 for us to copy over the stats. do so as a struct copy */
2389 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2390 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2391
2392 /* and notify the caller */
2393 complete(&pStatsContext->completion);
2394}
2395
2396VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2397{
2398 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2399 eHalStatus hstatus;
2400 long lrc;
2401 struct statsContext context;
2402
2403 if (NULL == pAdapter)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2406 return VOS_STATUS_SUCCESS;
2407 }
2408
2409 /* we are connected
2410 prepare our callback context */
2411 init_completion(&context.completion);
2412 context.pAdapter = pAdapter;
2413 context.magic = STATS_CONTEXT_MAGIC;
2414
2415 /* query only for Summary & Class A statistics */
2416 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2417 eCSR_HDD,
2418 SME_SUMMARY_STATS |
2419 SME_GLOBAL_CLASSA_STATS,
2420 hdd_get_station_statisticsCB,
2421 0, // not periodic
2422 FALSE, //non-cached results
2423 pHddStaCtx->conn_info.staId[0],
2424 &context);
2425 if (eHAL_STATUS_SUCCESS != hstatus)
2426 {
2427 hddLog(VOS_TRACE_LEVEL_ERROR,
2428 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002429 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002430 /* we'll return with cached values */
2431 }
2432 else
2433 {
2434 /* request was sent -- wait for the response */
2435 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2436 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2437 /* either we have a response or we timed out
2438 either way, first invalidate our magic */
2439 context.magic = 0;
2440 if (lrc <= 0)
2441 {
2442 hddLog(VOS_TRACE_LEVEL_ERROR,
2443 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002444 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002445 /* there is a race condition such that the callback
2446 function could be executing at the same time we are. of
2447 primary concern is if the callback function had already
2448 verified the "magic" but hasn't yet set the completion
2449 variable. Since the completion variable is on our
2450 stack, we'll delay just a bit to make sure the data is
2451 still valid if that is the case */
2452 msleep(50);
2453 }
2454 }
2455 return VOS_STATUS_SUCCESS;
2456}
2457
2458
Jeff Johnson295189b2012-06-20 16:38:30 -07002459/*
2460 * Support for the LINKSPEED private command
2461 * Per the WiFi framework the response must be of the form
2462 * "LinkSpeed xx"
2463 */
2464static int iw_get_linkspeed(struct net_device *dev,
2465 struct iw_request_info *info,
2466 union iwreq_data *wrqu, char *extra)
2467{
2468 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302469 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302471 int len = sizeof(v_U32_t) + 1;
2472 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302474 VOS_STATUS status;
2475 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002476
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302477 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2478
2479 valid = wlan_hdd_validate_context(pHddCtx);
2480
2481 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002482 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302483 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2484 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002485 }
2486
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2488 {
2489 /* we are not connected so we don't have a classAstats */
2490 link_speed = 0;
2491 }
2492 else
2493 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302494 status = wlan_hdd_get_classAstats(pAdapter);
2495
2496 if (!VOS_IS_STATUS_SUCCESS(status ))
2497 {
2498 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2499 return -EINVAL;
2500 }
2501
2502 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2503 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2504 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2505 &link_speed);
2506
2507 link_speed = link_speed / 10;
2508
2509 if (0 == link_speed)
2510 {
2511 /* The linkspeed returned by HAL is in units of 500kbps.
2512 * converting it to mbps.
2513 * This is required to support legacy firmware which does
2514 * not return link capacity.
2515 */
2516 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2517 }
2518
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 }
2520
2521 wrqu->data.length = len;
2522 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002523 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 if ((rc < 0) || (rc >= len))
2525 {
2526 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302527 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 return -EIO;
2529 }
2530
2531 /* a value is being successfully returned */
2532 return 0;
2533}
2534
2535
2536/*
2537 * Support for the RSSI & RSSI-APPROX private commands
2538 * Per the WiFi framework the response must be of the form
2539 * "<ssid> rssi <xx>"
2540 * unless we are not associated, in which case the response is
2541 * "OK"
2542 */
2543static int iw_get_rssi(struct net_device *dev,
2544 struct iw_request_info *info,
2545 union iwreq_data *wrqu, char *extra)
2546{
2547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002548 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 int len = wrqu->data.length;
2550 v_S7_t s7Rssi = 0;
2551 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2552 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2553 VOS_STATUS vosStatus;
2554 int rc;
2555
2556 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2557 (0 == ssidlen) || (ssidlen >= len))
2558 {
2559 /* we are not connected or our SSID is too long
2560 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002561 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 }
2563 else
2564 {
2565 /* we are connected with a valid SSID
2566 so we can write the SSID into the return buffer
2567 (note that it is not NUL-terminated) */
2568 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2569
2570 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2571
2572 if (VOS_STATUS_SUCCESS == vosStatus)
2573 {
2574 /* append the rssi to the ssid in the format required by
2575 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002576 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 }
2578 else
2579 {
2580 rc = -1;
2581 }
2582 }
2583
2584 /* verify that we wrote a valid response */
2585 if ((rc < 0) || (rc >= len))
2586 {
2587 // encoding or length error?
2588 hddLog(VOS_TRACE_LEVEL_ERROR,
2589 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002590 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 return -EIO;
2592 }
2593
2594 /* a value is being successfully returned */
2595 return 0;
2596}
2597
2598/*
2599 * Support for SoftAP channel range private command
2600 */
2601static int iw_softap_set_channel_range( struct net_device *dev,
2602 int startChannel,
2603 int endChannel,
2604 int band)
2605{
Jeff Johnson43971f52012-07-17 12:26:56 -07002606 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 int ret = 0;
2608 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2609 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002610 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2611
Jeff Johnson295189b2012-06-20 16:38:30 -07002612
2613 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2614 if (VOS_STATUS_SUCCESS != status)
2615 {
2616 ret = -EINVAL;
2617 }
Yathish9f22e662012-12-10 14:21:35 -08002618 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 return ret;
2620}
2621
2622VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2623{
2624 struct statsContext context;
2625 eHalStatus status;
2626 hdd_context_t *pHddCtx;
2627
2628 if (NULL == pAdapter)
2629 {
2630 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2631 return VOS_STATUS_E_FAULT;
2632 }
2633
2634 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2635 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2636 init_completion(&context.completion);
2637
2638 context.pAdapter = pAdapter;
2639 context.magic = POWER_CONTEXT_MAGIC;
2640
2641 if (DRIVER_POWER_MODE_ACTIVE == mode)
2642 {
2643 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2644 "Full Power", __func__);
2645 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2646 iw_power_callback_fn, &context,
2647 eSME_FULL_PWR_NEEDED_BY_HDD);
2648 // Enter Full power command received from GUI this means we are disconnected
2649 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2650 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2651 if (eHAL_STATUS_PMC_PENDING == status)
2652 {
2653 int lrc = wait_for_completion_interruptible_timeout(
2654 &context.completion,
2655 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2656 context.magic = 0;
2657 if (lrc <= 0)
2658 {
2659 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002660 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 /* there is a race condition such that the callback
2662 function could be executing at the same time we are. of
2663 primary concern is if the callback function had already
2664 verified the "magic" but hasn't yet set the completion
2665 variable. Since the completion variable is on our
2666 stack, we'll delay just a bit to make sure the data is
2667 still valid if that is the case */
2668 msleep(50);
2669 /* we'll now returned a cached value below */
2670 }
2671 }
2672 }
2673 else if (DRIVER_POWER_MODE_AUTO == mode)
2674 {
2675 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2676 {
2677 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2678 __func__);
2679 // Enter BMPS command received from GUI this means DHCP is completed
2680 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2681 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2682 FALSE);
2683 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2684 iw_power_callback_fn, &context);
2685 if (eHAL_STATUS_PMC_PENDING == status)
2686 {
2687 int lrc = wait_for_completion_interruptible_timeout(
2688 &context.completion,
2689 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2690 context.magic = 0;
2691 if (lrc <= 0)
2692 {
2693 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting BMPS ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002694 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 /* there is a race condition such that the callback
2696 function could be executing at the same time we are. of
2697 primary concern is if the callback function had already
2698 verified the "magic" but hasn't yet set the completion
2699 variable. Since the completion variable is on our
2700 stack, we'll delay just a bit to make sure the data is
2701 still valid if that is the case */
2702 msleep(50);
2703 /* we'll now returned a cached value below */
2704 }
2705 }
2706 }
2707 else
2708 {
2709 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2710 "enabled in the cfg");
2711 }
2712 }
2713 return VOS_STATUS_SUCCESS;
2714}
2715
2716VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2717 hdd_adapter_t *pAdapter)
2718{
2719 VOS_STATUS vos_Status;
2720
2721 if ((NULL == pAdapter) || (NULL == pHddCtx))
2722 {
2723 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2724 return VOS_STATUS_E_FAULT;
2725 }
2726
2727 /**Exit from Deep sleep or standby if we get the driver
2728 START cmd from android GUI
2729 */
2730 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2731 {
2732 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2733 "from Stand by",__func__);
2734 vos_Status = hdd_exit_standby(pHddCtx);
2735 }
2736 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2737 {
2738 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2739 "from deep sleep",__func__);
2740 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2741 }
2742 else
2743 {
2744 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2745 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2746 vos_Status = VOS_STATUS_SUCCESS;
2747 }
2748
2749 return vos_Status;
2750}
2751
2752VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2753{
2754 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2755
2756 if (NULL == pHddCtx)
2757 {
2758 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "HDD context NULL");
2759 return VOS_STATUS_E_FAULT;
2760 }
2761
2762 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2763 {
2764 //Execute standby procedure.
2765 //Executing standby procedure will cause the STA to
2766 //disassociate first and then the chip will be put into standby.
2767 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2768 vos_Status = hdd_enter_standby(pHddCtx);
2769 }
2770 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2771 pHddCtx->cfg_ini->nEnableDriverStop)
2772 {
2773 //Execute deep sleep procedure
2774 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002775 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 //Deep sleep not supported
2777 vos_Status = hdd_enter_standby(pHddCtx);
2778 }
2779 else
2780 {
2781 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2782 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2783 vos_Status = VOS_STATUS_SUCCESS;
2784 }
2785
2786 return vos_Status;
2787}
2788
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002789
2790void* wlan_hdd_change_country_code_callback(void *pAdapter)
2791{
2792
2793 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002794 complete(&call_back_pAdapter->change_country_code);
2795
2796 return NULL;
2797}
2798
Jeff Johnson295189b2012-06-20 16:38:30 -07002799static int iw_set_priv(struct net_device *dev,
2800 struct iw_request_info *info,
2801 union iwreq_data *wrqu, char *extra)
2802{
2803 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002804 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 int cmd_len = wrqu->data.length;
2806 int ret = 0;
2807 int status = 0;
2808 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2809
2810 ENTER();
2811
2812 if (ioctl_debug)
2813 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002814 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 }
2816
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002817 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2818 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002819
2820 if (pHddCtx->isLogpInProgress) {
2821 if (ioctl_debug)
2822 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002823 pr_info("%s: RESTART in progress\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 }
2825
2826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2827 "%s:LOGP in Progress. Ignore!!!",__func__);
2828 return status;
2829 }
2830
2831 if(strncmp(cmd, "CSCAN",5) == 0 )
2832 {
2833 status = iw_set_cscan(dev, info, wrqu, extra);
2834 }
2835 else if( strcasecmp(cmd, "start") == 0 ) {
2836
Arif Hussain6d2a3322013-11-17 19:50:10 -08002837 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
2839 status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
2840
2841 if(status == VOS_STATUS_SUCCESS)
2842 {
2843 union iwreq_data wrqu;
2844 char buf[10];
2845
2846 memset(&wrqu, 0, sizeof(wrqu));
2847 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
2848 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2849 }
2850 else
2851 {
2852 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: START CMD Status %d", __func__, status);
2853 }
2854 goto done;
2855 }
2856 else if( strcasecmp(cmd, "stop") == 0 )
2857 {
2858 union iwreq_data wrqu;
2859 char buf[10];
2860
Arif Hussain6d2a3322013-11-17 19:50:10 -08002861 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07002862
2863 wlan_hdd_enter_lowpower(pHddCtx);
2864 memset(&wrqu, 0, sizeof(wrqu));
2865 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
2866 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2867 status = VOS_STATUS_SUCCESS;
2868 goto done;
2869 }
2870 else if (strcasecmp(cmd, "macaddr") == 0)
2871 {
2872 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
2873 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
2874 }
2875 else if (strcasecmp(cmd, "scan-active") == 0)
2876 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002877 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 ret = snprintf(cmd, cmd_len, "OK");
2879 }
2880 else if (strcasecmp(cmd, "scan-passive") == 0)
2881 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002882 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 ret = snprintf(cmd, cmd_len, "OK");
2884 }
2885 else if( strcasecmp(cmd, "scan-mode") == 0 )
2886 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002887 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 }
2889 else if( strcasecmp(cmd, "linkspeed") == 0 )
2890 {
2891 status = iw_get_linkspeed(dev, info, wrqu, extra);
2892 }
2893 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
2894 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002895 long lrc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002896
2897 country_code = cmd + 8;
2898
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002899 init_completion(&pAdapter->change_country_code);
2900
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002902 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 country_code,
2904 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05302905 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05302906 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05302907 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002908
2909 /* Wait for completion */
2910 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
2911 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2912
2913 if (lrc <= 0)
2914 {
2915 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002916 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002917 }
2918
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 if( 0 != status )
2920 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002921 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002922 "%s: SME Change Country code fail",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002923 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 }
2925 }
2926 else if( strncasecmp(cmd, "rssi", 4) == 0 )
2927 {
2928 status = iw_get_rssi(dev, info, wrqu, extra);
2929 }
2930 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
2931 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07002932 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002933
Wilson Yang1be3e652013-10-09 15:18:31 -07002934 if (9 < cmd_len)
2935 {
2936 ptr = (char*)(cmd + 9);
2937
2938 }else{
2939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2940 "CMD LENGTH %d is not correct",cmd_len);
2941 return VOS_STATUS_E_FAILURE;
2942 }
2943
2944 if (1 != sscanf(ptr,"%d",&mode))
2945 {
2946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2947 "powermode input %s is not correct",ptr);
2948 return VOS_STATUS_E_FAILURE;
2949 }
2950
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 wlan_hdd_enter_bmps(pAdapter, mode);
2952 /*TODO:Set the power mode*/
2953 }
2954 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
2955 v_U32_t pmc_state;
2956 v_U16_t value;
2957
2958 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
2959 if(pmc_state == BMPS) {
2960 value = DRIVER_POWER_MODE_AUTO;
2961 }
2962 else {
2963 value = DRIVER_POWER_MODE_ACTIVE;
2964 }
2965 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
2966 }
2967 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002968 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 /*TODO: set the btcoexmode*/
2970 }
2971 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
2972
Arif Hussain6d2a3322013-11-17 19:50:10 -08002973 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 /*TODO: Return the btcoex status*/
2975 }
2976 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
2977
Arif Hussain6d2a3322013-11-17 19:50:10 -08002978 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07002979
2980 /*TODO: Enable Rx data Filter*/
2981 }
2982 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
2983
Arif Hussain6d2a3322013-11-17 19:50:10 -08002984 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07002985
2986 /*TODO: Disable Rx data Filter*/
2987 }
2988 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
2989
Arif Hussain6d2a3322013-11-17 19:50:10 -08002990 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 /*TODO: rxfilter-statistics*/
2992 }
2993 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
2994
Arif Hussain6d2a3322013-11-17 19:50:10 -08002995 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 /*TODO: rxfilter-add*/
2997 }
2998 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
2999
Arif Hussain6d2a3322013-11-17 19:50:10 -08003000 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 /*TODO: rxfilter-remove*/
3002 }
3003#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003004 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3005 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3006 /*TODO: support pnosetup*/
3007 }
3008 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3009 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3010 /*TODO: support pnoforce*/
3011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3013
Arif Hussain6d2a3322013-11-17 19:50:10 -08003014 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 status = iw_set_pno(dev, info, wrqu, extra, 3);
3016 return status;
3017 }
3018 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
3019
Arif Hussain6d2a3322013-11-17 19:50:10 -08003020 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 status = iw_set_rssi_filter(dev, info, wrqu, extra, 10);
3022 return status;
3023 }
3024#endif /*FEATURE_WLAN_SCAN_PNO*/
3025 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003026 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 status = iw_set_power_params(dev, info, wrqu, extra, 11);
3028 return status;
3029 }
3030 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3031 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003032 char *ptr;
3033
3034 if (18 < cmd_len)
3035 {
3036 ptr = (char*)(cmd + 18);
3037 }else{
3038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3039 "CMD LENGTH %d is not correct",cmd_len);
3040 return VOS_STATUS_E_FAILURE;
3041 }
3042
Jeff Johnson02797792013-10-26 19:17:13 -07003043 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003044 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3045 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3046 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3047 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3048 {
3049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3050 "CONFIG-TX-TRACKING %s input is not correct",ptr);
3051 return VOS_STATUS_E_FAILURE;
3052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003053
3054 // parameters checking
3055 // period has to be larger than 0
3056 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3057 {
3058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
3059 return VOS_STATUS_E_FAILURE;
3060 }
3061
3062 // use default value 5 is the input is not reasonable. in unit of 10%
3063 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3064 {
3065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3066 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3067 }
3068
3069 // default is 5
3070 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3071 {
3072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3073 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3074 }
3075
3076 status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam);
3077 if(status != eHAL_STATUS_SUCCESS){
3078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
3079 }
3080 }
3081 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003082 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3083 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 }
3085done:
3086 /* many of the commands write information back into the command
3087 string using snprintf(). check the return value here in one
3088 place */
3089 if ((ret < 0) || (ret >= cmd_len))
3090 {
3091 /* there was an encoding error or overflow */
3092 status = -EIO;
3093 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003094 else if (ret > 0)
3095 {
3096 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3097 {
3098 hddLog(VOS_TRACE_LEVEL_ERROR,
3099 "%s: failed to copy data to user buffer", __func__);
3100 return -EFAULT;
3101 }
3102 wrqu->data.length = ret;
3103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003104
3105 if (ioctl_debug)
3106 {
3107 pr_info("%s: rsp [%s] len [%d] status %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003108 __func__, cmd, wrqu->data.length, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 }
3110 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003111}
3112
3113static int iw_set_nick(struct net_device *dev,
3114 struct iw_request_info *info,
3115 union iwreq_data *wrqu, char *extra)
3116{
3117 ENTER();
3118 return 0;
3119}
3120
3121static int iw_get_nick(struct net_device *dev,
3122 struct iw_request_info *info,
3123 union iwreq_data *wrqu, char *extra)
3124{
3125 ENTER();
3126 return 0;
3127}
3128
3129static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3130{
3131 ENTER();
3132 return NULL;
3133}
3134
3135static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3136 union iwreq_data *wrqu,char *extra)
3137
3138{
3139 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3140 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3141 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3142 struct iw_point *encoderq = &(wrqu->encoding);
3143 v_U32_t keyId;
3144 v_U8_t key_length;
3145 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3146 v_BOOL_t fKeyPresent = 0;
3147 int i;
3148 eHalStatus status = eHAL_STATUS_SUCCESS;
3149
3150
3151 ENTER();
3152
3153 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3154 {
3155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3156 "%s:LOGP in Progress. Ignore!!!",__func__);
3157 return 0;
3158 }
3159
3160
3161 keyId = encoderq->flags & IW_ENCODE_INDEX;
3162
3163 if(keyId)
3164 {
3165 if(keyId > MAX_WEP_KEYS)
3166 {
3167 return -EINVAL;
3168 }
3169
3170 fKeyPresent = 1;
3171 keyId--;
3172 }
3173 else
3174 {
3175 fKeyPresent = 0;
3176 }
3177
3178
3179 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3180 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 if(!fKeyPresent) {
3183
3184 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3185
3186 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3187 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3188 }
3189 }
3190 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3191 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3192 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3193 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3194
3195 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3196 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3197
3198 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3199 {
3200 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3201 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003202 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3204 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3205 }
3206
3207 return status;
3208
3209 }
3210
3211 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3212 {
3213 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3214
3215 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3216
3217 }
3218
3219
3220 if(wrqu->data.length > 0)
3221 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003222 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003223
3224 key_length = wrqu->data.length;
3225
3226 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3227
3228 if(5 == key_length)
3229 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003230 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003231
3232 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3233 {
3234 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3235 }
3236 else
3237 {
3238 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3239 }
3240 }
3241 else if(13 == key_length)
3242 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003243 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003244
3245 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3246 {
3247 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3248 }
3249 else
3250 {
3251 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3252 }
3253 }
3254 else
3255 {
3256 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003257 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 return -EINVAL;
3259 }
3260
3261 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3262 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3263 pWextState->roamProfile.EncryptionType.numEntries = 1;
3264 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3265 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3266 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3267
3268 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3269 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3270 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3271 {
3272
3273 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3274
3275 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3276 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3277
3278 return status;
3279 }
3280 }
3281
3282 return 0;
3283}
3284
3285static int iw_get_encodeext(struct net_device *dev,
3286 struct iw_request_info *info,
3287 struct iw_point *dwrq,
3288 char *extra)
3289{
3290 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3291 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3292 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3293 int keyId;
3294 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3295 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3296 int i;
3297
3298 ENTER();
3299
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003300 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3301 {
3302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3303 "%s:LOGP in Progress. Ignore!!!", __func__);
3304 return -EBUSY;
3305 }
3306
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 keyId = pRoamProfile->Keys.defaultIndex;
3308
3309 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3310 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003311 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 return -EINVAL;
3313 }
3314
3315 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3316 {
3317 dwrq->flags |= IW_ENCODE_ENABLED;
3318 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303319 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3320 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 }
3322 else
3323 {
3324 dwrq->flags |= IW_ENCODE_DISABLED;
3325 }
3326
3327 for(i=0; i < MAX_WEP_KEYS; i++)
3328 {
3329 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3330 {
3331 continue;
3332 }
3333 else
3334 {
3335 break;
3336 }
3337 }
3338
3339 if(MAX_WEP_KEYS == i)
3340 {
3341 dwrq->flags |= IW_ENCODE_NOKEY;
3342 }
3343 else
3344 {
3345 dwrq->flags |= IW_ENCODE_ENABLED;
3346 }
3347
3348 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3349
3350 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3351 {
3352 dwrq->flags |= IW_ENCODE_DISABLED;
3353 }
3354
3355 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3356
3357 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3358 {
3359 dwrq->flags |= IW_ENCODE_OPEN;
3360 }
3361 else
3362 {
3363 dwrq->flags |= IW_ENCODE_RESTRICTED;
3364 }
3365 EXIT();
3366 return 0;
3367
3368}
3369
3370static int iw_set_encodeext(struct net_device *dev,
3371 struct iw_request_info *info,
3372 union iwreq_data *wrqu, char *extra)
3373{
3374 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3375 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3376 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3377 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3378
3379 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3380 v_U32_t status = 0;
3381
3382 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3383
3384 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3385
3386 int key_index;
3387 struct iw_point *encoding = &wrqu->encoding;
3388 tCsrRoamSetKey setKey;
3389 v_U32_t roamId= 0xFF;
3390 VOS_STATUS vos_status;
3391
3392 ENTER();
3393
3394 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3395 {
3396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3397 "%s:LOGP in Progress. Ignore!!!",__func__);
3398 return 0;
3399 }
3400
3401 key_index = encoding->flags & IW_ENCODE_INDEX;
3402
3403 if(key_index > 0) {
3404
3405 /*Convert from 1-based to 0-based keying*/
3406 key_index--;
3407 }
3408 if(!ext->key_len) {
3409
3410 /*Set the encrytion type to NONE*/
3411 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3412 return status;
3413 }
3414
3415 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3416 (IW_ENCODE_ALG_WEP == ext->alg))
3417 {
3418 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3419
Arif Hussain6d2a3322013-11-17 19:50:10 -08003420 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 return -EINVAL;
3422 }
3423 else {
3424 /*Static wep, update the roam profile with the keys */
3425 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3426 key_index < CSR_MAX_NUM_KEY) {
3427 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3428 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3429
3430 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3431 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3432
3433 }
3434 }
3435 return status;
3436 }
3437
3438 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3439
3440 setKey.keyId = key_index;
3441 setKey.keyLength = ext->key_len;
3442
3443 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3444 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3445 }
3446
3447 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3448 /*Key direction for group is RX only*/
3449 setKey.keyDirection = eSIR_RX_ONLY;
3450 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3451 }
3452 else {
3453
3454 setKey.keyDirection = eSIR_TX_RX;
3455 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3456 }
3457
3458 /*For supplicant pae role is zero*/
3459 setKey.paeRole = 0;
3460
3461 switch(ext->alg)
3462 {
3463 case IW_ENCODE_ALG_NONE:
3464 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3465 break;
3466
3467 case IW_ENCODE_ALG_WEP:
3468 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3469 break;
3470
3471 case IW_ENCODE_ALG_TKIP:
3472 {
3473 v_U8_t *pKey = &setKey.Key[0];
3474
3475 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3476
3477 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3478
3479 /*Supplicant sends the 32bytes key in this order
3480
3481 |--------------|----------|----------|
3482 | Tk1 |TX-MIC | RX Mic |
3483 |--------------|----------|----------|
3484 <---16bytes---><--8bytes--><--8bytes-->
3485
3486 */
3487 /*Sme expects the 32 bytes key to be in the below order
3488
3489 |--------------|----------|----------|
3490 | Tk1 |RX-MIC | TX Mic |
3491 |--------------|----------|----------|
3492 <---16bytes---><--8bytes--><--8bytes-->
3493 */
3494 /* Copy the Temporal Key 1 (TK1) */
3495 vos_mem_copy(pKey,ext->key,16);
3496
3497 /*Copy the rx mic first*/
3498 vos_mem_copy(&pKey[16],&ext->key[24],8);
3499
3500 /*Copy the tx mic */
3501 vos_mem_copy(&pKey[24],&ext->key[16],8);
3502
3503 }
3504 break;
3505
3506 case IW_ENCODE_ALG_CCMP:
3507 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3508 break;
3509
3510#ifdef FEATURE_WLAN_CCX
3511#define IW_ENCODE_ALG_KRK 6
3512 case IW_ENCODE_ALG_KRK:
3513 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3514 break;
3515#endif /* FEATURE_WLAN_CCX */
3516
3517 default:
3518 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3519 break;
3520 }
3521
3522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003523 ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d"),__func__,(int)ext->alg,(int)ext->key_len,setKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003524
3525#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303526 /* The supplicant may attempt to set the PTK once pre-authentication
3527 is done. Save the key in the UMAC and include it in the ADD
3528 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303530 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303532 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3533 "%s: Update PreAuth Key success", __func__);
3534 return 0;
3535 }
3536 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3537 {
3538 hddLog(VOS_TRACE_LEVEL_ERROR,
3539 "%s: Update PreAuth Key failed", __func__);
3540 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 }
3542#endif /* WLAN_FEATURE_VOWIFI_11R */
3543
3544 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3545
3546 vos_status = wlan_hdd_check_ula_done(pAdapter);
3547 if ( vos_status != VOS_STATUS_SUCCESS )
3548 {
3549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3550 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3551 __LINE__, vos_status );
3552
3553 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3554 }
3555
3556 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3557
3558 if ( halStatus != eHAL_STATUS_SUCCESS )
3559 {
3560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3561 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3562 __LINE__, halStatus );
3563
3564 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3565 }
3566
3567 return halStatus;
3568}
3569
3570static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3571 union iwreq_data *wrqu, char *extra)
3572{
3573 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3574 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3575
3576 ENTER();
3577
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003578 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3579 {
3580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3581 "%s:LOGP in Progress. Ignore!!!", __func__);
3582 return -EBUSY;
3583 }
3584
Jeff Johnson295189b2012-06-20 16:38:30 -07003585 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3586 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3587
Arif Hussain6d2a3322013-11-17 19:50:10 -08003588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003589
3590 return -EINVAL;
3591 }
3592
3593 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3594
3595 if((wrqu->retry.flags & IW_RETRY_LONG))
3596 {
3597 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3598 {
3599 return -EIO;
3600 }
3601 }
3602 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3603 {
3604 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3605 {
3606 return -EIO;
3607 }
3608 }
3609 }
3610 else
3611 {
3612 return -EOPNOTSUPP;
3613 }
3614
Arif Hussain6d2a3322013-11-17 19:50:10 -08003615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003616
3617 EXIT();
3618
3619 return 0;
3620
3621}
3622
3623static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3624 union iwreq_data *wrqu, char *extra)
3625{
3626 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3627 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3628 v_U32_t retry = 0;
3629
3630 ENTER();
3631
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003632 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3633 {
3634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3635 "%s:LOGP in Progress. Ignore!!!", __func__);
3636 return -EBUSY;
3637 }
3638
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 if((wrqu->retry.flags & IW_RETRY_LONG))
3640 {
3641 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3642
3643 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3644 {
3645 return -EIO;
3646 }
3647
3648 wrqu->retry.value = retry;
3649 }
3650 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3651 {
3652 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3653
3654 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3655 {
3656 return -EIO;
3657 }
3658
3659 wrqu->retry.value = retry;
3660 }
3661 else {
3662 return -EOPNOTSUPP;
3663 }
3664
Arif Hussain6d2a3322013-11-17 19:50:10 -08003665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003666
3667 EXIT();
3668
3669 return 0;
3670}
3671
3672static int iw_set_mlme(struct net_device *dev,
3673 struct iw_request_info *info,
3674 union iwreq_data *wrqu,
3675 char *extra)
3676{
3677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3678 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3679 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3680 eHalStatus status = eHAL_STATUS_SUCCESS;
3681
3682 ENTER();
3683
3684 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3685 {
3686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3687 "%s:LOGP in Progress. Ignore!!!",__func__);
3688 return 0;
3689 }
3690
3691 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3692 switch (mlme->cmd) {
3693 case IW_MLME_DISASSOC:
3694 case IW_MLME_DEAUTH:
3695
3696 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3697 {
3698 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3699
3700 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3701 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3702
3703 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3704 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3705
Jeff Johnson43971f52012-07-17 12:26:56 -07003706 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3708 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3709 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003710 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003711 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003712
3713 /* Resetting authKeyMgmt */
3714 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3715
3716 netif_tx_disable(dev);
3717 netif_carrier_off(dev);
3718
3719 }
3720 else
3721 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003722 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 }
3724 break;
3725 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003726 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 return -EINVAL;
3728 }//end of switch
3729
3730 EXIT();
3731
3732 return status;
3733
3734}
3735
3736/* set param sub-ioctls */
3737static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3738 union iwreq_data *wrqu, char *extra)
3739{
3740 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3741 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3742 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3743 int *value = (int *)extra;
3744 int sub_cmd = value[0];
3745 int set_value = value[1];
3746 int ret = 0; /* success */
3747 int enable_pbm, enable_mp;
3748#ifdef CONFIG_HAS_EARLYSUSPEND
3749 v_U8_t nEnableSuspendOld;
3750#endif
3751 INIT_COMPLETION(pWextState->completion_var);
3752
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003753 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3754 {
3755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3756 "%s:LOGP in Progress. Ignore!!!", __func__);
3757 return -EBUSY;
3758 }
3759
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 switch(sub_cmd)
3761 {
3762 case WE_SET_11D_STATE:
3763 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003764 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07003765 memset(&smeConfig, 0x00, sizeof(smeConfig));
3766
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3768
3769 sme_GetConfigParam(hHal,&smeConfig);
3770 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3771
Arif Hussain6d2a3322013-11-17 19:50:10 -08003772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07003773
3774 sme_UpdateConfig(hHal,&smeConfig);
3775 }
3776 else {
3777 return -EINVAL;
3778 }
3779 break;
3780 }
3781
3782 case WE_WOWL:
3783 {
3784 switch (set_value)
3785 {
3786 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003787 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 break;
3789 case 0x01:
3790 case 0x02:
3791 case 0x03:
3792 enable_mp = (set_value & 0x01) ? 1 : 0;
3793 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003794 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3796 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3797 break;
3798 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003799 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 ret = -EINVAL;
3801 break;
3802 }
3803
3804 break;
3805 }
3806 case WE_SET_POWER:
3807 {
3808 switch (set_value)
3809 {
3810 case 0: //Full Power
3811 {
3812 struct statsContext context;
3813 eHalStatus status;
3814
3815 init_completion(&context.completion);
3816
3817 context.pAdapter = pAdapter;
3818 context.magic = POWER_CONTEXT_MAGIC;
3819
3820 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3821 iw_power_callback_fn, &context,
3822 eSME_FULL_PWR_NEEDED_BY_HDD);
3823 if(eHAL_STATUS_PMC_PENDING == status)
3824 {
3825 int lrc = wait_for_completion_interruptible_timeout(
3826 &context.completion,
3827 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3828 context.magic = 0;
3829 if (lrc <= 0)
3830 {
3831 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3832 "requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003833 __func__, (0 == lrc) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 "timeout" : "interrupt");
3835 /* there is a race condition such that the callback
3836 function could be executing at the same time we are. of
3837 primary concern is if the callback function had already
3838 verified the "magic" but hasn't yet set the completion
3839 variable. Since the completion variable is on our
3840 stack, we'll delay just a bit to make sure the data is
3841 still valid if that is the case */
3842 msleep(50);
3843 /* we'll now returned a cached value below */
3844 }
3845 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003846 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 break;
3848 }
3849 case 1: //Enable BMPS
3850 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3851 break;
3852 case 2: //Disable BMPS
3853 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3854 break;
3855 case 3: //Request Bmps
3856 {
3857 struct statsContext context;
3858 eHalStatus status;
3859
3860 init_completion(&context.completion);
3861
3862 context.pAdapter = pAdapter;
3863 context.magic = POWER_CONTEXT_MAGIC;
3864
3865 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3866 iw_power_callback_fn, &context);
3867 if(eHAL_STATUS_PMC_PENDING == status)
3868 {
3869 int lrc = wait_for_completion_interruptible_timeout(
3870 &context.completion,
3871 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3872 context.magic = 0;
3873 if (lrc <= 0)
3874 {
3875 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3876 "requesting BMPS",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003877 __func__, (0 == lrc) ? "timeout" :
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 "interrupt");
3879 /* there is a race condition such that the callback
3880 function could be executing at the same time we are. of
3881 primary concern is if the callback function had already
3882 verified the "magic" but hasn't yet set the completion
3883 variable. Since the completion variable is on our
3884 stack, we'll delay just a bit to make sure the data is
3885 still valid if that is the case */
3886 msleep(50);
3887 /* we'll now returned a cached value below */
3888 }
3889 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003890 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 break;
3892 }
3893 case 4: //Enable IMPS
3894 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3895 break;
3896 case 5: //Disable IMPS
3897 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3898 break;
3899 case 6: //Enable Standby
3900 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3901 break;
3902 case 7: //Disable Standby
3903 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3904 break;
3905 case 8: //Request Standby
3906#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003907#endif
3908 break;
3909 case 9: //Start Auto Bmps Timer
3910 sme_StartAutoBmpsTimer(hHal);
3911 break;
3912 case 10://Stop Auto BMPS Timer
3913 sme_StopAutoBmpsTimer(hHal);
3914 break;
3915#ifdef CONFIG_HAS_EARLYSUSPEND
3916 case 11://suspend to standby
3917#ifdef CONFIG_HAS_EARLYSUSPEND
3918 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3919 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3921#endif
3922 break;
3923 case 12://suspend to deep sleep
3924#ifdef CONFIG_HAS_EARLYSUSPEND
3925 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3926 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3928#endif
3929 break;
3930 case 13://resume from suspend
3931#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003932#endif
3933 break;
3934#endif
3935 case 14://reset wlan (power down/power up)
3936 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
3937 break;
3938 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003939 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 ret = -EINVAL;
3941 break;
3942 }
3943 break;
3944 }
3945
3946 case WE_SET_MAX_ASSOC:
3947 {
3948 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
3949 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
3950 {
3951 ret = -EINVAL;
3952 }
3953 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
3954 set_value, NULL, eANI_BOOLEAN_FALSE)
3955 != eHAL_STATUS_SUCCESS )
3956 {
3957 ret = -EIO;
3958 }
3959 break;
3960 }
3961
3962 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
3963 {
3964 if( 0 == set_value )
3965 {
3966 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
3967 }
3968 else if ( 1 == set_value )
3969 {
3970 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
3971 }
3972 else
3973 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003974 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 ret = -EINVAL;
3976 }
3977 break;
3978 }
3979
3980 case WE_SET_DATA_INACTIVITY_TO:
3981 {
3982 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
3983 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
3984 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
3985 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
3986 set_value,
3987 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
3988 {
3989 hddLog(LOGE,"Failure: Could not pass on "
3990 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003991 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 ret = -EINVAL;
3993 }
3994 break;
3995 }
3996 case WE_SET_MAX_TX_POWER:
3997 {
3998 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3999 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4000
4001 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4002 __func__, set_value);
4003 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4004 eHAL_STATUS_SUCCESS )
4005 {
4006 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4007 __func__);
4008 return -EIO;
4009 }
4010
4011 break;
4012 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004013 case WE_SET_MAX_TX_POWER_2_4:
4014 {
4015 hddLog(VOS_TRACE_LEVEL_INFO,
4016 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4017 __func__, set_value);
4018 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4019 eHAL_STATUS_SUCCESS)
4020 {
4021 hddLog(VOS_TRACE_LEVEL_ERROR,
4022 "%s: Setting maximum tx power failed for 2.4 GHz band",
4023 __func__);
4024 return -EIO;
4025 }
4026
4027 break;
4028 }
4029 case WE_SET_MAX_TX_POWER_5_0:
4030 {
4031 hddLog(VOS_TRACE_LEVEL_INFO,
4032 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4033 __func__, set_value);
4034 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4035 eHAL_STATUS_SUCCESS)
4036 {
4037 hddLog(VOS_TRACE_LEVEL_ERROR,
4038 "%s: Setting maximum tx power failed for 5.0 GHz band",
4039 __func__);
4040 return -EIO;
4041 }
4042
4043 break;
4044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 case WE_SET_HIGHER_DTIM_TRANSITION:
4046 {
4047 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4048 (set_value == eANI_BOOLEAN_TRUE)))
4049 {
4050 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4051 ret = -EINVAL;
4052 }
4053 else
4054 {
4055 if(pAdapter->higherDtimTransition != set_value)
4056 {
4057 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004058 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 }
4060 }
4061
4062 break;
4063 }
4064
4065 case WE_SET_TM_LEVEL:
4066 {
4067 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4068 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
4069 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4070
4071 break;
4072 }
4073
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304074 case WE_ENABLE_STRICT_FCC_REG:
4075 {
4076 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4077 struct wiphy *wiphy = NULL;
4078 long lrc;
4079 int status;
4080
4081 wiphy = hddCtxt->wiphy;
4082 if(wiphy == NULL)
4083 {
4084 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4085 break;
4086 }
4087 init_completion(&hddCtxt->wiphy_channel_update_event);
4088
4089 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4090
4091 status = regulatory_hint(wiphy, "00");
4092 if(status < 0)
4093 {
4094 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4095 break;
4096 }
4097
4098 /* Wait for completion */
4099 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4100 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4101 if (lrc <= 0)
4102 {
4103 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4104 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4105 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4106 }
4107 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4108
4109 break;
4110 }
4111
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 default:
4113 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004114 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 sub_cmd, set_value);
4116 break;
4117 }
4118 }
4119
4120 return ret;
4121}
4122
4123/* set param sub-ioctls */
4124static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4125 union iwreq_data *wrqu, char *extra)
4126{
4127 VOS_STATUS vstatus;
4128 int sub_cmd = wrqu->data.flags;
4129 int ret = 0; /* success */
4130 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4131 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4132#ifdef WLAN_FEATURE_VOWIFI
4133 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4134#endif /* WLAN_FEATURE_VOWIFI */
4135
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received length %d", __func__, wrqu->data.length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received data %s", __func__, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004138
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004139 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4140 {
4141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4142 "%s:LOGP in Progress. Ignore!!!", __func__);
4143 return -EBUSY;
4144 }
4145
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 switch(sub_cmd)
4147 {
4148 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain7adce1b2013-11-11 22:59:34 -08004150 hdd_add_wowl_ptrn(pAdapter, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 break;
4152 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain7adce1b2013-11-11 22:59:34 -08004154 hdd_del_wowl_ptrn(pAdapter, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 break;
4156#if defined WLAN_FEATURE_VOWIFI
4157 case WE_NEIGHBOR_REPORT_REQUEST:
4158 {
4159 tRrmNeighborReq neighborReq;
4160 tRrmNeighborRspCallbackInfo callbackInfo;
4161
4162 if (pConfig->fRrmEnable)
4163 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4166 if( !neighborReq.no_ssid )
4167 {
4168 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain7adce1b2013-11-11 22:59:34 -08004169 vos_mem_copy( neighborReq.ssid.ssId, extra, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 }
4171
4172 callbackInfo.neighborRspCallback = NULL;
4173 callbackInfo.neighborRspCallbackContext = NULL;
4174 callbackInfo.timeout = 5000; //5 seconds
4175 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4176 }
4177 else
4178 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004179 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 ret = -EINVAL;
4181 }
4182 }
4183 break;
4184#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 case WE_SET_AP_WPS_IE:
4186 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain7adce1b2013-11-11 22:59:34 -08004187 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), extra, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 case WE_SET_CONFIG:
Arif Hussain7adce1b2013-11-11 22:59:34 -08004190 vstatus = hdd_execute_config_command(pHddCtx, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 if (VOS_STATUS_SUCCESS != vstatus)
4192 {
4193 ret = -EINVAL;
4194 }
4195 break;
4196 default:
4197 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004198 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 ret = -EINVAL;
4200 break;
4201 }
4202 }
4203 return ret;
4204}
4205
4206/* get param sub-ioctls */
4207static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4208 union iwreq_data *wrqu, char *extra)
4209{
4210 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4211 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4212 int *value = (int *)extra;
4213 int ret = 0; /* success */
4214
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004215 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4216 {
4217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4218 "%s:LOGP in Progress. Ignore!!!", __func__);
4219 return -EBUSY;
4220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004221
4222 switch (value[0])
4223 {
4224 case WE_GET_11D_STATE:
4225 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004226 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304228
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4230
Arif Hussain6d2a3322013-11-17 19:50:10 -08004231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004232
4233 break;
4234 }
4235
4236 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 break;
4239
4240 case WE_PMC_STATE:
4241 {
4242 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 break;
4245 }
4246 case WE_GET_WLAN_DBG:
4247 {
4248 vos_trace_display();
4249 *value = 0;
4250 break;
4251 }
4252 case WE_MODULE_DOWN_IND:
4253 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4256#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4259#endif
4260 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4261
4262 *value = 0;
4263 break;
4264 }
4265 case WE_GET_MAX_ASSOC:
4266 {
4267 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4268 {
4269 ret = -EIO;
4270 }
4271 break;
4272 }
4273
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 case WE_GET_WDI_DBG:
4275 {
4276 wpalTraceDisplay();
4277 *value = 0;
4278 break;
4279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004280
4281 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4282 {
4283 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4284 break;
4285 }
4286 case WE_GET_CONCURRENCY_MODE:
4287 {
4288 *value = hdd_get_concurrency_mode ( );
4289
Arif Hussain6d2a3322013-11-17 19:50:10 -08004290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 break;
4292 }
4293
4294 default:
4295 {
4296 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4297 break;
4298 }
4299 }
4300
4301 return ret;
4302}
4303
4304/* set param sub-ioctls */
4305int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4306 union iwreq_data *wrqu, char *extra)
4307{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004308 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 int *value = (int *)extra;
4310 int sub_cmd = value[0];
4311 int ret = 0;
4312
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004313 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4314 {
4315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4316 "%s:LOGP in Progress. Ignore!!!", __func__);
4317 return -EBUSY;
4318 }
4319
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 switch(sub_cmd)
4321 {
4322 case WE_SET_WLAN_DBG:
4323 {
4324 vos_trace_setValue( value[1], value[2], value[3]);
4325 break;
4326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 case WE_SET_WDI_DBG:
4328 {
4329 wpalTraceSetLevel( value[1], value[2], value[3]);
4330 break;
4331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 case WE_SET_SAP_CHANNELS:
4333 {
4334 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4335 break;
4336 }
4337
4338 default:
4339 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004340 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 break;
4342 }
4343 }
4344 return ret;
4345}
4346
4347static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4348 union iwreq_data *wrqu, char *extra)
4349{
4350 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4351 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004352#ifdef WLAN_FEATURE_11W
4353 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4354#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004355
Yue Ma3ede6052013-08-29 00:33:26 -07004356 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4357 {
4358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4359 "%s: HDD Context is NULL!", __func__);
4360
4361 return -EINVAL;
4362 }
4363
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004364 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4365 {
4366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4367 "%s:LOGP in Progress. Ignore!!!", __func__);
4368 return -EBUSY;
4369 }
4370
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 switch(sub_cmd)
4372 {
4373 case WE_WLAN_VERSION:
4374 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004375 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 break;
4377 }
4378
4379 case WE_GET_STATS:
4380 {
4381 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4382 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4383 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4384
4385 snprintf(extra, WE_MAX_STR_LEN,
4386 "\nTransmit"
4387 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4388 "\n dropped BK %u, BE %u, VI %u, VO %u"
4389 "\n classified BK %u, BE %u, VI %u, VO %u"
4390 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4391 "\n queued BK %u, BE %u, VI %u, VO %u"
4392 "\nfetched %u, empty %u, lowres %u, deqerr %u"
4393 "\ndequeued %u, depressured %u, completed %u, flushed %u"
4394 "\n fetched BK %u, BE %u, VI %u, VO %u"
4395 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4396 "\n depressured BK %u, BE %u, VI %u, VO %u"
4397 "\n flushed BK %u, BE %u, VI %u, VO %u"
4398 "\n\nReceive"
4399 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4400 "\n\nResetsStats"
4401 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4402 "\n",
4403 pStats->txXmitCalled,
4404 pStats->txXmitDropped,
4405 pStats->txXmitBackPressured,
4406 pStats->txXmitQueued,
4407
4408 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4409 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4410 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4411 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4412
4413 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4414 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4415 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4416 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4417
4418 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4419 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4420 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4421 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4422
4423 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4424 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4425 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4426 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4427
4428 pStats->txFetched,
4429 pStats->txFetchEmpty,
4430 pStats->txFetchLowResources,
4431 pStats->txFetchDequeueError,
4432
4433 pStats->txFetchDequeued,
4434 pStats->txFetchDePressured,
4435 pStats->txCompleted,
4436 pStats->txFlushed,
4437
4438 pStats->txFetchedAC[WLANTL_AC_BK],
4439 pStats->txFetchedAC[WLANTL_AC_BE],
4440 pStats->txFetchedAC[WLANTL_AC_VI],
4441 pStats->txFetchedAC[WLANTL_AC_VO],
4442
4443 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4444 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4445 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4446 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4447
4448 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4449 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4450 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4451 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4452
4453 pStats->txFlushedAC[WLANTL_AC_BK],
4454 pStats->txFlushedAC[WLANTL_AC_BE],
4455 pStats->txFlushedAC[WLANTL_AC_VI],
4456 pStats->txFlushedAC[WLANTL_AC_VO],
4457
4458 pStats->rxChains,
4459 pStats->rxPackets,
4460 pStats->rxDropped,
4461 pStats->rxDelivered,
4462 pStats->rxRefused,
4463
4464 pResetStats->totalLogpResets,
4465 pResetStats->totalCMD53Failures,
4466 pResetStats->totalMutexReadFailures,
4467 pResetStats->totalMIFErrorFailures,
4468 pResetStats->totalFWHearbeatFailures,
4469 pResetStats->totalUnknownExceptions
4470 );
4471 wrqu->data.length = strlen(extra)+1;
4472 break;
4473 }
4474
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304475/* The case prints the current state of the HDD, SME, CSR, PE, TL
4476 *it can be extended for WDI Global State as well.
4477 *And currently it only checks P2P_CLIENT adapter.
4478 *P2P_DEVICE and P2P_GO have not been added as of now.
4479*/
4480 case WE_GET_STATES:
4481 {
4482 int buf = 0, len = 0;
4483 int adapter_num = 0;
4484 int count = 0, check = 1;
4485
4486 tANI_U16 tlState;
4487 tHalHandle hHal;
4488 tpAniSirGlobal pMac;
4489 hdd_station_ctx_t *pHddStaCtx;
4490
4491 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4492 hdd_adapter_t *useAdapter = NULL;
4493
4494 /* Print wlan0 or p2p0 states based on the adapter_num
4495 *by using the correct adapter
4496 */
4497 while ( adapter_num < 2 )
4498 {
4499 if ( WLAN_ADAPTER == adapter_num )
4500 {
4501 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004502 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304503 "\n\n wlan0 States:-");
4504 len += buf;
4505 }
4506 else if ( P2P_ADAPTER == adapter_num )
4507 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004508 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304509 "\n\n p2p0 States:-");
4510 len += buf;
4511
4512 if( !pHddCtx )
4513 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004514 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304515 "\n pHddCtx is NULL");
4516 len += buf;
4517 break;
4518 }
4519
4520 /*Printing p2p0 states only in the case when the device is
4521 configured as a p2p_client*/
4522 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4523 if ( !useAdapter )
4524 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004525 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304526 "\n Device not configured as P2P_CLIENT.");
4527 len += buf;
4528 break;
4529 }
4530 }
4531
4532 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
4533 pMac = PMAC_STRUCT( hHal );
4534 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4535 if( !pHddStaCtx )
4536 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004537 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304538 "\n pHddStaCtx is NULL");
4539 len += buf;
4540 break;
4541 }
4542
4543 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4544
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004545 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304546 "\n HDD Conn State - %s "
4547 "\n \n SME State:"
4548 "\n Neighbour Roam State - %s"
4549 "\n CSR State - %s"
4550 "\n CSR Substate - %s"
4551 "\n \n TL STA %d State: %s",
4552 macTraceGetHDDWlanConnState(
4553 pHddStaCtx->conn_info.connState),
4554 macTraceGetNeighbourRoamState(
4555 pMac->roam.neighborRoamInfo.neighborRoamState),
4556 macTraceGetcsrRoamState(
4557 pMac->roam.curState[useAdapter->sessionId]),
4558 macTraceGetcsrRoamSubState(
4559 pMac->roam.curSubState[useAdapter->sessionId]),
4560 pHddStaCtx->conn_info.staId[0],
4561 macTraceGetTLState(tlState)
4562 );
4563 len += buf;
4564 adapter_num++;
4565 }
4566
4567 /* Printing Lim State starting with global lim states */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004568 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304569 "\n \n LIM STATES:-"
4570 "\n Global Sme State - %s "\
4571 "\n Global mlm State - %s "\
4572 "\n",
4573 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4574 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4575 );
4576 len += buf;
4577
4578 /*printing the PE Sme and Mlm states for valid lim sessions*/
4579 while ( check < 3 && count < 255)
4580 {
4581 if ( pMac->lim.gpSession[count].valid )
4582 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004583 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304584 "\n Lim Valid Session %d:-"
4585 "\n PE Sme State - %s "
4586 "\n PE Mlm State - %s "
4587 "\n",
4588 check,
4589 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4590 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4591 );
4592
4593 len += buf;
4594 check++;
4595 }
4596 count++;
4597 }
4598
4599 wrqu->data.length = strlen(extra)+1;
4600 break;
4601 }
4602
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 case WE_GET_CFG:
4604 {
4605 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4606 wrqu->data.length = strlen(extra)+1;
4607 break;
4608 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004609#ifdef WLAN_FEATURE_11AC
4610 case WE_GET_RSSI:
4611 {
4612 v_S7_t s7Rssi = 0;
4613 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4614 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4615 wrqu->data.length = strlen(extra)+1;
4616 break;
4617 }
4618#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304619
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004620#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4621 case WE_GET_ROAM_RSSI:
4622 {
4623 v_S7_t s7Rssi = 0;
4624 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4625 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4626 wrqu->data.length = strlen(extra)+1;
4627 break;
4628 }
4629#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 case WE_GET_WMM_STATUS:
4631 {
4632 snprintf(extra, WE_MAX_STR_LEN,
4633 "\nDir: 0=up, 1=down, 3=both\n"
4634 "|------------------------|\n"
4635 "|AC | ACM |Admitted| Dir |\n"
4636 "|------------------------|\n"
4637 "|VO | %d | %3s | %d |\n"
4638 "|VI | %d | %3s | %d |\n"
4639 "|BE | %d | %3s | %d |\n"
4640 "|BK | %d | %3s | %d |\n"
4641 "|------------------------|\n",
4642 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4643 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4644 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4645 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4646 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4647 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4648 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4649 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4650 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4651 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4652 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4653 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4654
Jeff Johnsone7245742012-09-05 17:12:55 -07004655
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 wrqu->data.length = strlen(extra)+1;
4657 break;
4658 }
4659 case WE_GET_CHANNEL_LIST:
4660 {
4661 VOS_STATUS status;
4662 v_U8_t i, len;
4663 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004664
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 tChannelListInfo channel_list;
4666
4667 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
4668 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4669 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004670 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 return -EINVAL;
4672 }
4673 buf = extra;
4674
4675 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004676 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4677 * needed = 5 * number of channels. Check ifsufficient
4678 * buffer is available and then proceed to fill the buffer.
4679 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4681 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004682 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004683 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004684 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 return -EINVAL;
4686 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004687 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4688 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 for(i = 0 ; i < channel_list.num_channels; i++)
4690 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004691 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 }
4694 wrqu->data.length = strlen(extra)+1;
4695
4696 break;
4697 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004698#ifdef FEATURE_WLAN_TDLS
4699 case WE_GET_TDLS_PEERS:
4700 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004701 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004702 break;
4703 }
4704#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004705#ifdef WLAN_FEATURE_11W
4706 case WE_GET_11W_INFO:
4707 {
4708 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4709
4710 snprintf(extra, WE_MAX_STR_LEN,
4711 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4712 "\n Number of Unprotected Disassocs %d"
4713 "\n Number of Unprotected Deauths %d",
4714 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4715 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4716 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4717 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4718 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4719
4720 wrqu->data.length = strlen(extra)+1;
4721 break;
4722 }
4723#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304724 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004726 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 break;
4728 }
4729 }
4730
4731 return 0;
4732}
4733
4734/* action sub-ioctls */
4735static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4736 union iwreq_data *wrqu, char *extra)
4737{
4738 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4739 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004740 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004741
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004742 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4743 {
4744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4745 "%s:LOGP in Progress. Ignore!!!", __func__);
4746 return -EBUSY;
4747 }
4748
Jeff Johnson295189b2012-06-20 16:38:30 -07004749 switch (sub_cmd)
4750 {
4751 case WE_CLEAR_STATS:
4752 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4755 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4756 break;
4757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 case WE_INIT_AP:
4759 {
4760 pr_info("Init AP trigger\n");
4761 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4762 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4763 break;
4764 }
4765 case WE_STOP_AP:
4766 {
4767 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
4768 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
4769 * this is a dead code and need to find the adpater by name rather than mode */
4770 hdd_adapter_t* pAdapter_to_stop =
4771 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
4772 if( pAdapter_to_stop )
4773 {
4774 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4775
4776 pr_info("Stopping AP mode\n");
4777
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05304778 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4779 {
4780 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
4781 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
4782 }
4783
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 /*Make sure that pAdapter cleaned properly*/
4785 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
4786 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
4787 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
4788
4789 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
4790 pAdapter_to_stop->macAddressCurrent.bytes);
4791 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
4792 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05304793
4794 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4795 {
4796 /* put the device back into BMPS */
4797 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
4798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 }
4800 else
4801 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08004802 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 }
4804
4805 break;
4806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004807#ifdef WLAN_BTAMP_FEATURE
4808 case WE_ENABLE_AMP:
4809 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 WLANBAP_RegisterWithHCI(pAdapter);
4812 break;
4813 }
4814 case WE_DISABLE_AMP:
4815 {
4816 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4817 VOS_STATUS status;
4818
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004820
4821 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4822 status = WLANBAP_StopAmp();
4823 if(VOS_STATUS_SUCCESS != status )
4824 {
4825 pHddCtx->isAmpAllowed = VOS_TRUE;
4826 hddLog(VOS_TRACE_LEVEL_FATAL,
4827 "%s: Failed to stop AMP", __func__);
4828 }
4829 else
4830 {
4831 //a state m/c implementation in PAL is TBD to avoid this delay
4832 msleep(500);
4833 pHddCtx->isAmpAllowed = VOS_FALSE;
4834 WLANBAP_DeregisterFromHCI();
4835 }
4836
4837 break;
4838 }
4839#endif
4840
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004841 case WE_ENABLE_DXE_STALL_DETECT:
4842 {
schang6295e542013-03-12 15:31:23 -07004843 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4844 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004845 break;
4846 }
4847 case WE_DISPLAY_DXE_SNAP_SHOT:
4848 {
schang6295e542013-03-12 15:31:23 -07004849 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4850 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004851 break;
4852 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304853 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
4854 {
4855 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
4856 hdd_wmm_tx_snapshot(pAdapter);
4857 WLANTL_TLDebugMessage(VOS_TRUE);
4858 break;
4859 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07004860 case WE_SET_REASSOC_TRIGGER:
4861 {
4862 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4863 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
4864 v_U32_t roamId = 0;
4865 tCsrRoamModifyProfileFields modProfileFields;
4866 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
4867 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
4868 return 0;
4869 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304870
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004871
Jeff Johnson295189b2012-06-20 16:38:30 -07004872 default:
4873 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004874 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 break;
4876 }
4877 }
4878
4879 return ret;
4880}
4881
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304882void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
4883{
4884 /*
4885 * Function to display HDD WMM information
4886 * for Tx Queues.
4887 * Prints globala as well as per client depending
4888 * whether the clients are registered or not.
4889 */
4890 int i = 0, j = 0;
4891 for ( i=0; i< NUM_TX_QUEUES; i++)
4892 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304893 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004894 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304895 i, pAdapter->wmm_tx_queue[i].count,
4896 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304897 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304898 }
4899
4900 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
4901 {
4902 if(pAdapter->aStaInfo[i].isUsed)
4903 {
4904 hddLog(LOGE, "******STAIndex: %d*********", i);
4905 for ( j=0; j< NUM_TX_QUEUES; j++)
4906 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304907 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004908 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304909 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
4910 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
4911 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304912 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304913 }
4914 }
4915 }
4916
4917}
Jeff Johnson295189b2012-06-20 16:38:30 -07004918int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4919 union iwreq_data *wrqu, char *extra)
4920{
4921 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4922 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4923 int sub_cmd = wrqu->data.flags;
Arif Hussain7adce1b2013-11-11 22:59:34 -08004924 int *value = (int*)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 int apps_args[MAX_VAR_ARGS] = {0};
4926 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004927 hdd_station_ctx_t *pStaCtx = NULL ;
4928 hdd_ap_ctx_t *pAPCtx = NULL;
4929 int cmd = 0;
4930 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004931
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004932 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004933
4934 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4935 {
4936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4937 "%s:LOGP in Progress. Ignore!!!", __func__);
4938 return -EBUSY;
4939 }
4940
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 if (num_args > MAX_VAR_ARGS)
4942 {
4943 num_args = MAX_VAR_ARGS;
4944 }
4945 vos_mem_copy(apps_args, value, (sizeof(int)) * num_args);
4946
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004947 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
4948 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
4949 {
4950 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
4951 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
4952 {
4953 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4954 staId = pStaCtx->conn_info.staId[0];
4955 }
4956 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
4957 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
4958 {
4959 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4960 staId = pAPCtx->uBCStaId;
4961 }
4962 else
4963 {
4964 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
4965 return 0;
4966 }
4967 }
4968
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 switch (sub_cmd)
4970 {
4971 case WE_LOG_DUMP_CMD:
4972 {
4973 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004974 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 apps_args[3], apps_args[4]);
4976
4977 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
4978 apps_args[3], apps_args[4]);
4979
4980 }
4981 break;
4982
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 case WE_P2P_NOA_CMD:
4984 {
4985 p2p_app_setP2pPs_t p2pNoA;
4986
4987 p2pNoA.opp_ps = apps_args[0];
4988 p2pNoA.ctWindow = apps_args[1];
4989 p2pNoA.duration = apps_args[2];
4990 p2pNoA.interval = apps_args[3];
4991 p2pNoA.count = apps_args[4];
4992 p2pNoA.single_noa_duration = apps_args[5];
4993 p2pNoA.psSelection = apps_args[6];
4994
4995 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
4996 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004997 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
4999
5000 hdd_setP2pPs(dev, &p2pNoA);
5001
5002 }
5003 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005004
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005005 case WE_MCC_CONFIG_CREDENTIAL :
5006 {
5007 cmd = 287; //Command should be updated if there is any change
5008 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005009 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005010 {
5011 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5012 }
5013 else
5014 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005015 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005016 return 0;
5017 }
5018 }
5019 break;
5020
5021 case WE_MCC_CONFIG_PARAMS :
5022 {
5023 cmd = 288; //command Should be updated if there is any change
5024 // in the Riva dump command
5025 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5026 }
5027 break;
5028
Chilam NG571c65a2013-01-19 12:27:36 +05305029#ifdef FEATURE_WLAN_TDLS
5030 case WE_TDLS_CONFIG_PARAMS :
5031 {
5032 tdls_config_params_t tdlsParams;
5033
Chilam Ng01120412013-02-19 18:32:21 -08005034 tdlsParams.tdls = apps_args[0];
5035 tdlsParams.tx_period_t = apps_args[1];
5036 tdlsParams.tx_packet_n = apps_args[2];
5037 tdlsParams.discovery_period_t = apps_args[3];
5038 tdlsParams.discovery_tries_n = apps_args[4];
5039 tdlsParams.idle_timeout_t = apps_args[5];
5040 tdlsParams.idle_packet_n = apps_args[6];
5041 tdlsParams.rssi_hysteresis = apps_args[7];
5042 tdlsParams.rssi_trigger_threshold = apps_args[8];
5043 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305044
Chilam Ng01120412013-02-19 18:32:21 -08005045 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305046 }
5047 break;
5048#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 default:
5050 {
5051 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
5052 }
5053 break;
5054 }
5055
5056 return 0;
5057}
5058
5059
5060static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5061 union iwreq_data *wrqu, char *extra)
5062{
5063 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5064 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5065 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5066 int params[HDD_WLAN_WMM_PARAM_COUNT];
5067 sme_QosWmmTspecInfo tSpec;
5068 v_U32_t handle;
5069
5070 // make sure the application is sufficiently priviledged
5071 // note that the kernel will do this for "set" ioctls, but since
5072 // this ioctl wants to return status to user space it must be
5073 // defined as a "get" ioctl
5074 if (!capable(CAP_NET_ADMIN))
5075 {
5076 return -EPERM;
5077 }
5078
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005079 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5080 {
5081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5082 "%s:LOGP in Progress. Ignore!!!", __func__);
5083 return -EBUSY;
5084 }
5085
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 // we must be associated in order to add a tspec
5087 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5088 {
5089 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5090 return 0;
5091 }
5092
5093 // since we are defined to be a "get" ioctl, and since the number
5094 // of params exceeds the number of params that wireless extensions
5095 // will pass down in the iwreq_data, we must copy the "set" params
5096 // from user space ourselves
5097 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5098 {
5099 // hmmm, can't get them
5100 return -EIO;
5101 }
5102
5103 // clear the tspec
5104 memset(&tSpec, 0, sizeof(tSpec));
5105
5106 // validate the handle
5107 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5108 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5109 {
5110 // that one is reserved
5111 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5112 return 0;
5113 }
5114
5115 // validate the TID
5116 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5117 {
5118 // out of range
5119 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5120 return 0;
5121 }
5122 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5123
5124 // validate the direction
5125 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5126 {
5127 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5128 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5129 break;
5130
5131 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5132 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5133 break;
5134
5135 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5136 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5137 break;
5138
5139 default:
5140 // unknown
5141 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5142 return 0;
5143 }
5144
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305145 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5146
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 // validate the user priority
5148 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5149 {
5150 // out of range
5151 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5152 return 0;
5153 }
5154 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305155 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5156 {
5157 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5158 return 0;
5159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005160
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5162 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5163 tSpec.ts_info.psb, tSpec.ts_info.up);
5164
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5166 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5167 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5168 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5169 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5170 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5171 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5172 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5173 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5174 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5175 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5176 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5177
5178 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5179
5180 // validate the ts info ack policy
5181 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5182 {
5183 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5184 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5185 break;
5186
5187 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5188 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5189 break;
5190
5191 default:
5192 // unknown
5193 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5194 return 0;
5195 }
5196
5197 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5198 return 0;
5199}
5200
5201
5202static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5203 union iwreq_data *wrqu, char *extra)
5204{
5205 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5206 int *params = (int *)extra;
5207 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5208 v_U32_t handle;
5209
5210 // make sure the application is sufficiently priviledged
5211 // note that the kernel will do this for "set" ioctls, but since
5212 // this ioctl wants to return status to user space it must be
5213 // defined as a "get" ioctl
5214 if (!capable(CAP_NET_ADMIN))
5215 {
5216 return -EPERM;
5217 }
5218
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005219 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5220 {
5221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5222 "%s:LOGP in Progress. Ignore!!!", __func__);
5223 return -EBUSY;
5224 }
5225
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 // although we are defined to be a "get" ioctl, the params we require
5227 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5228 // is no need to copy the params from user space
5229
5230 // validate the handle
5231 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5232 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5233 {
5234 // that one is reserved
5235 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5236 return 0;
5237 }
5238
5239 *pStatus = hdd_wmm_delts(pAdapter, handle);
5240 return 0;
5241}
5242
5243
5244static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5245 union iwreq_data *wrqu, char *extra)
5246{
5247 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5248 int *params = (int *)extra;
5249 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5250 v_U32_t handle;
5251
5252 // although we are defined to be a "get" ioctl, the params we require
5253 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5254 // is no need to copy the params from user space
5255
5256 // validate the handle
5257 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5258 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5259 {
5260 // that one is reserved
5261 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5262 return 0;
5263 }
5264
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005265 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5266 {
5267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5268 "%s:LOGP in Progress. Ignore!!!", __func__);
5269 return -EBUSY;
5270 }
5271
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5273 return 0;
5274}
5275
5276
5277#ifdef FEATURE_WLAN_WAPI
5278static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5279 union iwreq_data *wrqu, char *extra)
5280{
5281 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5282 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5283 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5284 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5285
Arif Hussain7adce1b2013-11-11 22:59:34 -08005286 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005287
5288 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005289 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005290 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5291 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005292
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005293 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5294 {
5295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5296 "%s:LOGP in Progress. Ignore!!!", __func__);
5297 return -EBUSY;
5298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005299
5300 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005301 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5303 pRoamProfile->EncryptionType.numEntries = 1;
5304 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5305 pRoamProfile->mcEncryptionType.numEntries = 1;
5306 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5307
5308 pRoamProfile->AuthType.numEntries = 1;
5309 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5310 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5311 }
5312 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005313 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 }
5315 else
5316 return -EINVAL;
5317
5318 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5319
5320 return 0;
5321}
5322
5323static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5324 union iwreq_data *wrqu, char *extra)
5325{
5326 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5327 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5328
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005329 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5330 {
5331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5332 "%s:LOGP in Progress. Ignore!!!", __func__);
5333 return -EBUSY;
5334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5336
5337 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005338 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
5340 return 0;
5341}
5342
5343static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5344 union iwreq_data *wrqu, char *extra)
5345{
5346 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5347// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5348 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5349 int i = 0, j = 0;
5350 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005351 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005352 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005353
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005354 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5355 {
5356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5357 "%s:LOGP in Progress. Ignore!!!", __func__);
5358 return -EBUSY;
5359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 VOS_ASSERT(pWapiAssocInfo);
5361
Arif Hussain6d2a3322013-11-17 19:50:10 -08005362 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005363 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005365 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005366
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005367 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005369 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005370
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005371 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005372 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 for(i = 0 ; i < 16 ; i++) {
5374 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5375 for(j = 0 ; j < 16 ; j++)
5376 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5377 }
5378
5379 /* We are not using the entire IE as provided by the supplicant.
5380 * This is being calculated by SME. This is the same as in the
5381 * case of WPA. Only the auth mode information needs to be
5382 * extracted here*/
5383 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005384 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5386 }
5387
5388 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005389 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5391 }
5392 return 0;
5393}
5394
5395static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5396 union iwreq_data *wrqu, char *extra)
5397{
5398 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5399 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5400 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5401 tANI_U32 roamId = 0xFF;
5402 tANI_U8 *pKeyPtr = NULL;
5403 v_BOOL_t isConnected = TRUE;
5404 tCsrRoamSetKey setKey;
5405 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5407
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005408 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5409 {
5410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5411 "%s:LOGP in Progress. Ignore!!!", __func__);
5412 return -EBUSY;
5413 }
5414
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005416 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005417 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005418
Arif Hussain6d2a3322013-11-17 19:50:10 -08005419 hddLog(LOG1,":%s: INPUT DATA:\nKey Type:0x%02x Key Direction:0x%02x KEY ID:0x%02x", __func__, pWapiKey->keyType, pWapiKey->keyDirection, pWapiKey->keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 hddLog(LOG1,"Add Index:0x");
5421 for(i =0 ; i < 12 ; i++)
5422 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5423
Arif Hussain6d2a3322013-11-17 19:50:10 -08005424 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5426 for(i =0 ; i < 16 ; i++)
5427 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5428
Arif Hussain6d2a3322013-11-17 19:50:10 -08005429 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5431 for(i =0 ; i < 16 ; i++)
5432 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5433
Arif Hussain6d2a3322013-11-17 19:50:10 -08005434 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 for(i = 0 ; i < 16 ; i++)
5436 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5437
5438 // Clear the setkey memory
5439 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5440 // Store Key ID
5441 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5442 // SET WAPI Encryption
5443 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5444 // Key Directionn both TX and RX
5445 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5446 // the PAE role
5447 setKey.paeRole = 0 ;
5448
5449 switch ( pWapiKey->keyType )
5450 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005451 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 {
5453 isConnected = hdd_connIsConnected(pHddStaCtx);
5454 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5455 break;
5456 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005457 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 {
5459 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5460 break;
5461 }
5462 default:
5463 {
5464 //Any other option is invalid.
5465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005466 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005467
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005468 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5470 break; // NEED RETURN FROM HERE ????
5471 }
5472 }
5473
5474 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5475 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5476 pKeyPtr = setKey.Key;
5477 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5478 pKeyPtr += pWapiKey->wpiekLen;
5479 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5480
5481 // Set the new key with SME.
5482 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5483
5484 if ( isConnected ) {
5485 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5486 if ( halStatus != eHAL_STATUS_SUCCESS )
5487 {
5488 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5489 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5490
5491 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5492 }
5493 }
5494#if 0 /// NEED TO CHECK ON THIS
5495 else
5496 {
5497 // Store the keys in the adapter to be moved to the profile & passed to
5498 // SME in the ConnectRequest if we are not yet in connected state.
5499 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5500 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5501
5502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5503 " Saving key [idx= %d] to apply when moving to connected state ",
5504 setKey.keyId );
5505
5506 }
5507#endif
5508 return halStatus;
5509}
5510
5511static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5512 union iwreq_data *wrqu, char *extra)
5513{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005514 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005515#ifdef WLAN_DEBUG
5516 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005517 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005518#endif
5519
5520 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005521 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005522 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005523
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005524 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5525 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005526
5527 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005528
5529 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5530 {
5531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5532 "%s:LOGP in Progress. Ignore!!!", __func__);
5533 return -EBUSY;
5534 }
5535
Jeff Johnson295189b2012-06-20 16:38:30 -07005536#ifdef WLAN_DEBUG
5537 for(i =0 ; i < 16 ; i++)
5538 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5539#endif
5540
5541 return 0;
5542}
5543
5544static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5545 union iwreq_data *wrqu, char *extra)
5546{
5547 /* Yet to implement this function, 19th April 2010 */
5548 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5549
5550 return 0;
5551}
5552#endif /* FEATURE_WLAN_WAPI */
5553
5554#ifdef WLAN_FEATURE_VOWIFI_11R
5555//
5556//
5557// Each time the supplicant has the auth_request or reassoc request
5558// IEs ready. This is pushed to the driver. The driver will inturn use
5559// it to send out the auth req and reassoc req for 11r FT Assoc.
5560//
5561static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5562 union iwreq_data *wrqu, char *extra)
5563{
5564 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5565 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5566 //v_CONTEXT_t pVosContext;
5567
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005568 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5569 {
5570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5571 "%s:LOGP in Progress. Ignore!!!", __func__);
5572 return -EBUSY;
5573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 if (!wrqu->data.length)
5575 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005576 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 return -EINVAL;
5578 }
5579 if (wrqu->data.pointer == NULL)
5580 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005581 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 return -EINVAL;
5583 }
5584
5585 // Added for debug on reception of Re-assoc Req.
5586 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5587 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005588 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005590 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 }
5592
5593#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005594 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005595#endif
5596
5597 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005598 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 wrqu->data.length);
5600
5601 return 0;
5602}
5603#endif
5604
Amar Singhalf3a6e762013-02-19 15:06:50 -08005605static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005606 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005608{
Jeff Johnson295189b2012-06-20 16:38:30 -07005609 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005610 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005612 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005613 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005614 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5615 int idx;
5616 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005617
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005618 if (pHddCtx->isLogpInProgress)
5619 {
5620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5621 "%s:LOGP in Progress. Ignore!!!", __func__);
5622 return -EBUSY;
5623 }
5624
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305625 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5626 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305627#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005628
Amar Singhalf3a6e762013-02-19 15:06:50 -08005629 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5630 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005631 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005632 hddLog(VOS_TRACE_LEVEL_ERROR,
5633 "%s: vos_mem_alloc failed", __func__);
5634 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005635 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005636
5637 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5638
5639 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5640 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5641
5642 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5643 mc_addr_list_ptr->ulMulticastAddrCnt);
5644
5645 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005646 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005647 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5648 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5649
5650 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5651 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005652 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005653
Amar Singhalf3a6e762013-02-19 15:06:50 -08005654 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5655 vos_mem_free(mc_addr_list_ptr);
5656 if (eHAL_STATUS_SUCCESS != ret_val)
5657 {
5658 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5659 __func__);
5660 return -EINVAL;
5661 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305662#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305663 }
5664 else
5665 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005666
Amar Singhalf3a6e762013-02-19 15:06:50 -08005667 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5668 "%s: Set MC BC Filter Config request: %d suspend %d",
5669 __func__, pRequest->mcastBcastFilterSetting,
5670 pHddCtx->hdd_wlan_suspended);
5671
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305672 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005673
5674 if (pHddCtx->hdd_wlan_suspended)
5675 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005676 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5677 if (NULL == wlanRxpFilterParam)
5678 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305679 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005680 "%s: vos_mem_alloc failed", __func__);
5681 return -EINVAL;
5682 }
5683
Amar Singhalf3a6e762013-02-19 15:06:50 -08005684 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5685 pRequest->mcastBcastFilterSetting;
5686 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5687
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305688 hdd_conf_hostoffload(pAdapter, TRUE);
5689 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5690 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005691
5692 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5693 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305694 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08005695 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5696 wlanRxpFilterParam->setMcstBcstFilter);
5697
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305698 if (eHAL_STATUS_SUCCESS !=
5699 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5700 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08005701 {
5702 hddLog(VOS_TRACE_LEVEL_ERROR,
5703 "%s: Failure to execute set HW MC/BC Filter request",
5704 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005705 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005706 return -EINVAL;
5707 }
5708
Amar Singhalf3a6e762013-02-19 15:06:50 -08005709 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005711
5712 return 0;
5713}
5714
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005715static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
5716 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 union iwreq_data *wrqu, char *extra)
5718{
5719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5720 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305721 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005722 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005723
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305724 //Reset the filter to INI value as we have to clear the dynamic filter
5725 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005726
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305727 //Configure FW with new setting
5728 if (pHddCtx->hdd_wlan_suspended)
5729 {
5730 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5731 if (NULL == wlanRxpFilterParam)
5732 {
5733 hddLog(VOS_TRACE_LEVEL_ERROR,
5734 "%s: vos_mem_alloc failed", __func__);
5735 return -EINVAL;
5736 }
5737
5738 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5739 pHddCtx->configuredMcastBcastFilter;
5740 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5741
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305742 hdd_conf_hostoffload(pAdapter, TRUE);
5743 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5744 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305745
5746 if (eHAL_STATUS_SUCCESS !=
5747 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5748 wlanRxpFilterParam))
5749 {
5750 hddLog(VOS_TRACE_LEVEL_ERROR,
5751 "%s: Failure to execute set HW MC/BC Filter request",
5752 __func__);
5753 vos_mem_free(wlanRxpFilterParam);
5754 return -EINVAL;
5755 }
5756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 return 0;
5758}
5759
5760static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
5761 union iwreq_data *wrqu, char *extra)
5762{
5763 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005764 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 tSirHostOffloadReq offloadRequest;
5766
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005767 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5768 {
5769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5770 "%s:LOGP in Progress. Ignore!!!", __func__);
5771 return -EBUSY;
5772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 /* Debug display of request components. */
5774 switch (pRequest->offloadType)
5775 {
5776 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005777 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 switch (pRequest->enableOrDisable)
5779 {
5780 case WLAN_OFFLOAD_DISABLE:
5781 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
5782 break;
5783 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
5784 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
5785 case WLAN_OFFLOAD_ENABLE:
5786 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
5787 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
5788 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
5789 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
5790 }
5791 break;
5792
5793 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005794 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005795 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 switch (pRequest->enableOrDisable)
5797 {
5798 case WLAN_OFFLOAD_DISABLE:
5799 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
5800 break;
5801 case WLAN_OFFLOAD_ENABLE:
5802 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
5803 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
5804 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
5805 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
5806 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
5807 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
5808 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
5809 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
5810 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
5811 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
5812 }
5813 }
5814
5815 /* Execute offload request. The reason that we can copy the request information
5816 from the ioctl structure to the SME structure is that they are laid out
5817 exactly the same. Otherwise, each piece of information would have to be
5818 copied individually. */
5819 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07005820 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
5821 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005823 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 __func__);
5825 return -EINVAL;
5826 }
5827
5828 return 0;
5829}
5830
5831static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
5832 union iwreq_data *wrqu, char *extra)
5833{
5834 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005835 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 tSirKeepAliveReq keepaliveRequest;
5837
5838 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5839 {
5840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005841 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 return 0;
5843 }
5844
5845 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08005846 hddLog(VOS_TRACE_LEVEL_INFO,
5847 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
5848 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005849
5850 switch (pRequest->packetType)
5851 {
5852 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005853 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 break;
5855
5856 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
5857
Arif Hussain6d2a3322013-11-17 19:50:10 -08005858 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005859 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005860
5861 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
5862 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
5863 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
5864
5865 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
5866 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
5867 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
5868
5869 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
5870 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
5871 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
5872 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
5873 break;
5874
5875 }
5876
5877 /* Execute keep alive request. The reason that we can copy the request information
5878 from the ioctl structure to the SME structure is that they are laid out
5879 exactly the same. Otherwise, each piece of information would have to be
5880 copied individually. */
5881 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
5882
Arif Hussain6d2a3322013-11-17 19:50:10 -08005883 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07005884
Jeff Johnsone7245742012-09-05 17:12:55 -07005885 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
5886 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005888 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 __func__);
5890 return -EINVAL;
5891 }
5892
5893 return 0;
5894}
5895
5896#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -07005897int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
5898 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005899{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005900 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5901 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 int i=0;
5903
5904 if (pHddCtx->cfg_ini->disablePacketFilter)
5905 {
5906 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005907 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 return 0;
5909 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005910 if (pHddCtx->isLogpInProgress)
5911 {
5912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5913 "%s:LOGP in Progress. Ignore!!!", __func__);
5914 return -EBUSY;
5915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 /* Debug display of request components. */
5917 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005918 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07005919
5920 switch (pRequest->filterAction)
5921 {
5922 case HDD_RCV_FILTER_SET:
5923 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005924 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005925
5926 packetFilterSetReq.filterId = pRequest->filterId;
5927 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
5928 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005929 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 __func__, pRequest->numParams);
5931 return -EINVAL;
5932 }
5933 packetFilterSetReq.numFieldParams = pRequest->numParams;
5934 packetFilterSetReq.coalesceTime = 0;
5935 packetFilterSetReq.filterType = 1;
5936 for (i=0; i < pRequest->numParams; i++)
5937 {
5938 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
5939 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
5940 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
5941 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
5942 packetFilterSetReq.paramsData[i].reserved = 0;
5943
Arif Hussain6d2a3322013-11-17 19:50:10 -08005944 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
5946 packetFilterSetReq.filterType);
5947
Arif Hussain6d2a3322013-11-17 19:50:10 -08005948 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
5950
5951 memcpy(&packetFilterSetReq.paramsData[i].compareData,
5952 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
5953 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
5954 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
5955
Arif Hussain6d2a3322013-11-17 19:50:10 -08005956 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
5958 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
5959 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
5960
Arif Hussain6d2a3322013-11-17 19:50:10 -08005961 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
5963 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
5964 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
5965 }
5966
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005967 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005969 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 __func__);
5971 return -EINVAL;
5972 }
5973
5974 break;
5975
5976 case HDD_RCV_FILTER_CLEAR:
5977
Arif Hussain6d2a3322013-11-17 19:50:10 -08005978 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005979 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005981 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005983 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 __func__);
5985 return -EINVAL;
5986 }
5987 break;
5988
5989 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08005990 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005991 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 return -EINVAL;
5993 }
5994 return 0;
5995}
5996
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05305997int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
5998 tANI_U8 sessionId)
5999{
6000 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6001 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6002
6003 if (NULL == pHddCtx)
6004 {
6005 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6006 return -EINVAL;
6007 }
6008
6009 if (pHddCtx->isLogpInProgress)
6010 {
6011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6012 "%s:LOGP in Progress. Ignore!!!", __func__);
6013 return -EBUSY;
6014 }
6015
6016 if (pHddCtx->cfg_ini->disablePacketFilter)
6017 {
6018 hddLog(VOS_TRACE_LEVEL_ERROR,
6019 "%s: Packet Filtering Disabled. Returning ",
6020 __func__ );
6021 return -EINVAL;
6022 }
6023
6024 switch (filterType)
6025 {
6026 /* For setting IPV6 MC and UC Filter we need to configure
6027 * 2 filters, one for MC and one for UC.
6028 * The Filter ID shouldn't be swapped, which results in making
6029 * UC Filter ineffective.
6030 * We have Hardcode all the values
6031 *
6032 * Reason for a seperate UC filter is because, driver need to
6033 * specify the FW that the specific filter is for unicast
6034 * otherwise FW will not pass the unicast frames by default
6035 * through the filter. This is required to avoid any performance
6036 * hits when no unicast filter is set and only MC/BC are set.
6037 * The way driver informs host is by using the MAC protocol
6038 * layer, CMP flag set to MAX, CMP Data set to 1.
6039 */
6040
6041 case HDD_FILTER_IPV6_MC_UC:
6042 /* Setting IPV6 MC Filter below
6043 */
6044 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6045 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6046 packetFilterSetReq.numFieldParams = 2;
6047 packetFilterSetReq.paramsData[0].protocolLayer =
6048 HDD_FILTER_PROTO_TYPE_MAC;
6049 packetFilterSetReq.paramsData[0].cmpFlag =
6050 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6051 packetFilterSetReq.paramsData[0].dataOffset =
6052 WLAN_HDD_80211_FRM_DA_OFFSET;
6053 packetFilterSetReq.paramsData[0].dataLength = 1;
6054 packetFilterSetReq.paramsData[0].compareData[0] =
6055 HDD_IPV6_MC_CMP_DATA;
6056
6057 packetFilterSetReq.paramsData[1].protocolLayer =
6058 HDD_FILTER_PROTO_TYPE_ARP;
6059 packetFilterSetReq.paramsData[1].cmpFlag =
6060 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6061 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6062 packetFilterSetReq.paramsData[1].dataLength = 2;
6063 packetFilterSetReq.paramsData[1].compareData[0] =
6064 HDD_IPV6_CMP_DATA_0;
6065 packetFilterSetReq.paramsData[1].compareData[1] =
6066 HDD_IPV6_CMP_DATA_1;
6067
6068
6069 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6070 &packetFilterSetReq, sessionId))
6071 {
6072 hddLog(VOS_TRACE_LEVEL_ERROR,
6073 "%s: Failure to execute Set IPv6 Mulicast Filter",
6074 __func__);
6075 return -EINVAL;
6076 }
6077
6078 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6079
6080 /*
6081 * Setting IPV6 UC Filter below
6082 */
6083 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6084 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6085 packetFilterSetReq.numFieldParams = 2;
6086 packetFilterSetReq.paramsData[0].protocolLayer =
6087 HDD_FILTER_PROTO_TYPE_MAC;
6088 packetFilterSetReq.paramsData[0].cmpFlag =
6089 HDD_FILTER_CMP_TYPE_MAX;
6090 packetFilterSetReq.paramsData[0].dataOffset = 0;
6091 packetFilterSetReq.paramsData[0].dataLength = 1;
6092 packetFilterSetReq.paramsData[0].compareData[0] =
6093 HDD_IPV6_UC_CMP_DATA;
6094
6095 packetFilterSetReq.paramsData[1].protocolLayer =
6096 HDD_FILTER_PROTO_TYPE_ARP;
6097 packetFilterSetReq.paramsData[1].cmpFlag =
6098 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6099 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6100 packetFilterSetReq.paramsData[1].dataLength = 2;
6101 packetFilterSetReq.paramsData[1].compareData[0] =
6102 HDD_IPV6_CMP_DATA_0;
6103 packetFilterSetReq.paramsData[1].compareData[1] =
6104 HDD_IPV6_CMP_DATA_1;
6105
6106 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6107 &packetFilterSetReq, sessionId))
6108 {
6109 hddLog(VOS_TRACE_LEVEL_ERROR,
6110 "%s: Failure to execute Set IPv6 Unicast Filter",
6111 __func__);
6112 return -EINVAL;
6113 }
6114
6115 break;
6116
6117 case HDD_FILTER_IPV6_MC:
6118 /*
6119 * IPV6 UC Filter might be already set,
6120 * clear the UC Filter. As the Filter
6121 * IDs are static, we can directly clear it.
6122 */
6123 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6124 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6125 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6126 &packetFilterClrReq, sessionId))
6127 {
6128 hddLog(VOS_TRACE_LEVEL_ERROR,
6129 "%s: Failure to execute Clear IPv6 Unicast Filter",
6130 __func__);
6131 return -EINVAL;
6132 }
6133
6134 /*
6135 * Setting IPV6 MC Filter below
6136 */
6137 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6138 packetFilterSetReq.numFieldParams = 2;
6139 packetFilterSetReq.paramsData[0].protocolLayer =
6140 HDD_FILTER_PROTO_TYPE_MAC;
6141 packetFilterSetReq.paramsData[0].cmpFlag =
6142 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6143 packetFilterSetReq.paramsData[0].dataOffset =
6144 WLAN_HDD_80211_FRM_DA_OFFSET;
6145 packetFilterSetReq.paramsData[0].dataLength = 1;
6146 packetFilterSetReq.paramsData[0].compareData[0] =
6147 HDD_IPV6_MC_CMP_DATA;
6148
6149 packetFilterSetReq.paramsData[1].protocolLayer =
6150 HDD_FILTER_PROTO_TYPE_ARP;
6151 packetFilterSetReq.paramsData[1].cmpFlag =
6152 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6153 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6154 packetFilterSetReq.paramsData[1].dataLength = 2;
6155 packetFilterSetReq.paramsData[1].compareData[0] =
6156 HDD_IPV6_CMP_DATA_0;
6157 packetFilterSetReq.paramsData[1].compareData[1] =
6158 HDD_IPV6_CMP_DATA_1;
6159
6160
6161 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6162 &packetFilterSetReq, sessionId))
6163 {
6164 hddLog(VOS_TRACE_LEVEL_ERROR,
6165 "%s: Failure to execute Set IPv6 Multicast Filter",
6166 __func__);
6167 return -EINVAL;
6168 }
6169 break;
6170
6171 default :
6172 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6173 "%s: Packet Filter Request: Invalid",
6174 __func__);
6175 return -EINVAL;
6176 }
6177 return 0;
6178}
6179
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306180void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006181{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306182 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306183 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006184 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306185 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006186
Yue Ma3ede6052013-08-29 00:33:26 -07006187 if (NULL == pHddCtx)
6188 {
6189 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6190 return;
6191 }
6192
6193 hHal = pHddCtx->hHal;
6194
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306195 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306197 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6198 return;
6199 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306200
6201 /* Check if INI is enabled or not, other wise just return
6202 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306203 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306204 {
6205 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6206 if (NULL == pMulticastAddrs)
6207 {
6208 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6209 return;
6210 }
6211
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 if (set)
6213 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306214 /* Following pre-conditions should be satisfied before wei
6215 * configure the MC address list.
6216 */
6217 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6218 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6219 && pAdapter->mc_addr_list.mc_cnt
6220 && (eConnectionState_Associated ==
6221 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6222 {
6223 pMulticastAddrs->ulMulticastAddrCnt =
6224 pAdapter->mc_addr_list.mc_cnt;
6225 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6226 {
6227 memcpy(&(pMulticastAddrs->multicastAddr[i][0]),
6228 &(pAdapter->mc_addr_list.addr[i][0]),
6229 sizeof(pAdapter->mc_addr_list.addr[i]));
6230 hddLog(VOS_TRACE_LEVEL_INFO,
6231 "%s: %s multicast filter: addr ="
6232 MAC_ADDRESS_STR,
6233 __func__, set ? "setting" : "clearing",
6234 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6235 }
6236 /* Set multicast filter */
6237 sme_8023MulticastList(hHal, pAdapter->sessionId,
6238 pMulticastAddrs);
6239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306241 else
6242 {
6243 /* Need to clear only if it was previously configured
6244 */
6245 if (pAdapter->mc_addr_list.isFilterApplied)
6246 {
6247 pMulticastAddrs->ulMulticastAddrCnt = 0;
6248 sme_8023MulticastList(hHal, pAdapter->sessionId,
6249 pMulticastAddrs);
6250 }
6251
6252 }
6253 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006254 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306256 else
6257 {
6258 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306259 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306260 }
6261 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006262}
6263
6264static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6265 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306266{
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006268 tpPacketFilterCfg pRequest = (tpPacketFilterCfg) extra;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006269
Jeff Johnsone7245742012-09-05 17:12:55 -07006270 return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006271}
6272#endif
6273static int iw_get_statistics(struct net_device *dev,
6274 struct iw_request_info *info,
6275 union iwreq_data *wrqu, char *extra)
6276{
6277
6278 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6279 eHalStatus status = eHAL_STATUS_SUCCESS;
6280 hdd_wext_state_t *pWextState;
6281 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6282 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6283 char *p = extra;
6284 int tlen = 0;
6285 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6286
6287 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6288 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6289
6290 ENTER();
6291
6292 if (pHddCtx->isLogpInProgress) {
6293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6294 return -EINVAL;
6295 }
6296
6297 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6298
6299 wrqu->txpower.value = 0;
6300 }
6301 else {
6302 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6303 SME_SUMMARY_STATS |
6304 SME_GLOBAL_CLASSA_STATS |
6305 SME_GLOBAL_CLASSB_STATS |
6306 SME_GLOBAL_CLASSC_STATS |
6307 SME_GLOBAL_CLASSD_STATS |
6308 SME_PER_STA_STATS,
6309 hdd_StatisticsCB, 0, FALSE,
6310 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6311
6312 if (eHAL_STATUS_SUCCESS != status)
6313 {
6314 hddLog(VOS_TRACE_LEVEL_ERROR,
6315 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006316 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 return -EINVAL;
6318 }
6319
6320 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6321
6322 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6323 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6324 {
6325 hddLog(VOS_TRACE_LEVEL_ERROR,
6326 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006327 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 /*Remove the SME statistics list by passing NULL in callback argument*/
6329 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6330 SME_SUMMARY_STATS |
6331 SME_GLOBAL_CLASSA_STATS |
6332 SME_GLOBAL_CLASSB_STATS |
6333 SME_GLOBAL_CLASSC_STATS |
6334 SME_GLOBAL_CLASSD_STATS |
6335 SME_PER_STA_STATS,
6336 NULL, 0, FALSE,
6337 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6338
6339 return -EINVAL;
6340 }
6341 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6342 (tANI_U8) sizeof (pStats->retry_cnt),
6343 (char*) &(pStats->retry_cnt[0]),
6344 tlen);
6345
6346 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6347 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6348 (char*) &(pStats->multiple_retry_cnt[0]),
6349 tlen);
6350
6351 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6352 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6353 (char*) &(pStats->tx_frm_cnt[0]),
6354 tlen);
6355
6356 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6357 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6358 (char*) &(pStats->rx_frm_cnt),
6359 tlen);
6360
6361 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6362 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6363 (char*) &(pStats->frm_dup_cnt),
6364 tlen);
6365
6366 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6367 (tANI_U8) sizeof (pStats->fail_cnt),
6368 (char*) &(pStats->fail_cnt[0]),
6369 tlen);
6370
6371 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6372 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6373 (char*) &(pStats->rts_fail_cnt),
6374 tlen);
6375
6376 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6377 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6378 (char*) &(pStats->ack_fail_cnt),
6379 tlen);
6380
6381 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6382 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6383 (char*) &(pStats->rts_succ_cnt),
6384 tlen);
6385
6386 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6387 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6388 (char*) &(pStats->rx_discard_cnt),
6389 tlen);
6390
6391 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6392 (tANI_U8) sizeof (pStats->rx_error_cnt),
6393 (char*) &(pStats->rx_error_cnt),
6394 tlen);
6395
Jeff Johnsone7245742012-09-05 17:12:55 -07006396 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
6397 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6398 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 tlen);
6400
6401 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6402 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6403 (char*) &(dStats->rx_byte_cnt),
6404 tlen);
6405
6406 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6407 (tANI_U8) sizeof (dStats->rx_rate),
6408 (char*) &(dStats->rx_rate),
6409 tlen);
6410
6411 /* Transmit rate, in units of 500 kbit/sec */
6412 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6413 (tANI_U8) sizeof (aStats->tx_rate),
6414 (char*) &(aStats->tx_rate),
6415 tlen);
6416
Jeff Johnsone7245742012-09-05 17:12:55 -07006417 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6418 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6419 (char*) &(dStats->rx_uc_byte_cnt[0]),
6420 tlen);
6421 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6422 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6423 (char*) &(dStats->rx_mc_byte_cnt),
6424 tlen);
6425 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6426 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6427 (char*) &(dStats->rx_bc_byte_cnt),
6428 tlen);
6429 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6430 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6431 (char*) &(dStats->tx_uc_byte_cnt[0]),
6432 tlen);
6433 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6434 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6435 (char*) &(dStats->tx_mc_byte_cnt),
6436 tlen);
6437 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6438 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6439 (char*) &(dStats->tx_bc_byte_cnt),
6440 tlen);
6441
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 wrqu->data.length = tlen;
6443
6444 }
6445
6446 EXIT();
6447
6448 return 0;
6449}
6450
6451
6452#ifdef FEATURE_WLAN_SCAN_PNO
6453
6454/*Max Len for PNO notification*/
6455#define MAX_PNO_NOTIFY_LEN 100
6456void found_pref_network_cb (void *callbackContext,
6457 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6458{
6459 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6460 union iwreq_data wrqu;
6461 char buf[MAX_PNO_NOTIFY_LEN+1];
6462
6463 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6464 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6465
6466 // create the event
6467 memset(&wrqu, 0, sizeof(wrqu));
6468 memset(buf, 0, sizeof(buf));
6469
6470 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6471 pPrefNetworkFoundInd->ssId.ssId,
6472 (unsigned int)pPrefNetworkFoundInd->rssi);
6473
6474 wrqu.data.pointer = buf;
6475 wrqu.data.length = strlen(buf);
6476
6477 // send the event
6478
6479 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6480
6481}
6482
6483
6484/*string based input*/
6485VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6486 union iwreq_data *wrqu, char *extra, int nOffset)
6487{
6488 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006489 /* pnoRequest is a large struct, so we make it static to avoid stack
6490 overflow. This API is only invoked via ioctl, so it is
6491 serialized by the kernel rtnl_lock and hence does not need to be
6492 reentrant */
6493 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 char *ptr;
6495 v_U8_t i,j, ucParams, ucMode;
6496 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6497
6498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6499 "PNO data len %d data %s",
6500 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006501 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006502
6503 if (wrqu->data.length <= nOffset )
6504 {
6505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6506 return VOS_STATUS_E_FAILURE;
6507 }
6508
6509 pnoRequest.enable = 0;
6510 pnoRequest.ucNetworksCount = 0;
6511 /*-----------------------------------------------------------------------
6512 Input is string based and expected to be like this:
6513
6514 <enabled> <netw_count>
6515 for each network:
6516 <ssid_len> <ssid> <authentication> <encryption>
6517 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6518 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6519
6520 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006521 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 -07006522
6523 this translates into:
6524 -----------------------------
6525 enable PNO
6526 look for 2 networks:
6527 test - with authentication type 0 and encryption type 0,
6528 that can be found on 3 channels: 1 6 and 11 ,
6529 SSID bcast type is unknown (directed probe will be sent if AP not found)
6530 and must meet -40dBm RSSI
6531
6532 test2 - with auth and enrytption type 4/4
6533 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6534 bcast type is non-bcast (directed probe will be sent)
6535 and must not meet any RSSI threshold
6536
Jeff Johnson8301aa12013-03-28 14:27:29 -07006537 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006539 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006540
Wilson Yang623f6592013-10-08 16:33:37 -07006541 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6542 {
6543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6544 "PNO enable input is not valid %s",ptr);
6545 return VOS_STATUS_E_FAILURE;
6546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006547
6548 if ( 0 == pnoRequest.enable )
6549 {
6550 /*Disable PNO*/
6551 memset(&pnoRequest, 0, sizeof(pnoRequest));
6552 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6553 pAdapter->sessionId,
6554 found_pref_network_cb, pAdapter);
6555 return VOS_STATUS_SUCCESS;
6556 }
6557
6558 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006559
6560 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6561 {
6562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6563 "PNO count input not valid %s",ptr);
6564 return VOS_STATUS_E_FAILURE;
6565
6566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006567
6568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6569 "PNO enable %d networks count %d offset %d",
6570 pnoRequest.enable,
6571 pnoRequest.ucNetworksCount,
6572 nOffset);
6573
6574 /* Parameters checking:
6575 ucNetworksCount has to be larger than 0*/
6576 if (( 0 == pnoRequest.ucNetworksCount ) ||
6577 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6578 {
6579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6580 return VOS_STATUS_E_FAILURE;
6581 }
6582
6583 ptr += nOffset;
6584
6585 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6586 {
6587
6588 pnoRequest.aNetworks[i].ssId.length = 0;
6589
Wilson Yang623f6592013-10-08 16:33:37 -07006590 ucParams = sscanf(ptr,"%hhu %n",
6591 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6592
6593 if (1 != ucParams)
6594 {
6595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6596 "PNO ssid length input is not valid %s",ptr);
6597 return VOS_STATUS_E_FAILURE;
6598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006599
6600 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6601 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6602 {
6603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6604 "SSID Len %d is not correct for network %d",
6605 pnoRequest.aNetworks[i].ssId.length, i);
6606 return VOS_STATUS_E_FAILURE;
6607 }
6608
6609 /*Advance to SSID*/
6610 ptr += nOffset;
6611
Jeff Johnson8301aa12013-03-28 14:27:29 -07006612 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006613 pnoRequest.aNetworks[i].ssId.length);
6614 ptr += pnoRequest.aNetworks[i].ssId.length;
6615
Jeff Johnson02797792013-10-26 19:17:13 -07006616 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006617 &(pnoRequest.aNetworks[i].authentication),
6618 &(pnoRequest.aNetworks[i].encryption),
6619 &(pnoRequest.aNetworks[i].ucChannelCount),
6620 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006621
Wilson Yang623f6592013-10-08 16:33:37 -07006622 if ( 3 != ucParams )
6623 {
6624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6625 "Incorrect cmd %s",ptr);
6626 return VOS_STATUS_E_FAILURE;
6627 }
6628
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006630 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006631 "auth %d encry %d channel count %d offset %d",
6632 pnoRequest.aNetworks[i].ssId.length,
6633 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6634 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6635 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6636 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6637 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6638 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6639 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6640 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6641 pnoRequest.aNetworks[i].authentication,
6642 pnoRequest.aNetworks[i].encryption,
6643 pnoRequest.aNetworks[i].ucChannelCount,
6644 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006645
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 /*Advance to channel list*/
6647 ptr += nOffset;
6648
Wilson Yang623f6592013-10-08 16:33:37 -07006649 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 {
6651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6652 "Incorrect number of channels");
6653 return VOS_STATUS_E_FAILURE;
6654 }
6655
6656 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6657 {
6658 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6659 {
Wilson Yang623f6592013-10-08 16:33:37 -07006660 if (1 != sscanf(ptr,"%hhu %n",
6661 &(pnoRequest.aNetworks[i].aChannels[j]),
6662 &nOffset))
6663 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6664 "PNO network channel input is not valid %s",ptr);
6665 return VOS_STATUS_E_FAILURE;
6666 }
6667 /*Advance to next channel number*/
6668 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 }
6670 }
6671
Jeff Johnson02797792013-10-26 19:17:13 -07006672 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006673 &(pnoRequest.aNetworks[i].bcastNetwType),
6674 &nOffset))
6675 {
6676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6677 "PNO broadcast network type input is not valid %s",ptr);
6678 return VOS_STATUS_E_FAILURE;
6679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006680
6681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6682 "PNO bcastNetwType %d offset %d",
6683 pnoRequest.aNetworks[i].bcastNetwType,
6684 nOffset );
6685
6686 /*Advance to rssi Threshold*/
6687 ptr += nOffset;
6688
Wilson Yang623f6592013-10-08 16:33:37 -07006689 if (1 != sscanf(ptr,"%hhu %n",
6690 &(pnoRequest.aNetworks[i].rssiThreshold),
6691 &nOffset))
6692 {
6693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6694 "PNO rssi threshold input is not valid %s",ptr);
6695 return VOS_STATUS_E_FAILURE;
6696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006697
6698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6699 "PNO rssi %d offset %d",
6700 pnoRequest.aNetworks[i].rssiThreshold,
6701 nOffset );
6702 /*Advance to next network*/
6703 ptr += nOffset;
6704 }/*For ucNetworkCount*/
6705
6706 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006707 &(pnoRequest.scanTimers.ucScanTimersCount),
6708 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006709
6710 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07006711 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 {
6713 ptr += nOffset;
6714
Jeff Johnson8301aa12013-03-28 14:27:29 -07006715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6716 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 pnoRequest.scanTimers.ucScanTimersCount,
6718 nOffset );
6719
6720 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
6721 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 "Incorrect cmd - too many scan timers");
6724 return VOS_STATUS_E_FAILURE;
6725 }
6726
6727 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
6728 {
Jeff Johnson02797792013-10-26 19:17:13 -07006729 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
6731 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
6732 &nOffset);
6733
Wilson Yang623f6592013-10-08 16:33:37 -07006734 if (2 != ucParams)
6735 {
6736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6737 "Incorrect cmd - diff params then expected %d", ucParams);
6738 return VOS_STATUS_E_FAILURE;
6739 }
6740
Jeff Johnson8301aa12013-03-28 14:27:29 -07006741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6742 "PNO Timer value %d Timer repeat %d offset %d",
6743 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
6745 nOffset );
6746
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 ptr += nOffset;
6748 }
6749
6750 }
6751 else
6752 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6754 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
6756
6757 /*Scan timers defaults to 5 minutes*/
6758 pnoRequest.scanTimers.ucScanTimersCount = 1;
6759 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
6760 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
6761 }
6762
Wilson Yang623f6592013-10-08 16:33:37 -07006763 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006764
6765 pnoRequest.modePNO = ucMode;
6766 /*for LA we just expose suspend option*/
6767 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
6768 {
6769 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
6770 }
6771
6772 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6773 pAdapter->sessionId,
6774 found_pref_network_cb, pAdapter);
6775
6776 return VOS_STATUS_SUCCESS;
6777}/*iw_set_pno*/
6778
6779VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
6780 union iwreq_data *wrqu, char *extra, int nOffset)
6781{
6782 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6783 v_U8_t rssiThreshold = 0;
6784 v_U8_t nRead;
6785
Arif Hussain7adce1b2013-11-11 22:59:34 -08006786 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006787 &rssiThreshold);
6788
6789 if ( 1 != nRead )
6790 {
6791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6792 "Incorrect format");
6793 return VOS_STATUS_E_FAILURE;
6794 }
6795
6796 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
6797 return VOS_STATUS_SUCCESS;
6798}
6799
6800
6801static int iw_set_pno_priv(struct net_device *dev,
6802 struct iw_request_info *info,
6803 union iwreq_data *wrqu, char *extra)
6804{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006805 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6806
6807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006809
6810 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6811 {
6812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6813 "%s:LOGP in Progress. Ignore!!!", __func__);
6814 return -EBUSY;
6815 }
6816 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006817}
6818#endif /*FEATURE_WLAN_SCAN_PNO*/
6819
6820//Common function to SetBand
6821int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
6822{
6823 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6824 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6825 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6826 tANI_U8 band = 0;
6827 eCsrBand currBand = eCSR_BAND_MAX;
6828
6829 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
6830
6831 switch(band)
6832 {
6833 case WLAN_HDD_UI_BAND_AUTO:
6834 band = eCSR_BAND_ALL;
6835 break;
6836 case WLAN_HDD_UI_BAND_5_GHZ:
6837 band = eCSR_BAND_5G;
6838 break;
6839 case WLAN_HDD_UI_BAND_2_4_GHZ:
6840 band = eCSR_BAND_24;
6841 break;
6842 default:
6843 band = eCSR_BAND_MAX;
6844 }
6845
6846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006847 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006848
6849 if (band == eCSR_BAND_MAX)
6850 {
6851 /* Received change band request with invalid band value */
6852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006853 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 return -EIO;
6855 }
6856
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306857 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
6858 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
6859 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
6860 {
Shake M Subhani90cc8622013-11-05 16:13:10 +05306861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006862 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006863 band, pHddCtx->cfg_ini->nBandCapability);
6864 return -EIO;
6865 }
6866
Jeff Johnson295189b2012-06-20 16:38:30 -07006867 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
6868 {
6869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6870 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006871 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 return -EIO;
6873 }
6874
6875 if (currBand != band)
6876 {
6877 /* Change band request received.
6878 * Abort pending scan requests, flush the existing scan results,
6879 * and change the band capability
6880 */
6881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6882 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006883 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006884
6885 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6886 {
6887 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
6888 eHalStatus status = eHAL_STATUS_SUCCESS;
6889 long lrc;
6890
6891 /* STA already connected on current band, So issue disconnect first,
6892 * then change the band*/
6893
6894 hddLog(VOS_TRACE_LEVEL_INFO,
6895 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
6896 __func__, csrGetCurrentBand(hHal), band);
6897
6898 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6899 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6900
6901 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6902 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6903
Jeff Johnson43971f52012-07-17 12:26:56 -07006904 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 {
6906 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006907 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006908 __func__, (int)status );
6909 return -EINVAL;
6910 }
6911
6912 lrc = wait_for_completion_interruptible_timeout(
6913 &pAdapter->disconnect_comp_var,
6914 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6915
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306916 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07006917
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07006918 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006919 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006920
6921 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6922 }
6923 }
6924
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306925 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Srinivas Girigowdade697412013-02-14 16:31:48 -08006927#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6928 sme_UpdateBgScanConfigIniChannelList(hHal, (eCsrBand) band);
6929#endif
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306930 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 {
6932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6933 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006934 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 return -EINVAL;
6936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 }
6939 return 0;
6940}
6941
6942static int iw_set_band_config(struct net_device *dev,
6943 struct iw_request_info *info,
6944 union iwreq_data *wrqu, char *extra)
6945{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006946 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006947 tANI_U8 *ptr = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 int ret = 0;
6949
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006951
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006952 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6953 {
6954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6955 "%s:LOGP in Progress. Ignore!!!", __func__);
6956 return -EBUSY;
6957 }
6958
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 if (memcmp(ptr, "SETBAND ", 8) == 0)
6960 {
6961 /* Change band request received */
6962 ret = hdd_setBand_helper(dev, ptr);
6963 return ret;
6964
6965 }
6966 return 0;
6967}
6968
6969static int iw_set_power_params_priv(struct net_device *dev,
6970 struct iw_request_info *info,
6971 union iwreq_data *wrqu, char *extra)
6972{
6973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6974 "Set power params Private");
6975 return iw_set_power_params(dev,info,wrqu,extra,0);
6976}
6977
6978
6979
6980/*string based input*/
6981VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
6982 union iwreq_data *wrqu, char *extra, int nOffset)
6983{
6984 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6985 tSirSetPowerParamsReq powerRequest;
6986 char *ptr;
6987 v_U8_t ucType;
6988 v_U32_t uTotalSize, uValue;
6989 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6990
6991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6992 "Power Params data len %d data %s",
6993 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006994 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006995
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006996 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6997 {
6998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6999 "%s:LOGP in Progress. Ignore!!!", __func__);
7000 return -EBUSY;
7001 }
7002
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 if (wrqu->data.length <= nOffset )
7004 {
7005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7006 return VOS_STATUS_E_FAILURE;
7007 }
7008
7009 uTotalSize = wrqu->data.length - nOffset;
7010
7011 /*-----------------------------------------------------------------------
7012 Input is string based and expected to be like this:
7013
7014 <param_type> <param_value> <param_type> <param_value> ...
7015
7016 e.g:
7017 1 2 2 3 3 0 4 1 5 1
7018
7019 e.g. setting just a few:
7020 1 2 4 1
7021
7022 parameter types:
7023 -----------------------------
7024 1 - Ignore DTIM
7025 2 - Listen Interval
7026 3 - Broadcast Multicas Filter
7027 4 - Beacon Early Termination
7028 5 - Beacon Early Termination Interval
7029 -----------------------------------------------------------------------*/
7030 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7031 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7032 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7033 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7034 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7035
Arif Hussain7adce1b2013-11-11 22:59:34 -08007036 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007037
7038 while ( uTotalSize )
7039 {
Wilson Yang6f971452013-10-08 15:00:00 -07007040 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7041 {
7042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7043 "Invalid input parameter type %s",ptr);
7044 return VOS_STATUS_E_FAILURE;
7045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007046
7047 uTotalSize -= nOffset;
7048
7049 if (!uTotalSize)
7050 {
7051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007052 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 ucType, nOffset);
7054 return VOS_STATUS_E_FAILURE;
7055 }
7056
7057 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007058
Jeff Johnson02797792013-10-26 19:17:13 -07007059 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007060 {
7061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7062 "Invalid input parameter value %s",ptr);
7063 return VOS_STATUS_E_FAILURE;
7064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007065
7066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7067 "Power request parameter %d value %d offset %d",
7068 ucType, uValue, nOffset);
7069
7070 switch (ucType)
7071 {
7072 case eSIR_IGNORE_DTIM:
7073 powerRequest.uIgnoreDTIM = uValue;
7074 break;
7075 case eSIR_LISTEN_INTERVAL:
7076 powerRequest.uListenInterval = uValue;
7077 break;
7078 case eSIR_MCAST_BCAST_FILTER:
7079 powerRequest.uBcastMcastFilter = uValue;
7080 break;
7081 case eSIR_ENABLE_BET:
7082 powerRequest.uEnableBET = uValue;
7083 break;
7084 case eSIR_BET_INTERVAL:
7085 powerRequest.uBETInterval = uValue;
7086 break;
7087 default:
7088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007089 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007090 ucType, uValue, nOffset);
7091 return VOS_STATUS_E_FAILURE;
7092 }
7093
7094 uTotalSize -= nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7096 "Power request parameter %d Total size",
7097 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007099 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
7100 if(!(uTotalSize - nOffset) &&
7101 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7102 {
7103 uTotalSize = 0;
7104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007105
7106 }/*Go for as long as we have a valid string*/
7107
7108 /* put the device into full power*/
7109 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7110
7111 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007112 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007113
7114 /* put the device back to power save*/
7115 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7116
7117 return VOS_STATUS_SUCCESS;
7118}/*iw_set_power_params*/
7119
7120
7121// Define the Wireless Extensions to the Linux Network Device structure
7122// A number of these routines are NULL (meaning they are not implemented.)
7123
7124static const iw_handler we_handler[] =
7125{
7126 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7127 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7128 (iw_handler) NULL, /* SIOCSIWNWID */
7129 (iw_handler) NULL, /* SIOCGIWNWID */
7130 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7131 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7132 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7133 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7134 (iw_handler) NULL, /* SIOCSIWSENS */
7135 (iw_handler) NULL, /* SIOCGIWSENS */
7136 (iw_handler) NULL, /* SIOCSIWRANGE */
7137 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7138 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7139 (iw_handler) NULL, /* SIOCGIWPRIV */
7140 (iw_handler) NULL, /* SIOCSIWSTATS */
7141 (iw_handler) NULL, /* SIOCGIWSTATS */
7142 iw_handler_set_spy, /* SIOCSIWSPY */
7143 iw_handler_get_spy, /* SIOCGIWSPY */
7144 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7145 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7146 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7147 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7148 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7149 (iw_handler) NULL, /* SIOCGIWAPLIST */
7150 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7151 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7152 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7153 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7154 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7155 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7156 (iw_handler) NULL, /* -- hole -- */
7157 (iw_handler) NULL, /* -- hole -- */
7158 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7159 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7160 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7161 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7162 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7163 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7164 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7165 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7166 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7167 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7168 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7169 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7170 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7171 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7172 (iw_handler) NULL, /* -- hole -- */
7173 (iw_handler) NULL, /* -- hole -- */
7174 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7175 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7176 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7177 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7178 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7179 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7180 (iw_handler) NULL, /* SIOCSIWPMKSA */
7181};
7182
7183static const iw_handler we_private[] = {
7184
7185 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7186 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7187 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7188 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7189 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7190 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7191 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7192 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7193 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7194 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007195#ifdef FEATURE_OEM_DATA_SUPPORT
7196 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7197 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7198#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007199
7200#ifdef FEATURE_WLAN_WAPI
7201 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7202 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7203 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7204 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7205 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7206 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7207#endif /* FEATURE_WLAN_WAPI */
7208#ifdef WLAN_FEATURE_VOWIFI_11R
7209 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7210#endif
7211 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7212 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7213 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7214#ifdef WLAN_FEATURE_PACKET_FILTERING
7215 ,
7216 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7217#endif
7218#ifdef FEATURE_WLAN_SCAN_PNO
7219 ,
7220 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7221#endif
7222 ,
7223 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7224 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7225 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7226 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007227 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007228};
7229
7230/*Maximum command length can be only 15 */
7231static const struct iw_priv_args we_private_args[] = {
7232
7233 /* handlers for main ioctl */
7234 { WLAN_PRIV_SET_INT_GET_NONE,
7235 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7236 0,
7237 "" },
7238
7239 /* handlers for sub-ioctl */
7240 { WE_SET_11D_STATE,
7241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7242 0,
7243 "set11Dstate" },
7244
7245 { WE_WOWL,
7246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7247 0,
7248 "wowl" },
7249
7250 { WE_SET_POWER,
7251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7252 0,
7253 "setPower" },
7254
7255 { WE_SET_MAX_ASSOC,
7256 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7257 0,
7258 "setMaxAssoc" },
7259
7260 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7262 0,
7263 "setAutoChannel" },
7264
7265 { WE_SET_DATA_INACTIVITY_TO,
7266 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7267 0,
7268 "inactivityTO" },
7269
7270 { WE_SET_MAX_TX_POWER,
7271 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7272 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007273 "setMaxTxPower" },
7274
7275 { WE_SET_MAX_TX_POWER_2_4,
7276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7277 0,
7278 "setTxMaxPower2G" },
7279
7280 { WE_SET_MAX_TX_POWER_5_0,
7281 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7282 0,
7283 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007284
7285 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7286 * as well to keep same syntax as in SAP. Now onwards, STA
7287 * will support both */
7288 { WE_SET_MAX_TX_POWER,
7289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7290 0,
7291 "setTxMaxPower" },
7292
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7294 * 1 = enable and 0 = disable */
7295 {
7296 WE_SET_HIGHER_DTIM_TRANSITION,
7297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7298 0,
7299 "setHDtimTransn" },
7300
7301 { WE_SET_TM_LEVEL,
7302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7303 0,
7304 "setTmLevel" },
7305
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307306 { WE_ENABLE_STRICT_FCC_REG,
7307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7308 0,
7309 "setStrictFCCreg" },
7310
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 /* handlers for main ioctl */
7312 { WLAN_PRIV_SET_NONE_GET_INT,
7313 0,
7314 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7315 "" },
7316
7317 /* handlers for sub-ioctl */
7318 { WE_GET_11D_STATE,
7319 0,
7320 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7321 "get11Dstate" },
7322
7323 { WE_IBSS_STATUS,
7324 0,
7325 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7326 "getAdhocStatus" },
7327
7328 { WE_PMC_STATE,
7329 0,
7330 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7331 "pmcState" },
7332
7333 { WE_GET_WLAN_DBG,
7334 0,
7335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7336 "getwlandbg" },
7337
7338 { WE_MODULE_DOWN_IND,
7339 0,
7340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7341 "moduleDownInd" },
7342
7343 { WE_GET_MAX_ASSOC,
7344 0,
7345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7346 "getMaxAssoc" },
7347
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 { WE_GET_WDI_DBG,
7349 0,
7350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7351 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007352
7353 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7354 0,
7355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7356 "getAutoChannel" },
7357
7358 { WE_GET_CONCURRENCY_MODE,
7359 0,
7360 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7361 "getconcurrency" },
7362
7363 /* handlers for main ioctl */
7364 { WLAN_PRIV_SET_CHAR_GET_NONE,
7365 IW_PRIV_TYPE_CHAR| 512,
7366 0,
7367 "" },
7368
7369 /* handlers for sub-ioctl */
7370 { WE_WOWL_ADD_PTRN,
7371 IW_PRIV_TYPE_CHAR| 512,
7372 0,
7373 "wowlAddPtrn" },
7374
7375 { WE_WOWL_DEL_PTRN,
7376 IW_PRIV_TYPE_CHAR| 512,
7377 0,
7378 "wowlDelPtrn" },
7379
7380#if defined WLAN_FEATURE_VOWIFI
7381 /* handlers for sub-ioctl */
7382 { WE_NEIGHBOR_REPORT_REQUEST,
7383 IW_PRIV_TYPE_CHAR | 512,
7384 0,
7385 "neighbor" },
7386#endif
7387 { WE_SET_AP_WPS_IE,
7388 IW_PRIV_TYPE_CHAR| 512,
7389 0,
7390 "set_ap_wps_ie" },
7391
7392 { WE_SET_CONFIG,
7393 IW_PRIV_TYPE_CHAR| 512,
7394 0,
7395 "setConfig" },
7396
7397 /* handlers for main ioctl */
7398 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7399 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7400 0,
7401 "" },
7402
7403 /* handlers for sub-ioctl */
7404 { WE_SET_WLAN_DBG,
7405 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7406 0,
7407 "setwlandbg" },
7408
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 { WE_SET_WDI_DBG,
7410 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7411 0,
7412 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007413
7414 { WE_SET_SAP_CHANNELS,
7415 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7416 0,
7417 "setsapchannels" },
7418
7419 /* handlers for main ioctl */
7420 { WLAN_PRIV_GET_CHAR_SET_NONE,
7421 0,
7422 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7423 "" },
7424
7425 /* handlers for sub-ioctl */
7426 { WE_WLAN_VERSION,
7427 0,
7428 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7429 "version" },
7430 { WE_GET_STATS,
7431 0,
7432 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7433 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307434 { WE_GET_STATES,
7435 0,
7436 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7437 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 { WE_GET_CFG,
7439 0,
7440 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7441 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007442#ifdef WLAN_FEATURE_11AC
7443 { WE_GET_RSSI,
7444 0,
7445 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7446 "getRSSI" },
7447#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007448#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
7449 { WE_GET_ROAM_RSSI,
7450 0,
7451 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7452 "getRoamRSSI" },
7453#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007454 { WE_GET_WMM_STATUS,
7455 0,
7456 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7457 "getWmmStatus" },
7458 {
7459 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307460 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7462 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007463#ifdef FEATURE_WLAN_TDLS
7464 {
7465 WE_GET_TDLS_PEERS,
7466 0,
7467 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7468 "getTdlsPeers" },
7469#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007470#ifdef WLAN_FEATURE_11W
7471 {
7472 WE_GET_11W_INFO,
7473 0,
7474 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7475 "getPMFInfo" },
7476#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007477 /* handlers for main ioctl */
7478 { WLAN_PRIV_SET_NONE_GET_NONE,
7479 0,
7480 0,
7481 "" },
7482
7483 /* handlers for sub-ioctl */
7484 { WE_CLEAR_STATS,
7485 0,
7486 0,
7487 "clearStats" },
7488 { WE_INIT_AP,
7489 0,
7490 0,
7491 "initAP" },
7492 { WE_STOP_AP,
7493 0,
7494 0,
7495 "exitAP" },
7496 { WE_ENABLE_AMP,
7497 0,
7498 0,
7499 "enableAMP" },
7500 { WE_DISABLE_AMP,
7501 0,
7502 0,
7503 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007504 { WE_ENABLE_DXE_STALL_DETECT,
7505 0,
7506 0,
7507 "dxeStallDetect" },
7508 { WE_DISPLAY_DXE_SNAP_SHOT,
7509 0,
7510 0,
7511 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307512 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7513 0,
7514 0,
7515 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007516 {
7517 WE_SET_REASSOC_TRIGGER,
7518 0,
7519 0,
7520 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007521
7522 /* handlers for main ioctl */
7523 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7524 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7525 0,
7526 "" },
7527
7528 /* handlers for sub-ioctl */
7529 { WE_LOG_DUMP_CMD,
7530 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7531 0,
7532 "dump" },
7533
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007534 /* handlers for sub ioctl */
7535 {
7536 WE_MCC_CONFIG_CREDENTIAL,
7537 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7538 0,
7539 "setMccCrdnl" },
7540
7541 /* handlers for sub ioctl */
7542 {
7543 WE_MCC_CONFIG_PARAMS,
7544 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7545 0,
7546 "setMccConfig" },
7547
Chilam NG571c65a2013-01-19 12:27:36 +05307548#ifdef FEATURE_WLAN_TDLS
7549 /* handlers for sub ioctl */
7550 {
7551 WE_TDLS_CONFIG_PARAMS,
7552 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7553 0,
7554 "setTdlsConfig" },
7555#endif
7556
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 /* handlers for main ioctl */
7558 { WLAN_PRIV_ADD_TSPEC,
7559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7560 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7561 "addTspec" },
7562
7563 /* handlers for main ioctl */
7564 { WLAN_PRIV_DEL_TSPEC,
7565 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7566 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7567 "delTspec" },
7568
7569 /* handlers for main ioctl */
7570 { WLAN_PRIV_GET_TSPEC,
7571 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7573 "getTspec" },
7574
Jeff Johnsone7245742012-09-05 17:12:55 -07007575#ifdef FEATURE_OEM_DATA_SUPPORT
7576 /* handlers for main ioctl - OEM DATA */
7577 {
7578 WLAN_PRIV_SET_OEM_DATA_REQ,
7579 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7580 0,
7581 "set_oem_data_req" },
7582
7583 /* handlers for main ioctl - OEM DATA */
7584 {
7585 WLAN_PRIV_GET_OEM_DATA_RSP,
7586 0,
7587 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7588 "get_oem_data_rsp" },
7589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007590
7591#ifdef FEATURE_WLAN_WAPI
7592 /* handlers for main ioctl SET_WAPI_MODE */
7593 { WLAN_PRIV_SET_WAPI_MODE,
7594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7595 0,
7596 "SET_WAPI_MODE" },
7597
7598 /* handlers for main ioctl GET_WAPI_MODE */
7599 { WLAN_PRIV_GET_WAPI_MODE,
7600 0,
7601 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7602 "GET_WAPI_MODE" },
7603
7604 /* handlers for main ioctl SET_ASSOC_INFO */
7605 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
7606 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
7607 0,
7608 "SET_WAPI_ASSOC" },
7609
7610 /* handlers for main ioctl SET_WAPI_KEY */
7611 { WLAN_PRIV_SET_WAPI_KEY,
7612 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
7613 0,
7614 "SET_WAPI_KEY" },
7615
7616 /* handlers for main ioctl SET_WAPI_BKID */
7617 { WLAN_PRIV_SET_WAPI_BKID,
7618 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7619 0,
7620 "SET_WAPI_BKID" },
7621
7622 /* handlers for main ioctl GET_WAPI_BKID */
7623 { WLAN_PRIV_GET_WAPI_BKID,
7624 0,
7625 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7626 "GET_WAPI_BKID" },
7627#endif /* FEATURE_WLAN_WAPI */
7628
7629 /* handlers for main ioctl - host offload */
7630 {
7631 WLAN_PRIV_SET_HOST_OFFLOAD,
7632 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
7633 0,
7634 "setHostOffload" },
7635
7636 {
7637 WLAN_GET_WLAN_STATISTICS,
7638 0,
7639 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
7640 "getWlanStats" },
7641
7642 {
7643 WLAN_SET_KEEPALIVE_PARAMS,
7644 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
7645 0,
7646 "setKeepAlive" },
7647#ifdef WLAN_FEATURE_PACKET_FILTERING
7648 {
7649 WLAN_SET_PACKET_FILTER_PARAMS,
7650 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
7651 0,
7652 "setPktFilter" },
7653#endif
7654#ifdef FEATURE_WLAN_SCAN_PNO
7655 {
7656 WLAN_SET_PNO,
7657 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7658 0,
7659 "setpno" },
7660#endif
7661 {
7662 WLAN_SET_BAND_CONFIG,
7663 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7664 0,
7665 "SETBAND" },
7666 /* handlers for dynamic MC BC ioctl */
7667 {
7668 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007669 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 0,
7671 "setMCBCFilter" },
7672 {
7673 WLAN_PRIV_CLEAR_MCBC_FILTER,
7674 0,
7675 0,
7676 "clearMCBCFilter" },
7677 {
7678 WLAN_SET_POWER_PARAMS,
7679 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7680 0,
7681 "setpowerparams" },
7682 {
7683 WLAN_GET_LINK_SPEED,
7684 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05307685 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007686};
7687
7688
7689
7690const struct iw_handler_def we_handler_def = {
7691 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
7692 .num_private = sizeof(we_private) / sizeof(we_private[0]),
7693 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
7694
7695 .standard = (iw_handler *)we_handler,
7696 .private = (iw_handler *)we_private,
7697 .private_args = we_private_args,
7698 .get_wireless_stats = get_wireless_stats,
7699};
7700
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007701int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
7702{
7703 v_U32_t cmd = 288; //Command to RIVA
7704 hdd_context_t *pHddCtx = NULL;
7705 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7706 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7707 /*
7708 *configMccParam : specify the bit which needs to be modified
7709 *allowed to update based on wlan_qcom_cfg.ini
7710 * configuration
7711 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
7712 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
7713 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
7714 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
7715 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
7716 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
7717 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
7718 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
7719 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
7720 * Bit 9 : Reserved
7721 */
7722 switch (arg1)
7723 {
7724 //Update MCC SCHEDULE_TIME_SLICE parameter
7725 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
7726 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
7727 {
7728 if((arg2 >= 5) && (arg2 <= 20))
7729 {
7730 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7731 }
7732 else
7733 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007734 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007735 return 0;
7736 }
7737 }
7738 break;
7739
7740 //Update MCC MAX_NULL_SEND_TIME parameter
7741 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
7742 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
7743 {
7744 if((arg2 >= 1) && (arg2 <= 10))
7745 {
7746 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7747 }
7748 else
7749 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007750 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007751 return 0;
7752 }
7753 }
7754 break;
7755
7756 //Update MCC TX_EARLY_STOP_TIME parameter
7757 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
7758 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
7759 {
7760 if((arg2 >= 1) && (arg2 <= 10))
7761 {
7762 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7763 }
7764 else
7765 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007766 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007767 return 0;
7768 }
7769 }
7770 break;
7771
7772 //Update MCC RX_DRAIN_TIME parameter
7773 case MCC_RX_DRAIN_TIME_CFG_PARAM :
7774 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
7775 {
7776 if((arg2 >= 1) && (arg2 <= 10))
7777 {
7778 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7779 }
7780 else
7781 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007782 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007783 return 0;
7784 }
7785 }
7786 break;
7787
7788 //Update MCC CHANNEL_SWITCH_TIME parameter
7789 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
7790 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
7791 {
7792 if((arg2 >= 1) && (arg2 <= 20))
7793 {
7794 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7795 }
7796 else
7797 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007798 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007799 return 0;
7800 }
7801 }
7802 break;
7803
7804 //Update MCC MIN_CHANNEL_TIME parameter
7805 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
7806 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
7807 {
7808 if((arg2 >= 5) && (arg2 <= 20))
7809 {
7810 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7811 }
7812 else
7813 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007814 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007815 return 0;
7816 }
7817 }
7818 break;
7819
7820 //Update MCC PARK_BEFORE_TBTT parameter
7821 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
7822 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
7823 {
7824 if((arg2 >= 1) && (arg2 <= 5))
7825 {
7826 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7827 }
7828 else
7829 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007830 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007831 return 0;
7832 }
7833 }
7834 break;
7835
7836 //Update MCC MIN_AFTER_DTIM parameter
7837 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
7838 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
7839 {
7840 if((arg2 >= 5) && (arg2 <= 15))
7841 {
7842 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7843 }
7844 else
7845 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007846 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007847 return 0;
7848 }
7849 }
7850 break;
7851
7852 //Update MCC TOO_CLOSE_MARGIN parameter
7853 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
7854 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
7855 {
7856 if((arg2 >= 1) && (arg2 <= 3))
7857 {
7858 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7859 }
7860 else
7861 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007862 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007863 return 0;
7864 }
7865 }
7866 break;
7867
7868 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08007869 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007870 __FUNCTION__,arg1);
7871 break;
7872 }
7873 return 0;
7874}
7875
Jeff Johnson295189b2012-06-20 16:38:30 -07007876int hdd_set_wext(hdd_adapter_t *pAdapter)
7877{
7878 hdd_wext_state_t *pwextBuf;
7879 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007880 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007881
7882 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7883
7884 // Now configure the roaming profile links. To SSID and bssid.
7885 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
7886 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
7887
7888 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
7889 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
7890
7891 /*Set the numOfChannels to zero to scan all the channels*/
7892 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
7893 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
7894
7895 /* Default is no encryption */
7896 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
7897 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7898
7899 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
7900 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7901
7902 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
7903
7904 /* Default is no authentication */
7905 pwextBuf->roamProfile.AuthType.numEntries = 1;
7906 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
7907
7908 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
7909 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
7910
7911 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007912 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07007913
7914 hdd_clearRoamProfileIe(pAdapter);
7915
7916 return VOS_STATUS_SUCCESS;
7917
7918 }
7919
7920int hdd_register_wext(struct net_device *dev)
7921 {
7922 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7923 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7924 VOS_STATUS status;
7925
7926 ENTER();
7927
7928 // Zero the memory. This zeros the profile structure.
7929 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
7930
7931 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
7932
7933
7934 status = hdd_set_wext(pAdapter);
7935
7936 if(!VOS_IS_STATUS_SUCCESS(status)) {
7937
Arif Hussain6d2a3322013-11-17 19:50:10 -08007938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007939 return eHAL_STATUS_FAILURE;
7940 }
7941
7942 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
7943 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 return eHAL_STATUS_FAILURE;
7946 }
7947
7948 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
7949 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 return eHAL_STATUS_FAILURE;
7952 }
7953
7954 // Register as a wireless device
7955 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
7956
7957 EXIT();
7958 return 0;
7959}
7960
7961int hdd_UnregisterWext(struct net_device *dev)
7962{
7963#if 0
7964 hdd_wext_state_t *wextBuf;
7965 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7966
7967 ENTER();
7968 // Set up the pointer to the Wireless Extensions state structure
7969 wextBuf = pAdapter->pWextState;
7970
7971 // De-allocate the Wireless Extensions state structure
7972 kfree(wextBuf);
7973
7974 // Clear out the pointer to the Wireless Extensions state structure
7975 pAdapter->pWextState = NULL;
7976
7977 EXIT();
7978#endif
7979 dev->wireless_handlers = NULL;
7980 return 0;
7981}
7982
7983