blob: 3672d12db86e6bccb90173d68faace6887578221 [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>
66#include <wlan_hdd_includes.h>
67#include <wlan_btc_svc.h>
68#include <wlan_nlink_common.h>
69#ifdef WLAN_BTAMP_FEATURE
70#include <bap_hdd_main.h>
71#endif
72#include <vos_api.h>
73#include <net/arp.h>
74#include "ccmApi.h"
75#include "sirParams.h"
76#include "csrApi.h"
77#include "csrInsideApi.h"
78#if defined WLAN_FEATURE_VOWIFI
79#include "smeRrmInternal.h"
80#endif
81#include <aniGlobal.h>
82#include "dot11f.h"
83#include <wlan_hdd_wowl.h>
84#include <wlan_hdd_cfg.h>
85#include <wlan_hdd_wmm.h>
86#include "utilsApi.h"
87#ifdef WLAN_FEATURE_P2P
88#include "wlan_hdd_p2p.h"
89#endif
Chilam NG571c65a2013-01-19 12:27:36 +053090#ifdef FEATURE_WLAN_TDLS
91#include "wlan_hdd_tdls.h"
92#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070093
94#ifdef CONFIG_HAS_EARLYSUSPEND
95#include <linux/earlysuspend.h>
96#endif
97#include "wlan_hdd_power.h"
98#include "qwlan_version.h"
99#include <vos_power.h>
100#include "wlan_hdd_host_offload.h"
101#include "wlan_hdd_keep_alive.h"
102#ifdef WLAN_FEATURE_PACKET_FILTERING
103#include "wlan_hdd_packet_filtering.h"
104#endif
105
106#ifdef CONFIG_CFG80211
107#include <linux/wireless.h>
108#include <net/cfg80211.h>
109#endif
110#ifdef FEATURE_WLAN_INTEGRATED_SOC
111#include "wlan_qct_pal_trace.h"
112#endif // FEATURE_WLAN_INTEGRATED_SOC
113
114#include "wlan_hdd_misc.h"
115#include "bap_hdd_misc.h"
116
117#include "wlan_hdd_dev_pwr.h"
118#include "qc_sap_ioctl.h"
119#define WE_MAX_STR_LEN 1024
120
121#ifdef CONFIG_HAS_EARLYSUSPEND
122extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
123extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
124#endif
125
Jeff Johnsone7245742012-09-05 17:12:55 -0700126#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800127#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700128#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700129
130#define HDD_FINISH_ULA_TIME_OUT 800
131
132extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
133int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
134
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700135static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700136module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
137
138struct statsContext
139{
140 struct completion completion;
141 hdd_adapter_t *pAdapter;
142 unsigned int magic;
143};
144
145#define STATS_CONTEXT_MAGIC 0x53544154 //STAT
146#define RSSI_CONTEXT_MAGIC 0x52535349 //RSSI
147#define POWER_CONTEXT_MAGIC 0x504F5752 // POWR
148
149/* To Validate Channel against the Frequency and Vice-Versa */
150static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
151 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
152 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
153 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
154 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
155 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
156 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
157 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
158 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
159
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800160#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700161
162/* Private ioctls and their sub-ioctls */
163#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
164#define WE_SET_11D_STATE 1
165#define WE_WOWL 2
166#define WE_SET_POWER 3
167#define WE_SET_MAX_ASSOC 4
168#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
169#define WE_SET_DATA_INACTIVITY_TO 6
170#define WE_SET_MAX_TX_POWER 7
171#define WE_SET_HIGHER_DTIM_TRANSITION 8
172#define WE_SET_TM_LEVEL 9
173
174/* Private ioctls and their sub-ioctls */
175#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
176#define WE_GET_11D_STATE 1
177#define WE_IBSS_STATUS 2
178#define WE_PMC_STATE 3
179#define WE_GET_WLAN_DBG 4
180#define WE_MODULE_DOWN_IND 5
181#define WE_GET_MAX_ASSOC 6
182#define WE_GET_WDI_DBG 7
183#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
184#define WE_GET_CONCURRENCY_MODE 9
185/* Private ioctls and their sub-ioctls */
186#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
187
188/* Private ioctls and their sub-ioctls */
189#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
190#define WE_WOWL_ADD_PTRN 1
191#define WE_WOWL_DEL_PTRN 2
192#if defined WLAN_FEATURE_VOWIFI
193#define WE_NEIGHBOR_REPORT_REQUEST 3
194#endif
195#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
196#define WE_SET_CONFIG 5
197
198/* Private ioctls and their sub-ioctls */
199#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
200#define WE_SET_WLAN_DBG 1
201#define WE_SET_WDI_DBG 2
202#define WE_SET_SAP_CHANNELS 3
203
204/* Private ioctls and their sub-ioctls */
205#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
206#define WE_WLAN_VERSION 1
207#define WE_GET_STATS 2
208#define WE_GET_CFG 3
209#define WE_GET_WMM_STATUS 4
210#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700211#ifdef WLAN_FEATURE_11AC
212#define WE_GET_RSSI 6
213#endif
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800214#ifdef FEATURE_WLAN_TDLS
215#define WE_GET_TDLS_PEERS 8
216#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700217
218/* Private ioctls and their sub-ioctls */
219#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
220#define WE_CLEAR_STATS 1
221#define WE_INIT_AP 2
222#define WE_STOP_AP 3
223#define WE_ENABLE_AMP 4
224#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700225#define WE_ENABLE_DXE_STALL_DETECT 6
226#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700227#define WE_SET_REASSOC_TRIGGER 8
Jeff Johnson295189b2012-06-20 16:38:30 -0700228
229/* Private ioctls and their sub-ioctls */
230#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
231#define WE_LOG_DUMP_CMD 1
232
233#ifdef WLAN_FEATURE_P2P
234#define WE_P2P_NOA_CMD 2
235#endif
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800236//IOCTL to configure MCC params
237#define WE_MCC_CONFIG_CREDENTIAL 3
238#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700239
Chilam NG571c65a2013-01-19 12:27:36 +0530240#ifdef FEATURE_WLAN_TDLS
241#define WE_TDLS_CONFIG_PARAMS 5
242#endif
243
Chilam Ng01120412013-02-19 18:32:21 -0800244#ifdef FEATURE_WLAN_TDLS
245#undef MAX_VAR_ARGS
246#define MAX_VAR_ARGS 10
247#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700248#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800249#endif
250
Jeff Johnson295189b2012-06-20 16:38:30 -0700251
252/* Private ioctls (with no sub-ioctls) */
253/* note that they must be odd so that they have "get" semantics */
254#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
255#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
256#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
257
258#ifdef FEATURE_WLAN_WAPI
259/* Private ioctls EVEN NO: SET, ODD NO:GET */
260#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
261#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
262#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
263#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
264#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
265#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
266#define WAPI_PSK_AKM_SUITE 0x02721400
267#define WAPI_CERT_AKM_SUITE 0x01721400
268#endif
269
Jeff Johnsone7245742012-09-05 17:12:55 -0700270#ifdef FEATURE_OEM_DATA_SUPPORT
271/* Private ioctls for setting the measurement configuration */
272#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
273#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
274#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700275
276#ifdef WLAN_FEATURE_VOWIFI_11R
277#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
278#endif
279
280/* Private ioctl for setting the host offload feature */
281#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
282
283/* Private ioctl to get the statistics */
284#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
285
286/* Private ioctl to set the Keep Alive Params */
287#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
288#ifdef WLAN_FEATURE_PACKET_FILTERING
289/* Private ioctl to set the Packet Filtering Params */
290#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
291#endif
292
293#ifdef FEATURE_WLAN_SCAN_PNO
294/* Private ioctl to get the statistics */
295#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
296#endif
297
298#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
299
300#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
301#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700302/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700303
Jeff Johnson295189b2012-06-20 16:38:30 -0700304#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
305#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
306
307#define WLAN_STATS_INVALID 0
308#define WLAN_STATS_RETRY_CNT 1
309#define WLAN_STATS_MUL_RETRY_CNT 2
310#define WLAN_STATS_TX_FRM_CNT 3
311#define WLAN_STATS_RX_FRM_CNT 4
312#define WLAN_STATS_FRM_DUP_CNT 5
313#define WLAN_STATS_FAIL_CNT 6
314#define WLAN_STATS_RTS_FAIL_CNT 7
315#define WLAN_STATS_ACK_FAIL_CNT 8
316#define WLAN_STATS_RTS_SUC_CNT 9
317#define WLAN_STATS_RX_DISCARD_CNT 10
318#define WLAN_STATS_RX_ERROR_CNT 11
319#define WLAN_STATS_TX_BYTE_CNT 12
320
321#define WLAN_STATS_RX_BYTE_CNT 13
322#define WLAN_STATS_RX_RATE 14
323#define WLAN_STATS_TX_RATE 15
324
Jeff Johnsone7245742012-09-05 17:12:55 -0700325#define WLAN_STATS_RX_UC_BYTE_CNT 16
326#define WLAN_STATS_RX_MC_BYTE_CNT 17
327#define WLAN_STATS_RX_BC_BYTE_CNT 18
328#define WLAN_STATS_TX_UC_BYTE_CNT 19
329#define WLAN_STATS_TX_MC_BYTE_CNT 20
330#define WLAN_STATS_TX_BC_BYTE_CNT 21
331
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800332#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
333 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
334 { \
335 *__p++ = __type; \
336 *__p++ = __size; \
337 memcpy(__p, __val, __size); \
338 __p += __size; \
339 __tlen += __size + 2; \
340 } \
341 else \
342 { \
343 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!\n"); \
344 } \
345 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700346
347#define VERSION_VALUE_MAX_LEN 32
348
349#define TX_PER_TRACKING_DEFAULT_RATIO 5
350#define TX_PER_TRACKING_MAX_RATIO 10
351#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
352
353#define WLAN_HDD_UI_BAND_AUTO 0
354#define WLAN_HDD_UI_BAND_5_GHZ 1
355#define WLAN_HDD_UI_BAND_2_4_GHZ 2
356#define WLAN_HDD_UI_SET_BAND_VALUE_OFFSET 8
357
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800358/*MCC Configuration parameters */
359enum {
360 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
361 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
362 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
363 MCC_RX_DRAIN_TIME_CFG_PARAM,
364 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
365 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
366 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
367 MCC_MIN_AFTER_DTIM_CFG_PARAM,
368 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
369};
370
371int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
372 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
373
Jeff Johnson295189b2012-06-20 16:38:30 -0700374#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -0700375int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
376 v_U8_t sessionId);
377void wlan_hdd_set_mc_addr_list(hdd_context_t *pHddCtx, v_U8_t set, v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700378#endif
379
Jeff Johnson295189b2012-06-20 16:38:30 -0700380/**---------------------------------------------------------------------------
381
382 \brief hdd_wlan_get_version() -
383
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800384 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700385
386 \param - pAdapter Pointer to the adapter.
387 wrqu - Pointer to IOCTL REQUEST Data.
388 extra - Pointer to char
389
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800390 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700391
392 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800393void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
394 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700395{
396 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800397 tSirVersionString wcnss_SW_version;
398 tSirVersionString wcnss_HW_version;
399 char *pSWversion;
400 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700402
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800403 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
404 sizeof(wcnss_SW_version));
405 if (VOS_IS_STATUS_SUCCESS(status))
406 {
407 pSWversion = wcnss_SW_version;
408 }
409 else
410 {
411 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 }
413
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800414 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
415 sizeof(wcnss_HW_version));
416 if (VOS_IS_STATUS_SUCCESS(status))
417 {
418 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700419 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800420 else
421 {
422 pHWversion = "Unknown";
423 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700424
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800425 wrqu->data.length = snprintf(extra, WE_MAX_STR_LEN,
426 "Host SW:%s, FW:%s, HW:%s",
427 QWLAN_VERSIONSTR,
428 pSWversion,
429 pHWversion);
430
431 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700432}
433
Jeff Johnson295189b2012-06-20 16:38:30 -0700434int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
435{
436 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
437 v_U32_t threshold = 0,status = 0;
438
439 ENTER();
440
441 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
443 "%s:LOGP in Progress. Ignore!!!",__func__);
444 return status;
445 }
446
447 if ( eHAL_STATUS_SUCCESS !=
448 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
449 {
450 return -EIO;
451 }
452 wrqu->rts.value = threshold;
453
454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
455 ("Rts-Threshold=%ld!!\n"), wrqu->rts.value);
456
457 EXIT();
458
459 return 0;
460}
461
462int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
463{
464 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
465 v_U32_t threshold = 0,status = 0;
466
467 ENTER();
468
469 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
471 "%s:LOGP in Progress. Ignore!!!",__func__);
472 return status;
473 }
474
475 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
476 != eHAL_STATUS_SUCCESS )
477 {
478 return -EIO;
479 }
480 wrqu->frag.value = threshold;
481
482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
483 ("Frag-Threshold=%ld!!\n"), wrqu->frag.value);
484
485 EXIT();
486
487 return 0;
488}
489
490int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
491{
Jeff Johnsone7245742012-09-05 17:12:55 -0700492 int i;
493 if (channel > 0)
494 {
495 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
496 {
497 if (channel == freq_chan_map[i].chan)
498 {
499 *pfreq = freq_chan_map[i].freq;
500 return 1;
501 }
502 }
503 }
504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
505 ("Invalid channel no=%d!!\n"), channel);
506 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700507}
508
509static v_BOOL_t
510hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
511{
512 v_BOOL_t rsnType = VOS_FALSE;
513 // is the authType supported?
514 switch (authType)
515 {
516 case eCSR_AUTH_TYPE_NONE: //never used
517 rsnType = eANI_BOOLEAN_FALSE;
518 break;
519 // MAC layer authentication types
520 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
521 rsnType = eANI_BOOLEAN_FALSE;
522 break;
523 case eCSR_AUTH_TYPE_SHARED_KEY:
524 rsnType = eANI_BOOLEAN_FALSE;
525 break;
526 case eCSR_AUTH_TYPE_AUTOSWITCH:
527 rsnType = eANI_BOOLEAN_FALSE;
528 break;
529
530 // Upper layer authentication types
531 case eCSR_AUTH_TYPE_WPA:
532 rsnType = eANI_BOOLEAN_TRUE;
533 break;
534 case eCSR_AUTH_TYPE_WPA_PSK:
535 rsnType = eANI_BOOLEAN_TRUE;
536 break;
537 case eCSR_AUTH_TYPE_WPA_NONE:
538 rsnType = eANI_BOOLEAN_TRUE;
539 break;
540#ifdef WLAN_FEATURE_VOWIFI_11R
541 case eCSR_AUTH_TYPE_FT_RSN:
542#endif
543 case eCSR_AUTH_TYPE_RSN:
544 rsnType = eANI_BOOLEAN_TRUE;
545 break;
546#ifdef WLAN_FEATURE_VOWIFI_11R
547 case eCSR_AUTH_TYPE_FT_RSN_PSK:
548#endif
549 case eCSR_AUTH_TYPE_RSN_PSK:
550 rsnType = eANI_BOOLEAN_TRUE;
551 break;
552 //case eCSR_AUTH_TYPE_FAILED:
553 case eCSR_AUTH_TYPE_UNKNOWN:
554 rsnType = eANI_BOOLEAN_FALSE;
555 break;
556 default:
557 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700558 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 rsnType = eANI_BOOLEAN_FALSE;
560 break;
561 }
562 hddLog(LOGE, FL("%s called with authType: %d, returned: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700563 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 return rsnType;
565}
566
567static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
568{
569 struct statsContext *pStatsContext;
570 hdd_adapter_t *pAdapter;
571
572 if (ioctl_debug)
573 {
574 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700575 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 }
577
578 if (NULL == pContext)
579 {
580 hddLog(VOS_TRACE_LEVEL_ERROR,
581 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700582 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 return;
584 }
585
586 /* there is a race condition that exists between this callback function
587 and the caller since the caller could time out either before or
588 while this code is executing. we'll assume the timeout hasn't
589 occurred, but we'll verify that right before we save our work */
590
591 pStatsContext = pContext;
592 pAdapter = pStatsContext->pAdapter;
593 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
594 {
595 /* the caller presumably timed out so there is nothing we can do */
596 hddLog(VOS_TRACE_LEVEL_WARN,
597 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700598 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 if (ioctl_debug)
600 {
601 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700602 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 }
604 return;
605 }
606
607 /* the race is on. caller could have timed out immediately after
608 we verified the magic, but if so, caller will wait a short time
609 for us to copy over the rssi */
610 pAdapter->rssi = rssi;
611
612 /* and notify the caller */
613 complete(&pStatsContext->completion);
614}
615
616VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
617{
618 struct statsContext context;
619 hdd_context_t *pHddCtx;
620 hdd_station_ctx_t *pHddStaCtx;
621 eHalStatus hstatus;
622 long lrc;
623
624 if (NULL == pAdapter)
625 {
626 hddLog(VOS_TRACE_LEVEL_WARN,
627 "%s: Invalid context, pAdapter", __func__);
628 return VOS_STATUS_E_FAULT;
629 }
630 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
631 {
632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
633 /* return a cached value */
634 *rssi_value = pAdapter->rssi;
635 return VOS_STATUS_SUCCESS;
636 }
637
638 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
639 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
640
641 init_completion(&context.completion);
642 context.pAdapter = pAdapter;
643 context.magic = RSSI_CONTEXT_MAGIC;
644
645 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
646 pHddStaCtx->conn_info.staId[ 0 ],
647 pHddStaCtx->conn_info.bssId,
648 &context, pHddCtx->pvosContext);
649 if (eHAL_STATUS_SUCCESS != hstatus)
650 {
651 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700652 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 /* we'll returned a cached value below */
654 }
655 else
656 {
657 /* request was sent -- wait for the response */
658 lrc = wait_for_completion_interruptible_timeout(&context.completion,
659 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
660 /* either we have a response or we timed out
661 either way, first invalidate our magic */
662 context.magic = 0;
663 if (lrc <= 0)
664 {
665 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700666 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 /* there is a race condition such that the callback
668 function could be executing at the same time we are. of
669 primary concern is if the callback function had already
670 verified the "magic" but hasn't yet set the completion
671 variable. Since the completion variable is on our
672 stack, we'll delay just a bit to make sure the data is
673 still valid if that is the case */
674 msleep(50);
675 /* we'll now returned a cached value below */
676 }
677 }
678 *rssi_value = pAdapter->rssi;
679
680 return VOS_STATUS_SUCCESS;
681}
682
683void hdd_StatisticsCB( void *pStats, void *pContext )
684{
685 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
686 hdd_stats_t *pStatsCache = NULL;
687 hdd_wext_state_t *pWextState;
688 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
689
690 tCsrSummaryStatsInfo *pSummaryStats = NULL;
691 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
692 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
693 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
694 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
695 tCsrPerStaStatsInfo *pPerStaStats = NULL;
696
697 if (pAdapter!= NULL)
698 pStatsCache = &pAdapter->hdd_stats;
699
700
701 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
702 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
703 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
704 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
705 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
706 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
707
708 if (pStatsCache!=NULL)
709 {
710 // and copy the stats into the cache we keep in the adapter instance structure
711 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
712 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
713 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
714 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
715 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
716 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
717 }
718
719 if(pAdapter)
720 {
721 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
722 if(pWextState)
723 {
724 vos_status = vos_event_set(&pWextState->vosevent);
725 if (!VOS_IS_STATUS_SUCCESS(vos_status))
726 {
727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700728 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 return;
730 }
731 }
732 }
733}
734
735void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
736{
737 v_CONTEXT_t pVosContext;
738 hdd_context_t *pHddCtx;
739 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
740#if 0
741 hdd_wext_state_t *pWextState;
742 v_U32_t roamId;
743#endif
744
745 ENTER();
746
747 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
748
749 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
750 if (NULL == pHddCtx)
751 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700752 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 return;
754 }
755#if 0
756 pWextState = pAdapter->pWextState;
757#endif
758
759 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
760 {
761 //TODO Verify is this is really used. If yes need to fix it.
762 hdd_reconnect_all_adapters( pHddCtx );
763#if 0
764 pAdapter->conn_info.connState = eConnectionState_NotConnected;
765 INIT_COMPLETION(pAdapter->disconnect_comp_var);
766 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
767
768 if(VOS_STATUS_SUCCESS == vosStatus)
769 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
770 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
771
772 sme_RoamConnect(halHandle,
773 pAdapter->sessionId, &(pWextState->roamProfile),
774 &roamId);
775#endif
776 }
777
778 EXIT();
779
780}
781
782void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
783{
784 int i = 0;
785 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
786
787 /* clear WPA/RSN/WSC IE information in the profile */
788 pWextState->roamProfile.nWPAReqIELength = 0;
789 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
790 pWextState->roamProfile.nRSNReqIELength = 0;
791 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
792
793 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
794 pWextState->roamProfile.pAddIEScan = (tANI_U8 *)NULL;
795 pWextState->roamProfile.nAddIEScanLength = 0;
796 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
797 pWextState->roamProfile.nAddIEAssocLength = 0;
798
799 pWextState->roamProfile.EncryptionType.numEntries = 1;
800 pWextState->roamProfile.EncryptionType.encryptionType[0]
801 = eCSR_ENCRYPT_TYPE_NONE;
802
803 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
804 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
805 = eCSR_ENCRYPT_TYPE_NONE;
806
807 pWextState->roamProfile.AuthType.numEntries = 1;
808 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
809
810 pWextState->authKeyMgmt = 0;
811
812 for (i=0; i < CSR_MAX_NUM_KEY; i++)
813 {
814 if (pWextState->roamProfile.Keys.KeyMaterial[i])
815 {
816 pWextState->roamProfile.Keys.KeyLength[i] = 0;
817 }
818 }
819#ifdef FEATURE_WLAN_WAPI
820 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
821 pAdapter->wapi_info.nWapiMode = 0;
822#endif
823
824 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
825
826}
827
828void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
829{
830 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
831 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
832
833 complete(&pWextState->completion_var);
834}
835
836VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
837{
838 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
839 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
840 VOS_STATUS vos_status;
841
842 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
843 {
844 INIT_COMPLETION(pWextState->completion_var);
845
846 /*To avoid race condition between the set key and the last EAPOL
847 packet, notify TL to finish upper layer authentication incase if the
848 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -0800849 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700850
851 if ( vos_status != VOS_STATUS_SUCCESS )
852 {
853 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
854 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
855 __LINE__, vos_status );
856 return vos_status;
857
858 }
859
860 wait_for_completion_timeout(&pWextState->completion_var,
861 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
862 }
863 return VOS_STATUS_SUCCESS;
864}
865
866v_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)
867{
868
869 int left = ie_len;
870 v_U8_t *ptr = ie;
871 v_U8_t elem_id,elem_len;
872 v_U8_t eid = 0xDD;
873
874 if ( NULL == ie || 0 == ie_len )
875 return NULL;
876
877 while(left >= 2)
878 {
879 elem_id = ptr[0];
880 elem_len = ptr[1];
881 left -= 2;
882 if(elem_len > left)
883 {
884 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700885 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 eid,elem_len,left);
887 return NULL;
888 }
889 if (elem_id == eid)
890 {
891 if(memcmp( &ptr[2], oui, oui_size)==0)
892 return ptr;
893 }
894
895 left -= elem_len;
896 ptr += (elem_len + 2);
897 }
898 return NULL;
899}
900
901static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
902 union iwreq_data *wrqu, char *extra)
903{
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700904 hddLog( LOG1, "In %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 /* Do nothing for now */
906 return 0;
907}
908
909static int iw_get_name(struct net_device *dev,
910 struct iw_request_info *info,
911 char *wrqu, char *extra)
912{
913
914 ENTER();
915 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
916 EXIT();
917 return 0;
918}
919
920static int iw_set_mode(struct net_device *dev,
921 struct iw_request_info *info,
922 union iwreq_data *wrqu, char *extra)
923{
924 hdd_wext_state_t *pWextState;
925 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
926 tCsrRoamProfile *pRoamProfile;
927 eCsrRoamBssType LastBSSType;
928 eMib_dot11DesiredBssType connectedBssType;
929 hdd_config_t *pConfig;
930#ifdef CONFIG_CFG80211
931 struct wireless_dev *wdev;
932#endif
933
934 ENTER();
935
936 if (NULL == pAdapter)
937 {
938 hddLog(VOS_TRACE_LEVEL_WARN,
939 "%s: Invalid context, pAdapter", __func__);
940 return 0;
941 }
942
943 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
945 return 0;
946 }
947
948 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
949 if (pWextState == NULL)
950 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700951 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 return -EINVAL;
953 }
954
955#ifdef CONFIG_CFG80211
956 wdev = dev->ieee80211_ptr;
957#endif
958 pRoamProfile = &pWextState->roamProfile;
959 LastBSSType = pRoamProfile->BSSType;
960
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700961 hddLog( LOG1,"%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700962
963 switch (wrqu->mode)
964 {
965 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700966 hddLog( LOG1,"%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
968 // Set the phymode correctly for IBSS.
969 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
970 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
971#ifdef CONFIG_CFG80211
972 wdev->iftype = NL80211_IFTYPE_ADHOC;
973#endif
974 break;
975 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700976 hddLog( LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
978#ifdef CONFIG_CFG80211
979 wdev->iftype = NL80211_IFTYPE_STATION;
980#endif
981 break;
982 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700983 hddLog(LOG1,"%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
985 break;
986 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700987 hddLog(LOG1,"%s Unknown AP Mode value", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 return -EOPNOTSUPP;
989 }
990
991 if ( LastBSSType != pRoamProfile->BSSType )
992 {
993 //the BSS mode changed
994 // We need to issue disconnect if connected or in IBSS disconnect state
995 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
996 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
997 {
998 VOS_STATUS vosStatus;
999 // need to issue a disconnect to CSR.
1000 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1001 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1002 pAdapter->sessionId,
1003 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1004 if(VOS_STATUS_SUCCESS == vosStatus)
1005 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1006 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1007 }
1008 }
1009
1010
1011
1012 EXIT();
1013 return 0;
1014}
1015
1016
1017static int iw_get_mode(struct net_device *dev,
1018 struct iw_request_info *info,
1019 v_U32_t *uwrq, char *extra)
1020{
1021
1022 hdd_wext_state_t *pWextState;
1023 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1024
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001025 hddLog (LOG1, "In %s",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001026
1027 if (NULL == pAdapter)
1028 {
1029 hddLog(VOS_TRACE_LEVEL_WARN,
1030 "%s: Invalid context, pAdapter", __func__);
1031 return 0;
1032 }
1033
1034 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1036 return 0;
1037 }
1038
1039 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1040 if (pWextState == NULL)
1041 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001042 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 return -EINVAL;
1044 }
1045
1046 switch (pWextState->roamProfile.BSSType)
1047 {
1048 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001049 hddLog(LOG1, "%s returns IW_MODE_INFRA\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 *uwrq = IW_MODE_INFRA ;
1051 break;
1052 case eCSR_BSS_TYPE_IBSS:
1053 case eCSR_BSS_TYPE_START_IBSS:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001054 hddLog( LOG1,"%s returns IW_MODE_ADHOC\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 *uwrq= IW_MODE_ADHOC;
1056 break;
1057 case eCSR_BSS_TYPE_ANY:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001058 hddLog( LOG1,"%s returns IW_MODE_AUTO\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 *uwrq= IW_MODE_AUTO;
1060 break;
1061 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001062 hddLog( LOG1,"%s returns APMODE_UNKNOWN\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 break;
1064 }
1065 return 0;
1066}
1067
1068static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1069 union iwreq_data *wrqu, char *extra)
1070{
1071 v_U32_t numChans = 0;
1072 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1073 v_U32_t indx = 0;
1074 v_U32_t status = 0;
1075
1076 hdd_wext_state_t *pWextState;
1077 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1078 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1079 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1080 tCsrRoamProfile * pRoamProfile;
1081 ENTER();
1082
1083 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1085 return status;
1086 }
1087
1088 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1089
1090 pRoamProfile = &pWextState->roamProfile;
1091
1092 hddLog(LOG1,"setCHANNEL ioctl\n");
1093
1094 /* Link is up then return cant set channel*/
1095 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1096 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1097 {
1098 hddLog( LOGE, "IBSS Associated\n");
1099 return -EOPNOTSUPP;
1100 }
1101
1102 /* Settings by Frequency as input */
1103 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1104 (wrqu->freq.m <= (tANI_U32)5.825e8))
1105 {
1106 tANI_U32 freq = wrqu->freq.m / 100000;
1107
1108 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1109 indx++;
1110 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1111 {
1112 return -EINVAL;
1113 }
1114 wrqu->freq.e = 0;
1115 wrqu->freq.m = freq_chan_map[indx].chan;
1116
1117 }
1118
1119 if (wrqu->freq.e == 0)
1120 {
1121 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1122 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1123 {
1124 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001125 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1127 return -EINVAL;
1128 }
1129
1130 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1131
1132 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1133 validChan, &numChans) != eHAL_STATUS_SUCCESS){
1134 return -EIO;
1135 }
1136
1137 for (indx = 0; indx < numChans; indx++) {
1138 if (wrqu->freq.m == validChan[indx]){
1139 break;
1140 }
1141 }
1142 }
1143 else{
1144
1145 return -EINVAL;
1146 }
1147
1148 if(indx >= numChans)
1149 {
1150 return -EINVAL;
1151 }
1152
1153 /* Set the Operational Channel */
1154 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1155 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1156 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1157
1158 hddLog(LOG1,"pRoamProfile->operationChannel = %d\n", wrqu->freq.m);
1159
1160 EXIT();
1161
1162 return status;
1163}
1164
1165static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1166 struct iw_freq *fwrq, char *extra)
1167{
Jeff Johnsone7245742012-09-05 17:12:55 -07001168 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1170 tHalHandle hHal;
1171 hdd_wext_state_t *pWextState;
1172 tCsrRoamProfile * pRoamProfile;
1173 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1174
1175 ENTER();
1176
1177 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1179 return status;
1180 }
1181
1182 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1183 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1184
1185 pRoamProfile = &pWextState->roamProfile;
1186
1187 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1188 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001189 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 {
1191 return -EIO;
1192 }
1193 else
1194 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001195 status = hdd_wlan_get_freq(channel, &freq);
1196 if( TRUE == status )
1197 {
1198 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1199 * iwlist & iwconfig command shows frequency into proper
1200 * format (2.412 GHz instead of 246.2 MHz)*/
1201 fwrq->m = freq;
1202 fwrq->e = MHZ;
1203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 }
1205 }
1206 else
1207 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001208 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1209 * iwlist & iwconfig command shows frequency into proper
1210 * format (2.412 GHz instead of 246.2 MHz)*/
1211 fwrq->m = 0;
1212 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001214 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001215}
1216
1217static int iw_get_tx_power(struct net_device *dev,
1218 struct iw_request_info *info,
1219 union iwreq_data *wrqu, char *extra)
1220{
1221
1222 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1223 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1225
1226 if (pHddCtx->isLogpInProgress)
1227 {
1228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1229 "%s:LOGP in Progress. Ignore!!!",__func__);
1230 return -EBUSY;
1231 }
1232
1233 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1234 {
1235 wrqu->txpower.value = 0;
1236 return 0;
1237 }
1238 wlan_hdd_get_classAstats(pAdapter);
1239 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1240
1241 return 0;
1242}
1243
1244static int iw_set_tx_power(struct net_device *dev,
1245 struct iw_request_info *info,
1246 union iwreq_data *wrqu, char *extra)
1247{
1248 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1249 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1250
1251 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1252 {
1253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1254 return 0;
1255 }
1256
1257 ENTER();
1258
1259 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1260 {
1261 return -EIO;
1262 }
1263
1264 EXIT();
1265
1266 return 0;
1267}
1268
1269static int iw_get_bitrate(struct net_device *dev,
1270 struct iw_request_info *info,
1271 union iwreq_data *wrqu, char *extra)
1272{
1273 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1274 eHalStatus status = eHAL_STATUS_SUCCESS;
1275 hdd_wext_state_t *pWextState;
1276 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1277 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1278
1279 ENTER();
1280
1281 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1283 return status;
1284 }
1285
1286 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1287 wrqu->bitrate.value = 0;
1288 }
1289 else {
1290 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1291 SME_SUMMARY_STATS |
1292 SME_GLOBAL_CLASSA_STATS |
1293 SME_GLOBAL_CLASSB_STATS |
1294 SME_GLOBAL_CLASSC_STATS |
1295 SME_GLOBAL_CLASSD_STATS |
1296 SME_PER_STA_STATS,
1297 hdd_StatisticsCB, 0, FALSE,
1298 pHddStaCtx->conn_info.staId[0], pAdapter );
1299
1300 if(eHAL_STATUS_SUCCESS != status)
1301 {
1302 hddLog(VOS_TRACE_LEVEL_ERROR,
1303 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001304 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 return status;
1306 }
1307
1308 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1309
1310 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1311
1312 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1313 {
1314 hddLog(VOS_TRACE_LEVEL_ERROR,
1315 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001316 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 return VOS_STATUS_E_FAILURE;
1318 }
1319
1320 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1321 }
1322
1323 EXIT();
1324
1325 return vos_status;
1326}
1327/* ccm call back function */
1328
1329static int iw_set_bitrate(struct net_device *dev,
1330 struct iw_request_info *info,
1331 union iwreq_data *wrqu,
1332 char *extra)
1333{
1334 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1335 hdd_wext_state_t *pWextState;
1336 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1337 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1338 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1339 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1340 v_U32_t i, rate;
1341 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1342
1343 ENTER();
1344
1345 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1347 return 0;
1348 }
1349
1350 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1351
1352 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1353 {
1354 return -ENXIO ;
1355 }
1356
1357 rate = wrqu->bitrate.value;
1358
1359 if (rate == -1)
1360 {
1361 rate = WNI_CFG_FIXED_RATE_AUTO;
1362 valid_rate = TRUE;
1363 }
1364 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1365 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1366 {
1367 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1368 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1369 {
1370 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1371 WNI_CFG_SUPPORTED_RATES_11A,
1372 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1373 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1374 WNI_CFG_SUPPORTED_RATES_11B,
1375 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1376 {
1377 for (i = 0; i < (b_len + a_len); ++i)
1378 {
1379 /* supported rates returned is double the actual rate so we divide it by 2 */
1380 if ((supp_rates[i]&0x7F)/2 == rate)
1381 {
1382 valid_rate = TRUE;
1383 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1384 break;
1385 }
1386 }
1387 }
1388 }
1389 }
1390 if (valid_rate != TRUE)
1391 {
1392 return -EINVAL;
1393 }
1394 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1395 WNI_CFG_FIXED_RATE, rate,
1396 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1397 {
1398 return -EIO;
1399 }
1400 return 0;
1401}
1402
1403
1404static int iw_set_genie(struct net_device *dev,
1405 struct iw_request_info *info,
1406 union iwreq_data *wrqu,
1407 char *extra)
1408{
1409 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1410 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1411 u_int8_t *genie;
1412 v_U16_t remLen;
1413
1414 ENTER();
1415 if(!wrqu->data.length) {
1416 hdd_clearRoamProfileIe(pAdapter);
1417 EXIT();
1418 return 0;
1419 }
1420
1421 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1423 return 0;
1424 }
1425
1426 genie = wrqu->data.pointer;
1427 remLen = wrqu->data.length;
1428
1429 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]\n", genie[0], genie[1]);
1430
1431 /* clear any previous genIE before this call */
1432 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1433
1434 while (remLen >= 2)
1435 {
1436 v_U16_t eLen = 0;
1437 v_U8_t elementId;
1438 elementId = *genie++;
1439 eLen = *genie++;
1440 remLen -= 2;
1441
1442 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
1443 __func__, elementId, eLen);
1444
1445 switch ( elementId )
1446 {
1447 case IE_EID_VENDOR:
1448 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
1449 return -EINVAL;
1450
1451 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1452 {
1453 v_U16_t curGenIELen = pWextState->genIE.length;
1454 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1455 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1456
1457 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1458 {
1459 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1460 "Need bigger buffer space\n");
1461 VOS_ASSERT(0);
1462 return -ENOMEM;
1463 }
1464 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1465 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1466 pWextState->genIE.length += eLen + 2;
1467 }
1468 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1469 {
1470 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1471 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1472 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1473 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1474 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1475 }
1476 else /* any vendorId except WPA IE should be accumulated to genIE */
1477 {
1478 v_U16_t curGenIELen = pWextState->genIE.length;
1479 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1480 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1481
1482 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1483 {
1484 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1485 "Need bigger buffer space\n");
1486 VOS_ASSERT(0);
1487 return -ENOMEM;
1488 }
1489 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1490 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1491 pWextState->genIE.length += eLen + 2;
1492 }
1493 break;
1494 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001495 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1497 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1498 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1499 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1500 break;
1501
1502 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001503 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 return 0;
1505 }
1506 genie += eLen;
1507 remLen -= eLen;
1508 }
1509 EXIT();
1510 return 0;
1511}
1512
1513static int iw_get_genie(struct net_device *dev,
1514 struct iw_request_info *info,
1515 union iwreq_data *wrqu,
1516 char *extra)
1517{
1518 hdd_wext_state_t *pWextState;
1519 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1520 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1521 eHalStatus status;
1522 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1523 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1524
1525 ENTER();
1526
1527 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1529 return 0;
1530 }
1531
1532
1533 hddLog(LOG1,"getGEN_IE ioctl\n");
1534
1535 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1536
1537 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1538 {
1539 return -ENXIO;
1540 }
1541
1542 // Return something ONLY if we are associated with an RSN or WPA network
1543 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1544 pWextState->roamProfile.negotiatedAuthType))
1545 {
1546 return -ENXIO;
1547 }
1548
1549 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1550 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1551 pAdapter->sessionId,
1552 &length,
1553 genIeBytes);
1554 wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1555
1556 vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length);
1557
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001558 hddLog(LOG1,"%s: RSN IE of %d bytes returned\n", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001559
1560 EXIT();
1561
1562 return 0;
1563}
1564
1565static int iw_get_encode(struct net_device *dev,
1566 struct iw_request_info *info,
1567 struct iw_point *dwrq, char *extra)
1568{
1569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1570 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1571 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1572 int keyId;
1573 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1574 int i;
1575
1576 ENTER();
1577
1578 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1580 return 0;
1581 }
1582
1583 keyId = pRoamProfile->Keys.defaultIndex;
1584
1585 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1586 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001587 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 return -EINVAL;
1589 }
1590
1591 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1592 {
1593 dwrq->flags |= IW_ENCODE_ENABLED;
1594 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1595 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1596
1597 dwrq->flags |= (keyId + 1);
1598
1599 }
1600 else
1601 {
1602 dwrq->flags |= IW_ENCODE_DISABLED;
1603 }
1604
1605 for(i=0; i < MAX_WEP_KEYS; i++)
1606 {
1607 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
1608 {
1609 continue;
1610 }
1611 else
1612 {
1613 break;
1614 }
1615 }
1616
1617 if(MAX_WEP_KEYS == i)
1618 {
1619 dwrq->flags |= IW_ENCODE_NOKEY;
1620 }
1621
1622 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
1623
1624 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
1625 {
1626 dwrq->flags |= IW_ENCODE_OPEN;
1627 }
1628 else
1629 {
1630 dwrq->flags |= IW_ENCODE_RESTRICTED;
1631 }
1632 EXIT();
1633 return 0;
1634}
1635
1636#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
1637#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
1638
1639
1640/*
1641 * This function sends a single 'key' to LIM at all time.
1642 */
1643
1644static int iw_get_rts_threshold(struct net_device *dev,
1645 struct iw_request_info *info,
1646 union iwreq_data *wrqu, char *extra)
1647{
1648 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1649 v_U32_t status = 0;
1650
1651 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
1652
1653 return status;
1654}
1655
1656static int iw_set_rts_threshold(struct net_device *dev,
1657 struct iw_request_info *info,
1658 union iwreq_data *wrqu, char *extra)
1659{
1660 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1661 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1662
1663 ENTER();
1664
1665 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
1666 {
1667 return -EINVAL;
1668 }
1669
1670 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1671 {
1672 return -EIO;
1673 }
1674
1675 EXIT();
1676
1677 return 0;
1678}
1679
1680static int iw_get_frag_threshold(struct net_device *dev,
1681 struct iw_request_info *info,
1682 union iwreq_data *wrqu, char *extra)
1683{
1684 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1685 v_U32_t status = 0;
1686
1687 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
1688
1689 return status;
1690}
1691
1692static int iw_set_frag_threshold(struct net_device *dev,
1693 struct iw_request_info *info,
1694 union iwreq_data *wrqu, char *extra)
1695{
1696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1697 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1698
1699 ENTER();
1700
1701 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
1702 {
1703 return -EINVAL;
1704 }
1705
1706 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1707 {
1708 return -EIO;
1709 }
1710
1711 EXIT();
1712
1713 return 0;
1714}
1715
1716static int iw_get_power_mode(struct net_device *dev,
1717 struct iw_request_info *info,
1718 union iwreq_data *wrqu, char *extra)
1719{
1720 ENTER();
1721 return -EOPNOTSUPP;
1722}
1723
1724static int iw_set_power_mode(struct net_device *dev,
1725 struct iw_request_info *info,
1726 union iwreq_data *wrqu, char *extra)
1727{
1728 ENTER();
1729 return -EOPNOTSUPP;
1730}
1731
1732static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
1733 union iwreq_data *wrqu, char *extra)
1734{
1735 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1736 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1737 struct iw_range *range = (struct iw_range *) extra;
1738
1739 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1740
1741 v_U32_t num_channels = sizeof(channels);
1742 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1743 v_U32_t a_len;
1744 v_U32_t b_len;
1745 v_U32_t active_phy_mode = 0;
1746 v_U8_t index = 0, i;
1747
1748 ENTER();
1749
1750 wrqu->data.length = sizeof(struct iw_range);
1751 memset(range, 0, sizeof(struct iw_range));
1752
1753
1754 /*Get the phy mode*/
1755 if (ccmCfgGetInt(hHal,
1756 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1757 {
1758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1759 "active_phy_mode = %ld", active_phy_mode);
1760
1761 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
1762 {
1763 /*Get the supported rates for 11G band*/
1764 if (ccmCfgGetStr(hHal,
1765 WNI_CFG_SUPPORTED_RATES_11A,
1766 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
1767 {
1768 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
1769 {
1770 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1771 }
1772 for (i = 0; i < a_len; i++)
1773 {
1774 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
1775 }
1776 range->num_bitrates = a_len;
1777 }
1778 else
1779 {
1780 return -EIO;
1781 }
1782 }
1783 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1784 {
1785 /*Get the supported rates for 11B band*/
1786 if (ccmCfgGetStr(hHal,
1787 WNI_CFG_SUPPORTED_RATES_11B,
1788 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
1789 {
1790 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
1791 {
1792 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1793 }
1794 for (i = 0; i < b_len; i++)
1795 {
1796 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
1797 }
1798 range->num_bitrates = b_len;
1799 }
1800 else
1801 {
1802 return -EIO;
1803 }
1804 }
1805 }
1806
1807 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
1808 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
1809 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
1810
1811 range->encoding_size[0] = 5;
1812 range->encoding_size[1] = 13;
1813 range->num_encoding_sizes = 2;
1814 range->max_encoding_tokens = MAX_WEP_KEYS;
1815
1816 // we support through Wireless Extensions 22
1817 range->we_version_compiled = WIRELESS_EXT;
1818 range->we_version_source = 22;
1819
1820 /*Supported Channels and Frequencies*/
1821 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
1822 {
1823 return -EIO;
1824 }
1825 if (num_channels > IW_MAX_FREQUENCIES)
1826 {
1827 num_channels = IW_MAX_FREQUENCIES;
1828 }
1829
1830 range->num_channels = num_channels;
1831 range->num_frequency = num_channels;
1832
1833 for (index=0; index < num_channels; index++)
1834 {
1835 v_U32_t frq_indx = 0;
1836
1837 range->freq[index].i = channels[index];
1838 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
1839 {
1840 if(channels[index] == freq_chan_map[frq_indx].chan)
1841 {
1842 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
1843 range->freq[index].e = 1;
1844 break;
1845 }
1846 frq_indx++;
1847 }
1848 }
1849
1850 /* Event capability (kernel + driver) */
1851 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
1852 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
1853 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
1854 range->event_capa[1] = IW_EVENT_CAPA_K_1;
1855
1856 /*Encryption capability*/
1857 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
1858 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
1859
1860 /* Txpower capability */
1861 range->txpower_capa = IW_TXPOW_MWATT;
1862
1863 /*Scanning capability*/
1864 #if WIRELESS_EXT >= 22
1865 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
1866 #endif
1867
1868 EXIT();
1869 return 0;
1870}
1871
1872/* Callback function registered with PMC to know status of PMC request */
1873static void iw_power_callback_fn (void *pContext, eHalStatus status)
1874{
1875 struct statsContext *pStatsContext;
1876 hdd_adapter_t *pAdapter;
1877
1878 if (NULL == pContext)
1879 {
1880 hddLog(VOS_TRACE_LEVEL_ERROR,
1881 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001882 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 return;
1884 }
1885
1886 /* there is a race condition that exists between this callback function
1887 and the caller since the caller could time out either before or
1888 while this code is executing. we'll assume the timeout hasn't
1889 occurred, but we'll verify that right before we save our work */
1890
1891 pStatsContext = (struct statsContext *)pContext;
1892 pAdapter = pStatsContext->pAdapter;
1893
1894 if ((NULL == pAdapter) || (POWER_CONTEXT_MAGIC != pStatsContext->magic))
1895 {
1896 /* the caller presumably timed out so there is nothing we can do */
1897 hddLog(VOS_TRACE_LEVEL_WARN,
1898 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001899 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07001900
1901 if (ioctl_debug)
1902 {
1903 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001904 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07001905 }
1906 return;
1907 }
1908
1909 /* and notify the caller */
1910 complete(&pStatsContext->completion);
1911}
1912
1913/* Callback function for tx per hit */
1914void hdd_tx_per_hit_cb (void *pCallbackContext)
1915{
1916 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
1917 unsigned char tx_fail[16];
1918 union iwreq_data wrqu;
1919
1920 if (NULL == pAdapter)
1921 {
1922 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL\n");
1923 return;
1924 }
1925 memset(&wrqu, 0, sizeof(wrqu));
1926 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
1927 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
1928}
1929
1930void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
1931{
1932 struct statsContext *pStatsContext;
1933 tCsrGlobalClassAStatsInfo *pClassAStats;
1934 hdd_adapter_t *pAdapter;
1935
1936 if (ioctl_debug)
1937 {
1938 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001939 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 }
1941
1942 if ((NULL == pStats) || (NULL == pContext))
1943 {
1944 hddLog(VOS_TRACE_LEVEL_ERROR,
1945 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001946 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 return;
1948 }
1949
1950 /* there is a race condition that exists between this callback function
1951 and the caller since the caller could time out either before or
1952 while this code is executing. we'll assume the timeout hasn't
1953 occurred, but we'll verify that right before we save our work */
1954
1955 pClassAStats = pStats;
1956 pStatsContext = pContext;
1957 pAdapter = pStatsContext->pAdapter;
1958 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
1959 {
1960 /* the caller presumably timed out so there is nothing we can do */
1961 hddLog(VOS_TRACE_LEVEL_WARN,
1962 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001963 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 if (ioctl_debug)
1965 {
1966 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001967 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 }
1969 return;
1970 }
1971
1972 /* the race is on. caller could have timed out immediately after
1973 we verified the magic, but if so, caller will wait a short time
1974 for us to copy over the stats. do so as a struct copy */
1975 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
1976
1977 /* and notify the caller */
1978 complete(&pStatsContext->completion);
1979}
1980
1981VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
1982{
1983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1984 eHalStatus hstatus;
1985 long lrc;
1986 struct statsContext context;
1987
1988 if (NULL == pAdapter)
1989 {
1990 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
1991 return VOS_STATUS_E_FAULT;
1992 }
1993 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1994 {
1995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1996 return VOS_STATUS_SUCCESS;
1997 }
1998
1999 /* we are connected
2000 prepare our callback context */
2001 init_completion(&context.completion);
2002 context.pAdapter = pAdapter;
2003 context.magic = STATS_CONTEXT_MAGIC;
2004 /* query only for Class A statistics (which include link speed) */
2005 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2006 eCSR_HDD,
2007 SME_GLOBAL_CLASSA_STATS,
2008 hdd_GetClassA_statisticsCB,
2009 0, // not periodic
2010 FALSE, //non-cached results
2011 pHddStaCtx->conn_info.staId[0],
2012 &context);
2013 if (eHAL_STATUS_SUCCESS != hstatus)
2014 {
2015 hddLog(VOS_TRACE_LEVEL_ERROR,
2016 "%s: Unable to retrieve Class A statistics ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002017 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 /* we'll returned a cached value below */
2019 }
2020 else
2021 {
2022 /* request was sent -- wait for the response */
2023 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2024 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2025 /* either we have a response or we timed out
2026 either way, first invalidate our magic */
2027 context.magic = 0;
2028 if (lrc <= 0)
2029 {
2030 hddLog(VOS_TRACE_LEVEL_ERROR,
2031 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002032 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 /* there is a race condition such that the callback
2034 function could be executing at the same time we are. of
2035 primary concern is if the callback function had already
2036 verified the "magic" but hasn't yet set the completion
2037 variable. Since the completion variable is on our
2038 stack, we'll delay just a bit to make sure the data is
2039 still valid if that is the case */
2040 msleep(50);
2041 }
2042 }
2043 return VOS_STATUS_SUCCESS;
2044}
2045
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002046static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2047{
2048 struct statsContext *pStatsContext;
2049 tCsrSummaryStatsInfo *pSummaryStats;
2050 tCsrGlobalClassAStatsInfo *pClassAStats;
2051 hdd_adapter_t *pAdapter;
2052
2053 if (ioctl_debug)
2054 {
2055 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002056 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002057 }
2058
2059 if ((NULL == pStats) || (NULL == pContext))
2060 {
2061 hddLog(VOS_TRACE_LEVEL_ERROR,
2062 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002063 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002064 return;
2065 }
2066
2067 /* there is a race condition that exists between this callback function
2068 and the caller since the caller could time out either before or
2069 while this code is executing. we'll assume the timeout hasn't
2070 occurred, but we'll verify that right before we save our work */
2071
2072 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2073 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2074 pStatsContext = pContext;
2075 pAdapter = pStatsContext->pAdapter;
2076 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2077 {
2078 /* the caller presumably timed out so there is nothing we can do */
2079 hddLog(VOS_TRACE_LEVEL_WARN,
2080 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002081 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002082 if (ioctl_debug)
2083 {
2084 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002085 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002086 }
2087 return;
2088 }
2089
2090 /* the race is on. caller could have timed out immediately after
2091 we verified the magic, but if so, caller will wait a short time
2092 for us to copy over the stats. do so as a struct copy */
2093 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2094 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2095
2096 /* and notify the caller */
2097 complete(&pStatsContext->completion);
2098}
2099
2100VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2101{
2102 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2103 eHalStatus hstatus;
2104 long lrc;
2105 struct statsContext context;
2106
2107 if (NULL == pAdapter)
2108 {
2109 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2110 return VOS_STATUS_SUCCESS;
2111 }
2112
2113 /* we are connected
2114 prepare our callback context */
2115 init_completion(&context.completion);
2116 context.pAdapter = pAdapter;
2117 context.magic = STATS_CONTEXT_MAGIC;
2118
2119 /* query only for Summary & Class A statistics */
2120 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2121 eCSR_HDD,
2122 SME_SUMMARY_STATS |
2123 SME_GLOBAL_CLASSA_STATS,
2124 hdd_get_station_statisticsCB,
2125 0, // not periodic
2126 FALSE, //non-cached results
2127 pHddStaCtx->conn_info.staId[0],
2128 &context);
2129 if (eHAL_STATUS_SUCCESS != hstatus)
2130 {
2131 hddLog(VOS_TRACE_LEVEL_ERROR,
2132 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002133 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002134 /* we'll return with cached values */
2135 }
2136 else
2137 {
2138 /* request was sent -- wait for the response */
2139 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2140 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2141 /* either we have a response or we timed out
2142 either way, first invalidate our magic */
2143 context.magic = 0;
2144 if (lrc <= 0)
2145 {
2146 hddLog(VOS_TRACE_LEVEL_ERROR,
2147 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002148 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002149 /* there is a race condition such that the callback
2150 function could be executing at the same time we are. of
2151 primary concern is if the callback function had already
2152 verified the "magic" but hasn't yet set the completion
2153 variable. Since the completion variable is on our
2154 stack, we'll delay just a bit to make sure the data is
2155 still valid if that is the case */
2156 msleep(50);
2157 }
2158 }
2159 return VOS_STATUS_SUCCESS;
2160}
2161
2162
Jeff Johnson295189b2012-06-20 16:38:30 -07002163/*
2164 * Support for the LINKSPEED private command
2165 * Per the WiFi framework the response must be of the form
2166 * "LinkSpeed xx"
2167 */
2168static int iw_get_linkspeed(struct net_device *dev,
2169 struct iw_request_info *info,
2170 union iwreq_data *wrqu, char *extra)
2171{
2172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2173 char *pLinkSpeed = (char*)extra;
2174 int len = sizeof(v_U16_t) + 1;
2175 v_U16_t link_speed;
2176 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2177 int rc;
2178
2179 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2180 {
2181 /* we are not connected so we don't have a classAstats */
2182 link_speed = 0;
2183 }
2184 else
2185 {
2186 wlan_hdd_get_classAstats(pAdapter);
2187 //The linkspeed returned by HAL is in units of 500kbps.
2188 //converting it to mbps
2189 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2190 }
2191
2192 wrqu->data.length = len;
2193 // return the linkspeed in the format required by the WiFi Framework
2194 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
2195 if ((rc < 0) || (rc >= len))
2196 {
2197 // encoding or length error?
2198 hddLog(VOS_TRACE_LEVEL_ERROR,
2199 "%s: Unable to encode link speed, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002200 __func__,pLinkSpeed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 return -EIO;
2202 }
2203
2204 /* a value is being successfully returned */
2205 return 0;
2206}
2207
2208
2209/*
2210 * Support for the RSSI & RSSI-APPROX private commands
2211 * Per the WiFi framework the response must be of the form
2212 * "<ssid> rssi <xx>"
2213 * unless we are not associated, in which case the response is
2214 * "OK"
2215 */
2216static int iw_get_rssi(struct net_device *dev,
2217 struct iw_request_info *info,
2218 union iwreq_data *wrqu, char *extra)
2219{
2220 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2221 char *cmd = (char*)wrqu->data.pointer;
2222 int len = wrqu->data.length;
2223 v_S7_t s7Rssi = 0;
2224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2225 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2226 VOS_STATUS vosStatus;
2227 int rc;
2228
2229 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2230 (0 == ssidlen) || (ssidlen >= len))
2231 {
2232 /* we are not connected or our SSID is too long
2233 so we cannot report an rssi */
2234 rc = snprintf(cmd, len, "OK");
2235 }
2236 else
2237 {
2238 /* we are connected with a valid SSID
2239 so we can write the SSID into the return buffer
2240 (note that it is not NUL-terminated) */
2241 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2242
2243 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2244
2245 if (VOS_STATUS_SUCCESS == vosStatus)
2246 {
2247 /* append the rssi to the ssid in the format required by
2248 the WiFI Framework */
2249 rc = snprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
2250 }
2251 else
2252 {
2253 rc = -1;
2254 }
2255 }
2256
2257 /* verify that we wrote a valid response */
2258 if ((rc < 0) || (rc >= len))
2259 {
2260 // encoding or length error?
2261 hddLog(VOS_TRACE_LEVEL_ERROR,
2262 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002263 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 return -EIO;
2265 }
2266
2267 /* a value is being successfully returned */
2268 return 0;
2269}
2270
2271/*
2272 * Support for SoftAP channel range private command
2273 */
2274static int iw_softap_set_channel_range( struct net_device *dev,
2275 int startChannel,
2276 int endChannel,
2277 int band)
2278{
Jeff Johnson43971f52012-07-17 12:26:56 -07002279 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 int ret = 0;
2281 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2282 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002283 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2284
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
2286 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2287 if (VOS_STATUS_SUCCESS != status)
2288 {
2289 ret = -EINVAL;
2290 }
Yathish9f22e662012-12-10 14:21:35 -08002291 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 return ret;
2293}
2294
2295VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2296{
2297 struct statsContext context;
2298 eHalStatus status;
2299 hdd_context_t *pHddCtx;
2300
2301 if (NULL == pAdapter)
2302 {
2303 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2304 return VOS_STATUS_E_FAULT;
2305 }
2306
2307 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2308 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2309 init_completion(&context.completion);
2310
2311 context.pAdapter = pAdapter;
2312 context.magic = POWER_CONTEXT_MAGIC;
2313
2314 if (DRIVER_POWER_MODE_ACTIVE == mode)
2315 {
2316 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2317 "Full Power", __func__);
2318 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2319 iw_power_callback_fn, &context,
2320 eSME_FULL_PWR_NEEDED_BY_HDD);
2321 // Enter Full power command received from GUI this means we are disconnected
2322 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2323 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2324 if (eHAL_STATUS_PMC_PENDING == status)
2325 {
2326 int lrc = wait_for_completion_interruptible_timeout(
2327 &context.completion,
2328 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2329 context.magic = 0;
2330 if (lrc <= 0)
2331 {
2332 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002333 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 /* there is a race condition such that the callback
2335 function could be executing at the same time we are. of
2336 primary concern is if the callback function had already
2337 verified the "magic" but hasn't yet set the completion
2338 variable. Since the completion variable is on our
2339 stack, we'll delay just a bit to make sure the data is
2340 still valid if that is the case */
2341 msleep(50);
2342 /* we'll now returned a cached value below */
2343 }
2344 }
2345 }
2346 else if (DRIVER_POWER_MODE_AUTO == mode)
2347 {
2348 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2349 {
2350 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2351 __func__);
2352 // Enter BMPS command received from GUI this means DHCP is completed
2353 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2354 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2355 FALSE);
2356 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2357 iw_power_callback_fn, &context);
2358 if (eHAL_STATUS_PMC_PENDING == status)
2359 {
2360 int lrc = wait_for_completion_interruptible_timeout(
2361 &context.completion,
2362 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2363 context.magic = 0;
2364 if (lrc <= 0)
2365 {
2366 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting BMPS ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002367 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 /* there is a race condition such that the callback
2369 function could be executing at the same time we are. of
2370 primary concern is if the callback function had already
2371 verified the "magic" but hasn't yet set the completion
2372 variable. Since the completion variable is on our
2373 stack, we'll delay just a bit to make sure the data is
2374 still valid if that is the case */
2375 msleep(50);
2376 /* we'll now returned a cached value below */
2377 }
2378 }
2379 }
2380 else
2381 {
2382 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2383 "enabled in the cfg");
2384 }
2385 }
2386 return VOS_STATUS_SUCCESS;
2387}
2388
2389VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2390 hdd_adapter_t *pAdapter)
2391{
2392 VOS_STATUS vos_Status;
2393
2394 if ((NULL == pAdapter) || (NULL == pHddCtx))
2395 {
2396 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2397 return VOS_STATUS_E_FAULT;
2398 }
2399
2400 /**Exit from Deep sleep or standby if we get the driver
2401 START cmd from android GUI
2402 */
2403 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2406 "from Stand by",__func__);
2407 vos_Status = hdd_exit_standby(pHddCtx);
2408 }
2409 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2410 {
2411 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2412 "from deep sleep",__func__);
2413 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2414 }
2415 else
2416 {
2417 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2418 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2419 vos_Status = VOS_STATUS_SUCCESS;
2420 }
2421
2422 return vos_Status;
2423}
2424
2425VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2426{
2427 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2428
2429 if (NULL == pHddCtx)
2430 {
2431 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "HDD context NULL");
2432 return VOS_STATUS_E_FAULT;
2433 }
2434
2435 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2436 {
2437 //Execute standby procedure.
2438 //Executing standby procedure will cause the STA to
2439 //disassociate first and then the chip will be put into standby.
2440 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2441 vos_Status = hdd_enter_standby(pHddCtx);
2442 }
2443 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2444 pHddCtx->cfg_ini->nEnableDriverStop)
2445 {
2446 //Execute deep sleep procedure
2447 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
2448 "deep sleep mode\n");
2449 //Deep sleep not supported
2450 vos_Status = hdd_enter_standby(pHddCtx);
2451 }
2452 else
2453 {
2454 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2455 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2456 vos_Status = VOS_STATUS_SUCCESS;
2457 }
2458
2459 return vos_Status;
2460}
2461
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002462
2463void* wlan_hdd_change_country_code_callback(void *pAdapter)
2464{
2465
2466 hdd_adapter_t *call_back_pAdapter = pAdapter;
2467
2468 complete(&call_back_pAdapter->change_country_code);
2469
2470 return NULL;
2471}
2472
Jeff Johnson295189b2012-06-20 16:38:30 -07002473static int iw_set_priv(struct net_device *dev,
2474 struct iw_request_info *info,
2475 union iwreq_data *wrqu, char *extra)
2476{
2477 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2478 char *cmd = (char*)wrqu->data.pointer;
2479 int cmd_len = wrqu->data.length;
2480 int ret = 0;
2481 int status = 0;
2482 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2483
2484 ENTER();
2485
2486 if (ioctl_debug)
2487 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002488 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 }
2490
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002491 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2492 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002493
2494 if (pHddCtx->isLogpInProgress) {
2495 if (ioctl_debug)
2496 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002497 pr_info("%s: RESTART in progress\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 }
2499
2500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2501 "%s:LOGP in Progress. Ignore!!!",__func__);
2502 return status;
2503 }
2504
2505 if(strncmp(cmd, "CSCAN",5) == 0 )
2506 {
2507 status = iw_set_cscan(dev, info, wrqu, extra);
2508 }
2509 else if( strcasecmp(cmd, "start") == 0 ) {
2510
2511 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command\n");
2512 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
2513 status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
2514
2515 if(status == VOS_STATUS_SUCCESS)
2516 {
2517 union iwreq_data wrqu;
2518 char buf[10];
2519
2520 memset(&wrqu, 0, sizeof(wrqu));
2521 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
2522 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2523 }
2524 else
2525 {
2526 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: START CMD Status %d", __func__, status);
2527 }
2528 goto done;
2529 }
2530 else if( strcasecmp(cmd, "stop") == 0 )
2531 {
2532 union iwreq_data wrqu;
2533 char buf[10];
2534
2535 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command\n");
2536
2537 wlan_hdd_enter_lowpower(pHddCtx);
2538 memset(&wrqu, 0, sizeof(wrqu));
2539 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
2540 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2541 status = VOS_STATUS_SUCCESS;
2542 goto done;
2543 }
2544 else if (strcasecmp(cmd, "macaddr") == 0)
2545 {
2546 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
2547 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
2548 }
2549 else if (strcasecmp(cmd, "scan-active") == 0)
2550 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002551 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 ret = snprintf(cmd, cmd_len, "OK");
2553 }
2554 else if (strcasecmp(cmd, "scan-passive") == 0)
2555 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002556 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 ret = snprintf(cmd, cmd_len, "OK");
2558 }
2559 else if( strcasecmp(cmd, "scan-mode") == 0 )
2560 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002561 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 }
2563 else if( strcasecmp(cmd, "linkspeed") == 0 )
2564 {
2565 status = iw_get_linkspeed(dev, info, wrqu, extra);
2566 }
2567 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
2568 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002569 long lrc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002570
2571 country_code = cmd + 8;
2572
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002573 init_completion(&pAdapter->change_country_code);
2574
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002576 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 country_code,
2578 pAdapter,
2579 pHddCtx->pvosContext);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002580
2581 /* Wait for completion */
2582 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
2583 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2584
2585 if (lrc <= 0)
2586 {
2587 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002588 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002589 }
2590
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 if( 0 != status )
2592 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002593 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2594 "%s: SME Change Country code fail \n",__func__);
2595 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 }
2597 }
2598 else if( strncasecmp(cmd, "rssi", 4) == 0 )
2599 {
2600 status = iw_get_rssi(dev, info, wrqu, extra);
2601 }
2602 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
2603 int mode;
2604 char *ptr = (char*)(cmd + 9);
2605
2606 sscanf(ptr,"%d",&mode);
2607 wlan_hdd_enter_bmps(pAdapter, mode);
2608 /*TODO:Set the power mode*/
2609 }
2610 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
2611 v_U32_t pmc_state;
2612 v_U16_t value;
2613
2614 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
2615 if(pmc_state == BMPS) {
2616 value = DRIVER_POWER_MODE_AUTO;
2617 }
2618 else {
2619 value = DRIVER_POWER_MODE_ACTIVE;
2620 }
2621 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
2622 }
2623 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
2624 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode\n");
2625 /*TODO: set the btcoexmode*/
2626 }
2627 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
2628
2629 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status\n");
2630 /*TODO: Return the btcoex status*/
2631 }
2632 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
2633
2634 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command\n");
2635
2636 /*TODO: Enable Rx data Filter*/
2637 }
2638 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
2639
2640 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command\n");
2641
2642 /*TODO: Disable Rx data Filter*/
2643 }
2644 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
2645
2646 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command\n");
2647 /*TODO: rxfilter-statistics*/
2648 }
2649 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
2650
2651 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add\n");
2652 /*TODO: rxfilter-add*/
2653 }
2654 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
2655
2656 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove\n");
2657 /*TODO: rxfilter-remove*/
2658 }
2659#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07002660 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
2661 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
2662 /*TODO: support pnosetup*/
2663 }
2664 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
2665 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
2666 /*TODO: support pnoforce*/
2667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 else if( strncasecmp(cmd, "pno",3) == 0 ) {
2669
2670 hddLog( VOS_TRACE_LEVEL_INFO, "pno\n");
2671 status = iw_set_pno(dev, info, wrqu, extra, 3);
2672 return status;
2673 }
2674 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
2675
2676 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter\n");
2677 status = iw_set_rssi_filter(dev, info, wrqu, extra, 10);
2678 return status;
2679 }
2680#endif /*FEATURE_WLAN_SCAN_PNO*/
2681 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
2682 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams\n");
2683 status = iw_set_power_params(dev, info, wrqu, extra, 11);
2684 return status;
2685 }
2686 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
2687 tSirTxPerTrackingParam tTxPerTrackingParam;
2688 char *ptr = (char*)(cmd + 18);
2689 sscanf(ptr,"%hhu %hhu %hhu %lu",&(tTxPerTrackingParam.ucTxPerTrackingEnable), &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
2690 &(tTxPerTrackingParam.ucTxPerTrackingRatio), &(tTxPerTrackingParam.uTxPerTrackingWatermark));
2691
2692 // parameters checking
2693 // period has to be larger than 0
2694 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
2695 {
2696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
2697 return VOS_STATUS_E_FAILURE;
2698 }
2699
2700 // use default value 5 is the input is not reasonable. in unit of 10%
2701 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
2702 {
2703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
2704 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
2705 }
2706
2707 // default is 5
2708 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
2709 {
2710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
2711 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
2712 }
2713
2714 status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam);
2715 if(status != eHAL_STATUS_SUCCESS){
2716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
2717 }
2718 }
2719 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002720 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
2721 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 }
2723done:
2724 /* many of the commands write information back into the command
2725 string using snprintf(). check the return value here in one
2726 place */
2727 if ((ret < 0) || (ret >= cmd_len))
2728 {
2729 /* there was an encoding error or overflow */
2730 status = -EIO;
2731 }
2732
2733 if (ioctl_debug)
2734 {
2735 pr_info("%s: rsp [%s] len [%d] status %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002736 __func__, cmd, wrqu->data.length, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 }
2738 return status;
2739
2740}
2741
2742static int iw_set_nick(struct net_device *dev,
2743 struct iw_request_info *info,
2744 union iwreq_data *wrqu, char *extra)
2745{
2746 ENTER();
2747 return 0;
2748}
2749
2750static int iw_get_nick(struct net_device *dev,
2751 struct iw_request_info *info,
2752 union iwreq_data *wrqu, char *extra)
2753{
2754 ENTER();
2755 return 0;
2756}
2757
2758static struct iw_statistics *get_wireless_stats(struct net_device *dev)
2759{
2760 ENTER();
2761 return NULL;
2762}
2763
2764static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
2765 union iwreq_data *wrqu,char *extra)
2766
2767{
2768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2769 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2770 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2771 struct iw_point *encoderq = &(wrqu->encoding);
2772 v_U32_t keyId;
2773 v_U8_t key_length;
2774 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
2775 v_BOOL_t fKeyPresent = 0;
2776 int i;
2777 eHalStatus status = eHAL_STATUS_SUCCESS;
2778
2779
2780 ENTER();
2781
2782 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2783 {
2784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2785 "%s:LOGP in Progress. Ignore!!!",__func__);
2786 return 0;
2787 }
2788
2789
2790 keyId = encoderq->flags & IW_ENCODE_INDEX;
2791
2792 if(keyId)
2793 {
2794 if(keyId > MAX_WEP_KEYS)
2795 {
2796 return -EINVAL;
2797 }
2798
2799 fKeyPresent = 1;
2800 keyId--;
2801 }
2802 else
2803 {
2804 fKeyPresent = 0;
2805 }
2806
2807
2808 if(wrqu->data.flags & IW_ENCODE_DISABLED)
2809 {
2810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****\n");
2811 if(!fKeyPresent) {
2812
2813 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
2814
2815 if(pWextState->roamProfile.Keys.KeyMaterial[i])
2816 pWextState->roamProfile.Keys.KeyLength[i] = 0;
2817 }
2818 }
2819 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
2820 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
2821 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2822 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2823
2824 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2825 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2826
2827 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
2828 {
2829 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2830 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07002831 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
2833 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2834 }
2835
2836 return status;
2837
2838 }
2839
2840 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
2841 {
2842 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
2843
2844 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
2845
2846 }
2847
2848
2849 if(wrqu->data.length > 0)
2850 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002851 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002852
2853 key_length = wrqu->data.length;
2854
2855 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
2856
2857 if(5 == key_length)
2858 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002859 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002860
2861 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2862 {
2863 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
2864 }
2865 else
2866 {
2867 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2868 }
2869 }
2870 else if(13 == key_length)
2871 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002872 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002873
2874 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2875 {
2876 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
2877 }
2878 else
2879 {
2880 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2881 }
2882 }
2883 else
2884 {
2885 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002886 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 return -EINVAL;
2888 }
2889
2890 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
2891 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
2892 pWextState->roamProfile.EncryptionType.numEntries = 1;
2893 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
2894 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
2895 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
2896
2897 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
2898 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
2899 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
2900 {
2901
2902 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
2903
2904 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
2905 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
2906
2907 return status;
2908 }
2909 }
2910
2911 return 0;
2912}
2913
2914static int iw_get_encodeext(struct net_device *dev,
2915 struct iw_request_info *info,
2916 struct iw_point *dwrq,
2917 char *extra)
2918{
2919 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2920 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2921 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2922 int keyId;
2923 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
2924 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2925 int i;
2926
2927 ENTER();
2928
2929 keyId = pRoamProfile->Keys.defaultIndex;
2930
2931 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2932 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002933 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 return -EINVAL;
2935 }
2936
2937 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2938 {
2939 dwrq->flags |= IW_ENCODE_ENABLED;
2940 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2941 palCopyMemory(dev,extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2942 }
2943 else
2944 {
2945 dwrq->flags |= IW_ENCODE_DISABLED;
2946 }
2947
2948 for(i=0; i < MAX_WEP_KEYS; i++)
2949 {
2950 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2951 {
2952 continue;
2953 }
2954 else
2955 {
2956 break;
2957 }
2958 }
2959
2960 if(MAX_WEP_KEYS == i)
2961 {
2962 dwrq->flags |= IW_ENCODE_NOKEY;
2963 }
2964 else
2965 {
2966 dwrq->flags |= IW_ENCODE_ENABLED;
2967 }
2968
2969 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
2970
2971 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
2972 {
2973 dwrq->flags |= IW_ENCODE_DISABLED;
2974 }
2975
2976 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2977
2978 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
2979 {
2980 dwrq->flags |= IW_ENCODE_OPEN;
2981 }
2982 else
2983 {
2984 dwrq->flags |= IW_ENCODE_RESTRICTED;
2985 }
2986 EXIT();
2987 return 0;
2988
2989}
2990
2991static int iw_set_encodeext(struct net_device *dev,
2992 struct iw_request_info *info,
2993 union iwreq_data *wrqu, char *extra)
2994{
2995 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2996 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2997 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2998 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
2999
3000 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3001 v_U32_t status = 0;
3002
3003 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3004
3005 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3006
3007 int key_index;
3008 struct iw_point *encoding = &wrqu->encoding;
3009 tCsrRoamSetKey setKey;
3010 v_U32_t roamId= 0xFF;
3011 VOS_STATUS vos_status;
3012
3013 ENTER();
3014
3015 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3016 {
3017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3018 "%s:LOGP in Progress. Ignore!!!",__func__);
3019 return 0;
3020 }
3021
3022 key_index = encoding->flags & IW_ENCODE_INDEX;
3023
3024 if(key_index > 0) {
3025
3026 /*Convert from 1-based to 0-based keying*/
3027 key_index--;
3028 }
3029 if(!ext->key_len) {
3030
3031 /*Set the encrytion type to NONE*/
3032 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3033 return status;
3034 }
3035
3036 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3037 (IW_ENCODE_ALG_WEP == ext->alg))
3038 {
3039 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3040
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003041 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s \n"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 return -EINVAL;
3043 }
3044 else {
3045 /*Static wep, update the roam profile with the keys */
3046 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3047 key_index < CSR_MAX_NUM_KEY) {
3048 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3049 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3050
3051 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3052 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3053
3054 }
3055 }
3056 return status;
3057 }
3058
3059 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3060
3061 setKey.keyId = key_index;
3062 setKey.keyLength = ext->key_len;
3063
3064 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3065 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3066 }
3067
3068 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3069 /*Key direction for group is RX only*/
3070 setKey.keyDirection = eSIR_RX_ONLY;
3071 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3072 }
3073 else {
3074
3075 setKey.keyDirection = eSIR_TX_RX;
3076 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3077 }
3078
3079 /*For supplicant pae role is zero*/
3080 setKey.paeRole = 0;
3081
3082 switch(ext->alg)
3083 {
3084 case IW_ENCODE_ALG_NONE:
3085 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3086 break;
3087
3088 case IW_ENCODE_ALG_WEP:
3089 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3090 break;
3091
3092 case IW_ENCODE_ALG_TKIP:
3093 {
3094 v_U8_t *pKey = &setKey.Key[0];
3095
3096 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3097
3098 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3099
3100 /*Supplicant sends the 32bytes key in this order
3101
3102 |--------------|----------|----------|
3103 | Tk1 |TX-MIC | RX Mic |
3104 |--------------|----------|----------|
3105 <---16bytes---><--8bytes--><--8bytes-->
3106
3107 */
3108 /*Sme expects the 32 bytes key to be in the below order
3109
3110 |--------------|----------|----------|
3111 | Tk1 |RX-MIC | TX Mic |
3112 |--------------|----------|----------|
3113 <---16bytes---><--8bytes--><--8bytes-->
3114 */
3115 /* Copy the Temporal Key 1 (TK1) */
3116 vos_mem_copy(pKey,ext->key,16);
3117
3118 /*Copy the rx mic first*/
3119 vos_mem_copy(&pKey[16],&ext->key[24],8);
3120
3121 /*Copy the tx mic */
3122 vos_mem_copy(&pKey[24],&ext->key[16],8);
3123
3124 }
3125 break;
3126
3127 case IW_ENCODE_ALG_CCMP:
3128 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3129 break;
3130
3131#ifdef FEATURE_WLAN_CCX
3132#define IW_ENCODE_ALG_KRK 6
3133 case IW_ENCODE_ALG_KRK:
3134 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3135 break;
3136#endif /* FEATURE_WLAN_CCX */
3137
3138 default:
3139 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3140 break;
3141 }
3142
3143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003144 ("%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 -07003145
3146#ifdef WLAN_FEATURE_VOWIFI_11R
3147/* The supplicant may attempt to set the PTK once pre-authentication is done.
3148 Save the key in the UMAC and include it in the ADD BSS request */
3149 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303150 if( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_WAIT )
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303152 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 }
3154#endif /* WLAN_FEATURE_VOWIFI_11R */
3155
3156 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3157
3158 vos_status = wlan_hdd_check_ula_done(pAdapter);
3159 if ( vos_status != VOS_STATUS_SUCCESS )
3160 {
3161 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3162 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3163 __LINE__, vos_status );
3164
3165 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3166 }
3167
3168 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3169
3170 if ( halStatus != eHAL_STATUS_SUCCESS )
3171 {
3172 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3173 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3174 __LINE__, halStatus );
3175
3176 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3177 }
3178
3179 return halStatus;
3180}
3181
3182static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3183 union iwreq_data *wrqu, char *extra)
3184{
3185 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3186 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3187
3188 ENTER();
3189
3190 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3191 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3192
3193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%ld!!\n"),wrqu->retry.value);
3194
3195 return -EINVAL;
3196 }
3197
3198 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3199
3200 if((wrqu->retry.flags & IW_RETRY_LONG))
3201 {
3202 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3203 {
3204 return -EIO;
3205 }
3206 }
3207 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3208 {
3209 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3210 {
3211 return -EIO;
3212 }
3213 }
3214 }
3215 else
3216 {
3217 return -EOPNOTSUPP;
3218 }
3219
3220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%ld!!\n"),wrqu->retry.value);
3221
3222 EXIT();
3223
3224 return 0;
3225
3226}
3227
3228static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3229 union iwreq_data *wrqu, char *extra)
3230{
3231 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3232 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3233 v_U32_t retry = 0;
3234
3235 ENTER();
3236
3237 if((wrqu->retry.flags & IW_RETRY_LONG))
3238 {
3239 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3240
3241 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3242 {
3243 return -EIO;
3244 }
3245
3246 wrqu->retry.value = retry;
3247 }
3248 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3249 {
3250 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3251
3252 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3253 {
3254 return -EIO;
3255 }
3256
3257 wrqu->retry.value = retry;
3258 }
3259 else {
3260 return -EOPNOTSUPP;
3261 }
3262
3263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%ld!!\n"),retry);
3264
3265 EXIT();
3266
3267 return 0;
3268}
3269
3270static int iw_set_mlme(struct net_device *dev,
3271 struct iw_request_info *info,
3272 union iwreq_data *wrqu,
3273 char *extra)
3274{
3275 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3276 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3277 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3278 eHalStatus status = eHAL_STATUS_SUCCESS;
3279
3280 ENTER();
3281
3282 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3283 {
3284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3285 "%s:LOGP in Progress. Ignore!!!",__func__);
3286 return 0;
3287 }
3288
3289 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3290 switch (mlme->cmd) {
3291 case IW_MLME_DISASSOC:
3292 case IW_MLME_DEAUTH:
3293
3294 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3295 {
3296 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3297
3298 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3299 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3300
3301 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3302 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3303
Jeff Johnson43971f52012-07-17 12:26:56 -07003304 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3306 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3307 else
3308 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003309 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003310
3311 /* Resetting authKeyMgmt */
3312 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3313
3314 netif_tx_disable(dev);
3315 netif_carrier_off(dev);
3316
3317 }
3318 else
3319 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003320 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 -07003321 }
3322 break;
3323 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003324 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 return -EINVAL;
3326 }//end of switch
3327
3328 EXIT();
3329
3330 return status;
3331
3332}
3333
3334/* set param sub-ioctls */
3335static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3336 union iwreq_data *wrqu, char *extra)
3337{
3338 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3339 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3340 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3341 int *value = (int *)extra;
3342 int sub_cmd = value[0];
3343 int set_value = value[1];
3344 int ret = 0; /* success */
3345 int enable_pbm, enable_mp;
3346#ifdef CONFIG_HAS_EARLYSUSPEND
3347 v_U8_t nEnableSuspendOld;
3348#endif
3349 INIT_COMPLETION(pWextState->completion_var);
3350
3351 switch(sub_cmd)
3352 {
3353 case WE_SET_11D_STATE:
3354 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003355 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3357
3358 sme_GetConfigParam(hHal,&smeConfig);
3359 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3360
3361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),smeConfig.csrConfig.Is11dSupportEnabled);
3362
3363 sme_UpdateConfig(hHal,&smeConfig);
3364 }
3365 else {
3366 return -EINVAL;
3367 }
3368 break;
3369 }
3370
3371 case WE_WOWL:
3372 {
3373 switch (set_value)
3374 {
3375 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003376 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 break;
3378 case 0x01:
3379 case 0x02:
3380 case 0x03:
3381 enable_mp = (set_value & 0x01) ? 1 : 0;
3382 enable_pbm = (set_value & 0x02) ? 1 : 0;
3383 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s\n",
3384 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3385 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3386 break;
3387 default:
3388 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL\n", set_value);
3389 ret = -EINVAL;
3390 break;
3391 }
3392
3393 break;
3394 }
3395 case WE_SET_POWER:
3396 {
3397 switch (set_value)
3398 {
3399 case 0: //Full Power
3400 {
3401 struct statsContext context;
3402 eHalStatus status;
3403
3404 init_completion(&context.completion);
3405
3406 context.pAdapter = pAdapter;
3407 context.magic = POWER_CONTEXT_MAGIC;
3408
3409 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3410 iw_power_callback_fn, &context,
3411 eSME_FULL_PWR_NEEDED_BY_HDD);
3412 if(eHAL_STATUS_PMC_PENDING == status)
3413 {
3414 int lrc = wait_for_completion_interruptible_timeout(
3415 &context.completion,
3416 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3417 context.magic = 0;
3418 if (lrc <= 0)
3419 {
3420 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3421 "requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003422 __func__, (0 == lrc) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 "timeout" : "interrupt");
3424 /* there is a race condition such that the callback
3425 function could be executing at the same time we are. of
3426 primary concern is if the callback function had already
3427 verified the "magic" but hasn't yet set the completion
3428 variable. Since the completion variable is on our
3429 stack, we'll delay just a bit to make sure the data is
3430 still valid if that is the case */
3431 msleep(50);
3432 /* we'll now returned a cached value below */
3433 }
3434 }
3435 hddLog(LOGE, "iwpriv Full Power completed\n");
3436 break;
3437 }
3438 case 1: //Enable BMPS
3439 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3440 break;
3441 case 2: //Disable BMPS
3442 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3443 break;
3444 case 3: //Request Bmps
3445 {
3446 struct statsContext context;
3447 eHalStatus status;
3448
3449 init_completion(&context.completion);
3450
3451 context.pAdapter = pAdapter;
3452 context.magic = POWER_CONTEXT_MAGIC;
3453
3454 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3455 iw_power_callback_fn, &context);
3456 if(eHAL_STATUS_PMC_PENDING == status)
3457 {
3458 int lrc = wait_for_completion_interruptible_timeout(
3459 &context.completion,
3460 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3461 context.magic = 0;
3462 if (lrc <= 0)
3463 {
3464 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3465 "requesting BMPS",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003466 __func__, (0 == lrc) ? "timeout" :
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 "interrupt");
3468 /* there is a race condition such that the callback
3469 function could be executing at the same time we are. of
3470 primary concern is if the callback function had already
3471 verified the "magic" but hasn't yet set the completion
3472 variable. Since the completion variable is on our
3473 stack, we'll delay just a bit to make sure the data is
3474 still valid if that is the case */
3475 msleep(50);
3476 /* we'll now returned a cached value below */
3477 }
3478 }
3479 hddLog(LOGE, "iwpriv Request BMPS completed\n");
3480 break;
3481 }
3482 case 4: //Enable IMPS
3483 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3484 break;
3485 case 5: //Disable IMPS
3486 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3487 break;
3488 case 6: //Enable Standby
3489 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3490 break;
3491 case 7: //Disable Standby
3492 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3493 break;
3494 case 8: //Request Standby
3495#ifdef CONFIG_HAS_EARLYSUSPEND
3496#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
3497 (void)hdd_enter_standby(pAdapter->pHddCtx);
3498#endif
3499#endif
3500 break;
3501 case 9: //Start Auto Bmps Timer
3502 sme_StartAutoBmpsTimer(hHal);
3503 break;
3504 case 10://Stop Auto BMPS Timer
3505 sme_StopAutoBmpsTimer(hHal);
3506 break;
3507#ifdef CONFIG_HAS_EARLYSUSPEND
3508 case 11://suspend to standby
3509#ifdef CONFIG_HAS_EARLYSUSPEND
3510 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3511 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
3512#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
3513 hdd_suspend_wlan(NULL);
3514#endif
3515 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3516#endif
3517 break;
3518 case 12://suspend to deep sleep
3519#ifdef CONFIG_HAS_EARLYSUSPEND
3520 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3521 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
3522#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
3523 hdd_suspend_wlan(NULL);
3524#endif
3525 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3526#endif
3527 break;
3528 case 13://resume from suspend
3529#ifdef CONFIG_HAS_EARLYSUSPEND
3530#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
3531 hdd_resume_wlan(NULL);
3532#endif
3533#endif
3534 break;
3535#endif
3536 case 14://reset wlan (power down/power up)
3537 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
3538 break;
3539 default:
3540 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL\n", set_value);
3541 ret = -EINVAL;
3542 break;
3543 }
3544 break;
3545 }
3546
3547 case WE_SET_MAX_ASSOC:
3548 {
3549 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
3550 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
3551 {
3552 ret = -EINVAL;
3553 }
3554 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
3555 set_value, NULL, eANI_BOOLEAN_FALSE)
3556 != eHAL_STATUS_SUCCESS )
3557 {
3558 ret = -EIO;
3559 }
3560 break;
3561 }
3562
3563 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
3564 {
3565 if( 0 == set_value )
3566 {
3567 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
3568 }
3569 else if ( 1 == set_value )
3570 {
3571 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
3572 }
3573 else
3574 {
3575 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL\n", set_value);
3576 ret = -EINVAL;
3577 }
3578 break;
3579 }
3580
3581 case WE_SET_DATA_INACTIVITY_TO:
3582 {
3583 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
3584 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
3585 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
3586 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
3587 set_value,
3588 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
3589 {
3590 hddLog(LOGE,"Failure: Could not pass on "
3591 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
3592 "to CCM\n");
3593 ret = -EINVAL;
3594 }
3595 break;
3596 }
3597 case WE_SET_MAX_TX_POWER:
3598 {
3599 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3600 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3601
3602 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
3603 __func__, set_value);
3604 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
3605 eHAL_STATUS_SUCCESS )
3606 {
3607 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
3608 __func__);
3609 return -EIO;
3610 }
3611
3612 break;
3613 }
3614 case WE_SET_HIGHER_DTIM_TRANSITION:
3615 {
3616 if(!((set_value == eANI_BOOLEAN_FALSE) ||
3617 (set_value == eANI_BOOLEAN_TRUE)))
3618 {
3619 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
3620 ret = -EINVAL;
3621 }
3622 else
3623 {
3624 if(pAdapter->higherDtimTransition != set_value)
3625 {
3626 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003627 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 }
3629 }
3630
3631 break;
3632 }
3633
3634 case WE_SET_TM_LEVEL:
3635 {
3636 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
3637 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
3638 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
3639
3640 break;
3641 }
3642
3643 default:
3644 {
3645 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d \n",
3646 sub_cmd, set_value);
3647 break;
3648 }
3649 }
3650
3651 return ret;
3652}
3653
3654/* set param sub-ioctls */
3655static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
3656 union iwreq_data *wrqu, char *extra)
3657{
3658 VOS_STATUS vstatus;
3659 int sub_cmd = wrqu->data.flags;
3660 int ret = 0; /* success */
3661 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3662 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3663#ifdef WLAN_FEATURE_VOWIFI
3664 hdd_config_t *pConfig = pHddCtx->cfg_ini;
3665#endif /* WLAN_FEATURE_VOWIFI */
3666
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received length %d", __func__, wrqu->data.length);
3668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003669
3670 switch(sub_cmd)
3671 {
3672 case WE_WOWL_ADD_PTRN:
3673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003674 hdd_add_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 break;
3676 case WE_WOWL_DEL_PTRN:
3677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003678 hdd_del_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 break;
3680#if defined WLAN_FEATURE_VOWIFI
3681 case WE_NEIGHBOR_REPORT_REQUEST:
3682 {
3683 tRrmNeighborReq neighborReq;
3684 tRrmNeighborRspCallbackInfo callbackInfo;
3685
3686 if (pConfig->fRrmEnable)
3687 {
3688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request\n");
3689 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
3690 if( !neighborReq.no_ssid )
3691 {
3692 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
3693 vos_mem_copy( neighborReq.ssid.ssId, wrqu->data.pointer, neighborReq.ssid.length );
3694 }
3695
3696 callbackInfo.neighborRspCallback = NULL;
3697 callbackInfo.neighborRspCallbackContext = NULL;
3698 callbackInfo.timeout = 5000; //5 seconds
3699 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
3700 }
3701 else
3702 {
3703 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled\n", __func__);
3704 ret = -EINVAL;
3705 }
3706 }
3707 break;
3708#endif
3709#ifdef WLAN_FEATURE_P2P
3710 case WE_SET_AP_WPS_IE:
3711 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
3712#ifdef WLAN_FEATURE_P2P
3713 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), wrqu->data.pointer, wrqu->data.length );
3714#endif // WLAN_FEATURE_P2P
3715 break;
3716#endif
3717 case WE_SET_CONFIG:
3718 vstatus = hdd_execute_config_command(pHddCtx, wrqu->data.pointer);
3719 if (VOS_STATUS_SUCCESS != vstatus)
3720 {
3721 ret = -EINVAL;
3722 }
3723 break;
3724 default:
3725 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003726 hddLog(LOGE, "%s: Invalid sub command %d\n",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 ret = -EINVAL;
3728 break;
3729 }
3730 }
3731 return ret;
3732}
3733
3734/* get param sub-ioctls */
3735static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
3736 union iwreq_data *wrqu, char *extra)
3737{
3738 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3739 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3740 int *value = (int *)extra;
3741 int ret = 0; /* success */
3742
3743
3744 switch (value[0])
3745 {
3746 case WE_GET_11D_STATE:
3747 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003748 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003749
3750 sme_GetConfigParam(hHal,&smeConfig);
3751
3752 *value = smeConfig.csrConfig.Is11dSupportEnabled;
3753
3754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),*value);
3755
3756 break;
3757 }
3758
3759 case WE_IBSS_STATUS:
3760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****\n");
3761 break;
3762
3763 case WE_PMC_STATE:
3764 {
3765 *value = pmcGetPmcState(hHal);
3766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%ld!!\n"),*value);
3767 break;
3768 }
3769 case WE_GET_WLAN_DBG:
3770 {
3771 vos_trace_display();
3772 *value = 0;
3773 break;
3774 }
3775 case WE_MODULE_DOWN_IND:
3776 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
3779#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
3782#endif
3783 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
3784
3785 *value = 0;
3786 break;
3787 }
3788 case WE_GET_MAX_ASSOC:
3789 {
3790 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
3791 {
3792 ret = -EIO;
3793 }
3794 break;
3795 }
3796
3797#ifdef FEATURE_WLAN_INTEGRATED_SOC
3798 case WE_GET_WDI_DBG:
3799 {
3800 wpalTraceDisplay();
3801 *value = 0;
3802 break;
3803 }
3804#endif // FEATURE_WLAN_INTEGRATED_SOC
3805
3806 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
3807 {
3808 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
3809 break;
3810 }
3811 case WE_GET_CONCURRENCY_MODE:
3812 {
3813 *value = hdd_get_concurrency_mode ( );
3814
3815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d \n"),*value);
3816 break;
3817 }
3818
3819 default:
3820 {
3821 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
3822 break;
3823 }
3824 }
3825
3826 return ret;
3827}
3828
3829/* set param sub-ioctls */
3830int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
3831 union iwreq_data *wrqu, char *extra)
3832{
3833 int *value = (int *)extra;
3834 int sub_cmd = value[0];
3835 int ret = 0;
3836
3837 switch(sub_cmd)
3838 {
3839 case WE_SET_WLAN_DBG:
3840 {
3841 vos_trace_setValue( value[1], value[2], value[3]);
3842 break;
3843 }
3844#ifdef FEATURE_WLAN_INTEGRATED_SOC
3845 case WE_SET_WDI_DBG:
3846 {
3847 wpalTraceSetLevel( value[1], value[2], value[3]);
3848 break;
3849 }
3850#endif // FEATURE_WLAN_INTEGRATED_SOC
3851 case WE_SET_SAP_CHANNELS:
3852 {
3853 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
3854 break;
3855 }
3856
3857 default:
3858 {
3859 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
3860 break;
3861 }
3862 }
3863 return ret;
3864}
3865
3866static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
3867 union iwreq_data *wrqu, char *extra)
3868{
3869 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3870 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 switch(sub_cmd)
3872 {
3873 case WE_WLAN_VERSION:
3874 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003875 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 break;
3877 }
3878
3879 case WE_GET_STATS:
3880 {
3881 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3882 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
3883 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
3884
3885 snprintf(extra, WE_MAX_STR_LEN,
3886 "\nTransmit"
3887 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3888 "\n dropped BK %u, BE %u, VI %u, VO %u"
3889 "\n classified BK %u, BE %u, VI %u, VO %u"
3890 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3891 "\n queued BK %u, BE %u, VI %u, VO %u"
3892 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3893 "\ndequeued %u, depressured %u, completed %u, flushed %u"
3894 "\n fetched BK %u, BE %u, VI %u, VO %u"
3895 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3896 "\n depressured BK %u, BE %u, VI %u, VO %u"
3897 "\n flushed BK %u, BE %u, VI %u, VO %u"
3898 "\n\nReceive"
3899 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3900 "\n\nResetsStats"
3901 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
3902 "\n",
3903 pStats->txXmitCalled,
3904 pStats->txXmitDropped,
3905 pStats->txXmitBackPressured,
3906 pStats->txXmitQueued,
3907
3908 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3909 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3910 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3911 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3912
3913 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3914 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3915 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3916 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3917
3918 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3919 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3920 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3921 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3922
3923 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3924 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3925 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3926 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3927
3928 pStats->txFetched,
3929 pStats->txFetchEmpty,
3930 pStats->txFetchLowResources,
3931 pStats->txFetchDequeueError,
3932
3933 pStats->txFetchDequeued,
3934 pStats->txFetchDePressured,
3935 pStats->txCompleted,
3936 pStats->txFlushed,
3937
3938 pStats->txFetchedAC[WLANTL_AC_BK],
3939 pStats->txFetchedAC[WLANTL_AC_BE],
3940 pStats->txFetchedAC[WLANTL_AC_VI],
3941 pStats->txFetchedAC[WLANTL_AC_VO],
3942
3943 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3944 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3945 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3946 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3947
3948 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3949 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3950 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3951 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3952
3953 pStats->txFlushedAC[WLANTL_AC_BK],
3954 pStats->txFlushedAC[WLANTL_AC_BE],
3955 pStats->txFlushedAC[WLANTL_AC_VI],
3956 pStats->txFlushedAC[WLANTL_AC_VO],
3957
3958 pStats->rxChains,
3959 pStats->rxPackets,
3960 pStats->rxDropped,
3961 pStats->rxDelivered,
3962 pStats->rxRefused,
3963
3964 pResetStats->totalLogpResets,
3965 pResetStats->totalCMD53Failures,
3966 pResetStats->totalMutexReadFailures,
3967 pResetStats->totalMIFErrorFailures,
3968 pResetStats->totalFWHearbeatFailures,
3969 pResetStats->totalUnknownExceptions
3970 );
3971 wrqu->data.length = strlen(extra)+1;
3972 break;
3973 }
3974
3975 case WE_GET_CFG:
3976 {
3977 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
3978 wrqu->data.length = strlen(extra)+1;
3979 break;
3980 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003981#ifdef WLAN_FEATURE_11AC
3982 case WE_GET_RSSI:
3983 {
3984 v_S7_t s7Rssi = 0;
3985 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3986 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
3987 wrqu->data.length = strlen(extra)+1;
3988 break;
3989 }
3990#endif
3991
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 case WE_GET_WMM_STATUS:
3993 {
3994 snprintf(extra, WE_MAX_STR_LEN,
3995 "\nDir: 0=up, 1=down, 3=both\n"
3996 "|------------------------|\n"
3997 "|AC | ACM |Admitted| Dir |\n"
3998 "|------------------------|\n"
3999 "|VO | %d | %3s | %d |\n"
4000 "|VI | %d | %3s | %d |\n"
4001 "|BE | %d | %3s | %d |\n"
4002 "|BK | %d | %3s | %d |\n"
4003 "|------------------------|\n",
4004 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4005 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4006 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4007 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4008 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4009 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4010 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4011 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4012 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4013 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4014 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4015 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4016
Jeff Johnsone7245742012-09-05 17:12:55 -07004017
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 wrqu->data.length = strlen(extra)+1;
4019 break;
4020 }
4021 case WE_GET_CHANNEL_LIST:
4022 {
4023 VOS_STATUS status;
4024 v_U8_t i, len;
4025 char* buf ;
4026 tChannelListInfo channel_list;
4027
4028 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
4029 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4030 {
4031 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!\n",__func__);
4032 return -EINVAL;
4033 }
4034 buf = extra;
4035
4036 /**
4037 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4038 * needed = 5 * number of channels. Check if sufficient buffer is available and
4039 * then proceed to fill the buffer.
4040 */
4041 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4042 {
4043 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Insufficient Buffer to populate channel list\n",__func__);
4044 return -EINVAL;
4045 }
4046 len = snprintf(buf, 5, "%u ", channel_list.num_channels);
4047 buf += len;
4048 for(i = 0 ; i < channel_list.num_channels; i++)
4049 {
4050 len = snprintf(buf, 5,
4051 "%u ", channel_list.channels[i]);
4052 buf += len;
4053 }
4054 wrqu->data.length = strlen(extra)+1;
4055
4056 break;
4057 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004058#ifdef FEATURE_WLAN_TDLS
4059 case WE_GET_TDLS_PEERS:
4060 {
4061 wrqu->data.length = wlan_hdd_tdls_get_all_peers(extra, WE_MAX_STR_LEN)+1;
4062 break;
4063 }
4064#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 default:
4066 {
4067 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4068 break;
4069 }
4070 }
4071
4072 return 0;
4073}
4074
4075/* action sub-ioctls */
4076static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4077 union iwreq_data *wrqu, char *extra)
4078{
4079 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4080 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004081 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004082
4083 switch (sub_cmd)
4084 {
4085 case WE_CLEAR_STATS:
4086 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4089 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4090 break;
4091 }
4092#ifdef WLAN_SOFTAP_FEATURE
4093 case WE_INIT_AP:
4094 {
4095 pr_info("Init AP trigger\n");
4096 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4097 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4098 break;
4099 }
4100 case WE_STOP_AP:
4101 {
4102 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
4103 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
4104 * this is a dead code and need to find the adpater by name rather than mode */
4105 hdd_adapter_t* pAdapter_to_stop =
4106 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
4107 if( pAdapter_to_stop )
4108 {
4109 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4110
4111 pr_info("Stopping AP mode\n");
4112
4113 /*Make sure that pAdapter cleaned properly*/
4114 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
4115 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
4116 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
4117
4118 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
4119 pAdapter_to_stop->macAddressCurrent.bytes);
4120 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
4121 TRUE);
4122 }
4123 else
4124 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08004125 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 }
4127
4128 break;
4129 }
4130#endif
4131#ifdef WLAN_BTAMP_FEATURE
4132 case WE_ENABLE_AMP:
4133 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 WLANBAP_RegisterWithHCI(pAdapter);
4136 break;
4137 }
4138 case WE_DISABLE_AMP:
4139 {
4140 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4141 VOS_STATUS status;
4142
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004144
4145 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4146 status = WLANBAP_StopAmp();
4147 if(VOS_STATUS_SUCCESS != status )
4148 {
4149 pHddCtx->isAmpAllowed = VOS_TRUE;
4150 hddLog(VOS_TRACE_LEVEL_FATAL,
4151 "%s: Failed to stop AMP", __func__);
4152 }
4153 else
4154 {
4155 //a state m/c implementation in PAL is TBD to avoid this delay
4156 msleep(500);
4157 pHddCtx->isAmpAllowed = VOS_FALSE;
4158 WLANBAP_DeregisterFromHCI();
4159 }
4160
4161 break;
4162 }
4163#endif
4164
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004165 case WE_ENABLE_DXE_STALL_DETECT:
4166 {
4167 sme_transportDebug(VOS_FALSE, VOS_TRUE);
4168 break;
4169 }
4170 case WE_DISPLAY_DXE_SNAP_SHOT:
4171 {
4172 sme_transportDebug(VOS_TRUE, VOS_FALSE);
4173 break;
4174 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07004175 case WE_SET_REASSOC_TRIGGER:
4176 {
4177 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4178 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
4179 v_U32_t roamId = 0;
4180 tCsrRoamModifyProfileFields modProfileFields;
4181 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
4182 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
4183 return 0;
4184 }
4185
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004186
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 default:
4188 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004189 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 break;
4191 }
4192 }
4193
4194 return ret;
4195}
4196
4197int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4198 union iwreq_data *wrqu, char *extra)
4199{
4200 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4201 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4202 int sub_cmd = wrqu->data.flags;
4203 int *value = (int*)wrqu->data.pointer;
4204 int apps_args[MAX_VAR_ARGS] = {0};
4205 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004206 hdd_station_ctx_t *pStaCtx = NULL ;
4207 hdd_ap_ctx_t *pAPCtx = NULL;
4208 int cmd = 0;
4209 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004210
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004211 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 if (num_args > MAX_VAR_ARGS)
4213 {
4214 num_args = MAX_VAR_ARGS;
4215 }
4216 vos_mem_copy(apps_args, value, (sizeof(int)) * num_args);
4217
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004218 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
4219 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
4220 {
4221 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
4222 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
4223 {
4224 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4225 staId = pStaCtx->conn_info.staId[0];
4226 }
4227 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
4228 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
4229 {
4230 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4231 staId = pAPCtx->uBCStaId;
4232 }
4233 else
4234 {
4235 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
4236 return 0;
4237 }
4238 }
4239
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 switch (sub_cmd)
4241 {
4242 case WE_LOG_DUMP_CMD:
4243 {
4244 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004245 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 apps_args[3], apps_args[4]);
4247
4248 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
4249 apps_args[3], apps_args[4]);
4250
4251 }
4252 break;
4253
4254#ifdef WLAN_FEATURE_P2P
4255 case WE_P2P_NOA_CMD:
4256 {
4257 p2p_app_setP2pPs_t p2pNoA;
4258
4259 p2pNoA.opp_ps = apps_args[0];
4260 p2pNoA.ctWindow = apps_args[1];
4261 p2pNoA.duration = apps_args[2];
4262 p2pNoA.interval = apps_args[3];
4263 p2pNoA.count = apps_args[4];
4264 p2pNoA.single_noa_duration = apps_args[5];
4265 p2pNoA.psSelection = apps_args[6];
4266
4267 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
4268 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004269 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
4271
4272 hdd_setP2pPs(dev, &p2pNoA);
4273
4274 }
4275 break;
4276#endif
4277
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004278 case WE_MCC_CONFIG_CREDENTIAL :
4279 {
4280 cmd = 287; //Command should be updated if there is any change
4281 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08004282 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004283 {
4284 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
4285 }
4286 else
4287 {
Kumar Anand90ca3dd2013-01-18 15:24:47 -08004288 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160\n");
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004289 return 0;
4290 }
4291 }
4292 break;
4293
4294 case WE_MCC_CONFIG_PARAMS :
4295 {
4296 cmd = 288; //command Should be updated if there is any change
4297 // in the Riva dump command
4298 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
4299 }
4300 break;
4301
Chilam NG571c65a2013-01-19 12:27:36 +05304302#ifdef FEATURE_WLAN_TDLS
4303 case WE_TDLS_CONFIG_PARAMS :
4304 {
4305 tdls_config_params_t tdlsParams;
4306
Chilam Ng01120412013-02-19 18:32:21 -08004307 tdlsParams.tdls = apps_args[0];
4308 tdlsParams.tx_period_t = apps_args[1];
4309 tdlsParams.tx_packet_n = apps_args[2];
4310 tdlsParams.discovery_period_t = apps_args[3];
4311 tdlsParams.discovery_tries_n = apps_args[4];
4312 tdlsParams.idle_timeout_t = apps_args[5];
4313 tdlsParams.idle_packet_n = apps_args[6];
4314 tdlsParams.rssi_hysteresis = apps_args[7];
4315 tdlsParams.rssi_trigger_threshold = apps_args[8];
4316 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05304317
Chilam Ng01120412013-02-19 18:32:21 -08004318 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05304319 }
4320 break;
4321#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 default:
4323 {
4324 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
4325 }
4326 break;
4327 }
4328
4329 return 0;
4330}
4331
4332
4333static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
4334 union iwreq_data *wrqu, char *extra)
4335{
4336 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4337 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4338 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4339 int params[HDD_WLAN_WMM_PARAM_COUNT];
4340 sme_QosWmmTspecInfo tSpec;
4341 v_U32_t handle;
4342
4343 // make sure the application is sufficiently priviledged
4344 // note that the kernel will do this for "set" ioctls, but since
4345 // this ioctl wants to return status to user space it must be
4346 // defined as a "get" ioctl
4347 if (!capable(CAP_NET_ADMIN))
4348 {
4349 return -EPERM;
4350 }
4351
4352 // we must be associated in order to add a tspec
4353 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4354 {
4355 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4356 return 0;
4357 }
4358
4359 // since we are defined to be a "get" ioctl, and since the number
4360 // of params exceeds the number of params that wireless extensions
4361 // will pass down in the iwreq_data, we must copy the "set" params
4362 // from user space ourselves
4363 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
4364 {
4365 // hmmm, can't get them
4366 return -EIO;
4367 }
4368
4369 // clear the tspec
4370 memset(&tSpec, 0, sizeof(tSpec));
4371
4372 // validate the handle
4373 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4374 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4375 {
4376 // that one is reserved
4377 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4378 return 0;
4379 }
4380
4381 // validate the TID
4382 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
4383 {
4384 // out of range
4385 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4386 return 0;
4387 }
4388 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
4389
4390 // validate the direction
4391 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
4392 {
4393 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
4394 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
4395 break;
4396
4397 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
4398 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
4399 break;
4400
4401 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
4402 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
4403 break;
4404
4405 default:
4406 // unknown
4407 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4408 return 0;
4409 }
4410
4411 // validate the user priority
4412 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
4413 {
4414 // out of range
4415 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4416 return 0;
4417 }
4418 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
4419
4420 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
4421 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
4422 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
4423 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
4424 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
4425 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
4426 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
4427 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
4428 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
4429 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
4430 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
4431 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
4432
4433 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
4434
4435 // validate the ts info ack policy
4436 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
4437 {
4438 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
4439 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
4440 break;
4441
4442 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
4443 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
4444 break;
4445
4446 default:
4447 // unknown
4448 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4449 return 0;
4450 }
4451
4452 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
4453 return 0;
4454}
4455
4456
4457static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
4458 union iwreq_data *wrqu, char *extra)
4459{
4460 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4461 int *params = (int *)extra;
4462 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4463 v_U32_t handle;
4464
4465 // make sure the application is sufficiently priviledged
4466 // note that the kernel will do this for "set" ioctls, but since
4467 // this ioctl wants to return status to user space it must be
4468 // defined as a "get" ioctl
4469 if (!capable(CAP_NET_ADMIN))
4470 {
4471 return -EPERM;
4472 }
4473
4474 // although we are defined to be a "get" ioctl, the params we require
4475 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
4476 // is no need to copy the params from user space
4477
4478 // validate the handle
4479 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4480 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4481 {
4482 // that one is reserved
4483 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4484 return 0;
4485 }
4486
4487 *pStatus = hdd_wmm_delts(pAdapter, handle);
4488 return 0;
4489}
4490
4491
4492static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
4493 union iwreq_data *wrqu, char *extra)
4494{
4495 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4496 int *params = (int *)extra;
4497 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4498 v_U32_t handle;
4499
4500 // although we are defined to be a "get" ioctl, the params we require
4501 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
4502 // is no need to copy the params from user space
4503
4504 // validate the handle
4505 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4506 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4507 {
4508 // that one is reserved
4509 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4510 return 0;
4511 }
4512
4513 *pStatus = hdd_wmm_checkts(pAdapter, handle);
4514 return 0;
4515}
4516
4517
4518#ifdef FEATURE_WLAN_WAPI
4519static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
4520 union iwreq_data *wrqu, char *extra)
4521{
4522 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4523 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4524 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4525 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4526
4527 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)wrqu->data.pointer;
4528
4529 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004530 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4531 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4532 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004533
4534
4535 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004536 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
4538 pRoamProfile->EncryptionType.numEntries = 1;
4539 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4540 pRoamProfile->mcEncryptionType.numEntries = 1;
4541 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4542
4543 pRoamProfile->AuthType.numEntries = 1;
4544 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4545 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4546 }
4547 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004548 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 }
4550 else
4551 return -EINVAL;
4552
4553 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
4554
4555 return 0;
4556}
4557
4558static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
4559 union iwreq_data *wrqu, char *extra)
4560{
4561 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4562 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
4563
4564 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
4565
4566 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004567 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
4569 return 0;
4570}
4571
4572static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
4573 union iwreq_data *wrqu, char *extra)
4574{
4575 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4576// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
4577 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
4578 int i = 0, j = 0;
4579 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004580 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4581 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4582 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004583
4584 VOS_ASSERT(pWapiAssocInfo);
4585
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004586 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x\n",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
4587 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 for(i =0 ; i < 16 ; i++)
4589 hddLog(LOG1,"akm suite[%02d]:0x%08lx",i,pWapiAssocInfo->akmSuite[i]);
4590
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004591 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 for(i =0 ; i < 16 ; i++)
4593 hddLog(LOG1, "Unicast suite[%02d]:0x%08lx",i,pWapiAssocInfo->unicastSuite[i]);
4594
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004595 hddLog(LOG1,"%s: Multicast suite:0x%08lx Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
4596 hddLog(LOG1, "%s: BKID Cnt:0x%04x\n",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 for(i = 0 ; i < 16 ; i++) {
4598 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
4599 for(j = 0 ; j < 16 ; j++)
4600 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
4601 }
4602
4603 /* We are not using the entire IE as provided by the supplicant.
4604 * This is being calculated by SME. This is the same as in the
4605 * case of WPA. Only the auth mode information needs to be
4606 * extracted here*/
4607 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004608 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
4610 }
4611
4612 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004613 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
4615 }
4616 return 0;
4617}
4618
4619static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
4620 union iwreq_data *wrqu, char *extra)
4621{
4622 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4623 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4624 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
4625 tANI_U32 roamId = 0xFF;
4626 tANI_U8 *pKeyPtr = NULL;
4627 v_BOOL_t isConnected = TRUE;
4628 tCsrRoamSetKey setKey;
4629 int i = 0;
4630
4631// WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(wrqu->data.pointer);
4632 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
4633
4634 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004635 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4636 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4637 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004638
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004639 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 -07004640 hddLog(LOG1,"Add Index:0x");
4641 for(i =0 ; i < 12 ; i++)
4642 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
4643
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004644 hddLog(LOG1,"\n%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
4646 for(i =0 ; i < 16 ; i++)
4647 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
4648
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004649 hddLog(LOG1,"\n%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
4651 for(i =0 ; i < 16 ; i++)
4652 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
4653
4654 hddLog(LOG1,"\nWAPI PN NUMBER:0x");
4655 for(i = 0 ; i < 16 ; i++)
4656 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
4657
4658 // Clear the setkey memory
4659 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4660 // Store Key ID
4661 setKey.keyId = (unsigned char)( pWapiKey->keyId );
4662 // SET WAPI Encryption
4663 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
4664 // Key Directionn both TX and RX
4665 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
4666 // the PAE role
4667 setKey.paeRole = 0 ;
4668
4669 switch ( pWapiKey->keyType )
4670 {
4671 case HDD_PAIRWISE_WAPI_KEY:
4672 {
4673 isConnected = hdd_connIsConnected(pHddStaCtx);
4674 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
4675 break;
4676 }
4677 case HDD_GROUP_WAPI_KEY:
4678 {
4679 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
4680 break;
4681 }
4682 default:
4683 {
4684 //Any other option is invalid.
4685 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004686 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004687
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004688 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
4690 break; // NEED RETURN FROM HERE ????
4691 }
4692 }
4693
4694 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
4695 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
4696 pKeyPtr = setKey.Key;
4697 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
4698 pKeyPtr += pWapiKey->wpiekLen;
4699 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
4700
4701 // Set the new key with SME.
4702 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4703
4704 if ( isConnected ) {
4705 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
4706 if ( halStatus != eHAL_STATUS_SUCCESS )
4707 {
4708 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4709 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
4710
4711 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4712 }
4713 }
4714#if 0 /// NEED TO CHECK ON THIS
4715 else
4716 {
4717 // Store the keys in the adapter to be moved to the profile & passed to
4718 // SME in the ConnectRequest if we are not yet in connected state.
4719 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
4720 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
4721
4722 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
4723 " Saving key [idx= %d] to apply when moving to connected state ",
4724 setKey.keyId );
4725
4726 }
4727#endif
4728 return halStatus;
4729}
4730
4731static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
4732 union iwreq_data *wrqu, char *extra)
4733{
4734#ifdef WLAN_DEBUG
4735 int i = 0;
4736 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) (wrqu->data.pointer);
4737#endif
4738
4739 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004740 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4741 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4742 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004743
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004744 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08lx\n", __func__,pBkid->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 hddLog(LOG1,"%s: BKID Cnt:0x%04lx",pBkid->BKIDCount);
4746
4747 hddLog(LOG1,"BKID KEY LIST[0]:0x");
4748#ifdef WLAN_DEBUG
4749 for(i =0 ; i < 16 ; i++)
4750 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
4751#endif
4752
4753 return 0;
4754}
4755
4756static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
4757 union iwreq_data *wrqu, char *extra)
4758{
4759 /* Yet to implement this function, 19th April 2010 */
4760 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
4761
4762 return 0;
4763}
4764#endif /* FEATURE_WLAN_WAPI */
4765
4766#ifdef WLAN_FEATURE_VOWIFI_11R
4767//
4768//
4769// Each time the supplicant has the auth_request or reassoc request
4770// IEs ready. This is pushed to the driver. The driver will inturn use
4771// it to send out the auth req and reassoc req for 11r FT Assoc.
4772//
4773static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
4774 union iwreq_data *wrqu, char *extra)
4775{
4776 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4777 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4778 //v_CONTEXT_t pVosContext;
4779
4780 if (!wrqu->data.length)
4781 {
4782 hddLog(LOGE, FL("%s called with 0 length IEs\n"));
4783 return -EINVAL;
4784 }
4785 if (wrqu->data.pointer == NULL)
4786 {
4787 hddLog(LOGE, FL("%s called with NULL IE\n"));
4788 return -EINVAL;
4789 }
4790
4791 // Added for debug on reception of Re-assoc Req.
4792 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4793 {
4794 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
4795 wrqu->data.length);
4796 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
4797 }
4798
4799#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
4800 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, wrqu->data.length);
4801#endif
4802
4803 // Pass the received FT IEs to SME
4804 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, wrqu->data.pointer,
4805 wrqu->data.length);
4806
4807 return 0;
4808}
4809#endif
4810
Amar Singhalf3a6e762013-02-19 15:06:50 -08004811static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004812 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08004814{
Jeff Johnson295189b2012-06-20 16:38:30 -07004815 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Amar Singhalf3a6e762013-02-19 15:06:50 -08004816 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)wrqu->data.pointer;
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004818 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08004819 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyyalamudi51d87f72012-09-24 12:05:23 -07004820 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
Amar Singhalf3a6e762013-02-19 15:06:50 -08004821 tpSirRcvFltMcAddrList mc_addr_list_ptr;
4822 int idx;
4823 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07004824
Amar Singhalf3a6e762013-02-19 15:06:50 -08004825 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004826
Amar Singhalf3a6e762013-02-19 15:06:50 -08004827 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
4828 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004829 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08004830 hddLog(VOS_TRACE_LEVEL_ERROR,
4831 "%s: vos_mem_alloc failed", __func__);
4832 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004833 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08004834
4835 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
4836
4837 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
4838 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
4839
4840 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
4841 mc_addr_list_ptr->ulMulticastAddrCnt);
4842
4843 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004844 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08004845 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
4846 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
4847
4848 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
4849 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004850 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004851
Amar Singhalf3a6e762013-02-19 15:06:50 -08004852 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
4853 vos_mem_free(mc_addr_list_ptr);
4854 if (eHAL_STATUS_SUCCESS != ret_val)
4855 {
4856 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
4857 __func__);
4858 return -EINVAL;
4859 }
4860 } else {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004861
Amar Singhalf3a6e762013-02-19 15:06:50 -08004862 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4863 "%s: Set MC BC Filter Config request: %d suspend %d",
4864 __func__, pRequest->mcastBcastFilterSetting,
4865 pHddCtx->hdd_wlan_suspended);
4866
4867 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
4868 if (NULL == wlanRxpFilterParam)
4869 {
4870 hddLog(VOS_TRACE_LEVEL_FATAL,
4871 "%s: vos_mem_alloc failed", __func__);
4872 return -EINVAL;
4873 }
4874
4875 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting =
4876 pRequest->mcastBcastFilterSetting;
4877 pHddCtx->dynamic_mcbc_filter.enableCfg = TRUE;
4878
4879 if (pHddCtx->hdd_wlan_suspended)
4880 {
4881 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
4882 pRequest->mcastBcastFilterSetting;
4883 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
4884
4885 if ((pHddCtx->cfg_ini->fhostArpOffload) &&
4886 (eConnectionState_Associated ==
4887 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
4888 {
4889 vstatus = hdd_conf_hostarpoffload(pAdapter, TRUE);
4890 if (!VOS_IS_STATUS_SUCCESS(vstatus))
4891 {
4892 hddLog(VOS_TRACE_LEVEL_INFO,
4893 "%s:Failed to enable ARPOFFLOAD Feature %d",
4894 __func__, vstatus);
4895 }
4896 else
4897 {
4898 if (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST ==
4899 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting)
4900 {
4901 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
4902 HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST;
4903 }
4904 else if (HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST ==
4905 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting)
4906 {
4907 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
4908 HDD_MCASTBCASTFILTER_FILTER_NONE;
4909 }
4910 }
4911 }
4912
4913 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
4914 __func__,
4915 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting,
4916 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
4917 wlanRxpFilterParam->setMcstBcstFilter);
4918
4919 if (eHAL_STATUS_SUCCESS != sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
4920 wlanRxpFilterParam))
4921 {
4922 hddLog(VOS_TRACE_LEVEL_ERROR,
4923 "%s: Failure to execute set HW MC/BC Filter request",
4924 __func__);
4925 return -EINVAL;
4926 }
4927
4928 pHddCtx->dynamic_mcbc_filter.mcBcFilterSuspend =
4929 wlanRxpFilterParam->configuredMcstBcstFilterSetting;
4930 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004932
4933 return 0;
4934}
4935
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004936static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
4937 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 union iwreq_data *wrqu, char *extra)
4939{
4940 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4941 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4942
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004943 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004944
4945 pHddCtx->dynamic_mcbc_filter.enableCfg = FALSE;
4946
4947 return 0;
4948}
4949
4950static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
4951 union iwreq_data *wrqu, char *extra)
4952{
4953 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4954 tpHostOffloadRequest pRequest = (tpHostOffloadRequest)wrqu->data.pointer;
4955 tSirHostOffloadReq offloadRequest;
4956
4957 /* Debug display of request components. */
4958 switch (pRequest->offloadType)
4959 {
4960 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004961 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 switch (pRequest->enableOrDisable)
4963 {
4964 case WLAN_OFFLOAD_DISABLE:
4965 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
4966 break;
4967 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
4968 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
4969 case WLAN_OFFLOAD_ENABLE:
4970 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
4971 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
4972 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
4973 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
4974 }
4975 break;
4976
4977 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
4978 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004979 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 switch (pRequest->enableOrDisable)
4981 {
4982 case WLAN_OFFLOAD_DISABLE:
4983 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
4984 break;
4985 case WLAN_OFFLOAD_ENABLE:
4986 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
4987 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
4988 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
4989 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
4990 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
4991 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
4992 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
4993 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
4994 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
4995 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
4996 }
4997 }
4998
4999 /* Execute offload request. The reason that we can copy the request information
5000 from the ioctl structure to the SME structure is that they are laid out
5001 exactly the same. Otherwise, each piece of information would have to be
5002 copied individually. */
5003 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07005004 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
5005 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 {
5007 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request\n",
5008 __func__);
5009 return -EINVAL;
5010 }
5011
5012 return 0;
5013}
5014
5015static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
5016 union iwreq_data *wrqu, char *extra)
5017{
5018 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5019 tpKeepAliveRequest pRequest = (tpKeepAliveRequest)wrqu->data.pointer;
5020 tSirKeepAliveReq keepaliveRequest;
5021
5022 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5023 {
5024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5025 "%s:LOGP in Progress. Ignore!!!",__func__);
5026 return 0;
5027 }
5028
5029 /* Debug display of request components. */
5030 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Keep Alive Request : TimePeriod %d size %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005031 __func__,pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005032
5033 switch (pRequest->packetType)
5034 {
5035 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005036 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 break;
5038
5039 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
5040
5041 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005042 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005043
5044 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
5045 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
5046 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
5047
5048 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
5049 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
5050 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
5051
5052 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
5053 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
5054 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
5055 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
5056 break;
5057
5058 }
5059
5060 /* Execute keep alive request. The reason that we can copy the request information
5061 from the ioctl structure to the SME structure is that they are laid out
5062 exactly the same. Otherwise, each piece of information would have to be
5063 copied individually. */
5064 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
5065
5066 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d\n", keepaliveRequest.timePeriod);
5067
Jeff Johnsone7245742012-09-05 17:12:55 -07005068 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
5069 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 {
5071 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive\n",
5072 __func__);
5073 return -EINVAL;
5074 }
5075
5076 return 0;
5077}
5078
5079#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -07005080int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
5081 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005082{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005083 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5084 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 int i=0;
5086
5087 if (pHddCtx->cfg_ini->disablePacketFilter)
5088 {
5089 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005090 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 return 0;
5092 }
5093
5094 /* Debug display of request components. */
5095 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005096 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07005097
5098 switch (pRequest->filterAction)
5099 {
5100 case HDD_RCV_FILTER_SET:
5101 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005102 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005103
5104 packetFilterSetReq.filterId = pRequest->filterId;
5105 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
5106 {
5107 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d\n",
5108 __func__, pRequest->numParams);
5109 return -EINVAL;
5110 }
5111 packetFilterSetReq.numFieldParams = pRequest->numParams;
5112 packetFilterSetReq.coalesceTime = 0;
5113 packetFilterSetReq.filterType = 1;
5114 for (i=0; i < pRequest->numParams; i++)
5115 {
5116 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
5117 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
5118 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
5119 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
5120 packetFilterSetReq.paramsData[i].reserved = 0;
5121
5122 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type\n",
5123 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
5124 packetFilterSetReq.filterType);
5125
5126 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d\n",
5127 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
5128
5129 memcpy(&packetFilterSetReq.paramsData[i].compareData,
5130 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
5131 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
5132 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
5133
5134 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d\n",
5135 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
5136 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
5137 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
5138
5139 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d\n",
5140 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
5141 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
5142 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
5143 }
5144
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005145 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 {
5147 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter\n",
5148 __func__);
5149 return -EINVAL;
5150 }
5151
5152 break;
5153
5154 case HDD_RCV_FILTER_CLEAR:
5155
5156 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005157 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005159 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 {
5161 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter\n",
5162 __func__);
5163 return -EINVAL;
5164 }
5165 break;
5166
5167 default :
5168 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005169 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 return -EINVAL;
5171 }
5172 return 0;
5173}
5174
Jeff Johnsone7245742012-09-05 17:12:55 -07005175void wlan_hdd_set_mc_addr_list(hdd_context_t *pHddCtx, v_U8_t set, v_U8_t sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005176{
5177 v_U8_t filterAction = 0;
5178 tPacketFilterCfg request = {0};
5179 v_U8_t i = 0;
5180
5181 filterAction = set ? HDD_RCV_FILTER_SET : HDD_RCV_FILTER_CLEAR;
5182
5183 /*set mulitcast addr list*/
5184 for (i = 0; i < pHddCtx->mc_addr_list.mc_cnt; i++)
5185 {
5186 memset(&request, 0, sizeof (tPacketFilterCfg));
5187 request.filterAction = filterAction;
5188 request.filterId = i;
5189 if (set)
5190 {
5191 request.numParams = 1;
5192 request.paramsData[0].protocolLayer = HDD_FILTER_PROTO_TYPE_MAC;
5193 request.paramsData[0].cmpFlag = HDD_FILTER_CMP_TYPE_EQUAL;
5194 request.paramsData[0].dataOffset = WLAN_HDD_80211_FRM_DA_OFFSET;
5195 request.paramsData[0].dataLength = ETH_ALEN;
5196 memcpy(&(request.paramsData[0].compareData[0]),
5197 &(pHddCtx->mc_addr_list.addr[i][0]), ETH_ALEN);
5198 /*set mulitcast filters*/
5199 hddLog(VOS_TRACE_LEVEL_INFO,
5200 "%s: %s multicast filter: addr ="
5201 "%02x:%02x:%02x:%02x:%02x:%02x",
5202 __func__, set ? "setting" : "clearing",
5203 request.paramsData[0].compareData[0],
5204 request.paramsData[0].compareData[1],
5205 request.paramsData[0].compareData[2],
5206 request.paramsData[0].compareData[3],
5207 request.paramsData[0].compareData[4],
5208 request.paramsData[0].compareData[5]);
5209 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005210 wlan_hdd_set_filter(pHddCtx, &request, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 }
5212 pHddCtx->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
5213}
5214
5215static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
5216 union iwreq_data *wrqu, char *extra)
5217{
5218 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5219 tpPacketFilterCfg pRequest = (tpPacketFilterCfg)wrqu->data.pointer;
Jeff Johnsone7245742012-09-05 17:12:55 -07005220 return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005221}
5222#endif
5223static int iw_get_statistics(struct net_device *dev,
5224 struct iw_request_info *info,
5225 union iwreq_data *wrqu, char *extra)
5226{
5227
5228 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
5229 eHalStatus status = eHAL_STATUS_SUCCESS;
5230 hdd_wext_state_t *pWextState;
5231 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5232 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5233 char *p = extra;
5234 int tlen = 0;
5235 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
5236
5237 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
5238 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
5239
5240 ENTER();
5241
5242 if (pHddCtx->isLogpInProgress) {
5243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
5244 return -EINVAL;
5245 }
5246
5247 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
5248
5249 wrqu->txpower.value = 0;
5250 }
5251 else {
5252 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
5253 SME_SUMMARY_STATS |
5254 SME_GLOBAL_CLASSA_STATS |
5255 SME_GLOBAL_CLASSB_STATS |
5256 SME_GLOBAL_CLASSC_STATS |
5257 SME_GLOBAL_CLASSD_STATS |
5258 SME_PER_STA_STATS,
5259 hdd_StatisticsCB, 0, FALSE,
5260 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
5261
5262 if (eHAL_STATUS_SUCCESS != status)
5263 {
5264 hddLog(VOS_TRACE_LEVEL_ERROR,
5265 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005266 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 return -EINVAL;
5268 }
5269
5270 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5271
5272 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
5273 if (!VOS_IS_STATUS_SUCCESS(vos_status))
5274 {
5275 hddLog(VOS_TRACE_LEVEL_ERROR,
5276 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005277 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 /*Remove the SME statistics list by passing NULL in callback argument*/
5279 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
5280 SME_SUMMARY_STATS |
5281 SME_GLOBAL_CLASSA_STATS |
5282 SME_GLOBAL_CLASSB_STATS |
5283 SME_GLOBAL_CLASSC_STATS |
5284 SME_GLOBAL_CLASSD_STATS |
5285 SME_PER_STA_STATS,
5286 NULL, 0, FALSE,
5287 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
5288
5289 return -EINVAL;
5290 }
5291 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
5292 (tANI_U8) sizeof (pStats->retry_cnt),
5293 (char*) &(pStats->retry_cnt[0]),
5294 tlen);
5295
5296 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
5297 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
5298 (char*) &(pStats->multiple_retry_cnt[0]),
5299 tlen);
5300
5301 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
5302 (tANI_U8) sizeof (pStats->tx_frm_cnt),
5303 (char*) &(pStats->tx_frm_cnt[0]),
5304 tlen);
5305
5306 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
5307 (tANI_U8) sizeof (pStats->rx_frm_cnt),
5308 (char*) &(pStats->rx_frm_cnt),
5309 tlen);
5310
5311 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
5312 (tANI_U8) sizeof (pStats->frm_dup_cnt),
5313 (char*) &(pStats->frm_dup_cnt),
5314 tlen);
5315
5316 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
5317 (tANI_U8) sizeof (pStats->fail_cnt),
5318 (char*) &(pStats->fail_cnt[0]),
5319 tlen);
5320
5321 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
5322 (tANI_U8) sizeof (pStats->rts_fail_cnt),
5323 (char*) &(pStats->rts_fail_cnt),
5324 tlen);
5325
5326 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
5327 (tANI_U8) sizeof (pStats->ack_fail_cnt),
5328 (char*) &(pStats->ack_fail_cnt),
5329 tlen);
5330
5331 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
5332 (tANI_U8) sizeof (pStats->rts_succ_cnt),
5333 (char*) &(pStats->rts_succ_cnt),
5334 tlen);
5335
5336 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
5337 (tANI_U8) sizeof (pStats->rx_discard_cnt),
5338 (char*) &(pStats->rx_discard_cnt),
5339 tlen);
5340
5341 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
5342 (tANI_U8) sizeof (pStats->rx_error_cnt),
5343 (char*) &(pStats->rx_error_cnt),
5344 tlen);
5345
Jeff Johnsone7245742012-09-05 17:12:55 -07005346 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
5347 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
5348 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 tlen);
5350
5351 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
5352 (tANI_U8) sizeof (dStats->rx_byte_cnt),
5353 (char*) &(dStats->rx_byte_cnt),
5354 tlen);
5355
5356 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
5357 (tANI_U8) sizeof (dStats->rx_rate),
5358 (char*) &(dStats->rx_rate),
5359 tlen);
5360
5361 /* Transmit rate, in units of 500 kbit/sec */
5362 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
5363 (tANI_U8) sizeof (aStats->tx_rate),
5364 (char*) &(aStats->tx_rate),
5365 tlen);
5366
Jeff Johnsone7245742012-09-05 17:12:55 -07005367 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
5368 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
5369 (char*) &(dStats->rx_uc_byte_cnt[0]),
5370 tlen);
5371 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
5372 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
5373 (char*) &(dStats->rx_mc_byte_cnt),
5374 tlen);
5375 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
5376 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
5377 (char*) &(dStats->rx_bc_byte_cnt),
5378 tlen);
5379 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
5380 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
5381 (char*) &(dStats->tx_uc_byte_cnt[0]),
5382 tlen);
5383 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
5384 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
5385 (char*) &(dStats->tx_mc_byte_cnt),
5386 tlen);
5387 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
5388 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
5389 (char*) &(dStats->tx_bc_byte_cnt),
5390 tlen);
5391
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 wrqu->data.length = tlen;
5393
5394 }
5395
5396 EXIT();
5397
5398 return 0;
5399}
5400
5401
5402#ifdef FEATURE_WLAN_SCAN_PNO
5403
5404/*Max Len for PNO notification*/
5405#define MAX_PNO_NOTIFY_LEN 100
5406void found_pref_network_cb (void *callbackContext,
5407 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
5408{
5409 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
5410 union iwreq_data wrqu;
5411 char buf[MAX_PNO_NOTIFY_LEN+1];
5412
5413 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
5414 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
5415
5416 // create the event
5417 memset(&wrqu, 0, sizeof(wrqu));
5418 memset(buf, 0, sizeof(buf));
5419
5420 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
5421 pPrefNetworkFoundInd->ssId.ssId,
5422 (unsigned int)pPrefNetworkFoundInd->rssi);
5423
5424 wrqu.data.pointer = buf;
5425 wrqu.data.length = strlen(buf);
5426
5427 // send the event
5428
5429 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5430
5431}
5432
5433
5434/*string based input*/
5435VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
5436 union iwreq_data *wrqu, char *extra, int nOffset)
5437{
5438 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07005439 /* pnoRequest is a large struct, so we make it static to avoid stack
5440 overflow. This API is only invoked via ioctl, so it is
5441 serialized by the kernel rtnl_lock and hence does not need to be
5442 reentrant */
5443 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 char *ptr;
5445 v_U8_t i,j, ucParams, ucMode;
5446 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5447
5448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5449 "PNO data len %d data %s",
5450 wrqu->data.length,
5451 wrqu->data.pointer);
5452
5453 if (wrqu->data.length <= nOffset )
5454 {
5455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
5456 return VOS_STATUS_E_FAILURE;
5457 }
5458
5459 pnoRequest.enable = 0;
5460 pnoRequest.ucNetworksCount = 0;
5461 /*-----------------------------------------------------------------------
5462 Input is string based and expected to be like this:
5463
5464 <enabled> <netw_count>
5465 for each network:
5466 <ssid_len> <ssid> <authentication> <encryption>
5467 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
5468 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
5469
5470 e.g:
5471 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
5472
5473 this translates into:
5474 -----------------------------
5475 enable PNO
5476 look for 2 networks:
5477 test - with authentication type 0 and encryption type 0,
5478 that can be found on 3 channels: 1 6 and 11 ,
5479 SSID bcast type is unknown (directed probe will be sent if AP not found)
5480 and must meet -40dBm RSSI
5481
5482 test2 - with auth and enrytption type 4/4
5483 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
5484 bcast type is non-bcast (directed probe will be sent)
5485 and must not meet any RSSI threshold
5486
5487 scan every 5 seconds 2 times, scan every 300 seconds until stopped
5488 -----------------------------------------------------------------------*/
5489 ptr = (char*)(wrqu->data.pointer + nOffset);
5490
5491 sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset);
5492
5493 if ( 0 == pnoRequest.enable )
5494 {
5495 /*Disable PNO*/
5496 memset(&pnoRequest, 0, sizeof(pnoRequest));
5497 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
5498 pAdapter->sessionId,
5499 found_pref_network_cb, pAdapter);
5500 return VOS_STATUS_SUCCESS;
5501 }
5502
5503 ptr += nOffset;
5504 sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset);
5505
5506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5507 "PNO enable %d networks count %d offset %d",
5508 pnoRequest.enable,
5509 pnoRequest.ucNetworksCount,
5510 nOffset);
5511
5512 /* Parameters checking:
5513 ucNetworksCount has to be larger than 0*/
5514 if (( 0 == pnoRequest.ucNetworksCount ) ||
5515 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
5516 {
5517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
5518 return VOS_STATUS_E_FAILURE;
5519 }
5520
5521 ptr += nOffset;
5522
5523 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
5524 {
5525
5526 pnoRequest.aNetworks[i].ssId.length = 0;
5527
5528 sscanf(ptr,"%hhu %n",
5529 &(pnoRequest.aNetworks[i].ssId.length), &nOffset);
5530
5531 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
5532 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
5533 {
5534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5535 "SSID Len %d is not correct for network %d",
5536 pnoRequest.aNetworks[i].ssId.length, i);
5537 return VOS_STATUS_E_FAILURE;
5538 }
5539
5540 /*Advance to SSID*/
5541 ptr += nOffset;
5542
Amar Singhal751e6072013-01-24 16:02:56 -08005543 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
5544 pnoRequest.aNetworks[i].ssId.length);
5545 ptr += pnoRequest.aNetworks[i].ssId.length;
5546
5547 ucParams = sscanf(ptr,"%lu %lu %hhu %n",
5548 &(pnoRequest.aNetworks[i].authentication),
5549 &(pnoRequest.aNetworks[i].encryption),
5550 &(pnoRequest.aNetworks[i].ucChannelCount),
5551 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07005552
5553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal751e6072013-01-24 16:02:56 -08005554 "PNO len %d ssid 0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx"
5555 "auth %d encry %d channel count %d offset %d",
5556 pnoRequest.aNetworks[i].ssId.length,
5557 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
5558 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
5559 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
5560 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
5561 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
5562 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
5563 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
5564 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
5565 pnoRequest.aNetworks[i].authentication,
5566 pnoRequest.aNetworks[i].encryption,
5567 pnoRequest.aNetworks[i].ucChannelCount,
5568 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07005569
Amar Singhal751e6072013-01-24 16:02:56 -08005570 if ( 3 != ucParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 {
5572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5573 "Incorrect cmd");
5574 return VOS_STATUS_E_FAILURE;
5575 }
5576
5577 /*Advance to channel list*/
5578 ptr += nOffset;
5579
5580 if ( SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount )
5581 {
5582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5583 "Incorrect number of channels");
5584 return VOS_STATUS_E_FAILURE;
5585 }
5586
5587 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
5588 {
5589 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
5590 {
5591 sscanf(ptr,"%hhu %n",
5592 &(pnoRequest.aNetworks[i].aChannels[j]), &nOffset);
5593 /*Advance to next channel number*/
5594 ptr += nOffset;
5595 }
5596 }
5597
5598 sscanf(ptr,"%lu %n",
5599 &(pnoRequest.aNetworks[i].bcastNetwType), &nOffset);
5600
5601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5602 "PNO bcastNetwType %d offset %d",
5603 pnoRequest.aNetworks[i].bcastNetwType,
5604 nOffset );
5605
5606 /*Advance to rssi Threshold*/
5607 ptr += nOffset;
5608
5609 sscanf(ptr,"%hhu %n",
5610 &(pnoRequest.aNetworks[i].rssiThreshold), &nOffset);
5611
5612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5613 "PNO rssi %d offset %d",
5614 pnoRequest.aNetworks[i].rssiThreshold,
5615 nOffset );
5616 /*Advance to next network*/
5617 ptr += nOffset;
5618 }/*For ucNetworkCount*/
5619
5620 ucParams = sscanf(ptr,"%hhu %n",
5621 &(pnoRequest.scanTimers.ucScanTimersCount), &nOffset);
5622
5623 /*Read the scan timers*/
5624 if (( 1 == ucParams )&&( pnoRequest.scanTimers.ucScanTimersCount >= 0 ))
5625 {
5626 ptr += nOffset;
5627
5628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5629 "Scan timer count %d offset %d",
5630 pnoRequest.scanTimers.ucScanTimersCount,
5631 nOffset );
5632
5633 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
5634 {
5635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5636 "Incorrect cmd - too many scan timers");
5637 return VOS_STATUS_E_FAILURE;
5638 }
5639
5640 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
5641 {
5642 ucParams = sscanf(ptr,"%lu %lu %n",
5643 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
5644 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
5645 &nOffset);
5646
5647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5648 "PNO Timer value %d Timer repeat %d offset %d",
5649 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
5650 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
5651 nOffset );
5652
5653 if ( 2 != ucParams )
5654 {
5655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5656 "Incorrect cmd - diff params then expected %d", ucParams);
5657 return VOS_STATUS_E_FAILURE;
5658 }
5659
5660 ptr += nOffset;
5661 }
5662
5663 }
5664 else
5665 {
5666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5667 "No scan timers provided param count %d scan timers %d",
5668 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
5669
5670 /*Scan timers defaults to 5 minutes*/
5671 pnoRequest.scanTimers.ucScanTimersCount = 1;
5672 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
5673 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
5674 }
5675
5676 ucParams = sscanf(ptr,"%hhu %n",
5677 &(ucMode), &nOffset);
5678
5679 pnoRequest.modePNO = ucMode;
5680 /*for LA we just expose suspend option*/
5681 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
5682 {
5683 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
5684 }
5685
5686 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
5687 pAdapter->sessionId,
5688 found_pref_network_cb, pAdapter);
5689
5690 return VOS_STATUS_SUCCESS;
5691}/*iw_set_pno*/
5692
5693VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
5694 union iwreq_data *wrqu, char *extra, int nOffset)
5695{
5696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5697 v_U8_t rssiThreshold = 0;
5698 v_U8_t nRead;
5699
5700 nRead = sscanf(wrqu->data.pointer + nOffset,"%hhu",
5701 &rssiThreshold);
5702
5703 if ( 1 != nRead )
5704 {
5705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5706 "Incorrect format");
5707 return VOS_STATUS_E_FAILURE;
5708 }
5709
5710 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
5711 return VOS_STATUS_SUCCESS;
5712}
5713
5714
5715static int iw_set_pno_priv(struct net_device *dev,
5716 struct iw_request_info *info,
5717 union iwreq_data *wrqu, char *extra)
5718{
5719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5720 "Set PNO Private");
5721 return iw_set_pno(dev,info,wrqu,extra,0);
5722}
5723#endif /*FEATURE_WLAN_SCAN_PNO*/
5724
5725//Common function to SetBand
5726int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
5727{
5728 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5729 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5730 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5731 tANI_U8 band = 0;
5732 eCsrBand currBand = eCSR_BAND_MAX;
5733
5734 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
5735
5736 switch(band)
5737 {
5738 case WLAN_HDD_UI_BAND_AUTO:
5739 band = eCSR_BAND_ALL;
5740 break;
5741 case WLAN_HDD_UI_BAND_5_GHZ:
5742 band = eCSR_BAND_5G;
5743 break;
5744 case WLAN_HDD_UI_BAND_2_4_GHZ:
5745 band = eCSR_BAND_24;
5746 break;
5747 default:
5748 band = eCSR_BAND_MAX;
5749 }
5750
5751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005752 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07005753
5754 if (band == eCSR_BAND_MAX)
5755 {
5756 /* Received change band request with invalid band value */
5757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005758 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 return -EIO;
5760 }
5761
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005762 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
5763 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
5764 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
5765 {
5766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005767 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005768 band, pHddCtx->cfg_ini->nBandCapability);
5769 return -EIO;
5770 }
5771
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
5773 {
5774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5775 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005776 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 return -EIO;
5778 }
5779
5780 if (currBand != band)
5781 {
5782 /* Change band request received.
5783 * Abort pending scan requests, flush the existing scan results,
5784 * and change the band capability
5785 */
5786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5787 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005788 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07005789
5790 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
5791 {
5792 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
5793 eHalStatus status = eHAL_STATUS_SUCCESS;
5794 long lrc;
5795
5796 /* STA already connected on current band, So issue disconnect first,
5797 * then change the band*/
5798
5799 hddLog(VOS_TRACE_LEVEL_INFO,
5800 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
5801 __func__, csrGetCurrentBand(hHal), band);
5802
5803 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
5804 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5805
5806 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5807 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5808
Jeff Johnson43971f52012-07-17 12:26:56 -07005809 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 {
5811 hddLog(VOS_TRACE_LEVEL_ERROR,
5812 "%s csrRoamDisconnect failure, returned %d \n",
5813 __func__, (int)status );
5814 return -EINVAL;
5815 }
5816
5817 lrc = wait_for_completion_interruptible_timeout(
5818 &pAdapter->disconnect_comp_var,
5819 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5820
5821 if(lrc <= 0) {
5822
5823 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005824 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005825
5826 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5827 }
5828 }
5829
5830 hdd_abort_mac_scan(pHddCtx);
5831 sme_ScanFlushResult(hHal, pAdapter->sessionId);
5832 if(eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
5833 {
5834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5835 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005836 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 return -EINVAL;
5838 }
5839#ifdef CONFIG_CFG80211
5840 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
5841#endif
5842 }
5843 return 0;
5844}
5845
5846static int iw_set_band_config(struct net_device *dev,
5847 struct iw_request_info *info,
5848 union iwreq_data *wrqu, char *extra)
5849{
5850 tANI_U8 *ptr = (tANI_U8*)wrqu->data.pointer;
5851 int ret = 0;
5852
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005854
5855 if (memcmp(ptr, "SETBAND ", 8) == 0)
5856 {
5857 /* Change band request received */
5858 ret = hdd_setBand_helper(dev, ptr);
5859 return ret;
5860
5861 }
5862 return 0;
5863}
5864
5865static int iw_set_power_params_priv(struct net_device *dev,
5866 struct iw_request_info *info,
5867 union iwreq_data *wrqu, char *extra)
5868{
5869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5870 "Set power params Private");
5871 return iw_set_power_params(dev,info,wrqu,extra,0);
5872}
5873
5874
5875
5876/*string based input*/
5877VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
5878 union iwreq_data *wrqu, char *extra, int nOffset)
5879{
5880 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5881 tSirSetPowerParamsReq powerRequest;
5882 char *ptr;
5883 v_U8_t ucType;
5884 v_U32_t uTotalSize, uValue;
5885 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5886
5887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5888 "Power Params data len %d data %s",
5889 wrqu->data.length,
5890 wrqu->data.pointer);
5891
5892 if (wrqu->data.length <= nOffset )
5893 {
5894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
5895 return VOS_STATUS_E_FAILURE;
5896 }
5897
5898 uTotalSize = wrqu->data.length - nOffset;
5899
5900 /*-----------------------------------------------------------------------
5901 Input is string based and expected to be like this:
5902
5903 <param_type> <param_value> <param_type> <param_value> ...
5904
5905 e.g:
5906 1 2 2 3 3 0 4 1 5 1
5907
5908 e.g. setting just a few:
5909 1 2 4 1
5910
5911 parameter types:
5912 -----------------------------
5913 1 - Ignore DTIM
5914 2 - Listen Interval
5915 3 - Broadcast Multicas Filter
5916 4 - Beacon Early Termination
5917 5 - Beacon Early Termination Interval
5918 -----------------------------------------------------------------------*/
5919 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
5920 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
5921 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
5922 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
5923 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
5924
5925 ptr = (char*)(wrqu->data.pointer + nOffset);
5926
5927 while ( uTotalSize )
5928 {
5929 sscanf(ptr,"%hhu %n", &(ucType), &nOffset);
5930
5931 uTotalSize -= nOffset;
5932
5933 if (!uTotalSize)
5934 {
5935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005936 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 ucType, nOffset);
5938 return VOS_STATUS_E_FAILURE;
5939 }
5940
5941 ptr += nOffset;
5942 sscanf(ptr,"%lu %n", &(uValue), &nOffset);
5943
5944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5945 "Power request parameter %d value %d offset %d",
5946 ucType, uValue, nOffset);
5947
5948 switch (ucType)
5949 {
5950 case eSIR_IGNORE_DTIM:
5951 powerRequest.uIgnoreDTIM = uValue;
5952 break;
5953 case eSIR_LISTEN_INTERVAL:
5954 powerRequest.uListenInterval = uValue;
5955 break;
5956 case eSIR_MCAST_BCAST_FILTER:
5957 powerRequest.uBcastMcastFilter = uValue;
5958 break;
5959 case eSIR_ENABLE_BET:
5960 powerRequest.uEnableBET = uValue;
5961 break;
5962 case eSIR_BET_INTERVAL:
5963 powerRequest.uBETInterval = uValue;
5964 break;
5965 default:
5966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005967 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 ucType, uValue, nOffset);
5969 return VOS_STATUS_E_FAILURE;
5970 }
5971
5972 uTotalSize -= nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07005973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5974 "Power request parameter %d Total size",
5975 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07005977 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
5978 if(!(uTotalSize - nOffset) &&
5979 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
5980 {
5981 uTotalSize = 0;
5982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005983
5984 }/*Go for as long as we have a valid string*/
5985
5986 /* put the device into full power*/
5987 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5988
5989 /* Apply the power save params*/
5990 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest);
5991
5992 /* put the device back to power save*/
5993 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5994
5995 return VOS_STATUS_SUCCESS;
5996}/*iw_set_power_params*/
5997
5998
5999// Define the Wireless Extensions to the Linux Network Device structure
6000// A number of these routines are NULL (meaning they are not implemented.)
6001
6002static const iw_handler we_handler[] =
6003{
6004 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
6005 (iw_handler) iw_get_name, /* SIOCGIWNAME */
6006 (iw_handler) NULL, /* SIOCSIWNWID */
6007 (iw_handler) NULL, /* SIOCGIWNWID */
6008 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
6009 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
6010 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
6011 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
6012 (iw_handler) NULL, /* SIOCSIWSENS */
6013 (iw_handler) NULL, /* SIOCGIWSENS */
6014 (iw_handler) NULL, /* SIOCSIWRANGE */
6015 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
6016 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
6017 (iw_handler) NULL, /* SIOCGIWPRIV */
6018 (iw_handler) NULL, /* SIOCSIWSTATS */
6019 (iw_handler) NULL, /* SIOCGIWSTATS */
6020 iw_handler_set_spy, /* SIOCSIWSPY */
6021 iw_handler_get_spy, /* SIOCGIWSPY */
6022 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
6023 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
6024 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
6025 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
6026 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
6027 (iw_handler) NULL, /* SIOCGIWAPLIST */
6028 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
6029 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
6030 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
6031 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
6032 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
6033 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
6034 (iw_handler) NULL, /* -- hole -- */
6035 (iw_handler) NULL, /* -- hole -- */
6036 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
6037 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
6038 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
6039 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
6040 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
6041 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
6042 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
6043 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
6044 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
6045 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
6046 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
6047 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
6048 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
6049 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
6050 (iw_handler) NULL, /* -- hole -- */
6051 (iw_handler) NULL, /* -- hole -- */
6052 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
6053 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
6054 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
6055 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
6056 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
6057 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
6058 (iw_handler) NULL, /* SIOCSIWPMKSA */
6059};
6060
6061static const iw_handler we_private[] = {
6062
6063 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
6064 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
6065 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
6066 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
6067 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
6068 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
6069 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
6070 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
6071 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
6072 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07006073#ifdef FEATURE_OEM_DATA_SUPPORT
6074 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
6075 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
6076#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006077
6078#ifdef FEATURE_WLAN_WAPI
6079 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
6080 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
6081 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
6082 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
6083 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
6084 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
6085#endif /* FEATURE_WLAN_WAPI */
6086#ifdef WLAN_FEATURE_VOWIFI_11R
6087 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
6088#endif
6089 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
6090 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
6091 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
6092#ifdef WLAN_FEATURE_PACKET_FILTERING
6093 ,
6094 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
6095#endif
6096#ifdef FEATURE_WLAN_SCAN_PNO
6097 ,
6098 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
6099#endif
6100 ,
6101 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
6102 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
6103 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
6104 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006105 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07006106};
6107
6108/*Maximum command length can be only 15 */
6109static const struct iw_priv_args we_private_args[] = {
6110
6111 /* handlers for main ioctl */
6112 { WLAN_PRIV_SET_INT_GET_NONE,
6113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6114 0,
6115 "" },
6116
6117 /* handlers for sub-ioctl */
6118 { WE_SET_11D_STATE,
6119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6120 0,
6121 "set11Dstate" },
6122
6123 { WE_WOWL,
6124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6125 0,
6126 "wowl" },
6127
6128 { WE_SET_POWER,
6129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6130 0,
6131 "setPower" },
6132
6133 { WE_SET_MAX_ASSOC,
6134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6135 0,
6136 "setMaxAssoc" },
6137
6138 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
6139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6140 0,
6141 "setAutoChannel" },
6142
6143 { WE_SET_DATA_INACTIVITY_TO,
6144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6145 0,
6146 "inactivityTO" },
6147
6148 { WE_SET_MAX_TX_POWER,
6149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6150 0,
6151 "setMaxTxPower" },
6152 /* set Higher DTIM Transition (DTIM1 to DTIM3)
6153 * 1 = enable and 0 = disable */
6154 {
6155 WE_SET_HIGHER_DTIM_TRANSITION,
6156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6157 0,
6158 "setHDtimTransn" },
6159
6160 { WE_SET_TM_LEVEL,
6161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6162 0,
6163 "setTmLevel" },
6164
6165 /* handlers for main ioctl */
6166 { WLAN_PRIV_SET_NONE_GET_INT,
6167 0,
6168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6169 "" },
6170
6171 /* handlers for sub-ioctl */
6172 { WE_GET_11D_STATE,
6173 0,
6174 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6175 "get11Dstate" },
6176
6177 { WE_IBSS_STATUS,
6178 0,
6179 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6180 "getAdhocStatus" },
6181
6182 { WE_PMC_STATE,
6183 0,
6184 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6185 "pmcState" },
6186
6187 { WE_GET_WLAN_DBG,
6188 0,
6189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6190 "getwlandbg" },
6191
6192 { WE_MODULE_DOWN_IND,
6193 0,
6194 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6195 "moduleDownInd" },
6196
6197 { WE_GET_MAX_ASSOC,
6198 0,
6199 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6200 "getMaxAssoc" },
6201
6202#ifdef FEATURE_WLAN_INTEGRATED_SOC
6203 { WE_GET_WDI_DBG,
6204 0,
6205 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6206 "getwdidbg" },
6207#endif // FEATURE_WLAN_INTEGRATED_SOC
6208
6209 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
6210 0,
6211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6212 "getAutoChannel" },
6213
6214 { WE_GET_CONCURRENCY_MODE,
6215 0,
6216 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6217 "getconcurrency" },
6218
6219 /* handlers for main ioctl */
6220 { WLAN_PRIV_SET_CHAR_GET_NONE,
6221 IW_PRIV_TYPE_CHAR| 512,
6222 0,
6223 "" },
6224
6225 /* handlers for sub-ioctl */
6226 { WE_WOWL_ADD_PTRN,
6227 IW_PRIV_TYPE_CHAR| 512,
6228 0,
6229 "wowlAddPtrn" },
6230
6231 { WE_WOWL_DEL_PTRN,
6232 IW_PRIV_TYPE_CHAR| 512,
6233 0,
6234 "wowlDelPtrn" },
6235
6236#if defined WLAN_FEATURE_VOWIFI
6237 /* handlers for sub-ioctl */
6238 { WE_NEIGHBOR_REPORT_REQUEST,
6239 IW_PRIV_TYPE_CHAR | 512,
6240 0,
6241 "neighbor" },
6242#endif
6243 { WE_SET_AP_WPS_IE,
6244 IW_PRIV_TYPE_CHAR| 512,
6245 0,
6246 "set_ap_wps_ie" },
6247
6248 { WE_SET_CONFIG,
6249 IW_PRIV_TYPE_CHAR| 512,
6250 0,
6251 "setConfig" },
6252
6253 /* handlers for main ioctl */
6254 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
6255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6256 0,
6257 "" },
6258
6259 /* handlers for sub-ioctl */
6260 { WE_SET_WLAN_DBG,
6261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6262 0,
6263 "setwlandbg" },
6264
6265#ifdef FEATURE_WLAN_INTEGRATED_SOC
6266 { WE_SET_WDI_DBG,
6267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6268 0,
6269 "setwdidbg" },
6270#endif // FEATURE_WLAN_INTEGRATED_SOC
6271
6272 { WE_SET_SAP_CHANNELS,
6273 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6274 0,
6275 "setsapchannels" },
6276
6277 /* handlers for main ioctl */
6278 { WLAN_PRIV_GET_CHAR_SET_NONE,
6279 0,
6280 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6281 "" },
6282
6283 /* handlers for sub-ioctl */
6284 { WE_WLAN_VERSION,
6285 0,
6286 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6287 "version" },
6288 { WE_GET_STATS,
6289 0,
6290 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6291 "getStats" },
6292 { WE_GET_CFG,
6293 0,
6294 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6295 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07006296#ifdef WLAN_FEATURE_11AC
6297 { WE_GET_RSSI,
6298 0,
6299 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6300 "getRSSI" },
6301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 { WE_GET_WMM_STATUS,
6303 0,
6304 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6305 "getWmmStatus" },
6306 {
6307 WE_GET_CHANNEL_LIST,
6308 0,
6309 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6310 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006311#ifdef FEATURE_WLAN_TDLS
6312 {
6313 WE_GET_TDLS_PEERS,
6314 0,
6315 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6316 "getTdlsPeers" },
6317#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 /* handlers for main ioctl */
6319 { WLAN_PRIV_SET_NONE_GET_NONE,
6320 0,
6321 0,
6322 "" },
6323
6324 /* handlers for sub-ioctl */
6325 { WE_CLEAR_STATS,
6326 0,
6327 0,
6328 "clearStats" },
6329 { WE_INIT_AP,
6330 0,
6331 0,
6332 "initAP" },
6333 { WE_STOP_AP,
6334 0,
6335 0,
6336 "exitAP" },
6337 { WE_ENABLE_AMP,
6338 0,
6339 0,
6340 "enableAMP" },
6341 { WE_DISABLE_AMP,
6342 0,
6343 0,
6344 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006345 { WE_ENABLE_DXE_STALL_DETECT,
6346 0,
6347 0,
6348 "dxeStallDetect" },
6349 { WE_DISPLAY_DXE_SNAP_SHOT,
6350 0,
6351 0,
6352 "dxeSnapshot" },
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07006353 {
6354 WE_SET_REASSOC_TRIGGER,
6355 0,
6356 0,
6357 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07006358
6359 /* handlers for main ioctl */
6360 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
6361 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6362 0,
6363 "" },
6364
6365 /* handlers for sub-ioctl */
6366 { WE_LOG_DUMP_CMD,
6367 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6368 0,
6369 "dump" },
6370
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006371 /* handlers for sub ioctl */
6372 {
6373 WE_MCC_CONFIG_CREDENTIAL,
6374 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6375 0,
6376 "setMccCrdnl" },
6377
6378 /* handlers for sub ioctl */
6379 {
6380 WE_MCC_CONFIG_PARAMS,
6381 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6382 0,
6383 "setMccConfig" },
6384
Chilam NG571c65a2013-01-19 12:27:36 +05306385#ifdef FEATURE_WLAN_TDLS
6386 /* handlers for sub ioctl */
6387 {
6388 WE_TDLS_CONFIG_PARAMS,
6389 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6390 0,
6391 "setTdlsConfig" },
6392#endif
6393
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 /* handlers for main ioctl */
6395 { WLAN_PRIV_ADD_TSPEC,
6396 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
6397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6398 "addTspec" },
6399
6400 /* handlers for main ioctl */
6401 { WLAN_PRIV_DEL_TSPEC,
6402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6404 "delTspec" },
6405
6406 /* handlers for main ioctl */
6407 { WLAN_PRIV_GET_TSPEC,
6408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6410 "getTspec" },
6411
Jeff Johnsone7245742012-09-05 17:12:55 -07006412#ifdef FEATURE_OEM_DATA_SUPPORT
6413 /* handlers for main ioctl - OEM DATA */
6414 {
6415 WLAN_PRIV_SET_OEM_DATA_REQ,
6416 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
6417 0,
6418 "set_oem_data_req" },
6419
6420 /* handlers for main ioctl - OEM DATA */
6421 {
6422 WLAN_PRIV_GET_OEM_DATA_RSP,
6423 0,
6424 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
6425 "get_oem_data_rsp" },
6426#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006427
6428#ifdef FEATURE_WLAN_WAPI
6429 /* handlers for main ioctl SET_WAPI_MODE */
6430 { WLAN_PRIV_SET_WAPI_MODE,
6431 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6432 0,
6433 "SET_WAPI_MODE" },
6434
6435 /* handlers for main ioctl GET_WAPI_MODE */
6436 { WLAN_PRIV_GET_WAPI_MODE,
6437 0,
6438 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6439 "GET_WAPI_MODE" },
6440
6441 /* handlers for main ioctl SET_ASSOC_INFO */
6442 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
6443 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
6444 0,
6445 "SET_WAPI_ASSOC" },
6446
6447 /* handlers for main ioctl SET_WAPI_KEY */
6448 { WLAN_PRIV_SET_WAPI_KEY,
6449 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
6450 0,
6451 "SET_WAPI_KEY" },
6452
6453 /* handlers for main ioctl SET_WAPI_BKID */
6454 { WLAN_PRIV_SET_WAPI_BKID,
6455 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
6456 0,
6457 "SET_WAPI_BKID" },
6458
6459 /* handlers for main ioctl GET_WAPI_BKID */
6460 { WLAN_PRIV_GET_WAPI_BKID,
6461 0,
6462 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
6463 "GET_WAPI_BKID" },
6464#endif /* FEATURE_WLAN_WAPI */
6465
6466 /* handlers for main ioctl - host offload */
6467 {
6468 WLAN_PRIV_SET_HOST_OFFLOAD,
6469 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
6470 0,
6471 "setHostOffload" },
6472
6473 {
6474 WLAN_GET_WLAN_STATISTICS,
6475 0,
6476 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
6477 "getWlanStats" },
6478
6479 {
6480 WLAN_SET_KEEPALIVE_PARAMS,
6481 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
6482 0,
6483 "setKeepAlive" },
6484#ifdef WLAN_FEATURE_PACKET_FILTERING
6485 {
6486 WLAN_SET_PACKET_FILTER_PARAMS,
6487 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
6488 0,
6489 "setPktFilter" },
6490#endif
6491#ifdef FEATURE_WLAN_SCAN_PNO
6492 {
6493 WLAN_SET_PNO,
6494 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6495 0,
6496 "setpno" },
6497#endif
6498 {
6499 WLAN_SET_BAND_CONFIG,
6500 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6501 0,
6502 "SETBAND" },
6503 /* handlers for dynamic MC BC ioctl */
6504 {
6505 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006506 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 0,
6508 "setMCBCFilter" },
6509 {
6510 WLAN_PRIV_CLEAR_MCBC_FILTER,
6511 0,
6512 0,
6513 "clearMCBCFilter" },
6514 {
6515 WLAN_SET_POWER_PARAMS,
6516 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6517 0,
6518 "setpowerparams" },
6519 {
6520 WLAN_GET_LINK_SPEED,
6521 IW_PRIV_TYPE_CHAR | 18,
6522 IW_PRIV_TYPE_CHAR | 3, "getLinkSpeed" },
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07006523
Jeff Johnson295189b2012-06-20 16:38:30 -07006524};
6525
6526
6527
6528const struct iw_handler_def we_handler_def = {
6529 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
6530 .num_private = sizeof(we_private) / sizeof(we_private[0]),
6531 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
6532
6533 .standard = (iw_handler *)we_handler,
6534 .private = (iw_handler *)we_private,
6535 .private_args = we_private_args,
6536 .get_wireless_stats = get_wireless_stats,
6537};
6538
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006539int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
6540{
6541 v_U32_t cmd = 288; //Command to RIVA
6542 hdd_context_t *pHddCtx = NULL;
6543 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6544 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6545 /*
6546 *configMccParam : specify the bit which needs to be modified
6547 *allowed to update based on wlan_qcom_cfg.ini
6548 * configuration
6549 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
6550 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
6551 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
6552 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
6553 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
6554 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
6555 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
6556 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
6557 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
6558 * Bit 9 : Reserved
6559 */
6560 switch (arg1)
6561 {
6562 //Update MCC SCHEDULE_TIME_SLICE parameter
6563 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
6564 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
6565 {
6566 if((arg2 >= 5) && (arg2 <= 20))
6567 {
6568 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6569 }
6570 else
6571 {
6572 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6573 return 0;
6574 }
6575 }
6576 break;
6577
6578 //Update MCC MAX_NULL_SEND_TIME parameter
6579 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
6580 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
6581 {
6582 if((arg2 >= 1) && (arg2 <= 10))
6583 {
6584 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6585 }
6586 else
6587 {
6588 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6589 return 0;
6590 }
6591 }
6592 break;
6593
6594 //Update MCC TX_EARLY_STOP_TIME parameter
6595 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
6596 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
6597 {
6598 if((arg2 >= 1) && (arg2 <= 10))
6599 {
6600 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6601 }
6602 else
6603 {
6604 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6605 return 0;
6606 }
6607 }
6608 break;
6609
6610 //Update MCC RX_DRAIN_TIME parameter
6611 case MCC_RX_DRAIN_TIME_CFG_PARAM :
6612 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
6613 {
6614 if((arg2 >= 1) && (arg2 <= 10))
6615 {
6616 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6617 }
6618 else
6619 {
6620 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6621 return 0;
6622 }
6623 }
6624 break;
6625
6626 //Update MCC CHANNEL_SWITCH_TIME parameter
6627 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
6628 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
6629 {
6630 if((arg2 >= 1) && (arg2 <= 20))
6631 {
6632 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6633 }
6634 else
6635 {
6636 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6637 return 0;
6638 }
6639 }
6640 break;
6641
6642 //Update MCC MIN_CHANNEL_TIME parameter
6643 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
6644 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
6645 {
6646 if((arg2 >= 5) && (arg2 <= 20))
6647 {
6648 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6649 }
6650 else
6651 {
6652 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6653 return 0;
6654 }
6655 }
6656 break;
6657
6658 //Update MCC PARK_BEFORE_TBTT parameter
6659 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
6660 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
6661 {
6662 if((arg2 >= 1) && (arg2 <= 5))
6663 {
6664 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6665 }
6666 else
6667 {
6668 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6669 return 0;
6670 }
6671 }
6672 break;
6673
6674 //Update MCC MIN_AFTER_DTIM parameter
6675 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
6676 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
6677 {
6678 if((arg2 >= 5) && (arg2 <= 15))
6679 {
6680 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6681 }
6682 else
6683 {
6684 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6685 return 0;
6686 }
6687 }
6688 break;
6689
6690 //Update MCC TOO_CLOSE_MARGIN parameter
6691 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
6692 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
6693 {
6694 if((arg2 >= 1) && (arg2 <= 3))
6695 {
6696 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6697 }
6698 else
6699 {
6700 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6701 return 0;
6702 }
6703 }
6704 break;
6705
6706 default :
6707 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d\n",
6708 __FUNCTION__,arg1);
6709 break;
6710 }
6711 return 0;
6712}
6713
Jeff Johnson295189b2012-06-20 16:38:30 -07006714int hdd_set_wext(hdd_adapter_t *pAdapter)
6715{
6716 hdd_wext_state_t *pwextBuf;
6717 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006718 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006719
6720 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6721
6722 // Now configure the roaming profile links. To SSID and bssid.
6723 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
6724 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
6725
6726 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
6727 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
6728
6729 /*Set the numOfChannels to zero to scan all the channels*/
6730 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
6731 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
6732
6733 /* Default is no encryption */
6734 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
6735 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6736
6737 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
6738 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6739
6740 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
6741
6742 /* Default is no authentication */
6743 pwextBuf->roamProfile.AuthType.numEntries = 1;
6744 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6745
6746 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
6747 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6748
6749 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006750 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07006751
6752 hdd_clearRoamProfileIe(pAdapter);
6753
6754 return VOS_STATUS_SUCCESS;
6755
6756 }
6757
6758int hdd_register_wext(struct net_device *dev)
6759 {
6760 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6761 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6762 VOS_STATUS status;
6763
6764 ENTER();
6765
6766 // Zero the memory. This zeros the profile structure.
6767 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
6768
6769 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
6770
6771
6772 status = hdd_set_wext(pAdapter);
6773
6774 if(!VOS_IS_STATUS_SUCCESS(status)) {
6775
6776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!\n"));
6777 return eHAL_STATUS_FAILURE;
6778 }
6779
6780 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
6781 {
6782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!\n"));
6783 return eHAL_STATUS_FAILURE;
6784 }
6785
6786 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
6787 {
6788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!\n"));
6789 return eHAL_STATUS_FAILURE;
6790 }
6791
6792 // Register as a wireless device
6793 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
6794
6795 EXIT();
6796 return 0;
6797}
6798
6799int hdd_UnregisterWext(struct net_device *dev)
6800{
6801#if 0
6802 hdd_wext_state_t *wextBuf;
6803 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6804
6805 ENTER();
6806 // Set up the pointer to the Wireless Extensions state structure
6807 wextBuf = pAdapter->pWextState;
6808
6809 // De-allocate the Wireless Extensions state structure
6810 kfree(wextBuf);
6811
6812 // Clear out the pointer to the Wireless Extensions state structure
6813 pAdapter->pWextState = NULL;
6814
6815 EXIT();
6816#endif
6817 dev->wireless_handlers = NULL;
6818 return 0;
6819}
6820
6821