blob: 43141a91822c4b6bfe6379cee53f3fb90de42003 [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"
Jeff Johnson295189b2012-06-20 16:38:30 -0700119
120#ifdef CONFIG_HAS_EARLYSUSPEND
121extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
122extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
123#endif
124
Jeff Johnsone7245742012-09-05 17:12:55 -0700125#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800126#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700127#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700128
129#define HDD_FINISH_ULA_TIME_OUT 800
130
131extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
132int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
133
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700134static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700135module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
136
137struct statsContext
138{
139 struct completion completion;
140 hdd_adapter_t *pAdapter;
141 unsigned int magic;
142};
143
144#define STATS_CONTEXT_MAGIC 0x53544154 //STAT
145#define RSSI_CONTEXT_MAGIC 0x52535349 //RSSI
146#define POWER_CONTEXT_MAGIC 0x504F5752 // POWR
147
148/* To Validate Channel against the Frequency and Vice-Versa */
149static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
150 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
151 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
152 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
153 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
154 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
155 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
156 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
157 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
158
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800159#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700160
161/* Private ioctls and their sub-ioctls */
162#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
163#define WE_SET_11D_STATE 1
164#define WE_WOWL 2
165#define WE_SET_POWER 3
166#define WE_SET_MAX_ASSOC 4
167#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
168#define WE_SET_DATA_INACTIVITY_TO 6
169#define WE_SET_MAX_TX_POWER 7
170#define WE_SET_HIGHER_DTIM_TRANSITION 8
171#define WE_SET_TM_LEVEL 9
172
173/* Private ioctls and their sub-ioctls */
174#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
175#define WE_GET_11D_STATE 1
176#define WE_IBSS_STATUS 2
177#define WE_PMC_STATE 3
178#define WE_GET_WLAN_DBG 4
179#define WE_MODULE_DOWN_IND 5
180#define WE_GET_MAX_ASSOC 6
181#define WE_GET_WDI_DBG 7
182#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
183#define WE_GET_CONCURRENCY_MODE 9
184/* Private ioctls and their sub-ioctls */
185#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
186
187/* Private ioctls and their sub-ioctls */
188#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
189#define WE_WOWL_ADD_PTRN 1
190#define WE_WOWL_DEL_PTRN 2
191#if defined WLAN_FEATURE_VOWIFI
192#define WE_NEIGHBOR_REPORT_REQUEST 3
193#endif
194#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
195#define WE_SET_CONFIG 5
196
197/* Private ioctls and their sub-ioctls */
198#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
199#define WE_SET_WLAN_DBG 1
200#define WE_SET_WDI_DBG 2
201#define WE_SET_SAP_CHANNELS 3
202
203/* Private ioctls and their sub-ioctls */
204#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
205#define WE_WLAN_VERSION 1
206#define WE_GET_STATS 2
207#define WE_GET_CFG 3
208#define WE_GET_WMM_STATUS 4
209#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700210#ifdef WLAN_FEATURE_11AC
211#define WE_GET_RSSI 6
212#endif
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800213#ifdef FEATURE_WLAN_TDLS
214#define WE_GET_TDLS_PEERS 8
215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700216
217/* Private ioctls and their sub-ioctls */
218#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
219#define WE_CLEAR_STATS 1
220#define WE_INIT_AP 2
221#define WE_STOP_AP 3
222#define WE_ENABLE_AMP 4
223#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700224#define WE_ENABLE_DXE_STALL_DETECT 6
225#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700226#define WE_SET_REASSOC_TRIGGER 8
Jeff Johnson295189b2012-06-20 16:38:30 -0700227
228/* Private ioctls and their sub-ioctls */
229#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
230#define WE_LOG_DUMP_CMD 1
231
232#ifdef WLAN_FEATURE_P2P
233#define WE_P2P_NOA_CMD 2
234#endif
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800235//IOCTL to configure MCC params
236#define WE_MCC_CONFIG_CREDENTIAL 3
237#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
Chilam NG571c65a2013-01-19 12:27:36 +0530239#ifdef FEATURE_WLAN_TDLS
240#define WE_TDLS_CONFIG_PARAMS 5
241#endif
242
Chilam Ng01120412013-02-19 18:32:21 -0800243#ifdef FEATURE_WLAN_TDLS
244#undef MAX_VAR_ARGS
245#define MAX_VAR_ARGS 10
246#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700247#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800248#endif
249
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
251/* Private ioctls (with no sub-ioctls) */
252/* note that they must be odd so that they have "get" semantics */
253#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
254#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
255#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
256
257#ifdef FEATURE_WLAN_WAPI
258/* Private ioctls EVEN NO: SET, ODD NO:GET */
259#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
260#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
261#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
262#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
263#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
264#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
265#define WAPI_PSK_AKM_SUITE 0x02721400
266#define WAPI_CERT_AKM_SUITE 0x01721400
267#endif
268
Jeff Johnsone7245742012-09-05 17:12:55 -0700269#ifdef FEATURE_OEM_DATA_SUPPORT
270/* Private ioctls for setting the measurement configuration */
271#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
272#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
273#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700274
275#ifdef WLAN_FEATURE_VOWIFI_11R
276#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
277#endif
278
279/* Private ioctl for setting the host offload feature */
280#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
281
282/* Private ioctl to get the statistics */
283#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
284
285/* Private ioctl to set the Keep Alive Params */
286#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
287#ifdef WLAN_FEATURE_PACKET_FILTERING
288/* Private ioctl to set the Packet Filtering Params */
289#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
290#endif
291
292#ifdef FEATURE_WLAN_SCAN_PNO
293/* Private ioctl to get the statistics */
294#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
295#endif
296
297#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
298
299#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
300#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700301/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700302
Jeff Johnson295189b2012-06-20 16:38:30 -0700303#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
304#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
305
306#define WLAN_STATS_INVALID 0
307#define WLAN_STATS_RETRY_CNT 1
308#define WLAN_STATS_MUL_RETRY_CNT 2
309#define WLAN_STATS_TX_FRM_CNT 3
310#define WLAN_STATS_RX_FRM_CNT 4
311#define WLAN_STATS_FRM_DUP_CNT 5
312#define WLAN_STATS_FAIL_CNT 6
313#define WLAN_STATS_RTS_FAIL_CNT 7
314#define WLAN_STATS_ACK_FAIL_CNT 8
315#define WLAN_STATS_RTS_SUC_CNT 9
316#define WLAN_STATS_RX_DISCARD_CNT 10
317#define WLAN_STATS_RX_ERROR_CNT 11
318#define WLAN_STATS_TX_BYTE_CNT 12
319
320#define WLAN_STATS_RX_BYTE_CNT 13
321#define WLAN_STATS_RX_RATE 14
322#define WLAN_STATS_TX_RATE 15
323
Jeff Johnsone7245742012-09-05 17:12:55 -0700324#define WLAN_STATS_RX_UC_BYTE_CNT 16
325#define WLAN_STATS_RX_MC_BYTE_CNT 17
326#define WLAN_STATS_RX_BC_BYTE_CNT 18
327#define WLAN_STATS_TX_UC_BYTE_CNT 19
328#define WLAN_STATS_TX_MC_BYTE_CNT 20
329#define WLAN_STATS_TX_BC_BYTE_CNT 21
330
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800331#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
332 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
333 { \
334 *__p++ = __type; \
335 *__p++ = __size; \
336 memcpy(__p, __val, __size); \
337 __p += __size; \
338 __tlen += __size + 2; \
339 } \
340 else \
341 { \
342 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!\n"); \
343 } \
344 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700345
346#define VERSION_VALUE_MAX_LEN 32
347
348#define TX_PER_TRACKING_DEFAULT_RATIO 5
349#define TX_PER_TRACKING_MAX_RATIO 10
350#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
351
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800352/*MCC Configuration parameters */
353enum {
354 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
355 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
356 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
357 MCC_RX_DRAIN_TIME_CFG_PARAM,
358 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
359 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
360 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
361 MCC_MIN_AFTER_DTIM_CFG_PARAM,
362 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
363};
364
365int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
366 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
367
Jeff Johnson295189b2012-06-20 16:38:30 -0700368#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -0700369int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
370 v_U8_t sessionId);
371void 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 -0700372#endif
373
Jeff Johnson295189b2012-06-20 16:38:30 -0700374/**---------------------------------------------------------------------------
375
376 \brief hdd_wlan_get_version() -
377
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800378 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
380 \param - pAdapter Pointer to the adapter.
381 wrqu - Pointer to IOCTL REQUEST Data.
382 extra - Pointer to char
383
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800384 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700385
386 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800387void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
388 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700389{
390 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800391 tSirVersionString wcnss_SW_version;
392 tSirVersionString wcnss_HW_version;
393 char *pSWversion;
394 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700396
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800397 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
398 sizeof(wcnss_SW_version));
399 if (VOS_IS_STATUS_SUCCESS(status))
400 {
401 pSWversion = wcnss_SW_version;
402 }
403 else
404 {
405 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 }
407
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800408 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
409 sizeof(wcnss_HW_version));
410 if (VOS_IS_STATUS_SUCCESS(status))
411 {
412 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800414 else
415 {
416 pHWversion = "Unknown";
417 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700418
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800419 wrqu->data.length = snprintf(extra, WE_MAX_STR_LEN,
420 "Host SW:%s, FW:%s, HW:%s",
421 QWLAN_VERSIONSTR,
422 pSWversion,
423 pHWversion);
424
425 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700426}
427
Jeff Johnson295189b2012-06-20 16:38:30 -0700428int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
429{
430 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
431 v_U32_t threshold = 0,status = 0;
432
433 ENTER();
434
435 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
437 "%s:LOGP in Progress. Ignore!!!",__func__);
438 return status;
439 }
440
441 if ( eHAL_STATUS_SUCCESS !=
442 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
443 {
444 return -EIO;
445 }
446 wrqu->rts.value = threshold;
447
448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
449 ("Rts-Threshold=%ld!!\n"), wrqu->rts.value);
450
451 EXIT();
452
453 return 0;
454}
455
456int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
457{
458 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
459 v_U32_t threshold = 0,status = 0;
460
461 ENTER();
462
463 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
465 "%s:LOGP in Progress. Ignore!!!",__func__);
466 return status;
467 }
468
469 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
470 != eHAL_STATUS_SUCCESS )
471 {
472 return -EIO;
473 }
474 wrqu->frag.value = threshold;
475
476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
477 ("Frag-Threshold=%ld!!\n"), wrqu->frag.value);
478
479 EXIT();
480
481 return 0;
482}
483
484int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
485{
Jeff Johnsone7245742012-09-05 17:12:55 -0700486 int i;
487 if (channel > 0)
488 {
489 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
490 {
491 if (channel == freq_chan_map[i].chan)
492 {
493 *pfreq = freq_chan_map[i].freq;
494 return 1;
495 }
496 }
497 }
498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
499 ("Invalid channel no=%d!!\n"), channel);
500 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700501}
502
503static v_BOOL_t
504hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
505{
506 v_BOOL_t rsnType = VOS_FALSE;
507 // is the authType supported?
508 switch (authType)
509 {
510 case eCSR_AUTH_TYPE_NONE: //never used
511 rsnType = eANI_BOOLEAN_FALSE;
512 break;
513 // MAC layer authentication types
514 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
515 rsnType = eANI_BOOLEAN_FALSE;
516 break;
517 case eCSR_AUTH_TYPE_SHARED_KEY:
518 rsnType = eANI_BOOLEAN_FALSE;
519 break;
520 case eCSR_AUTH_TYPE_AUTOSWITCH:
521 rsnType = eANI_BOOLEAN_FALSE;
522 break;
523
524 // Upper layer authentication types
525 case eCSR_AUTH_TYPE_WPA:
526 rsnType = eANI_BOOLEAN_TRUE;
527 break;
528 case eCSR_AUTH_TYPE_WPA_PSK:
529 rsnType = eANI_BOOLEAN_TRUE;
530 break;
531 case eCSR_AUTH_TYPE_WPA_NONE:
532 rsnType = eANI_BOOLEAN_TRUE;
533 break;
534#ifdef WLAN_FEATURE_VOWIFI_11R
535 case eCSR_AUTH_TYPE_FT_RSN:
536#endif
537 case eCSR_AUTH_TYPE_RSN:
538 rsnType = eANI_BOOLEAN_TRUE;
539 break;
540#ifdef WLAN_FEATURE_VOWIFI_11R
541 case eCSR_AUTH_TYPE_FT_RSN_PSK:
542#endif
543 case eCSR_AUTH_TYPE_RSN_PSK:
544 rsnType = eANI_BOOLEAN_TRUE;
545 break;
546 //case eCSR_AUTH_TYPE_FAILED:
547 case eCSR_AUTH_TYPE_UNKNOWN:
548 rsnType = eANI_BOOLEAN_FALSE;
549 break;
550 default:
551 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700552 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 rsnType = eANI_BOOLEAN_FALSE;
554 break;
555 }
556 hddLog(LOGE, FL("%s called with authType: %d, returned: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700557 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 return rsnType;
559}
560
561static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
562{
563 struct statsContext *pStatsContext;
564 hdd_adapter_t *pAdapter;
565
566 if (ioctl_debug)
567 {
568 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700569 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 }
571
572 if (NULL == pContext)
573 {
574 hddLog(VOS_TRACE_LEVEL_ERROR,
575 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700576 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 return;
578 }
579
580 /* there is a race condition that exists between this callback function
581 and the caller since the caller could time out either before or
582 while this code is executing. we'll assume the timeout hasn't
583 occurred, but we'll verify that right before we save our work */
584
585 pStatsContext = pContext;
586 pAdapter = pStatsContext->pAdapter;
587 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
588 {
589 /* the caller presumably timed out so there is nothing we can do */
590 hddLog(VOS_TRACE_LEVEL_WARN,
591 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700592 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 if (ioctl_debug)
594 {
595 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700596 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 }
598 return;
599 }
600
601 /* the race is on. caller could have timed out immediately after
602 we verified the magic, but if so, caller will wait a short time
603 for us to copy over the rssi */
604 pAdapter->rssi = rssi;
605
606 /* and notify the caller */
607 complete(&pStatsContext->completion);
608}
609
610VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
611{
612 struct statsContext context;
613 hdd_context_t *pHddCtx;
614 hdd_station_ctx_t *pHddStaCtx;
615 eHalStatus hstatus;
616 long lrc;
617
618 if (NULL == pAdapter)
619 {
620 hddLog(VOS_TRACE_LEVEL_WARN,
621 "%s: Invalid context, pAdapter", __func__);
622 return VOS_STATUS_E_FAULT;
623 }
624 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
625 {
626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
627 /* return a cached value */
628 *rssi_value = pAdapter->rssi;
629 return VOS_STATUS_SUCCESS;
630 }
631
632 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
633 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
634
635 init_completion(&context.completion);
636 context.pAdapter = pAdapter;
637 context.magic = RSSI_CONTEXT_MAGIC;
638
639 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
640 pHddStaCtx->conn_info.staId[ 0 ],
641 pHddStaCtx->conn_info.bssId,
642 &context, pHddCtx->pvosContext);
643 if (eHAL_STATUS_SUCCESS != hstatus)
644 {
645 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700646 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 /* we'll returned a cached value below */
648 }
649 else
650 {
651 /* request was sent -- wait for the response */
652 lrc = wait_for_completion_interruptible_timeout(&context.completion,
653 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
654 /* either we have a response or we timed out
655 either way, first invalidate our magic */
656 context.magic = 0;
657 if (lrc <= 0)
658 {
659 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700660 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 /* there is a race condition such that the callback
662 function could be executing at the same time we are. of
663 primary concern is if the callback function had already
664 verified the "magic" but hasn't yet set the completion
665 variable. Since the completion variable is on our
666 stack, we'll delay just a bit to make sure the data is
667 still valid if that is the case */
668 msleep(50);
669 /* we'll now returned a cached value below */
670 }
671 }
672 *rssi_value = pAdapter->rssi;
673
674 return VOS_STATUS_SUCCESS;
675}
676
677void hdd_StatisticsCB( void *pStats, void *pContext )
678{
679 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
680 hdd_stats_t *pStatsCache = NULL;
681 hdd_wext_state_t *pWextState;
682 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
683
684 tCsrSummaryStatsInfo *pSummaryStats = NULL;
685 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
686 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
687 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
688 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
689 tCsrPerStaStatsInfo *pPerStaStats = NULL;
690
691 if (pAdapter!= NULL)
692 pStatsCache = &pAdapter->hdd_stats;
693
694
695 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
696 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
697 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
698 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
699 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
700 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
701
702 if (pStatsCache!=NULL)
703 {
704 // and copy the stats into the cache we keep in the adapter instance structure
705 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
706 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
707 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
708 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
709 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
710 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
711 }
712
713 if(pAdapter)
714 {
715 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
716 if(pWextState)
717 {
718 vos_status = vos_event_set(&pWextState->vosevent);
719 if (!VOS_IS_STATUS_SUCCESS(vos_status))
720 {
721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700722 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 return;
724 }
725 }
726 }
727}
728
729void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
730{
731 v_CONTEXT_t pVosContext;
732 hdd_context_t *pHddCtx;
733 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
734#if 0
735 hdd_wext_state_t *pWextState;
736 v_U32_t roamId;
737#endif
738
739 ENTER();
740
741 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
742
743 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
744 if (NULL == pHddCtx)
745 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700746 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 return;
748 }
749#if 0
750 pWextState = pAdapter->pWextState;
751#endif
752
753 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
754 {
755 //TODO Verify is this is really used. If yes need to fix it.
756 hdd_reconnect_all_adapters( pHddCtx );
757#if 0
758 pAdapter->conn_info.connState = eConnectionState_NotConnected;
759 INIT_COMPLETION(pAdapter->disconnect_comp_var);
760 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
761
762 if(VOS_STATUS_SUCCESS == vosStatus)
763 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
764 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
765
766 sme_RoamConnect(halHandle,
767 pAdapter->sessionId, &(pWextState->roamProfile),
768 &roamId);
769#endif
770 }
771
772 EXIT();
773
774}
775
776void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
777{
778 int i = 0;
779 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
780
781 /* clear WPA/RSN/WSC IE information in the profile */
782 pWextState->roamProfile.nWPAReqIELength = 0;
783 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
784 pWextState->roamProfile.nRSNReqIELength = 0;
785 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
786
787 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
788 pWextState->roamProfile.pAddIEScan = (tANI_U8 *)NULL;
789 pWextState->roamProfile.nAddIEScanLength = 0;
790 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
791 pWextState->roamProfile.nAddIEAssocLength = 0;
792
793 pWextState->roamProfile.EncryptionType.numEntries = 1;
794 pWextState->roamProfile.EncryptionType.encryptionType[0]
795 = eCSR_ENCRYPT_TYPE_NONE;
796
797 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
798 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
799 = eCSR_ENCRYPT_TYPE_NONE;
800
801 pWextState->roamProfile.AuthType.numEntries = 1;
802 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
803
804 pWextState->authKeyMgmt = 0;
805
806 for (i=0; i < CSR_MAX_NUM_KEY; i++)
807 {
808 if (pWextState->roamProfile.Keys.KeyMaterial[i])
809 {
810 pWextState->roamProfile.Keys.KeyLength[i] = 0;
811 }
812 }
813#ifdef FEATURE_WLAN_WAPI
814 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
815 pAdapter->wapi_info.nWapiMode = 0;
816#endif
817
818 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
819
820}
821
822void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
823{
824 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
825 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
826
827 complete(&pWextState->completion_var);
828}
829
830VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
831{
832 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
833 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
834 VOS_STATUS vos_status;
835
836 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
837 {
838 INIT_COMPLETION(pWextState->completion_var);
839
840 /*To avoid race condition between the set key and the last EAPOL
841 packet, notify TL to finish upper layer authentication incase if the
842 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -0800843 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844
845 if ( vos_status != VOS_STATUS_SUCCESS )
846 {
847 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
848 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
849 __LINE__, vos_status );
850 return vos_status;
851
852 }
853
854 wait_for_completion_timeout(&pWextState->completion_var,
855 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
856 }
857 return VOS_STATUS_SUCCESS;
858}
859
860v_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)
861{
862
863 int left = ie_len;
864 v_U8_t *ptr = ie;
865 v_U8_t elem_id,elem_len;
866 v_U8_t eid = 0xDD;
867
868 if ( NULL == ie || 0 == ie_len )
869 return NULL;
870
871 while(left >= 2)
872 {
873 elem_id = ptr[0];
874 elem_len = ptr[1];
875 left -= 2;
876 if(elem_len > left)
877 {
878 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700879 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 eid,elem_len,left);
881 return NULL;
882 }
883 if (elem_id == eid)
884 {
885 if(memcmp( &ptr[2], oui, oui_size)==0)
886 return ptr;
887 }
888
889 left -= elem_len;
890 ptr += (elem_len + 2);
891 }
892 return NULL;
893}
894
895static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
896 union iwreq_data *wrqu, char *extra)
897{
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700898 hddLog( LOG1, "In %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 /* Do nothing for now */
900 return 0;
901}
902
903static int iw_get_name(struct net_device *dev,
904 struct iw_request_info *info,
905 char *wrqu, char *extra)
906{
907
908 ENTER();
909 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
910 EXIT();
911 return 0;
912}
913
914static int iw_set_mode(struct net_device *dev,
915 struct iw_request_info *info,
916 union iwreq_data *wrqu, char *extra)
917{
918 hdd_wext_state_t *pWextState;
919 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
920 tCsrRoamProfile *pRoamProfile;
921 eCsrRoamBssType LastBSSType;
922 eMib_dot11DesiredBssType connectedBssType;
923 hdd_config_t *pConfig;
924#ifdef CONFIG_CFG80211
925 struct wireless_dev *wdev;
926#endif
927
928 ENTER();
929
930 if (NULL == pAdapter)
931 {
932 hddLog(VOS_TRACE_LEVEL_WARN,
933 "%s: Invalid context, pAdapter", __func__);
934 return 0;
935 }
936
937 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
939 return 0;
940 }
941
942 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
943 if (pWextState == NULL)
944 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700945 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 return -EINVAL;
947 }
948
949#ifdef CONFIG_CFG80211
950 wdev = dev->ieee80211_ptr;
951#endif
952 pRoamProfile = &pWextState->roamProfile;
953 LastBSSType = pRoamProfile->BSSType;
954
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700955 hddLog( LOG1,"%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700956
957 switch (wrqu->mode)
958 {
959 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700960 hddLog( LOG1,"%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
962 // Set the phymode correctly for IBSS.
963 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
964 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
965#ifdef CONFIG_CFG80211
966 wdev->iftype = NL80211_IFTYPE_ADHOC;
967#endif
968 break;
969 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700970 hddLog( LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
972#ifdef CONFIG_CFG80211
973 wdev->iftype = NL80211_IFTYPE_STATION;
974#endif
975 break;
976 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700977 hddLog(LOG1,"%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
979 break;
980 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700981 hddLog(LOG1,"%s Unknown AP Mode value", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 return -EOPNOTSUPP;
983 }
984
985 if ( LastBSSType != pRoamProfile->BSSType )
986 {
987 //the BSS mode changed
988 // We need to issue disconnect if connected or in IBSS disconnect state
989 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
990 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
991 {
992 VOS_STATUS vosStatus;
993 // need to issue a disconnect to CSR.
994 INIT_COMPLETION(pAdapter->disconnect_comp_var);
995 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
996 pAdapter->sessionId,
997 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
998 if(VOS_STATUS_SUCCESS == vosStatus)
999 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1000 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1001 }
1002 }
1003
1004
1005
1006 EXIT();
1007 return 0;
1008}
1009
1010
1011static int iw_get_mode(struct net_device *dev,
1012 struct iw_request_info *info,
1013 v_U32_t *uwrq, char *extra)
1014{
1015
1016 hdd_wext_state_t *pWextState;
1017 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1018
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001019 hddLog (LOG1, "In %s",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001020
1021 if (NULL == pAdapter)
1022 {
1023 hddLog(VOS_TRACE_LEVEL_WARN,
1024 "%s: Invalid context, pAdapter", __func__);
1025 return 0;
1026 }
1027
1028 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1030 return 0;
1031 }
1032
1033 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1034 if (pWextState == NULL)
1035 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001036 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 return -EINVAL;
1038 }
1039
1040 switch (pWextState->roamProfile.BSSType)
1041 {
1042 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001043 hddLog(LOG1, "%s returns IW_MODE_INFRA\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 *uwrq = IW_MODE_INFRA ;
1045 break;
1046 case eCSR_BSS_TYPE_IBSS:
1047 case eCSR_BSS_TYPE_START_IBSS:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001048 hddLog( LOG1,"%s returns IW_MODE_ADHOC\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 *uwrq= IW_MODE_ADHOC;
1050 break;
1051 case eCSR_BSS_TYPE_ANY:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001052 hddLog( LOG1,"%s returns IW_MODE_AUTO\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 *uwrq= IW_MODE_AUTO;
1054 break;
1055 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001056 hddLog( LOG1,"%s returns APMODE_UNKNOWN\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 break;
1058 }
1059 return 0;
1060}
1061
1062static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1063 union iwreq_data *wrqu, char *extra)
1064{
1065 v_U32_t numChans = 0;
1066 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1067 v_U32_t indx = 0;
1068 v_U32_t status = 0;
1069
1070 hdd_wext_state_t *pWextState;
1071 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1072 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1073 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1074 tCsrRoamProfile * pRoamProfile;
1075 ENTER();
1076
1077 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1079 return status;
1080 }
1081
1082 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1083
1084 pRoamProfile = &pWextState->roamProfile;
1085
1086 hddLog(LOG1,"setCHANNEL ioctl\n");
1087
1088 /* Link is up then return cant set channel*/
1089 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1090 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1091 {
1092 hddLog( LOGE, "IBSS Associated\n");
1093 return -EOPNOTSUPP;
1094 }
1095
1096 /* Settings by Frequency as input */
1097 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1098 (wrqu->freq.m <= (tANI_U32)5.825e8))
1099 {
1100 tANI_U32 freq = wrqu->freq.m / 100000;
1101
1102 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1103 indx++;
1104 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1105 {
1106 return -EINVAL;
1107 }
1108 wrqu->freq.e = 0;
1109 wrqu->freq.m = freq_chan_map[indx].chan;
1110
1111 }
1112
1113 if (wrqu->freq.e == 0)
1114 {
1115 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1116 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1117 {
1118 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001119 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1121 return -EINVAL;
1122 }
1123
1124 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1125
1126 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1127 validChan, &numChans) != eHAL_STATUS_SUCCESS){
1128 return -EIO;
1129 }
1130
1131 for (indx = 0; indx < numChans; indx++) {
1132 if (wrqu->freq.m == validChan[indx]){
1133 break;
1134 }
1135 }
1136 }
1137 else{
1138
1139 return -EINVAL;
1140 }
1141
1142 if(indx >= numChans)
1143 {
1144 return -EINVAL;
1145 }
1146
1147 /* Set the Operational Channel */
1148 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1149 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1150 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1151
1152 hddLog(LOG1,"pRoamProfile->operationChannel = %d\n", wrqu->freq.m);
1153
1154 EXIT();
1155
1156 return status;
1157}
1158
1159static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1160 struct iw_freq *fwrq, char *extra)
1161{
Jeff Johnsone7245742012-09-05 17:12:55 -07001162 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1164 tHalHandle hHal;
1165 hdd_wext_state_t *pWextState;
1166 tCsrRoamProfile * pRoamProfile;
1167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1168
1169 ENTER();
1170
1171 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1173 return status;
1174 }
1175
1176 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1177 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1178
1179 pRoamProfile = &pWextState->roamProfile;
1180
1181 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1182 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001183 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 {
1185 return -EIO;
1186 }
1187 else
1188 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001189 status = hdd_wlan_get_freq(channel, &freq);
1190 if( TRUE == status )
1191 {
1192 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1193 * iwlist & iwconfig command shows frequency into proper
1194 * format (2.412 GHz instead of 246.2 MHz)*/
1195 fwrq->m = freq;
1196 fwrq->e = MHZ;
1197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 }
1199 }
1200 else
1201 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001202 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1203 * iwlist & iwconfig command shows frequency into proper
1204 * format (2.412 GHz instead of 246.2 MHz)*/
1205 fwrq->m = 0;
1206 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001208 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001209}
1210
1211static int iw_get_tx_power(struct net_device *dev,
1212 struct iw_request_info *info,
1213 union iwreq_data *wrqu, char *extra)
1214{
1215
1216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1217 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1218 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1219
1220 if (pHddCtx->isLogpInProgress)
1221 {
1222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1223 "%s:LOGP in Progress. Ignore!!!",__func__);
1224 return -EBUSY;
1225 }
1226
1227 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1228 {
1229 wrqu->txpower.value = 0;
1230 return 0;
1231 }
1232 wlan_hdd_get_classAstats(pAdapter);
1233 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1234
1235 return 0;
1236}
1237
1238static int iw_set_tx_power(struct net_device *dev,
1239 struct iw_request_info *info,
1240 union iwreq_data *wrqu, char *extra)
1241{
1242 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1243 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1244
1245 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1246 {
1247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1248 return 0;
1249 }
1250
1251 ENTER();
1252
1253 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1254 {
1255 return -EIO;
1256 }
1257
1258 EXIT();
1259
1260 return 0;
1261}
1262
1263static int iw_get_bitrate(struct net_device *dev,
1264 struct iw_request_info *info,
1265 union iwreq_data *wrqu, char *extra)
1266{
1267 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1268 eHalStatus status = eHAL_STATUS_SUCCESS;
1269 hdd_wext_state_t *pWextState;
1270 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1271 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1272
1273 ENTER();
1274
1275 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1277 return status;
1278 }
1279
1280 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1281 wrqu->bitrate.value = 0;
1282 }
1283 else {
1284 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1285 SME_SUMMARY_STATS |
1286 SME_GLOBAL_CLASSA_STATS |
1287 SME_GLOBAL_CLASSB_STATS |
1288 SME_GLOBAL_CLASSC_STATS |
1289 SME_GLOBAL_CLASSD_STATS |
1290 SME_PER_STA_STATS,
1291 hdd_StatisticsCB, 0, FALSE,
1292 pHddStaCtx->conn_info.staId[0], pAdapter );
1293
1294 if(eHAL_STATUS_SUCCESS != status)
1295 {
1296 hddLog(VOS_TRACE_LEVEL_ERROR,
1297 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001298 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 return status;
1300 }
1301
1302 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1303
1304 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1305
1306 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1307 {
1308 hddLog(VOS_TRACE_LEVEL_ERROR,
1309 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001310 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 return VOS_STATUS_E_FAILURE;
1312 }
1313
1314 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1315 }
1316
1317 EXIT();
1318
1319 return vos_status;
1320}
1321/* ccm call back function */
1322
1323static int iw_set_bitrate(struct net_device *dev,
1324 struct iw_request_info *info,
1325 union iwreq_data *wrqu,
1326 char *extra)
1327{
1328 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1329 hdd_wext_state_t *pWextState;
1330 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1331 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1332 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1333 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1334 v_U32_t i, rate;
1335 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1336
1337 ENTER();
1338
1339 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1341 return 0;
1342 }
1343
1344 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1345
1346 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1347 {
1348 return -ENXIO ;
1349 }
1350
1351 rate = wrqu->bitrate.value;
1352
1353 if (rate == -1)
1354 {
1355 rate = WNI_CFG_FIXED_RATE_AUTO;
1356 valid_rate = TRUE;
1357 }
1358 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1359 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1360 {
1361 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1362 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1363 {
1364 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1365 WNI_CFG_SUPPORTED_RATES_11A,
1366 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1367 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1368 WNI_CFG_SUPPORTED_RATES_11B,
1369 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1370 {
1371 for (i = 0; i < (b_len + a_len); ++i)
1372 {
1373 /* supported rates returned is double the actual rate so we divide it by 2 */
1374 if ((supp_rates[i]&0x7F)/2 == rate)
1375 {
1376 valid_rate = TRUE;
1377 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1378 break;
1379 }
1380 }
1381 }
1382 }
1383 }
1384 if (valid_rate != TRUE)
1385 {
1386 return -EINVAL;
1387 }
1388 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1389 WNI_CFG_FIXED_RATE, rate,
1390 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1391 {
1392 return -EIO;
1393 }
1394 return 0;
1395}
1396
1397
1398static int iw_set_genie(struct net_device *dev,
1399 struct iw_request_info *info,
1400 union iwreq_data *wrqu,
1401 char *extra)
1402{
1403 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1404 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1405 u_int8_t *genie;
1406 v_U16_t remLen;
1407
1408 ENTER();
1409 if(!wrqu->data.length) {
1410 hdd_clearRoamProfileIe(pAdapter);
1411 EXIT();
1412 return 0;
1413 }
1414
1415 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1417 return 0;
1418 }
1419
1420 genie = wrqu->data.pointer;
1421 remLen = wrqu->data.length;
1422
1423 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]\n", genie[0], genie[1]);
1424
1425 /* clear any previous genIE before this call */
1426 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1427
1428 while (remLen >= 2)
1429 {
1430 v_U16_t eLen = 0;
1431 v_U8_t elementId;
1432 elementId = *genie++;
1433 eLen = *genie++;
1434 remLen -= 2;
1435
1436 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
1437 __func__, elementId, eLen);
1438
1439 switch ( elementId )
1440 {
1441 case IE_EID_VENDOR:
1442 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
1443 return -EINVAL;
1444
1445 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1446 {
1447 v_U16_t curGenIELen = pWextState->genIE.length;
1448 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1449 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1450
1451 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1452 {
1453 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1454 "Need bigger buffer space\n");
1455 VOS_ASSERT(0);
1456 return -ENOMEM;
1457 }
1458 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1459 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1460 pWextState->genIE.length += eLen + 2;
1461 }
1462 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1463 {
1464 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1465 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1466 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1467 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1468 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1469 }
1470 else /* any vendorId except WPA IE should be accumulated to genIE */
1471 {
1472 v_U16_t curGenIELen = pWextState->genIE.length;
1473 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1474 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1475
1476 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1477 {
1478 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1479 "Need bigger buffer space\n");
1480 VOS_ASSERT(0);
1481 return -ENOMEM;
1482 }
1483 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1484 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1485 pWextState->genIE.length += eLen + 2;
1486 }
1487 break;
1488 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001489 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1491 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1492 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1493 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1494 break;
1495
1496 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001497 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 return 0;
1499 }
1500 genie += eLen;
1501 remLen -= eLen;
1502 }
1503 EXIT();
1504 return 0;
1505}
1506
1507static int iw_get_genie(struct net_device *dev,
1508 struct iw_request_info *info,
1509 union iwreq_data *wrqu,
1510 char *extra)
1511{
1512 hdd_wext_state_t *pWextState;
1513 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1514 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1515 eHalStatus status;
1516 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1517 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1518
1519 ENTER();
1520
1521 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1523 return 0;
1524 }
1525
1526
1527 hddLog(LOG1,"getGEN_IE ioctl\n");
1528
1529 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1530
1531 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1532 {
1533 return -ENXIO;
1534 }
1535
1536 // Return something ONLY if we are associated with an RSN or WPA network
1537 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1538 pWextState->roamProfile.negotiatedAuthType))
1539 {
1540 return -ENXIO;
1541 }
1542
1543 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1544 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1545 pAdapter->sessionId,
1546 &length,
1547 genIeBytes);
1548 wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1549
1550 vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length);
1551
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001552 hddLog(LOG1,"%s: RSN IE of %d bytes returned\n", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001553
1554 EXIT();
1555
1556 return 0;
1557}
1558
1559static int iw_get_encode(struct net_device *dev,
1560 struct iw_request_info *info,
1561 struct iw_point *dwrq, char *extra)
1562{
1563 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1564 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1565 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1566 int keyId;
1567 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1568 int i;
1569
1570 ENTER();
1571
1572 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1574 return 0;
1575 }
1576
1577 keyId = pRoamProfile->Keys.defaultIndex;
1578
1579 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1580 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001581 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 return -EINVAL;
1583 }
1584
1585 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1586 {
1587 dwrq->flags |= IW_ENCODE_ENABLED;
1588 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1589 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1590
1591 dwrq->flags |= (keyId + 1);
1592
1593 }
1594 else
1595 {
1596 dwrq->flags |= IW_ENCODE_DISABLED;
1597 }
1598
1599 for(i=0; i < MAX_WEP_KEYS; i++)
1600 {
1601 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
1602 {
1603 continue;
1604 }
1605 else
1606 {
1607 break;
1608 }
1609 }
1610
1611 if(MAX_WEP_KEYS == i)
1612 {
1613 dwrq->flags |= IW_ENCODE_NOKEY;
1614 }
1615
1616 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
1617
1618 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
1619 {
1620 dwrq->flags |= IW_ENCODE_OPEN;
1621 }
1622 else
1623 {
1624 dwrq->flags |= IW_ENCODE_RESTRICTED;
1625 }
1626 EXIT();
1627 return 0;
1628}
1629
1630#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
1631#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
1632
1633
1634/*
1635 * This function sends a single 'key' to LIM at all time.
1636 */
1637
1638static int iw_get_rts_threshold(struct net_device *dev,
1639 struct iw_request_info *info,
1640 union iwreq_data *wrqu, char *extra)
1641{
1642 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1643 v_U32_t status = 0;
1644
1645 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
1646
1647 return status;
1648}
1649
1650static int iw_set_rts_threshold(struct net_device *dev,
1651 struct iw_request_info *info,
1652 union iwreq_data *wrqu, char *extra)
1653{
1654 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1655 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1656
1657 ENTER();
1658
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001659 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1660 {
1661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1662 "%s:LOGP in Progress. Ignore!!!", __func__);
1663 return -EAGAIN;
1664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 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
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001701 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1702 {
1703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1704 "%s:LOGP in Progress. Ignore!!!", __func__);
1705 return -EBUSY;
1706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
1708 {
1709 return -EINVAL;
1710 }
1711
1712 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1713 {
1714 return -EIO;
1715 }
1716
1717 EXIT();
1718
1719 return 0;
1720}
1721
1722static int iw_get_power_mode(struct net_device *dev,
1723 struct iw_request_info *info,
1724 union iwreq_data *wrqu, char *extra)
1725{
1726 ENTER();
1727 return -EOPNOTSUPP;
1728}
1729
1730static int iw_set_power_mode(struct net_device *dev,
1731 struct iw_request_info *info,
1732 union iwreq_data *wrqu, char *extra)
1733{
1734 ENTER();
1735 return -EOPNOTSUPP;
1736}
1737
1738static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
1739 union iwreq_data *wrqu, char *extra)
1740{
1741 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1742 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1743 struct iw_range *range = (struct iw_range *) extra;
1744
1745 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1746
1747 v_U32_t num_channels = sizeof(channels);
1748 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1749 v_U32_t a_len;
1750 v_U32_t b_len;
1751 v_U32_t active_phy_mode = 0;
1752 v_U8_t index = 0, i;
1753
1754 ENTER();
1755
1756 wrqu->data.length = sizeof(struct iw_range);
1757 memset(range, 0, sizeof(struct iw_range));
1758
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001759 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1760 {
1761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1762 "%s:LOGP in Progress. Ignore!!!", __func__);
1763 return -EBUSY;
1764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001765
1766 /*Get the phy mode*/
1767 if (ccmCfgGetInt(hHal,
1768 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1769 {
1770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1771 "active_phy_mode = %ld", active_phy_mode);
1772
1773 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
1774 {
1775 /*Get the supported rates for 11G band*/
1776 if (ccmCfgGetStr(hHal,
1777 WNI_CFG_SUPPORTED_RATES_11A,
1778 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
1779 {
1780 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
1781 {
1782 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1783 }
1784 for (i = 0; i < a_len; i++)
1785 {
1786 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
1787 }
1788 range->num_bitrates = a_len;
1789 }
1790 else
1791 {
1792 return -EIO;
1793 }
1794 }
1795 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1796 {
1797 /*Get the supported rates for 11B band*/
1798 if (ccmCfgGetStr(hHal,
1799 WNI_CFG_SUPPORTED_RATES_11B,
1800 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
1801 {
1802 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
1803 {
1804 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1805 }
1806 for (i = 0; i < b_len; i++)
1807 {
1808 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
1809 }
1810 range->num_bitrates = b_len;
1811 }
1812 else
1813 {
1814 return -EIO;
1815 }
1816 }
1817 }
1818
1819 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
1820 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
1821 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
1822
1823 range->encoding_size[0] = 5;
1824 range->encoding_size[1] = 13;
1825 range->num_encoding_sizes = 2;
1826 range->max_encoding_tokens = MAX_WEP_KEYS;
1827
1828 // we support through Wireless Extensions 22
1829 range->we_version_compiled = WIRELESS_EXT;
1830 range->we_version_source = 22;
1831
1832 /*Supported Channels and Frequencies*/
1833 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
1834 {
1835 return -EIO;
1836 }
1837 if (num_channels > IW_MAX_FREQUENCIES)
1838 {
1839 num_channels = IW_MAX_FREQUENCIES;
1840 }
1841
1842 range->num_channels = num_channels;
1843 range->num_frequency = num_channels;
1844
1845 for (index=0; index < num_channels; index++)
1846 {
1847 v_U32_t frq_indx = 0;
1848
1849 range->freq[index].i = channels[index];
1850 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
1851 {
1852 if(channels[index] == freq_chan_map[frq_indx].chan)
1853 {
1854 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
1855 range->freq[index].e = 1;
1856 break;
1857 }
1858 frq_indx++;
1859 }
1860 }
1861
1862 /* Event capability (kernel + driver) */
1863 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
1864 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
1865 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
1866 range->event_capa[1] = IW_EVENT_CAPA_K_1;
1867
1868 /*Encryption capability*/
1869 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
1870 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
1871
1872 /* Txpower capability */
1873 range->txpower_capa = IW_TXPOW_MWATT;
1874
1875 /*Scanning capability*/
1876 #if WIRELESS_EXT >= 22
1877 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
1878 #endif
1879
1880 EXIT();
1881 return 0;
1882}
1883
1884/* Callback function registered with PMC to know status of PMC request */
1885static void iw_power_callback_fn (void *pContext, eHalStatus status)
1886{
1887 struct statsContext *pStatsContext;
1888 hdd_adapter_t *pAdapter;
1889
1890 if (NULL == pContext)
1891 {
1892 hddLog(VOS_TRACE_LEVEL_ERROR,
1893 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001894 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 return;
1896 }
1897
1898 /* there is a race condition that exists between this callback function
1899 and the caller since the caller could time out either before or
1900 while this code is executing. we'll assume the timeout hasn't
1901 occurred, but we'll verify that right before we save our work */
1902
1903 pStatsContext = (struct statsContext *)pContext;
1904 pAdapter = pStatsContext->pAdapter;
1905
1906 if ((NULL == pAdapter) || (POWER_CONTEXT_MAGIC != pStatsContext->magic))
1907 {
1908 /* the caller presumably timed out so there is nothing we can do */
1909 hddLog(VOS_TRACE_LEVEL_WARN,
1910 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001911 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07001912
1913 if (ioctl_debug)
1914 {
1915 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001916 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 }
1918 return;
1919 }
1920
1921 /* and notify the caller */
1922 complete(&pStatsContext->completion);
1923}
1924
1925/* Callback function for tx per hit */
1926void hdd_tx_per_hit_cb (void *pCallbackContext)
1927{
1928 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
1929 unsigned char tx_fail[16];
1930 union iwreq_data wrqu;
1931
1932 if (NULL == pAdapter)
1933 {
1934 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL\n");
1935 return;
1936 }
1937 memset(&wrqu, 0, sizeof(wrqu));
1938 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
1939 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
1940}
1941
1942void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
1943{
1944 struct statsContext *pStatsContext;
1945 tCsrGlobalClassAStatsInfo *pClassAStats;
1946 hdd_adapter_t *pAdapter;
1947
1948 if (ioctl_debug)
1949 {
1950 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001951 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 }
1953
1954 if ((NULL == pStats) || (NULL == pContext))
1955 {
1956 hddLog(VOS_TRACE_LEVEL_ERROR,
1957 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001958 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 return;
1960 }
1961
1962 /* there is a race condition that exists between this callback function
1963 and the caller since the caller could time out either before or
1964 while this code is executing. we'll assume the timeout hasn't
1965 occurred, but we'll verify that right before we save our work */
1966
1967 pClassAStats = pStats;
1968 pStatsContext = pContext;
1969 pAdapter = pStatsContext->pAdapter;
1970 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
1971 {
1972 /* the caller presumably timed out so there is nothing we can do */
1973 hddLog(VOS_TRACE_LEVEL_WARN,
1974 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001975 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 if (ioctl_debug)
1977 {
1978 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001979 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 }
1981 return;
1982 }
1983
1984 /* the race is on. caller could have timed out immediately after
1985 we verified the magic, but if so, caller will wait a short time
1986 for us to copy over the stats. do so as a struct copy */
1987 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
1988
1989 /* and notify the caller */
1990 complete(&pStatsContext->completion);
1991}
1992
1993VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
1994{
1995 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1996 eHalStatus hstatus;
1997 long lrc;
1998 struct statsContext context;
1999
2000 if (NULL == pAdapter)
2001 {
2002 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2003 return VOS_STATUS_E_FAULT;
2004 }
2005 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2006 {
2007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2008 return VOS_STATUS_SUCCESS;
2009 }
2010
2011 /* we are connected
2012 prepare our callback context */
2013 init_completion(&context.completion);
2014 context.pAdapter = pAdapter;
2015 context.magic = STATS_CONTEXT_MAGIC;
2016 /* query only for Class A statistics (which include link speed) */
2017 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2018 eCSR_HDD,
2019 SME_GLOBAL_CLASSA_STATS,
2020 hdd_GetClassA_statisticsCB,
2021 0, // not periodic
2022 FALSE, //non-cached results
2023 pHddStaCtx->conn_info.staId[0],
2024 &context);
2025 if (eHAL_STATUS_SUCCESS != hstatus)
2026 {
2027 hddLog(VOS_TRACE_LEVEL_ERROR,
2028 "%s: Unable to retrieve Class A statistics ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002029 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 /* we'll returned a cached value below */
2031 }
2032 else
2033 {
2034 /* request was sent -- wait for the response */
2035 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2036 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2037 /* either we have a response or we timed out
2038 either way, first invalidate our magic */
2039 context.magic = 0;
2040 if (lrc <= 0)
2041 {
2042 hddLog(VOS_TRACE_LEVEL_ERROR,
2043 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002044 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 /* there is a race condition such that the callback
2046 function could be executing at the same time we are. of
2047 primary concern is if the callback function had already
2048 verified the "magic" but hasn't yet set the completion
2049 variable. Since the completion variable is on our
2050 stack, we'll delay just a bit to make sure the data is
2051 still valid if that is the case */
2052 msleep(50);
2053 }
2054 }
2055 return VOS_STATUS_SUCCESS;
2056}
2057
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002058static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2059{
2060 struct statsContext *pStatsContext;
2061 tCsrSummaryStatsInfo *pSummaryStats;
2062 tCsrGlobalClassAStatsInfo *pClassAStats;
2063 hdd_adapter_t *pAdapter;
2064
2065 if (ioctl_debug)
2066 {
2067 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002068 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002069 }
2070
2071 if ((NULL == pStats) || (NULL == pContext))
2072 {
2073 hddLog(VOS_TRACE_LEVEL_ERROR,
2074 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002075 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002076 return;
2077 }
2078
2079 /* there is a race condition that exists between this callback function
2080 and the caller since the caller could time out either before or
2081 while this code is executing. we'll assume the timeout hasn't
2082 occurred, but we'll verify that right before we save our work */
2083
2084 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2085 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2086 pStatsContext = pContext;
2087 pAdapter = pStatsContext->pAdapter;
2088 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2089 {
2090 /* the caller presumably timed out so there is nothing we can do */
2091 hddLog(VOS_TRACE_LEVEL_WARN,
2092 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002093 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002094 if (ioctl_debug)
2095 {
2096 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002097 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002098 }
2099 return;
2100 }
2101
2102 /* the race is on. caller could have timed out immediately after
2103 we verified the magic, but if so, caller will wait a short time
2104 for us to copy over the stats. do so as a struct copy */
2105 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2106 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2107
2108 /* and notify the caller */
2109 complete(&pStatsContext->completion);
2110}
2111
2112VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2113{
2114 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2115 eHalStatus hstatus;
2116 long lrc;
2117 struct statsContext context;
2118
2119 if (NULL == pAdapter)
2120 {
2121 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2122 return VOS_STATUS_SUCCESS;
2123 }
2124
2125 /* we are connected
2126 prepare our callback context */
2127 init_completion(&context.completion);
2128 context.pAdapter = pAdapter;
2129 context.magic = STATS_CONTEXT_MAGIC;
2130
2131 /* query only for Summary & Class A statistics */
2132 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2133 eCSR_HDD,
2134 SME_SUMMARY_STATS |
2135 SME_GLOBAL_CLASSA_STATS,
2136 hdd_get_station_statisticsCB,
2137 0, // not periodic
2138 FALSE, //non-cached results
2139 pHddStaCtx->conn_info.staId[0],
2140 &context);
2141 if (eHAL_STATUS_SUCCESS != hstatus)
2142 {
2143 hddLog(VOS_TRACE_LEVEL_ERROR,
2144 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002145 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002146 /* we'll return with cached values */
2147 }
2148 else
2149 {
2150 /* request was sent -- wait for the response */
2151 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2152 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2153 /* either we have a response or we timed out
2154 either way, first invalidate our magic */
2155 context.magic = 0;
2156 if (lrc <= 0)
2157 {
2158 hddLog(VOS_TRACE_LEVEL_ERROR,
2159 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002160 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002161 /* there is a race condition such that the callback
2162 function could be executing at the same time we are. of
2163 primary concern is if the callback function had already
2164 verified the "magic" but hasn't yet set the completion
2165 variable. Since the completion variable is on our
2166 stack, we'll delay just a bit to make sure the data is
2167 still valid if that is the case */
2168 msleep(50);
2169 }
2170 }
2171 return VOS_STATUS_SUCCESS;
2172}
2173
2174
Jeff Johnson295189b2012-06-20 16:38:30 -07002175/*
2176 * Support for the LINKSPEED private command
2177 * Per the WiFi framework the response must be of the form
2178 * "LinkSpeed xx"
2179 */
2180static int iw_get_linkspeed(struct net_device *dev,
2181 struct iw_request_info *info,
2182 union iwreq_data *wrqu, char *extra)
2183{
2184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2185 char *pLinkSpeed = (char*)extra;
2186 int len = sizeof(v_U16_t) + 1;
2187 v_U16_t link_speed;
2188 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2189 int rc;
2190
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002191 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2192 {
2193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2194 "%s:LOGP in Progress. Ignore!!!", __func__);
2195 return -EBUSY;
2196 }
2197
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2199 {
2200 /* we are not connected so we don't have a classAstats */
2201 link_speed = 0;
2202 }
2203 else
2204 {
2205 wlan_hdd_get_classAstats(pAdapter);
2206 //The linkspeed returned by HAL is in units of 500kbps.
2207 //converting it to mbps
2208 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2209 }
2210
2211 wrqu->data.length = len;
2212 // return the linkspeed in the format required by the WiFi Framework
2213 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
2214 if ((rc < 0) || (rc >= len))
2215 {
2216 // encoding or length error?
2217 hddLog(VOS_TRACE_LEVEL_ERROR,
2218 "%s: Unable to encode link speed, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002219 __func__,pLinkSpeed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 return -EIO;
2221 }
2222
2223 /* a value is being successfully returned */
2224 return 0;
2225}
2226
2227
2228/*
2229 * Support for the RSSI & RSSI-APPROX private commands
2230 * Per the WiFi framework the response must be of the form
2231 * "<ssid> rssi <xx>"
2232 * unless we are not associated, in which case the response is
2233 * "OK"
2234 */
2235static int iw_get_rssi(struct net_device *dev,
2236 struct iw_request_info *info,
2237 union iwreq_data *wrqu, char *extra)
2238{
2239 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2240 char *cmd = (char*)wrqu->data.pointer;
2241 int len = wrqu->data.length;
2242 v_S7_t s7Rssi = 0;
2243 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2244 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2245 VOS_STATUS vosStatus;
2246 int rc;
2247
2248 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2249 (0 == ssidlen) || (ssidlen >= len))
2250 {
2251 /* we are not connected or our SSID is too long
2252 so we cannot report an rssi */
2253 rc = snprintf(cmd, len, "OK");
2254 }
2255 else
2256 {
2257 /* we are connected with a valid SSID
2258 so we can write the SSID into the return buffer
2259 (note that it is not NUL-terminated) */
2260 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2261
2262 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2263
2264 if (VOS_STATUS_SUCCESS == vosStatus)
2265 {
2266 /* append the rssi to the ssid in the format required by
2267 the WiFI Framework */
2268 rc = snprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
2269 }
2270 else
2271 {
2272 rc = -1;
2273 }
2274 }
2275
2276 /* verify that we wrote a valid response */
2277 if ((rc < 0) || (rc >= len))
2278 {
2279 // encoding or length error?
2280 hddLog(VOS_TRACE_LEVEL_ERROR,
2281 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002282 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 return -EIO;
2284 }
2285
2286 /* a value is being successfully returned */
2287 return 0;
2288}
2289
2290/*
2291 * Support for SoftAP channel range private command
2292 */
2293static int iw_softap_set_channel_range( struct net_device *dev,
2294 int startChannel,
2295 int endChannel,
2296 int band)
2297{
Jeff Johnson43971f52012-07-17 12:26:56 -07002298 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 int ret = 0;
2300 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2301 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002302 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2303
Jeff Johnson295189b2012-06-20 16:38:30 -07002304
2305 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2306 if (VOS_STATUS_SUCCESS != status)
2307 {
2308 ret = -EINVAL;
2309 }
Yathish9f22e662012-12-10 14:21:35 -08002310 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 return ret;
2312}
2313
2314VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2315{
2316 struct statsContext context;
2317 eHalStatus status;
2318 hdd_context_t *pHddCtx;
2319
2320 if (NULL == pAdapter)
2321 {
2322 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2323 return VOS_STATUS_E_FAULT;
2324 }
2325
2326 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2328 init_completion(&context.completion);
2329
2330 context.pAdapter = pAdapter;
2331 context.magic = POWER_CONTEXT_MAGIC;
2332
2333 if (DRIVER_POWER_MODE_ACTIVE == mode)
2334 {
2335 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2336 "Full Power", __func__);
2337 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2338 iw_power_callback_fn, &context,
2339 eSME_FULL_PWR_NEEDED_BY_HDD);
2340 // Enter Full power command received from GUI this means we are disconnected
2341 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2342 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2343 if (eHAL_STATUS_PMC_PENDING == status)
2344 {
2345 int lrc = wait_for_completion_interruptible_timeout(
2346 &context.completion,
2347 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2348 context.magic = 0;
2349 if (lrc <= 0)
2350 {
2351 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002352 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 /* there is a race condition such that the callback
2354 function could be executing at the same time we are. of
2355 primary concern is if the callback function had already
2356 verified the "magic" but hasn't yet set the completion
2357 variable. Since the completion variable is on our
2358 stack, we'll delay just a bit to make sure the data is
2359 still valid if that is the case */
2360 msleep(50);
2361 /* we'll now returned a cached value below */
2362 }
2363 }
2364 }
2365 else if (DRIVER_POWER_MODE_AUTO == mode)
2366 {
2367 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2368 {
2369 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2370 __func__);
2371 // Enter BMPS command received from GUI this means DHCP is completed
2372 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2373 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2374 FALSE);
2375 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2376 iw_power_callback_fn, &context);
2377 if (eHAL_STATUS_PMC_PENDING == status)
2378 {
2379 int lrc = wait_for_completion_interruptible_timeout(
2380 &context.completion,
2381 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2382 context.magic = 0;
2383 if (lrc <= 0)
2384 {
2385 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting BMPS ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002386 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 /* there is a race condition such that the callback
2388 function could be executing at the same time we are. of
2389 primary concern is if the callback function had already
2390 verified the "magic" but hasn't yet set the completion
2391 variable. Since the completion variable is on our
2392 stack, we'll delay just a bit to make sure the data is
2393 still valid if that is the case */
2394 msleep(50);
2395 /* we'll now returned a cached value below */
2396 }
2397 }
2398 }
2399 else
2400 {
2401 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2402 "enabled in the cfg");
2403 }
2404 }
2405 return VOS_STATUS_SUCCESS;
2406}
2407
2408VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2409 hdd_adapter_t *pAdapter)
2410{
2411 VOS_STATUS vos_Status;
2412
2413 if ((NULL == pAdapter) || (NULL == pHddCtx))
2414 {
2415 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2416 return VOS_STATUS_E_FAULT;
2417 }
2418
2419 /**Exit from Deep sleep or standby if we get the driver
2420 START cmd from android GUI
2421 */
2422 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2423 {
2424 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2425 "from Stand by",__func__);
2426 vos_Status = hdd_exit_standby(pHddCtx);
2427 }
2428 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2429 {
2430 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2431 "from deep sleep",__func__);
2432 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2433 }
2434 else
2435 {
2436 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2437 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2438 vos_Status = VOS_STATUS_SUCCESS;
2439 }
2440
2441 return vos_Status;
2442}
2443
2444VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2445{
2446 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2447
2448 if (NULL == pHddCtx)
2449 {
2450 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "HDD context NULL");
2451 return VOS_STATUS_E_FAULT;
2452 }
2453
2454 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2455 {
2456 //Execute standby procedure.
2457 //Executing standby procedure will cause the STA to
2458 //disassociate first and then the chip will be put into standby.
2459 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2460 vos_Status = hdd_enter_standby(pHddCtx);
2461 }
2462 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2463 pHddCtx->cfg_ini->nEnableDriverStop)
2464 {
2465 //Execute deep sleep procedure
2466 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
2467 "deep sleep mode\n");
2468 //Deep sleep not supported
2469 vos_Status = hdd_enter_standby(pHddCtx);
2470 }
2471 else
2472 {
2473 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2474 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2475 vos_Status = VOS_STATUS_SUCCESS;
2476 }
2477
2478 return vos_Status;
2479}
2480
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002481
2482void* wlan_hdd_change_country_code_callback(void *pAdapter)
2483{
2484
2485 hdd_adapter_t *call_back_pAdapter = pAdapter;
2486
2487 complete(&call_back_pAdapter->change_country_code);
2488
2489 return NULL;
2490}
2491
Jeff Johnson295189b2012-06-20 16:38:30 -07002492static int iw_set_priv(struct net_device *dev,
2493 struct iw_request_info *info,
2494 union iwreq_data *wrqu, char *extra)
2495{
2496 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2497 char *cmd = (char*)wrqu->data.pointer;
2498 int cmd_len = wrqu->data.length;
2499 int ret = 0;
2500 int status = 0;
2501 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2502
2503 ENTER();
2504
2505 if (ioctl_debug)
2506 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002507 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 }
2509
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002510 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2511 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002512
2513 if (pHddCtx->isLogpInProgress) {
2514 if (ioctl_debug)
2515 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002516 pr_info("%s: RESTART in progress\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 }
2518
2519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2520 "%s:LOGP in Progress. Ignore!!!",__func__);
2521 return status;
2522 }
2523
2524 if(strncmp(cmd, "CSCAN",5) == 0 )
2525 {
2526 status = iw_set_cscan(dev, info, wrqu, extra);
2527 }
2528 else if( strcasecmp(cmd, "start") == 0 ) {
2529
2530 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command\n");
2531 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
2532 status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
2533
2534 if(status == VOS_STATUS_SUCCESS)
2535 {
2536 union iwreq_data wrqu;
2537 char buf[10];
2538
2539 memset(&wrqu, 0, sizeof(wrqu));
2540 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
2541 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2542 }
2543 else
2544 {
2545 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: START CMD Status %d", __func__, status);
2546 }
2547 goto done;
2548 }
2549 else if( strcasecmp(cmd, "stop") == 0 )
2550 {
2551 union iwreq_data wrqu;
2552 char buf[10];
2553
2554 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command\n");
2555
2556 wlan_hdd_enter_lowpower(pHddCtx);
2557 memset(&wrqu, 0, sizeof(wrqu));
2558 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
2559 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2560 status = VOS_STATUS_SUCCESS;
2561 goto done;
2562 }
2563 else if (strcasecmp(cmd, "macaddr") == 0)
2564 {
2565 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
2566 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
2567 }
2568 else if (strcasecmp(cmd, "scan-active") == 0)
2569 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002570 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 ret = snprintf(cmd, cmd_len, "OK");
2572 }
2573 else if (strcasecmp(cmd, "scan-passive") == 0)
2574 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002575 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 ret = snprintf(cmd, cmd_len, "OK");
2577 }
2578 else if( strcasecmp(cmd, "scan-mode") == 0 )
2579 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002580 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 }
2582 else if( strcasecmp(cmd, "linkspeed") == 0 )
2583 {
2584 status = iw_get_linkspeed(dev, info, wrqu, extra);
2585 }
2586 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
2587 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002588 long lrc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002589
2590 country_code = cmd + 8;
2591
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002592 init_completion(&pAdapter->change_country_code);
2593
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002595 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 country_code,
2597 pAdapter,
2598 pHddCtx->pvosContext);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002599
2600 /* Wait for completion */
2601 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
2602 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2603
2604 if (lrc <= 0)
2605 {
2606 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002607 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002608 }
2609
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 if( 0 != status )
2611 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002612 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2613 "%s: SME Change Country code fail \n",__func__);
2614 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 }
2616 }
2617 else if( strncasecmp(cmd, "rssi", 4) == 0 )
2618 {
2619 status = iw_get_rssi(dev, info, wrqu, extra);
2620 }
2621 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
2622 int mode;
2623 char *ptr = (char*)(cmd + 9);
2624
2625 sscanf(ptr,"%d",&mode);
2626 wlan_hdd_enter_bmps(pAdapter, mode);
2627 /*TODO:Set the power mode*/
2628 }
2629 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
2630 v_U32_t pmc_state;
2631 v_U16_t value;
2632
2633 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
2634 if(pmc_state == BMPS) {
2635 value = DRIVER_POWER_MODE_AUTO;
2636 }
2637 else {
2638 value = DRIVER_POWER_MODE_ACTIVE;
2639 }
2640 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
2641 }
2642 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
2643 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode\n");
2644 /*TODO: set the btcoexmode*/
2645 }
2646 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
2647
2648 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status\n");
2649 /*TODO: Return the btcoex status*/
2650 }
2651 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
2652
2653 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command\n");
2654
2655 /*TODO: Enable Rx data Filter*/
2656 }
2657 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
2658
2659 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command\n");
2660
2661 /*TODO: Disable Rx data Filter*/
2662 }
2663 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
2664
2665 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command\n");
2666 /*TODO: rxfilter-statistics*/
2667 }
2668 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
2669
2670 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add\n");
2671 /*TODO: rxfilter-add*/
2672 }
2673 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
2674
2675 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove\n");
2676 /*TODO: rxfilter-remove*/
2677 }
2678#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07002679 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
2680 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
2681 /*TODO: support pnosetup*/
2682 }
2683 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
2684 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
2685 /*TODO: support pnoforce*/
2686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 else if( strncasecmp(cmd, "pno",3) == 0 ) {
2688
2689 hddLog( VOS_TRACE_LEVEL_INFO, "pno\n");
2690 status = iw_set_pno(dev, info, wrqu, extra, 3);
2691 return status;
2692 }
2693 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
2694
2695 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter\n");
2696 status = iw_set_rssi_filter(dev, info, wrqu, extra, 10);
2697 return status;
2698 }
2699#endif /*FEATURE_WLAN_SCAN_PNO*/
2700 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
2701 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams\n");
2702 status = iw_set_power_params(dev, info, wrqu, extra, 11);
2703 return status;
2704 }
2705 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
2706 tSirTxPerTrackingParam tTxPerTrackingParam;
2707 char *ptr = (char*)(cmd + 18);
2708 sscanf(ptr,"%hhu %hhu %hhu %lu",&(tTxPerTrackingParam.ucTxPerTrackingEnable), &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
2709 &(tTxPerTrackingParam.ucTxPerTrackingRatio), &(tTxPerTrackingParam.uTxPerTrackingWatermark));
2710
2711 // parameters checking
2712 // period has to be larger than 0
2713 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
2714 {
2715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
2716 return VOS_STATUS_E_FAILURE;
2717 }
2718
2719 // use default value 5 is the input is not reasonable. in unit of 10%
2720 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
2721 {
2722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
2723 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
2724 }
2725
2726 // default is 5
2727 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
2728 {
2729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
2730 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
2731 }
2732
2733 status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam);
2734 if(status != eHAL_STATUS_SUCCESS){
2735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
2736 }
2737 }
2738 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002739 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
2740 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 }
2742done:
2743 /* many of the commands write information back into the command
2744 string using snprintf(). check the return value here in one
2745 place */
2746 if ((ret < 0) || (ret >= cmd_len))
2747 {
2748 /* there was an encoding error or overflow */
2749 status = -EIO;
2750 }
2751
2752 if (ioctl_debug)
2753 {
2754 pr_info("%s: rsp [%s] len [%d] status %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002755 __func__, cmd, wrqu->data.length, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 }
2757 return status;
2758
2759}
2760
2761static int iw_set_nick(struct net_device *dev,
2762 struct iw_request_info *info,
2763 union iwreq_data *wrqu, char *extra)
2764{
2765 ENTER();
2766 return 0;
2767}
2768
2769static int iw_get_nick(struct net_device *dev,
2770 struct iw_request_info *info,
2771 union iwreq_data *wrqu, char *extra)
2772{
2773 ENTER();
2774 return 0;
2775}
2776
2777static struct iw_statistics *get_wireless_stats(struct net_device *dev)
2778{
2779 ENTER();
2780 return NULL;
2781}
2782
2783static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
2784 union iwreq_data *wrqu,char *extra)
2785
2786{
2787 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2788 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2789 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2790 struct iw_point *encoderq = &(wrqu->encoding);
2791 v_U32_t keyId;
2792 v_U8_t key_length;
2793 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
2794 v_BOOL_t fKeyPresent = 0;
2795 int i;
2796 eHalStatus status = eHAL_STATUS_SUCCESS;
2797
2798
2799 ENTER();
2800
2801 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2802 {
2803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2804 "%s:LOGP in Progress. Ignore!!!",__func__);
2805 return 0;
2806 }
2807
2808
2809 keyId = encoderq->flags & IW_ENCODE_INDEX;
2810
2811 if(keyId)
2812 {
2813 if(keyId > MAX_WEP_KEYS)
2814 {
2815 return -EINVAL;
2816 }
2817
2818 fKeyPresent = 1;
2819 keyId--;
2820 }
2821 else
2822 {
2823 fKeyPresent = 0;
2824 }
2825
2826
2827 if(wrqu->data.flags & IW_ENCODE_DISABLED)
2828 {
2829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****\n");
2830 if(!fKeyPresent) {
2831
2832 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
2833
2834 if(pWextState->roamProfile.Keys.KeyMaterial[i])
2835 pWextState->roamProfile.Keys.KeyLength[i] = 0;
2836 }
2837 }
2838 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
2839 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
2840 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2841 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2842
2843 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2844 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2845
2846 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
2847 {
2848 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2849 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07002850 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
2852 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2853 }
2854
2855 return status;
2856
2857 }
2858
2859 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
2860 {
2861 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
2862
2863 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
2864
2865 }
2866
2867
2868 if(wrqu->data.length > 0)
2869 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002870 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002871
2872 key_length = wrqu->data.length;
2873
2874 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
2875
2876 if(5 == key_length)
2877 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002878 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002879
2880 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2881 {
2882 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
2883 }
2884 else
2885 {
2886 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2887 }
2888 }
2889 else if(13 == key_length)
2890 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002891 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002892
2893 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2894 {
2895 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
2896 }
2897 else
2898 {
2899 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2900 }
2901 }
2902 else
2903 {
2904 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002905 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 return -EINVAL;
2907 }
2908
2909 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
2910 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
2911 pWextState->roamProfile.EncryptionType.numEntries = 1;
2912 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
2913 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
2914 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
2915
2916 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
2917 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
2918 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
2919 {
2920
2921 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
2922
2923 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
2924 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
2925
2926 return status;
2927 }
2928 }
2929
2930 return 0;
2931}
2932
2933static int iw_get_encodeext(struct net_device *dev,
2934 struct iw_request_info *info,
2935 struct iw_point *dwrq,
2936 char *extra)
2937{
2938 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2939 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2940 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2941 int keyId;
2942 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
2943 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2944 int i;
2945
2946 ENTER();
2947
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002948 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2949 {
2950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2951 "%s:LOGP in Progress. Ignore!!!", __func__);
2952 return -EBUSY;
2953 }
2954
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 keyId = pRoamProfile->Keys.defaultIndex;
2956
2957 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2958 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002959 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 return -EINVAL;
2961 }
2962
2963 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2964 {
2965 dwrq->flags |= IW_ENCODE_ENABLED;
2966 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2967 palCopyMemory(dev,extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2968 }
2969 else
2970 {
2971 dwrq->flags |= IW_ENCODE_DISABLED;
2972 }
2973
2974 for(i=0; i < MAX_WEP_KEYS; i++)
2975 {
2976 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2977 {
2978 continue;
2979 }
2980 else
2981 {
2982 break;
2983 }
2984 }
2985
2986 if(MAX_WEP_KEYS == i)
2987 {
2988 dwrq->flags |= IW_ENCODE_NOKEY;
2989 }
2990 else
2991 {
2992 dwrq->flags |= IW_ENCODE_ENABLED;
2993 }
2994
2995 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
2996
2997 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
2998 {
2999 dwrq->flags |= IW_ENCODE_DISABLED;
3000 }
3001
3002 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3003
3004 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3005 {
3006 dwrq->flags |= IW_ENCODE_OPEN;
3007 }
3008 else
3009 {
3010 dwrq->flags |= IW_ENCODE_RESTRICTED;
3011 }
3012 EXIT();
3013 return 0;
3014
3015}
3016
3017static int iw_set_encodeext(struct net_device *dev,
3018 struct iw_request_info *info,
3019 union iwreq_data *wrqu, char *extra)
3020{
3021 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3022 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3023 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3024 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3025
3026 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3027 v_U32_t status = 0;
3028
3029 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3030
3031 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3032
3033 int key_index;
3034 struct iw_point *encoding = &wrqu->encoding;
3035 tCsrRoamSetKey setKey;
3036 v_U32_t roamId= 0xFF;
3037 VOS_STATUS vos_status;
3038
3039 ENTER();
3040
3041 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3042 {
3043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3044 "%s:LOGP in Progress. Ignore!!!",__func__);
3045 return 0;
3046 }
3047
3048 key_index = encoding->flags & IW_ENCODE_INDEX;
3049
3050 if(key_index > 0) {
3051
3052 /*Convert from 1-based to 0-based keying*/
3053 key_index--;
3054 }
3055 if(!ext->key_len) {
3056
3057 /*Set the encrytion type to NONE*/
3058 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3059 return status;
3060 }
3061
3062 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3063 (IW_ENCODE_ALG_WEP == ext->alg))
3064 {
3065 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3066
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003067 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s \n"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 return -EINVAL;
3069 }
3070 else {
3071 /*Static wep, update the roam profile with the keys */
3072 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3073 key_index < CSR_MAX_NUM_KEY) {
3074 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3075 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3076
3077 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3078 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3079
3080 }
3081 }
3082 return status;
3083 }
3084
3085 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3086
3087 setKey.keyId = key_index;
3088 setKey.keyLength = ext->key_len;
3089
3090 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3091 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3092 }
3093
3094 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3095 /*Key direction for group is RX only*/
3096 setKey.keyDirection = eSIR_RX_ONLY;
3097 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3098 }
3099 else {
3100
3101 setKey.keyDirection = eSIR_TX_RX;
3102 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3103 }
3104
3105 /*For supplicant pae role is zero*/
3106 setKey.paeRole = 0;
3107
3108 switch(ext->alg)
3109 {
3110 case IW_ENCODE_ALG_NONE:
3111 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3112 break;
3113
3114 case IW_ENCODE_ALG_WEP:
3115 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3116 break;
3117
3118 case IW_ENCODE_ALG_TKIP:
3119 {
3120 v_U8_t *pKey = &setKey.Key[0];
3121
3122 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3123
3124 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3125
3126 /*Supplicant sends the 32bytes key in this order
3127
3128 |--------------|----------|----------|
3129 | Tk1 |TX-MIC | RX Mic |
3130 |--------------|----------|----------|
3131 <---16bytes---><--8bytes--><--8bytes-->
3132
3133 */
3134 /*Sme expects the 32 bytes key to be in the below order
3135
3136 |--------------|----------|----------|
3137 | Tk1 |RX-MIC | TX Mic |
3138 |--------------|----------|----------|
3139 <---16bytes---><--8bytes--><--8bytes-->
3140 */
3141 /* Copy the Temporal Key 1 (TK1) */
3142 vos_mem_copy(pKey,ext->key,16);
3143
3144 /*Copy the rx mic first*/
3145 vos_mem_copy(&pKey[16],&ext->key[24],8);
3146
3147 /*Copy the tx mic */
3148 vos_mem_copy(&pKey[24],&ext->key[16],8);
3149
3150 }
3151 break;
3152
3153 case IW_ENCODE_ALG_CCMP:
3154 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3155 break;
3156
3157#ifdef FEATURE_WLAN_CCX
3158#define IW_ENCODE_ALG_KRK 6
3159 case IW_ENCODE_ALG_KRK:
3160 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3161 break;
3162#endif /* FEATURE_WLAN_CCX */
3163
3164 default:
3165 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3166 break;
3167 }
3168
3169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003170 ("%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 -07003171
3172#ifdef WLAN_FEATURE_VOWIFI_11R
3173/* The supplicant may attempt to set the PTK once pre-authentication is done.
3174 Save the key in the UMAC and include it in the ADD BSS request */
3175 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303176 if( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_WAIT )
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303178 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 }
3180#endif /* WLAN_FEATURE_VOWIFI_11R */
3181
3182 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3183
3184 vos_status = wlan_hdd_check_ula_done(pAdapter);
3185 if ( vos_status != VOS_STATUS_SUCCESS )
3186 {
3187 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3188 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3189 __LINE__, vos_status );
3190
3191 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3192 }
3193
3194 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3195
3196 if ( halStatus != eHAL_STATUS_SUCCESS )
3197 {
3198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3199 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3200 __LINE__, halStatus );
3201
3202 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3203 }
3204
3205 return halStatus;
3206}
3207
3208static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3209 union iwreq_data *wrqu, char *extra)
3210{
3211 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3212 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3213
3214 ENTER();
3215
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003216 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3217 {
3218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3219 "%s:LOGP in Progress. Ignore!!!", __func__);
3220 return -EBUSY;
3221 }
3222
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3224 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3225
3226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%ld!!\n"),wrqu->retry.value);
3227
3228 return -EINVAL;
3229 }
3230
3231 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3232
3233 if((wrqu->retry.flags & IW_RETRY_LONG))
3234 {
3235 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3236 {
3237 return -EIO;
3238 }
3239 }
3240 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3241 {
3242 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3243 {
3244 return -EIO;
3245 }
3246 }
3247 }
3248 else
3249 {
3250 return -EOPNOTSUPP;
3251 }
3252
3253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%ld!!\n"),wrqu->retry.value);
3254
3255 EXIT();
3256
3257 return 0;
3258
3259}
3260
3261static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3262 union iwreq_data *wrqu, char *extra)
3263{
3264 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3265 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3266 v_U32_t retry = 0;
3267
3268 ENTER();
3269
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003270 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3271 {
3272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3273 "%s:LOGP in Progress. Ignore!!!", __func__);
3274 return -EBUSY;
3275 }
3276
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 if((wrqu->retry.flags & IW_RETRY_LONG))
3278 {
3279 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3280
3281 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3282 {
3283 return -EIO;
3284 }
3285
3286 wrqu->retry.value = retry;
3287 }
3288 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3289 {
3290 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3291
3292 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3293 {
3294 return -EIO;
3295 }
3296
3297 wrqu->retry.value = retry;
3298 }
3299 else {
3300 return -EOPNOTSUPP;
3301 }
3302
3303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%ld!!\n"),retry);
3304
3305 EXIT();
3306
3307 return 0;
3308}
3309
3310static int iw_set_mlme(struct net_device *dev,
3311 struct iw_request_info *info,
3312 union iwreq_data *wrqu,
3313 char *extra)
3314{
3315 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3316 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3317 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3318 eHalStatus status = eHAL_STATUS_SUCCESS;
3319
3320 ENTER();
3321
3322 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3323 {
3324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3325 "%s:LOGP in Progress. Ignore!!!",__func__);
3326 return 0;
3327 }
3328
3329 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3330 switch (mlme->cmd) {
3331 case IW_MLME_DISASSOC:
3332 case IW_MLME_DEAUTH:
3333
3334 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3335 {
3336 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3337
3338 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3339 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3340
3341 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3342 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3343
Jeff Johnson43971f52012-07-17 12:26:56 -07003344 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3346 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3347 else
3348 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003349 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003350
3351 /* Resetting authKeyMgmt */
3352 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3353
3354 netif_tx_disable(dev);
3355 netif_carrier_off(dev);
3356
3357 }
3358 else
3359 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003360 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 -07003361 }
3362 break;
3363 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003364 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 return -EINVAL;
3366 }//end of switch
3367
3368 EXIT();
3369
3370 return status;
3371
3372}
3373
3374/* set param sub-ioctls */
3375static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3376 union iwreq_data *wrqu, char *extra)
3377{
3378 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3379 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3380 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3381 int *value = (int *)extra;
3382 int sub_cmd = value[0];
3383 int set_value = value[1];
3384 int ret = 0; /* success */
3385 int enable_pbm, enable_mp;
3386#ifdef CONFIG_HAS_EARLYSUSPEND
3387 v_U8_t nEnableSuspendOld;
3388#endif
3389 INIT_COMPLETION(pWextState->completion_var);
3390
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003391 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3392 {
3393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3394 "%s:LOGP in Progress. Ignore!!!", __func__);
3395 return -EBUSY;
3396 }
3397
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 switch(sub_cmd)
3399 {
3400 case WE_SET_11D_STATE:
3401 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003402 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3404
3405 sme_GetConfigParam(hHal,&smeConfig);
3406 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3407
3408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),smeConfig.csrConfig.Is11dSupportEnabled);
3409
3410 sme_UpdateConfig(hHal,&smeConfig);
3411 }
3412 else {
3413 return -EINVAL;
3414 }
3415 break;
3416 }
3417
3418 case WE_WOWL:
3419 {
3420 switch (set_value)
3421 {
3422 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003423 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 break;
3425 case 0x01:
3426 case 0x02:
3427 case 0x03:
3428 enable_mp = (set_value & 0x01) ? 1 : 0;
3429 enable_pbm = (set_value & 0x02) ? 1 : 0;
3430 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s\n",
3431 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3432 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3433 break;
3434 default:
3435 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL\n", set_value);
3436 ret = -EINVAL;
3437 break;
3438 }
3439
3440 break;
3441 }
3442 case WE_SET_POWER:
3443 {
3444 switch (set_value)
3445 {
3446 case 0: //Full Power
3447 {
3448 struct statsContext context;
3449 eHalStatus status;
3450
3451 init_completion(&context.completion);
3452
3453 context.pAdapter = pAdapter;
3454 context.magic = POWER_CONTEXT_MAGIC;
3455
3456 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3457 iw_power_callback_fn, &context,
3458 eSME_FULL_PWR_NEEDED_BY_HDD);
3459 if(eHAL_STATUS_PMC_PENDING == status)
3460 {
3461 int lrc = wait_for_completion_interruptible_timeout(
3462 &context.completion,
3463 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3464 context.magic = 0;
3465 if (lrc <= 0)
3466 {
3467 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3468 "requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003469 __func__, (0 == lrc) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 "timeout" : "interrupt");
3471 /* there is a race condition such that the callback
3472 function could be executing at the same time we are. of
3473 primary concern is if the callback function had already
3474 verified the "magic" but hasn't yet set the completion
3475 variable. Since the completion variable is on our
3476 stack, we'll delay just a bit to make sure the data is
3477 still valid if that is the case */
3478 msleep(50);
3479 /* we'll now returned a cached value below */
3480 }
3481 }
3482 hddLog(LOGE, "iwpriv Full Power completed\n");
3483 break;
3484 }
3485 case 1: //Enable BMPS
3486 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3487 break;
3488 case 2: //Disable BMPS
3489 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3490 break;
3491 case 3: //Request Bmps
3492 {
3493 struct statsContext context;
3494 eHalStatus status;
3495
3496 init_completion(&context.completion);
3497
3498 context.pAdapter = pAdapter;
3499 context.magic = POWER_CONTEXT_MAGIC;
3500
3501 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3502 iw_power_callback_fn, &context);
3503 if(eHAL_STATUS_PMC_PENDING == status)
3504 {
3505 int lrc = wait_for_completion_interruptible_timeout(
3506 &context.completion,
3507 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3508 context.magic = 0;
3509 if (lrc <= 0)
3510 {
3511 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3512 "requesting BMPS",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003513 __func__, (0 == lrc) ? "timeout" :
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 "interrupt");
3515 /* there is a race condition such that the callback
3516 function could be executing at the same time we are. of
3517 primary concern is if the callback function had already
3518 verified the "magic" but hasn't yet set the completion
3519 variable. Since the completion variable is on our
3520 stack, we'll delay just a bit to make sure the data is
3521 still valid if that is the case */
3522 msleep(50);
3523 /* we'll now returned a cached value below */
3524 }
3525 }
3526 hddLog(LOGE, "iwpriv Request BMPS completed\n");
3527 break;
3528 }
3529 case 4: //Enable IMPS
3530 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3531 break;
3532 case 5: //Disable IMPS
3533 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3534 break;
3535 case 6: //Enable Standby
3536 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3537 break;
3538 case 7: //Disable Standby
3539 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3540 break;
3541 case 8: //Request Standby
3542#ifdef CONFIG_HAS_EARLYSUSPEND
3543#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
3544 (void)hdd_enter_standby(pAdapter->pHddCtx);
3545#endif
3546#endif
3547 break;
3548 case 9: //Start Auto Bmps Timer
3549 sme_StartAutoBmpsTimer(hHal);
3550 break;
3551 case 10://Stop Auto BMPS Timer
3552 sme_StopAutoBmpsTimer(hHal);
3553 break;
3554#ifdef CONFIG_HAS_EARLYSUSPEND
3555 case 11://suspend to standby
3556#ifdef CONFIG_HAS_EARLYSUSPEND
3557 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3558 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
3559#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
3560 hdd_suspend_wlan(NULL);
3561#endif
3562 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3563#endif
3564 break;
3565 case 12://suspend to deep sleep
3566#ifdef CONFIG_HAS_EARLYSUSPEND
3567 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3568 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
3569#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
3570 hdd_suspend_wlan(NULL);
3571#endif
3572 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3573#endif
3574 break;
3575 case 13://resume from suspend
3576#ifdef CONFIG_HAS_EARLYSUSPEND
3577#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
3578 hdd_resume_wlan(NULL);
3579#endif
3580#endif
3581 break;
3582#endif
3583 case 14://reset wlan (power down/power up)
3584 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
3585 break;
3586 default:
3587 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL\n", set_value);
3588 ret = -EINVAL;
3589 break;
3590 }
3591 break;
3592 }
3593
3594 case WE_SET_MAX_ASSOC:
3595 {
3596 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
3597 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
3598 {
3599 ret = -EINVAL;
3600 }
3601 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
3602 set_value, NULL, eANI_BOOLEAN_FALSE)
3603 != eHAL_STATUS_SUCCESS )
3604 {
3605 ret = -EIO;
3606 }
3607 break;
3608 }
3609
3610 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
3611 {
3612 if( 0 == set_value )
3613 {
3614 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
3615 }
3616 else if ( 1 == set_value )
3617 {
3618 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
3619 }
3620 else
3621 {
3622 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL\n", set_value);
3623 ret = -EINVAL;
3624 }
3625 break;
3626 }
3627
3628 case WE_SET_DATA_INACTIVITY_TO:
3629 {
3630 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
3631 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
3632 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
3633 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
3634 set_value,
3635 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
3636 {
3637 hddLog(LOGE,"Failure: Could not pass on "
3638 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
3639 "to CCM\n");
3640 ret = -EINVAL;
3641 }
3642 break;
3643 }
3644 case WE_SET_MAX_TX_POWER:
3645 {
3646 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3647 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3648
3649 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
3650 __func__, set_value);
3651 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
3652 eHAL_STATUS_SUCCESS )
3653 {
3654 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
3655 __func__);
3656 return -EIO;
3657 }
3658
3659 break;
3660 }
3661 case WE_SET_HIGHER_DTIM_TRANSITION:
3662 {
3663 if(!((set_value == eANI_BOOLEAN_FALSE) ||
3664 (set_value == eANI_BOOLEAN_TRUE)))
3665 {
3666 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
3667 ret = -EINVAL;
3668 }
3669 else
3670 {
3671 if(pAdapter->higherDtimTransition != set_value)
3672 {
3673 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003674 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 }
3676 }
3677
3678 break;
3679 }
3680
3681 case WE_SET_TM_LEVEL:
3682 {
3683 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
3684 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
3685 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
3686
3687 break;
3688 }
3689
3690 default:
3691 {
3692 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d \n",
3693 sub_cmd, set_value);
3694 break;
3695 }
3696 }
3697
3698 return ret;
3699}
3700
3701/* set param sub-ioctls */
3702static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
3703 union iwreq_data *wrqu, char *extra)
3704{
3705 VOS_STATUS vstatus;
3706 int sub_cmd = wrqu->data.flags;
3707 int ret = 0; /* success */
3708 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3709 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3710#ifdef WLAN_FEATURE_VOWIFI
3711 hdd_config_t *pConfig = pHddCtx->cfg_ini;
3712#endif /* WLAN_FEATURE_VOWIFI */
3713
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received length %d", __func__, wrqu->data.length);
3715 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 -07003716
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003717 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3718 {
3719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3720 "%s:LOGP in Progress. Ignore!!!", __func__);
3721 return -EBUSY;
3722 }
3723
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 switch(sub_cmd)
3725 {
3726 case WE_WOWL_ADD_PTRN:
3727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003728 hdd_add_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 break;
3730 case WE_WOWL_DEL_PTRN:
3731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003732 hdd_del_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 break;
3734#if defined WLAN_FEATURE_VOWIFI
3735 case WE_NEIGHBOR_REPORT_REQUEST:
3736 {
3737 tRrmNeighborReq neighborReq;
3738 tRrmNeighborRspCallbackInfo callbackInfo;
3739
3740 if (pConfig->fRrmEnable)
3741 {
3742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request\n");
3743 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
3744 if( !neighborReq.no_ssid )
3745 {
3746 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
3747 vos_mem_copy( neighborReq.ssid.ssId, wrqu->data.pointer, neighborReq.ssid.length );
3748 }
3749
3750 callbackInfo.neighborRspCallback = NULL;
3751 callbackInfo.neighborRspCallbackContext = NULL;
3752 callbackInfo.timeout = 5000; //5 seconds
3753 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
3754 }
3755 else
3756 {
3757 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled\n", __func__);
3758 ret = -EINVAL;
3759 }
3760 }
3761 break;
3762#endif
3763#ifdef WLAN_FEATURE_P2P
3764 case WE_SET_AP_WPS_IE:
3765 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
3766#ifdef WLAN_FEATURE_P2P
3767 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), wrqu->data.pointer, wrqu->data.length );
3768#endif // WLAN_FEATURE_P2P
3769 break;
3770#endif
3771 case WE_SET_CONFIG:
3772 vstatus = hdd_execute_config_command(pHddCtx, wrqu->data.pointer);
3773 if (VOS_STATUS_SUCCESS != vstatus)
3774 {
3775 ret = -EINVAL;
3776 }
3777 break;
3778 default:
3779 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003780 hddLog(LOGE, "%s: Invalid sub command %d\n",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 ret = -EINVAL;
3782 break;
3783 }
3784 }
3785 return ret;
3786}
3787
3788/* get param sub-ioctls */
3789static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
3790 union iwreq_data *wrqu, char *extra)
3791{
3792 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3793 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3794 int *value = (int *)extra;
3795 int ret = 0; /* success */
3796
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003797 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3798 {
3799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3800 "%s:LOGP in Progress. Ignore!!!", __func__);
3801 return -EBUSY;
3802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003803
3804 switch (value[0])
3805 {
3806 case WE_GET_11D_STATE:
3807 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003808 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003809
3810 sme_GetConfigParam(hHal,&smeConfig);
3811
3812 *value = smeConfig.csrConfig.Is11dSupportEnabled;
3813
3814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),*value);
3815
3816 break;
3817 }
3818
3819 case WE_IBSS_STATUS:
3820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****\n");
3821 break;
3822
3823 case WE_PMC_STATE:
3824 {
3825 *value = pmcGetPmcState(hHal);
3826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%ld!!\n"),*value);
3827 break;
3828 }
3829 case WE_GET_WLAN_DBG:
3830 {
3831 vos_trace_display();
3832 *value = 0;
3833 break;
3834 }
3835 case WE_MODULE_DOWN_IND:
3836 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
3839#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
3842#endif
3843 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
3844
3845 *value = 0;
3846 break;
3847 }
3848 case WE_GET_MAX_ASSOC:
3849 {
3850 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
3851 {
3852 ret = -EIO;
3853 }
3854 break;
3855 }
3856
3857#ifdef FEATURE_WLAN_INTEGRATED_SOC
3858 case WE_GET_WDI_DBG:
3859 {
3860 wpalTraceDisplay();
3861 *value = 0;
3862 break;
3863 }
3864#endif // FEATURE_WLAN_INTEGRATED_SOC
3865
3866 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
3867 {
3868 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
3869 break;
3870 }
3871 case WE_GET_CONCURRENCY_MODE:
3872 {
3873 *value = hdd_get_concurrency_mode ( );
3874
3875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d \n"),*value);
3876 break;
3877 }
3878
3879 default:
3880 {
3881 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
3882 break;
3883 }
3884 }
3885
3886 return ret;
3887}
3888
3889/* set param sub-ioctls */
3890int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
3891 union iwreq_data *wrqu, char *extra)
3892{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003893 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 int *value = (int *)extra;
3895 int sub_cmd = value[0];
3896 int ret = 0;
3897
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003898 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3899 {
3900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3901 "%s:LOGP in Progress. Ignore!!!", __func__);
3902 return -EBUSY;
3903 }
3904
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 switch(sub_cmd)
3906 {
3907 case WE_SET_WLAN_DBG:
3908 {
3909 vos_trace_setValue( value[1], value[2], value[3]);
3910 break;
3911 }
3912#ifdef FEATURE_WLAN_INTEGRATED_SOC
3913 case WE_SET_WDI_DBG:
3914 {
3915 wpalTraceSetLevel( value[1], value[2], value[3]);
3916 break;
3917 }
3918#endif // FEATURE_WLAN_INTEGRATED_SOC
3919 case WE_SET_SAP_CHANNELS:
3920 {
3921 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
3922 break;
3923 }
3924
3925 default:
3926 {
3927 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
3928 break;
3929 }
3930 }
3931 return ret;
3932}
3933
3934static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
3935 union iwreq_data *wrqu, char *extra)
3936{
3937 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3938 int sub_cmd = wrqu->data.flags;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003939
3940 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3941 {
3942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3943 "%s:LOGP in Progress. Ignore!!!", __func__);
3944 return -EBUSY;
3945 }
3946
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 switch(sub_cmd)
3948 {
3949 case WE_WLAN_VERSION:
3950 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003951 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 break;
3953 }
3954
3955 case WE_GET_STATS:
3956 {
3957 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3958 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
3959 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
3960
3961 snprintf(extra, WE_MAX_STR_LEN,
3962 "\nTransmit"
3963 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3964 "\n dropped BK %u, BE %u, VI %u, VO %u"
3965 "\n classified BK %u, BE %u, VI %u, VO %u"
3966 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3967 "\n queued BK %u, BE %u, VI %u, VO %u"
3968 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3969 "\ndequeued %u, depressured %u, completed %u, flushed %u"
3970 "\n fetched BK %u, BE %u, VI %u, VO %u"
3971 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3972 "\n depressured BK %u, BE %u, VI %u, VO %u"
3973 "\n flushed BK %u, BE %u, VI %u, VO %u"
3974 "\n\nReceive"
3975 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3976 "\n\nResetsStats"
3977 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
3978 "\n",
3979 pStats->txXmitCalled,
3980 pStats->txXmitDropped,
3981 pStats->txXmitBackPressured,
3982 pStats->txXmitQueued,
3983
3984 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3985 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3986 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3987 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3988
3989 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3990 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3991 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3992 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3993
3994 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3995 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3996 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3997 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3998
3999 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4000 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4001 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4002 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4003
4004 pStats->txFetched,
4005 pStats->txFetchEmpty,
4006 pStats->txFetchLowResources,
4007 pStats->txFetchDequeueError,
4008
4009 pStats->txFetchDequeued,
4010 pStats->txFetchDePressured,
4011 pStats->txCompleted,
4012 pStats->txFlushed,
4013
4014 pStats->txFetchedAC[WLANTL_AC_BK],
4015 pStats->txFetchedAC[WLANTL_AC_BE],
4016 pStats->txFetchedAC[WLANTL_AC_VI],
4017 pStats->txFetchedAC[WLANTL_AC_VO],
4018
4019 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4020 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4021 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4022 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4023
4024 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4025 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4026 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4027 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4028
4029 pStats->txFlushedAC[WLANTL_AC_BK],
4030 pStats->txFlushedAC[WLANTL_AC_BE],
4031 pStats->txFlushedAC[WLANTL_AC_VI],
4032 pStats->txFlushedAC[WLANTL_AC_VO],
4033
4034 pStats->rxChains,
4035 pStats->rxPackets,
4036 pStats->rxDropped,
4037 pStats->rxDelivered,
4038 pStats->rxRefused,
4039
4040 pResetStats->totalLogpResets,
4041 pResetStats->totalCMD53Failures,
4042 pResetStats->totalMutexReadFailures,
4043 pResetStats->totalMIFErrorFailures,
4044 pResetStats->totalFWHearbeatFailures,
4045 pResetStats->totalUnknownExceptions
4046 );
4047 wrqu->data.length = strlen(extra)+1;
4048 break;
4049 }
4050
4051 case WE_GET_CFG:
4052 {
4053 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4054 wrqu->data.length = strlen(extra)+1;
4055 break;
4056 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004057#ifdef WLAN_FEATURE_11AC
4058 case WE_GET_RSSI:
4059 {
4060 v_S7_t s7Rssi = 0;
4061 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4062 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4063 wrqu->data.length = strlen(extra)+1;
4064 break;
4065 }
4066#endif
4067
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 case WE_GET_WMM_STATUS:
4069 {
4070 snprintf(extra, WE_MAX_STR_LEN,
4071 "\nDir: 0=up, 1=down, 3=both\n"
4072 "|------------------------|\n"
4073 "|AC | ACM |Admitted| Dir |\n"
4074 "|------------------------|\n"
4075 "|VO | %d | %3s | %d |\n"
4076 "|VI | %d | %3s | %d |\n"
4077 "|BE | %d | %3s | %d |\n"
4078 "|BK | %d | %3s | %d |\n"
4079 "|------------------------|\n",
4080 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4081 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4082 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4083 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4084 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4085 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4086 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4087 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4088 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4089 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4090 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4091 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4092
Jeff Johnsone7245742012-09-05 17:12:55 -07004093
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 wrqu->data.length = strlen(extra)+1;
4095 break;
4096 }
4097 case WE_GET_CHANNEL_LIST:
4098 {
4099 VOS_STATUS status;
4100 v_U8_t i, len;
4101 char* buf ;
4102 tChannelListInfo channel_list;
4103
4104 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
4105 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4106 {
4107 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!\n",__func__);
4108 return -EINVAL;
4109 }
4110 buf = extra;
4111
4112 /**
4113 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4114 * needed = 5 * number of channels. Check if sufficient buffer is available and
4115 * then proceed to fill the buffer.
4116 */
4117 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4118 {
4119 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Insufficient Buffer to populate channel list\n",__func__);
4120 return -EINVAL;
4121 }
4122 len = snprintf(buf, 5, "%u ", channel_list.num_channels);
4123 buf += len;
4124 for(i = 0 ; i < channel_list.num_channels; i++)
4125 {
4126 len = snprintf(buf, 5,
4127 "%u ", channel_list.channels[i]);
4128 buf += len;
4129 }
4130 wrqu->data.length = strlen(extra)+1;
4131
4132 break;
4133 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004134#ifdef FEATURE_WLAN_TDLS
4135 case WE_GET_TDLS_PEERS:
4136 {
4137 wrqu->data.length = wlan_hdd_tdls_get_all_peers(extra, WE_MAX_STR_LEN)+1;
4138 break;
4139 }
4140#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 default:
4142 {
4143 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4144 break;
4145 }
4146 }
4147
4148 return 0;
4149}
4150
4151/* action sub-ioctls */
4152static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4153 union iwreq_data *wrqu, char *extra)
4154{
4155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4156 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004157 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004158
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004159 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4160 {
4161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4162 "%s:LOGP in Progress. Ignore!!!", __func__);
4163 return -EBUSY;
4164 }
4165
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 switch (sub_cmd)
4167 {
4168 case WE_CLEAR_STATS:
4169 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4172 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4173 break;
4174 }
4175#ifdef WLAN_SOFTAP_FEATURE
4176 case WE_INIT_AP:
4177 {
4178 pr_info("Init AP trigger\n");
4179 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4180 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4181 break;
4182 }
4183 case WE_STOP_AP:
4184 {
4185 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
4186 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
4187 * this is a dead code and need to find the adpater by name rather than mode */
4188 hdd_adapter_t* pAdapter_to_stop =
4189 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
4190 if( pAdapter_to_stop )
4191 {
4192 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4193
4194 pr_info("Stopping AP mode\n");
4195
4196 /*Make sure that pAdapter cleaned properly*/
4197 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
4198 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
4199 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
4200
4201 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
4202 pAdapter_to_stop->macAddressCurrent.bytes);
4203 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
4204 TRUE);
4205 }
4206 else
4207 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08004208 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 }
4210
4211 break;
4212 }
4213#endif
4214#ifdef WLAN_BTAMP_FEATURE
4215 case WE_ENABLE_AMP:
4216 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 WLANBAP_RegisterWithHCI(pAdapter);
4219 break;
4220 }
4221 case WE_DISABLE_AMP:
4222 {
4223 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4224 VOS_STATUS status;
4225
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004227
4228 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4229 status = WLANBAP_StopAmp();
4230 if(VOS_STATUS_SUCCESS != status )
4231 {
4232 pHddCtx->isAmpAllowed = VOS_TRUE;
4233 hddLog(VOS_TRACE_LEVEL_FATAL,
4234 "%s: Failed to stop AMP", __func__);
4235 }
4236 else
4237 {
4238 //a state m/c implementation in PAL is TBD to avoid this delay
4239 msleep(500);
4240 pHddCtx->isAmpAllowed = VOS_FALSE;
4241 WLANBAP_DeregisterFromHCI();
4242 }
4243
4244 break;
4245 }
4246#endif
4247
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004248 case WE_ENABLE_DXE_STALL_DETECT:
4249 {
4250 sme_transportDebug(VOS_FALSE, VOS_TRUE);
4251 break;
4252 }
4253 case WE_DISPLAY_DXE_SNAP_SHOT:
4254 {
4255 sme_transportDebug(VOS_TRUE, VOS_FALSE);
4256 break;
4257 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07004258 case WE_SET_REASSOC_TRIGGER:
4259 {
4260 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4261 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
4262 v_U32_t roamId = 0;
4263 tCsrRoamModifyProfileFields modProfileFields;
4264 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
4265 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
4266 return 0;
4267 }
4268
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004269
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 default:
4271 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004272 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 break;
4274 }
4275 }
4276
4277 return ret;
4278}
4279
4280int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4281 union iwreq_data *wrqu, char *extra)
4282{
4283 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4284 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4285 int sub_cmd = wrqu->data.flags;
4286 int *value = (int*)wrqu->data.pointer;
4287 int apps_args[MAX_VAR_ARGS] = {0};
4288 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004289 hdd_station_ctx_t *pStaCtx = NULL ;
4290 hdd_ap_ctx_t *pAPCtx = NULL;
4291 int cmd = 0;
4292 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004293
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004294 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004295
4296 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4297 {
4298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4299 "%s:LOGP in Progress. Ignore!!!", __func__);
4300 return -EBUSY;
4301 }
4302
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 if (num_args > MAX_VAR_ARGS)
4304 {
4305 num_args = MAX_VAR_ARGS;
4306 }
4307 vos_mem_copy(apps_args, value, (sizeof(int)) * num_args);
4308
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004309 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
4310 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
4311 {
4312 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
4313 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
4314 {
4315 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4316 staId = pStaCtx->conn_info.staId[0];
4317 }
4318 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
4319 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
4320 {
4321 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4322 staId = pAPCtx->uBCStaId;
4323 }
4324 else
4325 {
4326 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
4327 return 0;
4328 }
4329 }
4330
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 switch (sub_cmd)
4332 {
4333 case WE_LOG_DUMP_CMD:
4334 {
4335 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004336 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 apps_args[3], apps_args[4]);
4338
4339 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
4340 apps_args[3], apps_args[4]);
4341
4342 }
4343 break;
4344
4345#ifdef WLAN_FEATURE_P2P
4346 case WE_P2P_NOA_CMD:
4347 {
4348 p2p_app_setP2pPs_t p2pNoA;
4349
4350 p2pNoA.opp_ps = apps_args[0];
4351 p2pNoA.ctWindow = apps_args[1];
4352 p2pNoA.duration = apps_args[2];
4353 p2pNoA.interval = apps_args[3];
4354 p2pNoA.count = apps_args[4];
4355 p2pNoA.single_noa_duration = apps_args[5];
4356 p2pNoA.psSelection = apps_args[6];
4357
4358 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
4359 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004360 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
4362
4363 hdd_setP2pPs(dev, &p2pNoA);
4364
4365 }
4366 break;
4367#endif
4368
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004369 case WE_MCC_CONFIG_CREDENTIAL :
4370 {
4371 cmd = 287; //Command should be updated if there is any change
4372 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08004373 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004374 {
4375 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
4376 }
4377 else
4378 {
Kumar Anand90ca3dd2013-01-18 15:24:47 -08004379 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160\n");
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004380 return 0;
4381 }
4382 }
4383 break;
4384
4385 case WE_MCC_CONFIG_PARAMS :
4386 {
4387 cmd = 288; //command Should be updated if there is any change
4388 // in the Riva dump command
4389 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
4390 }
4391 break;
4392
Chilam NG571c65a2013-01-19 12:27:36 +05304393#ifdef FEATURE_WLAN_TDLS
4394 case WE_TDLS_CONFIG_PARAMS :
4395 {
4396 tdls_config_params_t tdlsParams;
4397
Chilam Ng01120412013-02-19 18:32:21 -08004398 tdlsParams.tdls = apps_args[0];
4399 tdlsParams.tx_period_t = apps_args[1];
4400 tdlsParams.tx_packet_n = apps_args[2];
4401 tdlsParams.discovery_period_t = apps_args[3];
4402 tdlsParams.discovery_tries_n = apps_args[4];
4403 tdlsParams.idle_timeout_t = apps_args[5];
4404 tdlsParams.idle_packet_n = apps_args[6];
4405 tdlsParams.rssi_hysteresis = apps_args[7];
4406 tdlsParams.rssi_trigger_threshold = apps_args[8];
4407 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05304408
Chilam Ng01120412013-02-19 18:32:21 -08004409 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05304410 }
4411 break;
4412#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 default:
4414 {
4415 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
4416 }
4417 break;
4418 }
4419
4420 return 0;
4421}
4422
4423
4424static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
4425 union iwreq_data *wrqu, char *extra)
4426{
4427 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4428 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4429 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4430 int params[HDD_WLAN_WMM_PARAM_COUNT];
4431 sme_QosWmmTspecInfo tSpec;
4432 v_U32_t handle;
4433
4434 // make sure the application is sufficiently priviledged
4435 // note that the kernel will do this for "set" ioctls, but since
4436 // this ioctl wants to return status to user space it must be
4437 // defined as a "get" ioctl
4438 if (!capable(CAP_NET_ADMIN))
4439 {
4440 return -EPERM;
4441 }
4442
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004443 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4444 {
4445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4446 "%s:LOGP in Progress. Ignore!!!", __func__);
4447 return -EBUSY;
4448 }
4449
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 // we must be associated in order to add a tspec
4451 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4452 {
4453 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4454 return 0;
4455 }
4456
4457 // since we are defined to be a "get" ioctl, and since the number
4458 // of params exceeds the number of params that wireless extensions
4459 // will pass down in the iwreq_data, we must copy the "set" params
4460 // from user space ourselves
4461 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
4462 {
4463 // hmmm, can't get them
4464 return -EIO;
4465 }
4466
4467 // clear the tspec
4468 memset(&tSpec, 0, sizeof(tSpec));
4469
4470 // validate the handle
4471 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4472 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4473 {
4474 // that one is reserved
4475 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4476 return 0;
4477 }
4478
4479 // validate the TID
4480 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
4481 {
4482 // out of range
4483 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4484 return 0;
4485 }
4486 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
4487
4488 // validate the direction
4489 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
4490 {
4491 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
4492 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
4493 break;
4494
4495 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
4496 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
4497 break;
4498
4499 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
4500 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
4501 break;
4502
4503 default:
4504 // unknown
4505 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4506 return 0;
4507 }
4508
4509 // validate the user priority
4510 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
4511 {
4512 // out of range
4513 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4514 return 0;
4515 }
4516 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
4517
4518 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
4519 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
4520 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
4521 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
4522 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
4523 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
4524 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
4525 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
4526 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
4527 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
4528 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
4529 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
4530
4531 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
4532
4533 // validate the ts info ack policy
4534 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
4535 {
4536 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
4537 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
4538 break;
4539
4540 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
4541 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
4542 break;
4543
4544 default:
4545 // unknown
4546 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4547 return 0;
4548 }
4549
4550 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
4551 return 0;
4552}
4553
4554
4555static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
4556 union iwreq_data *wrqu, char *extra)
4557{
4558 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4559 int *params = (int *)extra;
4560 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4561 v_U32_t handle;
4562
4563 // make sure the application is sufficiently priviledged
4564 // note that the kernel will do this for "set" ioctls, but since
4565 // this ioctl wants to return status to user space it must be
4566 // defined as a "get" ioctl
4567 if (!capable(CAP_NET_ADMIN))
4568 {
4569 return -EPERM;
4570 }
4571
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004572 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4573 {
4574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4575 "%s:LOGP in Progress. Ignore!!!", __func__);
4576 return -EBUSY;
4577 }
4578
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 // although we are defined to be a "get" ioctl, the params we require
4580 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
4581 // is no need to copy the params from user space
4582
4583 // validate the handle
4584 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4585 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4586 {
4587 // that one is reserved
4588 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4589 return 0;
4590 }
4591
4592 *pStatus = hdd_wmm_delts(pAdapter, handle);
4593 return 0;
4594}
4595
4596
4597static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
4598 union iwreq_data *wrqu, char *extra)
4599{
4600 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4601 int *params = (int *)extra;
4602 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4603 v_U32_t handle;
4604
4605 // although we are defined to be a "get" ioctl, the params we require
4606 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
4607 // is no need to copy the params from user space
4608
4609 // validate the handle
4610 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4611 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4612 {
4613 // that one is reserved
4614 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4615 return 0;
4616 }
4617
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004618 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4619 {
4620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4621 "%s:LOGP in Progress. Ignore!!!", __func__);
4622 return -EBUSY;
4623 }
4624
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 *pStatus = hdd_wmm_checkts(pAdapter, handle);
4626 return 0;
4627}
4628
4629
4630#ifdef FEATURE_WLAN_WAPI
4631static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
4632 union iwreq_data *wrqu, char *extra)
4633{
4634 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4635 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4636 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4637 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4638
4639 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)wrqu->data.pointer;
4640
4641 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004642 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4643 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4644 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004645
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004646 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4647 {
4648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4649 "%s:LOGP in Progress. Ignore!!!", __func__);
4650 return -EBUSY;
4651 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004652
4653 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004654 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
4656 pRoamProfile->EncryptionType.numEntries = 1;
4657 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4658 pRoamProfile->mcEncryptionType.numEntries = 1;
4659 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4660
4661 pRoamProfile->AuthType.numEntries = 1;
4662 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4663 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4664 }
4665 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004666 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 }
4668 else
4669 return -EINVAL;
4670
4671 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
4672
4673 return 0;
4674}
4675
4676static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
4677 union iwreq_data *wrqu, char *extra)
4678{
4679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4680 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
4681
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004682 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4683 {
4684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4685 "%s:LOGP in Progress. Ignore!!!", __func__);
4686 return -EBUSY;
4687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
4689
4690 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004691 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
4693 return 0;
4694}
4695
4696static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
4697 union iwreq_data *wrqu, char *extra)
4698{
4699 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4700// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
4701 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
4702 int i = 0, j = 0;
4703 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004704 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4705 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4706 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004707
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004708 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4709 {
4710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4711 "%s:LOGP in Progress. Ignore!!!", __func__);
4712 return -EBUSY;
4713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 VOS_ASSERT(pWapiAssocInfo);
4715
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004716 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x\n",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
4717 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 for(i =0 ; i < 16 ; i++)
4719 hddLog(LOG1,"akm suite[%02d]:0x%08lx",i,pWapiAssocInfo->akmSuite[i]);
4720
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004721 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 for(i =0 ; i < 16 ; i++)
4723 hddLog(LOG1, "Unicast suite[%02d]:0x%08lx",i,pWapiAssocInfo->unicastSuite[i]);
4724
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004725 hddLog(LOG1,"%s: Multicast suite:0x%08lx Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
4726 hddLog(LOG1, "%s: BKID Cnt:0x%04x\n",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 for(i = 0 ; i < 16 ; i++) {
4728 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
4729 for(j = 0 ; j < 16 ; j++)
4730 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
4731 }
4732
4733 /* We are not using the entire IE as provided by the supplicant.
4734 * This is being calculated by SME. This is the same as in the
4735 * case of WPA. Only the auth mode information needs to be
4736 * extracted here*/
4737 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004738 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
4740 }
4741
4742 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004743 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
4745 }
4746 return 0;
4747}
4748
4749static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
4750 union iwreq_data *wrqu, char *extra)
4751{
4752 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4753 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4754 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
4755 tANI_U32 roamId = 0xFF;
4756 tANI_U8 *pKeyPtr = NULL;
4757 v_BOOL_t isConnected = TRUE;
4758 tCsrRoamSetKey setKey;
4759 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
4761
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004762 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4763 {
4764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4765 "%s:LOGP in Progress. Ignore!!!", __func__);
4766 return -EBUSY;
4767 }
4768
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004770 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4771 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4772 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004773
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004774 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 -07004775 hddLog(LOG1,"Add Index:0x");
4776 for(i =0 ; i < 12 ; i++)
4777 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
4778
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004779 hddLog(LOG1,"\n%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
4781 for(i =0 ; i < 16 ; i++)
4782 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
4783
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004784 hddLog(LOG1,"\n%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
4786 for(i =0 ; i < 16 ; i++)
4787 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
4788
4789 hddLog(LOG1,"\nWAPI PN NUMBER:0x");
4790 for(i = 0 ; i < 16 ; i++)
4791 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
4792
4793 // Clear the setkey memory
4794 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4795 // Store Key ID
4796 setKey.keyId = (unsigned char)( pWapiKey->keyId );
4797 // SET WAPI Encryption
4798 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
4799 // Key Directionn both TX and RX
4800 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
4801 // the PAE role
4802 setKey.paeRole = 0 ;
4803
4804 switch ( pWapiKey->keyType )
4805 {
4806 case HDD_PAIRWISE_WAPI_KEY:
4807 {
4808 isConnected = hdd_connIsConnected(pHddStaCtx);
4809 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
4810 break;
4811 }
4812 case HDD_GROUP_WAPI_KEY:
4813 {
4814 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
4815 break;
4816 }
4817 default:
4818 {
4819 //Any other option is invalid.
4820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004821 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004822
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004823 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
4825 break; // NEED RETURN FROM HERE ????
4826 }
4827 }
4828
4829 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
4830 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
4831 pKeyPtr = setKey.Key;
4832 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
4833 pKeyPtr += pWapiKey->wpiekLen;
4834 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
4835
4836 // Set the new key with SME.
4837 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4838
4839 if ( isConnected ) {
4840 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
4841 if ( halStatus != eHAL_STATUS_SUCCESS )
4842 {
4843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4844 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
4845
4846 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4847 }
4848 }
4849#if 0 /// NEED TO CHECK ON THIS
4850 else
4851 {
4852 // Store the keys in the adapter to be moved to the profile & passed to
4853 // SME in the ConnectRequest if we are not yet in connected state.
4854 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
4855 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
4856
4857 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
4858 " Saving key [idx= %d] to apply when moving to connected state ",
4859 setKey.keyId );
4860
4861 }
4862#endif
4863 return halStatus;
4864}
4865
4866static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
4867 union iwreq_data *wrqu, char *extra)
4868{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004869 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004870#ifdef WLAN_DEBUG
4871 int i = 0;
4872 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) (wrqu->data.pointer);
4873#endif
4874
4875 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004876 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4877 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4878 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004879
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004880 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08lx\n", __func__,pBkid->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 hddLog(LOG1,"%s: BKID Cnt:0x%04lx",pBkid->BKIDCount);
4882
4883 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004884
4885 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4886 {
4887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4888 "%s:LOGP in Progress. Ignore!!!", __func__);
4889 return -EBUSY;
4890 }
4891
Jeff Johnson295189b2012-06-20 16:38:30 -07004892#ifdef WLAN_DEBUG
4893 for(i =0 ; i < 16 ; i++)
4894 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
4895#endif
4896
4897 return 0;
4898}
4899
4900static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
4901 union iwreq_data *wrqu, char *extra)
4902{
4903 /* Yet to implement this function, 19th April 2010 */
4904 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
4905
4906 return 0;
4907}
4908#endif /* FEATURE_WLAN_WAPI */
4909
4910#ifdef WLAN_FEATURE_VOWIFI_11R
4911//
4912//
4913// Each time the supplicant has the auth_request or reassoc request
4914// IEs ready. This is pushed to the driver. The driver will inturn use
4915// it to send out the auth req and reassoc req for 11r FT Assoc.
4916//
4917static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
4918 union iwreq_data *wrqu, char *extra)
4919{
4920 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4921 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4922 //v_CONTEXT_t pVosContext;
4923
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004924 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4925 {
4926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4927 "%s:LOGP in Progress. Ignore!!!", __func__);
4928 return -EBUSY;
4929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 if (!wrqu->data.length)
4931 {
4932 hddLog(LOGE, FL("%s called with 0 length IEs\n"));
4933 return -EINVAL;
4934 }
4935 if (wrqu->data.pointer == NULL)
4936 {
4937 hddLog(LOGE, FL("%s called with NULL IE\n"));
4938 return -EINVAL;
4939 }
4940
4941 // Added for debug on reception of Re-assoc Req.
4942 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4943 {
4944 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
4945 wrqu->data.length);
4946 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
4947 }
4948
4949#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
4950 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, wrqu->data.length);
4951#endif
4952
4953 // Pass the received FT IEs to SME
4954 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, wrqu->data.pointer,
4955 wrqu->data.length);
4956
4957 return 0;
4958}
4959#endif
4960
Amar Singhalf3a6e762013-02-19 15:06:50 -08004961static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004962 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08004964{
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Amar Singhalf3a6e762013-02-19 15:06:50 -08004966 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)wrqu->data.pointer;
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004968 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08004969 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyyalamudi51d87f72012-09-24 12:05:23 -07004970 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
Amar Singhalf3a6e762013-02-19 15:06:50 -08004971 tpSirRcvFltMcAddrList mc_addr_list_ptr;
4972 int idx;
4973 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07004974
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004975 if (pHddCtx->isLogpInProgress)
4976 {
4977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4978 "%s:LOGP in Progress. Ignore!!!", __func__);
4979 return -EBUSY;
4980 }
4981
Amar Singhalf3a6e762013-02-19 15:06:50 -08004982 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004983
Amar Singhalf3a6e762013-02-19 15:06:50 -08004984 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
4985 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004986 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08004987 hddLog(VOS_TRACE_LEVEL_ERROR,
4988 "%s: vos_mem_alloc failed", __func__);
4989 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07004990 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08004991
4992 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
4993
4994 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
4995 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
4996
4997 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
4998 mc_addr_list_ptr->ulMulticastAddrCnt);
4999
5000 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005001 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005002 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5003 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5004
5005 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5006 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005007 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005008
Amar Singhalf3a6e762013-02-19 15:06:50 -08005009 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5010 vos_mem_free(mc_addr_list_ptr);
5011 if (eHAL_STATUS_SUCCESS != ret_val)
5012 {
5013 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5014 __func__);
5015 return -EINVAL;
5016 }
5017 } else {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005018
Amar Singhalf3a6e762013-02-19 15:06:50 -08005019 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5020 "%s: Set MC BC Filter Config request: %d suspend %d",
5021 __func__, pRequest->mcastBcastFilterSetting,
5022 pHddCtx->hdd_wlan_suspended);
5023
5024 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5025 if (NULL == wlanRxpFilterParam)
5026 {
5027 hddLog(VOS_TRACE_LEVEL_FATAL,
5028 "%s: vos_mem_alloc failed", __func__);
5029 return -EINVAL;
5030 }
5031
5032 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting =
5033 pRequest->mcastBcastFilterSetting;
5034 pHddCtx->dynamic_mcbc_filter.enableCfg = TRUE;
5035
5036 if (pHddCtx->hdd_wlan_suspended)
5037 {
5038 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5039 pRequest->mcastBcastFilterSetting;
5040 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5041
5042 if ((pHddCtx->cfg_ini->fhostArpOffload) &&
5043 (eConnectionState_Associated ==
5044 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
5045 {
5046 vstatus = hdd_conf_hostarpoffload(pAdapter, TRUE);
5047 if (!VOS_IS_STATUS_SUCCESS(vstatus))
5048 {
5049 hddLog(VOS_TRACE_LEVEL_INFO,
5050 "%s:Failed to enable ARPOFFLOAD Feature %d",
5051 __func__, vstatus);
5052 }
5053 else
5054 {
5055 if (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST ==
5056 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting)
5057 {
5058 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5059 HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST;
5060 }
5061 else if (HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST ==
5062 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting)
5063 {
5064 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5065 HDD_MCASTBCASTFILTER_FILTER_NONE;
5066 }
5067 }
5068 }
5069
5070 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5071 __func__,
5072 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting,
5073 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5074 wlanRxpFilterParam->setMcstBcstFilter);
5075
5076 if (eHAL_STATUS_SUCCESS != sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5077 wlanRxpFilterParam))
5078 {
5079 hddLog(VOS_TRACE_LEVEL_ERROR,
5080 "%s: Failure to execute set HW MC/BC Filter request",
5081 __func__);
5082 return -EINVAL;
5083 }
5084
5085 pHddCtx->dynamic_mcbc_filter.mcBcFilterSuspend =
5086 wlanRxpFilterParam->configuredMcstBcstFilterSetting;
5087 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005089
5090 return 0;
5091}
5092
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005093static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
5094 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 union iwreq_data *wrqu, char *extra)
5096{
5097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5098 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5099
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005100 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005101
5102 pHddCtx->dynamic_mcbc_filter.enableCfg = FALSE;
5103
5104 return 0;
5105}
5106
5107static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
5108 union iwreq_data *wrqu, char *extra)
5109{
5110 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5111 tpHostOffloadRequest pRequest = (tpHostOffloadRequest)wrqu->data.pointer;
5112 tSirHostOffloadReq offloadRequest;
5113
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005114 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5115 {
5116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5117 "%s:LOGP in Progress. Ignore!!!", __func__);
5118 return -EBUSY;
5119 }
5120
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 /* Debug display of request components. */
5122 switch (pRequest->offloadType)
5123 {
5124 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005125 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 switch (pRequest->enableOrDisable)
5127 {
5128 case WLAN_OFFLOAD_DISABLE:
5129 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
5130 break;
5131 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
5132 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
5133 case WLAN_OFFLOAD_ENABLE:
5134 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
5135 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
5136 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
5137 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
5138 }
5139 break;
5140
5141 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
5142 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005143 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 switch (pRequest->enableOrDisable)
5145 {
5146 case WLAN_OFFLOAD_DISABLE:
5147 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
5148 break;
5149 case WLAN_OFFLOAD_ENABLE:
5150 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
5151 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
5152 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
5153 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
5154 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
5155 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
5156 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
5157 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
5158 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
5159 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
5160 }
5161 }
5162
5163 /* Execute offload request. The reason that we can copy the request information
5164 from the ioctl structure to the SME structure is that they are laid out
5165 exactly the same. Otherwise, each piece of information would have to be
5166 copied individually. */
5167 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07005168 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
5169 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 {
5171 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request\n",
5172 __func__);
5173 return -EINVAL;
5174 }
5175
5176 return 0;
5177}
5178
5179static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
5180 union iwreq_data *wrqu, char *extra)
5181{
5182 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5183 tpKeepAliveRequest pRequest = (tpKeepAliveRequest)wrqu->data.pointer;
5184 tSirKeepAliveReq keepaliveRequest;
5185
5186 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5187 {
5188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005189 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 return 0;
5191 }
5192
5193 /* Debug display of request components. */
5194 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Keep Alive Request : TimePeriod %d size %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005195 __func__,pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005196
5197 switch (pRequest->packetType)
5198 {
5199 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005200 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 break;
5202
5203 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
5204
5205 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005206 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005207
5208 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
5209 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
5210 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
5211
5212 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
5213 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
5214 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
5215
5216 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
5217 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
5218 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
5219 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
5220 break;
5221
5222 }
5223
5224 /* Execute keep alive request. The reason that we can copy the request information
5225 from the ioctl structure to the SME structure is that they are laid out
5226 exactly the same. Otherwise, each piece of information would have to be
5227 copied individually. */
5228 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
5229
5230 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d\n", keepaliveRequest.timePeriod);
5231
Jeff Johnsone7245742012-09-05 17:12:55 -07005232 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
5233 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 {
5235 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive\n",
5236 __func__);
5237 return -EINVAL;
5238 }
5239
5240 return 0;
5241}
5242
5243#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -07005244int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
5245 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005246{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005247 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5248 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 int i=0;
5250
5251 if (pHddCtx->cfg_ini->disablePacketFilter)
5252 {
5253 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005254 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 return 0;
5256 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005257 if (pHddCtx->isLogpInProgress)
5258 {
5259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5260 "%s:LOGP in Progress. Ignore!!!", __func__);
5261 return -EBUSY;
5262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 /* Debug display of request components. */
5264 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005265 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07005266
5267 switch (pRequest->filterAction)
5268 {
5269 case HDD_RCV_FILTER_SET:
5270 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005271 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005272
5273 packetFilterSetReq.filterId = pRequest->filterId;
5274 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
5275 {
5276 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d\n",
5277 __func__, pRequest->numParams);
5278 return -EINVAL;
5279 }
5280 packetFilterSetReq.numFieldParams = pRequest->numParams;
5281 packetFilterSetReq.coalesceTime = 0;
5282 packetFilterSetReq.filterType = 1;
5283 for (i=0; i < pRequest->numParams; i++)
5284 {
5285 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
5286 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
5287 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
5288 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
5289 packetFilterSetReq.paramsData[i].reserved = 0;
5290
5291 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type\n",
5292 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
5293 packetFilterSetReq.filterType);
5294
5295 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d\n",
5296 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
5297
5298 memcpy(&packetFilterSetReq.paramsData[i].compareData,
5299 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
5300 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
5301 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
5302
5303 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d\n",
5304 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
5305 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
5306 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
5307
5308 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d\n",
5309 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
5310 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
5311 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
5312 }
5313
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005314 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 {
5316 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter\n",
5317 __func__);
5318 return -EINVAL;
5319 }
5320
5321 break;
5322
5323 case HDD_RCV_FILTER_CLEAR:
5324
5325 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005326 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005328 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 {
5330 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter\n",
5331 __func__);
5332 return -EINVAL;
5333 }
5334 break;
5335
5336 default :
5337 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005338 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 return -EINVAL;
5340 }
5341 return 0;
5342}
5343
Jeff Johnsone7245742012-09-05 17:12:55 -07005344void 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 -07005345{
5346 v_U8_t filterAction = 0;
5347 tPacketFilterCfg request = {0};
5348 v_U8_t i = 0;
5349
5350 filterAction = set ? HDD_RCV_FILTER_SET : HDD_RCV_FILTER_CLEAR;
5351
5352 /*set mulitcast addr list*/
5353 for (i = 0; i < pHddCtx->mc_addr_list.mc_cnt; i++)
5354 {
5355 memset(&request, 0, sizeof (tPacketFilterCfg));
5356 request.filterAction = filterAction;
5357 request.filterId = i;
5358 if (set)
5359 {
5360 request.numParams = 1;
5361 request.paramsData[0].protocolLayer = HDD_FILTER_PROTO_TYPE_MAC;
5362 request.paramsData[0].cmpFlag = HDD_FILTER_CMP_TYPE_EQUAL;
5363 request.paramsData[0].dataOffset = WLAN_HDD_80211_FRM_DA_OFFSET;
5364 request.paramsData[0].dataLength = ETH_ALEN;
5365 memcpy(&(request.paramsData[0].compareData[0]),
5366 &(pHddCtx->mc_addr_list.addr[i][0]), ETH_ALEN);
5367 /*set mulitcast filters*/
5368 hddLog(VOS_TRACE_LEVEL_INFO,
5369 "%s: %s multicast filter: addr ="
5370 "%02x:%02x:%02x:%02x:%02x:%02x",
5371 __func__, set ? "setting" : "clearing",
5372 request.paramsData[0].compareData[0],
5373 request.paramsData[0].compareData[1],
5374 request.paramsData[0].compareData[2],
5375 request.paramsData[0].compareData[3],
5376 request.paramsData[0].compareData[4],
5377 request.paramsData[0].compareData[5]);
5378 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005379 wlan_hdd_set_filter(pHddCtx, &request, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 }
5381 pHddCtx->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
5382}
5383
5384static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
5385 union iwreq_data *wrqu, char *extra)
5386{
5387 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5388 tpPacketFilterCfg pRequest = (tpPacketFilterCfg)wrqu->data.pointer;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005389
Jeff Johnsone7245742012-09-05 17:12:55 -07005390 return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005391}
5392#endif
5393static int iw_get_statistics(struct net_device *dev,
5394 struct iw_request_info *info,
5395 union iwreq_data *wrqu, char *extra)
5396{
5397
5398 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
5399 eHalStatus status = eHAL_STATUS_SUCCESS;
5400 hdd_wext_state_t *pWextState;
5401 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5402 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5403 char *p = extra;
5404 int tlen = 0;
5405 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
5406
5407 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
5408 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
5409
5410 ENTER();
5411
5412 if (pHddCtx->isLogpInProgress) {
5413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
5414 return -EINVAL;
5415 }
5416
5417 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
5418
5419 wrqu->txpower.value = 0;
5420 }
5421 else {
5422 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
5423 SME_SUMMARY_STATS |
5424 SME_GLOBAL_CLASSA_STATS |
5425 SME_GLOBAL_CLASSB_STATS |
5426 SME_GLOBAL_CLASSC_STATS |
5427 SME_GLOBAL_CLASSD_STATS |
5428 SME_PER_STA_STATS,
5429 hdd_StatisticsCB, 0, FALSE,
5430 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
5431
5432 if (eHAL_STATUS_SUCCESS != status)
5433 {
5434 hddLog(VOS_TRACE_LEVEL_ERROR,
5435 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005436 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 return -EINVAL;
5438 }
5439
5440 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5441
5442 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
5443 if (!VOS_IS_STATUS_SUCCESS(vos_status))
5444 {
5445 hddLog(VOS_TRACE_LEVEL_ERROR,
5446 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005447 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 /*Remove the SME statistics list by passing NULL in callback argument*/
5449 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
5450 SME_SUMMARY_STATS |
5451 SME_GLOBAL_CLASSA_STATS |
5452 SME_GLOBAL_CLASSB_STATS |
5453 SME_GLOBAL_CLASSC_STATS |
5454 SME_GLOBAL_CLASSD_STATS |
5455 SME_PER_STA_STATS,
5456 NULL, 0, FALSE,
5457 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
5458
5459 return -EINVAL;
5460 }
5461 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
5462 (tANI_U8) sizeof (pStats->retry_cnt),
5463 (char*) &(pStats->retry_cnt[0]),
5464 tlen);
5465
5466 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
5467 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
5468 (char*) &(pStats->multiple_retry_cnt[0]),
5469 tlen);
5470
5471 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
5472 (tANI_U8) sizeof (pStats->tx_frm_cnt),
5473 (char*) &(pStats->tx_frm_cnt[0]),
5474 tlen);
5475
5476 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
5477 (tANI_U8) sizeof (pStats->rx_frm_cnt),
5478 (char*) &(pStats->rx_frm_cnt),
5479 tlen);
5480
5481 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
5482 (tANI_U8) sizeof (pStats->frm_dup_cnt),
5483 (char*) &(pStats->frm_dup_cnt),
5484 tlen);
5485
5486 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
5487 (tANI_U8) sizeof (pStats->fail_cnt),
5488 (char*) &(pStats->fail_cnt[0]),
5489 tlen);
5490
5491 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
5492 (tANI_U8) sizeof (pStats->rts_fail_cnt),
5493 (char*) &(pStats->rts_fail_cnt),
5494 tlen);
5495
5496 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
5497 (tANI_U8) sizeof (pStats->ack_fail_cnt),
5498 (char*) &(pStats->ack_fail_cnt),
5499 tlen);
5500
5501 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
5502 (tANI_U8) sizeof (pStats->rts_succ_cnt),
5503 (char*) &(pStats->rts_succ_cnt),
5504 tlen);
5505
5506 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
5507 (tANI_U8) sizeof (pStats->rx_discard_cnt),
5508 (char*) &(pStats->rx_discard_cnt),
5509 tlen);
5510
5511 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
5512 (tANI_U8) sizeof (pStats->rx_error_cnt),
5513 (char*) &(pStats->rx_error_cnt),
5514 tlen);
5515
Jeff Johnsone7245742012-09-05 17:12:55 -07005516 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
5517 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
5518 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 tlen);
5520
5521 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
5522 (tANI_U8) sizeof (dStats->rx_byte_cnt),
5523 (char*) &(dStats->rx_byte_cnt),
5524 tlen);
5525
5526 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
5527 (tANI_U8) sizeof (dStats->rx_rate),
5528 (char*) &(dStats->rx_rate),
5529 tlen);
5530
5531 /* Transmit rate, in units of 500 kbit/sec */
5532 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
5533 (tANI_U8) sizeof (aStats->tx_rate),
5534 (char*) &(aStats->tx_rate),
5535 tlen);
5536
Jeff Johnsone7245742012-09-05 17:12:55 -07005537 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
5538 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
5539 (char*) &(dStats->rx_uc_byte_cnt[0]),
5540 tlen);
5541 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
5542 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
5543 (char*) &(dStats->rx_mc_byte_cnt),
5544 tlen);
5545 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
5546 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
5547 (char*) &(dStats->rx_bc_byte_cnt),
5548 tlen);
5549 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
5550 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
5551 (char*) &(dStats->tx_uc_byte_cnt[0]),
5552 tlen);
5553 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
5554 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
5555 (char*) &(dStats->tx_mc_byte_cnt),
5556 tlen);
5557 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
5558 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
5559 (char*) &(dStats->tx_bc_byte_cnt),
5560 tlen);
5561
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 wrqu->data.length = tlen;
5563
5564 }
5565
5566 EXIT();
5567
5568 return 0;
5569}
5570
5571
5572#ifdef FEATURE_WLAN_SCAN_PNO
5573
5574/*Max Len for PNO notification*/
5575#define MAX_PNO_NOTIFY_LEN 100
5576void found_pref_network_cb (void *callbackContext,
5577 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
5578{
5579 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
5580 union iwreq_data wrqu;
5581 char buf[MAX_PNO_NOTIFY_LEN+1];
5582
5583 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
5584 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
5585
5586 // create the event
5587 memset(&wrqu, 0, sizeof(wrqu));
5588 memset(buf, 0, sizeof(buf));
5589
5590 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
5591 pPrefNetworkFoundInd->ssId.ssId,
5592 (unsigned int)pPrefNetworkFoundInd->rssi);
5593
5594 wrqu.data.pointer = buf;
5595 wrqu.data.length = strlen(buf);
5596
5597 // send the event
5598
5599 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5600
5601}
5602
5603
5604/*string based input*/
5605VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
5606 union iwreq_data *wrqu, char *extra, int nOffset)
5607{
5608 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07005609 /* pnoRequest is a large struct, so we make it static to avoid stack
5610 overflow. This API is only invoked via ioctl, so it is
5611 serialized by the kernel rtnl_lock and hence does not need to be
5612 reentrant */
5613 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 char *ptr;
5615 v_U8_t i,j, ucParams, ucMode;
5616 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5617
5618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5619 "PNO data len %d data %s",
5620 wrqu->data.length,
5621 wrqu->data.pointer);
5622
5623 if (wrqu->data.length <= nOffset )
5624 {
5625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
5626 return VOS_STATUS_E_FAILURE;
5627 }
5628
5629 pnoRequest.enable = 0;
5630 pnoRequest.ucNetworksCount = 0;
5631 /*-----------------------------------------------------------------------
5632 Input is string based and expected to be like this:
5633
5634 <enabled> <netw_count>
5635 for each network:
5636 <ssid_len> <ssid> <authentication> <encryption>
5637 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
5638 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
5639
5640 e.g:
5641 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
5642
5643 this translates into:
5644 -----------------------------
5645 enable PNO
5646 look for 2 networks:
5647 test - with authentication type 0 and encryption type 0,
5648 that can be found on 3 channels: 1 6 and 11 ,
5649 SSID bcast type is unknown (directed probe will be sent if AP not found)
5650 and must meet -40dBm RSSI
5651
5652 test2 - with auth and enrytption type 4/4
5653 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
5654 bcast type is non-bcast (directed probe will be sent)
5655 and must not meet any RSSI threshold
5656
5657 scan every 5 seconds 2 times, scan every 300 seconds until stopped
5658 -----------------------------------------------------------------------*/
5659 ptr = (char*)(wrqu->data.pointer + nOffset);
5660
5661 sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset);
5662
5663 if ( 0 == pnoRequest.enable )
5664 {
5665 /*Disable PNO*/
5666 memset(&pnoRequest, 0, sizeof(pnoRequest));
5667 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
5668 pAdapter->sessionId,
5669 found_pref_network_cb, pAdapter);
5670 return VOS_STATUS_SUCCESS;
5671 }
5672
5673 ptr += nOffset;
5674 sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset);
5675
5676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5677 "PNO enable %d networks count %d offset %d",
5678 pnoRequest.enable,
5679 pnoRequest.ucNetworksCount,
5680 nOffset);
5681
5682 /* Parameters checking:
5683 ucNetworksCount has to be larger than 0*/
5684 if (( 0 == pnoRequest.ucNetworksCount ) ||
5685 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
5686 {
5687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
5688 return VOS_STATUS_E_FAILURE;
5689 }
5690
5691 ptr += nOffset;
5692
5693 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
5694 {
5695
5696 pnoRequest.aNetworks[i].ssId.length = 0;
5697
5698 sscanf(ptr,"%hhu %n",
5699 &(pnoRequest.aNetworks[i].ssId.length), &nOffset);
5700
5701 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
5702 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
5703 {
5704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5705 "SSID Len %d is not correct for network %d",
5706 pnoRequest.aNetworks[i].ssId.length, i);
5707 return VOS_STATUS_E_FAILURE;
5708 }
5709
5710 /*Advance to SSID*/
5711 ptr += nOffset;
5712
Amar Singhal751e6072013-01-24 16:02:56 -08005713 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
5714 pnoRequest.aNetworks[i].ssId.length);
5715 ptr += pnoRequest.aNetworks[i].ssId.length;
5716
5717 ucParams = sscanf(ptr,"%lu %lu %hhu %n",
5718 &(pnoRequest.aNetworks[i].authentication),
5719 &(pnoRequest.aNetworks[i].encryption),
5720 &(pnoRequest.aNetworks[i].ucChannelCount),
5721 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07005722
5723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal751e6072013-01-24 16:02:56 -08005724 "PNO len %d ssid 0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx"
5725 "auth %d encry %d channel count %d offset %d",
5726 pnoRequest.aNetworks[i].ssId.length,
5727 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
5728 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
5729 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
5730 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
5731 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
5732 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
5733 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
5734 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
5735 pnoRequest.aNetworks[i].authentication,
5736 pnoRequest.aNetworks[i].encryption,
5737 pnoRequest.aNetworks[i].ucChannelCount,
5738 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07005739
Amar Singhal751e6072013-01-24 16:02:56 -08005740 if ( 3 != ucParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 {
5742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5743 "Incorrect cmd");
5744 return VOS_STATUS_E_FAILURE;
5745 }
5746
5747 /*Advance to channel list*/
5748 ptr += nOffset;
5749
5750 if ( SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount )
5751 {
5752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5753 "Incorrect number of channels");
5754 return VOS_STATUS_E_FAILURE;
5755 }
5756
5757 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
5758 {
5759 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
5760 {
5761 sscanf(ptr,"%hhu %n",
5762 &(pnoRequest.aNetworks[i].aChannels[j]), &nOffset);
5763 /*Advance to next channel number*/
5764 ptr += nOffset;
5765 }
5766 }
5767
5768 sscanf(ptr,"%lu %n",
5769 &(pnoRequest.aNetworks[i].bcastNetwType), &nOffset);
5770
5771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5772 "PNO bcastNetwType %d offset %d",
5773 pnoRequest.aNetworks[i].bcastNetwType,
5774 nOffset );
5775
5776 /*Advance to rssi Threshold*/
5777 ptr += nOffset;
5778
5779 sscanf(ptr,"%hhu %n",
5780 &(pnoRequest.aNetworks[i].rssiThreshold), &nOffset);
5781
5782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5783 "PNO rssi %d offset %d",
5784 pnoRequest.aNetworks[i].rssiThreshold,
5785 nOffset );
5786 /*Advance to next network*/
5787 ptr += nOffset;
5788 }/*For ucNetworkCount*/
5789
5790 ucParams = sscanf(ptr,"%hhu %n",
5791 &(pnoRequest.scanTimers.ucScanTimersCount), &nOffset);
5792
5793 /*Read the scan timers*/
5794 if (( 1 == ucParams )&&( pnoRequest.scanTimers.ucScanTimersCount >= 0 ))
5795 {
5796 ptr += nOffset;
5797
5798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5799 "Scan timer count %d offset %d",
5800 pnoRequest.scanTimers.ucScanTimersCount,
5801 nOffset );
5802
5803 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
5804 {
5805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5806 "Incorrect cmd - too many scan timers");
5807 return VOS_STATUS_E_FAILURE;
5808 }
5809
5810 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
5811 {
5812 ucParams = sscanf(ptr,"%lu %lu %n",
5813 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
5814 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
5815 &nOffset);
5816
5817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5818 "PNO Timer value %d Timer repeat %d offset %d",
5819 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
5820 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
5821 nOffset );
5822
5823 if ( 2 != ucParams )
5824 {
5825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5826 "Incorrect cmd - diff params then expected %d", ucParams);
5827 return VOS_STATUS_E_FAILURE;
5828 }
5829
5830 ptr += nOffset;
5831 }
5832
5833 }
5834 else
5835 {
5836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5837 "No scan timers provided param count %d scan timers %d",
5838 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
5839
5840 /*Scan timers defaults to 5 minutes*/
5841 pnoRequest.scanTimers.ucScanTimersCount = 1;
5842 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
5843 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
5844 }
5845
5846 ucParams = sscanf(ptr,"%hhu %n",
5847 &(ucMode), &nOffset);
5848
5849 pnoRequest.modePNO = ucMode;
5850 /*for LA we just expose suspend option*/
5851 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
5852 {
5853 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
5854 }
5855
5856 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
5857 pAdapter->sessionId,
5858 found_pref_network_cb, pAdapter);
5859
5860 return VOS_STATUS_SUCCESS;
5861}/*iw_set_pno*/
5862
5863VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
5864 union iwreq_data *wrqu, char *extra, int nOffset)
5865{
5866 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5867 v_U8_t rssiThreshold = 0;
5868 v_U8_t nRead;
5869
5870 nRead = sscanf(wrqu->data.pointer + nOffset,"%hhu",
5871 &rssiThreshold);
5872
5873 if ( 1 != nRead )
5874 {
5875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5876 "Incorrect format");
5877 return VOS_STATUS_E_FAILURE;
5878 }
5879
5880 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
5881 return VOS_STATUS_SUCCESS;
5882}
5883
5884
5885static int iw_set_pno_priv(struct net_device *dev,
5886 struct iw_request_info *info,
5887 union iwreq_data *wrqu, char *extra)
5888{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005889 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5890
5891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005893
5894 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5895 {
5896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5897 "%s:LOGP in Progress. Ignore!!!", __func__);
5898 return -EBUSY;
5899 }
5900 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005901}
5902#endif /*FEATURE_WLAN_SCAN_PNO*/
5903
5904//Common function to SetBand
5905int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
5906{
5907 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5908 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5909 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5910 tANI_U8 band = 0;
5911 eCsrBand currBand = eCSR_BAND_MAX;
5912
5913 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
5914
5915 switch(band)
5916 {
5917 case WLAN_HDD_UI_BAND_AUTO:
5918 band = eCSR_BAND_ALL;
5919 break;
5920 case WLAN_HDD_UI_BAND_5_GHZ:
5921 band = eCSR_BAND_5G;
5922 break;
5923 case WLAN_HDD_UI_BAND_2_4_GHZ:
5924 band = eCSR_BAND_24;
5925 break;
5926 default:
5927 band = eCSR_BAND_MAX;
5928 }
5929
5930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005931 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07005932
5933 if (band == eCSR_BAND_MAX)
5934 {
5935 /* Received change band request with invalid band value */
5936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005937 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 return -EIO;
5939 }
5940
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005941 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
5942 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
5943 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
5944 {
5945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005946 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005947 band, pHddCtx->cfg_ini->nBandCapability);
5948 return -EIO;
5949 }
5950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
5952 {
5953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5954 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005955 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 return -EIO;
5957 }
5958
5959 if (currBand != band)
5960 {
5961 /* Change band request received.
5962 * Abort pending scan requests, flush the existing scan results,
5963 * and change the band capability
5964 */
5965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5966 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005967 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
5969 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
5970 {
5971 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
5972 eHalStatus status = eHAL_STATUS_SUCCESS;
5973 long lrc;
5974
5975 /* STA already connected on current band, So issue disconnect first,
5976 * then change the band*/
5977
5978 hddLog(VOS_TRACE_LEVEL_INFO,
5979 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
5980 __func__, csrGetCurrentBand(hHal), band);
5981
5982 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
5983 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5984
5985 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5986 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5987
Jeff Johnson43971f52012-07-17 12:26:56 -07005988 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 {
5990 hddLog(VOS_TRACE_LEVEL_ERROR,
5991 "%s csrRoamDisconnect failure, returned %d \n",
5992 __func__, (int)status );
5993 return -EINVAL;
5994 }
5995
5996 lrc = wait_for_completion_interruptible_timeout(
5997 &pAdapter->disconnect_comp_var,
5998 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5999
6000 if(lrc <= 0) {
6001
6002 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006003 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006004
6005 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6006 }
6007 }
6008
6009 hdd_abort_mac_scan(pHddCtx);
6010 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Srinivas Girigowdade697412013-02-14 16:31:48 -08006011#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6012 sme_UpdateBgScanConfigIniChannelList(hHal, (eCsrBand) band);
6013#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 if(eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
6015 {
6016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6017 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006018 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 return -EINVAL;
6020 }
6021#ifdef CONFIG_CFG80211
6022 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
6023#endif
6024 }
6025 return 0;
6026}
6027
6028static int iw_set_band_config(struct net_device *dev,
6029 struct iw_request_info *info,
6030 union iwreq_data *wrqu, char *extra)
6031{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006032 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 tANI_U8 *ptr = (tANI_U8*)wrqu->data.pointer;
6034 int ret = 0;
6035
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006037
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006038 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6039 {
6040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6041 "%s:LOGP in Progress. Ignore!!!", __func__);
6042 return -EBUSY;
6043 }
6044
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 if (memcmp(ptr, "SETBAND ", 8) == 0)
6046 {
6047 /* Change band request received */
6048 ret = hdd_setBand_helper(dev, ptr);
6049 return ret;
6050
6051 }
6052 return 0;
6053}
6054
6055static int iw_set_power_params_priv(struct net_device *dev,
6056 struct iw_request_info *info,
6057 union iwreq_data *wrqu, char *extra)
6058{
6059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6060 "Set power params Private");
6061 return iw_set_power_params(dev,info,wrqu,extra,0);
6062}
6063
6064
6065
6066/*string based input*/
6067VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
6068 union iwreq_data *wrqu, char *extra, int nOffset)
6069{
6070 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6071 tSirSetPowerParamsReq powerRequest;
6072 char *ptr;
6073 v_U8_t ucType;
6074 v_U32_t uTotalSize, uValue;
6075 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6076
6077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6078 "Power Params data len %d data %s",
6079 wrqu->data.length,
6080 wrqu->data.pointer);
6081
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006082 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6083 {
6084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6085 "%s:LOGP in Progress. Ignore!!!", __func__);
6086 return -EBUSY;
6087 }
6088
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 if (wrqu->data.length <= nOffset )
6090 {
6091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
6092 return VOS_STATUS_E_FAILURE;
6093 }
6094
6095 uTotalSize = wrqu->data.length - nOffset;
6096
6097 /*-----------------------------------------------------------------------
6098 Input is string based and expected to be like this:
6099
6100 <param_type> <param_value> <param_type> <param_value> ...
6101
6102 e.g:
6103 1 2 2 3 3 0 4 1 5 1
6104
6105 e.g. setting just a few:
6106 1 2 4 1
6107
6108 parameter types:
6109 -----------------------------
6110 1 - Ignore DTIM
6111 2 - Listen Interval
6112 3 - Broadcast Multicas Filter
6113 4 - Beacon Early Termination
6114 5 - Beacon Early Termination Interval
6115 -----------------------------------------------------------------------*/
6116 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
6117 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
6118 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
6119 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
6120 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
6121
6122 ptr = (char*)(wrqu->data.pointer + nOffset);
6123
6124 while ( uTotalSize )
6125 {
6126 sscanf(ptr,"%hhu %n", &(ucType), &nOffset);
6127
6128 uTotalSize -= nOffset;
6129
6130 if (!uTotalSize)
6131 {
6132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006133 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 ucType, nOffset);
6135 return VOS_STATUS_E_FAILURE;
6136 }
6137
6138 ptr += nOffset;
6139 sscanf(ptr,"%lu %n", &(uValue), &nOffset);
6140
6141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6142 "Power request parameter %d value %d offset %d",
6143 ucType, uValue, nOffset);
6144
6145 switch (ucType)
6146 {
6147 case eSIR_IGNORE_DTIM:
6148 powerRequest.uIgnoreDTIM = uValue;
6149 break;
6150 case eSIR_LISTEN_INTERVAL:
6151 powerRequest.uListenInterval = uValue;
6152 break;
6153 case eSIR_MCAST_BCAST_FILTER:
6154 powerRequest.uBcastMcastFilter = uValue;
6155 break;
6156 case eSIR_ENABLE_BET:
6157 powerRequest.uEnableBET = uValue;
6158 break;
6159 case eSIR_BET_INTERVAL:
6160 powerRequest.uBETInterval = uValue;
6161 break;
6162 default:
6163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006164 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 ucType, uValue, nOffset);
6166 return VOS_STATUS_E_FAILURE;
6167 }
6168
6169 uTotalSize -= nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07006170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6171 "Power request parameter %d Total size",
6172 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07006174 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
6175 if(!(uTotalSize - nOffset) &&
6176 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
6177 {
6178 uTotalSize = 0;
6179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006180
6181 }/*Go for as long as we have a valid string*/
6182
6183 /* put the device into full power*/
6184 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6185
6186 /* Apply the power save params*/
6187 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest);
6188
6189 /* put the device back to power save*/
6190 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6191
6192 return VOS_STATUS_SUCCESS;
6193}/*iw_set_power_params*/
6194
6195
6196// Define the Wireless Extensions to the Linux Network Device structure
6197// A number of these routines are NULL (meaning they are not implemented.)
6198
6199static const iw_handler we_handler[] =
6200{
6201 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
6202 (iw_handler) iw_get_name, /* SIOCGIWNAME */
6203 (iw_handler) NULL, /* SIOCSIWNWID */
6204 (iw_handler) NULL, /* SIOCGIWNWID */
6205 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
6206 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
6207 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
6208 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
6209 (iw_handler) NULL, /* SIOCSIWSENS */
6210 (iw_handler) NULL, /* SIOCGIWSENS */
6211 (iw_handler) NULL, /* SIOCSIWRANGE */
6212 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
6213 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
6214 (iw_handler) NULL, /* SIOCGIWPRIV */
6215 (iw_handler) NULL, /* SIOCSIWSTATS */
6216 (iw_handler) NULL, /* SIOCGIWSTATS */
6217 iw_handler_set_spy, /* SIOCSIWSPY */
6218 iw_handler_get_spy, /* SIOCGIWSPY */
6219 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
6220 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
6221 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
6222 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
6223 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
6224 (iw_handler) NULL, /* SIOCGIWAPLIST */
6225 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
6226 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
6227 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
6228 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
6229 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
6230 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
6231 (iw_handler) NULL, /* -- hole -- */
6232 (iw_handler) NULL, /* -- hole -- */
6233 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
6234 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
6235 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
6236 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
6237 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
6238 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
6239 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
6240 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
6241 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
6242 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
6243 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
6244 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
6245 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
6246 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
6247 (iw_handler) NULL, /* -- hole -- */
6248 (iw_handler) NULL, /* -- hole -- */
6249 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
6250 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
6251 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
6252 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
6253 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
6254 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
6255 (iw_handler) NULL, /* SIOCSIWPMKSA */
6256};
6257
6258static const iw_handler we_private[] = {
6259
6260 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
6261 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
6262 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
6263 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
6264 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
6265 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
6266 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
6267 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
6268 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
6269 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07006270#ifdef FEATURE_OEM_DATA_SUPPORT
6271 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
6272 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
6273#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006274
6275#ifdef FEATURE_WLAN_WAPI
6276 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
6277 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
6278 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
6279 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
6280 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
6281 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
6282#endif /* FEATURE_WLAN_WAPI */
6283#ifdef WLAN_FEATURE_VOWIFI_11R
6284 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
6285#endif
6286 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
6287 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
6288 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
6289#ifdef WLAN_FEATURE_PACKET_FILTERING
6290 ,
6291 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
6292#endif
6293#ifdef FEATURE_WLAN_SCAN_PNO
6294 ,
6295 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
6296#endif
6297 ,
6298 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
6299 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
6300 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
6301 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006302 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07006303};
6304
6305/*Maximum command length can be only 15 */
6306static const struct iw_priv_args we_private_args[] = {
6307
6308 /* handlers for main ioctl */
6309 { WLAN_PRIV_SET_INT_GET_NONE,
6310 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6311 0,
6312 "" },
6313
6314 /* handlers for sub-ioctl */
6315 { WE_SET_11D_STATE,
6316 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6317 0,
6318 "set11Dstate" },
6319
6320 { WE_WOWL,
6321 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6322 0,
6323 "wowl" },
6324
6325 { WE_SET_POWER,
6326 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6327 0,
6328 "setPower" },
6329
6330 { WE_SET_MAX_ASSOC,
6331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6332 0,
6333 "setMaxAssoc" },
6334
6335 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
6336 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6337 0,
6338 "setAutoChannel" },
6339
6340 { WE_SET_DATA_INACTIVITY_TO,
6341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6342 0,
6343 "inactivityTO" },
6344
6345 { WE_SET_MAX_TX_POWER,
6346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6347 0,
6348 "setMaxTxPower" },
6349 /* set Higher DTIM Transition (DTIM1 to DTIM3)
6350 * 1 = enable and 0 = disable */
6351 {
6352 WE_SET_HIGHER_DTIM_TRANSITION,
6353 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6354 0,
6355 "setHDtimTransn" },
6356
6357 { WE_SET_TM_LEVEL,
6358 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6359 0,
6360 "setTmLevel" },
6361
6362 /* handlers for main ioctl */
6363 { WLAN_PRIV_SET_NONE_GET_INT,
6364 0,
6365 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6366 "" },
6367
6368 /* handlers for sub-ioctl */
6369 { WE_GET_11D_STATE,
6370 0,
6371 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6372 "get11Dstate" },
6373
6374 { WE_IBSS_STATUS,
6375 0,
6376 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6377 "getAdhocStatus" },
6378
6379 { WE_PMC_STATE,
6380 0,
6381 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6382 "pmcState" },
6383
6384 { WE_GET_WLAN_DBG,
6385 0,
6386 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6387 "getwlandbg" },
6388
6389 { WE_MODULE_DOWN_IND,
6390 0,
6391 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6392 "moduleDownInd" },
6393
6394 { WE_GET_MAX_ASSOC,
6395 0,
6396 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6397 "getMaxAssoc" },
6398
6399#ifdef FEATURE_WLAN_INTEGRATED_SOC
6400 { WE_GET_WDI_DBG,
6401 0,
6402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6403 "getwdidbg" },
6404#endif // FEATURE_WLAN_INTEGRATED_SOC
6405
6406 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
6407 0,
6408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6409 "getAutoChannel" },
6410
6411 { WE_GET_CONCURRENCY_MODE,
6412 0,
6413 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6414 "getconcurrency" },
6415
6416 /* handlers for main ioctl */
6417 { WLAN_PRIV_SET_CHAR_GET_NONE,
6418 IW_PRIV_TYPE_CHAR| 512,
6419 0,
6420 "" },
6421
6422 /* handlers for sub-ioctl */
6423 { WE_WOWL_ADD_PTRN,
6424 IW_PRIV_TYPE_CHAR| 512,
6425 0,
6426 "wowlAddPtrn" },
6427
6428 { WE_WOWL_DEL_PTRN,
6429 IW_PRIV_TYPE_CHAR| 512,
6430 0,
6431 "wowlDelPtrn" },
6432
6433#if defined WLAN_FEATURE_VOWIFI
6434 /* handlers for sub-ioctl */
6435 { WE_NEIGHBOR_REPORT_REQUEST,
6436 IW_PRIV_TYPE_CHAR | 512,
6437 0,
6438 "neighbor" },
6439#endif
6440 { WE_SET_AP_WPS_IE,
6441 IW_PRIV_TYPE_CHAR| 512,
6442 0,
6443 "set_ap_wps_ie" },
6444
6445 { WE_SET_CONFIG,
6446 IW_PRIV_TYPE_CHAR| 512,
6447 0,
6448 "setConfig" },
6449
6450 /* handlers for main ioctl */
6451 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
6452 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6453 0,
6454 "" },
6455
6456 /* handlers for sub-ioctl */
6457 { WE_SET_WLAN_DBG,
6458 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6459 0,
6460 "setwlandbg" },
6461
6462#ifdef FEATURE_WLAN_INTEGRATED_SOC
6463 { WE_SET_WDI_DBG,
6464 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6465 0,
6466 "setwdidbg" },
6467#endif // FEATURE_WLAN_INTEGRATED_SOC
6468
6469 { WE_SET_SAP_CHANNELS,
6470 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6471 0,
6472 "setsapchannels" },
6473
6474 /* handlers for main ioctl */
6475 { WLAN_PRIV_GET_CHAR_SET_NONE,
6476 0,
6477 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6478 "" },
6479
6480 /* handlers for sub-ioctl */
6481 { WE_WLAN_VERSION,
6482 0,
6483 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6484 "version" },
6485 { WE_GET_STATS,
6486 0,
6487 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6488 "getStats" },
6489 { WE_GET_CFG,
6490 0,
6491 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6492 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07006493#ifdef WLAN_FEATURE_11AC
6494 { WE_GET_RSSI,
6495 0,
6496 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6497 "getRSSI" },
6498#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 { WE_GET_WMM_STATUS,
6500 0,
6501 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6502 "getWmmStatus" },
6503 {
6504 WE_GET_CHANNEL_LIST,
6505 0,
6506 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6507 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006508#ifdef FEATURE_WLAN_TDLS
6509 {
6510 WE_GET_TDLS_PEERS,
6511 0,
6512 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6513 "getTdlsPeers" },
6514#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 /* handlers for main ioctl */
6516 { WLAN_PRIV_SET_NONE_GET_NONE,
6517 0,
6518 0,
6519 "" },
6520
6521 /* handlers for sub-ioctl */
6522 { WE_CLEAR_STATS,
6523 0,
6524 0,
6525 "clearStats" },
6526 { WE_INIT_AP,
6527 0,
6528 0,
6529 "initAP" },
6530 { WE_STOP_AP,
6531 0,
6532 0,
6533 "exitAP" },
6534 { WE_ENABLE_AMP,
6535 0,
6536 0,
6537 "enableAMP" },
6538 { WE_DISABLE_AMP,
6539 0,
6540 0,
6541 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006542 { WE_ENABLE_DXE_STALL_DETECT,
6543 0,
6544 0,
6545 "dxeStallDetect" },
6546 { WE_DISPLAY_DXE_SNAP_SHOT,
6547 0,
6548 0,
6549 "dxeSnapshot" },
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07006550 {
6551 WE_SET_REASSOC_TRIGGER,
6552 0,
6553 0,
6554 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07006555
6556 /* handlers for main ioctl */
6557 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
6558 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6559 0,
6560 "" },
6561
6562 /* handlers for sub-ioctl */
6563 { WE_LOG_DUMP_CMD,
6564 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6565 0,
6566 "dump" },
6567
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006568 /* handlers for sub ioctl */
6569 {
6570 WE_MCC_CONFIG_CREDENTIAL,
6571 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6572 0,
6573 "setMccCrdnl" },
6574
6575 /* handlers for sub ioctl */
6576 {
6577 WE_MCC_CONFIG_PARAMS,
6578 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6579 0,
6580 "setMccConfig" },
6581
Chilam NG571c65a2013-01-19 12:27:36 +05306582#ifdef FEATURE_WLAN_TDLS
6583 /* handlers for sub ioctl */
6584 {
6585 WE_TDLS_CONFIG_PARAMS,
6586 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6587 0,
6588 "setTdlsConfig" },
6589#endif
6590
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 /* handlers for main ioctl */
6592 { WLAN_PRIV_ADD_TSPEC,
6593 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
6594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6595 "addTspec" },
6596
6597 /* handlers for main ioctl */
6598 { WLAN_PRIV_DEL_TSPEC,
6599 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6600 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6601 "delTspec" },
6602
6603 /* handlers for main ioctl */
6604 { WLAN_PRIV_GET_TSPEC,
6605 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6606 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6607 "getTspec" },
6608
Jeff Johnsone7245742012-09-05 17:12:55 -07006609#ifdef FEATURE_OEM_DATA_SUPPORT
6610 /* handlers for main ioctl - OEM DATA */
6611 {
6612 WLAN_PRIV_SET_OEM_DATA_REQ,
6613 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
6614 0,
6615 "set_oem_data_req" },
6616
6617 /* handlers for main ioctl - OEM DATA */
6618 {
6619 WLAN_PRIV_GET_OEM_DATA_RSP,
6620 0,
6621 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
6622 "get_oem_data_rsp" },
6623#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006624
6625#ifdef FEATURE_WLAN_WAPI
6626 /* handlers for main ioctl SET_WAPI_MODE */
6627 { WLAN_PRIV_SET_WAPI_MODE,
6628 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6629 0,
6630 "SET_WAPI_MODE" },
6631
6632 /* handlers for main ioctl GET_WAPI_MODE */
6633 { WLAN_PRIV_GET_WAPI_MODE,
6634 0,
6635 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6636 "GET_WAPI_MODE" },
6637
6638 /* handlers for main ioctl SET_ASSOC_INFO */
6639 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
6640 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
6641 0,
6642 "SET_WAPI_ASSOC" },
6643
6644 /* handlers for main ioctl SET_WAPI_KEY */
6645 { WLAN_PRIV_SET_WAPI_KEY,
6646 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
6647 0,
6648 "SET_WAPI_KEY" },
6649
6650 /* handlers for main ioctl SET_WAPI_BKID */
6651 { WLAN_PRIV_SET_WAPI_BKID,
6652 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
6653 0,
6654 "SET_WAPI_BKID" },
6655
6656 /* handlers for main ioctl GET_WAPI_BKID */
6657 { WLAN_PRIV_GET_WAPI_BKID,
6658 0,
6659 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
6660 "GET_WAPI_BKID" },
6661#endif /* FEATURE_WLAN_WAPI */
6662
6663 /* handlers for main ioctl - host offload */
6664 {
6665 WLAN_PRIV_SET_HOST_OFFLOAD,
6666 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
6667 0,
6668 "setHostOffload" },
6669
6670 {
6671 WLAN_GET_WLAN_STATISTICS,
6672 0,
6673 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
6674 "getWlanStats" },
6675
6676 {
6677 WLAN_SET_KEEPALIVE_PARAMS,
6678 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
6679 0,
6680 "setKeepAlive" },
6681#ifdef WLAN_FEATURE_PACKET_FILTERING
6682 {
6683 WLAN_SET_PACKET_FILTER_PARAMS,
6684 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
6685 0,
6686 "setPktFilter" },
6687#endif
6688#ifdef FEATURE_WLAN_SCAN_PNO
6689 {
6690 WLAN_SET_PNO,
6691 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6692 0,
6693 "setpno" },
6694#endif
6695 {
6696 WLAN_SET_BAND_CONFIG,
6697 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6698 0,
6699 "SETBAND" },
6700 /* handlers for dynamic MC BC ioctl */
6701 {
6702 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006703 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 0,
6705 "setMCBCFilter" },
6706 {
6707 WLAN_PRIV_CLEAR_MCBC_FILTER,
6708 0,
6709 0,
6710 "clearMCBCFilter" },
6711 {
6712 WLAN_SET_POWER_PARAMS,
6713 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6714 0,
6715 "setpowerparams" },
6716 {
6717 WLAN_GET_LINK_SPEED,
6718 IW_PRIV_TYPE_CHAR | 18,
6719 IW_PRIV_TYPE_CHAR | 3, "getLinkSpeed" },
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07006720
Jeff Johnson295189b2012-06-20 16:38:30 -07006721};
6722
6723
6724
6725const struct iw_handler_def we_handler_def = {
6726 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
6727 .num_private = sizeof(we_private) / sizeof(we_private[0]),
6728 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
6729
6730 .standard = (iw_handler *)we_handler,
6731 .private = (iw_handler *)we_private,
6732 .private_args = we_private_args,
6733 .get_wireless_stats = get_wireless_stats,
6734};
6735
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006736int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
6737{
6738 v_U32_t cmd = 288; //Command to RIVA
6739 hdd_context_t *pHddCtx = NULL;
6740 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6741 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6742 /*
6743 *configMccParam : specify the bit which needs to be modified
6744 *allowed to update based on wlan_qcom_cfg.ini
6745 * configuration
6746 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
6747 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
6748 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
6749 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
6750 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
6751 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
6752 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
6753 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
6754 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
6755 * Bit 9 : Reserved
6756 */
6757 switch (arg1)
6758 {
6759 //Update MCC SCHEDULE_TIME_SLICE parameter
6760 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
6761 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
6762 {
6763 if((arg2 >= 5) && (arg2 <= 20))
6764 {
6765 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6766 }
6767 else
6768 {
6769 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6770 return 0;
6771 }
6772 }
6773 break;
6774
6775 //Update MCC MAX_NULL_SEND_TIME parameter
6776 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
6777 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
6778 {
6779 if((arg2 >= 1) && (arg2 <= 10))
6780 {
6781 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6782 }
6783 else
6784 {
6785 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6786 return 0;
6787 }
6788 }
6789 break;
6790
6791 //Update MCC TX_EARLY_STOP_TIME parameter
6792 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
6793 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
6794 {
6795 if((arg2 >= 1) && (arg2 <= 10))
6796 {
6797 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6798 }
6799 else
6800 {
6801 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6802 return 0;
6803 }
6804 }
6805 break;
6806
6807 //Update MCC RX_DRAIN_TIME parameter
6808 case MCC_RX_DRAIN_TIME_CFG_PARAM :
6809 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
6810 {
6811 if((arg2 >= 1) && (arg2 <= 10))
6812 {
6813 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6814 }
6815 else
6816 {
6817 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6818 return 0;
6819 }
6820 }
6821 break;
6822
6823 //Update MCC CHANNEL_SWITCH_TIME parameter
6824 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
6825 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
6826 {
6827 if((arg2 >= 1) && (arg2 <= 20))
6828 {
6829 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6830 }
6831 else
6832 {
6833 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6834 return 0;
6835 }
6836 }
6837 break;
6838
6839 //Update MCC MIN_CHANNEL_TIME parameter
6840 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
6841 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
6842 {
6843 if((arg2 >= 5) && (arg2 <= 20))
6844 {
6845 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6846 }
6847 else
6848 {
6849 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6850 return 0;
6851 }
6852 }
6853 break;
6854
6855 //Update MCC PARK_BEFORE_TBTT parameter
6856 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
6857 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
6858 {
6859 if((arg2 >= 1) && (arg2 <= 5))
6860 {
6861 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6862 }
6863 else
6864 {
6865 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6866 return 0;
6867 }
6868 }
6869 break;
6870
6871 //Update MCC MIN_AFTER_DTIM parameter
6872 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
6873 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
6874 {
6875 if((arg2 >= 5) && (arg2 <= 15))
6876 {
6877 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6878 }
6879 else
6880 {
6881 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6882 return 0;
6883 }
6884 }
6885 break;
6886
6887 //Update MCC TOO_CLOSE_MARGIN parameter
6888 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
6889 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
6890 {
6891 if((arg2 >= 1) && (arg2 <= 3))
6892 {
6893 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6894 }
6895 else
6896 {
6897 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6898 return 0;
6899 }
6900 }
6901 break;
6902
6903 default :
6904 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d\n",
6905 __FUNCTION__,arg1);
6906 break;
6907 }
6908 return 0;
6909}
6910
Jeff Johnson295189b2012-06-20 16:38:30 -07006911int hdd_set_wext(hdd_adapter_t *pAdapter)
6912{
6913 hdd_wext_state_t *pwextBuf;
6914 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006915 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006916
6917 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6918
6919 // Now configure the roaming profile links. To SSID and bssid.
6920 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
6921 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
6922
6923 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
6924 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
6925
6926 /*Set the numOfChannels to zero to scan all the channels*/
6927 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
6928 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
6929
6930 /* Default is no encryption */
6931 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
6932 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6933
6934 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
6935 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6936
6937 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
6938
6939 /* Default is no authentication */
6940 pwextBuf->roamProfile.AuthType.numEntries = 1;
6941 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6942
6943 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
6944 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6945
6946 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006947 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07006948
6949 hdd_clearRoamProfileIe(pAdapter);
6950
6951 return VOS_STATUS_SUCCESS;
6952
6953 }
6954
6955int hdd_register_wext(struct net_device *dev)
6956 {
6957 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6958 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6959 VOS_STATUS status;
6960
6961 ENTER();
6962
6963 // Zero the memory. This zeros the profile structure.
6964 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
6965
6966 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
6967
6968
6969 status = hdd_set_wext(pAdapter);
6970
6971 if(!VOS_IS_STATUS_SUCCESS(status)) {
6972
6973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!\n"));
6974 return eHAL_STATUS_FAILURE;
6975 }
6976
6977 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
6978 {
6979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!\n"));
6980 return eHAL_STATUS_FAILURE;
6981 }
6982
6983 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
6984 {
6985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!\n"));
6986 return eHAL_STATUS_FAILURE;
6987 }
6988
6989 // Register as a wireless device
6990 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
6991
6992 EXIT();
6993 return 0;
6994}
6995
6996int hdd_UnregisterWext(struct net_device *dev)
6997{
6998#if 0
6999 hdd_wext_state_t *wextBuf;
7000 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7001
7002 ENTER();
7003 // Set up the pointer to the Wireless Extensions state structure
7004 wextBuf = pAdapter->pWextState;
7005
7006 // De-allocate the Wireless Extensions state structure
7007 kfree(wextBuf);
7008
7009 // Clear out the pointer to the Wireless Extensions state structure
7010 pAdapter->pWextState = NULL;
7011
7012 EXIT();
7013#endif
7014 dev->wireless_handlers = NULL;
7015 return 0;
7016}
7017
7018