blob: 632926be22667a93ea612abdabedda3bd5c9f051 [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"
Jeff Johnson295189b2012-06-20 16:38:30 -070087#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053088#ifdef FEATURE_WLAN_TDLS
89#include "wlan_hdd_tdls.h"
90#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070091
92#ifdef CONFIG_HAS_EARLYSUSPEND
93#include <linux/earlysuspend.h>
94#endif
95#include "wlan_hdd_power.h"
96#include "qwlan_version.h"
97#include <vos_power.h>
98#include "wlan_hdd_host_offload.h"
99#include "wlan_hdd_keep_alive.h"
100#ifdef WLAN_FEATURE_PACKET_FILTERING
101#include "wlan_hdd_packet_filtering.h"
102#endif
103
Jeff Johnson295189b2012-06-20 16:38:30 -0700104#include <linux/wireless.h>
105#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700106#include "wlan_qct_pal_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#include "wlan_hdd_misc.h"
109#include "bap_hdd_misc.h"
110
111#include "wlan_hdd_dev_pwr.h"
112#include "qc_sap_ioctl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700113
114#ifdef CONFIG_HAS_EARLYSUSPEND
115extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
116extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
117#endif
118
Jeff Johnsone7245742012-09-05 17:12:55 -0700119#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800120#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700121#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
123#define HDD_FINISH_ULA_TIME_OUT 800
124
125extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
126int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
131struct statsContext
132{
133 struct completion completion;
134 hdd_adapter_t *pAdapter;
135 unsigned int magic;
136};
137
138#define STATS_CONTEXT_MAGIC 0x53544154 //STAT
139#define RSSI_CONTEXT_MAGIC 0x52535349 //RSSI
140#define POWER_CONTEXT_MAGIC 0x504F5752 // POWR
141
142/* To Validate Channel against the Frequency and Vice-Versa */
143static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
144 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
145 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
146 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
147 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
148 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
149 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
150 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
151 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
152
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800153#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700154
155/* Private ioctls and their sub-ioctls */
156#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
157#define WE_SET_11D_STATE 1
158#define WE_WOWL 2
159#define WE_SET_POWER 3
160#define WE_SET_MAX_ASSOC 4
161#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
162#define WE_SET_DATA_INACTIVITY_TO 6
163#define WE_SET_MAX_TX_POWER 7
164#define WE_SET_HIGHER_DTIM_TRANSITION 8
165#define WE_SET_TM_LEVEL 9
166
167/* Private ioctls and their sub-ioctls */
168#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
169#define WE_GET_11D_STATE 1
170#define WE_IBSS_STATUS 2
171#define WE_PMC_STATE 3
172#define WE_GET_WLAN_DBG 4
173#define WE_MODULE_DOWN_IND 5
174#define WE_GET_MAX_ASSOC 6
175#define WE_GET_WDI_DBG 7
176#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
177#define WE_GET_CONCURRENCY_MODE 9
178/* Private ioctls and their sub-ioctls */
179#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
180
181/* Private ioctls and their sub-ioctls */
182#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
183#define WE_WOWL_ADD_PTRN 1
184#define WE_WOWL_DEL_PTRN 2
185#if defined WLAN_FEATURE_VOWIFI
186#define WE_NEIGHBOR_REPORT_REQUEST 3
187#endif
188#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
189#define WE_SET_CONFIG 5
190
191/* Private ioctls and their sub-ioctls */
192#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
193#define WE_SET_WLAN_DBG 1
194#define WE_SET_WDI_DBG 2
195#define WE_SET_SAP_CHANNELS 3
196
197/* Private ioctls and their sub-ioctls */
198#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
199#define WE_WLAN_VERSION 1
200#define WE_GET_STATS 2
201#define WE_GET_CFG 3
202#define WE_GET_WMM_STATUS 4
203#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700204#ifdef WLAN_FEATURE_11AC
205#define WE_GET_RSSI 6
206#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800207#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800208#ifdef FEATURE_WLAN_TDLS
209#define WE_GET_TDLS_PEERS 8
210#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700211#ifdef WLAN_FEATURE_11W
212#define WE_GET_11W_INFO 9
213#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700214
215/* Private ioctls and their sub-ioctls */
216#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
217#define WE_CLEAR_STATS 1
218#define WE_INIT_AP 2
219#define WE_STOP_AP 3
220#define WE_ENABLE_AMP 4
221#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700222#define WE_ENABLE_DXE_STALL_DETECT 6
223#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700224#define WE_SET_REASSOC_TRIGGER 8
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
226/* Private ioctls and their sub-ioctls */
227#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
228#define WE_LOG_DUMP_CMD 1
229
Jeff Johnson295189b2012-06-20 16:38:30 -0700230#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800231//IOCTL to configure MCC params
232#define WE_MCC_CONFIG_CREDENTIAL 3
233#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700234
Chilam NG571c65a2013-01-19 12:27:36 +0530235#ifdef FEATURE_WLAN_TDLS
236#define WE_TDLS_CONFIG_PARAMS 5
237#endif
238
Chilam Ng01120412013-02-19 18:32:21 -0800239#ifdef FEATURE_WLAN_TDLS
240#undef MAX_VAR_ARGS
241#define MAX_VAR_ARGS 10
242#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700243#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800244#endif
245
Jeff Johnson295189b2012-06-20 16:38:30 -0700246
247/* Private ioctls (with no sub-ioctls) */
248/* note that they must be odd so that they have "get" semantics */
249#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
250#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
251#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
252
253#ifdef FEATURE_WLAN_WAPI
254/* Private ioctls EVEN NO: SET, ODD NO:GET */
255#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
256#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
257#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
258#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
259#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
260#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
261#define WAPI_PSK_AKM_SUITE 0x02721400
262#define WAPI_CERT_AKM_SUITE 0x01721400
263#endif
264
Jeff Johnsone7245742012-09-05 17:12:55 -0700265#ifdef FEATURE_OEM_DATA_SUPPORT
266/* Private ioctls for setting the measurement configuration */
267#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
268#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
269#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700270
271#ifdef WLAN_FEATURE_VOWIFI_11R
272#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
273#endif
274
275/* Private ioctl for setting the host offload feature */
276#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
277
278/* Private ioctl to get the statistics */
279#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
280
281/* Private ioctl to set the Keep Alive Params */
282#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
283#ifdef WLAN_FEATURE_PACKET_FILTERING
284/* Private ioctl to set the Packet Filtering Params */
285#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
286#endif
287
288#ifdef FEATURE_WLAN_SCAN_PNO
289/* Private ioctl to get the statistics */
290#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
291#endif
292
293#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
294
295#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
296#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700297/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700298
Jeff Johnson295189b2012-06-20 16:38:30 -0700299#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
300#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
301
302#define WLAN_STATS_INVALID 0
303#define WLAN_STATS_RETRY_CNT 1
304#define WLAN_STATS_MUL_RETRY_CNT 2
305#define WLAN_STATS_TX_FRM_CNT 3
306#define WLAN_STATS_RX_FRM_CNT 4
307#define WLAN_STATS_FRM_DUP_CNT 5
308#define WLAN_STATS_FAIL_CNT 6
309#define WLAN_STATS_RTS_FAIL_CNT 7
310#define WLAN_STATS_ACK_FAIL_CNT 8
311#define WLAN_STATS_RTS_SUC_CNT 9
312#define WLAN_STATS_RX_DISCARD_CNT 10
313#define WLAN_STATS_RX_ERROR_CNT 11
314#define WLAN_STATS_TX_BYTE_CNT 12
315
316#define WLAN_STATS_RX_BYTE_CNT 13
317#define WLAN_STATS_RX_RATE 14
318#define WLAN_STATS_TX_RATE 15
319
Jeff Johnsone7245742012-09-05 17:12:55 -0700320#define WLAN_STATS_RX_UC_BYTE_CNT 16
321#define WLAN_STATS_RX_MC_BYTE_CNT 17
322#define WLAN_STATS_RX_BC_BYTE_CNT 18
323#define WLAN_STATS_TX_UC_BYTE_CNT 19
324#define WLAN_STATS_TX_MC_BYTE_CNT 20
325#define WLAN_STATS_TX_BC_BYTE_CNT 21
326
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800327#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
328 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
329 { \
330 *__p++ = __type; \
331 *__p++ = __size; \
332 memcpy(__p, __val, __size); \
333 __p += __size; \
334 __tlen += __size + 2; \
335 } \
336 else \
337 { \
338 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!\n"); \
339 } \
340 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
342#define VERSION_VALUE_MAX_LEN 32
343
344#define TX_PER_TRACKING_DEFAULT_RATIO 5
345#define TX_PER_TRACKING_MAX_RATIO 10
346#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
347
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800348/*MCC Configuration parameters */
349enum {
350 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
351 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
352 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
353 MCC_RX_DRAIN_TIME_CFG_PARAM,
354 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
355 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
356 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
357 MCC_MIN_AFTER_DTIM_CFG_PARAM,
358 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
359};
360
361int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
362 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
363
Jeff Johnson295189b2012-06-20 16:38:30 -0700364#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -0700365int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
366 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700367#endif
368
Jeff Johnson295189b2012-06-20 16:38:30 -0700369/**---------------------------------------------------------------------------
370
371 \brief hdd_wlan_get_version() -
372
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800373 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700374
375 \param - pAdapter Pointer to the adapter.
376 wrqu - Pointer to IOCTL REQUEST Data.
377 extra - Pointer to char
378
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800379 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700380
381 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800382void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
383 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700384{
385 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800386 tSirVersionString wcnss_SW_version;
387 tSirVersionString wcnss_HW_version;
388 char *pSWversion;
389 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700390 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700391
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800392 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
393 sizeof(wcnss_SW_version));
394 if (VOS_IS_STATUS_SUCCESS(status))
395 {
396 pSWversion = wcnss_SW_version;
397 }
398 else
399 {
400 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 }
402
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800403 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
404 sizeof(wcnss_HW_version));
405 if (VOS_IS_STATUS_SUCCESS(status))
406 {
407 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800409 else
410 {
411 pHWversion = "Unknown";
412 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700413
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800414 wrqu->data.length = snprintf(extra, WE_MAX_STR_LEN,
415 "Host SW:%s, FW:%s, HW:%s",
416 QWLAN_VERSIONSTR,
417 pSWversion,
418 pHWversion);
419
420 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700421}
422
Jeff Johnson295189b2012-06-20 16:38:30 -0700423int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
424{
425 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
426 v_U32_t threshold = 0,status = 0;
427
428 ENTER();
429
430 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
432 "%s:LOGP in Progress. Ignore!!!",__func__);
433 return status;
434 }
435
436 if ( eHAL_STATUS_SUCCESS !=
437 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
438 {
439 return -EIO;
440 }
441 wrqu->rts.value = threshold;
442
443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
444 ("Rts-Threshold=%ld!!\n"), wrqu->rts.value);
445
446 EXIT();
447
448 return 0;
449}
450
451int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
452{
453 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
454 v_U32_t threshold = 0,status = 0;
455
456 ENTER();
457
458 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
460 "%s:LOGP in Progress. Ignore!!!",__func__);
461 return status;
462 }
463
464 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
465 != eHAL_STATUS_SUCCESS )
466 {
467 return -EIO;
468 }
469 wrqu->frag.value = threshold;
470
471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
472 ("Frag-Threshold=%ld!!\n"), wrqu->frag.value);
473
474 EXIT();
475
476 return 0;
477}
478
479int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
480{
Jeff Johnsone7245742012-09-05 17:12:55 -0700481 int i;
482 if (channel > 0)
483 {
484 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
485 {
486 if (channel == freq_chan_map[i].chan)
487 {
488 *pfreq = freq_chan_map[i].freq;
489 return 1;
490 }
491 }
492 }
493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
494 ("Invalid channel no=%d!!\n"), channel);
495 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700496}
497
498static v_BOOL_t
499hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
500{
501 v_BOOL_t rsnType = VOS_FALSE;
502 // is the authType supported?
503 switch (authType)
504 {
505 case eCSR_AUTH_TYPE_NONE: //never used
506 rsnType = eANI_BOOLEAN_FALSE;
507 break;
508 // MAC layer authentication types
509 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
510 rsnType = eANI_BOOLEAN_FALSE;
511 break;
512 case eCSR_AUTH_TYPE_SHARED_KEY:
513 rsnType = eANI_BOOLEAN_FALSE;
514 break;
515 case eCSR_AUTH_TYPE_AUTOSWITCH:
516 rsnType = eANI_BOOLEAN_FALSE;
517 break;
518
519 // Upper layer authentication types
520 case eCSR_AUTH_TYPE_WPA:
521 rsnType = eANI_BOOLEAN_TRUE;
522 break;
523 case eCSR_AUTH_TYPE_WPA_PSK:
524 rsnType = eANI_BOOLEAN_TRUE;
525 break;
526 case eCSR_AUTH_TYPE_WPA_NONE:
527 rsnType = eANI_BOOLEAN_TRUE;
528 break;
529#ifdef WLAN_FEATURE_VOWIFI_11R
530 case eCSR_AUTH_TYPE_FT_RSN:
531#endif
532 case eCSR_AUTH_TYPE_RSN:
533 rsnType = eANI_BOOLEAN_TRUE;
534 break;
535#ifdef WLAN_FEATURE_VOWIFI_11R
536 case eCSR_AUTH_TYPE_FT_RSN_PSK:
537#endif
538 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700539#ifdef WLAN_FEATURE_11W
540 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
541#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 rsnType = eANI_BOOLEAN_TRUE;
543 break;
544 //case eCSR_AUTH_TYPE_FAILED:
545 case eCSR_AUTH_TYPE_UNKNOWN:
546 rsnType = eANI_BOOLEAN_FALSE;
547 break;
548 default:
549 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700550 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 rsnType = eANI_BOOLEAN_FALSE;
552 break;
553 }
554 hddLog(LOGE, FL("%s called with authType: %d, returned: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700555 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 return rsnType;
557}
558
559static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
560{
561 struct statsContext *pStatsContext;
562 hdd_adapter_t *pAdapter;
563
564 if (ioctl_debug)
565 {
566 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700567 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 }
569
570 if (NULL == pContext)
571 {
572 hddLog(VOS_TRACE_LEVEL_ERROR,
573 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700574 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 return;
576 }
577
578 /* there is a race condition that exists between this callback function
579 and the caller since the caller could time out either before or
580 while this code is executing. we'll assume the timeout hasn't
581 occurred, but we'll verify that right before we save our work */
582
583 pStatsContext = pContext;
584 pAdapter = pStatsContext->pAdapter;
585 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
586 {
587 /* the caller presumably timed out so there is nothing we can do */
588 hddLog(VOS_TRACE_LEVEL_WARN,
589 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700590 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 if (ioctl_debug)
592 {
593 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700594 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 }
596 return;
597 }
598
599 /* the race is on. caller could have timed out immediately after
600 we verified the magic, but if so, caller will wait a short time
601 for us to copy over the rssi */
602 pAdapter->rssi = rssi;
603
604 /* and notify the caller */
605 complete(&pStatsContext->completion);
606}
607
608VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
609{
610 struct statsContext context;
611 hdd_context_t *pHddCtx;
612 hdd_station_ctx_t *pHddStaCtx;
613 eHalStatus hstatus;
614 long lrc;
615
616 if (NULL == pAdapter)
617 {
618 hddLog(VOS_TRACE_LEVEL_WARN,
619 "%s: Invalid context, pAdapter", __func__);
620 return VOS_STATUS_E_FAULT;
621 }
622 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
623 {
624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
625 /* return a cached value */
626 *rssi_value = pAdapter->rssi;
627 return VOS_STATUS_SUCCESS;
628 }
629
630 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
631 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
632
633 init_completion(&context.completion);
634 context.pAdapter = pAdapter;
635 context.magic = RSSI_CONTEXT_MAGIC;
636
637 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
638 pHddStaCtx->conn_info.staId[ 0 ],
639 pHddStaCtx->conn_info.bssId,
640 &context, pHddCtx->pvosContext);
641 if (eHAL_STATUS_SUCCESS != hstatus)
642 {
643 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700644 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 /* we'll returned a cached value below */
646 }
647 else
648 {
649 /* request was sent -- wait for the response */
650 lrc = wait_for_completion_interruptible_timeout(&context.completion,
651 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
652 /* either we have a response or we timed out
653 either way, first invalidate our magic */
654 context.magic = 0;
655 if (lrc <= 0)
656 {
657 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700658 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 /* there is a race condition such that the callback
660 function could be executing at the same time we are. of
661 primary concern is if the callback function had already
662 verified the "magic" but hasn't yet set the completion
663 variable. Since the completion variable is on our
664 stack, we'll delay just a bit to make sure the data is
665 still valid if that is the case */
666 msleep(50);
667 /* we'll now returned a cached value below */
668 }
669 }
670 *rssi_value = pAdapter->rssi;
671
672 return VOS_STATUS_SUCCESS;
673}
674
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800675#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
676
677static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
678{
679 struct statsContext *pStatsContext;
680 hdd_adapter_t *pAdapter;
681 if (ioctl_debug)
682 {
683 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
684 __func__, (int)rssi, (int)staId, pContext);
685 }
686
687 if (NULL == pContext)
688 {
689 hddLog(VOS_TRACE_LEVEL_ERROR,
690 "%s: Bad param, pContext [%p]",
691 __func__, pContext);
692 return;
693 }
694
695 /* there is a race condition that exists between this callback function
696 and the caller since the caller could time out either before or
697 while this code is executing. we'll assume the timeout hasn't
698 occurred, but we'll verify that right before we save our work */
699
700 pStatsContext = pContext;
701 pAdapter = pStatsContext->pAdapter;
702 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
703 {
704 /* the caller presumably timed out so there is nothing we can do */
705 hddLog(VOS_TRACE_LEVEL_WARN,
706 "%s: Invalid context, pAdapter [%p] magic [%08x]",
707 __func__, pAdapter, pStatsContext->magic);
708 if (ioctl_debug)
709 {
710 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
711 __func__, pAdapter, pStatsContext->magic);
712 }
713 return;
714 }
715
716 /* the race is on. caller could have timed out immediately after
717 we verified the magic, but if so, caller will wait a short time
718 for us to copy over the rssi */
719 pAdapter->rssi = rssi;
720
721 /* and notify the caller */
722 complete(&pStatsContext->completion);
723}
724
725
726
727VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
728{
729 struct statsContext context;
730 hdd_context_t *pHddCtx = NULL;
731 hdd_station_ctx_t *pHddStaCtx = NULL;
732 eHalStatus hstatus;
733 long lrc;
734
735 if (NULL == pAdapter)
736 {
737 hddLog(VOS_TRACE_LEVEL_WARN,
738 "%s: Invalid context, pAdapter", __func__);
739 return VOS_STATUS_E_FAULT;
740 }
741 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
742 {
743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
744 /* return a cached value */
745 *rssi_value = pAdapter->rssi;
746 return VOS_STATUS_SUCCESS;
747 }
748
749 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
750 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
751
752 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
753 {
754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
755 /* return a cached value */
756 *rssi_value = 0;
757 return VOS_STATUS_SUCCESS;
758 }
759 init_completion(&context.completion);
760 context.pAdapter = pAdapter;
761 context.magic = RSSI_CONTEXT_MAGIC;
762
763 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
764 pHddStaCtx->conn_info.staId[ 0 ],
765 pHddStaCtx->conn_info.bssId,
766 &context, pHddCtx->pvosContext);
767 if (eHAL_STATUS_SUCCESS != hstatus)
768 {
769 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
770 __func__);
771 /* we'll returned a cached value below */
772 }
773 else
774 {
775 /* request was sent -- wait for the response */
776 lrc = wait_for_completion_interruptible_timeout(&context.completion,
777 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
778 /* either we have a response or we timed out
779 either way, first invalidate our magic */
780 context.magic = 0;
781 if (lrc <= 0)
782 {
783 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
784 __func__, (0 == lrc) ? "timeout" : "interrupt");
785 /* there is a race condition such that the callback
786 function could be executing at the same time we are. of
787 primary concern is if the callback function had already
788 verified the "magic" but hasn't yet set the completion
789 variable. Since the completion variable is on our
790 stack, we'll delay just a bit to make sure the data is
791 still valid if that is the case */
792 msleep(50);
793 /* we'll now returned a cached value below */
794 }
795 }
796 *rssi_value = pAdapter->rssi;
797
798 return VOS_STATUS_SUCCESS;
799}
800#endif
801
802
Jeff Johnson295189b2012-06-20 16:38:30 -0700803void hdd_StatisticsCB( void *pStats, void *pContext )
804{
805 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
806 hdd_stats_t *pStatsCache = NULL;
807 hdd_wext_state_t *pWextState;
808 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
809
810 tCsrSummaryStatsInfo *pSummaryStats = NULL;
811 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
812 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
813 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
814 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
815 tCsrPerStaStatsInfo *pPerStaStats = NULL;
816
817 if (pAdapter!= NULL)
818 pStatsCache = &pAdapter->hdd_stats;
819
820
821 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
822 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
823 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
824 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
825 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
826 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
827
828 if (pStatsCache!=NULL)
829 {
830 // and copy the stats into the cache we keep in the adapter instance structure
831 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
832 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
833 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
834 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
835 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
836 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
837 }
838
839 if(pAdapter)
840 {
841 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
842 if(pWextState)
843 {
844 vos_status = vos_event_set(&pWextState->vosevent);
845 if (!VOS_IS_STATUS_SUCCESS(vos_status))
846 {
847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700848 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 return;
850 }
851 }
852 }
853}
854
855void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
856{
857 v_CONTEXT_t pVosContext;
858 hdd_context_t *pHddCtx;
859 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
860#if 0
861 hdd_wext_state_t *pWextState;
862 v_U32_t roamId;
863#endif
864
865 ENTER();
866
867 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
868
869 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
870 if (NULL == pHddCtx)
871 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700872 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 return;
874 }
875#if 0
876 pWextState = pAdapter->pWextState;
877#endif
878
879 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
880 {
881 //TODO Verify is this is really used. If yes need to fix it.
882 hdd_reconnect_all_adapters( pHddCtx );
883#if 0
884 pAdapter->conn_info.connState = eConnectionState_NotConnected;
885 INIT_COMPLETION(pAdapter->disconnect_comp_var);
886 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
887
888 if(VOS_STATUS_SUCCESS == vosStatus)
889 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
890 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
891
892 sme_RoamConnect(halHandle,
893 pAdapter->sessionId, &(pWextState->roamProfile),
894 &roamId);
895#endif
896 }
897
898 EXIT();
899
900}
901
902void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
903{
904 int i = 0;
905 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
906
907 /* clear WPA/RSN/WSC IE information in the profile */
908 pWextState->roamProfile.nWPAReqIELength = 0;
909 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
910 pWextState->roamProfile.nRSNReqIELength = 0;
911 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
912
Chet Lanctot186b5732013-03-18 10:26:30 -0700913#ifdef FEATURE_WLAN_WAPI
914 pWextState->roamProfile.nWAPIReqIELength = 0;
915 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
916#endif
917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
919 pWextState->roamProfile.pAddIEScan = (tANI_U8 *)NULL;
920 pWextState->roamProfile.nAddIEScanLength = 0;
921 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
922 pWextState->roamProfile.nAddIEAssocLength = 0;
923
924 pWextState->roamProfile.EncryptionType.numEntries = 1;
925 pWextState->roamProfile.EncryptionType.encryptionType[0]
926 = eCSR_ENCRYPT_TYPE_NONE;
927
928 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
929 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
930 = eCSR_ENCRYPT_TYPE_NONE;
931
932 pWextState->roamProfile.AuthType.numEntries = 1;
933 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
934
Chet Lanctot186b5732013-03-18 10:26:30 -0700935#ifdef WLAN_FEATURE_11W
936 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
937 pWextState->roamProfile.MFPRequired = 0;
938 pWextState->roamProfile.MFPCapable = 0;
939#endif
940
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 pWextState->authKeyMgmt = 0;
942
943 for (i=0; i < CSR_MAX_NUM_KEY; i++)
944 {
945 if (pWextState->roamProfile.Keys.KeyMaterial[i])
946 {
947 pWextState->roamProfile.Keys.KeyLength[i] = 0;
948 }
949 }
950#ifdef FEATURE_WLAN_WAPI
951 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
952 pAdapter->wapi_info.nWapiMode = 0;
953#endif
954
955 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
956
957}
958
959void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
960{
961 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -0700962
Jeff Johnson9efb9aa2013-03-15 13:59:27 -0700963 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
964 {
965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
966 "%s: Invalid pAdapter magic", __func__);
967 }
968 else
969 {
970 complete(&pAdapter->ula_complete);
971 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700972}
973
974VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
975{
976 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -0700978 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700979
980 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
981 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -0700982 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -0700983
984 /*To avoid race condition between the set key and the last EAPOL
985 packet, notify TL to finish upper layer authentication incase if the
986 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -0800987 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700988
989 if ( vos_status != VOS_STATUS_SUCCESS )
990 {
991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
992 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
993 __LINE__, vos_status );
994 return vos_status;
995
996 }
997
Jeff Johnson9efb9aa2013-03-15 13:59:27 -0700998 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001000 if (0 == rc)
1001 {
1002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1003 "%s: Timeout waiting for ULA to complete", __func__);
1004 /* we'll still fall through and return success since the
1005 * connection may still get established but is just taking
1006 * too long for us to wait */
1007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 }
1009 return VOS_STATUS_SUCCESS;
1010}
1011
1012v_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)
1013{
1014
1015 int left = ie_len;
1016 v_U8_t *ptr = ie;
1017 v_U8_t elem_id,elem_len;
1018 v_U8_t eid = 0xDD;
1019
1020 if ( NULL == ie || 0 == ie_len )
1021 return NULL;
1022
1023 while(left >= 2)
1024 {
1025 elem_id = ptr[0];
1026 elem_len = ptr[1];
1027 left -= 2;
1028 if(elem_len > left)
1029 {
1030 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001031 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 eid,elem_len,left);
1033 return NULL;
1034 }
1035 if (elem_id == eid)
1036 {
1037 if(memcmp( &ptr[2], oui, oui_size)==0)
1038 return ptr;
1039 }
1040
1041 left -= elem_len;
1042 ptr += (elem_len + 2);
1043 }
1044 return NULL;
1045}
1046
1047static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1048 union iwreq_data *wrqu, char *extra)
1049{
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001050 hddLog( LOG1, "In %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 /* Do nothing for now */
1052 return 0;
1053}
1054
1055static int iw_get_name(struct net_device *dev,
1056 struct iw_request_info *info,
1057 char *wrqu, char *extra)
1058{
1059
1060 ENTER();
1061 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1062 EXIT();
1063 return 0;
1064}
1065
1066static int iw_set_mode(struct net_device *dev,
1067 struct iw_request_info *info,
1068 union iwreq_data *wrqu, char *extra)
1069{
1070 hdd_wext_state_t *pWextState;
1071 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1072 tCsrRoamProfile *pRoamProfile;
1073 eCsrRoamBssType LastBSSType;
1074 eMib_dot11DesiredBssType connectedBssType;
1075 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001077
1078 ENTER();
1079
1080 if (NULL == pAdapter)
1081 {
1082 hddLog(VOS_TRACE_LEVEL_WARN,
1083 "%s: Invalid context, pAdapter", __func__);
1084 return 0;
1085 }
1086
1087 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1089 return 0;
1090 }
1091
1092 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1093 if (pWextState == NULL)
1094 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001095 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 return -EINVAL;
1097 }
1098
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 pRoamProfile = &pWextState->roamProfile;
1101 LastBSSType = pRoamProfile->BSSType;
1102
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001103 hddLog( LOG1,"%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001104
1105 switch (wrqu->mode)
1106 {
1107 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001108 hddLog( LOG1,"%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1110 // Set the phymode correctly for IBSS.
1111 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1112 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001113 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 break;
1116 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001117 hddLog( LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 break;
1121 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001122 hddLog(LOG1,"%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1124 break;
1125 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001126 hddLog(LOG1,"%s Unknown AP Mode value", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 return -EOPNOTSUPP;
1128 }
1129
1130 if ( LastBSSType != pRoamProfile->BSSType )
1131 {
1132 //the BSS mode changed
1133 // We need to issue disconnect if connected or in IBSS disconnect state
1134 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1135 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1136 {
1137 VOS_STATUS vosStatus;
1138 // need to issue a disconnect to CSR.
1139 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1140 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1141 pAdapter->sessionId,
1142 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1143 if(VOS_STATUS_SUCCESS == vosStatus)
1144 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1145 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1146 }
1147 }
1148
1149
1150
1151 EXIT();
1152 return 0;
1153}
1154
1155
1156static int iw_get_mode(struct net_device *dev,
1157 struct iw_request_info *info,
1158 v_U32_t *uwrq, char *extra)
1159{
1160
1161 hdd_wext_state_t *pWextState;
1162 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1163
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001164 hddLog (LOG1, "In %s",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
1166 if (NULL == pAdapter)
1167 {
1168 hddLog(VOS_TRACE_LEVEL_WARN,
1169 "%s: Invalid context, pAdapter", __func__);
1170 return 0;
1171 }
1172
1173 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1175 return 0;
1176 }
1177
1178 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1179 if (pWextState == NULL)
1180 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001181 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 return -EINVAL;
1183 }
1184
1185 switch (pWextState->roamProfile.BSSType)
1186 {
1187 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001188 hddLog(LOG1, "%s returns IW_MODE_INFRA\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 *uwrq = IW_MODE_INFRA ;
1190 break;
1191 case eCSR_BSS_TYPE_IBSS:
1192 case eCSR_BSS_TYPE_START_IBSS:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001193 hddLog( LOG1,"%s returns IW_MODE_ADHOC\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 *uwrq= IW_MODE_ADHOC;
1195 break;
1196 case eCSR_BSS_TYPE_ANY:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001197 hddLog( LOG1,"%s returns IW_MODE_AUTO\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 *uwrq= IW_MODE_AUTO;
1199 break;
1200 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001201 hddLog( LOG1,"%s returns APMODE_UNKNOWN\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 break;
1203 }
1204 return 0;
1205}
1206
1207static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1208 union iwreq_data *wrqu, char *extra)
1209{
1210 v_U32_t numChans = 0;
1211 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1212 v_U32_t indx = 0;
1213 v_U32_t status = 0;
1214
1215 hdd_wext_state_t *pWextState;
1216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1217 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1218 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1219 tCsrRoamProfile * pRoamProfile;
1220 ENTER();
1221
1222 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1224 return status;
1225 }
1226
1227 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1228
1229 pRoamProfile = &pWextState->roamProfile;
1230
1231 hddLog(LOG1,"setCHANNEL ioctl\n");
1232
1233 /* Link is up then return cant set channel*/
1234 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1235 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1236 {
1237 hddLog( LOGE, "IBSS Associated\n");
1238 return -EOPNOTSUPP;
1239 }
1240
1241 /* Settings by Frequency as input */
1242 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1243 (wrqu->freq.m <= (tANI_U32)5.825e8))
1244 {
1245 tANI_U32 freq = wrqu->freq.m / 100000;
1246
1247 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1248 indx++;
1249 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1250 {
1251 return -EINVAL;
1252 }
1253 wrqu->freq.e = 0;
1254 wrqu->freq.m = freq_chan_map[indx].chan;
1255
1256 }
1257
1258 if (wrqu->freq.e == 0)
1259 {
1260 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1261 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1262 {
1263 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001264 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1266 return -EINVAL;
1267 }
1268
1269 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1270
1271 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1272 validChan, &numChans) != eHAL_STATUS_SUCCESS){
1273 return -EIO;
1274 }
1275
1276 for (indx = 0; indx < numChans; indx++) {
1277 if (wrqu->freq.m == validChan[indx]){
1278 break;
1279 }
1280 }
1281 }
1282 else{
1283
1284 return -EINVAL;
1285 }
1286
1287 if(indx >= numChans)
1288 {
1289 return -EINVAL;
1290 }
1291
1292 /* Set the Operational Channel */
1293 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1294 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1295 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1296
1297 hddLog(LOG1,"pRoamProfile->operationChannel = %d\n", wrqu->freq.m);
1298
1299 EXIT();
1300
1301 return status;
1302}
1303
1304static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1305 struct iw_freq *fwrq, char *extra)
1306{
Jeff Johnsone7245742012-09-05 17:12:55 -07001307 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1309 tHalHandle hHal;
1310 hdd_wext_state_t *pWextState;
1311 tCsrRoamProfile * pRoamProfile;
1312 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1313
1314 ENTER();
1315
1316 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1318 return status;
1319 }
1320
1321 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1322 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1323
1324 pRoamProfile = &pWextState->roamProfile;
1325
1326 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1327 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001328 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 {
1330 return -EIO;
1331 }
1332 else
1333 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001334 status = hdd_wlan_get_freq(channel, &freq);
1335 if( TRUE == status )
1336 {
1337 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1338 * iwlist & iwconfig command shows frequency into proper
1339 * format (2.412 GHz instead of 246.2 MHz)*/
1340 fwrq->m = freq;
1341 fwrq->e = MHZ;
1342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 }
1344 }
1345 else
1346 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001347 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1348 * iwlist & iwconfig command shows frequency into proper
1349 * format (2.412 GHz instead of 246.2 MHz)*/
1350 fwrq->m = 0;
1351 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001353 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001354}
1355
1356static int iw_get_tx_power(struct net_device *dev,
1357 struct iw_request_info *info,
1358 union iwreq_data *wrqu, char *extra)
1359{
1360
1361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1362 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1363 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1364
1365 if (pHddCtx->isLogpInProgress)
1366 {
1367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1368 "%s:LOGP in Progress. Ignore!!!",__func__);
1369 return -EBUSY;
1370 }
1371
1372 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1373 {
1374 wrqu->txpower.value = 0;
1375 return 0;
1376 }
1377 wlan_hdd_get_classAstats(pAdapter);
1378 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1379
1380 return 0;
1381}
1382
1383static int iw_set_tx_power(struct net_device *dev,
1384 struct iw_request_info *info,
1385 union iwreq_data *wrqu, char *extra)
1386{
1387 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1388 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1389
1390 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1391 {
1392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1393 return 0;
1394 }
1395
1396 ENTER();
1397
1398 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1399 {
1400 return -EIO;
1401 }
1402
1403 EXIT();
1404
1405 return 0;
1406}
1407
1408static int iw_get_bitrate(struct net_device *dev,
1409 struct iw_request_info *info,
1410 union iwreq_data *wrqu, char *extra)
1411{
1412 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1413 eHalStatus status = eHAL_STATUS_SUCCESS;
1414 hdd_wext_state_t *pWextState;
1415 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1416 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1417
1418 ENTER();
1419
1420 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1422 return status;
1423 }
1424
1425 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1426 wrqu->bitrate.value = 0;
1427 }
1428 else {
1429 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1430 SME_SUMMARY_STATS |
1431 SME_GLOBAL_CLASSA_STATS |
1432 SME_GLOBAL_CLASSB_STATS |
1433 SME_GLOBAL_CLASSC_STATS |
1434 SME_GLOBAL_CLASSD_STATS |
1435 SME_PER_STA_STATS,
1436 hdd_StatisticsCB, 0, FALSE,
1437 pHddStaCtx->conn_info.staId[0], pAdapter );
1438
1439 if(eHAL_STATUS_SUCCESS != status)
1440 {
1441 hddLog(VOS_TRACE_LEVEL_ERROR,
1442 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001443 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 return status;
1445 }
1446
1447 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1448
1449 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1450
1451 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1452 {
1453 hddLog(VOS_TRACE_LEVEL_ERROR,
1454 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001455 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 return VOS_STATUS_E_FAILURE;
1457 }
1458
1459 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1460 }
1461
1462 EXIT();
1463
1464 return vos_status;
1465}
1466/* ccm call back function */
1467
1468static int iw_set_bitrate(struct net_device *dev,
1469 struct iw_request_info *info,
1470 union iwreq_data *wrqu,
1471 char *extra)
1472{
1473 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1474 hdd_wext_state_t *pWextState;
1475 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1476 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1477 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1478 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1479 v_U32_t i, rate;
1480 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1481
1482 ENTER();
1483
1484 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1486 return 0;
1487 }
1488
1489 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1490
1491 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1492 {
1493 return -ENXIO ;
1494 }
1495
1496 rate = wrqu->bitrate.value;
1497
1498 if (rate == -1)
1499 {
1500 rate = WNI_CFG_FIXED_RATE_AUTO;
1501 valid_rate = TRUE;
1502 }
1503 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1504 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1505 {
1506 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1507 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1508 {
1509 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1510 WNI_CFG_SUPPORTED_RATES_11A,
1511 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1512 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1513 WNI_CFG_SUPPORTED_RATES_11B,
1514 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1515 {
1516 for (i = 0; i < (b_len + a_len); ++i)
1517 {
1518 /* supported rates returned is double the actual rate so we divide it by 2 */
1519 if ((supp_rates[i]&0x7F)/2 == rate)
1520 {
1521 valid_rate = TRUE;
1522 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1523 break;
1524 }
1525 }
1526 }
1527 }
1528 }
1529 if (valid_rate != TRUE)
1530 {
1531 return -EINVAL;
1532 }
1533 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1534 WNI_CFG_FIXED_RATE, rate,
1535 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1536 {
1537 return -EIO;
1538 }
1539 return 0;
1540}
1541
1542
1543static int iw_set_genie(struct net_device *dev,
1544 struct iw_request_info *info,
1545 union iwreq_data *wrqu,
1546 char *extra)
1547{
1548 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1549 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1550 u_int8_t *genie;
1551 v_U16_t remLen;
1552
1553 ENTER();
1554 if(!wrqu->data.length) {
1555 hdd_clearRoamProfileIe(pAdapter);
1556 EXIT();
1557 return 0;
1558 }
1559
1560 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1562 return 0;
1563 }
1564
1565 genie = wrqu->data.pointer;
1566 remLen = wrqu->data.length;
1567
1568 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]\n", genie[0], genie[1]);
1569
1570 /* clear any previous genIE before this call */
1571 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1572
1573 while (remLen >= 2)
1574 {
1575 v_U16_t eLen = 0;
1576 v_U8_t elementId;
1577 elementId = *genie++;
1578 eLen = *genie++;
1579 remLen -= 2;
1580
1581 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
1582 __func__, elementId, eLen);
1583
1584 switch ( elementId )
1585 {
1586 case IE_EID_VENDOR:
1587 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
1588 return -EINVAL;
1589
1590 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1591 {
1592 v_U16_t curGenIELen = pWextState->genIE.length;
1593 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1594 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1595
1596 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1597 {
1598 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1599 "Need bigger buffer space\n");
1600 VOS_ASSERT(0);
1601 return -ENOMEM;
1602 }
1603 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1604 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1605 pWextState->genIE.length += eLen + 2;
1606 }
1607 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1608 {
1609 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1610 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1611 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1612 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1613 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1614 }
1615 else /* any vendorId except WPA IE should be accumulated to genIE */
1616 {
1617 v_U16_t curGenIELen = pWextState->genIE.length;
1618 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1619 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1620
1621 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1622 {
1623 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1624 "Need bigger buffer space\n");
1625 VOS_ASSERT(0);
1626 return -ENOMEM;
1627 }
1628 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1629 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1630 pWextState->genIE.length += eLen + 2;
1631 }
1632 break;
1633 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001634 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1636 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1637 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1638 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1639 break;
1640
1641 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001642 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 return 0;
1644 }
1645 genie += eLen;
1646 remLen -= eLen;
1647 }
1648 EXIT();
1649 return 0;
1650}
1651
1652static int iw_get_genie(struct net_device *dev,
1653 struct iw_request_info *info,
1654 union iwreq_data *wrqu,
1655 char *extra)
1656{
1657 hdd_wext_state_t *pWextState;
1658 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1659 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1660 eHalStatus status;
1661 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1662 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1663
1664 ENTER();
1665
1666 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1668 return 0;
1669 }
1670
1671
1672 hddLog(LOG1,"getGEN_IE ioctl\n");
1673
1674 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1675
1676 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1677 {
1678 return -ENXIO;
1679 }
1680
1681 // Return something ONLY if we are associated with an RSN or WPA network
1682 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1683 pWextState->roamProfile.negotiatedAuthType))
1684 {
1685 return -ENXIO;
1686 }
1687
1688 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1689 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1690 pAdapter->sessionId,
1691 &length,
1692 genIeBytes);
1693 wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1694
1695 vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length);
1696
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001697 hddLog(LOG1,"%s: RSN IE of %d bytes returned\n", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001698
1699 EXIT();
1700
1701 return 0;
1702}
1703
1704static int iw_get_encode(struct net_device *dev,
1705 struct iw_request_info *info,
1706 struct iw_point *dwrq, char *extra)
1707{
1708 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1709 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1710 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1711 int keyId;
1712 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1713 int i;
1714
1715 ENTER();
1716
1717 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1719 return 0;
1720 }
1721
1722 keyId = pRoamProfile->Keys.defaultIndex;
1723
1724 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1725 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001726 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 return -EINVAL;
1728 }
1729
1730 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1731 {
1732 dwrq->flags |= IW_ENCODE_ENABLED;
1733 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1734 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1735
1736 dwrq->flags |= (keyId + 1);
1737
1738 }
1739 else
1740 {
1741 dwrq->flags |= IW_ENCODE_DISABLED;
1742 }
1743
1744 for(i=0; i < MAX_WEP_KEYS; i++)
1745 {
1746 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
1747 {
1748 continue;
1749 }
1750 else
1751 {
1752 break;
1753 }
1754 }
1755
1756 if(MAX_WEP_KEYS == i)
1757 {
1758 dwrq->flags |= IW_ENCODE_NOKEY;
1759 }
1760
1761 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
1762
1763 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
1764 {
1765 dwrq->flags |= IW_ENCODE_OPEN;
1766 }
1767 else
1768 {
1769 dwrq->flags |= IW_ENCODE_RESTRICTED;
1770 }
1771 EXIT();
1772 return 0;
1773}
1774
1775#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
1776#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
1777
1778
1779/*
1780 * This function sends a single 'key' to LIM at all time.
1781 */
1782
1783static int iw_get_rts_threshold(struct net_device *dev,
1784 struct iw_request_info *info,
1785 union iwreq_data *wrqu, char *extra)
1786{
1787 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1788 v_U32_t status = 0;
1789
1790 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
1791
1792 return status;
1793}
1794
1795static int iw_set_rts_threshold(struct net_device *dev,
1796 struct iw_request_info *info,
1797 union iwreq_data *wrqu, char *extra)
1798{
1799 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1800 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1801
1802 ENTER();
1803
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001804 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1805 {
1806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1807 "%s:LOGP in Progress. Ignore!!!", __func__);
1808 return -EAGAIN;
1809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
1811 {
1812 return -EINVAL;
1813 }
1814
1815 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1816 {
1817 return -EIO;
1818 }
1819
1820 EXIT();
1821
1822 return 0;
1823}
1824
1825static int iw_get_frag_threshold(struct net_device *dev,
1826 struct iw_request_info *info,
1827 union iwreq_data *wrqu, char *extra)
1828{
1829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1830 v_U32_t status = 0;
1831
1832 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
1833
1834 return status;
1835}
1836
1837static int iw_set_frag_threshold(struct net_device *dev,
1838 struct iw_request_info *info,
1839 union iwreq_data *wrqu, char *extra)
1840{
1841 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1842 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1843
1844 ENTER();
1845
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001846 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1847 {
1848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1849 "%s:LOGP in Progress. Ignore!!!", __func__);
1850 return -EBUSY;
1851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
1853 {
1854 return -EINVAL;
1855 }
1856
1857 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1858 {
1859 return -EIO;
1860 }
1861
1862 EXIT();
1863
1864 return 0;
1865}
1866
1867static int iw_get_power_mode(struct net_device *dev,
1868 struct iw_request_info *info,
1869 union iwreq_data *wrqu, char *extra)
1870{
1871 ENTER();
1872 return -EOPNOTSUPP;
1873}
1874
1875static int iw_set_power_mode(struct net_device *dev,
1876 struct iw_request_info *info,
1877 union iwreq_data *wrqu, char *extra)
1878{
1879 ENTER();
1880 return -EOPNOTSUPP;
1881}
1882
1883static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
1884 union iwreq_data *wrqu, char *extra)
1885{
1886 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1887 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1888 struct iw_range *range = (struct iw_range *) extra;
1889
1890 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1891
1892 v_U32_t num_channels = sizeof(channels);
1893 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1894 v_U32_t a_len;
1895 v_U32_t b_len;
1896 v_U32_t active_phy_mode = 0;
1897 v_U8_t index = 0, i;
1898
1899 ENTER();
1900
1901 wrqu->data.length = sizeof(struct iw_range);
1902 memset(range, 0, sizeof(struct iw_range));
1903
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001904 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1905 {
1906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1907 "%s:LOGP in Progress. Ignore!!!", __func__);
1908 return -EBUSY;
1909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001910
1911 /*Get the phy mode*/
1912 if (ccmCfgGetInt(hHal,
1913 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1914 {
1915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1916 "active_phy_mode = %ld", active_phy_mode);
1917
1918 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
1919 {
1920 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07001921 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 if (ccmCfgGetStr(hHal,
1923 WNI_CFG_SUPPORTED_RATES_11A,
1924 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
1925 {
1926 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
1927 {
1928 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1929 }
1930 for (i = 0; i < a_len; i++)
1931 {
1932 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
1933 }
1934 range->num_bitrates = a_len;
1935 }
1936 else
1937 {
1938 return -EIO;
1939 }
1940 }
1941 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1942 {
1943 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07001944 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 if (ccmCfgGetStr(hHal,
1946 WNI_CFG_SUPPORTED_RATES_11B,
1947 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
1948 {
1949 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
1950 {
1951 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1952 }
1953 for (i = 0; i < b_len; i++)
1954 {
1955 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
1956 }
1957 range->num_bitrates = b_len;
1958 }
1959 else
1960 {
1961 return -EIO;
1962 }
1963 }
1964 }
1965
1966 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
1967 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
1968 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
1969
1970 range->encoding_size[0] = 5;
1971 range->encoding_size[1] = 13;
1972 range->num_encoding_sizes = 2;
1973 range->max_encoding_tokens = MAX_WEP_KEYS;
1974
1975 // we support through Wireless Extensions 22
1976 range->we_version_compiled = WIRELESS_EXT;
1977 range->we_version_source = 22;
1978
1979 /*Supported Channels and Frequencies*/
1980 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
1981 {
1982 return -EIO;
1983 }
1984 if (num_channels > IW_MAX_FREQUENCIES)
1985 {
1986 num_channels = IW_MAX_FREQUENCIES;
1987 }
1988
1989 range->num_channels = num_channels;
1990 range->num_frequency = num_channels;
1991
1992 for (index=0; index < num_channels; index++)
1993 {
1994 v_U32_t frq_indx = 0;
1995
1996 range->freq[index].i = channels[index];
1997 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
1998 {
1999 if(channels[index] == freq_chan_map[frq_indx].chan)
2000 {
2001 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2002 range->freq[index].e = 1;
2003 break;
2004 }
2005 frq_indx++;
2006 }
2007 }
2008
2009 /* Event capability (kernel + driver) */
2010 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2011 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2012 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2013 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2014
2015 /*Encryption capability*/
2016 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2017 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2018
2019 /* Txpower capability */
2020 range->txpower_capa = IW_TXPOW_MWATT;
2021
2022 /*Scanning capability*/
2023 #if WIRELESS_EXT >= 22
2024 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2025 #endif
2026
2027 EXIT();
2028 return 0;
2029}
2030
2031/* Callback function registered with PMC to know status of PMC request */
2032static void iw_power_callback_fn (void *pContext, eHalStatus status)
2033{
2034 struct statsContext *pStatsContext;
2035 hdd_adapter_t *pAdapter;
2036
2037 if (NULL == pContext)
2038 {
2039 hddLog(VOS_TRACE_LEVEL_ERROR,
2040 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002041 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 return;
2043 }
2044
2045 /* there is a race condition that exists between this callback function
2046 and the caller since the caller could time out either before or
2047 while this code is executing. we'll assume the timeout hasn't
2048 occurred, but we'll verify that right before we save our work */
2049
2050 pStatsContext = (struct statsContext *)pContext;
2051 pAdapter = pStatsContext->pAdapter;
2052
2053 if ((NULL == pAdapter) || (POWER_CONTEXT_MAGIC != pStatsContext->magic))
2054 {
2055 /* the caller presumably timed out so there is nothing we can do */
2056 hddLog(VOS_TRACE_LEVEL_WARN,
2057 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002058 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002059
2060 if (ioctl_debug)
2061 {
2062 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002063 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 }
2065 return;
2066 }
2067
2068 /* and notify the caller */
2069 complete(&pStatsContext->completion);
2070}
2071
2072/* Callback function for tx per hit */
2073void hdd_tx_per_hit_cb (void *pCallbackContext)
2074{
2075 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2076 unsigned char tx_fail[16];
2077 union iwreq_data wrqu;
2078
2079 if (NULL == pAdapter)
2080 {
2081 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL\n");
2082 return;
2083 }
2084 memset(&wrqu, 0, sizeof(wrqu));
2085 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2086 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2087}
2088
2089void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2090{
2091 struct statsContext *pStatsContext;
2092 tCsrGlobalClassAStatsInfo *pClassAStats;
2093 hdd_adapter_t *pAdapter;
2094
2095 if (ioctl_debug)
2096 {
2097 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002098 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 }
2100
2101 if ((NULL == pStats) || (NULL == pContext))
2102 {
2103 hddLog(VOS_TRACE_LEVEL_ERROR,
2104 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002105 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 return;
2107 }
2108
2109 /* there is a race condition that exists between this callback function
2110 and the caller since the caller could time out either before or
2111 while this code is executing. we'll assume the timeout hasn't
2112 occurred, but we'll verify that right before we save our work */
2113
2114 pClassAStats = pStats;
2115 pStatsContext = pContext;
2116 pAdapter = pStatsContext->pAdapter;
2117 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2118 {
2119 /* the caller presumably timed out so there is nothing we can do */
2120 hddLog(VOS_TRACE_LEVEL_WARN,
2121 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002122 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 if (ioctl_debug)
2124 {
2125 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002126 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 }
2128 return;
2129 }
2130
2131 /* the race is on. caller could have timed out immediately after
2132 we verified the magic, but if so, caller will wait a short time
2133 for us to copy over the stats. do so as a struct copy */
2134 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2135
2136 /* and notify the caller */
2137 complete(&pStatsContext->completion);
2138}
2139
2140VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2141{
2142 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2143 eHalStatus hstatus;
2144 long lrc;
2145 struct statsContext context;
2146
2147 if (NULL == pAdapter)
2148 {
2149 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2150 return VOS_STATUS_E_FAULT;
2151 }
2152 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2153 {
2154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2155 return VOS_STATUS_SUCCESS;
2156 }
2157
2158 /* we are connected
2159 prepare our callback context */
2160 init_completion(&context.completion);
2161 context.pAdapter = pAdapter;
2162 context.magic = STATS_CONTEXT_MAGIC;
2163 /* query only for Class A statistics (which include link speed) */
2164 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2165 eCSR_HDD,
2166 SME_GLOBAL_CLASSA_STATS,
2167 hdd_GetClassA_statisticsCB,
2168 0, // not periodic
2169 FALSE, //non-cached results
2170 pHddStaCtx->conn_info.staId[0],
2171 &context);
2172 if (eHAL_STATUS_SUCCESS != hstatus)
2173 {
2174 hddLog(VOS_TRACE_LEVEL_ERROR,
2175 "%s: Unable to retrieve Class A statistics ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002176 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 /* we'll returned a cached value below */
2178 }
2179 else
2180 {
2181 /* request was sent -- wait for the response */
2182 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2183 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2184 /* either we have a response or we timed out
2185 either way, first invalidate our magic */
2186 context.magic = 0;
2187 if (lrc <= 0)
2188 {
2189 hddLog(VOS_TRACE_LEVEL_ERROR,
2190 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002191 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 /* there is a race condition such that the callback
2193 function could be executing at the same time we are. of
2194 primary concern is if the callback function had already
2195 verified the "magic" but hasn't yet set the completion
2196 variable. Since the completion variable is on our
2197 stack, we'll delay just a bit to make sure the data is
2198 still valid if that is the case */
2199 msleep(50);
2200 }
2201 }
2202 return VOS_STATUS_SUCCESS;
2203}
2204
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002205static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2206{
2207 struct statsContext *pStatsContext;
2208 tCsrSummaryStatsInfo *pSummaryStats;
2209 tCsrGlobalClassAStatsInfo *pClassAStats;
2210 hdd_adapter_t *pAdapter;
2211
2212 if (ioctl_debug)
2213 {
2214 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002215 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002216 }
2217
2218 if ((NULL == pStats) || (NULL == pContext))
2219 {
2220 hddLog(VOS_TRACE_LEVEL_ERROR,
2221 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002222 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002223 return;
2224 }
2225
2226 /* there is a race condition that exists between this callback function
2227 and the caller since the caller could time out either before or
2228 while this code is executing. we'll assume the timeout hasn't
2229 occurred, but we'll verify that right before we save our work */
2230
2231 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2232 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2233 pStatsContext = pContext;
2234 pAdapter = pStatsContext->pAdapter;
2235 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2236 {
2237 /* the caller presumably timed out so there is nothing we can do */
2238 hddLog(VOS_TRACE_LEVEL_WARN,
2239 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002240 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002241 if (ioctl_debug)
2242 {
2243 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002244 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002245 }
2246 return;
2247 }
2248
2249 /* the race is on. caller could have timed out immediately after
2250 we verified the magic, but if so, caller will wait a short time
2251 for us to copy over the stats. do so as a struct copy */
2252 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2253 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2254
2255 /* and notify the caller */
2256 complete(&pStatsContext->completion);
2257}
2258
2259VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2260{
2261 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2262 eHalStatus hstatus;
2263 long lrc;
2264 struct statsContext context;
2265
2266 if (NULL == pAdapter)
2267 {
2268 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2269 return VOS_STATUS_SUCCESS;
2270 }
2271
2272 /* we are connected
2273 prepare our callback context */
2274 init_completion(&context.completion);
2275 context.pAdapter = pAdapter;
2276 context.magic = STATS_CONTEXT_MAGIC;
2277
2278 /* query only for Summary & Class A statistics */
2279 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2280 eCSR_HDD,
2281 SME_SUMMARY_STATS |
2282 SME_GLOBAL_CLASSA_STATS,
2283 hdd_get_station_statisticsCB,
2284 0, // not periodic
2285 FALSE, //non-cached results
2286 pHddStaCtx->conn_info.staId[0],
2287 &context);
2288 if (eHAL_STATUS_SUCCESS != hstatus)
2289 {
2290 hddLog(VOS_TRACE_LEVEL_ERROR,
2291 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002292 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002293 /* we'll return with cached values */
2294 }
2295 else
2296 {
2297 /* request was sent -- wait for the response */
2298 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2299 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2300 /* either we have a response or we timed out
2301 either way, first invalidate our magic */
2302 context.magic = 0;
2303 if (lrc <= 0)
2304 {
2305 hddLog(VOS_TRACE_LEVEL_ERROR,
2306 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002307 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002308 /* there is a race condition such that the callback
2309 function could be executing at the same time we are. of
2310 primary concern is if the callback function had already
2311 verified the "magic" but hasn't yet set the completion
2312 variable. Since the completion variable is on our
2313 stack, we'll delay just a bit to make sure the data is
2314 still valid if that is the case */
2315 msleep(50);
2316 }
2317 }
2318 return VOS_STATUS_SUCCESS;
2319}
2320
2321
Jeff Johnson295189b2012-06-20 16:38:30 -07002322/*
2323 * Support for the LINKSPEED private command
2324 * Per the WiFi framework the response must be of the form
2325 * "LinkSpeed xx"
2326 */
2327static int iw_get_linkspeed(struct net_device *dev,
2328 struct iw_request_info *info,
2329 union iwreq_data *wrqu, char *extra)
2330{
2331 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2332 char *pLinkSpeed = (char*)extra;
2333 int len = sizeof(v_U16_t) + 1;
2334 v_U16_t link_speed;
2335 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2336 int rc;
2337
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002338 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2339 {
2340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2341 "%s:LOGP in Progress. Ignore!!!", __func__);
2342 return -EBUSY;
2343 }
2344
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2346 {
2347 /* we are not connected so we don't have a classAstats */
2348 link_speed = 0;
2349 }
2350 else
2351 {
2352 wlan_hdd_get_classAstats(pAdapter);
2353 //The linkspeed returned by HAL is in units of 500kbps.
2354 //converting it to mbps
2355 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2356 }
2357
2358 wrqu->data.length = len;
2359 // return the linkspeed in the format required by the WiFi Framework
2360 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
2361 if ((rc < 0) || (rc >= len))
2362 {
2363 // encoding or length error?
2364 hddLog(VOS_TRACE_LEVEL_ERROR,
2365 "%s: Unable to encode link speed, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002366 __func__,pLinkSpeed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 return -EIO;
2368 }
2369
2370 /* a value is being successfully returned */
2371 return 0;
2372}
2373
2374
2375/*
2376 * Support for the RSSI & RSSI-APPROX private commands
2377 * Per the WiFi framework the response must be of the form
2378 * "<ssid> rssi <xx>"
2379 * unless we are not associated, in which case the response is
2380 * "OK"
2381 */
2382static int iw_get_rssi(struct net_device *dev,
2383 struct iw_request_info *info,
2384 union iwreq_data *wrqu, char *extra)
2385{
2386 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2387 char *cmd = (char*)wrqu->data.pointer;
2388 int len = wrqu->data.length;
2389 v_S7_t s7Rssi = 0;
2390 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2391 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2392 VOS_STATUS vosStatus;
2393 int rc;
2394
2395 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2396 (0 == ssidlen) || (ssidlen >= len))
2397 {
2398 /* we are not connected or our SSID is too long
2399 so we cannot report an rssi */
2400 rc = snprintf(cmd, len, "OK");
2401 }
2402 else
2403 {
2404 /* we are connected with a valid SSID
2405 so we can write the SSID into the return buffer
2406 (note that it is not NUL-terminated) */
2407 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2408
2409 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2410
2411 if (VOS_STATUS_SUCCESS == vosStatus)
2412 {
2413 /* append the rssi to the ssid in the format required by
2414 the WiFI Framework */
2415 rc = snprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
2416 }
2417 else
2418 {
2419 rc = -1;
2420 }
2421 }
2422
2423 /* verify that we wrote a valid response */
2424 if ((rc < 0) || (rc >= len))
2425 {
2426 // encoding or length error?
2427 hddLog(VOS_TRACE_LEVEL_ERROR,
2428 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002429 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 return -EIO;
2431 }
2432
2433 /* a value is being successfully returned */
2434 return 0;
2435}
2436
2437/*
2438 * Support for SoftAP channel range private command
2439 */
2440static int iw_softap_set_channel_range( struct net_device *dev,
2441 int startChannel,
2442 int endChannel,
2443 int band)
2444{
Jeff Johnson43971f52012-07-17 12:26:56 -07002445 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 int ret = 0;
2447 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2448 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002449 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2450
Jeff Johnson295189b2012-06-20 16:38:30 -07002451
2452 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2453 if (VOS_STATUS_SUCCESS != status)
2454 {
2455 ret = -EINVAL;
2456 }
Yathish9f22e662012-12-10 14:21:35 -08002457 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 return ret;
2459}
2460
2461VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2462{
2463 struct statsContext context;
2464 eHalStatus status;
2465 hdd_context_t *pHddCtx;
2466
2467 if (NULL == pAdapter)
2468 {
2469 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2470 return VOS_STATUS_E_FAULT;
2471 }
2472
2473 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2474 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2475 init_completion(&context.completion);
2476
2477 context.pAdapter = pAdapter;
2478 context.magic = POWER_CONTEXT_MAGIC;
2479
2480 if (DRIVER_POWER_MODE_ACTIVE == mode)
2481 {
2482 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2483 "Full Power", __func__);
2484 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2485 iw_power_callback_fn, &context,
2486 eSME_FULL_PWR_NEEDED_BY_HDD);
2487 // Enter Full power command received from GUI this means we are disconnected
2488 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2489 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2490 if (eHAL_STATUS_PMC_PENDING == status)
2491 {
2492 int lrc = wait_for_completion_interruptible_timeout(
2493 &context.completion,
2494 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2495 context.magic = 0;
2496 if (lrc <= 0)
2497 {
2498 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002499 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 /* there is a race condition such that the callback
2501 function could be executing at the same time we are. of
2502 primary concern is if the callback function had already
2503 verified the "magic" but hasn't yet set the completion
2504 variable. Since the completion variable is on our
2505 stack, we'll delay just a bit to make sure the data is
2506 still valid if that is the case */
2507 msleep(50);
2508 /* we'll now returned a cached value below */
2509 }
2510 }
2511 }
2512 else if (DRIVER_POWER_MODE_AUTO == mode)
2513 {
2514 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2515 {
2516 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2517 __func__);
2518 // Enter BMPS command received from GUI this means DHCP is completed
2519 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2520 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2521 FALSE);
2522 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2523 iw_power_callback_fn, &context);
2524 if (eHAL_STATUS_PMC_PENDING == status)
2525 {
2526 int lrc = wait_for_completion_interruptible_timeout(
2527 &context.completion,
2528 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2529 context.magic = 0;
2530 if (lrc <= 0)
2531 {
2532 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting BMPS ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002533 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 /* there is a race condition such that the callback
2535 function could be executing at the same time we are. of
2536 primary concern is if the callback function had already
2537 verified the "magic" but hasn't yet set the completion
2538 variable. Since the completion variable is on our
2539 stack, we'll delay just a bit to make sure the data is
2540 still valid if that is the case */
2541 msleep(50);
2542 /* we'll now returned a cached value below */
2543 }
2544 }
2545 }
2546 else
2547 {
2548 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2549 "enabled in the cfg");
2550 }
2551 }
2552 return VOS_STATUS_SUCCESS;
2553}
2554
2555VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2556 hdd_adapter_t *pAdapter)
2557{
2558 VOS_STATUS vos_Status;
2559
2560 if ((NULL == pAdapter) || (NULL == pHddCtx))
2561 {
2562 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2563 return VOS_STATUS_E_FAULT;
2564 }
2565
2566 /**Exit from Deep sleep or standby if we get the driver
2567 START cmd from android GUI
2568 */
2569 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2570 {
2571 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2572 "from Stand by",__func__);
2573 vos_Status = hdd_exit_standby(pHddCtx);
2574 }
2575 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2576 {
2577 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2578 "from deep sleep",__func__);
2579 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2580 }
2581 else
2582 {
2583 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2584 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2585 vos_Status = VOS_STATUS_SUCCESS;
2586 }
2587
2588 return vos_Status;
2589}
2590
2591VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2592{
2593 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2594
2595 if (NULL == pHddCtx)
2596 {
2597 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "HDD context NULL");
2598 return VOS_STATUS_E_FAULT;
2599 }
2600
2601 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2602 {
2603 //Execute standby procedure.
2604 //Executing standby procedure will cause the STA to
2605 //disassociate first and then the chip will be put into standby.
2606 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2607 vos_Status = hdd_enter_standby(pHddCtx);
2608 }
2609 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2610 pHddCtx->cfg_ini->nEnableDriverStop)
2611 {
2612 //Execute deep sleep procedure
2613 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
2614 "deep sleep mode\n");
2615 //Deep sleep not supported
2616 vos_Status = hdd_enter_standby(pHddCtx);
2617 }
2618 else
2619 {
2620 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2621 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2622 vos_Status = VOS_STATUS_SUCCESS;
2623 }
2624
2625 return vos_Status;
2626}
2627
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002628
2629void* wlan_hdd_change_country_code_callback(void *pAdapter)
2630{
2631
2632 hdd_adapter_t *call_back_pAdapter = pAdapter;
2633
2634 complete(&call_back_pAdapter->change_country_code);
2635
2636 return NULL;
2637}
2638
Jeff Johnson295189b2012-06-20 16:38:30 -07002639static int iw_set_priv(struct net_device *dev,
2640 struct iw_request_info *info,
2641 union iwreq_data *wrqu, char *extra)
2642{
2643 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2644 char *cmd = (char*)wrqu->data.pointer;
2645 int cmd_len = wrqu->data.length;
2646 int ret = 0;
2647 int status = 0;
2648 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2649
2650 ENTER();
2651
2652 if (ioctl_debug)
2653 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002654 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 }
2656
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002657 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2658 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002659
2660 if (pHddCtx->isLogpInProgress) {
2661 if (ioctl_debug)
2662 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002663 pr_info("%s: RESTART in progress\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 }
2665
2666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2667 "%s:LOGP in Progress. Ignore!!!",__func__);
2668 return status;
2669 }
2670
2671 if(strncmp(cmd, "CSCAN",5) == 0 )
2672 {
2673 status = iw_set_cscan(dev, info, wrqu, extra);
2674 }
2675 else if( strcasecmp(cmd, "start") == 0 ) {
2676
2677 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command\n");
2678 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
2679 status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
2680
2681 if(status == VOS_STATUS_SUCCESS)
2682 {
2683 union iwreq_data wrqu;
2684 char buf[10];
2685
2686 memset(&wrqu, 0, sizeof(wrqu));
2687 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
2688 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2689 }
2690 else
2691 {
2692 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: START CMD Status %d", __func__, status);
2693 }
2694 goto done;
2695 }
2696 else if( strcasecmp(cmd, "stop") == 0 )
2697 {
2698 union iwreq_data wrqu;
2699 char buf[10];
2700
2701 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command\n");
2702
2703 wlan_hdd_enter_lowpower(pHddCtx);
2704 memset(&wrqu, 0, sizeof(wrqu));
2705 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
2706 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2707 status = VOS_STATUS_SUCCESS;
2708 goto done;
2709 }
2710 else if (strcasecmp(cmd, "macaddr") == 0)
2711 {
2712 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
2713 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
2714 }
2715 else if (strcasecmp(cmd, "scan-active") == 0)
2716 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002717 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 ret = snprintf(cmd, cmd_len, "OK");
2719 }
2720 else if (strcasecmp(cmd, "scan-passive") == 0)
2721 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002722 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 ret = snprintf(cmd, cmd_len, "OK");
2724 }
2725 else if( strcasecmp(cmd, "scan-mode") == 0 )
2726 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002727 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 }
2729 else if( strcasecmp(cmd, "linkspeed") == 0 )
2730 {
2731 status = iw_get_linkspeed(dev, info, wrqu, extra);
2732 }
2733 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
2734 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002735 long lrc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002736
2737 country_code = cmd + 8;
2738
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002739 init_completion(&pAdapter->change_country_code);
2740
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002742 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 country_code,
2744 pAdapter,
2745 pHddCtx->pvosContext);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002746
2747 /* Wait for completion */
2748 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
2749 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2750
2751 if (lrc <= 0)
2752 {
2753 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002754 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002755 }
2756
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 if( 0 != status )
2758 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002759 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2760 "%s: SME Change Country code fail \n",__func__);
2761 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 }
2763 }
2764 else if( strncasecmp(cmd, "rssi", 4) == 0 )
2765 {
2766 status = iw_get_rssi(dev, info, wrqu, extra);
2767 }
2768 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
2769 int mode;
2770 char *ptr = (char*)(cmd + 9);
2771
2772 sscanf(ptr,"%d",&mode);
2773 wlan_hdd_enter_bmps(pAdapter, mode);
2774 /*TODO:Set the power mode*/
2775 }
2776 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
2777 v_U32_t pmc_state;
2778 v_U16_t value;
2779
2780 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
2781 if(pmc_state == BMPS) {
2782 value = DRIVER_POWER_MODE_AUTO;
2783 }
2784 else {
2785 value = DRIVER_POWER_MODE_ACTIVE;
2786 }
2787 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
2788 }
2789 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
2790 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode\n");
2791 /*TODO: set the btcoexmode*/
2792 }
2793 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
2794
2795 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status\n");
2796 /*TODO: Return the btcoex status*/
2797 }
2798 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
2799
2800 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command\n");
2801
2802 /*TODO: Enable Rx data Filter*/
2803 }
2804 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
2805
2806 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command\n");
2807
2808 /*TODO: Disable Rx data Filter*/
2809 }
2810 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
2811
2812 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command\n");
2813 /*TODO: rxfilter-statistics*/
2814 }
2815 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
2816
2817 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add\n");
2818 /*TODO: rxfilter-add*/
2819 }
2820 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
2821
2822 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove\n");
2823 /*TODO: rxfilter-remove*/
2824 }
2825#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07002826 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
2827 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
2828 /*TODO: support pnosetup*/
2829 }
2830 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
2831 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
2832 /*TODO: support pnoforce*/
2833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 else if( strncasecmp(cmd, "pno",3) == 0 ) {
2835
2836 hddLog( VOS_TRACE_LEVEL_INFO, "pno\n");
2837 status = iw_set_pno(dev, info, wrqu, extra, 3);
2838 return status;
2839 }
2840 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
2841
2842 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter\n");
2843 status = iw_set_rssi_filter(dev, info, wrqu, extra, 10);
2844 return status;
2845 }
2846#endif /*FEATURE_WLAN_SCAN_PNO*/
2847 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
2848 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams\n");
2849 status = iw_set_power_params(dev, info, wrqu, extra, 11);
2850 return status;
2851 }
2852 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
2853 tSirTxPerTrackingParam tTxPerTrackingParam;
2854 char *ptr = (char*)(cmd + 18);
2855 sscanf(ptr,"%hhu %hhu %hhu %lu",&(tTxPerTrackingParam.ucTxPerTrackingEnable), &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
2856 &(tTxPerTrackingParam.ucTxPerTrackingRatio), &(tTxPerTrackingParam.uTxPerTrackingWatermark));
2857
2858 // parameters checking
2859 // period has to be larger than 0
2860 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
2861 {
2862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
2863 return VOS_STATUS_E_FAILURE;
2864 }
2865
2866 // use default value 5 is the input is not reasonable. in unit of 10%
2867 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
2868 {
2869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
2870 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
2871 }
2872
2873 // default is 5
2874 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
2875 {
2876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
2877 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
2878 }
2879
2880 status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam);
2881 if(status != eHAL_STATUS_SUCCESS){
2882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
2883 }
2884 }
2885 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002886 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
2887 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 }
2889done:
2890 /* many of the commands write information back into the command
2891 string using snprintf(). check the return value here in one
2892 place */
2893 if ((ret < 0) || (ret >= cmd_len))
2894 {
2895 /* there was an encoding error or overflow */
2896 status = -EIO;
2897 }
2898
2899 if (ioctl_debug)
2900 {
2901 pr_info("%s: rsp [%s] len [%d] status %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002902 __func__, cmd, wrqu->data.length, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 }
2904 return status;
2905
2906}
2907
2908static int iw_set_nick(struct net_device *dev,
2909 struct iw_request_info *info,
2910 union iwreq_data *wrqu, char *extra)
2911{
2912 ENTER();
2913 return 0;
2914}
2915
2916static int iw_get_nick(struct net_device *dev,
2917 struct iw_request_info *info,
2918 union iwreq_data *wrqu, char *extra)
2919{
2920 ENTER();
2921 return 0;
2922}
2923
2924static struct iw_statistics *get_wireless_stats(struct net_device *dev)
2925{
2926 ENTER();
2927 return NULL;
2928}
2929
2930static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
2931 union iwreq_data *wrqu,char *extra)
2932
2933{
2934 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2935 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2936 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2937 struct iw_point *encoderq = &(wrqu->encoding);
2938 v_U32_t keyId;
2939 v_U8_t key_length;
2940 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
2941 v_BOOL_t fKeyPresent = 0;
2942 int i;
2943 eHalStatus status = eHAL_STATUS_SUCCESS;
2944
2945
2946 ENTER();
2947
2948 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 0;
2953 }
2954
2955
2956 keyId = encoderq->flags & IW_ENCODE_INDEX;
2957
2958 if(keyId)
2959 {
2960 if(keyId > MAX_WEP_KEYS)
2961 {
2962 return -EINVAL;
2963 }
2964
2965 fKeyPresent = 1;
2966 keyId--;
2967 }
2968 else
2969 {
2970 fKeyPresent = 0;
2971 }
2972
2973
2974 if(wrqu->data.flags & IW_ENCODE_DISABLED)
2975 {
2976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****\n");
2977 if(!fKeyPresent) {
2978
2979 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
2980
2981 if(pWextState->roamProfile.Keys.KeyMaterial[i])
2982 pWextState->roamProfile.Keys.KeyLength[i] = 0;
2983 }
2984 }
2985 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
2986 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
2987 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2988 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2989
2990 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2991 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2992
2993 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
2994 {
2995 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2996 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07002997 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
2999 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3000 }
3001
3002 return status;
3003
3004 }
3005
3006 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3007 {
3008 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3009
3010 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3011
3012 }
3013
3014
3015 if(wrqu->data.length > 0)
3016 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003017 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003018
3019 key_length = wrqu->data.length;
3020
3021 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3022
3023 if(5 == key_length)
3024 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003025 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003026
3027 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3028 {
3029 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3030 }
3031 else
3032 {
3033 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3034 }
3035 }
3036 else if(13 == key_length)
3037 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003038 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003039
3040 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3041 {
3042 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3043 }
3044 else
3045 {
3046 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3047 }
3048 }
3049 else
3050 {
3051 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003052 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 return -EINVAL;
3054 }
3055
3056 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3057 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3058 pWextState->roamProfile.EncryptionType.numEntries = 1;
3059 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3060 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3061 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3062
3063 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3064 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3065 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3066 {
3067
3068 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3069
3070 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3071 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3072
3073 return status;
3074 }
3075 }
3076
3077 return 0;
3078}
3079
3080static int iw_get_encodeext(struct net_device *dev,
3081 struct iw_request_info *info,
3082 struct iw_point *dwrq,
3083 char *extra)
3084{
3085 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3086 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3087 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3088 int keyId;
3089 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3090 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3091 int i;
3092
3093 ENTER();
3094
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003095 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3096 {
3097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3098 "%s:LOGP in Progress. Ignore!!!", __func__);
3099 return -EBUSY;
3100 }
3101
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 keyId = pRoamProfile->Keys.defaultIndex;
3103
3104 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3105 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003106 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 return -EINVAL;
3108 }
3109
3110 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3111 {
3112 dwrq->flags |= IW_ENCODE_ENABLED;
3113 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
3114 palCopyMemory(dev,extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
3115 }
3116 else
3117 {
3118 dwrq->flags |= IW_ENCODE_DISABLED;
3119 }
3120
3121 for(i=0; i < MAX_WEP_KEYS; i++)
3122 {
3123 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3124 {
3125 continue;
3126 }
3127 else
3128 {
3129 break;
3130 }
3131 }
3132
3133 if(MAX_WEP_KEYS == i)
3134 {
3135 dwrq->flags |= IW_ENCODE_NOKEY;
3136 }
3137 else
3138 {
3139 dwrq->flags |= IW_ENCODE_ENABLED;
3140 }
3141
3142 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3143
3144 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3145 {
3146 dwrq->flags |= IW_ENCODE_DISABLED;
3147 }
3148
3149 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3150
3151 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3152 {
3153 dwrq->flags |= IW_ENCODE_OPEN;
3154 }
3155 else
3156 {
3157 dwrq->flags |= IW_ENCODE_RESTRICTED;
3158 }
3159 EXIT();
3160 return 0;
3161
3162}
3163
3164static int iw_set_encodeext(struct net_device *dev,
3165 struct iw_request_info *info,
3166 union iwreq_data *wrqu, char *extra)
3167{
3168 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3169 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3170 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3171 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3172
3173 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3174 v_U32_t status = 0;
3175
3176 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3177
3178 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3179
3180 int key_index;
3181 struct iw_point *encoding = &wrqu->encoding;
3182 tCsrRoamSetKey setKey;
3183 v_U32_t roamId= 0xFF;
3184 VOS_STATUS vos_status;
3185
3186 ENTER();
3187
3188 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3189 {
3190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3191 "%s:LOGP in Progress. Ignore!!!",__func__);
3192 return 0;
3193 }
3194
3195 key_index = encoding->flags & IW_ENCODE_INDEX;
3196
3197 if(key_index > 0) {
3198
3199 /*Convert from 1-based to 0-based keying*/
3200 key_index--;
3201 }
3202 if(!ext->key_len) {
3203
3204 /*Set the encrytion type to NONE*/
3205 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3206 return status;
3207 }
3208
3209 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3210 (IW_ENCODE_ALG_WEP == ext->alg))
3211 {
3212 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3213
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003214 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s \n"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 return -EINVAL;
3216 }
3217 else {
3218 /*Static wep, update the roam profile with the keys */
3219 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3220 key_index < CSR_MAX_NUM_KEY) {
3221 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3222 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3223
3224 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3225 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3226
3227 }
3228 }
3229 return status;
3230 }
3231
3232 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3233
3234 setKey.keyId = key_index;
3235 setKey.keyLength = ext->key_len;
3236
3237 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3238 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3239 }
3240
3241 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3242 /*Key direction for group is RX only*/
3243 setKey.keyDirection = eSIR_RX_ONLY;
3244 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3245 }
3246 else {
3247
3248 setKey.keyDirection = eSIR_TX_RX;
3249 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3250 }
3251
3252 /*For supplicant pae role is zero*/
3253 setKey.paeRole = 0;
3254
3255 switch(ext->alg)
3256 {
3257 case IW_ENCODE_ALG_NONE:
3258 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3259 break;
3260
3261 case IW_ENCODE_ALG_WEP:
3262 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3263 break;
3264
3265 case IW_ENCODE_ALG_TKIP:
3266 {
3267 v_U8_t *pKey = &setKey.Key[0];
3268
3269 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3270
3271 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3272
3273 /*Supplicant sends the 32bytes key in this order
3274
3275 |--------------|----------|----------|
3276 | Tk1 |TX-MIC | RX Mic |
3277 |--------------|----------|----------|
3278 <---16bytes---><--8bytes--><--8bytes-->
3279
3280 */
3281 /*Sme expects the 32 bytes key to be in the below order
3282
3283 |--------------|----------|----------|
3284 | Tk1 |RX-MIC | TX Mic |
3285 |--------------|----------|----------|
3286 <---16bytes---><--8bytes--><--8bytes-->
3287 */
3288 /* Copy the Temporal Key 1 (TK1) */
3289 vos_mem_copy(pKey,ext->key,16);
3290
3291 /*Copy the rx mic first*/
3292 vos_mem_copy(&pKey[16],&ext->key[24],8);
3293
3294 /*Copy the tx mic */
3295 vos_mem_copy(&pKey[24],&ext->key[16],8);
3296
3297 }
3298 break;
3299
3300 case IW_ENCODE_ALG_CCMP:
3301 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3302 break;
3303
3304#ifdef FEATURE_WLAN_CCX
3305#define IW_ENCODE_ALG_KRK 6
3306 case IW_ENCODE_ALG_KRK:
3307 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3308 break;
3309#endif /* FEATURE_WLAN_CCX */
3310
3311 default:
3312 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3313 break;
3314 }
3315
3316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003317 ("%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 -07003318
3319#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303320 /* The supplicant may attempt to set the PTK once pre-authentication
3321 is done. Save the key in the UMAC and include it in the ADD
3322 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303324 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303326 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3327 "%s: Update PreAuth Key success", __func__);
3328 return 0;
3329 }
3330 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3331 {
3332 hddLog(VOS_TRACE_LEVEL_ERROR,
3333 "%s: Update PreAuth Key failed", __func__);
3334 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 }
3336#endif /* WLAN_FEATURE_VOWIFI_11R */
3337
3338 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3339
3340 vos_status = wlan_hdd_check_ula_done(pAdapter);
3341 if ( vos_status != VOS_STATUS_SUCCESS )
3342 {
3343 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3344 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3345 __LINE__, vos_status );
3346
3347 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3348 }
3349
3350 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3351
3352 if ( halStatus != eHAL_STATUS_SUCCESS )
3353 {
3354 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3355 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3356 __LINE__, halStatus );
3357
3358 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3359 }
3360
3361 return halStatus;
3362}
3363
3364static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3365 union iwreq_data *wrqu, char *extra)
3366{
3367 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3368 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3369
3370 ENTER();
3371
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003372 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3373 {
3374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3375 "%s:LOGP in Progress. Ignore!!!", __func__);
3376 return -EBUSY;
3377 }
3378
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3380 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3381
3382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%ld!!\n"),wrqu->retry.value);
3383
3384 return -EINVAL;
3385 }
3386
3387 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3388
3389 if((wrqu->retry.flags & IW_RETRY_LONG))
3390 {
3391 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3392 {
3393 return -EIO;
3394 }
3395 }
3396 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3397 {
3398 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3399 {
3400 return -EIO;
3401 }
3402 }
3403 }
3404 else
3405 {
3406 return -EOPNOTSUPP;
3407 }
3408
3409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%ld!!\n"),wrqu->retry.value);
3410
3411 EXIT();
3412
3413 return 0;
3414
3415}
3416
3417static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3418 union iwreq_data *wrqu, char *extra)
3419{
3420 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3421 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3422 v_U32_t retry = 0;
3423
3424 ENTER();
3425
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003426 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3427 {
3428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3429 "%s:LOGP in Progress. Ignore!!!", __func__);
3430 return -EBUSY;
3431 }
3432
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 if((wrqu->retry.flags & IW_RETRY_LONG))
3434 {
3435 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3436
3437 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3438 {
3439 return -EIO;
3440 }
3441
3442 wrqu->retry.value = retry;
3443 }
3444 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3445 {
3446 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3447
3448 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3449 {
3450 return -EIO;
3451 }
3452
3453 wrqu->retry.value = retry;
3454 }
3455 else {
3456 return -EOPNOTSUPP;
3457 }
3458
3459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%ld!!\n"),retry);
3460
3461 EXIT();
3462
3463 return 0;
3464}
3465
3466static int iw_set_mlme(struct net_device *dev,
3467 struct iw_request_info *info,
3468 union iwreq_data *wrqu,
3469 char *extra)
3470{
3471 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3472 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3473 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3474 eHalStatus status = eHAL_STATUS_SUCCESS;
3475
3476 ENTER();
3477
3478 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3479 {
3480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3481 "%s:LOGP in Progress. Ignore!!!",__func__);
3482 return 0;
3483 }
3484
3485 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3486 switch (mlme->cmd) {
3487 case IW_MLME_DISASSOC:
3488 case IW_MLME_DEAUTH:
3489
3490 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3491 {
3492 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3493
3494 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3495 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3496
3497 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3498 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3499
Jeff Johnson43971f52012-07-17 12:26:56 -07003500 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3502 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3503 else
3504 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003505 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003506
3507 /* Resetting authKeyMgmt */
3508 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3509
3510 netif_tx_disable(dev);
3511 netif_carrier_off(dev);
3512
3513 }
3514 else
3515 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003516 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 -07003517 }
3518 break;
3519 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003520 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 return -EINVAL;
3522 }//end of switch
3523
3524 EXIT();
3525
3526 return status;
3527
3528}
3529
3530/* set param sub-ioctls */
3531static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3532 union iwreq_data *wrqu, char *extra)
3533{
3534 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3535 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3536 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3537 int *value = (int *)extra;
3538 int sub_cmd = value[0];
3539 int set_value = value[1];
3540 int ret = 0; /* success */
3541 int enable_pbm, enable_mp;
3542#ifdef CONFIG_HAS_EARLYSUSPEND
3543 v_U8_t nEnableSuspendOld;
3544#endif
3545 INIT_COMPLETION(pWextState->completion_var);
3546
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003547 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3548 {
3549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3550 "%s:LOGP in Progress. Ignore!!!", __func__);
3551 return -EBUSY;
3552 }
3553
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 switch(sub_cmd)
3555 {
3556 case WE_SET_11D_STATE:
3557 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003558 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3560
3561 sme_GetConfigParam(hHal,&smeConfig);
3562 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3563
3564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),smeConfig.csrConfig.Is11dSupportEnabled);
3565
3566 sme_UpdateConfig(hHal,&smeConfig);
3567 }
3568 else {
3569 return -EINVAL;
3570 }
3571 break;
3572 }
3573
3574 case WE_WOWL:
3575 {
3576 switch (set_value)
3577 {
3578 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003579 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 break;
3581 case 0x01:
3582 case 0x02:
3583 case 0x03:
3584 enable_mp = (set_value & 0x01) ? 1 : 0;
3585 enable_pbm = (set_value & 0x02) ? 1 : 0;
3586 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s\n",
3587 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3588 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3589 break;
3590 default:
3591 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL\n", set_value);
3592 ret = -EINVAL;
3593 break;
3594 }
3595
3596 break;
3597 }
3598 case WE_SET_POWER:
3599 {
3600 switch (set_value)
3601 {
3602 case 0: //Full Power
3603 {
3604 struct statsContext context;
3605 eHalStatus status;
3606
3607 init_completion(&context.completion);
3608
3609 context.pAdapter = pAdapter;
3610 context.magic = POWER_CONTEXT_MAGIC;
3611
3612 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3613 iw_power_callback_fn, &context,
3614 eSME_FULL_PWR_NEEDED_BY_HDD);
3615 if(eHAL_STATUS_PMC_PENDING == status)
3616 {
3617 int lrc = wait_for_completion_interruptible_timeout(
3618 &context.completion,
3619 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3620 context.magic = 0;
3621 if (lrc <= 0)
3622 {
3623 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3624 "requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003625 __func__, (0 == lrc) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 "timeout" : "interrupt");
3627 /* there is a race condition such that the callback
3628 function could be executing at the same time we are. of
3629 primary concern is if the callback function had already
3630 verified the "magic" but hasn't yet set the completion
3631 variable. Since the completion variable is on our
3632 stack, we'll delay just a bit to make sure the data is
3633 still valid if that is the case */
3634 msleep(50);
3635 /* we'll now returned a cached value below */
3636 }
3637 }
3638 hddLog(LOGE, "iwpriv Full Power completed\n");
3639 break;
3640 }
3641 case 1: //Enable BMPS
3642 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3643 break;
3644 case 2: //Disable BMPS
3645 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3646 break;
3647 case 3: //Request Bmps
3648 {
3649 struct statsContext context;
3650 eHalStatus status;
3651
3652 init_completion(&context.completion);
3653
3654 context.pAdapter = pAdapter;
3655 context.magic = POWER_CONTEXT_MAGIC;
3656
3657 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3658 iw_power_callback_fn, &context);
3659 if(eHAL_STATUS_PMC_PENDING == status)
3660 {
3661 int lrc = wait_for_completion_interruptible_timeout(
3662 &context.completion,
3663 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3664 context.magic = 0;
3665 if (lrc <= 0)
3666 {
3667 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3668 "requesting BMPS",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003669 __func__, (0 == lrc) ? "timeout" :
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 "interrupt");
3671 /* there is a race condition such that the callback
3672 function could be executing at the same time we are. of
3673 primary concern is if the callback function had already
3674 verified the "magic" but hasn't yet set the completion
3675 variable. Since the completion variable is on our
3676 stack, we'll delay just a bit to make sure the data is
3677 still valid if that is the case */
3678 msleep(50);
3679 /* we'll now returned a cached value below */
3680 }
3681 }
3682 hddLog(LOGE, "iwpriv Request BMPS completed\n");
3683 break;
3684 }
3685 case 4: //Enable IMPS
3686 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3687 break;
3688 case 5: //Disable IMPS
3689 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3690 break;
3691 case 6: //Enable Standby
3692 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3693 break;
3694 case 7: //Disable Standby
3695 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3696 break;
3697 case 8: //Request Standby
3698#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003699#endif
3700 break;
3701 case 9: //Start Auto Bmps Timer
3702 sme_StartAutoBmpsTimer(hHal);
3703 break;
3704 case 10://Stop Auto BMPS Timer
3705 sme_StopAutoBmpsTimer(hHal);
3706 break;
3707#ifdef CONFIG_HAS_EARLYSUSPEND
3708 case 11://suspend to standby
3709#ifdef CONFIG_HAS_EARLYSUSPEND
3710 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3711 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3713#endif
3714 break;
3715 case 12://suspend to deep sleep
3716#ifdef CONFIG_HAS_EARLYSUSPEND
3717 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3718 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3720#endif
3721 break;
3722 case 13://resume from suspend
3723#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003724#endif
3725 break;
3726#endif
3727 case 14://reset wlan (power down/power up)
3728 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
3729 break;
3730 default:
3731 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL\n", set_value);
3732 ret = -EINVAL;
3733 break;
3734 }
3735 break;
3736 }
3737
3738 case WE_SET_MAX_ASSOC:
3739 {
3740 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
3741 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
3742 {
3743 ret = -EINVAL;
3744 }
3745 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
3746 set_value, NULL, eANI_BOOLEAN_FALSE)
3747 != eHAL_STATUS_SUCCESS )
3748 {
3749 ret = -EIO;
3750 }
3751 break;
3752 }
3753
3754 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
3755 {
3756 if( 0 == set_value )
3757 {
3758 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
3759 }
3760 else if ( 1 == set_value )
3761 {
3762 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
3763 }
3764 else
3765 {
3766 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL\n", set_value);
3767 ret = -EINVAL;
3768 }
3769 break;
3770 }
3771
3772 case WE_SET_DATA_INACTIVITY_TO:
3773 {
3774 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
3775 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
3776 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
3777 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
3778 set_value,
3779 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
3780 {
3781 hddLog(LOGE,"Failure: Could not pass on "
3782 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
3783 "to CCM\n");
3784 ret = -EINVAL;
3785 }
3786 break;
3787 }
3788 case WE_SET_MAX_TX_POWER:
3789 {
3790 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3791 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3792
3793 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
3794 __func__, set_value);
3795 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
3796 eHAL_STATUS_SUCCESS )
3797 {
3798 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
3799 __func__);
3800 return -EIO;
3801 }
3802
3803 break;
3804 }
3805 case WE_SET_HIGHER_DTIM_TRANSITION:
3806 {
3807 if(!((set_value == eANI_BOOLEAN_FALSE) ||
3808 (set_value == eANI_BOOLEAN_TRUE)))
3809 {
3810 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
3811 ret = -EINVAL;
3812 }
3813 else
3814 {
3815 if(pAdapter->higherDtimTransition != set_value)
3816 {
3817 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003818 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 }
3820 }
3821
3822 break;
3823 }
3824
3825 case WE_SET_TM_LEVEL:
3826 {
3827 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
3828 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
3829 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
3830
3831 break;
3832 }
3833
3834 default:
3835 {
3836 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d \n",
3837 sub_cmd, set_value);
3838 break;
3839 }
3840 }
3841
3842 return ret;
3843}
3844
3845/* set param sub-ioctls */
3846static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
3847 union iwreq_data *wrqu, char *extra)
3848{
3849 VOS_STATUS vstatus;
3850 int sub_cmd = wrqu->data.flags;
3851 int ret = 0; /* success */
3852 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3853 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3854#ifdef WLAN_FEATURE_VOWIFI
3855 hdd_config_t *pConfig = pHddCtx->cfg_ini;
3856#endif /* WLAN_FEATURE_VOWIFI */
3857
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received length %d", __func__, wrqu->data.length);
3859 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 -07003860
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003861 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3862 {
3863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3864 "%s:LOGP in Progress. Ignore!!!", __func__);
3865 return -EBUSY;
3866 }
3867
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 switch(sub_cmd)
3869 {
3870 case WE_WOWL_ADD_PTRN:
3871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003872 hdd_add_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 break;
3874 case WE_WOWL_DEL_PTRN:
3875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003876 hdd_del_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 break;
3878#if defined WLAN_FEATURE_VOWIFI
3879 case WE_NEIGHBOR_REPORT_REQUEST:
3880 {
3881 tRrmNeighborReq neighborReq;
3882 tRrmNeighborRspCallbackInfo callbackInfo;
3883
3884 if (pConfig->fRrmEnable)
3885 {
3886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request\n");
3887 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
3888 if( !neighborReq.no_ssid )
3889 {
3890 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
3891 vos_mem_copy( neighborReq.ssid.ssId, wrqu->data.pointer, neighborReq.ssid.length );
3892 }
3893
3894 callbackInfo.neighborRspCallback = NULL;
3895 callbackInfo.neighborRspCallbackContext = NULL;
3896 callbackInfo.timeout = 5000; //5 seconds
3897 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
3898 }
3899 else
3900 {
3901 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled\n", __func__);
3902 ret = -EINVAL;
3903 }
3904 }
3905 break;
3906#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 case WE_SET_AP_WPS_IE:
3908 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), wrqu->data.pointer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 case WE_SET_CONFIG:
3912 vstatus = hdd_execute_config_command(pHddCtx, wrqu->data.pointer);
3913 if (VOS_STATUS_SUCCESS != vstatus)
3914 {
3915 ret = -EINVAL;
3916 }
3917 break;
3918 default:
3919 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003920 hddLog(LOGE, "%s: Invalid sub command %d\n",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 ret = -EINVAL;
3922 break;
3923 }
3924 }
3925 return ret;
3926}
3927
3928/* get param sub-ioctls */
3929static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
3930 union iwreq_data *wrqu, char *extra)
3931{
3932 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3933 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3934 int *value = (int *)extra;
3935 int ret = 0; /* success */
3936
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003937 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3938 {
3939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3940 "%s:LOGP in Progress. Ignore!!!", __func__);
3941 return -EBUSY;
3942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003943
3944 switch (value[0])
3945 {
3946 case WE_GET_11D_STATE:
3947 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003948 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003949
3950 sme_GetConfigParam(hHal,&smeConfig);
3951
3952 *value = smeConfig.csrConfig.Is11dSupportEnabled;
3953
3954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),*value);
3955
3956 break;
3957 }
3958
3959 case WE_IBSS_STATUS:
3960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****\n");
3961 break;
3962
3963 case WE_PMC_STATE:
3964 {
3965 *value = pmcGetPmcState(hHal);
3966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%ld!!\n"),*value);
3967 break;
3968 }
3969 case WE_GET_WLAN_DBG:
3970 {
3971 vos_trace_display();
3972 *value = 0;
3973 break;
3974 }
3975 case WE_MODULE_DOWN_IND:
3976 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
3979#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
3982#endif
3983 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
3984
3985 *value = 0;
3986 break;
3987 }
3988 case WE_GET_MAX_ASSOC:
3989 {
3990 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
3991 {
3992 ret = -EIO;
3993 }
3994 break;
3995 }
3996
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 case WE_GET_WDI_DBG:
3998 {
3999 wpalTraceDisplay();
4000 *value = 0;
4001 break;
4002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004003
4004 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4005 {
4006 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4007 break;
4008 }
4009 case WE_GET_CONCURRENCY_MODE:
4010 {
4011 *value = hdd_get_concurrency_mode ( );
4012
4013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d \n"),*value);
4014 break;
4015 }
4016
4017 default:
4018 {
4019 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4020 break;
4021 }
4022 }
4023
4024 return ret;
4025}
4026
4027/* set param sub-ioctls */
4028int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4029 union iwreq_data *wrqu, char *extra)
4030{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004031 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 int *value = (int *)extra;
4033 int sub_cmd = value[0];
4034 int ret = 0;
4035
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004036 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4037 {
4038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4039 "%s:LOGP in Progress. Ignore!!!", __func__);
4040 return -EBUSY;
4041 }
4042
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 switch(sub_cmd)
4044 {
4045 case WE_SET_WLAN_DBG:
4046 {
4047 vos_trace_setValue( value[1], value[2], value[3]);
4048 break;
4049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 case WE_SET_WDI_DBG:
4051 {
4052 wpalTraceSetLevel( value[1], value[2], value[3]);
4053 break;
4054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 case WE_SET_SAP_CHANNELS:
4056 {
4057 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4058 break;
4059 }
4060
4061 default:
4062 {
4063 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4064 break;
4065 }
4066 }
4067 return ret;
4068}
4069
4070static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4071 union iwreq_data *wrqu, char *extra)
4072{
4073 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4074 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004075#ifdef WLAN_FEATURE_11W
4076 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4077#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004078
4079 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4080 {
4081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4082 "%s:LOGP in Progress. Ignore!!!", __func__);
4083 return -EBUSY;
4084 }
4085
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 switch(sub_cmd)
4087 {
4088 case WE_WLAN_VERSION:
4089 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004090 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 break;
4092 }
4093
4094 case WE_GET_STATS:
4095 {
4096 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4097 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4098 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4099
4100 snprintf(extra, WE_MAX_STR_LEN,
4101 "\nTransmit"
4102 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4103 "\n dropped BK %u, BE %u, VI %u, VO %u"
4104 "\n classified BK %u, BE %u, VI %u, VO %u"
4105 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4106 "\n queued BK %u, BE %u, VI %u, VO %u"
4107 "\nfetched %u, empty %u, lowres %u, deqerr %u"
4108 "\ndequeued %u, depressured %u, completed %u, flushed %u"
4109 "\n fetched BK %u, BE %u, VI %u, VO %u"
4110 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4111 "\n depressured BK %u, BE %u, VI %u, VO %u"
4112 "\n flushed BK %u, BE %u, VI %u, VO %u"
4113 "\n\nReceive"
4114 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4115 "\n\nResetsStats"
4116 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4117 "\n",
4118 pStats->txXmitCalled,
4119 pStats->txXmitDropped,
4120 pStats->txXmitBackPressured,
4121 pStats->txXmitQueued,
4122
4123 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4124 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4125 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4126 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4127
4128 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4129 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4130 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4131 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4132
4133 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4134 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4135 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4136 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4137
4138 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4139 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4140 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4141 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4142
4143 pStats->txFetched,
4144 pStats->txFetchEmpty,
4145 pStats->txFetchLowResources,
4146 pStats->txFetchDequeueError,
4147
4148 pStats->txFetchDequeued,
4149 pStats->txFetchDePressured,
4150 pStats->txCompleted,
4151 pStats->txFlushed,
4152
4153 pStats->txFetchedAC[WLANTL_AC_BK],
4154 pStats->txFetchedAC[WLANTL_AC_BE],
4155 pStats->txFetchedAC[WLANTL_AC_VI],
4156 pStats->txFetchedAC[WLANTL_AC_VO],
4157
4158 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4159 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4160 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4161 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4162
4163 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4164 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4165 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4166 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4167
4168 pStats->txFlushedAC[WLANTL_AC_BK],
4169 pStats->txFlushedAC[WLANTL_AC_BE],
4170 pStats->txFlushedAC[WLANTL_AC_VI],
4171 pStats->txFlushedAC[WLANTL_AC_VO],
4172
4173 pStats->rxChains,
4174 pStats->rxPackets,
4175 pStats->rxDropped,
4176 pStats->rxDelivered,
4177 pStats->rxRefused,
4178
4179 pResetStats->totalLogpResets,
4180 pResetStats->totalCMD53Failures,
4181 pResetStats->totalMutexReadFailures,
4182 pResetStats->totalMIFErrorFailures,
4183 pResetStats->totalFWHearbeatFailures,
4184 pResetStats->totalUnknownExceptions
4185 );
4186 wrqu->data.length = strlen(extra)+1;
4187 break;
4188 }
4189
4190 case WE_GET_CFG:
4191 {
4192 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4193 wrqu->data.length = strlen(extra)+1;
4194 break;
4195 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004196#ifdef WLAN_FEATURE_11AC
4197 case WE_GET_RSSI:
4198 {
4199 v_S7_t s7Rssi = 0;
4200 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4201 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4202 wrqu->data.length = strlen(extra)+1;
4203 break;
4204 }
4205#endif
4206
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004207#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4208 case WE_GET_ROAM_RSSI:
4209 {
4210 v_S7_t s7Rssi = 0;
4211 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4212 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4213 wrqu->data.length = strlen(extra)+1;
4214 break;
4215 }
4216#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 case WE_GET_WMM_STATUS:
4218 {
4219 snprintf(extra, WE_MAX_STR_LEN,
4220 "\nDir: 0=up, 1=down, 3=both\n"
4221 "|------------------------|\n"
4222 "|AC | ACM |Admitted| Dir |\n"
4223 "|------------------------|\n"
4224 "|VO | %d | %3s | %d |\n"
4225 "|VI | %d | %3s | %d |\n"
4226 "|BE | %d | %3s | %d |\n"
4227 "|BK | %d | %3s | %d |\n"
4228 "|------------------------|\n",
4229 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4230 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4231 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4232 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4233 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4234 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4235 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4236 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4237 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4238 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4239 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4240 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4241
Jeff Johnsone7245742012-09-05 17:12:55 -07004242
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 wrqu->data.length = strlen(extra)+1;
4244 break;
4245 }
4246 case WE_GET_CHANNEL_LIST:
4247 {
4248 VOS_STATUS status;
4249 v_U8_t i, len;
4250 char* buf ;
4251 tChannelListInfo channel_list;
4252
4253 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
4254 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4255 {
4256 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!\n",__func__);
4257 return -EINVAL;
4258 }
4259 buf = extra;
4260
4261 /**
4262 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4263 * needed = 5 * number of channels. Check if sufficient buffer is available and
4264 * then proceed to fill the buffer.
4265 */
4266 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4267 {
4268 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Insufficient Buffer to populate channel list\n",__func__);
4269 return -EINVAL;
4270 }
4271 len = snprintf(buf, 5, "%u ", channel_list.num_channels);
4272 buf += len;
4273 for(i = 0 ; i < channel_list.num_channels; i++)
4274 {
4275 len = snprintf(buf, 5,
4276 "%u ", channel_list.channels[i]);
4277 buf += len;
4278 }
4279 wrqu->data.length = strlen(extra)+1;
4280
4281 break;
4282 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004283#ifdef FEATURE_WLAN_TDLS
4284 case WE_GET_TDLS_PEERS:
4285 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004286 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004287 break;
4288 }
4289#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004290#ifdef WLAN_FEATURE_11W
4291 case WE_GET_11W_INFO:
4292 {
4293 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4294
4295 snprintf(extra, WE_MAX_STR_LEN,
4296 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4297 "\n Number of Unprotected Disassocs %d"
4298 "\n Number of Unprotected Deauths %d",
4299 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4300 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4301 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4302 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4303 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4304
4305 wrqu->data.length = strlen(extra)+1;
4306 break;
4307 }
4308#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 default:
4310 {
4311 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4312 break;
4313 }
4314 }
4315
4316 return 0;
4317}
4318
4319/* action sub-ioctls */
4320static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4321 union iwreq_data *wrqu, char *extra)
4322{
4323 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4324 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004325 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004326
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004327 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4328 {
4329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4330 "%s:LOGP in Progress. Ignore!!!", __func__);
4331 return -EBUSY;
4332 }
4333
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 switch (sub_cmd)
4335 {
4336 case WE_CLEAR_STATS:
4337 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4340 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4341 break;
4342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 case WE_INIT_AP:
4344 {
4345 pr_info("Init AP trigger\n");
4346 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4347 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4348 break;
4349 }
4350 case WE_STOP_AP:
4351 {
4352 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
4353 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
4354 * this is a dead code and need to find the adpater by name rather than mode */
4355 hdd_adapter_t* pAdapter_to_stop =
4356 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
4357 if( pAdapter_to_stop )
4358 {
4359 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4360
4361 pr_info("Stopping AP mode\n");
4362
4363 /*Make sure that pAdapter cleaned properly*/
4364 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
4365 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
4366 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
4367
4368 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
4369 pAdapter_to_stop->macAddressCurrent.bytes);
4370 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
4371 TRUE);
4372 }
4373 else
4374 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08004375 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 }
4377
4378 break;
4379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004380#ifdef WLAN_BTAMP_FEATURE
4381 case WE_ENABLE_AMP:
4382 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 WLANBAP_RegisterWithHCI(pAdapter);
4385 break;
4386 }
4387 case WE_DISABLE_AMP:
4388 {
4389 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4390 VOS_STATUS status;
4391
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004393
4394 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4395 status = WLANBAP_StopAmp();
4396 if(VOS_STATUS_SUCCESS != status )
4397 {
4398 pHddCtx->isAmpAllowed = VOS_TRUE;
4399 hddLog(VOS_TRACE_LEVEL_FATAL,
4400 "%s: Failed to stop AMP", __func__);
4401 }
4402 else
4403 {
4404 //a state m/c implementation in PAL is TBD to avoid this delay
4405 msleep(500);
4406 pHddCtx->isAmpAllowed = VOS_FALSE;
4407 WLANBAP_DeregisterFromHCI();
4408 }
4409
4410 break;
4411 }
4412#endif
4413
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004414 case WE_ENABLE_DXE_STALL_DETECT:
4415 {
schang6295e542013-03-12 15:31:23 -07004416 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4417 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004418 break;
4419 }
4420 case WE_DISPLAY_DXE_SNAP_SHOT:
4421 {
schang6295e542013-03-12 15:31:23 -07004422 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4423 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004424 break;
4425 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07004426 case WE_SET_REASSOC_TRIGGER:
4427 {
4428 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4429 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
4430 v_U32_t roamId = 0;
4431 tCsrRoamModifyProfileFields modProfileFields;
4432 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
4433 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
4434 return 0;
4435 }
4436
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004437
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 default:
4439 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004440 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 break;
4442 }
4443 }
4444
4445 return ret;
4446}
4447
4448int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4449 union iwreq_data *wrqu, char *extra)
4450{
4451 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4452 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4453 int sub_cmd = wrqu->data.flags;
4454 int *value = (int*)wrqu->data.pointer;
4455 int apps_args[MAX_VAR_ARGS] = {0};
4456 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004457 hdd_station_ctx_t *pStaCtx = NULL ;
4458 hdd_ap_ctx_t *pAPCtx = NULL;
4459 int cmd = 0;
4460 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004461
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004462 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004463
4464 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4465 {
4466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4467 "%s:LOGP in Progress. Ignore!!!", __func__);
4468 return -EBUSY;
4469 }
4470
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 if (num_args > MAX_VAR_ARGS)
4472 {
4473 num_args = MAX_VAR_ARGS;
4474 }
4475 vos_mem_copy(apps_args, value, (sizeof(int)) * num_args);
4476
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004477 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
4478 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
4479 {
4480 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
4481 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
4482 {
4483 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4484 staId = pStaCtx->conn_info.staId[0];
4485 }
4486 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
4487 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
4488 {
4489 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4490 staId = pAPCtx->uBCStaId;
4491 }
4492 else
4493 {
4494 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
4495 return 0;
4496 }
4497 }
4498
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 switch (sub_cmd)
4500 {
4501 case WE_LOG_DUMP_CMD:
4502 {
4503 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004504 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 apps_args[3], apps_args[4]);
4506
4507 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
4508 apps_args[3], apps_args[4]);
4509
4510 }
4511 break;
4512
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 case WE_P2P_NOA_CMD:
4514 {
4515 p2p_app_setP2pPs_t p2pNoA;
4516
4517 p2pNoA.opp_ps = apps_args[0];
4518 p2pNoA.ctWindow = apps_args[1];
4519 p2pNoA.duration = apps_args[2];
4520 p2pNoA.interval = apps_args[3];
4521 p2pNoA.count = apps_args[4];
4522 p2pNoA.single_noa_duration = apps_args[5];
4523 p2pNoA.psSelection = apps_args[6];
4524
4525 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
4526 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004527 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
4529
4530 hdd_setP2pPs(dev, &p2pNoA);
4531
4532 }
4533 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004534
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004535 case WE_MCC_CONFIG_CREDENTIAL :
4536 {
4537 cmd = 287; //Command should be updated if there is any change
4538 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08004539 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004540 {
4541 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
4542 }
4543 else
4544 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304545 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160\n", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004546 return 0;
4547 }
4548 }
4549 break;
4550
4551 case WE_MCC_CONFIG_PARAMS :
4552 {
4553 cmd = 288; //command Should be updated if there is any change
4554 // in the Riva dump command
4555 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
4556 }
4557 break;
4558
Chilam NG571c65a2013-01-19 12:27:36 +05304559#ifdef FEATURE_WLAN_TDLS
4560 case WE_TDLS_CONFIG_PARAMS :
4561 {
4562 tdls_config_params_t tdlsParams;
4563
Chilam Ng01120412013-02-19 18:32:21 -08004564 tdlsParams.tdls = apps_args[0];
4565 tdlsParams.tx_period_t = apps_args[1];
4566 tdlsParams.tx_packet_n = apps_args[2];
4567 tdlsParams.discovery_period_t = apps_args[3];
4568 tdlsParams.discovery_tries_n = apps_args[4];
4569 tdlsParams.idle_timeout_t = apps_args[5];
4570 tdlsParams.idle_packet_n = apps_args[6];
4571 tdlsParams.rssi_hysteresis = apps_args[7];
4572 tdlsParams.rssi_trigger_threshold = apps_args[8];
4573 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05304574
Chilam Ng01120412013-02-19 18:32:21 -08004575 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05304576 }
4577 break;
4578#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 default:
4580 {
4581 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
4582 }
4583 break;
4584 }
4585
4586 return 0;
4587}
4588
4589
4590static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
4591 union iwreq_data *wrqu, char *extra)
4592{
4593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4594 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4595 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4596 int params[HDD_WLAN_WMM_PARAM_COUNT];
4597 sme_QosWmmTspecInfo tSpec;
4598 v_U32_t handle;
4599
4600 // make sure the application is sufficiently priviledged
4601 // note that the kernel will do this for "set" ioctls, but since
4602 // this ioctl wants to return status to user space it must be
4603 // defined as a "get" ioctl
4604 if (!capable(CAP_NET_ADMIN))
4605 {
4606 return -EPERM;
4607 }
4608
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004609 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4610 {
4611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4612 "%s:LOGP in Progress. Ignore!!!", __func__);
4613 return -EBUSY;
4614 }
4615
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 // we must be associated in order to add a tspec
4617 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4618 {
4619 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4620 return 0;
4621 }
4622
4623 // since we are defined to be a "get" ioctl, and since the number
4624 // of params exceeds the number of params that wireless extensions
4625 // will pass down in the iwreq_data, we must copy the "set" params
4626 // from user space ourselves
4627 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
4628 {
4629 // hmmm, can't get them
4630 return -EIO;
4631 }
4632
4633 // clear the tspec
4634 memset(&tSpec, 0, sizeof(tSpec));
4635
4636 // validate the handle
4637 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4638 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4639 {
4640 // that one is reserved
4641 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4642 return 0;
4643 }
4644
4645 // validate the TID
4646 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
4647 {
4648 // out of range
4649 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4650 return 0;
4651 }
4652 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
4653
4654 // validate the direction
4655 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
4656 {
4657 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
4658 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
4659 break;
4660
4661 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
4662 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
4663 break;
4664
4665 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
4666 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
4667 break;
4668
4669 default:
4670 // unknown
4671 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4672 return 0;
4673 }
4674
4675 // validate the user priority
4676 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
4677 {
4678 // out of range
4679 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4680 return 0;
4681 }
4682 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
4683
4684 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
4685 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
4686 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
4687 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
4688 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
4689 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
4690 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
4691 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
4692 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
4693 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
4694 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
4695 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
4696
4697 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
4698
4699 // validate the ts info ack policy
4700 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
4701 {
4702 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
4703 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
4704 break;
4705
4706 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
4707 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
4708 break;
4709
4710 default:
4711 // unknown
4712 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4713 return 0;
4714 }
4715
4716 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
4717 return 0;
4718}
4719
4720
4721static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
4722 union iwreq_data *wrqu, char *extra)
4723{
4724 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4725 int *params = (int *)extra;
4726 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4727 v_U32_t handle;
4728
4729 // make sure the application is sufficiently priviledged
4730 // note that the kernel will do this for "set" ioctls, but since
4731 // this ioctl wants to return status to user space it must be
4732 // defined as a "get" ioctl
4733 if (!capable(CAP_NET_ADMIN))
4734 {
4735 return -EPERM;
4736 }
4737
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004738 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4739 {
4740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4741 "%s:LOGP in Progress. Ignore!!!", __func__);
4742 return -EBUSY;
4743 }
4744
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 // although we are defined to be a "get" ioctl, the params we require
4746 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
4747 // is no need to copy the params from user space
4748
4749 // validate the handle
4750 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4751 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4752 {
4753 // that one is reserved
4754 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4755 return 0;
4756 }
4757
4758 *pStatus = hdd_wmm_delts(pAdapter, handle);
4759 return 0;
4760}
4761
4762
4763static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
4764 union iwreq_data *wrqu, char *extra)
4765{
4766 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4767 int *params = (int *)extra;
4768 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4769 v_U32_t handle;
4770
4771 // although we are defined to be a "get" ioctl, the params we require
4772 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
4773 // is no need to copy the params from user space
4774
4775 // validate the handle
4776 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4777 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4778 {
4779 // that one is reserved
4780 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4781 return 0;
4782 }
4783
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004784 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4785 {
4786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4787 "%s:LOGP in Progress. Ignore!!!", __func__);
4788 return -EBUSY;
4789 }
4790
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 *pStatus = hdd_wmm_checkts(pAdapter, handle);
4792 return 0;
4793}
4794
4795
4796#ifdef FEATURE_WLAN_WAPI
4797static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
4798 union iwreq_data *wrqu, char *extra)
4799{
4800 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4801 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4802 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4803 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4804
4805 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)wrqu->data.pointer;
4806
4807 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004808 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4809 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4810 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004811
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004812 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4813 {
4814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4815 "%s:LOGP in Progress. Ignore!!!", __func__);
4816 return -EBUSY;
4817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004818
4819 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004820 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
4822 pRoamProfile->EncryptionType.numEntries = 1;
4823 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4824 pRoamProfile->mcEncryptionType.numEntries = 1;
4825 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4826
4827 pRoamProfile->AuthType.numEntries = 1;
4828 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4829 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4830 }
4831 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004832 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 }
4834 else
4835 return -EINVAL;
4836
4837 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
4838
4839 return 0;
4840}
4841
4842static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
4843 union iwreq_data *wrqu, char *extra)
4844{
4845 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4846 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
4847
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004848 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4849 {
4850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4851 "%s:LOGP in Progress. Ignore!!!", __func__);
4852 return -EBUSY;
4853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
4855
4856 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004857 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
4859 return 0;
4860}
4861
4862static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
4863 union iwreq_data *wrqu, char *extra)
4864{
4865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4866// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
4867 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
4868 int i = 0, j = 0;
4869 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004870 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4871 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4872 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004873
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004874 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4875 {
4876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4877 "%s:LOGP in Progress. Ignore!!!", __func__);
4878 return -EBUSY;
4879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 VOS_ASSERT(pWapiAssocInfo);
4881
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004882 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x\n",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
4883 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 for(i =0 ; i < 16 ; i++)
4885 hddLog(LOG1,"akm suite[%02d]:0x%08lx",i,pWapiAssocInfo->akmSuite[i]);
4886
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004887 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 for(i =0 ; i < 16 ; i++)
4889 hddLog(LOG1, "Unicast suite[%02d]:0x%08lx",i,pWapiAssocInfo->unicastSuite[i]);
4890
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004891 hddLog(LOG1,"%s: Multicast suite:0x%08lx Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
4892 hddLog(LOG1, "%s: BKID Cnt:0x%04x\n",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 for(i = 0 ; i < 16 ; i++) {
4894 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
4895 for(j = 0 ; j < 16 ; j++)
4896 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
4897 }
4898
4899 /* We are not using the entire IE as provided by the supplicant.
4900 * This is being calculated by SME. This is the same as in the
4901 * case of WPA. Only the auth mode information needs to be
4902 * extracted here*/
4903 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004904 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
4906 }
4907
4908 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004909 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
4911 }
4912 return 0;
4913}
4914
4915static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
4916 union iwreq_data *wrqu, char *extra)
4917{
4918 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4919 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4920 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
4921 tANI_U32 roamId = 0xFF;
4922 tANI_U8 *pKeyPtr = NULL;
4923 v_BOOL_t isConnected = TRUE;
4924 tCsrRoamSetKey setKey;
4925 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
4927
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004928 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4929 {
4930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4931 "%s:LOGP in Progress. Ignore!!!", __func__);
4932 return -EBUSY;
4933 }
4934
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004936 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4937 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4938 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004939
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304940 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 -07004941 hddLog(LOG1,"Add Index:0x");
4942 for(i =0 ; i < 12 ; i++)
4943 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
4944
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004945 hddLog(LOG1,"\n%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
4947 for(i =0 ; i < 16 ; i++)
4948 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
4949
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004950 hddLog(LOG1,"\n%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
4952 for(i =0 ; i < 16 ; i++)
4953 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
4954
4955 hddLog(LOG1,"\nWAPI PN NUMBER:0x");
4956 for(i = 0 ; i < 16 ; i++)
4957 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
4958
4959 // Clear the setkey memory
4960 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4961 // Store Key ID
4962 setKey.keyId = (unsigned char)( pWapiKey->keyId );
4963 // SET WAPI Encryption
4964 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
4965 // Key Directionn both TX and RX
4966 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
4967 // the PAE role
4968 setKey.paeRole = 0 ;
4969
4970 switch ( pWapiKey->keyType )
4971 {
Chilam Ngc4244af2013-04-01 15:37:32 -07004972 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 {
4974 isConnected = hdd_connIsConnected(pHddStaCtx);
4975 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
4976 break;
4977 }
Chilam Ngc4244af2013-04-01 15:37:32 -07004978 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 {
4980 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
4981 break;
4982 }
4983 default:
4984 {
4985 //Any other option is invalid.
4986 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004987 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004988
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004989 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
4991 break; // NEED RETURN FROM HERE ????
4992 }
4993 }
4994
4995 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
4996 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
4997 pKeyPtr = setKey.Key;
4998 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
4999 pKeyPtr += pWapiKey->wpiekLen;
5000 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5001
5002 // Set the new key with SME.
5003 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5004
5005 if ( isConnected ) {
5006 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5007 if ( halStatus != eHAL_STATUS_SUCCESS )
5008 {
5009 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5010 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5011
5012 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5013 }
5014 }
5015#if 0 /// NEED TO CHECK ON THIS
5016 else
5017 {
5018 // Store the keys in the adapter to be moved to the profile & passed to
5019 // SME in the ConnectRequest if we are not yet in connected state.
5020 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5021 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5022
5023 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5024 " Saving key [idx= %d] to apply when moving to connected state ",
5025 setKey.keyId );
5026
5027 }
5028#endif
5029 return halStatus;
5030}
5031
5032static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5033 union iwreq_data *wrqu, char *extra)
5034{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005035 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005036#ifdef WLAN_DEBUG
5037 int i = 0;
5038 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) (wrqu->data.pointer);
5039#endif
5040
5041 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005042 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5043 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5044 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005045
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005046 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08lx\n", __func__,pBkid->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 hddLog(LOG1,"%s: BKID Cnt:0x%04lx",pBkid->BKIDCount);
5048
5049 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005050
5051 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5052 {
5053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5054 "%s:LOGP in Progress. Ignore!!!", __func__);
5055 return -EBUSY;
5056 }
5057
Jeff Johnson295189b2012-06-20 16:38:30 -07005058#ifdef WLAN_DEBUG
5059 for(i =0 ; i < 16 ; i++)
5060 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5061#endif
5062
5063 return 0;
5064}
5065
5066static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5067 union iwreq_data *wrqu, char *extra)
5068{
5069 /* Yet to implement this function, 19th April 2010 */
5070 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5071
5072 return 0;
5073}
5074#endif /* FEATURE_WLAN_WAPI */
5075
5076#ifdef WLAN_FEATURE_VOWIFI_11R
5077//
5078//
5079// Each time the supplicant has the auth_request or reassoc request
5080// IEs ready. This is pushed to the driver. The driver will inturn use
5081// it to send out the auth req and reassoc req for 11r FT Assoc.
5082//
5083static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5084 union iwreq_data *wrqu, char *extra)
5085{
5086 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5087 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5088 //v_CONTEXT_t pVosContext;
5089
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005090 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5091 {
5092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5093 "%s:LOGP in Progress. Ignore!!!", __func__);
5094 return -EBUSY;
5095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 if (!wrqu->data.length)
5097 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305098 hddLog(LOGE, FL("called with 0 length IEs\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 return -EINVAL;
5100 }
5101 if (wrqu->data.pointer == NULL)
5102 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305103 hddLog(LOGE, FL("called with NULL IE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 return -EINVAL;
5105 }
5106
5107 // Added for debug on reception of Re-assoc Req.
5108 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5109 {
5110 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
5111 wrqu->data.length);
5112 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
5113 }
5114
5115#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
5116 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, wrqu->data.length);
5117#endif
5118
5119 // Pass the received FT IEs to SME
5120 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, wrqu->data.pointer,
5121 wrqu->data.length);
5122
5123 return 0;
5124}
5125#endif
5126
Amar Singhalf3a6e762013-02-19 15:06:50 -08005127static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005128 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005130{
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005132 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)wrqu->data.pointer;
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005134 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005135 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyyalamudi51d87f72012-09-24 12:05:23 -07005136 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005137 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5138 int idx;
5139 eHalStatus ret_val;
Chilam Ngc4244af2013-04-01 15:37:32 -07005140 tANI_U8 mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005141
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005142 if (pHddCtx->isLogpInProgress)
5143 {
5144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5145 "%s:LOGP in Progress. Ignore!!!", __func__);
5146 return -EBUSY;
5147 }
5148
Amar Singhalf3a6e762013-02-19 15:06:50 -08005149 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005150
Amar Singhalf3a6e762013-02-19 15:06:50 -08005151 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5152 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005153 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005154 hddLog(VOS_TRACE_LEVEL_ERROR,
5155 "%s: vos_mem_alloc failed", __func__);
5156 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005157 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005158
5159 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5160
5161 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5162 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5163
5164 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5165 mc_addr_list_ptr->ulMulticastAddrCnt);
5166
5167 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005168 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005169 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5170 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5171
5172 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5173 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005174 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005175
Amar Singhalf3a6e762013-02-19 15:06:50 -08005176 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5177 vos_mem_free(mc_addr_list_ptr);
5178 if (eHAL_STATUS_SUCCESS != ret_val)
5179 {
5180 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5181 __func__);
5182 return -EINVAL;
5183 }
5184 } else {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005185
Amar Singhalf3a6e762013-02-19 15:06:50 -08005186 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5187 "%s: Set MC BC Filter Config request: %d suspend %d",
5188 __func__, pRequest->mcastBcastFilterSetting,
5189 pHddCtx->hdd_wlan_suspended);
5190
Amar Singhalf3a6e762013-02-19 15:06:50 -08005191 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting =
5192 pRequest->mcastBcastFilterSetting;
5193 pHddCtx->dynamic_mcbc_filter.enableCfg = TRUE;
5194
5195 if (pHddCtx->hdd_wlan_suspended)
5196 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005197 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5198 if (NULL == wlanRxpFilterParam)
5199 {
5200 hddLog(VOS_TRACE_LEVEL_FATAL,
5201 "%s: vos_mem_alloc failed", __func__);
5202 return -EINVAL;
5203 }
5204
Amar Singhalf3a6e762013-02-19 15:06:50 -08005205 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5206 pRequest->mcastBcastFilterSetting;
5207 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5208
5209 if ((pHddCtx->cfg_ini->fhostArpOffload) &&
5210 (eConnectionState_Associated ==
5211 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
5212 {
5213 vstatus = hdd_conf_hostarpoffload(pAdapter, TRUE);
5214 if (!VOS_IS_STATUS_SUCCESS(vstatus))
5215 {
5216 hddLog(VOS_TRACE_LEVEL_INFO,
5217 "%s:Failed to enable ARPOFFLOAD Feature %d",
5218 __func__, vstatus);
5219 }
5220 else
5221 {
5222 if (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST ==
5223 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting)
5224 {
5225 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5226 HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST;
5227 }
5228 else if (HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST ==
5229 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting)
5230 {
5231 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5232 HDD_MCASTBCASTFILTER_FILTER_NONE;
5233 }
5234 }
5235 }
5236
5237 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5238 __func__,
5239 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting,
5240 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5241 wlanRxpFilterParam->setMcstBcstFilter);
5242
Chilam Ngc4244af2013-04-01 15:37:32 -07005243 mcastBcastFilterSetting = wlanRxpFilterParam->configuredMcstBcstFilterSetting;
5244
Amar Singhalf3a6e762013-02-19 15:06:50 -08005245 if (eHAL_STATUS_SUCCESS != sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5246 wlanRxpFilterParam))
5247 {
5248 hddLog(VOS_TRACE_LEVEL_ERROR,
5249 "%s: Failure to execute set HW MC/BC Filter request",
5250 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005251 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005252 return -EINVAL;
5253 }
5254
5255 pHddCtx->dynamic_mcbc_filter.mcBcFilterSuspend =
Chilam Ngc4244af2013-04-01 15:37:32 -07005256 mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005257 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005259
5260 return 0;
5261}
5262
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005263static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
5264 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005265 union iwreq_data *wrqu, char *extra)
5266{
5267 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5268 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5269
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005270 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005271
5272 pHddCtx->dynamic_mcbc_filter.enableCfg = FALSE;
5273
5274 return 0;
5275}
5276
5277static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
5278 union iwreq_data *wrqu, char *extra)
5279{
5280 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5281 tpHostOffloadRequest pRequest = (tpHostOffloadRequest)wrqu->data.pointer;
5282 tSirHostOffloadReq offloadRequest;
5283
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005284 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5285 {
5286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5287 "%s:LOGP in Progress. Ignore!!!", __func__);
5288 return -EBUSY;
5289 }
5290
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 /* Debug display of request components. */
5292 switch (pRequest->offloadType)
5293 {
5294 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005295 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 switch (pRequest->enableOrDisable)
5297 {
5298 case WLAN_OFFLOAD_DISABLE:
5299 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
5300 break;
5301 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
5302 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
5303 case WLAN_OFFLOAD_ENABLE:
5304 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
5305 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
5306 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
5307 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
5308 }
5309 break;
5310
5311 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
5312 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005313 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 switch (pRequest->enableOrDisable)
5315 {
5316 case WLAN_OFFLOAD_DISABLE:
5317 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
5318 break;
5319 case WLAN_OFFLOAD_ENABLE:
5320 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
5321 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
5322 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
5323 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
5324 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
5325 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
5326 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
5327 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
5328 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
5329 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
5330 }
5331 }
5332
5333 /* Execute offload request. The reason that we can copy the request information
5334 from the ioctl structure to the SME structure is that they are laid out
5335 exactly the same. Otherwise, each piece of information would have to be
5336 copied individually. */
5337 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07005338 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
5339 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 {
5341 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request\n",
5342 __func__);
5343 return -EINVAL;
5344 }
5345
5346 return 0;
5347}
5348
5349static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
5350 union iwreq_data *wrqu, char *extra)
5351{
5352 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5353 tpKeepAliveRequest pRequest = (tpKeepAliveRequest)wrqu->data.pointer;
5354 tSirKeepAliveReq keepaliveRequest;
5355
5356 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5357 {
5358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005359 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 return 0;
5361 }
5362
5363 /* Debug display of request components. */
5364 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Keep Alive Request : TimePeriod %d size %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005365 __func__,pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005366
5367 switch (pRequest->packetType)
5368 {
5369 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005370 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 break;
5372
5373 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
5374
5375 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005376 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005377
5378 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
5379 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
5380 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
5381
5382 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
5383 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
5384 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
5385
5386 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
5387 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
5388 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
5389 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
5390 break;
5391
5392 }
5393
5394 /* Execute keep alive request. The reason that we can copy the request information
5395 from the ioctl structure to the SME structure is that they are laid out
5396 exactly the same. Otherwise, each piece of information would have to be
5397 copied individually. */
5398 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
5399
5400 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d\n", keepaliveRequest.timePeriod);
5401
Jeff Johnsone7245742012-09-05 17:12:55 -07005402 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
5403 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 {
5405 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive\n",
5406 __func__);
5407 return -EINVAL;
5408 }
5409
5410 return 0;
5411}
5412
5413#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -07005414int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
5415 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005416{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005417 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5418 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 int i=0;
5420
5421 if (pHddCtx->cfg_ini->disablePacketFilter)
5422 {
5423 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005424 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 return 0;
5426 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005427 if (pHddCtx->isLogpInProgress)
5428 {
5429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5430 "%s:LOGP in Progress. Ignore!!!", __func__);
5431 return -EBUSY;
5432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 /* Debug display of request components. */
5434 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005435 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07005436
5437 switch (pRequest->filterAction)
5438 {
5439 case HDD_RCV_FILTER_SET:
5440 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005441 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005442
5443 packetFilterSetReq.filterId = pRequest->filterId;
5444 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
5445 {
5446 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d\n",
5447 __func__, pRequest->numParams);
5448 return -EINVAL;
5449 }
5450 packetFilterSetReq.numFieldParams = pRequest->numParams;
5451 packetFilterSetReq.coalesceTime = 0;
5452 packetFilterSetReq.filterType = 1;
5453 for (i=0; i < pRequest->numParams; i++)
5454 {
5455 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
5456 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
5457 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
5458 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
5459 packetFilterSetReq.paramsData[i].reserved = 0;
5460
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305461 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
5463 packetFilterSetReq.filterType);
5464
5465 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d\n",
5466 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
5467
5468 memcpy(&packetFilterSetReq.paramsData[i].compareData,
5469 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
5470 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
5471 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
5472
5473 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d\n",
5474 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
5475 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
5476 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
5477
5478 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d\n",
5479 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
5480 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
5481 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
5482 }
5483
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005484 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 {
5486 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter\n",
5487 __func__);
5488 return -EINVAL;
5489 }
5490
5491 break;
5492
5493 case HDD_RCV_FILTER_CLEAR:
5494
5495 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005496 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005498 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 {
5500 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter\n",
5501 __func__);
5502 return -EINVAL;
5503 }
5504 break;
5505
5506 default :
5507 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005508 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 return -EINVAL;
5510 }
5511 return 0;
5512}
5513
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305514void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07005515{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305516 v_U8_t filterAction;
5517 tPacketFilterCfg request;
5518 v_U8_t i;
5519 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005520
5521 filterAction = set ? HDD_RCV_FILTER_SET : HDD_RCV_FILTER_CLEAR;
5522
5523 /*set mulitcast addr list*/
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305524 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 {
5526 memset(&request, 0, sizeof (tPacketFilterCfg));
5527 request.filterAction = filterAction;
5528 request.filterId = i;
5529 if (set)
5530 {
5531 request.numParams = 1;
5532 request.paramsData[0].protocolLayer = HDD_FILTER_PROTO_TYPE_MAC;
5533 request.paramsData[0].cmpFlag = HDD_FILTER_CMP_TYPE_EQUAL;
5534 request.paramsData[0].dataOffset = WLAN_HDD_80211_FRM_DA_OFFSET;
5535 request.paramsData[0].dataLength = ETH_ALEN;
5536 memcpy(&(request.paramsData[0].compareData[0]),
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305537 &(pAdapter->mc_addr_list.addr[i][0]), ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 /*set mulitcast filters*/
5539 hddLog(VOS_TRACE_LEVEL_INFO,
5540 "%s: %s multicast filter: addr ="
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305541 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 __func__, set ? "setting" : "clearing",
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305543 MAC_ADDR_ARRAY(request.paramsData[0].compareData));
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 }
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305545 wlan_hdd_set_filter(pHddCtx, &request, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 }
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305547 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005548}
5549
5550static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
5551 union iwreq_data *wrqu, char *extra)
5552{
5553 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5554 tpPacketFilterCfg pRequest = (tpPacketFilterCfg)wrqu->data.pointer;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005555
Jeff Johnsone7245742012-09-05 17:12:55 -07005556 return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005557}
5558#endif
5559static int iw_get_statistics(struct net_device *dev,
5560 struct iw_request_info *info,
5561 union iwreq_data *wrqu, char *extra)
5562{
5563
5564 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
5565 eHalStatus status = eHAL_STATUS_SUCCESS;
5566 hdd_wext_state_t *pWextState;
5567 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5568 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5569 char *p = extra;
5570 int tlen = 0;
5571 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
5572
5573 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
5574 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
5575
5576 ENTER();
5577
5578 if (pHddCtx->isLogpInProgress) {
5579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
5580 return -EINVAL;
5581 }
5582
5583 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
5584
5585 wrqu->txpower.value = 0;
5586 }
5587 else {
5588 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
5589 SME_SUMMARY_STATS |
5590 SME_GLOBAL_CLASSA_STATS |
5591 SME_GLOBAL_CLASSB_STATS |
5592 SME_GLOBAL_CLASSC_STATS |
5593 SME_GLOBAL_CLASSD_STATS |
5594 SME_PER_STA_STATS,
5595 hdd_StatisticsCB, 0, FALSE,
5596 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
5597
5598 if (eHAL_STATUS_SUCCESS != status)
5599 {
5600 hddLog(VOS_TRACE_LEVEL_ERROR,
5601 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005602 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 return -EINVAL;
5604 }
5605
5606 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5607
5608 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
5609 if (!VOS_IS_STATUS_SUCCESS(vos_status))
5610 {
5611 hddLog(VOS_TRACE_LEVEL_ERROR,
5612 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005613 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 /*Remove the SME statistics list by passing NULL in callback argument*/
5615 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
5616 SME_SUMMARY_STATS |
5617 SME_GLOBAL_CLASSA_STATS |
5618 SME_GLOBAL_CLASSB_STATS |
5619 SME_GLOBAL_CLASSC_STATS |
5620 SME_GLOBAL_CLASSD_STATS |
5621 SME_PER_STA_STATS,
5622 NULL, 0, FALSE,
5623 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
5624
5625 return -EINVAL;
5626 }
5627 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
5628 (tANI_U8) sizeof (pStats->retry_cnt),
5629 (char*) &(pStats->retry_cnt[0]),
5630 tlen);
5631
5632 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
5633 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
5634 (char*) &(pStats->multiple_retry_cnt[0]),
5635 tlen);
5636
5637 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
5638 (tANI_U8) sizeof (pStats->tx_frm_cnt),
5639 (char*) &(pStats->tx_frm_cnt[0]),
5640 tlen);
5641
5642 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
5643 (tANI_U8) sizeof (pStats->rx_frm_cnt),
5644 (char*) &(pStats->rx_frm_cnt),
5645 tlen);
5646
5647 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
5648 (tANI_U8) sizeof (pStats->frm_dup_cnt),
5649 (char*) &(pStats->frm_dup_cnt),
5650 tlen);
5651
5652 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
5653 (tANI_U8) sizeof (pStats->fail_cnt),
5654 (char*) &(pStats->fail_cnt[0]),
5655 tlen);
5656
5657 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
5658 (tANI_U8) sizeof (pStats->rts_fail_cnt),
5659 (char*) &(pStats->rts_fail_cnt),
5660 tlen);
5661
5662 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
5663 (tANI_U8) sizeof (pStats->ack_fail_cnt),
5664 (char*) &(pStats->ack_fail_cnt),
5665 tlen);
5666
5667 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
5668 (tANI_U8) sizeof (pStats->rts_succ_cnt),
5669 (char*) &(pStats->rts_succ_cnt),
5670 tlen);
5671
5672 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
5673 (tANI_U8) sizeof (pStats->rx_discard_cnt),
5674 (char*) &(pStats->rx_discard_cnt),
5675 tlen);
5676
5677 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
5678 (tANI_U8) sizeof (pStats->rx_error_cnt),
5679 (char*) &(pStats->rx_error_cnt),
5680 tlen);
5681
Jeff Johnsone7245742012-09-05 17:12:55 -07005682 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
5683 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
5684 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 tlen);
5686
5687 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
5688 (tANI_U8) sizeof (dStats->rx_byte_cnt),
5689 (char*) &(dStats->rx_byte_cnt),
5690 tlen);
5691
5692 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
5693 (tANI_U8) sizeof (dStats->rx_rate),
5694 (char*) &(dStats->rx_rate),
5695 tlen);
5696
5697 /* Transmit rate, in units of 500 kbit/sec */
5698 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
5699 (tANI_U8) sizeof (aStats->tx_rate),
5700 (char*) &(aStats->tx_rate),
5701 tlen);
5702
Jeff Johnsone7245742012-09-05 17:12:55 -07005703 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
5704 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
5705 (char*) &(dStats->rx_uc_byte_cnt[0]),
5706 tlen);
5707 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
5708 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
5709 (char*) &(dStats->rx_mc_byte_cnt),
5710 tlen);
5711 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
5712 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
5713 (char*) &(dStats->rx_bc_byte_cnt),
5714 tlen);
5715 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
5716 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
5717 (char*) &(dStats->tx_uc_byte_cnt[0]),
5718 tlen);
5719 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
5720 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
5721 (char*) &(dStats->tx_mc_byte_cnt),
5722 tlen);
5723 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
5724 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
5725 (char*) &(dStats->tx_bc_byte_cnt),
5726 tlen);
5727
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 wrqu->data.length = tlen;
5729
5730 }
5731
5732 EXIT();
5733
5734 return 0;
5735}
5736
5737
5738#ifdef FEATURE_WLAN_SCAN_PNO
5739
5740/*Max Len for PNO notification*/
5741#define MAX_PNO_NOTIFY_LEN 100
5742void found_pref_network_cb (void *callbackContext,
5743 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
5744{
5745 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
5746 union iwreq_data wrqu;
5747 char buf[MAX_PNO_NOTIFY_LEN+1];
5748
5749 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
5750 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
5751
5752 // create the event
5753 memset(&wrqu, 0, sizeof(wrqu));
5754 memset(buf, 0, sizeof(buf));
5755
5756 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
5757 pPrefNetworkFoundInd->ssId.ssId,
5758 (unsigned int)pPrefNetworkFoundInd->rssi);
5759
5760 wrqu.data.pointer = buf;
5761 wrqu.data.length = strlen(buf);
5762
5763 // send the event
5764
5765 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5766
5767}
5768
5769
5770/*string based input*/
5771VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
5772 union iwreq_data *wrqu, char *extra, int nOffset)
5773{
5774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07005775 /* pnoRequest is a large struct, so we make it static to avoid stack
5776 overflow. This API is only invoked via ioctl, so it is
5777 serialized by the kernel rtnl_lock and hence does not need to be
5778 reentrant */
5779 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 char *ptr;
5781 v_U8_t i,j, ucParams, ucMode;
5782 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5783
5784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5785 "PNO data len %d data %s",
5786 wrqu->data.length,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305787 (char *)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005788
5789 if (wrqu->data.length <= nOffset )
5790 {
5791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
5792 return VOS_STATUS_E_FAILURE;
5793 }
5794
5795 pnoRequest.enable = 0;
5796 pnoRequest.ucNetworksCount = 0;
5797 /*-----------------------------------------------------------------------
5798 Input is string based and expected to be like this:
5799
5800 <enabled> <netw_count>
5801 for each network:
5802 <ssid_len> <ssid> <authentication> <encryption>
5803 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
5804 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
5805
5806 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07005807 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 2 5 2 300 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005808
5809 this translates into:
5810 -----------------------------
5811 enable PNO
5812 look for 2 networks:
5813 test - with authentication type 0 and encryption type 0,
5814 that can be found on 3 channels: 1 6 and 11 ,
5815 SSID bcast type is unknown (directed probe will be sent if AP not found)
5816 and must meet -40dBm RSSI
5817
5818 test2 - with auth and enrytption type 4/4
5819 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
5820 bcast type is non-bcast (directed probe will be sent)
5821 and must not meet any RSSI threshold
5822
Jeff Johnson8301aa12013-03-28 14:27:29 -07005823 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 -----------------------------------------------------------------------*/
5825 ptr = (char*)(wrqu->data.pointer + nOffset);
5826
5827 sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset);
5828
5829 if ( 0 == pnoRequest.enable )
5830 {
5831 /*Disable PNO*/
5832 memset(&pnoRequest, 0, sizeof(pnoRequest));
5833 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
5834 pAdapter->sessionId,
5835 found_pref_network_cb, pAdapter);
5836 return VOS_STATUS_SUCCESS;
5837 }
5838
5839 ptr += nOffset;
5840 sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset);
5841
5842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5843 "PNO enable %d networks count %d offset %d",
5844 pnoRequest.enable,
5845 pnoRequest.ucNetworksCount,
5846 nOffset);
5847
5848 /* Parameters checking:
5849 ucNetworksCount has to be larger than 0*/
5850 if (( 0 == pnoRequest.ucNetworksCount ) ||
5851 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
5852 {
5853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
5854 return VOS_STATUS_E_FAILURE;
5855 }
5856
5857 ptr += nOffset;
5858
5859 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
5860 {
5861
5862 pnoRequest.aNetworks[i].ssId.length = 0;
5863
5864 sscanf(ptr,"%hhu %n",
5865 &(pnoRequest.aNetworks[i].ssId.length), &nOffset);
5866
5867 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
5868 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
5869 {
5870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5871 "SSID Len %d is not correct for network %d",
5872 pnoRequest.aNetworks[i].ssId.length, i);
5873 return VOS_STATUS_E_FAILURE;
5874 }
5875
5876 /*Advance to SSID*/
5877 ptr += nOffset;
5878
Jeff Johnson8301aa12013-03-28 14:27:29 -07005879 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08005880 pnoRequest.aNetworks[i].ssId.length);
5881 ptr += pnoRequest.aNetworks[i].ssId.length;
5882
5883 ucParams = sscanf(ptr,"%lu %lu %hhu %n",
5884 &(pnoRequest.aNetworks[i].authentication),
5885 &(pnoRequest.aNetworks[i].encryption),
5886 &(pnoRequest.aNetworks[i].ucChannelCount),
5887 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07005888
5889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal751e6072013-01-24 16:02:56 -08005890 "PNO len %d ssid 0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx"
5891 "auth %d encry %d channel count %d offset %d",
5892 pnoRequest.aNetworks[i].ssId.length,
5893 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
5894 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
5895 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
5896 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
5897 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
5898 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
5899 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
5900 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
5901 pnoRequest.aNetworks[i].authentication,
5902 pnoRequest.aNetworks[i].encryption,
5903 pnoRequest.aNetworks[i].ucChannelCount,
5904 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07005905
Amar Singhal751e6072013-01-24 16:02:56 -08005906 if ( 3 != ucParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 {
5908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5909 "Incorrect cmd");
5910 return VOS_STATUS_E_FAILURE;
5911 }
5912
5913 /*Advance to channel list*/
5914 ptr += nOffset;
5915
5916 if ( SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount )
5917 {
5918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5919 "Incorrect number of channels");
5920 return VOS_STATUS_E_FAILURE;
5921 }
5922
5923 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
5924 {
5925 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
5926 {
5927 sscanf(ptr,"%hhu %n",
5928 &(pnoRequest.aNetworks[i].aChannels[j]), &nOffset);
5929 /*Advance to next channel number*/
5930 ptr += nOffset;
5931 }
5932 }
5933
5934 sscanf(ptr,"%lu %n",
5935 &(pnoRequest.aNetworks[i].bcastNetwType), &nOffset);
5936
5937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5938 "PNO bcastNetwType %d offset %d",
5939 pnoRequest.aNetworks[i].bcastNetwType,
5940 nOffset );
5941
5942 /*Advance to rssi Threshold*/
5943 ptr += nOffset;
5944
5945 sscanf(ptr,"%hhu %n",
5946 &(pnoRequest.aNetworks[i].rssiThreshold), &nOffset);
5947
5948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5949 "PNO rssi %d offset %d",
5950 pnoRequest.aNetworks[i].rssiThreshold,
5951 nOffset );
5952 /*Advance to next network*/
5953 ptr += nOffset;
5954 }/*For ucNetworkCount*/
5955
5956 ucParams = sscanf(ptr,"%hhu %n",
5957 &(pnoRequest.scanTimers.ucScanTimersCount), &nOffset);
5958
5959 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07005960 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 {
5962 ptr += nOffset;
5963
Jeff Johnson8301aa12013-03-28 14:27:29 -07005964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5965 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 pnoRequest.scanTimers.ucScanTimersCount,
5967 nOffset );
5968
5969 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
5970 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07005971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 "Incorrect cmd - too many scan timers");
5973 return VOS_STATUS_E_FAILURE;
5974 }
5975
5976 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
5977 {
5978 ucParams = sscanf(ptr,"%lu %lu %n",
5979 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
5980 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
5981 &nOffset);
5982
Jeff Johnson8301aa12013-03-28 14:27:29 -07005983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5984 "PNO Timer value %d Timer repeat %d offset %d",
5985 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
5987 nOffset );
5988
5989 if ( 2 != ucParams )
5990 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07005991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 "Incorrect cmd - diff params then expected %d", ucParams);
5993 return VOS_STATUS_E_FAILURE;
5994 }
5995
5996 ptr += nOffset;
5997 }
5998
5999 }
6000 else
6001 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6003 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
6005
6006 /*Scan timers defaults to 5 minutes*/
6007 pnoRequest.scanTimers.ucScanTimersCount = 1;
6008 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
6009 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
6010 }
6011
6012 ucParams = sscanf(ptr,"%hhu %n",
6013 &(ucMode), &nOffset);
6014
6015 pnoRequest.modePNO = ucMode;
6016 /*for LA we just expose suspend option*/
6017 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
6018 {
6019 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
6020 }
6021
6022 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6023 pAdapter->sessionId,
6024 found_pref_network_cb, pAdapter);
6025
6026 return VOS_STATUS_SUCCESS;
6027}/*iw_set_pno*/
6028
6029VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
6030 union iwreq_data *wrqu, char *extra, int nOffset)
6031{
6032 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6033 v_U8_t rssiThreshold = 0;
6034 v_U8_t nRead;
6035
6036 nRead = sscanf(wrqu->data.pointer + nOffset,"%hhu",
6037 &rssiThreshold);
6038
6039 if ( 1 != nRead )
6040 {
6041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6042 "Incorrect format");
6043 return VOS_STATUS_E_FAILURE;
6044 }
6045
6046 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
6047 return VOS_STATUS_SUCCESS;
6048}
6049
6050
6051static int iw_set_pno_priv(struct net_device *dev,
6052 struct iw_request_info *info,
6053 union iwreq_data *wrqu, char *extra)
6054{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006055 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6056
6057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006059
6060 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6061 {
6062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6063 "%s:LOGP in Progress. Ignore!!!", __func__);
6064 return -EBUSY;
6065 }
6066 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006067}
6068#endif /*FEATURE_WLAN_SCAN_PNO*/
6069
6070//Common function to SetBand
6071int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
6072{
6073 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6074 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6075 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6076 tANI_U8 band = 0;
6077 eCsrBand currBand = eCSR_BAND_MAX;
6078
6079 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
6080
6081 switch(band)
6082 {
6083 case WLAN_HDD_UI_BAND_AUTO:
6084 band = eCSR_BAND_ALL;
6085 break;
6086 case WLAN_HDD_UI_BAND_5_GHZ:
6087 band = eCSR_BAND_5G;
6088 break;
6089 case WLAN_HDD_UI_BAND_2_4_GHZ:
6090 band = eCSR_BAND_24;
6091 break;
6092 default:
6093 band = eCSR_BAND_MAX;
6094 }
6095
6096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006097 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006098
6099 if (band == eCSR_BAND_MAX)
6100 {
6101 /* Received change band request with invalid band value */
6102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006103 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 return -EIO;
6105 }
6106
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006107 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
6108 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
6109 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
6110 {
6111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006112 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006113 band, pHddCtx->cfg_ini->nBandCapability);
6114 return -EIO;
6115 }
6116
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
6118 {
6119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6120 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006121 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 return -EIO;
6123 }
6124
6125 if (currBand != band)
6126 {
6127 /* Change band request received.
6128 * Abort pending scan requests, flush the existing scan results,
6129 * and change the band capability
6130 */
6131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6132 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006133 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006134
6135 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6136 {
6137 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
6138 eHalStatus status = eHAL_STATUS_SUCCESS;
6139 long lrc;
6140
6141 /* STA already connected on current band, So issue disconnect first,
6142 * then change the band*/
6143
6144 hddLog(VOS_TRACE_LEVEL_INFO,
6145 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
6146 __func__, csrGetCurrentBand(hHal), band);
6147
6148 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6149 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6150
6151 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6152 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6153
Jeff Johnson43971f52012-07-17 12:26:56 -07006154 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 {
6156 hddLog(VOS_TRACE_LEVEL_ERROR,
6157 "%s csrRoamDisconnect failure, returned %d \n",
6158 __func__, (int)status );
6159 return -EINVAL;
6160 }
6161
6162 lrc = wait_for_completion_interruptible_timeout(
6163 &pAdapter->disconnect_comp_var,
6164 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6165
6166 if(lrc <= 0) {
6167
6168 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006169 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006170
6171 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6172 }
6173 }
6174
6175 hdd_abort_mac_scan(pHddCtx);
6176 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Srinivas Girigowdade697412013-02-14 16:31:48 -08006177#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6178 sme_UpdateBgScanConfigIniChannelList(hHal, (eCsrBand) band);
6179#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 if(eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
6181 {
6182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6183 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006184 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 return -EINVAL;
6186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 }
6189 return 0;
6190}
6191
6192static int iw_set_band_config(struct net_device *dev,
6193 struct iw_request_info *info,
6194 union iwreq_data *wrqu, char *extra)
6195{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006196 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 tANI_U8 *ptr = (tANI_U8*)wrqu->data.pointer;
6198 int ret = 0;
6199
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006201
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006202 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6203 {
6204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6205 "%s:LOGP in Progress. Ignore!!!", __func__);
6206 return -EBUSY;
6207 }
6208
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 if (memcmp(ptr, "SETBAND ", 8) == 0)
6210 {
6211 /* Change band request received */
6212 ret = hdd_setBand_helper(dev, ptr);
6213 return ret;
6214
6215 }
6216 return 0;
6217}
6218
6219static int iw_set_power_params_priv(struct net_device *dev,
6220 struct iw_request_info *info,
6221 union iwreq_data *wrqu, char *extra)
6222{
6223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6224 "Set power params Private");
6225 return iw_set_power_params(dev,info,wrqu,extra,0);
6226}
6227
6228
6229
6230/*string based input*/
6231VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
6232 union iwreq_data *wrqu, char *extra, int nOffset)
6233{
6234 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6235 tSirSetPowerParamsReq powerRequest;
6236 char *ptr;
6237 v_U8_t ucType;
6238 v_U32_t uTotalSize, uValue;
6239 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6240
6241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6242 "Power Params data len %d data %s",
6243 wrqu->data.length,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306244 (char *)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006245
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006246 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6247 {
6248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6249 "%s:LOGP in Progress. Ignore!!!", __func__);
6250 return -EBUSY;
6251 }
6252
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 if (wrqu->data.length <= nOffset )
6254 {
6255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
6256 return VOS_STATUS_E_FAILURE;
6257 }
6258
6259 uTotalSize = wrqu->data.length - nOffset;
6260
6261 /*-----------------------------------------------------------------------
6262 Input is string based and expected to be like this:
6263
6264 <param_type> <param_value> <param_type> <param_value> ...
6265
6266 e.g:
6267 1 2 2 3 3 0 4 1 5 1
6268
6269 e.g. setting just a few:
6270 1 2 4 1
6271
6272 parameter types:
6273 -----------------------------
6274 1 - Ignore DTIM
6275 2 - Listen Interval
6276 3 - Broadcast Multicas Filter
6277 4 - Beacon Early Termination
6278 5 - Beacon Early Termination Interval
6279 -----------------------------------------------------------------------*/
6280 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
6281 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
6282 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
6283 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
6284 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
6285
6286 ptr = (char*)(wrqu->data.pointer + nOffset);
6287
6288 while ( uTotalSize )
6289 {
6290 sscanf(ptr,"%hhu %n", &(ucType), &nOffset);
6291
6292 uTotalSize -= nOffset;
6293
6294 if (!uTotalSize)
6295 {
6296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006297 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 ucType, nOffset);
6299 return VOS_STATUS_E_FAILURE;
6300 }
6301
6302 ptr += nOffset;
6303 sscanf(ptr,"%lu %n", &(uValue), &nOffset);
6304
6305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6306 "Power request parameter %d value %d offset %d",
6307 ucType, uValue, nOffset);
6308
6309 switch (ucType)
6310 {
6311 case eSIR_IGNORE_DTIM:
6312 powerRequest.uIgnoreDTIM = uValue;
6313 break;
6314 case eSIR_LISTEN_INTERVAL:
6315 powerRequest.uListenInterval = uValue;
6316 break;
6317 case eSIR_MCAST_BCAST_FILTER:
6318 powerRequest.uBcastMcastFilter = uValue;
6319 break;
6320 case eSIR_ENABLE_BET:
6321 powerRequest.uEnableBET = uValue;
6322 break;
6323 case eSIR_BET_INTERVAL:
6324 powerRequest.uBETInterval = uValue;
6325 break;
6326 default:
6327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006328 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006329 ucType, uValue, nOffset);
6330 return VOS_STATUS_E_FAILURE;
6331 }
6332
6333 uTotalSize -= nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07006334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6335 "Power request parameter %d Total size",
6336 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07006338 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
6339 if(!(uTotalSize - nOffset) &&
6340 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
6341 {
6342 uTotalSize = 0;
6343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006344
6345 }/*Go for as long as we have a valid string*/
6346
6347 /* put the device into full power*/
6348 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6349
6350 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006351 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006352
6353 /* put the device back to power save*/
6354 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6355
6356 return VOS_STATUS_SUCCESS;
6357}/*iw_set_power_params*/
6358
6359
6360// Define the Wireless Extensions to the Linux Network Device structure
6361// A number of these routines are NULL (meaning they are not implemented.)
6362
6363static const iw_handler we_handler[] =
6364{
6365 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
6366 (iw_handler) iw_get_name, /* SIOCGIWNAME */
6367 (iw_handler) NULL, /* SIOCSIWNWID */
6368 (iw_handler) NULL, /* SIOCGIWNWID */
6369 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
6370 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
6371 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
6372 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
6373 (iw_handler) NULL, /* SIOCSIWSENS */
6374 (iw_handler) NULL, /* SIOCGIWSENS */
6375 (iw_handler) NULL, /* SIOCSIWRANGE */
6376 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
6377 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
6378 (iw_handler) NULL, /* SIOCGIWPRIV */
6379 (iw_handler) NULL, /* SIOCSIWSTATS */
6380 (iw_handler) NULL, /* SIOCGIWSTATS */
6381 iw_handler_set_spy, /* SIOCSIWSPY */
6382 iw_handler_get_spy, /* SIOCGIWSPY */
6383 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
6384 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
6385 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
6386 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
6387 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
6388 (iw_handler) NULL, /* SIOCGIWAPLIST */
6389 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
6390 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
6391 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
6392 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
6393 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
6394 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
6395 (iw_handler) NULL, /* -- hole -- */
6396 (iw_handler) NULL, /* -- hole -- */
6397 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
6398 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
6399 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
6400 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
6401 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
6402 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
6403 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
6404 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
6405 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
6406 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
6407 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
6408 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
6409 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
6410 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
6411 (iw_handler) NULL, /* -- hole -- */
6412 (iw_handler) NULL, /* -- hole -- */
6413 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
6414 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
6415 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
6416 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
6417 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
6418 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
6419 (iw_handler) NULL, /* SIOCSIWPMKSA */
6420};
6421
6422static const iw_handler we_private[] = {
6423
6424 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
6425 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
6426 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
6427 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
6428 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
6429 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
6430 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
6431 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
6432 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
6433 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07006434#ifdef FEATURE_OEM_DATA_SUPPORT
6435 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
6436 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
6437#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006438
6439#ifdef FEATURE_WLAN_WAPI
6440 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
6441 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
6442 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
6443 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
6444 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
6445 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
6446#endif /* FEATURE_WLAN_WAPI */
6447#ifdef WLAN_FEATURE_VOWIFI_11R
6448 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
6449#endif
6450 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
6451 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
6452 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
6453#ifdef WLAN_FEATURE_PACKET_FILTERING
6454 ,
6455 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
6456#endif
6457#ifdef FEATURE_WLAN_SCAN_PNO
6458 ,
6459 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
6460#endif
6461 ,
6462 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
6463 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
6464 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
6465 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006466 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07006467};
6468
6469/*Maximum command length can be only 15 */
6470static const struct iw_priv_args we_private_args[] = {
6471
6472 /* handlers for main ioctl */
6473 { WLAN_PRIV_SET_INT_GET_NONE,
6474 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6475 0,
6476 "" },
6477
6478 /* handlers for sub-ioctl */
6479 { WE_SET_11D_STATE,
6480 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6481 0,
6482 "set11Dstate" },
6483
6484 { WE_WOWL,
6485 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6486 0,
6487 "wowl" },
6488
6489 { WE_SET_POWER,
6490 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6491 0,
6492 "setPower" },
6493
6494 { WE_SET_MAX_ASSOC,
6495 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6496 0,
6497 "setMaxAssoc" },
6498
6499 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
6500 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6501 0,
6502 "setAutoChannel" },
6503
6504 { WE_SET_DATA_INACTIVITY_TO,
6505 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6506 0,
6507 "inactivityTO" },
6508
6509 { WE_SET_MAX_TX_POWER,
6510 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6511 0,
6512 "setMaxTxPower" },
6513 /* set Higher DTIM Transition (DTIM1 to DTIM3)
6514 * 1 = enable and 0 = disable */
6515 {
6516 WE_SET_HIGHER_DTIM_TRANSITION,
6517 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6518 0,
6519 "setHDtimTransn" },
6520
6521 { WE_SET_TM_LEVEL,
6522 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6523 0,
6524 "setTmLevel" },
6525
6526 /* handlers for main ioctl */
6527 { WLAN_PRIV_SET_NONE_GET_INT,
6528 0,
6529 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6530 "" },
6531
6532 /* handlers for sub-ioctl */
6533 { WE_GET_11D_STATE,
6534 0,
6535 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6536 "get11Dstate" },
6537
6538 { WE_IBSS_STATUS,
6539 0,
6540 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6541 "getAdhocStatus" },
6542
6543 { WE_PMC_STATE,
6544 0,
6545 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6546 "pmcState" },
6547
6548 { WE_GET_WLAN_DBG,
6549 0,
6550 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6551 "getwlandbg" },
6552
6553 { WE_MODULE_DOWN_IND,
6554 0,
6555 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6556 "moduleDownInd" },
6557
6558 { WE_GET_MAX_ASSOC,
6559 0,
6560 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6561 "getMaxAssoc" },
6562
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 { WE_GET_WDI_DBG,
6564 0,
6565 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6566 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07006567
6568 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
6569 0,
6570 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6571 "getAutoChannel" },
6572
6573 { WE_GET_CONCURRENCY_MODE,
6574 0,
6575 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6576 "getconcurrency" },
6577
6578 /* handlers for main ioctl */
6579 { WLAN_PRIV_SET_CHAR_GET_NONE,
6580 IW_PRIV_TYPE_CHAR| 512,
6581 0,
6582 "" },
6583
6584 /* handlers for sub-ioctl */
6585 { WE_WOWL_ADD_PTRN,
6586 IW_PRIV_TYPE_CHAR| 512,
6587 0,
6588 "wowlAddPtrn" },
6589
6590 { WE_WOWL_DEL_PTRN,
6591 IW_PRIV_TYPE_CHAR| 512,
6592 0,
6593 "wowlDelPtrn" },
6594
6595#if defined WLAN_FEATURE_VOWIFI
6596 /* handlers for sub-ioctl */
6597 { WE_NEIGHBOR_REPORT_REQUEST,
6598 IW_PRIV_TYPE_CHAR | 512,
6599 0,
6600 "neighbor" },
6601#endif
6602 { WE_SET_AP_WPS_IE,
6603 IW_PRIV_TYPE_CHAR| 512,
6604 0,
6605 "set_ap_wps_ie" },
6606
6607 { WE_SET_CONFIG,
6608 IW_PRIV_TYPE_CHAR| 512,
6609 0,
6610 "setConfig" },
6611
6612 /* handlers for main ioctl */
6613 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
6614 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6615 0,
6616 "" },
6617
6618 /* handlers for sub-ioctl */
6619 { WE_SET_WLAN_DBG,
6620 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6621 0,
6622 "setwlandbg" },
6623
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 { WE_SET_WDI_DBG,
6625 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6626 0,
6627 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07006628
6629 { WE_SET_SAP_CHANNELS,
6630 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6631 0,
6632 "setsapchannels" },
6633
6634 /* handlers for main ioctl */
6635 { WLAN_PRIV_GET_CHAR_SET_NONE,
6636 0,
6637 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6638 "" },
6639
6640 /* handlers for sub-ioctl */
6641 { WE_WLAN_VERSION,
6642 0,
6643 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6644 "version" },
6645 { WE_GET_STATS,
6646 0,
6647 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6648 "getStats" },
6649 { WE_GET_CFG,
6650 0,
6651 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6652 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07006653#ifdef WLAN_FEATURE_11AC
6654 { WE_GET_RSSI,
6655 0,
6656 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6657 "getRSSI" },
6658#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006659#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
6660 { WE_GET_ROAM_RSSI,
6661 0,
6662 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6663 "getRoamRSSI" },
6664#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 { WE_GET_WMM_STATUS,
6666 0,
6667 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6668 "getWmmStatus" },
6669 {
6670 WE_GET_CHANNEL_LIST,
6671 0,
6672 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6673 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006674#ifdef FEATURE_WLAN_TDLS
6675 {
6676 WE_GET_TDLS_PEERS,
6677 0,
6678 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6679 "getTdlsPeers" },
6680#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006681#ifdef WLAN_FEATURE_11W
6682 {
6683 WE_GET_11W_INFO,
6684 0,
6685 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6686 "getPMFInfo" },
6687#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 /* handlers for main ioctl */
6689 { WLAN_PRIV_SET_NONE_GET_NONE,
6690 0,
6691 0,
6692 "" },
6693
6694 /* handlers for sub-ioctl */
6695 { WE_CLEAR_STATS,
6696 0,
6697 0,
6698 "clearStats" },
6699 { WE_INIT_AP,
6700 0,
6701 0,
6702 "initAP" },
6703 { WE_STOP_AP,
6704 0,
6705 0,
6706 "exitAP" },
6707 { WE_ENABLE_AMP,
6708 0,
6709 0,
6710 "enableAMP" },
6711 { WE_DISABLE_AMP,
6712 0,
6713 0,
6714 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006715 { WE_ENABLE_DXE_STALL_DETECT,
6716 0,
6717 0,
6718 "dxeStallDetect" },
6719 { WE_DISPLAY_DXE_SNAP_SHOT,
6720 0,
6721 0,
6722 "dxeSnapshot" },
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07006723 {
6724 WE_SET_REASSOC_TRIGGER,
6725 0,
6726 0,
6727 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07006728
6729 /* handlers for main ioctl */
6730 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
6731 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6732 0,
6733 "" },
6734
6735 /* handlers for sub-ioctl */
6736 { WE_LOG_DUMP_CMD,
6737 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6738 0,
6739 "dump" },
6740
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006741 /* handlers for sub ioctl */
6742 {
6743 WE_MCC_CONFIG_CREDENTIAL,
6744 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6745 0,
6746 "setMccCrdnl" },
6747
6748 /* handlers for sub ioctl */
6749 {
6750 WE_MCC_CONFIG_PARAMS,
6751 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6752 0,
6753 "setMccConfig" },
6754
Chilam NG571c65a2013-01-19 12:27:36 +05306755#ifdef FEATURE_WLAN_TDLS
6756 /* handlers for sub ioctl */
6757 {
6758 WE_TDLS_CONFIG_PARAMS,
6759 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6760 0,
6761 "setTdlsConfig" },
6762#endif
6763
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 /* handlers for main ioctl */
6765 { WLAN_PRIV_ADD_TSPEC,
6766 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
6767 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6768 "addTspec" },
6769
6770 /* handlers for main ioctl */
6771 { WLAN_PRIV_DEL_TSPEC,
6772 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6774 "delTspec" },
6775
6776 /* handlers for main ioctl */
6777 { WLAN_PRIV_GET_TSPEC,
6778 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6779 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6780 "getTspec" },
6781
Jeff Johnsone7245742012-09-05 17:12:55 -07006782#ifdef FEATURE_OEM_DATA_SUPPORT
6783 /* handlers for main ioctl - OEM DATA */
6784 {
6785 WLAN_PRIV_SET_OEM_DATA_REQ,
6786 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
6787 0,
6788 "set_oem_data_req" },
6789
6790 /* handlers for main ioctl - OEM DATA */
6791 {
6792 WLAN_PRIV_GET_OEM_DATA_RSP,
6793 0,
6794 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
6795 "get_oem_data_rsp" },
6796#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006797
6798#ifdef FEATURE_WLAN_WAPI
6799 /* handlers for main ioctl SET_WAPI_MODE */
6800 { WLAN_PRIV_SET_WAPI_MODE,
6801 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6802 0,
6803 "SET_WAPI_MODE" },
6804
6805 /* handlers for main ioctl GET_WAPI_MODE */
6806 { WLAN_PRIV_GET_WAPI_MODE,
6807 0,
6808 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6809 "GET_WAPI_MODE" },
6810
6811 /* handlers for main ioctl SET_ASSOC_INFO */
6812 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
6813 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
6814 0,
6815 "SET_WAPI_ASSOC" },
6816
6817 /* handlers for main ioctl SET_WAPI_KEY */
6818 { WLAN_PRIV_SET_WAPI_KEY,
6819 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
6820 0,
6821 "SET_WAPI_KEY" },
6822
6823 /* handlers for main ioctl SET_WAPI_BKID */
6824 { WLAN_PRIV_SET_WAPI_BKID,
6825 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
6826 0,
6827 "SET_WAPI_BKID" },
6828
6829 /* handlers for main ioctl GET_WAPI_BKID */
6830 { WLAN_PRIV_GET_WAPI_BKID,
6831 0,
6832 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
6833 "GET_WAPI_BKID" },
6834#endif /* FEATURE_WLAN_WAPI */
6835
6836 /* handlers for main ioctl - host offload */
6837 {
6838 WLAN_PRIV_SET_HOST_OFFLOAD,
6839 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
6840 0,
6841 "setHostOffload" },
6842
6843 {
6844 WLAN_GET_WLAN_STATISTICS,
6845 0,
6846 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
6847 "getWlanStats" },
6848
6849 {
6850 WLAN_SET_KEEPALIVE_PARAMS,
6851 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
6852 0,
6853 "setKeepAlive" },
6854#ifdef WLAN_FEATURE_PACKET_FILTERING
6855 {
6856 WLAN_SET_PACKET_FILTER_PARAMS,
6857 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
6858 0,
6859 "setPktFilter" },
6860#endif
6861#ifdef FEATURE_WLAN_SCAN_PNO
6862 {
6863 WLAN_SET_PNO,
6864 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6865 0,
6866 "setpno" },
6867#endif
6868 {
6869 WLAN_SET_BAND_CONFIG,
6870 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6871 0,
6872 "SETBAND" },
6873 /* handlers for dynamic MC BC ioctl */
6874 {
6875 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006876 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 0,
6878 "setMCBCFilter" },
6879 {
6880 WLAN_PRIV_CLEAR_MCBC_FILTER,
6881 0,
6882 0,
6883 "clearMCBCFilter" },
6884 {
6885 WLAN_SET_POWER_PARAMS,
6886 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6887 0,
6888 "setpowerparams" },
6889 {
6890 WLAN_GET_LINK_SPEED,
6891 IW_PRIV_TYPE_CHAR | 18,
6892 IW_PRIV_TYPE_CHAR | 3, "getLinkSpeed" },
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07006893
Jeff Johnson295189b2012-06-20 16:38:30 -07006894};
6895
6896
6897
6898const struct iw_handler_def we_handler_def = {
6899 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
6900 .num_private = sizeof(we_private) / sizeof(we_private[0]),
6901 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
6902
6903 .standard = (iw_handler *)we_handler,
6904 .private = (iw_handler *)we_private,
6905 .private_args = we_private_args,
6906 .get_wireless_stats = get_wireless_stats,
6907};
6908
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006909int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
6910{
6911 v_U32_t cmd = 288; //Command to RIVA
6912 hdd_context_t *pHddCtx = NULL;
6913 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6914 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6915 /*
6916 *configMccParam : specify the bit which needs to be modified
6917 *allowed to update based on wlan_qcom_cfg.ini
6918 * configuration
6919 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
6920 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
6921 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
6922 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
6923 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
6924 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
6925 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
6926 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
6927 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
6928 * Bit 9 : Reserved
6929 */
6930 switch (arg1)
6931 {
6932 //Update MCC SCHEDULE_TIME_SLICE parameter
6933 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
6934 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
6935 {
6936 if((arg2 >= 5) && (arg2 <= 20))
6937 {
6938 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6939 }
6940 else
6941 {
6942 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6943 return 0;
6944 }
6945 }
6946 break;
6947
6948 //Update MCC MAX_NULL_SEND_TIME parameter
6949 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
6950 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
6951 {
6952 if((arg2 >= 1) && (arg2 <= 10))
6953 {
6954 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6955 }
6956 else
6957 {
6958 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6959 return 0;
6960 }
6961 }
6962 break;
6963
6964 //Update MCC TX_EARLY_STOP_TIME parameter
6965 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
6966 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
6967 {
6968 if((arg2 >= 1) && (arg2 <= 10))
6969 {
6970 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6971 }
6972 else
6973 {
6974 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6975 return 0;
6976 }
6977 }
6978 break;
6979
6980 //Update MCC RX_DRAIN_TIME parameter
6981 case MCC_RX_DRAIN_TIME_CFG_PARAM :
6982 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
6983 {
6984 if((arg2 >= 1) && (arg2 <= 10))
6985 {
6986 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6987 }
6988 else
6989 {
6990 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6991 return 0;
6992 }
6993 }
6994 break;
6995
6996 //Update MCC CHANNEL_SWITCH_TIME parameter
6997 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
6998 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
6999 {
7000 if((arg2 >= 1) && (arg2 <= 20))
7001 {
7002 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7003 }
7004 else
7005 {
7006 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7007 return 0;
7008 }
7009 }
7010 break;
7011
7012 //Update MCC MIN_CHANNEL_TIME parameter
7013 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
7014 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
7015 {
7016 if((arg2 >= 5) && (arg2 <= 20))
7017 {
7018 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7019 }
7020 else
7021 {
7022 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7023 return 0;
7024 }
7025 }
7026 break;
7027
7028 //Update MCC PARK_BEFORE_TBTT parameter
7029 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
7030 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
7031 {
7032 if((arg2 >= 1) && (arg2 <= 5))
7033 {
7034 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7035 }
7036 else
7037 {
7038 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7039 return 0;
7040 }
7041 }
7042 break;
7043
7044 //Update MCC MIN_AFTER_DTIM parameter
7045 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
7046 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
7047 {
7048 if((arg2 >= 5) && (arg2 <= 15))
7049 {
7050 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7051 }
7052 else
7053 {
7054 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7055 return 0;
7056 }
7057 }
7058 break;
7059
7060 //Update MCC TOO_CLOSE_MARGIN parameter
7061 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
7062 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
7063 {
7064 if((arg2 >= 1) && (arg2 <= 3))
7065 {
7066 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7067 }
7068 else
7069 {
7070 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7071 return 0;
7072 }
7073 }
7074 break;
7075
7076 default :
7077 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d\n",
7078 __FUNCTION__,arg1);
7079 break;
7080 }
7081 return 0;
7082}
7083
Jeff Johnson295189b2012-06-20 16:38:30 -07007084int hdd_set_wext(hdd_adapter_t *pAdapter)
7085{
7086 hdd_wext_state_t *pwextBuf;
7087 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007088 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007089
7090 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7091
7092 // Now configure the roaming profile links. To SSID and bssid.
7093 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
7094 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
7095
7096 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
7097 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
7098
7099 /*Set the numOfChannels to zero to scan all the channels*/
7100 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
7101 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
7102
7103 /* Default is no encryption */
7104 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
7105 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7106
7107 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
7108 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7109
7110 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
7111
7112 /* Default is no authentication */
7113 pwextBuf->roamProfile.AuthType.numEntries = 1;
7114 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
7115
7116 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
7117 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
7118
7119 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007120 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07007121
7122 hdd_clearRoamProfileIe(pAdapter);
7123
7124 return VOS_STATUS_SUCCESS;
7125
7126 }
7127
7128int hdd_register_wext(struct net_device *dev)
7129 {
7130 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7131 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7132 VOS_STATUS status;
7133
7134 ENTER();
7135
7136 // Zero the memory. This zeros the profile structure.
7137 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
7138
7139 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
7140
7141
7142 status = hdd_set_wext(pAdapter);
7143
7144 if(!VOS_IS_STATUS_SUCCESS(status)) {
7145
7146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!\n"));
7147 return eHAL_STATUS_FAILURE;
7148 }
7149
7150 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
7151 {
7152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!\n"));
7153 return eHAL_STATUS_FAILURE;
7154 }
7155
7156 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
7157 {
7158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!\n"));
7159 return eHAL_STATUS_FAILURE;
7160 }
7161
7162 // Register as a wireless device
7163 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
7164
7165 EXIT();
7166 return 0;
7167}
7168
7169int hdd_UnregisterWext(struct net_device *dev)
7170{
7171#if 0
7172 hdd_wext_state_t *wextBuf;
7173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7174
7175 ENTER();
7176 // Set up the pointer to the Wireless Extensions state structure
7177 wextBuf = pAdapter->pWextState;
7178
7179 // De-allocate the Wireless Extensions state structure
7180 kfree(wextBuf);
7181
7182 // Clear out the pointer to the Wireless Extensions state structure
7183 pAdapter->pWextState = NULL;
7184
7185 EXIT();
7186#endif
7187 dev->wireless_handlers = NULL;
7188 return 0;
7189}
7190
7191