blob: 289b6ed83fd62ba242b1e93f13edc81f4e0ccbee [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 { \
340 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!\n"); \
341 } \
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,
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700449 ("Rts-Threshold=%d!!\n"), 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,
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700477 ("Frag-Threshold=%d!!\n"), 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,
499 ("Invalid channel no=%d!!\n"), channel);
500 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:
554 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700555 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 rsnType = eANI_BOOLEAN_FALSE;
557 break;
558 }
559 hddLog(LOGE, FL("%s called with authType: %d, returned: %d\n"),
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{
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001181 hddLog( LOG1, "In %s\n", __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:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001320 hddLog(LOG1, "%s returns IW_MODE_INFRA\n", __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:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301325 hddLog(LOG1, "%s returns IW_MODE_ADHOC\n", __func__);
1326 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 break;
1328 case eCSR_BSS_TYPE_ANY:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301329 hddLog(LOG1, "%s returns IW_MODE_AUTO\n", __func__);
1330 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 break;
1332 default:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301333 hddLog(LOG1, "%s returns APMODE_UNKNOWN\n", __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
1364 hddLog(LOG1,"setCHANNEL ioctl\n");
1365
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 {
1370 hddLog( LOGE, "IBSS Associated\n");
1371 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 {
1396 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d\n",
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
1430 hddLog(LOG1,"pRoamProfile->operationChannel = %d\n", wrqu->freq.m);
1431
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
1700 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]\n", genie[0], genie[1]);
1701
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
1713 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
1714 __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. "
1731 "Need bigger buffer space\n");
1732 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. "
1756 "Need bigger buffer space\n");
1757 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
1804 hddLog(LOG1,"getGEN_IE ioctl\n");
1805
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
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001834 hddLog(LOG1,"%s: RSN IE of %d bytes returned\n", __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 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001863 hddLog(LOG1,"%s: Invalid keyId : %d\n",__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 {
2218 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL\n");
2219 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 "
2775 "deep sleep mode\n");
2776 //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
2837 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command\n");
2838 /*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
2861 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command\n");
2862
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,
2906 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002907
2908 /* Wait for completion */
2909 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
2910 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2911
2912 if (lrc <= 0)
2913 {
2914 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002915 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002916 }
2917
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 if( 0 != status )
2919 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002920 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2921 "%s: SME Change Country code fail \n",__func__);
2922 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 }
2924 }
2925 else if( strncasecmp(cmd, "rssi", 4) == 0 )
2926 {
2927 status = iw_get_rssi(dev, info, wrqu, extra);
2928 }
2929 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
2930 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07002931 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002932
Wilson Yang1be3e652013-10-09 15:18:31 -07002933 if (9 < cmd_len)
2934 {
2935 ptr = (char*)(cmd + 9);
2936
2937 }else{
2938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2939 "CMD LENGTH %d is not correct",cmd_len);
2940 return VOS_STATUS_E_FAILURE;
2941 }
2942
2943 if (1 != sscanf(ptr,"%d",&mode))
2944 {
2945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2946 "powermode input %s is not correct",ptr);
2947 return VOS_STATUS_E_FAILURE;
2948 }
2949
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 wlan_hdd_enter_bmps(pAdapter, mode);
2951 /*TODO:Set the power mode*/
2952 }
2953 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
2954 v_U32_t pmc_state;
2955 v_U16_t value;
2956
2957 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
2958 if(pmc_state == BMPS) {
2959 value = DRIVER_POWER_MODE_AUTO;
2960 }
2961 else {
2962 value = DRIVER_POWER_MODE_ACTIVE;
2963 }
2964 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
2965 }
2966 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
2967 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode\n");
2968 /*TODO: set the btcoexmode*/
2969 }
2970 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
2971
2972 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status\n");
2973 /*TODO: Return the btcoex status*/
2974 }
2975 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
2976
2977 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command\n");
2978
2979 /*TODO: Enable Rx data Filter*/
2980 }
2981 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
2982
2983 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command\n");
2984
2985 /*TODO: Disable Rx data Filter*/
2986 }
2987 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
2988
2989 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command\n");
2990 /*TODO: rxfilter-statistics*/
2991 }
2992 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
2993
2994 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add\n");
2995 /*TODO: rxfilter-add*/
2996 }
2997 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
2998
2999 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove\n");
3000 /*TODO: rxfilter-remove*/
3001 }
3002#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003003 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3004 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3005 /*TODO: support pnosetup*/
3006 }
3007 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3008 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3009 /*TODO: support pnoforce*/
3010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3012
3013 hddLog( VOS_TRACE_LEVEL_INFO, "pno\n");
3014 status = iw_set_pno(dev, info, wrqu, extra, 3);
3015 return status;
3016 }
3017 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
3018
3019 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter\n");
3020 status = iw_set_rssi_filter(dev, info, wrqu, extra, 10);
3021 return status;
3022 }
3023#endif /*FEATURE_WLAN_SCAN_PNO*/
3024 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
3025 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams\n");
3026 status = iw_set_power_params(dev, info, wrqu, extra, 11);
3027 return status;
3028 }
3029 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3030 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003031 char *ptr;
3032
3033 if (18 < cmd_len)
3034 {
3035 ptr = (char*)(cmd + 18);
3036 }else{
3037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3038 "CMD LENGTH %d is not correct",cmd_len);
3039 return VOS_STATUS_E_FAILURE;
3040 }
3041
Jeff Johnson02797792013-10-26 19:17:13 -07003042 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003043 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3044 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3045 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3046 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3047 {
3048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3049 "CONFIG-TX-TRACKING %s input is not correct",ptr);
3050 return VOS_STATUS_E_FAILURE;
3051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003052
3053 // parameters checking
3054 // period has to be larger than 0
3055 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3056 {
3057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
3058 return VOS_STATUS_E_FAILURE;
3059 }
3060
3061 // use default value 5 is the input is not reasonable. in unit of 10%
3062 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3063 {
3064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3065 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3066 }
3067
3068 // default is 5
3069 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3070 {
3071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3072 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3073 }
3074
3075 status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam);
3076 if(status != eHAL_STATUS_SUCCESS){
3077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
3078 }
3079 }
3080 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003081 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3082 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 }
3084done:
3085 /* many of the commands write information back into the command
3086 string using snprintf(). check the return value here in one
3087 place */
3088 if ((ret < 0) || (ret >= cmd_len))
3089 {
3090 /* there was an encoding error or overflow */
3091 status = -EIO;
3092 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003093 else if (ret > 0)
3094 {
3095 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3096 {
3097 hddLog(VOS_TRACE_LEVEL_ERROR,
3098 "%s: failed to copy data to user buffer", __func__);
3099 return -EFAULT;
3100 }
3101 wrqu->data.length = ret;
3102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003103
3104 if (ioctl_debug)
3105 {
3106 pr_info("%s: rsp [%s] len [%d] status %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003107 __func__, cmd, wrqu->data.length, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 }
3109 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003110}
3111
3112static int iw_set_nick(struct net_device *dev,
3113 struct iw_request_info *info,
3114 union iwreq_data *wrqu, char *extra)
3115{
3116 ENTER();
3117 return 0;
3118}
3119
3120static int iw_get_nick(struct net_device *dev,
3121 struct iw_request_info *info,
3122 union iwreq_data *wrqu, char *extra)
3123{
3124 ENTER();
3125 return 0;
3126}
3127
3128static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3129{
3130 ENTER();
3131 return NULL;
3132}
3133
3134static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3135 union iwreq_data *wrqu,char *extra)
3136
3137{
3138 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3139 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3140 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3141 struct iw_point *encoderq = &(wrqu->encoding);
3142 v_U32_t keyId;
3143 v_U8_t key_length;
3144 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3145 v_BOOL_t fKeyPresent = 0;
3146 int i;
3147 eHalStatus status = eHAL_STATUS_SUCCESS;
3148
3149
3150 ENTER();
3151
3152 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3153 {
3154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3155 "%s:LOGP in Progress. Ignore!!!",__func__);
3156 return 0;
3157 }
3158
3159
3160 keyId = encoderq->flags & IW_ENCODE_INDEX;
3161
3162 if(keyId)
3163 {
3164 if(keyId > MAX_WEP_KEYS)
3165 {
3166 return -EINVAL;
3167 }
3168
3169 fKeyPresent = 1;
3170 keyId--;
3171 }
3172 else
3173 {
3174 fKeyPresent = 0;
3175 }
3176
3177
3178 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3179 {
3180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****\n");
3181 if(!fKeyPresent) {
3182
3183 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3184
3185 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3186 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3187 }
3188 }
3189 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3190 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3191 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3192 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3193
3194 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3195 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3196
3197 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3198 {
3199 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3200 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003201 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3203 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3204 }
3205
3206 return status;
3207
3208 }
3209
3210 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3211 {
3212 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3213
3214 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3215
3216 }
3217
3218
3219 if(wrqu->data.length > 0)
3220 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003221 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222
3223 key_length = wrqu->data.length;
3224
3225 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3226
3227 if(5 == key_length)
3228 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003229 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003230
3231 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3232 {
3233 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3234 }
3235 else
3236 {
3237 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3238 }
3239 }
3240 else if(13 == key_length)
3241 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003242 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243
3244 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3245 {
3246 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3247 }
3248 else
3249 {
3250 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3251 }
3252 }
3253 else
3254 {
3255 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003256 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 return -EINVAL;
3258 }
3259
3260 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3261 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3262 pWextState->roamProfile.EncryptionType.numEntries = 1;
3263 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3264 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3265 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3266
3267 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3268 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3269 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3270 {
3271
3272 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3273
3274 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3275 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3276
3277 return status;
3278 }
3279 }
3280
3281 return 0;
3282}
3283
3284static int iw_get_encodeext(struct net_device *dev,
3285 struct iw_request_info *info,
3286 struct iw_point *dwrq,
3287 char *extra)
3288{
3289 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3290 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3291 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3292 int keyId;
3293 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3294 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3295 int i;
3296
3297 ENTER();
3298
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003299 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3300 {
3301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3302 "%s:LOGP in Progress. Ignore!!!", __func__);
3303 return -EBUSY;
3304 }
3305
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 keyId = pRoamProfile->Keys.defaultIndex;
3307
3308 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3309 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003310 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 return -EINVAL;
3312 }
3313
3314 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3315 {
3316 dwrq->flags |= IW_ENCODE_ENABLED;
3317 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303318 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3319 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 }
3321 else
3322 {
3323 dwrq->flags |= IW_ENCODE_DISABLED;
3324 }
3325
3326 for(i=0; i < MAX_WEP_KEYS; i++)
3327 {
3328 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3329 {
3330 continue;
3331 }
3332 else
3333 {
3334 break;
3335 }
3336 }
3337
3338 if(MAX_WEP_KEYS == i)
3339 {
3340 dwrq->flags |= IW_ENCODE_NOKEY;
3341 }
3342 else
3343 {
3344 dwrq->flags |= IW_ENCODE_ENABLED;
3345 }
3346
3347 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3348
3349 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3350 {
3351 dwrq->flags |= IW_ENCODE_DISABLED;
3352 }
3353
3354 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3355
3356 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3357 {
3358 dwrq->flags |= IW_ENCODE_OPEN;
3359 }
3360 else
3361 {
3362 dwrq->flags |= IW_ENCODE_RESTRICTED;
3363 }
3364 EXIT();
3365 return 0;
3366
3367}
3368
3369static int iw_set_encodeext(struct net_device *dev,
3370 struct iw_request_info *info,
3371 union iwreq_data *wrqu, char *extra)
3372{
3373 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3374 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3375 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3376 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3377
3378 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3379 v_U32_t status = 0;
3380
3381 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3382
3383 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3384
3385 int key_index;
3386 struct iw_point *encoding = &wrqu->encoding;
3387 tCsrRoamSetKey setKey;
3388 v_U32_t roamId= 0xFF;
3389 VOS_STATUS vos_status;
3390
3391 ENTER();
3392
3393 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3394 {
3395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3396 "%s:LOGP in Progress. Ignore!!!",__func__);
3397 return 0;
3398 }
3399
3400 key_index = encoding->flags & IW_ENCODE_INDEX;
3401
3402 if(key_index > 0) {
3403
3404 /*Convert from 1-based to 0-based keying*/
3405 key_index--;
3406 }
3407 if(!ext->key_len) {
3408
3409 /*Set the encrytion type to NONE*/
3410 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3411 return status;
3412 }
3413
3414 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3415 (IW_ENCODE_ALG_WEP == ext->alg))
3416 {
3417 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3418
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003419 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s \n"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 return -EINVAL;
3421 }
3422 else {
3423 /*Static wep, update the roam profile with the keys */
3424 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3425 key_index < CSR_MAX_NUM_KEY) {
3426 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3427 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3428
3429 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3430 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3431
3432 }
3433 }
3434 return status;
3435 }
3436
3437 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3438
3439 setKey.keyId = key_index;
3440 setKey.keyLength = ext->key_len;
3441
3442 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3443 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3444 }
3445
3446 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3447 /*Key direction for group is RX only*/
3448 setKey.keyDirection = eSIR_RX_ONLY;
3449 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3450 }
3451 else {
3452
3453 setKey.keyDirection = eSIR_TX_RX;
3454 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3455 }
3456
3457 /*For supplicant pae role is zero*/
3458 setKey.paeRole = 0;
3459
3460 switch(ext->alg)
3461 {
3462 case IW_ENCODE_ALG_NONE:
3463 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3464 break;
3465
3466 case IW_ENCODE_ALG_WEP:
3467 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3468 break;
3469
3470 case IW_ENCODE_ALG_TKIP:
3471 {
3472 v_U8_t *pKey = &setKey.Key[0];
3473
3474 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3475
3476 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3477
3478 /*Supplicant sends the 32bytes key in this order
3479
3480 |--------------|----------|----------|
3481 | Tk1 |TX-MIC | RX Mic |
3482 |--------------|----------|----------|
3483 <---16bytes---><--8bytes--><--8bytes-->
3484
3485 */
3486 /*Sme expects the 32 bytes key to be in the below order
3487
3488 |--------------|----------|----------|
3489 | Tk1 |RX-MIC | TX Mic |
3490 |--------------|----------|----------|
3491 <---16bytes---><--8bytes--><--8bytes-->
3492 */
3493 /* Copy the Temporal Key 1 (TK1) */
3494 vos_mem_copy(pKey,ext->key,16);
3495
3496 /*Copy the rx mic first*/
3497 vos_mem_copy(&pKey[16],&ext->key[24],8);
3498
3499 /*Copy the tx mic */
3500 vos_mem_copy(&pKey[24],&ext->key[16],8);
3501
3502 }
3503 break;
3504
3505 case IW_ENCODE_ALG_CCMP:
3506 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3507 break;
3508
3509#ifdef FEATURE_WLAN_CCX
3510#define IW_ENCODE_ALG_KRK 6
3511 case IW_ENCODE_ALG_KRK:
3512 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3513 break;
3514#endif /* FEATURE_WLAN_CCX */
3515
3516 default:
3517 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3518 break;
3519 }
3520
3521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003522 ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d \n"),__func__,(int)ext->alg,(int)ext->key_len,setKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003523
3524#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303525 /* The supplicant may attempt to set the PTK once pre-authentication
3526 is done. Save the key in the UMAC and include it in the ADD
3527 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303529 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303531 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3532 "%s: Update PreAuth Key success", __func__);
3533 return 0;
3534 }
3535 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3536 {
3537 hddLog(VOS_TRACE_LEVEL_ERROR,
3538 "%s: Update PreAuth Key failed", __func__);
3539 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 }
3541#endif /* WLAN_FEATURE_VOWIFI_11R */
3542
3543 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3544
3545 vos_status = wlan_hdd_check_ula_done(pAdapter);
3546 if ( vos_status != VOS_STATUS_SUCCESS )
3547 {
3548 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3549 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3550 __LINE__, vos_status );
3551
3552 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3553 }
3554
3555 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3556
3557 if ( halStatus != eHAL_STATUS_SUCCESS )
3558 {
3559 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3560 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3561 __LINE__, halStatus );
3562
3563 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3564 }
3565
3566 return halStatus;
3567}
3568
3569static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3570 union iwreq_data *wrqu, char *extra)
3571{
3572 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3573 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3574
3575 ENTER();
3576
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003577 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3578 {
3579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3580 "%s:LOGP in Progress. Ignore!!!", __func__);
3581 return -EBUSY;
3582 }
3583
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3585 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3586
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!\n"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003588
3589 return -EINVAL;
3590 }
3591
3592 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3593
3594 if((wrqu->retry.flags & IW_RETRY_LONG))
3595 {
3596 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3597 {
3598 return -EIO;
3599 }
3600 }
3601 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3602 {
3603 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3604 {
3605 return -EIO;
3606 }
3607 }
3608 }
3609 else
3610 {
3611 return -EOPNOTSUPP;
3612 }
3613
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!\n"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003615
3616 EXIT();
3617
3618 return 0;
3619
3620}
3621
3622static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3623 union iwreq_data *wrqu, char *extra)
3624{
3625 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3626 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3627 v_U32_t retry = 0;
3628
3629 ENTER();
3630
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003631 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3632 {
3633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3634 "%s:LOGP in Progress. Ignore!!!", __func__);
3635 return -EBUSY;
3636 }
3637
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 if((wrqu->retry.flags & IW_RETRY_LONG))
3639 {
3640 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3641
3642 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3643 {
3644 return -EIO;
3645 }
3646
3647 wrqu->retry.value = retry;
3648 }
3649 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3650 {
3651 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3652
3653 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3654 {
3655 return -EIO;
3656 }
3657
3658 wrqu->retry.value = retry;
3659 }
3660 else {
3661 return -EOPNOTSUPP;
3662 }
3663
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!\n"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003665
3666 EXIT();
3667
3668 return 0;
3669}
3670
3671static int iw_set_mlme(struct net_device *dev,
3672 struct iw_request_info *info,
3673 union iwreq_data *wrqu,
3674 char *extra)
3675{
3676 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3677 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3678 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3679 eHalStatus status = eHAL_STATUS_SUCCESS;
3680
3681 ENTER();
3682
3683 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3684 {
3685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3686 "%s:LOGP in Progress. Ignore!!!",__func__);
3687 return 0;
3688 }
3689
3690 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3691 switch (mlme->cmd) {
3692 case IW_MLME_DISASSOC:
3693 case IW_MLME_DEAUTH:
3694
3695 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3696 {
3697 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3698
3699 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3700 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3701
3702 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3703 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3704
Jeff Johnson43971f52012-07-17 12:26:56 -07003705 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3707 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3708 else
3709 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003710 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003711
3712 /* Resetting authKeyMgmt */
3713 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3714
3715 netif_tx_disable(dev);
3716 netif_carrier_off(dev);
3717
3718 }
3719 else
3720 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003721 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 }
3723 break;
3724 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003725 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 return -EINVAL;
3727 }//end of switch
3728
3729 EXIT();
3730
3731 return status;
3732
3733}
3734
3735/* set param sub-ioctls */
3736static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3737 union iwreq_data *wrqu, char *extra)
3738{
3739 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3740 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3741 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3742 int *value = (int *)extra;
3743 int sub_cmd = value[0];
3744 int set_value = value[1];
3745 int ret = 0; /* success */
3746 int enable_pbm, enable_mp;
3747#ifdef CONFIG_HAS_EARLYSUSPEND
3748 v_U8_t nEnableSuspendOld;
3749#endif
3750 INIT_COMPLETION(pWextState->completion_var);
3751
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003752 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3753 {
3754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3755 "%s:LOGP in Progress. Ignore!!!", __func__);
3756 return -EBUSY;
3757 }
3758
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 switch(sub_cmd)
3760 {
3761 case WE_SET_11D_STATE:
3762 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003763 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07003764 memset(&smeConfig, 0x00, sizeof(smeConfig));
3765
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3767
3768 sme_GetConfigParam(hHal,&smeConfig);
3769 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3770
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!\n"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07003772
3773 sme_UpdateConfig(hHal,&smeConfig);
3774 }
3775 else {
3776 return -EINVAL;
3777 }
3778 break;
3779 }
3780
3781 case WE_WOWL:
3782 {
3783 switch (set_value)
3784 {
3785 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003786 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 break;
3788 case 0x01:
3789 case 0x02:
3790 case 0x03:
3791 enable_mp = (set_value & 0x01) ? 1 : 0;
3792 enable_pbm = (set_value & 0x02) ? 1 : 0;
3793 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s\n",
3794 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3795 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3796 break;
3797 default:
3798 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL\n", set_value);
3799 ret = -EINVAL;
3800 break;
3801 }
3802
3803 break;
3804 }
3805 case WE_SET_POWER:
3806 {
3807 switch (set_value)
3808 {
3809 case 0: //Full Power
3810 {
3811 struct statsContext context;
3812 eHalStatus status;
3813
3814 init_completion(&context.completion);
3815
3816 context.pAdapter = pAdapter;
3817 context.magic = POWER_CONTEXT_MAGIC;
3818
3819 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3820 iw_power_callback_fn, &context,
3821 eSME_FULL_PWR_NEEDED_BY_HDD);
3822 if(eHAL_STATUS_PMC_PENDING == status)
3823 {
3824 int lrc = wait_for_completion_interruptible_timeout(
3825 &context.completion,
3826 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3827 context.magic = 0;
3828 if (lrc <= 0)
3829 {
3830 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3831 "requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003832 __func__, (0 == lrc) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 "timeout" : "interrupt");
3834 /* there is a race condition such that the callback
3835 function could be executing at the same time we are. of
3836 primary concern is if the callback function had already
3837 verified the "magic" but hasn't yet set the completion
3838 variable. Since the completion variable is on our
3839 stack, we'll delay just a bit to make sure the data is
3840 still valid if that is the case */
3841 msleep(50);
3842 /* we'll now returned a cached value below */
3843 }
3844 }
3845 hddLog(LOGE, "iwpriv Full Power completed\n");
3846 break;
3847 }
3848 case 1: //Enable BMPS
3849 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3850 break;
3851 case 2: //Disable BMPS
3852 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3853 break;
3854 case 3: //Request Bmps
3855 {
3856 struct statsContext context;
3857 eHalStatus status;
3858
3859 init_completion(&context.completion);
3860
3861 context.pAdapter = pAdapter;
3862 context.magic = POWER_CONTEXT_MAGIC;
3863
3864 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3865 iw_power_callback_fn, &context);
3866 if(eHAL_STATUS_PMC_PENDING == status)
3867 {
3868 int lrc = wait_for_completion_interruptible_timeout(
3869 &context.completion,
3870 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3871 context.magic = 0;
3872 if (lrc <= 0)
3873 {
3874 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3875 "requesting BMPS",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003876 __func__, (0 == lrc) ? "timeout" :
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 "interrupt");
3878 /* there is a race condition such that the callback
3879 function could be executing at the same time we are. of
3880 primary concern is if the callback function had already
3881 verified the "magic" but hasn't yet set the completion
3882 variable. Since the completion variable is on our
3883 stack, we'll delay just a bit to make sure the data is
3884 still valid if that is the case */
3885 msleep(50);
3886 /* we'll now returned a cached value below */
3887 }
3888 }
3889 hddLog(LOGE, "iwpriv Request BMPS completed\n");
3890 break;
3891 }
3892 case 4: //Enable IMPS
3893 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3894 break;
3895 case 5: //Disable IMPS
3896 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3897 break;
3898 case 6: //Enable Standby
3899 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3900 break;
3901 case 7: //Disable Standby
3902 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3903 break;
3904 case 8: //Request Standby
3905#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003906#endif
3907 break;
3908 case 9: //Start Auto Bmps Timer
3909 sme_StartAutoBmpsTimer(hHal);
3910 break;
3911 case 10://Stop Auto BMPS Timer
3912 sme_StopAutoBmpsTimer(hHal);
3913 break;
3914#ifdef CONFIG_HAS_EARLYSUSPEND
3915 case 11://suspend to standby
3916#ifdef CONFIG_HAS_EARLYSUSPEND
3917 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3918 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3920#endif
3921 break;
3922 case 12://suspend to deep sleep
3923#ifdef CONFIG_HAS_EARLYSUSPEND
3924 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3925 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3927#endif
3928 break;
3929 case 13://resume from suspend
3930#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003931#endif
3932 break;
3933#endif
3934 case 14://reset wlan (power down/power up)
3935 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
3936 break;
3937 default:
3938 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL\n", set_value);
3939 ret = -EINVAL;
3940 break;
3941 }
3942 break;
3943 }
3944
3945 case WE_SET_MAX_ASSOC:
3946 {
3947 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
3948 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
3949 {
3950 ret = -EINVAL;
3951 }
3952 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
3953 set_value, NULL, eANI_BOOLEAN_FALSE)
3954 != eHAL_STATUS_SUCCESS )
3955 {
3956 ret = -EIO;
3957 }
3958 break;
3959 }
3960
3961 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
3962 {
3963 if( 0 == set_value )
3964 {
3965 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
3966 }
3967 else if ( 1 == set_value )
3968 {
3969 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
3970 }
3971 else
3972 {
3973 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL\n", set_value);
3974 ret = -EINVAL;
3975 }
3976 break;
3977 }
3978
3979 case WE_SET_DATA_INACTIVITY_TO:
3980 {
3981 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
3982 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
3983 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
3984 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
3985 set_value,
3986 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
3987 {
3988 hddLog(LOGE,"Failure: Could not pass on "
3989 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
3990 "to CCM\n");
3991 ret = -EINVAL;
3992 }
3993 break;
3994 }
3995 case WE_SET_MAX_TX_POWER:
3996 {
3997 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3998 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3999
4000 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4001 __func__, set_value);
4002 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4003 eHAL_STATUS_SUCCESS )
4004 {
4005 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4006 __func__);
4007 return -EIO;
4008 }
4009
4010 break;
4011 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004012 case WE_SET_MAX_TX_POWER_2_4:
4013 {
4014 hddLog(VOS_TRACE_LEVEL_INFO,
4015 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4016 __func__, set_value);
4017 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4018 eHAL_STATUS_SUCCESS)
4019 {
4020 hddLog(VOS_TRACE_LEVEL_ERROR,
4021 "%s: Setting maximum tx power failed for 2.4 GHz band",
4022 __func__);
4023 return -EIO;
4024 }
4025
4026 break;
4027 }
4028 case WE_SET_MAX_TX_POWER_5_0:
4029 {
4030 hddLog(VOS_TRACE_LEVEL_INFO,
4031 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4032 __func__, set_value);
4033 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4034 eHAL_STATUS_SUCCESS)
4035 {
4036 hddLog(VOS_TRACE_LEVEL_ERROR,
4037 "%s: Setting maximum tx power failed for 5.0 GHz band",
4038 __func__);
4039 return -EIO;
4040 }
4041
4042 break;
4043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 case WE_SET_HIGHER_DTIM_TRANSITION:
4045 {
4046 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4047 (set_value == eANI_BOOLEAN_TRUE)))
4048 {
4049 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4050 ret = -EINVAL;
4051 }
4052 else
4053 {
4054 if(pAdapter->higherDtimTransition != set_value)
4055 {
4056 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004057 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 }
4059 }
4060
4061 break;
4062 }
4063
4064 case WE_SET_TM_LEVEL:
4065 {
4066 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4067 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
4068 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4069
4070 break;
4071 }
4072
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304073 case WE_ENABLE_STRICT_FCC_REG:
4074 {
4075 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4076 struct wiphy *wiphy = NULL;
4077 long lrc;
4078 int status;
4079
4080 wiphy = hddCtxt->wiphy;
4081 if(wiphy == NULL)
4082 {
4083 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4084 break;
4085 }
4086 init_completion(&hddCtxt->wiphy_channel_update_event);
4087
4088 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4089
4090 status = regulatory_hint(wiphy, "00");
4091 if(status < 0)
4092 {
4093 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4094 break;
4095 }
4096
4097 /* Wait for completion */
4098 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4099 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4100 if (lrc <= 0)
4101 {
4102 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4103 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4104 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4105 }
4106 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4107
4108 break;
4109 }
4110
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 default:
4112 {
4113 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d \n",
4114 sub_cmd, set_value);
4115 break;
4116 }
4117 }
4118
4119 return ret;
4120}
4121
4122/* set param sub-ioctls */
4123static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4124 union iwreq_data *wrqu, char *extra)
4125{
4126 VOS_STATUS vstatus;
4127 int sub_cmd = wrqu->data.flags;
4128 int ret = 0; /* success */
4129 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4130 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4131#ifdef WLAN_FEATURE_VOWIFI
4132 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4133#endif /* WLAN_FEATURE_VOWIFI */
4134
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004135 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 -08004136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received data %s", __func__, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004138 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4139 {
4140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4141 "%s:LOGP in Progress. Ignore!!!", __func__);
4142 return -EBUSY;
4143 }
4144
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 switch(sub_cmd)
4146 {
4147 case WE_WOWL_ADD_PTRN:
4148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN\n");
Arif Hussain7adce1b2013-11-11 22:59:34 -08004149 hdd_add_wowl_ptrn(pAdapter, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 break;
4151 case WE_WOWL_DEL_PTRN:
4152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN\n");
Arif Hussain7adce1b2013-11-11 22:59:34 -08004153 hdd_del_wowl_ptrn(pAdapter, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 break;
4155#if defined WLAN_FEATURE_VOWIFI
4156 case WE_NEIGHBOR_REPORT_REQUEST:
4157 {
4158 tRrmNeighborReq neighborReq;
4159 tRrmNeighborRspCallbackInfo callbackInfo;
4160
4161 if (pConfig->fRrmEnable)
4162 {
4163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request\n");
4164 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4165 if( !neighborReq.no_ssid )
4166 {
4167 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain7adce1b2013-11-11 22:59:34 -08004168 vos_mem_copy( neighborReq.ssid.ssId, extra, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 }
4170
4171 callbackInfo.neighborRspCallback = NULL;
4172 callbackInfo.neighborRspCallbackContext = NULL;
4173 callbackInfo.timeout = 5000; //5 seconds
4174 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4175 }
4176 else
4177 {
4178 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled\n", __func__);
4179 ret = -EINVAL;
4180 }
4181 }
4182 break;
4183#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 case WE_SET_AP_WPS_IE:
4185 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain7adce1b2013-11-11 22:59:34 -08004186 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), extra, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 case WE_SET_CONFIG:
Arif Hussain7adce1b2013-11-11 22:59:34 -08004189 vstatus = hdd_execute_config_command(pHddCtx, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 if (VOS_STATUS_SUCCESS != vstatus)
4191 {
4192 ret = -EINVAL;
4193 }
4194 break;
4195 default:
4196 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004197 hddLog(LOGE, "%s: Invalid sub command %d\n",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 ret = -EINVAL;
4199 break;
4200 }
4201 }
4202 return ret;
4203}
4204
4205/* get param sub-ioctls */
4206static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4207 union iwreq_data *wrqu, char *extra)
4208{
4209 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4210 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4211 int *value = (int *)extra;
4212 int ret = 0; /* success */
4213
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004214 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4215 {
4216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4217 "%s:LOGP in Progress. Ignore!!!", __func__);
4218 return -EBUSY;
4219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004220
4221 switch (value[0])
4222 {
4223 case WE_GET_11D_STATE:
4224 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004225 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304227
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4229
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!\n"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004231
4232 break;
4233 }
4234
4235 case WE_IBSS_STATUS:
4236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****\n");
4237 break;
4238
4239 case WE_PMC_STATE:
4240 {
4241 *value = pmcGetPmcState(hHal);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!\n"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 break;
4244 }
4245 case WE_GET_WLAN_DBG:
4246 {
4247 vos_trace_display();
4248 *value = 0;
4249 break;
4250 }
4251 case WE_MODULE_DOWN_IND:
4252 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4255#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4258#endif
4259 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4260
4261 *value = 0;
4262 break;
4263 }
4264 case WE_GET_MAX_ASSOC:
4265 {
4266 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4267 {
4268 ret = -EIO;
4269 }
4270 break;
4271 }
4272
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 case WE_GET_WDI_DBG:
4274 {
4275 wpalTraceDisplay();
4276 *value = 0;
4277 break;
4278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004279
4280 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4281 {
4282 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4283 break;
4284 }
4285 case WE_GET_CONCURRENCY_MODE:
4286 {
4287 *value = hdd_get_concurrency_mode ( );
4288
4289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d \n"),*value);
4290 break;
4291 }
4292
4293 default:
4294 {
4295 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4296 break;
4297 }
4298 }
4299
4300 return ret;
4301}
4302
4303/* set param sub-ioctls */
4304int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4305 union iwreq_data *wrqu, char *extra)
4306{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004307 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 int *value = (int *)extra;
4309 int sub_cmd = value[0];
4310 int ret = 0;
4311
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004312 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4313 {
4314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4315 "%s:LOGP in Progress. Ignore!!!", __func__);
4316 return -EBUSY;
4317 }
4318
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 switch(sub_cmd)
4320 {
4321 case WE_SET_WLAN_DBG:
4322 {
4323 vos_trace_setValue( value[1], value[2], value[3]);
4324 break;
4325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 case WE_SET_WDI_DBG:
4327 {
4328 wpalTraceSetLevel( value[1], value[2], value[3]);
4329 break;
4330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 case WE_SET_SAP_CHANNELS:
4332 {
4333 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4334 break;
4335 }
4336
4337 default:
4338 {
4339 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4340 break;
4341 }
4342 }
4343 return ret;
4344}
4345
4346static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4347 union iwreq_data *wrqu, char *extra)
4348{
4349 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4350 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004351#ifdef WLAN_FEATURE_11W
4352 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4353#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004354
Yue Ma3ede6052013-08-29 00:33:26 -07004355 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4356 {
4357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4358 "%s: HDD Context is NULL!", __func__);
4359
4360 return -EINVAL;
4361 }
4362
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004363 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4364 {
4365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4366 "%s:LOGP in Progress. Ignore!!!", __func__);
4367 return -EBUSY;
4368 }
4369
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 switch(sub_cmd)
4371 {
4372 case WE_WLAN_VERSION:
4373 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004374 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 break;
4376 }
4377
4378 case WE_GET_STATS:
4379 {
4380 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4381 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4382 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4383
4384 snprintf(extra, WE_MAX_STR_LEN,
4385 "\nTransmit"
4386 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4387 "\n dropped BK %u, BE %u, VI %u, VO %u"
4388 "\n classified BK %u, BE %u, VI %u, VO %u"
4389 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4390 "\n queued BK %u, BE %u, VI %u, VO %u"
4391 "\nfetched %u, empty %u, lowres %u, deqerr %u"
4392 "\ndequeued %u, depressured %u, completed %u, flushed %u"
4393 "\n fetched BK %u, BE %u, VI %u, VO %u"
4394 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4395 "\n depressured BK %u, BE %u, VI %u, VO %u"
4396 "\n flushed BK %u, BE %u, VI %u, VO %u"
4397 "\n\nReceive"
4398 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4399 "\n\nResetsStats"
4400 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4401 "\n",
4402 pStats->txXmitCalled,
4403 pStats->txXmitDropped,
4404 pStats->txXmitBackPressured,
4405 pStats->txXmitQueued,
4406
4407 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4408 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4409 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4410 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4411
4412 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4413 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4414 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4415 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4416
4417 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4418 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4419 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4420 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4421
4422 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4423 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4424 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4425 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4426
4427 pStats->txFetched,
4428 pStats->txFetchEmpty,
4429 pStats->txFetchLowResources,
4430 pStats->txFetchDequeueError,
4431
4432 pStats->txFetchDequeued,
4433 pStats->txFetchDePressured,
4434 pStats->txCompleted,
4435 pStats->txFlushed,
4436
4437 pStats->txFetchedAC[WLANTL_AC_BK],
4438 pStats->txFetchedAC[WLANTL_AC_BE],
4439 pStats->txFetchedAC[WLANTL_AC_VI],
4440 pStats->txFetchedAC[WLANTL_AC_VO],
4441
4442 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4443 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4444 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4445 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4446
4447 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4448 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4449 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4450 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4451
4452 pStats->txFlushedAC[WLANTL_AC_BK],
4453 pStats->txFlushedAC[WLANTL_AC_BE],
4454 pStats->txFlushedAC[WLANTL_AC_VI],
4455 pStats->txFlushedAC[WLANTL_AC_VO],
4456
4457 pStats->rxChains,
4458 pStats->rxPackets,
4459 pStats->rxDropped,
4460 pStats->rxDelivered,
4461 pStats->rxRefused,
4462
4463 pResetStats->totalLogpResets,
4464 pResetStats->totalCMD53Failures,
4465 pResetStats->totalMutexReadFailures,
4466 pResetStats->totalMIFErrorFailures,
4467 pResetStats->totalFWHearbeatFailures,
4468 pResetStats->totalUnknownExceptions
4469 );
4470 wrqu->data.length = strlen(extra)+1;
4471 break;
4472 }
4473
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304474/* The case prints the current state of the HDD, SME, CSR, PE, TL
4475 *it can be extended for WDI Global State as well.
4476 *And currently it only checks P2P_CLIENT adapter.
4477 *P2P_DEVICE and P2P_GO have not been added as of now.
4478*/
4479 case WE_GET_STATES:
4480 {
4481 int buf = 0, len = 0;
4482 int adapter_num = 0;
4483 int count = 0, check = 1;
4484
4485 tANI_U16 tlState;
4486 tHalHandle hHal;
4487 tpAniSirGlobal pMac;
4488 hdd_station_ctx_t *pHddStaCtx;
4489
4490 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4491 hdd_adapter_t *useAdapter = NULL;
4492
4493 /* Print wlan0 or p2p0 states based on the adapter_num
4494 *by using the correct adapter
4495 */
4496 while ( adapter_num < 2 )
4497 {
4498 if ( WLAN_ADAPTER == adapter_num )
4499 {
4500 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004501 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304502 "\n\n wlan0 States:-");
4503 len += buf;
4504 }
4505 else if ( P2P_ADAPTER == adapter_num )
4506 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004507 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304508 "\n\n p2p0 States:-");
4509 len += buf;
4510
4511 if( !pHddCtx )
4512 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004513 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304514 "\n pHddCtx is NULL");
4515 len += buf;
4516 break;
4517 }
4518
4519 /*Printing p2p0 states only in the case when the device is
4520 configured as a p2p_client*/
4521 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4522 if ( !useAdapter )
4523 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004524 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304525 "\n Device not configured as P2P_CLIENT.");
4526 len += buf;
4527 break;
4528 }
4529 }
4530
4531 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
4532 pMac = PMAC_STRUCT( hHal );
4533 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4534 if( !pHddStaCtx )
4535 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004536 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304537 "\n pHddStaCtx is NULL");
4538 len += buf;
4539 break;
4540 }
4541
4542 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4543
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004544 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304545 "\n HDD Conn State - %s "
4546 "\n \n SME State:"
4547 "\n Neighbour Roam State - %s"
4548 "\n CSR State - %s"
4549 "\n CSR Substate - %s"
4550 "\n \n TL STA %d State: %s",
4551 macTraceGetHDDWlanConnState(
4552 pHddStaCtx->conn_info.connState),
4553 macTraceGetNeighbourRoamState(
4554 pMac->roam.neighborRoamInfo.neighborRoamState),
4555 macTraceGetcsrRoamState(
4556 pMac->roam.curState[useAdapter->sessionId]),
4557 macTraceGetcsrRoamSubState(
4558 pMac->roam.curSubState[useAdapter->sessionId]),
4559 pHddStaCtx->conn_info.staId[0],
4560 macTraceGetTLState(tlState)
4561 );
4562 len += buf;
4563 adapter_num++;
4564 }
4565
4566 /* Printing Lim State starting with global lim states */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004567 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304568 "\n \n LIM STATES:-"
4569 "\n Global Sme State - %s "\
4570 "\n Global mlm State - %s "\
4571 "\n",
4572 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4573 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4574 );
4575 len += buf;
4576
4577 /*printing the PE Sme and Mlm states for valid lim sessions*/
4578 while ( check < 3 && count < 255)
4579 {
4580 if ( pMac->lim.gpSession[count].valid )
4581 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004582 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304583 "\n Lim Valid Session %d:-"
4584 "\n PE Sme State - %s "
4585 "\n PE Mlm State - %s "
4586 "\n",
4587 check,
4588 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4589 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4590 );
4591
4592 len += buf;
4593 check++;
4594 }
4595 count++;
4596 }
4597
4598 wrqu->data.length = strlen(extra)+1;
4599 break;
4600 }
4601
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 case WE_GET_CFG:
4603 {
4604 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4605 wrqu->data.length = strlen(extra)+1;
4606 break;
4607 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004608#ifdef WLAN_FEATURE_11AC
4609 case WE_GET_RSSI:
4610 {
4611 v_S7_t s7Rssi = 0;
4612 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4613 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4614 wrqu->data.length = strlen(extra)+1;
4615 break;
4616 }
4617#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304618
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004619#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4620 case WE_GET_ROAM_RSSI:
4621 {
4622 v_S7_t s7Rssi = 0;
4623 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4624 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4625 wrqu->data.length = strlen(extra)+1;
4626 break;
4627 }
4628#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 case WE_GET_WMM_STATUS:
4630 {
4631 snprintf(extra, WE_MAX_STR_LEN,
4632 "\nDir: 0=up, 1=down, 3=both\n"
4633 "|------------------------|\n"
4634 "|AC | ACM |Admitted| Dir |\n"
4635 "|------------------------|\n"
4636 "|VO | %d | %3s | %d |\n"
4637 "|VI | %d | %3s | %d |\n"
4638 "|BE | %d | %3s | %d |\n"
4639 "|BK | %d | %3s | %d |\n"
4640 "|------------------------|\n",
4641 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4642 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4643 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4644 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4645 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4646 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4647 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4648 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4649 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4650 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4651 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4652 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4653
Jeff Johnsone7245742012-09-05 17:12:55 -07004654
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 wrqu->data.length = strlen(extra)+1;
4656 break;
4657 }
4658 case WE_GET_CHANNEL_LIST:
4659 {
4660 VOS_STATUS status;
4661 v_U8_t i, len;
4662 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004663
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 tChannelListInfo channel_list;
4665
4666 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
4667 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4668 {
4669 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!\n",__func__);
4670 return -EINVAL;
4671 }
4672 buf = extra;
4673
4674 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004675 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4676 * needed = 5 * number of channels. Check ifsufficient
4677 * buffer is available and then proceed to fill the buffer.
4678 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4680 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004681 hddLog(VOS_TRACE_LEVEL_ERROR,
4682 "%s Insufficient Buffer to populate channel list\n",
4683 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004684 return -EINVAL;
4685 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004686 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4687 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 for(i = 0 ; i < channel_list.num_channels; i++)
4689 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004690 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 }
4693 wrqu->data.length = strlen(extra)+1;
4694
4695 break;
4696 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004697#ifdef FEATURE_WLAN_TDLS
4698 case WE_GET_TDLS_PEERS:
4699 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004700 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004701 break;
4702 }
4703#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004704#ifdef WLAN_FEATURE_11W
4705 case WE_GET_11W_INFO:
4706 {
4707 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4708
4709 snprintf(extra, WE_MAX_STR_LEN,
4710 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4711 "\n Number of Unprotected Disassocs %d"
4712 "\n Number of Unprotected Deauths %d",
4713 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4714 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4715 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4716 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4717 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4718
4719 wrqu->data.length = strlen(extra)+1;
4720 break;
4721 }
4722#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304723 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 {
4725 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4726 break;
4727 }
4728 }
4729
4730 return 0;
4731}
4732
4733/* action sub-ioctls */
4734static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4735 union iwreq_data *wrqu, char *extra)
4736{
4737 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4738 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004739 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004740
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004741 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4742 {
4743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4744 "%s:LOGP in Progress. Ignore!!!", __func__);
4745 return -EBUSY;
4746 }
4747
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 switch (sub_cmd)
4749 {
4750 case WE_CLEAR_STATS:
4751 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4754 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4755 break;
4756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 case WE_INIT_AP:
4758 {
4759 pr_info("Init AP trigger\n");
4760 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4761 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4762 break;
4763 }
4764 case WE_STOP_AP:
4765 {
4766 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
4767 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
4768 * this is a dead code and need to find the adpater by name rather than mode */
4769 hdd_adapter_t* pAdapter_to_stop =
4770 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
4771 if( pAdapter_to_stop )
4772 {
4773 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4774
4775 pr_info("Stopping AP mode\n");
4776
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05304777 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4778 {
4779 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
4780 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
4781 }
4782
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 /*Make sure that pAdapter cleaned properly*/
4784 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
4785 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
4786 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
4787
4788 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
4789 pAdapter_to_stop->macAddressCurrent.bytes);
4790 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
4791 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05304792
4793 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4794 {
4795 /* put the device back into BMPS */
4796 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
4797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 }
4799 else
4800 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08004801 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 }
4803
4804 break;
4805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004806#ifdef WLAN_BTAMP_FEATURE
4807 case WE_ENABLE_AMP:
4808 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 WLANBAP_RegisterWithHCI(pAdapter);
4811 break;
4812 }
4813 case WE_DISABLE_AMP:
4814 {
4815 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4816 VOS_STATUS status;
4817
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004819
4820 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4821 status = WLANBAP_StopAmp();
4822 if(VOS_STATUS_SUCCESS != status )
4823 {
4824 pHddCtx->isAmpAllowed = VOS_TRUE;
4825 hddLog(VOS_TRACE_LEVEL_FATAL,
4826 "%s: Failed to stop AMP", __func__);
4827 }
4828 else
4829 {
4830 //a state m/c implementation in PAL is TBD to avoid this delay
4831 msleep(500);
4832 pHddCtx->isAmpAllowed = VOS_FALSE;
4833 WLANBAP_DeregisterFromHCI();
4834 }
4835
4836 break;
4837 }
4838#endif
4839
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004840 case WE_ENABLE_DXE_STALL_DETECT:
4841 {
schang6295e542013-03-12 15:31:23 -07004842 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4843 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004844 break;
4845 }
4846 case WE_DISPLAY_DXE_SNAP_SHOT:
4847 {
schang6295e542013-03-12 15:31:23 -07004848 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4849 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004850 break;
4851 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304852 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
4853 {
4854 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
4855 hdd_wmm_tx_snapshot(pAdapter);
4856 WLANTL_TLDebugMessage(VOS_TRUE);
4857 break;
4858 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07004859 case WE_SET_REASSOC_TRIGGER:
4860 {
4861 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4862 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
4863 v_U32_t roamId = 0;
4864 tCsrRoamModifyProfileFields modProfileFields;
4865 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
4866 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
4867 return 0;
4868 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304869
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004870
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 default:
4872 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004873 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 break;
4875 }
4876 }
4877
4878 return ret;
4879}
4880
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304881void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
4882{
4883 /*
4884 * Function to display HDD WMM information
4885 * for Tx Queues.
4886 * Prints globala as well as per client depending
4887 * whether the clients are registered or not.
4888 */
4889 int i = 0, j = 0;
4890 for ( i=0; i< NUM_TX_QUEUES; i++)
4891 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304892 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004893 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304894 i, pAdapter->wmm_tx_queue[i].count,
4895 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304896 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304897 }
4898
4899 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
4900 {
4901 if(pAdapter->aStaInfo[i].isUsed)
4902 {
4903 hddLog(LOGE, "******STAIndex: %d*********", i);
4904 for ( j=0; j< NUM_TX_QUEUES; j++)
4905 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304906 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004907 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304908 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
4909 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
4910 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05304911 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304912 }
4913 }
4914 }
4915
4916}
Jeff Johnson295189b2012-06-20 16:38:30 -07004917int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4918 union iwreq_data *wrqu, char *extra)
4919{
4920 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4921 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4922 int sub_cmd = wrqu->data.flags;
Arif Hussain7adce1b2013-11-11 22:59:34 -08004923 int *value = (int*)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 int apps_args[MAX_VAR_ARGS] = {0};
4925 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004926 hdd_station_ctx_t *pStaCtx = NULL ;
4927 hdd_ap_ctx_t *pAPCtx = NULL;
4928 int cmd = 0;
4929 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004930
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004931 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004932
4933 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4934 {
4935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4936 "%s:LOGP in Progress. Ignore!!!", __func__);
4937 return -EBUSY;
4938 }
4939
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 if (num_args > MAX_VAR_ARGS)
4941 {
4942 num_args = MAX_VAR_ARGS;
4943 }
4944 vos_mem_copy(apps_args, value, (sizeof(int)) * num_args);
4945
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004946 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
4947 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
4948 {
4949 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
4950 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
4951 {
4952 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4953 staId = pStaCtx->conn_info.staId[0];
4954 }
4955 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
4956 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
4957 {
4958 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4959 staId = pAPCtx->uBCStaId;
4960 }
4961 else
4962 {
4963 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
4964 return 0;
4965 }
4966 }
4967
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 switch (sub_cmd)
4969 {
4970 case WE_LOG_DUMP_CMD:
4971 {
4972 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004973 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 apps_args[3], apps_args[4]);
4975
4976 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
4977 apps_args[3], apps_args[4]);
4978
4979 }
4980 break;
4981
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 case WE_P2P_NOA_CMD:
4983 {
4984 p2p_app_setP2pPs_t p2pNoA;
4985
4986 p2pNoA.opp_ps = apps_args[0];
4987 p2pNoA.ctWindow = apps_args[1];
4988 p2pNoA.duration = apps_args[2];
4989 p2pNoA.interval = apps_args[3];
4990 p2pNoA.count = apps_args[4];
4991 p2pNoA.single_noa_duration = apps_args[5];
4992 p2pNoA.psSelection = apps_args[6];
4993
4994 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
4995 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004996 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
4998
4999 hdd_setP2pPs(dev, &p2pNoA);
5000
5001 }
5002 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005003
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005004 case WE_MCC_CONFIG_CREDENTIAL :
5005 {
5006 cmd = 287; //Command should be updated if there is any change
5007 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005008 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005009 {
5010 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5011 }
5012 else
5013 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305014 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160\n", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005015 return 0;
5016 }
5017 }
5018 break;
5019
5020 case WE_MCC_CONFIG_PARAMS :
5021 {
5022 cmd = 288; //command Should be updated if there is any change
5023 // in the Riva dump command
5024 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5025 }
5026 break;
5027
Chilam NG571c65a2013-01-19 12:27:36 +05305028#ifdef FEATURE_WLAN_TDLS
5029 case WE_TDLS_CONFIG_PARAMS :
5030 {
5031 tdls_config_params_t tdlsParams;
5032
Chilam Ng01120412013-02-19 18:32:21 -08005033 tdlsParams.tdls = apps_args[0];
5034 tdlsParams.tx_period_t = apps_args[1];
5035 tdlsParams.tx_packet_n = apps_args[2];
5036 tdlsParams.discovery_period_t = apps_args[3];
5037 tdlsParams.discovery_tries_n = apps_args[4];
5038 tdlsParams.idle_timeout_t = apps_args[5];
5039 tdlsParams.idle_packet_n = apps_args[6];
5040 tdlsParams.rssi_hysteresis = apps_args[7];
5041 tdlsParams.rssi_trigger_threshold = apps_args[8];
5042 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305043
Chilam Ng01120412013-02-19 18:32:21 -08005044 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305045 }
5046 break;
5047#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 default:
5049 {
5050 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
5051 }
5052 break;
5053 }
5054
5055 return 0;
5056}
5057
5058
5059static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5060 union iwreq_data *wrqu, char *extra)
5061{
5062 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5063 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5064 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5065 int params[HDD_WLAN_WMM_PARAM_COUNT];
5066 sme_QosWmmTspecInfo tSpec;
5067 v_U32_t handle;
5068
5069 // make sure the application is sufficiently priviledged
5070 // note that the kernel will do this for "set" ioctls, but since
5071 // this ioctl wants to return status to user space it must be
5072 // defined as a "get" ioctl
5073 if (!capable(CAP_NET_ADMIN))
5074 {
5075 return -EPERM;
5076 }
5077
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005078 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5079 {
5080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5081 "%s:LOGP in Progress. Ignore!!!", __func__);
5082 return -EBUSY;
5083 }
5084
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 // we must be associated in order to add a tspec
5086 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5087 {
5088 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5089 return 0;
5090 }
5091
5092 // since we are defined to be a "get" ioctl, and since the number
5093 // of params exceeds the number of params that wireless extensions
5094 // will pass down in the iwreq_data, we must copy the "set" params
5095 // from user space ourselves
5096 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5097 {
5098 // hmmm, can't get them
5099 return -EIO;
5100 }
5101
5102 // clear the tspec
5103 memset(&tSpec, 0, sizeof(tSpec));
5104
5105 // validate the handle
5106 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5107 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5108 {
5109 // that one is reserved
5110 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5111 return 0;
5112 }
5113
5114 // validate the TID
5115 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5116 {
5117 // out of range
5118 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5119 return 0;
5120 }
5121 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5122
5123 // validate the direction
5124 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5125 {
5126 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5127 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5128 break;
5129
5130 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5131 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5132 break;
5133
5134 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5135 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5136 break;
5137
5138 default:
5139 // unknown
5140 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5141 return 0;
5142 }
5143
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305144 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5145
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 // validate the user priority
5147 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5148 {
5149 // out of range
5150 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5151 return 0;
5152 }
5153 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305154 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5155 {
5156 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5157 return 0;
5158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005159
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5161 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5162 tSpec.ts_info.psb, tSpec.ts_info.up);
5163
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5165 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5166 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5167 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5168 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5169 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5170 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5171 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5172 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5173 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5174 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5175 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5176
5177 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5178
5179 // validate the ts info ack policy
5180 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5181 {
5182 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5183 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5184 break;
5185
5186 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5187 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5188 break;
5189
5190 default:
5191 // unknown
5192 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5193 return 0;
5194 }
5195
5196 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5197 return 0;
5198}
5199
5200
5201static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5202 union iwreq_data *wrqu, char *extra)
5203{
5204 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5205 int *params = (int *)extra;
5206 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5207 v_U32_t handle;
5208
5209 // make sure the application is sufficiently priviledged
5210 // note that the kernel will do this for "set" ioctls, but since
5211 // this ioctl wants to return status to user space it must be
5212 // defined as a "get" ioctl
5213 if (!capable(CAP_NET_ADMIN))
5214 {
5215 return -EPERM;
5216 }
5217
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005218 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5219 {
5220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5221 "%s:LOGP in Progress. Ignore!!!", __func__);
5222 return -EBUSY;
5223 }
5224
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 // although we are defined to be a "get" ioctl, the params we require
5226 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5227 // is no need to copy the params from user space
5228
5229 // validate the handle
5230 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5231 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5232 {
5233 // that one is reserved
5234 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5235 return 0;
5236 }
5237
5238 *pStatus = hdd_wmm_delts(pAdapter, handle);
5239 return 0;
5240}
5241
5242
5243static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5244 union iwreq_data *wrqu, char *extra)
5245{
5246 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5247 int *params = (int *)extra;
5248 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5249 v_U32_t handle;
5250
5251 // although we are defined to be a "get" ioctl, the params we require
5252 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5253 // is no need to copy the params from user space
5254
5255 // validate the handle
5256 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5257 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5258 {
5259 // that one is reserved
5260 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5261 return 0;
5262 }
5263
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005264 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5265 {
5266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5267 "%s:LOGP in Progress. Ignore!!!", __func__);
5268 return -EBUSY;
5269 }
5270
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5272 return 0;
5273}
5274
5275
5276#ifdef FEATURE_WLAN_WAPI
5277static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5278 union iwreq_data *wrqu, char *extra)
5279{
5280 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5281 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5282 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5283 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5284
Arif Hussain7adce1b2013-11-11 22:59:34 -08005285 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005286
5287 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005288 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005289 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5290 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005291
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005292 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5293 {
5294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5295 "%s:LOGP in Progress. Ignore!!!", __func__);
5296 return -EBUSY;
5297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005298
5299 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005300 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5302 pRoamProfile->EncryptionType.numEntries = 1;
5303 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5304 pRoamProfile->mcEncryptionType.numEntries = 1;
5305 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5306
5307 pRoamProfile->AuthType.numEntries = 1;
5308 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5309 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5310 }
5311 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005312 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 }
5314 else
5315 return -EINVAL;
5316
5317 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5318
5319 return 0;
5320}
5321
5322static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5323 union iwreq_data *wrqu, char *extra)
5324{
5325 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5326 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5327
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005328 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5329 {
5330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5331 "%s:LOGP in Progress. Ignore!!!", __func__);
5332 return -EBUSY;
5333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5335
5336 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005337 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
5339 return 0;
5340}
5341
5342static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5343 union iwreq_data *wrqu, char *extra)
5344{
5345 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5346// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5347 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5348 int i = 0, j = 0;
5349 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005350 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005351 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005352
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005353 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5354 {
5355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5356 "%s:LOGP in Progress. Ignore!!!", __func__);
5357 return -EBUSY;
5358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 VOS_ASSERT(pWapiAssocInfo);
5360
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005361 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x\n",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
5362 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005364 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005365
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005366 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005368 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005369
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005370 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005371 hddLog(LOG1, "%s: BKID Cnt:0x%04x\n",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 for(i = 0 ; i < 16 ; i++) {
5373 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5374 for(j = 0 ; j < 16 ; j++)
5375 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5376 }
5377
5378 /* We are not using the entire IE as provided by the supplicant.
5379 * This is being calculated by SME. This is the same as in the
5380 * case of WPA. Only the auth mode information needs to be
5381 * extracted here*/
5382 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005383 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5385 }
5386
5387 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005388 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5390 }
5391 return 0;
5392}
5393
5394static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5395 union iwreq_data *wrqu, char *extra)
5396{
5397 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5398 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5399 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5400 tANI_U32 roamId = 0xFF;
5401 tANI_U8 *pKeyPtr = NULL;
5402 v_BOOL_t isConnected = TRUE;
5403 tCsrRoamSetKey setKey;
5404 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5406
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005407 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5408 {
5409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5410 "%s:LOGP in Progress. Ignore!!!", __func__);
5411 return -EBUSY;
5412 }
5413
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005415 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005416 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005417
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305418 hddLog(LOG1,":%s: INPUT DATA:\nKey Type:0x%02x Key Direction:0x%02x KEY ID:0x%02x\n", __func__, pWapiKey->keyType, pWapiKey->keyDirection, pWapiKey->keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 hddLog(LOG1,"Add Index:0x");
5420 for(i =0 ; i < 12 ; i++)
5421 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5422
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005423 hddLog(LOG1,"\n%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5425 for(i =0 ; i < 16 ; i++)
5426 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5427
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005428 hddLog(LOG1,"\n%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5430 for(i =0 ; i < 16 ; i++)
5431 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5432
5433 hddLog(LOG1,"\nWAPI PN NUMBER:0x");
5434 for(i = 0 ; i < 16 ; i++)
5435 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5436
5437 // Clear the setkey memory
5438 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5439 // Store Key ID
5440 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5441 // SET WAPI Encryption
5442 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5443 // Key Directionn both TX and RX
5444 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5445 // the PAE role
5446 setKey.paeRole = 0 ;
5447
5448 switch ( pWapiKey->keyType )
5449 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005450 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 {
5452 isConnected = hdd_connIsConnected(pHddStaCtx);
5453 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5454 break;
5455 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005456 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 {
5458 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5459 break;
5460 }
5461 default:
5462 {
5463 //Any other option is invalid.
5464 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005465 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005466
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005467 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5469 break; // NEED RETURN FROM HERE ????
5470 }
5471 }
5472
5473 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5474 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5475 pKeyPtr = setKey.Key;
5476 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5477 pKeyPtr += pWapiKey->wpiekLen;
5478 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5479
5480 // Set the new key with SME.
5481 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5482
5483 if ( isConnected ) {
5484 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5485 if ( halStatus != eHAL_STATUS_SUCCESS )
5486 {
5487 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5488 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5489
5490 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5491 }
5492 }
5493#if 0 /// NEED TO CHECK ON THIS
5494 else
5495 {
5496 // Store the keys in the adapter to be moved to the profile & passed to
5497 // SME in the ConnectRequest if we are not yet in connected state.
5498 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5499 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5500
5501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5502 " Saving key [idx= %d] to apply when moving to connected state ",
5503 setKey.keyId );
5504
5505 }
5506#endif
5507 return halStatus;
5508}
5509
5510static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5511 union iwreq_data *wrqu, char *extra)
5512{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005513 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005514#ifdef WLAN_DEBUG
5515 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005516 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005517#endif
5518
5519 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005520 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005521 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005522
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005523 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5524 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005525
5526 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005527
5528 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5529 {
5530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5531 "%s:LOGP in Progress. Ignore!!!", __func__);
5532 return -EBUSY;
5533 }
5534
Jeff Johnson295189b2012-06-20 16:38:30 -07005535#ifdef WLAN_DEBUG
5536 for(i =0 ; i < 16 ; i++)
5537 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5538#endif
5539
5540 return 0;
5541}
5542
5543static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5544 union iwreq_data *wrqu, char *extra)
5545{
5546 /* Yet to implement this function, 19th April 2010 */
5547 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5548
5549 return 0;
5550}
5551#endif /* FEATURE_WLAN_WAPI */
5552
5553#ifdef WLAN_FEATURE_VOWIFI_11R
5554//
5555//
5556// Each time the supplicant has the auth_request or reassoc request
5557// IEs ready. This is pushed to the driver. The driver will inturn use
5558// it to send out the auth req and reassoc req for 11r FT Assoc.
5559//
5560static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5561 union iwreq_data *wrqu, char *extra)
5562{
5563 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5564 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5565 //v_CONTEXT_t pVosContext;
5566
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005567 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5568 {
5569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5570 "%s:LOGP in Progress. Ignore!!!", __func__);
5571 return -EBUSY;
5572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 if (!wrqu->data.length)
5574 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305575 hddLog(LOGE, FL("called with 0 length IEs\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 return -EINVAL;
5577 }
5578 if (wrqu->data.pointer == NULL)
5579 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305580 hddLog(LOGE, FL("called with NULL IE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 return -EINVAL;
5582 }
5583
5584 // Added for debug on reception of Re-assoc Req.
5585 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5586 {
5587 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
5588 wrqu->data.length);
5589 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
5590 }
5591
5592#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
5593 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, wrqu->data.length);
5594#endif
5595
5596 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005597 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 wrqu->data.length);
5599
5600 return 0;
5601}
5602#endif
5603
Amar Singhalf3a6e762013-02-19 15:06:50 -08005604static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005605 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005607{
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005609 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005611 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005612 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005613 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5614 int idx;
5615 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005616
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005617 if (pHddCtx->isLogpInProgress)
5618 {
5619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5620 "%s:LOGP in Progress. Ignore!!!", __func__);
5621 return -EBUSY;
5622 }
5623
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305624 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5625 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305626#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005627
Amar Singhalf3a6e762013-02-19 15:06:50 -08005628 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5629 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005630 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005631 hddLog(VOS_TRACE_LEVEL_ERROR,
5632 "%s: vos_mem_alloc failed", __func__);
5633 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005634 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005635
5636 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5637
5638 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5639 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5640
5641 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5642 mc_addr_list_ptr->ulMulticastAddrCnt);
5643
5644 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005645 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005646 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5647 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5648
5649 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5650 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005651 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005652
Amar Singhalf3a6e762013-02-19 15:06:50 -08005653 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5654 vos_mem_free(mc_addr_list_ptr);
5655 if (eHAL_STATUS_SUCCESS != ret_val)
5656 {
5657 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5658 __func__);
5659 return -EINVAL;
5660 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305661#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305662 }
5663 else
5664 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005665
Amar Singhalf3a6e762013-02-19 15:06:50 -08005666 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5667 "%s: Set MC BC Filter Config request: %d suspend %d",
5668 __func__, pRequest->mcastBcastFilterSetting,
5669 pHddCtx->hdd_wlan_suspended);
5670
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305671 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005672
5673 if (pHddCtx->hdd_wlan_suspended)
5674 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005675 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5676 if (NULL == wlanRxpFilterParam)
5677 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305678 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005679 "%s: vos_mem_alloc failed", __func__);
5680 return -EINVAL;
5681 }
5682
Amar Singhalf3a6e762013-02-19 15:06:50 -08005683 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5684 pRequest->mcastBcastFilterSetting;
5685 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5686
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305687 hdd_conf_hostoffload(pAdapter, TRUE);
5688 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5689 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005690
5691 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5692 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305693 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08005694 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5695 wlanRxpFilterParam->setMcstBcstFilter);
5696
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305697 if (eHAL_STATUS_SUCCESS !=
5698 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5699 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08005700 {
5701 hddLog(VOS_TRACE_LEVEL_ERROR,
5702 "%s: Failure to execute set HW MC/BC Filter request",
5703 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005704 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005705 return -EINVAL;
5706 }
5707
Amar Singhalf3a6e762013-02-19 15:06:50 -08005708 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005710
5711 return 0;
5712}
5713
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005714static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
5715 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 union iwreq_data *wrqu, char *extra)
5717{
5718 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5719 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305720 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005721 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005722
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305723 //Reset the filter to INI value as we have to clear the dynamic filter
5724 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005725
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305726 //Configure FW with new setting
5727 if (pHddCtx->hdd_wlan_suspended)
5728 {
5729 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5730 if (NULL == wlanRxpFilterParam)
5731 {
5732 hddLog(VOS_TRACE_LEVEL_ERROR,
5733 "%s: vos_mem_alloc failed", __func__);
5734 return -EINVAL;
5735 }
5736
5737 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5738 pHddCtx->configuredMcastBcastFilter;
5739 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5740
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305741 hdd_conf_hostoffload(pAdapter, TRUE);
5742 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5743 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305744
5745 if (eHAL_STATUS_SUCCESS !=
5746 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5747 wlanRxpFilterParam))
5748 {
5749 hddLog(VOS_TRACE_LEVEL_ERROR,
5750 "%s: Failure to execute set HW MC/BC Filter request",
5751 __func__);
5752 vos_mem_free(wlanRxpFilterParam);
5753 return -EINVAL;
5754 }
5755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 return 0;
5757}
5758
5759static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
5760 union iwreq_data *wrqu, char *extra)
5761{
5762 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005763 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 tSirHostOffloadReq offloadRequest;
5765
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005766 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5767 {
5768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5769 "%s:LOGP in Progress. Ignore!!!", __func__);
5770 return -EBUSY;
5771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 /* Debug display of request components. */
5773 switch (pRequest->offloadType)
5774 {
5775 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005776 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 switch (pRequest->enableOrDisable)
5778 {
5779 case WLAN_OFFLOAD_DISABLE:
5780 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
5781 break;
5782 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
5783 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
5784 case WLAN_OFFLOAD_ENABLE:
5785 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
5786 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
5787 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
5788 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
5789 }
5790 break;
5791
5792 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
5793 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005794 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 switch (pRequest->enableOrDisable)
5796 {
5797 case WLAN_OFFLOAD_DISABLE:
5798 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
5799 break;
5800 case WLAN_OFFLOAD_ENABLE:
5801 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
5802 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
5803 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
5804 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
5805 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
5806 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
5807 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
5808 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
5809 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
5810 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
5811 }
5812 }
5813
5814 /* Execute offload request. The reason that we can copy the request information
5815 from the ioctl structure to the SME structure is that they are laid out
5816 exactly the same. Otherwise, each piece of information would have to be
5817 copied individually. */
5818 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07005819 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
5820 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 {
5822 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request\n",
5823 __func__);
5824 return -EINVAL;
5825 }
5826
5827 return 0;
5828}
5829
5830static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
5831 union iwreq_data *wrqu, char *extra)
5832{
5833 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005834 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 tSirKeepAliveReq keepaliveRequest;
5836
5837 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5838 {
5839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005840 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 return 0;
5842 }
5843
5844 /* Debug display of request components. */
5845 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Keep Alive Request : TimePeriod %d size %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005846 __func__,pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005847
5848 switch (pRequest->packetType)
5849 {
5850 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005851 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 break;
5853
5854 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
5855
5856 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005857 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005858
5859 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
5860 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
5861 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
5862
5863 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
5864 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
5865 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
5866
5867 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
5868 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
5869 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
5870 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
5871 break;
5872
5873 }
5874
5875 /* Execute keep alive request. The reason that we can copy the request information
5876 from the ioctl structure to the SME structure is that they are laid out
5877 exactly the same. Otherwise, each piece of information would have to be
5878 copied individually. */
5879 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
5880
5881 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d\n", keepaliveRequest.timePeriod);
5882
Jeff Johnsone7245742012-09-05 17:12:55 -07005883 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
5884 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 {
5886 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive\n",
5887 __func__);
5888 return -EINVAL;
5889 }
5890
5891 return 0;
5892}
5893
5894#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -07005895int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
5896 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005897{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005898 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5899 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 int i=0;
5901
5902 if (pHddCtx->cfg_ini->disablePacketFilter)
5903 {
5904 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005905 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 return 0;
5907 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005908 if (pHddCtx->isLogpInProgress)
5909 {
5910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5911 "%s:LOGP in Progress. Ignore!!!", __func__);
5912 return -EBUSY;
5913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 /* Debug display of request components. */
5915 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005916 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07005917
5918 switch (pRequest->filterAction)
5919 {
5920 case HDD_RCV_FILTER_SET:
5921 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005922 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005923
5924 packetFilterSetReq.filterId = pRequest->filterId;
5925 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
5926 {
5927 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d\n",
5928 __func__, pRequest->numParams);
5929 return -EINVAL;
5930 }
5931 packetFilterSetReq.numFieldParams = pRequest->numParams;
5932 packetFilterSetReq.coalesceTime = 0;
5933 packetFilterSetReq.filterType = 1;
5934 for (i=0; i < pRequest->numParams; i++)
5935 {
5936 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
5937 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
5938 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
5939 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
5940 packetFilterSetReq.paramsData[i].reserved = 0;
5941
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305942 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
5944 packetFilterSetReq.filterType);
5945
5946 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d\n",
5947 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
5948
5949 memcpy(&packetFilterSetReq.paramsData[i].compareData,
5950 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
5951 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
5952 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
5953
5954 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d\n",
5955 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
5956 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
5957 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
5958
5959 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d\n",
5960 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
5961 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
5962 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
5963 }
5964
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005965 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 {
5967 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter\n",
5968 __func__);
5969 return -EINVAL;
5970 }
5971
5972 break;
5973
5974 case HDD_RCV_FILTER_CLEAR:
5975
5976 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005977 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005979 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 {
5981 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter\n",
5982 __func__);
5983 return -EINVAL;
5984 }
5985 break;
5986
5987 default :
5988 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005989 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 return -EINVAL;
5991 }
5992 return 0;
5993}
5994
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05305995int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
5996 tANI_U8 sessionId)
5997{
5998 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5999 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6000
6001 if (NULL == pHddCtx)
6002 {
6003 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6004 return -EINVAL;
6005 }
6006
6007 if (pHddCtx->isLogpInProgress)
6008 {
6009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6010 "%s:LOGP in Progress. Ignore!!!", __func__);
6011 return -EBUSY;
6012 }
6013
6014 if (pHddCtx->cfg_ini->disablePacketFilter)
6015 {
6016 hddLog(VOS_TRACE_LEVEL_ERROR,
6017 "%s: Packet Filtering Disabled. Returning ",
6018 __func__ );
6019 return -EINVAL;
6020 }
6021
6022 switch (filterType)
6023 {
6024 /* For setting IPV6 MC and UC Filter we need to configure
6025 * 2 filters, one for MC and one for UC.
6026 * The Filter ID shouldn't be swapped, which results in making
6027 * UC Filter ineffective.
6028 * We have Hardcode all the values
6029 *
6030 * Reason for a seperate UC filter is because, driver need to
6031 * specify the FW that the specific filter is for unicast
6032 * otherwise FW will not pass the unicast frames by default
6033 * through the filter. This is required to avoid any performance
6034 * hits when no unicast filter is set and only MC/BC are set.
6035 * The way driver informs host is by using the MAC protocol
6036 * layer, CMP flag set to MAX, CMP Data set to 1.
6037 */
6038
6039 case HDD_FILTER_IPV6_MC_UC:
6040 /* Setting IPV6 MC Filter below
6041 */
6042 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6043 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6044 packetFilterSetReq.numFieldParams = 2;
6045 packetFilterSetReq.paramsData[0].protocolLayer =
6046 HDD_FILTER_PROTO_TYPE_MAC;
6047 packetFilterSetReq.paramsData[0].cmpFlag =
6048 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6049 packetFilterSetReq.paramsData[0].dataOffset =
6050 WLAN_HDD_80211_FRM_DA_OFFSET;
6051 packetFilterSetReq.paramsData[0].dataLength = 1;
6052 packetFilterSetReq.paramsData[0].compareData[0] =
6053 HDD_IPV6_MC_CMP_DATA;
6054
6055 packetFilterSetReq.paramsData[1].protocolLayer =
6056 HDD_FILTER_PROTO_TYPE_ARP;
6057 packetFilterSetReq.paramsData[1].cmpFlag =
6058 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6059 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6060 packetFilterSetReq.paramsData[1].dataLength = 2;
6061 packetFilterSetReq.paramsData[1].compareData[0] =
6062 HDD_IPV6_CMP_DATA_0;
6063 packetFilterSetReq.paramsData[1].compareData[1] =
6064 HDD_IPV6_CMP_DATA_1;
6065
6066
6067 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6068 &packetFilterSetReq, sessionId))
6069 {
6070 hddLog(VOS_TRACE_LEVEL_ERROR,
6071 "%s: Failure to execute Set IPv6 Mulicast Filter",
6072 __func__);
6073 return -EINVAL;
6074 }
6075
6076 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6077
6078 /*
6079 * Setting IPV6 UC Filter below
6080 */
6081 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6082 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6083 packetFilterSetReq.numFieldParams = 2;
6084 packetFilterSetReq.paramsData[0].protocolLayer =
6085 HDD_FILTER_PROTO_TYPE_MAC;
6086 packetFilterSetReq.paramsData[0].cmpFlag =
6087 HDD_FILTER_CMP_TYPE_MAX;
6088 packetFilterSetReq.paramsData[0].dataOffset = 0;
6089 packetFilterSetReq.paramsData[0].dataLength = 1;
6090 packetFilterSetReq.paramsData[0].compareData[0] =
6091 HDD_IPV6_UC_CMP_DATA;
6092
6093 packetFilterSetReq.paramsData[1].protocolLayer =
6094 HDD_FILTER_PROTO_TYPE_ARP;
6095 packetFilterSetReq.paramsData[1].cmpFlag =
6096 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6097 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6098 packetFilterSetReq.paramsData[1].dataLength = 2;
6099 packetFilterSetReq.paramsData[1].compareData[0] =
6100 HDD_IPV6_CMP_DATA_0;
6101 packetFilterSetReq.paramsData[1].compareData[1] =
6102 HDD_IPV6_CMP_DATA_1;
6103
6104 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6105 &packetFilterSetReq, sessionId))
6106 {
6107 hddLog(VOS_TRACE_LEVEL_ERROR,
6108 "%s: Failure to execute Set IPv6 Unicast Filter",
6109 __func__);
6110 return -EINVAL;
6111 }
6112
6113 break;
6114
6115 case HDD_FILTER_IPV6_MC:
6116 /*
6117 * IPV6 UC Filter might be already set,
6118 * clear the UC Filter. As the Filter
6119 * IDs are static, we can directly clear it.
6120 */
6121 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6122 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6123 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6124 &packetFilterClrReq, sessionId))
6125 {
6126 hddLog(VOS_TRACE_LEVEL_ERROR,
6127 "%s: Failure to execute Clear IPv6 Unicast Filter",
6128 __func__);
6129 return -EINVAL;
6130 }
6131
6132 /*
6133 * Setting IPV6 MC Filter below
6134 */
6135 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6136 packetFilterSetReq.numFieldParams = 2;
6137 packetFilterSetReq.paramsData[0].protocolLayer =
6138 HDD_FILTER_PROTO_TYPE_MAC;
6139 packetFilterSetReq.paramsData[0].cmpFlag =
6140 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6141 packetFilterSetReq.paramsData[0].dataOffset =
6142 WLAN_HDD_80211_FRM_DA_OFFSET;
6143 packetFilterSetReq.paramsData[0].dataLength = 1;
6144 packetFilterSetReq.paramsData[0].compareData[0] =
6145 HDD_IPV6_MC_CMP_DATA;
6146
6147 packetFilterSetReq.paramsData[1].protocolLayer =
6148 HDD_FILTER_PROTO_TYPE_ARP;
6149 packetFilterSetReq.paramsData[1].cmpFlag =
6150 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6151 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6152 packetFilterSetReq.paramsData[1].dataLength = 2;
6153 packetFilterSetReq.paramsData[1].compareData[0] =
6154 HDD_IPV6_CMP_DATA_0;
6155 packetFilterSetReq.paramsData[1].compareData[1] =
6156 HDD_IPV6_CMP_DATA_1;
6157
6158
6159 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6160 &packetFilterSetReq, sessionId))
6161 {
6162 hddLog(VOS_TRACE_LEVEL_ERROR,
6163 "%s: Failure to execute Set IPv6 Multicast Filter",
6164 __func__);
6165 return -EINVAL;
6166 }
6167 break;
6168
6169 default :
6170 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6171 "%s: Packet Filter Request: Invalid",
6172 __func__);
6173 return -EINVAL;
6174 }
6175 return 0;
6176}
6177
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306178void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006179{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306180 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306181 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006182 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306183 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006184
Yue Ma3ede6052013-08-29 00:33:26 -07006185 if (NULL == pHddCtx)
6186 {
6187 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6188 return;
6189 }
6190
6191 hHal = pHddCtx->hHal;
6192
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306193 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306195 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6196 return;
6197 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306198
6199 /* Check if INI is enabled or not, other wise just return
6200 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306201 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306202 {
6203 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6204 if (NULL == pMulticastAddrs)
6205 {
6206 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6207 return;
6208 }
6209
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 if (set)
6211 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306212 /* Following pre-conditions should be satisfied before wei
6213 * configure the MC address list.
6214 */
6215 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6216 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6217 && pAdapter->mc_addr_list.mc_cnt
6218 && (eConnectionState_Associated ==
6219 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6220 {
6221 pMulticastAddrs->ulMulticastAddrCnt =
6222 pAdapter->mc_addr_list.mc_cnt;
6223 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6224 {
6225 memcpy(&(pMulticastAddrs->multicastAddr[i][0]),
6226 &(pAdapter->mc_addr_list.addr[i][0]),
6227 sizeof(pAdapter->mc_addr_list.addr[i]));
6228 hddLog(VOS_TRACE_LEVEL_INFO,
6229 "%s: %s multicast filter: addr ="
6230 MAC_ADDRESS_STR,
6231 __func__, set ? "setting" : "clearing",
6232 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6233 }
6234 /* Set multicast filter */
6235 sme_8023MulticastList(hHal, pAdapter->sessionId,
6236 pMulticastAddrs);
6237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306239 else
6240 {
6241 /* Need to clear only if it was previously configured
6242 */
6243 if (pAdapter->mc_addr_list.isFilterApplied)
6244 {
6245 pMulticastAddrs->ulMulticastAddrCnt = 0;
6246 sme_8023MulticastList(hHal, pAdapter->sessionId,
6247 pMulticastAddrs);
6248 }
6249
6250 }
6251 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006252 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306254 else
6255 {
6256 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306257 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306258 }
6259 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006260}
6261
6262static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6263 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306264{
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006266 tpPacketFilterCfg pRequest = (tpPacketFilterCfg) extra;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006267
Jeff Johnsone7245742012-09-05 17:12:55 -07006268 return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006269}
6270#endif
6271static int iw_get_statistics(struct net_device *dev,
6272 struct iw_request_info *info,
6273 union iwreq_data *wrqu, char *extra)
6274{
6275
6276 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6277 eHalStatus status = eHAL_STATUS_SUCCESS;
6278 hdd_wext_state_t *pWextState;
6279 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6280 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6281 char *p = extra;
6282 int tlen = 0;
6283 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6284
6285 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6286 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6287
6288 ENTER();
6289
6290 if (pHddCtx->isLogpInProgress) {
6291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6292 return -EINVAL;
6293 }
6294
6295 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6296
6297 wrqu->txpower.value = 0;
6298 }
6299 else {
6300 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6301 SME_SUMMARY_STATS |
6302 SME_GLOBAL_CLASSA_STATS |
6303 SME_GLOBAL_CLASSB_STATS |
6304 SME_GLOBAL_CLASSC_STATS |
6305 SME_GLOBAL_CLASSD_STATS |
6306 SME_PER_STA_STATS,
6307 hdd_StatisticsCB, 0, FALSE,
6308 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6309
6310 if (eHAL_STATUS_SUCCESS != status)
6311 {
6312 hddLog(VOS_TRACE_LEVEL_ERROR,
6313 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006314 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 return -EINVAL;
6316 }
6317
6318 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6319
6320 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6321 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6322 {
6323 hddLog(VOS_TRACE_LEVEL_ERROR,
6324 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006325 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 /*Remove the SME statistics list by passing NULL in callback argument*/
6327 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6328 SME_SUMMARY_STATS |
6329 SME_GLOBAL_CLASSA_STATS |
6330 SME_GLOBAL_CLASSB_STATS |
6331 SME_GLOBAL_CLASSC_STATS |
6332 SME_GLOBAL_CLASSD_STATS |
6333 SME_PER_STA_STATS,
6334 NULL, 0, FALSE,
6335 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6336
6337 return -EINVAL;
6338 }
6339 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6340 (tANI_U8) sizeof (pStats->retry_cnt),
6341 (char*) &(pStats->retry_cnt[0]),
6342 tlen);
6343
6344 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6345 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6346 (char*) &(pStats->multiple_retry_cnt[0]),
6347 tlen);
6348
6349 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6350 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6351 (char*) &(pStats->tx_frm_cnt[0]),
6352 tlen);
6353
6354 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6355 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6356 (char*) &(pStats->rx_frm_cnt),
6357 tlen);
6358
6359 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6360 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6361 (char*) &(pStats->frm_dup_cnt),
6362 tlen);
6363
6364 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6365 (tANI_U8) sizeof (pStats->fail_cnt),
6366 (char*) &(pStats->fail_cnt[0]),
6367 tlen);
6368
6369 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6370 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6371 (char*) &(pStats->rts_fail_cnt),
6372 tlen);
6373
6374 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6375 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6376 (char*) &(pStats->ack_fail_cnt),
6377 tlen);
6378
6379 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6380 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6381 (char*) &(pStats->rts_succ_cnt),
6382 tlen);
6383
6384 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6385 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6386 (char*) &(pStats->rx_discard_cnt),
6387 tlen);
6388
6389 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6390 (tANI_U8) sizeof (pStats->rx_error_cnt),
6391 (char*) &(pStats->rx_error_cnt),
6392 tlen);
6393
Jeff Johnsone7245742012-09-05 17:12:55 -07006394 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
6395 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6396 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 tlen);
6398
6399 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6400 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6401 (char*) &(dStats->rx_byte_cnt),
6402 tlen);
6403
6404 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6405 (tANI_U8) sizeof (dStats->rx_rate),
6406 (char*) &(dStats->rx_rate),
6407 tlen);
6408
6409 /* Transmit rate, in units of 500 kbit/sec */
6410 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6411 (tANI_U8) sizeof (aStats->tx_rate),
6412 (char*) &(aStats->tx_rate),
6413 tlen);
6414
Jeff Johnsone7245742012-09-05 17:12:55 -07006415 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6416 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6417 (char*) &(dStats->rx_uc_byte_cnt[0]),
6418 tlen);
6419 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6420 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6421 (char*) &(dStats->rx_mc_byte_cnt),
6422 tlen);
6423 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6424 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6425 (char*) &(dStats->rx_bc_byte_cnt),
6426 tlen);
6427 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6428 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6429 (char*) &(dStats->tx_uc_byte_cnt[0]),
6430 tlen);
6431 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6432 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6433 (char*) &(dStats->tx_mc_byte_cnt),
6434 tlen);
6435 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6436 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6437 (char*) &(dStats->tx_bc_byte_cnt),
6438 tlen);
6439
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 wrqu->data.length = tlen;
6441
6442 }
6443
6444 EXIT();
6445
6446 return 0;
6447}
6448
6449
6450#ifdef FEATURE_WLAN_SCAN_PNO
6451
6452/*Max Len for PNO notification*/
6453#define MAX_PNO_NOTIFY_LEN 100
6454void found_pref_network_cb (void *callbackContext,
6455 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6456{
6457 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6458 union iwreq_data wrqu;
6459 char buf[MAX_PNO_NOTIFY_LEN+1];
6460
6461 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6462 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6463
6464 // create the event
6465 memset(&wrqu, 0, sizeof(wrqu));
6466 memset(buf, 0, sizeof(buf));
6467
6468 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6469 pPrefNetworkFoundInd->ssId.ssId,
6470 (unsigned int)pPrefNetworkFoundInd->rssi);
6471
6472 wrqu.data.pointer = buf;
6473 wrqu.data.length = strlen(buf);
6474
6475 // send the event
6476
6477 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6478
6479}
6480
6481
6482/*string based input*/
6483VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6484 union iwreq_data *wrqu, char *extra, int nOffset)
6485{
6486 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006487 /* pnoRequest is a large struct, so we make it static to avoid stack
6488 overflow. This API is only invoked via ioctl, so it is
6489 serialized by the kernel rtnl_lock and hence does not need to be
6490 reentrant */
6491 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 char *ptr;
6493 v_U8_t i,j, ucParams, ucMode;
6494 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6495
6496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6497 "PNO data len %d data %s",
6498 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006499 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006500
6501 if (wrqu->data.length <= nOffset )
6502 {
6503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6504 return VOS_STATUS_E_FAILURE;
6505 }
6506
6507 pnoRequest.enable = 0;
6508 pnoRequest.ucNetworksCount = 0;
6509 /*-----------------------------------------------------------------------
6510 Input is string based and expected to be like this:
6511
6512 <enabled> <netw_count>
6513 for each network:
6514 <ssid_len> <ssid> <authentication> <encryption>
6515 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6516 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6517
6518 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006519 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 -07006520
6521 this translates into:
6522 -----------------------------
6523 enable PNO
6524 look for 2 networks:
6525 test - with authentication type 0 and encryption type 0,
6526 that can be found on 3 channels: 1 6 and 11 ,
6527 SSID bcast type is unknown (directed probe will be sent if AP not found)
6528 and must meet -40dBm RSSI
6529
6530 test2 - with auth and enrytption type 4/4
6531 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6532 bcast type is non-bcast (directed probe will be sent)
6533 and must not meet any RSSI threshold
6534
Jeff Johnson8301aa12013-03-28 14:27:29 -07006535 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006537 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006538
Wilson Yang623f6592013-10-08 16:33:37 -07006539 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6540 {
6541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6542 "PNO enable input is not valid %s",ptr);
6543 return VOS_STATUS_E_FAILURE;
6544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006545
6546 if ( 0 == pnoRequest.enable )
6547 {
6548 /*Disable PNO*/
6549 memset(&pnoRequest, 0, sizeof(pnoRequest));
6550 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6551 pAdapter->sessionId,
6552 found_pref_network_cb, pAdapter);
6553 return VOS_STATUS_SUCCESS;
6554 }
6555
6556 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006557
6558 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6559 {
6560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6561 "PNO count input not valid %s",ptr);
6562 return VOS_STATUS_E_FAILURE;
6563
6564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006565
6566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6567 "PNO enable %d networks count %d offset %d",
6568 pnoRequest.enable,
6569 pnoRequest.ucNetworksCount,
6570 nOffset);
6571
6572 /* Parameters checking:
6573 ucNetworksCount has to be larger than 0*/
6574 if (( 0 == pnoRequest.ucNetworksCount ) ||
6575 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6576 {
6577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6578 return VOS_STATUS_E_FAILURE;
6579 }
6580
6581 ptr += nOffset;
6582
6583 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6584 {
6585
6586 pnoRequest.aNetworks[i].ssId.length = 0;
6587
Wilson Yang623f6592013-10-08 16:33:37 -07006588 ucParams = sscanf(ptr,"%hhu %n",
6589 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6590
6591 if (1 != ucParams)
6592 {
6593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6594 "PNO ssid length input is not valid %s",ptr);
6595 return VOS_STATUS_E_FAILURE;
6596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006597
6598 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6599 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6600 {
6601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6602 "SSID Len %d is not correct for network %d",
6603 pnoRequest.aNetworks[i].ssId.length, i);
6604 return VOS_STATUS_E_FAILURE;
6605 }
6606
6607 /*Advance to SSID*/
6608 ptr += nOffset;
6609
Jeff Johnson8301aa12013-03-28 14:27:29 -07006610 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006611 pnoRequest.aNetworks[i].ssId.length);
6612 ptr += pnoRequest.aNetworks[i].ssId.length;
6613
Jeff Johnson02797792013-10-26 19:17:13 -07006614 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006615 &(pnoRequest.aNetworks[i].authentication),
6616 &(pnoRequest.aNetworks[i].encryption),
6617 &(pnoRequest.aNetworks[i].ucChannelCount),
6618 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006619
Wilson Yang623f6592013-10-08 16:33:37 -07006620 if ( 3 != ucParams )
6621 {
6622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6623 "Incorrect cmd %s",ptr);
6624 return VOS_STATUS_E_FAILURE;
6625 }
6626
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006628 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006629 "auth %d encry %d channel count %d offset %d",
6630 pnoRequest.aNetworks[i].ssId.length,
6631 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6632 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6633 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6634 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6635 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6636 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6637 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6638 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6639 pnoRequest.aNetworks[i].authentication,
6640 pnoRequest.aNetworks[i].encryption,
6641 pnoRequest.aNetworks[i].ucChannelCount,
6642 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006643
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 /*Advance to channel list*/
6645 ptr += nOffset;
6646
Wilson Yang623f6592013-10-08 16:33:37 -07006647 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 {
6649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6650 "Incorrect number of channels");
6651 return VOS_STATUS_E_FAILURE;
6652 }
6653
6654 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6655 {
6656 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6657 {
Wilson Yang623f6592013-10-08 16:33:37 -07006658 if (1 != sscanf(ptr,"%hhu %n",
6659 &(pnoRequest.aNetworks[i].aChannels[j]),
6660 &nOffset))
6661 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6662 "PNO network channel input is not valid %s",ptr);
6663 return VOS_STATUS_E_FAILURE;
6664 }
6665 /*Advance to next channel number*/
6666 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 }
6668 }
6669
Jeff Johnson02797792013-10-26 19:17:13 -07006670 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006671 &(pnoRequest.aNetworks[i].bcastNetwType),
6672 &nOffset))
6673 {
6674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6675 "PNO broadcast network type input is not valid %s",ptr);
6676 return VOS_STATUS_E_FAILURE;
6677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006678
6679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6680 "PNO bcastNetwType %d offset %d",
6681 pnoRequest.aNetworks[i].bcastNetwType,
6682 nOffset );
6683
6684 /*Advance to rssi Threshold*/
6685 ptr += nOffset;
6686
Wilson Yang623f6592013-10-08 16:33:37 -07006687 if (1 != sscanf(ptr,"%hhu %n",
6688 &(pnoRequest.aNetworks[i].rssiThreshold),
6689 &nOffset))
6690 {
6691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6692 "PNO rssi threshold input is not valid %s",ptr);
6693 return VOS_STATUS_E_FAILURE;
6694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006695
6696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6697 "PNO rssi %d offset %d",
6698 pnoRequest.aNetworks[i].rssiThreshold,
6699 nOffset );
6700 /*Advance to next network*/
6701 ptr += nOffset;
6702 }/*For ucNetworkCount*/
6703
6704 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006705 &(pnoRequest.scanTimers.ucScanTimersCount),
6706 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006707
6708 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07006709 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 {
6711 ptr += nOffset;
6712
Jeff Johnson8301aa12013-03-28 14:27:29 -07006713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6714 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 pnoRequest.scanTimers.ucScanTimersCount,
6716 nOffset );
6717
6718 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
6719 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 "Incorrect cmd - too many scan timers");
6722 return VOS_STATUS_E_FAILURE;
6723 }
6724
6725 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
6726 {
Jeff Johnson02797792013-10-26 19:17:13 -07006727 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006728 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
6729 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
6730 &nOffset);
6731
Wilson Yang623f6592013-10-08 16:33:37 -07006732 if (2 != ucParams)
6733 {
6734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6735 "Incorrect cmd - diff params then expected %d", ucParams);
6736 return VOS_STATUS_E_FAILURE;
6737 }
6738
Jeff Johnson8301aa12013-03-28 14:27:29 -07006739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6740 "PNO Timer value %d Timer repeat %d offset %d",
6741 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
6743 nOffset );
6744
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 ptr += nOffset;
6746 }
6747
6748 }
6749 else
6750 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6752 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
6754
6755 /*Scan timers defaults to 5 minutes*/
6756 pnoRequest.scanTimers.ucScanTimersCount = 1;
6757 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
6758 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
6759 }
6760
Wilson Yang623f6592013-10-08 16:33:37 -07006761 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006762
6763 pnoRequest.modePNO = ucMode;
6764 /*for LA we just expose suspend option*/
6765 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
6766 {
6767 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
6768 }
6769
6770 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6771 pAdapter->sessionId,
6772 found_pref_network_cb, pAdapter);
6773
6774 return VOS_STATUS_SUCCESS;
6775}/*iw_set_pno*/
6776
6777VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
6778 union iwreq_data *wrqu, char *extra, int nOffset)
6779{
6780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6781 v_U8_t rssiThreshold = 0;
6782 v_U8_t nRead;
6783
Arif Hussain7adce1b2013-11-11 22:59:34 -08006784 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 &rssiThreshold);
6786
6787 if ( 1 != nRead )
6788 {
6789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6790 "Incorrect format");
6791 return VOS_STATUS_E_FAILURE;
6792 }
6793
6794 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
6795 return VOS_STATUS_SUCCESS;
6796}
6797
6798
6799static int iw_set_pno_priv(struct net_device *dev,
6800 struct iw_request_info *info,
6801 union iwreq_data *wrqu, char *extra)
6802{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006803 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6804
6805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006807
6808 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6809 {
6810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6811 "%s:LOGP in Progress. Ignore!!!", __func__);
6812 return -EBUSY;
6813 }
6814 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006815}
6816#endif /*FEATURE_WLAN_SCAN_PNO*/
6817
6818//Common function to SetBand
6819int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
6820{
6821 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6822 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6823 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6824 tANI_U8 band = 0;
6825 eCsrBand currBand = eCSR_BAND_MAX;
6826
6827 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
6828
6829 switch(band)
6830 {
6831 case WLAN_HDD_UI_BAND_AUTO:
6832 band = eCSR_BAND_ALL;
6833 break;
6834 case WLAN_HDD_UI_BAND_5_GHZ:
6835 band = eCSR_BAND_5G;
6836 break;
6837 case WLAN_HDD_UI_BAND_2_4_GHZ:
6838 band = eCSR_BAND_24;
6839 break;
6840 default:
6841 band = eCSR_BAND_MAX;
6842 }
6843
6844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006845 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006846
6847 if (band == eCSR_BAND_MAX)
6848 {
6849 /* Received change band request with invalid band value */
6850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006851 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 return -EIO;
6853 }
6854
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306855 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
6856 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
6857 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
6858 {
Shake M Subhani90cc8622013-11-05 16:13:10 +05306859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006860 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006861 band, pHddCtx->cfg_ini->nBandCapability);
6862 return -EIO;
6863 }
6864
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
6866 {
6867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6868 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006869 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 return -EIO;
6871 }
6872
6873 if (currBand != band)
6874 {
6875 /* Change band request received.
6876 * Abort pending scan requests, flush the existing scan results,
6877 * and change the band capability
6878 */
6879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6880 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006881 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006882
6883 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6884 {
6885 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
6886 eHalStatus status = eHAL_STATUS_SUCCESS;
6887 long lrc;
6888
6889 /* STA already connected on current band, So issue disconnect first,
6890 * then change the band*/
6891
6892 hddLog(VOS_TRACE_LEVEL_INFO,
6893 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
6894 __func__, csrGetCurrentBand(hHal), band);
6895
6896 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6897 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6898
6899 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6900 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6901
Jeff Johnson43971f52012-07-17 12:26:56 -07006902 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 {
6904 hddLog(VOS_TRACE_LEVEL_ERROR,
6905 "%s csrRoamDisconnect failure, returned %d \n",
6906 __func__, (int)status );
6907 return -EINVAL;
6908 }
6909
6910 lrc = wait_for_completion_interruptible_timeout(
6911 &pAdapter->disconnect_comp_var,
6912 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6913
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306914 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07006915
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07006916 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006917 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006918
6919 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6920 }
6921 }
6922
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306923 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Srinivas Girigowdade697412013-02-14 16:31:48 -08006925#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6926 sme_UpdateBgScanConfigIniChannelList(hHal, (eCsrBand) band);
6927#endif
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306928 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 {
6930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6931 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006932 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 return -EINVAL;
6934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 }
6937 return 0;
6938}
6939
6940static int iw_set_band_config(struct net_device *dev,
6941 struct iw_request_info *info,
6942 union iwreq_data *wrqu, char *extra)
6943{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006944 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006945 tANI_U8 *ptr = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006946 int ret = 0;
6947
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006949
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006950 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6951 {
6952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6953 "%s:LOGP in Progress. Ignore!!!", __func__);
6954 return -EBUSY;
6955 }
6956
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 if (memcmp(ptr, "SETBAND ", 8) == 0)
6958 {
6959 /* Change band request received */
6960 ret = hdd_setBand_helper(dev, ptr);
6961 return ret;
6962
6963 }
6964 return 0;
6965}
6966
6967static int iw_set_power_params_priv(struct net_device *dev,
6968 struct iw_request_info *info,
6969 union iwreq_data *wrqu, char *extra)
6970{
6971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6972 "Set power params Private");
6973 return iw_set_power_params(dev,info,wrqu,extra,0);
6974}
6975
6976
6977
6978/*string based input*/
6979VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
6980 union iwreq_data *wrqu, char *extra, int nOffset)
6981{
6982 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6983 tSirSetPowerParamsReq powerRequest;
6984 char *ptr;
6985 v_U8_t ucType;
6986 v_U32_t uTotalSize, uValue;
6987 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6988
6989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6990 "Power Params data len %d data %s",
6991 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006992 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006993
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006994 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6995 {
6996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6997 "%s:LOGP in Progress. Ignore!!!", __func__);
6998 return -EBUSY;
6999 }
7000
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 if (wrqu->data.length <= nOffset )
7002 {
7003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7004 return VOS_STATUS_E_FAILURE;
7005 }
7006
7007 uTotalSize = wrqu->data.length - nOffset;
7008
7009 /*-----------------------------------------------------------------------
7010 Input is string based and expected to be like this:
7011
7012 <param_type> <param_value> <param_type> <param_value> ...
7013
7014 e.g:
7015 1 2 2 3 3 0 4 1 5 1
7016
7017 e.g. setting just a few:
7018 1 2 4 1
7019
7020 parameter types:
7021 -----------------------------
7022 1 - Ignore DTIM
7023 2 - Listen Interval
7024 3 - Broadcast Multicas Filter
7025 4 - Beacon Early Termination
7026 5 - Beacon Early Termination Interval
7027 -----------------------------------------------------------------------*/
7028 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7029 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7030 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7031 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7032 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7033
Arif Hussain7adce1b2013-11-11 22:59:34 -08007034 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007035
7036 while ( uTotalSize )
7037 {
Wilson Yang6f971452013-10-08 15:00:00 -07007038 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7039 {
7040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7041 "Invalid input parameter type %s",ptr);
7042 return VOS_STATUS_E_FAILURE;
7043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007044
7045 uTotalSize -= nOffset;
7046
7047 if (!uTotalSize)
7048 {
7049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007050 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 ucType, nOffset);
7052 return VOS_STATUS_E_FAILURE;
7053 }
7054
7055 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007056
Jeff Johnson02797792013-10-26 19:17:13 -07007057 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007058 {
7059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7060 "Invalid input parameter value %s",ptr);
7061 return VOS_STATUS_E_FAILURE;
7062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007063
7064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7065 "Power request parameter %d value %d offset %d",
7066 ucType, uValue, nOffset);
7067
7068 switch (ucType)
7069 {
7070 case eSIR_IGNORE_DTIM:
7071 powerRequest.uIgnoreDTIM = uValue;
7072 break;
7073 case eSIR_LISTEN_INTERVAL:
7074 powerRequest.uListenInterval = uValue;
7075 break;
7076 case eSIR_MCAST_BCAST_FILTER:
7077 powerRequest.uBcastMcastFilter = uValue;
7078 break;
7079 case eSIR_ENABLE_BET:
7080 powerRequest.uEnableBET = uValue;
7081 break;
7082 case eSIR_BET_INTERVAL:
7083 powerRequest.uBETInterval = uValue;
7084 break;
7085 default:
7086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007087 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007088 ucType, uValue, nOffset);
7089 return VOS_STATUS_E_FAILURE;
7090 }
7091
7092 uTotalSize -= nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7094 "Power request parameter %d Total size",
7095 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007097 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
7098 if(!(uTotalSize - nOffset) &&
7099 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7100 {
7101 uTotalSize = 0;
7102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007103
7104 }/*Go for as long as we have a valid string*/
7105
7106 /* put the device into full power*/
7107 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7108
7109 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007110 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007111
7112 /* put the device back to power save*/
7113 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7114
7115 return VOS_STATUS_SUCCESS;
7116}/*iw_set_power_params*/
7117
7118
7119// Define the Wireless Extensions to the Linux Network Device structure
7120// A number of these routines are NULL (meaning they are not implemented.)
7121
7122static const iw_handler we_handler[] =
7123{
7124 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7125 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7126 (iw_handler) NULL, /* SIOCSIWNWID */
7127 (iw_handler) NULL, /* SIOCGIWNWID */
7128 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7129 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7130 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7131 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7132 (iw_handler) NULL, /* SIOCSIWSENS */
7133 (iw_handler) NULL, /* SIOCGIWSENS */
7134 (iw_handler) NULL, /* SIOCSIWRANGE */
7135 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7136 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7137 (iw_handler) NULL, /* SIOCGIWPRIV */
7138 (iw_handler) NULL, /* SIOCSIWSTATS */
7139 (iw_handler) NULL, /* SIOCGIWSTATS */
7140 iw_handler_set_spy, /* SIOCSIWSPY */
7141 iw_handler_get_spy, /* SIOCGIWSPY */
7142 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7143 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7144 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7145 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7146 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7147 (iw_handler) NULL, /* SIOCGIWAPLIST */
7148 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7149 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7150 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7151 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7152 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7153 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7154 (iw_handler) NULL, /* -- hole -- */
7155 (iw_handler) NULL, /* -- hole -- */
7156 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7157 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7158 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7159 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7160 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7161 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7162 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7163 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7164 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7165 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7166 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7167 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7168 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7169 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7170 (iw_handler) NULL, /* -- hole -- */
7171 (iw_handler) NULL, /* -- hole -- */
7172 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7173 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7174 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7175 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7176 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7177 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7178 (iw_handler) NULL, /* SIOCSIWPMKSA */
7179};
7180
7181static const iw_handler we_private[] = {
7182
7183 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7184 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7185 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7186 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7187 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7188 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7189 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7190 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7191 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7192 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007193#ifdef FEATURE_OEM_DATA_SUPPORT
7194 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7195 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7196#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007197
7198#ifdef FEATURE_WLAN_WAPI
7199 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7200 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7201 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7202 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7203 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7204 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7205#endif /* FEATURE_WLAN_WAPI */
7206#ifdef WLAN_FEATURE_VOWIFI_11R
7207 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7208#endif
7209 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7210 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7211 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7212#ifdef WLAN_FEATURE_PACKET_FILTERING
7213 ,
7214 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7215#endif
7216#ifdef FEATURE_WLAN_SCAN_PNO
7217 ,
7218 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7219#endif
7220 ,
7221 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7222 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7223 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7224 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007225 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007226};
7227
7228/*Maximum command length can be only 15 */
7229static const struct iw_priv_args we_private_args[] = {
7230
7231 /* handlers for main ioctl */
7232 { WLAN_PRIV_SET_INT_GET_NONE,
7233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7234 0,
7235 "" },
7236
7237 /* handlers for sub-ioctl */
7238 { WE_SET_11D_STATE,
7239 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7240 0,
7241 "set11Dstate" },
7242
7243 { WE_WOWL,
7244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7245 0,
7246 "wowl" },
7247
7248 { WE_SET_POWER,
7249 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7250 0,
7251 "setPower" },
7252
7253 { WE_SET_MAX_ASSOC,
7254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7255 0,
7256 "setMaxAssoc" },
7257
7258 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7260 0,
7261 "setAutoChannel" },
7262
7263 { WE_SET_DATA_INACTIVITY_TO,
7264 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7265 0,
7266 "inactivityTO" },
7267
7268 { WE_SET_MAX_TX_POWER,
7269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7270 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007271 "setMaxTxPower" },
7272
7273 { WE_SET_MAX_TX_POWER_2_4,
7274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7275 0,
7276 "setTxMaxPower2G" },
7277
7278 { WE_SET_MAX_TX_POWER_5_0,
7279 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7280 0,
7281 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007282
7283 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7284 * as well to keep same syntax as in SAP. Now onwards, STA
7285 * will support both */
7286 { WE_SET_MAX_TX_POWER,
7287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7288 0,
7289 "setTxMaxPower" },
7290
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7292 * 1 = enable and 0 = disable */
7293 {
7294 WE_SET_HIGHER_DTIM_TRANSITION,
7295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7296 0,
7297 "setHDtimTransn" },
7298
7299 { WE_SET_TM_LEVEL,
7300 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7301 0,
7302 "setTmLevel" },
7303
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307304 { WE_ENABLE_STRICT_FCC_REG,
7305 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7306 0,
7307 "setStrictFCCreg" },
7308
Jeff Johnson295189b2012-06-20 16:38:30 -07007309 /* handlers for main ioctl */
7310 { WLAN_PRIV_SET_NONE_GET_INT,
7311 0,
7312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7313 "" },
7314
7315 /* handlers for sub-ioctl */
7316 { WE_GET_11D_STATE,
7317 0,
7318 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7319 "get11Dstate" },
7320
7321 { WE_IBSS_STATUS,
7322 0,
7323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7324 "getAdhocStatus" },
7325
7326 { WE_PMC_STATE,
7327 0,
7328 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7329 "pmcState" },
7330
7331 { WE_GET_WLAN_DBG,
7332 0,
7333 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7334 "getwlandbg" },
7335
7336 { WE_MODULE_DOWN_IND,
7337 0,
7338 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7339 "moduleDownInd" },
7340
7341 { WE_GET_MAX_ASSOC,
7342 0,
7343 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7344 "getMaxAssoc" },
7345
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 { WE_GET_WDI_DBG,
7347 0,
7348 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7349 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007350
7351 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7352 0,
7353 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7354 "getAutoChannel" },
7355
7356 { WE_GET_CONCURRENCY_MODE,
7357 0,
7358 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7359 "getconcurrency" },
7360
7361 /* handlers for main ioctl */
7362 { WLAN_PRIV_SET_CHAR_GET_NONE,
7363 IW_PRIV_TYPE_CHAR| 512,
7364 0,
7365 "" },
7366
7367 /* handlers for sub-ioctl */
7368 { WE_WOWL_ADD_PTRN,
7369 IW_PRIV_TYPE_CHAR| 512,
7370 0,
7371 "wowlAddPtrn" },
7372
7373 { WE_WOWL_DEL_PTRN,
7374 IW_PRIV_TYPE_CHAR| 512,
7375 0,
7376 "wowlDelPtrn" },
7377
7378#if defined WLAN_FEATURE_VOWIFI
7379 /* handlers for sub-ioctl */
7380 { WE_NEIGHBOR_REPORT_REQUEST,
7381 IW_PRIV_TYPE_CHAR | 512,
7382 0,
7383 "neighbor" },
7384#endif
7385 { WE_SET_AP_WPS_IE,
7386 IW_PRIV_TYPE_CHAR| 512,
7387 0,
7388 "set_ap_wps_ie" },
7389
7390 { WE_SET_CONFIG,
7391 IW_PRIV_TYPE_CHAR| 512,
7392 0,
7393 "setConfig" },
7394
7395 /* handlers for main ioctl */
7396 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7398 0,
7399 "" },
7400
7401 /* handlers for sub-ioctl */
7402 { WE_SET_WLAN_DBG,
7403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7404 0,
7405 "setwlandbg" },
7406
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 { WE_SET_WDI_DBG,
7408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7409 0,
7410 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007411
7412 { WE_SET_SAP_CHANNELS,
7413 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7414 0,
7415 "setsapchannels" },
7416
7417 /* handlers for main ioctl */
7418 { WLAN_PRIV_GET_CHAR_SET_NONE,
7419 0,
7420 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7421 "" },
7422
7423 /* handlers for sub-ioctl */
7424 { WE_WLAN_VERSION,
7425 0,
7426 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7427 "version" },
7428 { WE_GET_STATS,
7429 0,
7430 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7431 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307432 { WE_GET_STATES,
7433 0,
7434 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7435 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007436 { WE_GET_CFG,
7437 0,
7438 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7439 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007440#ifdef WLAN_FEATURE_11AC
7441 { WE_GET_RSSI,
7442 0,
7443 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7444 "getRSSI" },
7445#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007446#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
7447 { WE_GET_ROAM_RSSI,
7448 0,
7449 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7450 "getRoamRSSI" },
7451#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 { WE_GET_WMM_STATUS,
7453 0,
7454 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7455 "getWmmStatus" },
7456 {
7457 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307458 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007459 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7460 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007461#ifdef FEATURE_WLAN_TDLS
7462 {
7463 WE_GET_TDLS_PEERS,
7464 0,
7465 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7466 "getTdlsPeers" },
7467#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007468#ifdef WLAN_FEATURE_11W
7469 {
7470 WE_GET_11W_INFO,
7471 0,
7472 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7473 "getPMFInfo" },
7474#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 /* handlers for main ioctl */
7476 { WLAN_PRIV_SET_NONE_GET_NONE,
7477 0,
7478 0,
7479 "" },
7480
7481 /* handlers for sub-ioctl */
7482 { WE_CLEAR_STATS,
7483 0,
7484 0,
7485 "clearStats" },
7486 { WE_INIT_AP,
7487 0,
7488 0,
7489 "initAP" },
7490 { WE_STOP_AP,
7491 0,
7492 0,
7493 "exitAP" },
7494 { WE_ENABLE_AMP,
7495 0,
7496 0,
7497 "enableAMP" },
7498 { WE_DISABLE_AMP,
7499 0,
7500 0,
7501 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007502 { WE_ENABLE_DXE_STALL_DETECT,
7503 0,
7504 0,
7505 "dxeStallDetect" },
7506 { WE_DISPLAY_DXE_SNAP_SHOT,
7507 0,
7508 0,
7509 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307510 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7511 0,
7512 0,
7513 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007514 {
7515 WE_SET_REASSOC_TRIGGER,
7516 0,
7517 0,
7518 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007519
7520 /* handlers for main ioctl */
7521 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7522 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7523 0,
7524 "" },
7525
7526 /* handlers for sub-ioctl */
7527 { WE_LOG_DUMP_CMD,
7528 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7529 0,
7530 "dump" },
7531
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007532 /* handlers for sub ioctl */
7533 {
7534 WE_MCC_CONFIG_CREDENTIAL,
7535 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7536 0,
7537 "setMccCrdnl" },
7538
7539 /* handlers for sub ioctl */
7540 {
7541 WE_MCC_CONFIG_PARAMS,
7542 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7543 0,
7544 "setMccConfig" },
7545
Chilam NG571c65a2013-01-19 12:27:36 +05307546#ifdef FEATURE_WLAN_TDLS
7547 /* handlers for sub ioctl */
7548 {
7549 WE_TDLS_CONFIG_PARAMS,
7550 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7551 0,
7552 "setTdlsConfig" },
7553#endif
7554
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 /* handlers for main ioctl */
7556 { WLAN_PRIV_ADD_TSPEC,
7557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7558 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7559 "addTspec" },
7560
7561 /* handlers for main ioctl */
7562 { WLAN_PRIV_DEL_TSPEC,
7563 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7565 "delTspec" },
7566
7567 /* handlers for main ioctl */
7568 { WLAN_PRIV_GET_TSPEC,
7569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7570 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7571 "getTspec" },
7572
Jeff Johnsone7245742012-09-05 17:12:55 -07007573#ifdef FEATURE_OEM_DATA_SUPPORT
7574 /* handlers for main ioctl - OEM DATA */
7575 {
7576 WLAN_PRIV_SET_OEM_DATA_REQ,
7577 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7578 0,
7579 "set_oem_data_req" },
7580
7581 /* handlers for main ioctl - OEM DATA */
7582 {
7583 WLAN_PRIV_GET_OEM_DATA_RSP,
7584 0,
7585 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7586 "get_oem_data_rsp" },
7587#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007588
7589#ifdef FEATURE_WLAN_WAPI
7590 /* handlers for main ioctl SET_WAPI_MODE */
7591 { WLAN_PRIV_SET_WAPI_MODE,
7592 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7593 0,
7594 "SET_WAPI_MODE" },
7595
7596 /* handlers for main ioctl GET_WAPI_MODE */
7597 { WLAN_PRIV_GET_WAPI_MODE,
7598 0,
7599 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7600 "GET_WAPI_MODE" },
7601
7602 /* handlers for main ioctl SET_ASSOC_INFO */
7603 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
7604 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
7605 0,
7606 "SET_WAPI_ASSOC" },
7607
7608 /* handlers for main ioctl SET_WAPI_KEY */
7609 { WLAN_PRIV_SET_WAPI_KEY,
7610 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
7611 0,
7612 "SET_WAPI_KEY" },
7613
7614 /* handlers for main ioctl SET_WAPI_BKID */
7615 { WLAN_PRIV_SET_WAPI_BKID,
7616 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7617 0,
7618 "SET_WAPI_BKID" },
7619
7620 /* handlers for main ioctl GET_WAPI_BKID */
7621 { WLAN_PRIV_GET_WAPI_BKID,
7622 0,
7623 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7624 "GET_WAPI_BKID" },
7625#endif /* FEATURE_WLAN_WAPI */
7626
7627 /* handlers for main ioctl - host offload */
7628 {
7629 WLAN_PRIV_SET_HOST_OFFLOAD,
7630 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
7631 0,
7632 "setHostOffload" },
7633
7634 {
7635 WLAN_GET_WLAN_STATISTICS,
7636 0,
7637 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
7638 "getWlanStats" },
7639
7640 {
7641 WLAN_SET_KEEPALIVE_PARAMS,
7642 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
7643 0,
7644 "setKeepAlive" },
7645#ifdef WLAN_FEATURE_PACKET_FILTERING
7646 {
7647 WLAN_SET_PACKET_FILTER_PARAMS,
7648 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
7649 0,
7650 "setPktFilter" },
7651#endif
7652#ifdef FEATURE_WLAN_SCAN_PNO
7653 {
7654 WLAN_SET_PNO,
7655 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7656 0,
7657 "setpno" },
7658#endif
7659 {
7660 WLAN_SET_BAND_CONFIG,
7661 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7662 0,
7663 "SETBAND" },
7664 /* handlers for dynamic MC BC ioctl */
7665 {
7666 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007667 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 0,
7669 "setMCBCFilter" },
7670 {
7671 WLAN_PRIV_CLEAR_MCBC_FILTER,
7672 0,
7673 0,
7674 "clearMCBCFilter" },
7675 {
7676 WLAN_SET_POWER_PARAMS,
7677 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7678 0,
7679 "setpowerparams" },
7680 {
7681 WLAN_GET_LINK_SPEED,
7682 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05307683 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007684};
7685
7686
7687
7688const struct iw_handler_def we_handler_def = {
7689 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
7690 .num_private = sizeof(we_private) / sizeof(we_private[0]),
7691 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
7692
7693 .standard = (iw_handler *)we_handler,
7694 .private = (iw_handler *)we_private,
7695 .private_args = we_private_args,
7696 .get_wireless_stats = get_wireless_stats,
7697};
7698
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007699int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
7700{
7701 v_U32_t cmd = 288; //Command to RIVA
7702 hdd_context_t *pHddCtx = NULL;
7703 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7704 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7705 /*
7706 *configMccParam : specify the bit which needs to be modified
7707 *allowed to update based on wlan_qcom_cfg.ini
7708 * configuration
7709 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
7710 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
7711 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
7712 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
7713 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
7714 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
7715 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
7716 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
7717 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
7718 * Bit 9 : Reserved
7719 */
7720 switch (arg1)
7721 {
7722 //Update MCC SCHEDULE_TIME_SLICE parameter
7723 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
7724 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
7725 {
7726 if((arg2 >= 5) && (arg2 <= 20))
7727 {
7728 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7729 }
7730 else
7731 {
7732 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7733 return 0;
7734 }
7735 }
7736 break;
7737
7738 //Update MCC MAX_NULL_SEND_TIME parameter
7739 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
7740 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
7741 {
7742 if((arg2 >= 1) && (arg2 <= 10))
7743 {
7744 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7745 }
7746 else
7747 {
7748 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7749 return 0;
7750 }
7751 }
7752 break;
7753
7754 //Update MCC TX_EARLY_STOP_TIME parameter
7755 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
7756 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
7757 {
7758 if((arg2 >= 1) && (arg2 <= 10))
7759 {
7760 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7761 }
7762 else
7763 {
7764 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7765 return 0;
7766 }
7767 }
7768 break;
7769
7770 //Update MCC RX_DRAIN_TIME parameter
7771 case MCC_RX_DRAIN_TIME_CFG_PARAM :
7772 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
7773 {
7774 if((arg2 >= 1) && (arg2 <= 10))
7775 {
7776 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7777 }
7778 else
7779 {
7780 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7781 return 0;
7782 }
7783 }
7784 break;
7785
7786 //Update MCC CHANNEL_SWITCH_TIME parameter
7787 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
7788 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
7789 {
7790 if((arg2 >= 1) && (arg2 <= 20))
7791 {
7792 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7793 }
7794 else
7795 {
7796 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7797 return 0;
7798 }
7799 }
7800 break;
7801
7802 //Update MCC MIN_CHANNEL_TIME parameter
7803 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
7804 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
7805 {
7806 if((arg2 >= 5) && (arg2 <= 20))
7807 {
7808 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7809 }
7810 else
7811 {
7812 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7813 return 0;
7814 }
7815 }
7816 break;
7817
7818 //Update MCC PARK_BEFORE_TBTT parameter
7819 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
7820 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
7821 {
7822 if((arg2 >= 1) && (arg2 <= 5))
7823 {
7824 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7825 }
7826 else
7827 {
7828 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7829 return 0;
7830 }
7831 }
7832 break;
7833
7834 //Update MCC MIN_AFTER_DTIM parameter
7835 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
7836 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
7837 {
7838 if((arg2 >= 5) && (arg2 <= 15))
7839 {
7840 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7841 }
7842 else
7843 {
7844 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7845 return 0;
7846 }
7847 }
7848 break;
7849
7850 //Update MCC TOO_CLOSE_MARGIN parameter
7851 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
7852 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
7853 {
7854 if((arg2 >= 1) && (arg2 <= 3))
7855 {
7856 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7857 }
7858 else
7859 {
7860 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7861 return 0;
7862 }
7863 }
7864 break;
7865
7866 default :
7867 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d\n",
7868 __FUNCTION__,arg1);
7869 break;
7870 }
7871 return 0;
7872}
7873
Jeff Johnson295189b2012-06-20 16:38:30 -07007874int hdd_set_wext(hdd_adapter_t *pAdapter)
7875{
7876 hdd_wext_state_t *pwextBuf;
7877 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007878 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007879
7880 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7881
7882 // Now configure the roaming profile links. To SSID and bssid.
7883 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
7884 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
7885
7886 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
7887 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
7888
7889 /*Set the numOfChannels to zero to scan all the channels*/
7890 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
7891 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
7892
7893 /* Default is no encryption */
7894 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
7895 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7896
7897 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
7898 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7899
7900 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
7901
7902 /* Default is no authentication */
7903 pwextBuf->roamProfile.AuthType.numEntries = 1;
7904 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
7905
7906 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
7907 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
7908
7909 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007910 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07007911
7912 hdd_clearRoamProfileIe(pAdapter);
7913
7914 return VOS_STATUS_SUCCESS;
7915
7916 }
7917
7918int hdd_register_wext(struct net_device *dev)
7919 {
7920 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7921 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7922 VOS_STATUS status;
7923
7924 ENTER();
7925
7926 // Zero the memory. This zeros the profile structure.
7927 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
7928
7929 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
7930
7931
7932 status = hdd_set_wext(pAdapter);
7933
7934 if(!VOS_IS_STATUS_SUCCESS(status)) {
7935
7936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!\n"));
7937 return eHAL_STATUS_FAILURE;
7938 }
7939
7940 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
7941 {
7942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!\n"));
7943 return eHAL_STATUS_FAILURE;
7944 }
7945
7946 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
7947 {
7948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!\n"));
7949 return eHAL_STATUS_FAILURE;
7950 }
7951
7952 // Register as a wireless device
7953 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
7954
7955 EXIT();
7956 return 0;
7957}
7958
7959int hdd_UnregisterWext(struct net_device *dev)
7960{
7961#if 0
7962 hdd_wext_state_t *wextBuf;
7963 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7964
7965 ENTER();
7966 // Set up the pointer to the Wireless Extensions state structure
7967 wextBuf = pAdapter->pWextState;
7968
7969 // De-allocate the Wireless Extensions state structure
7970 kfree(wextBuf);
7971
7972 // Clear out the pointer to the Wireless Extensions state structure
7973 pAdapter->pWextState = NULL;
7974
7975 EXIT();
7976#endif
7977 dev->wireless_handlers = NULL;
7978 return 0;
7979}
7980
7981