blob: 736c4f9a945b7d80e3b0ff82d42d1f36f681be2d [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"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530113#include "sme_Api.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700114
115#ifdef CONFIG_HAS_EARLYSUSPEND
116extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
117extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
118#endif
119
Jeff Johnsone7245742012-09-05 17:12:55 -0700120#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800121#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700122#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700123
124#define HDD_FINISH_ULA_TIME_OUT 800
125
126extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
127int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
128
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700129static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700130module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
131
132struct statsContext
133{
134 struct completion completion;
135 hdd_adapter_t *pAdapter;
136 unsigned int magic;
137};
138
139#define STATS_CONTEXT_MAGIC 0x53544154 //STAT
140#define RSSI_CONTEXT_MAGIC 0x52535349 //RSSI
141#define POWER_CONTEXT_MAGIC 0x504F5752 // POWR
142
143/* To Validate Channel against the Frequency and Vice-Versa */
144static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
145 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
146 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
147 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
148 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
149 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
150 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
151 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
152 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
153
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800154#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700155
156/* Private ioctls and their sub-ioctls */
157#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
158#define WE_SET_11D_STATE 1
159#define WE_WOWL 2
160#define WE_SET_POWER 3
161#define WE_SET_MAX_ASSOC 4
162#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
163#define WE_SET_DATA_INACTIVITY_TO 6
164#define WE_SET_MAX_TX_POWER 7
165#define WE_SET_HIGHER_DTIM_TRANSITION 8
166#define WE_SET_TM_LEVEL 9
167
168/* Private ioctls and their sub-ioctls */
169#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
170#define WE_GET_11D_STATE 1
171#define WE_IBSS_STATUS 2
172#define WE_PMC_STATE 3
173#define WE_GET_WLAN_DBG 4
174#define WE_MODULE_DOWN_IND 5
175#define WE_GET_MAX_ASSOC 6
176#define WE_GET_WDI_DBG 7
177#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
178#define WE_GET_CONCURRENCY_MODE 9
179/* Private ioctls and their sub-ioctls */
180#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
181
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
184#define WE_WOWL_ADD_PTRN 1
185#define WE_WOWL_DEL_PTRN 2
186#if defined WLAN_FEATURE_VOWIFI
187#define WE_NEIGHBOR_REPORT_REQUEST 3
188#endif
189#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
190#define WE_SET_CONFIG 5
191
192/* Private ioctls and their sub-ioctls */
193#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
194#define WE_SET_WLAN_DBG 1
195#define WE_SET_WDI_DBG 2
196#define WE_SET_SAP_CHANNELS 3
197
198/* Private ioctls and their sub-ioctls */
199#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
200#define WE_WLAN_VERSION 1
201#define WE_GET_STATS 2
202#define WE_GET_CFG 3
203#define WE_GET_WMM_STATUS 4
204#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700205#ifdef WLAN_FEATURE_11AC
206#define WE_GET_RSSI 6
207#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800208#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800209#ifdef FEATURE_WLAN_TDLS
210#define WE_GET_TDLS_PEERS 8
211#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700212#ifdef WLAN_FEATURE_11W
213#define WE_GET_11W_INFO 9
214#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700215
216/* Private ioctls and their sub-ioctls */
217#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
218#define WE_CLEAR_STATS 1
219#define WE_INIT_AP 2
220#define WE_STOP_AP 3
221#define WE_ENABLE_AMP 4
222#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700223#define WE_ENABLE_DXE_STALL_DETECT 6
224#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700225#define WE_SET_REASSOC_TRIGGER 8
Jeff Johnson295189b2012-06-20 16:38:30 -0700226
227/* Private ioctls and their sub-ioctls */
228#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
229#define WE_LOG_DUMP_CMD 1
230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800232//IOCTL to configure MCC params
233#define WE_MCC_CONFIG_CREDENTIAL 3
234#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
Chilam NG571c65a2013-01-19 12:27:36 +0530236#ifdef FEATURE_WLAN_TDLS
237#define WE_TDLS_CONFIG_PARAMS 5
238#endif
239
Chilam Ng01120412013-02-19 18:32:21 -0800240#ifdef FEATURE_WLAN_TDLS
241#undef MAX_VAR_ARGS
242#define MAX_VAR_ARGS 10
243#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700244#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800245#endif
246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247
248/* Private ioctls (with no sub-ioctls) */
249/* note that they must be odd so that they have "get" semantics */
250#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
251#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
252#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
253
254#ifdef FEATURE_WLAN_WAPI
255/* Private ioctls EVEN NO: SET, ODD NO:GET */
256#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
257#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
258#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
259#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
260#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
261#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
262#define WAPI_PSK_AKM_SUITE 0x02721400
263#define WAPI_CERT_AKM_SUITE 0x01721400
264#endif
265
Jeff Johnsone7245742012-09-05 17:12:55 -0700266#ifdef FEATURE_OEM_DATA_SUPPORT
267/* Private ioctls for setting the measurement configuration */
268#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
269#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
270#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700271
272#ifdef WLAN_FEATURE_VOWIFI_11R
273#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
274#endif
275
276/* Private ioctl for setting the host offload feature */
277#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
278
279/* Private ioctl to get the statistics */
280#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
281
282/* Private ioctl to set the Keep Alive Params */
283#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
284#ifdef WLAN_FEATURE_PACKET_FILTERING
285/* Private ioctl to set the Packet Filtering Params */
286#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
287#endif
288
289#ifdef FEATURE_WLAN_SCAN_PNO
290/* Private ioctl to get the statistics */
291#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
292#endif
293
294#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
295
296#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
297#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700298/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700299
Jeff Johnson295189b2012-06-20 16:38:30 -0700300#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
301#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
302
303#define WLAN_STATS_INVALID 0
304#define WLAN_STATS_RETRY_CNT 1
305#define WLAN_STATS_MUL_RETRY_CNT 2
306#define WLAN_STATS_TX_FRM_CNT 3
307#define WLAN_STATS_RX_FRM_CNT 4
308#define WLAN_STATS_FRM_DUP_CNT 5
309#define WLAN_STATS_FAIL_CNT 6
310#define WLAN_STATS_RTS_FAIL_CNT 7
311#define WLAN_STATS_ACK_FAIL_CNT 8
312#define WLAN_STATS_RTS_SUC_CNT 9
313#define WLAN_STATS_RX_DISCARD_CNT 10
314#define WLAN_STATS_RX_ERROR_CNT 11
315#define WLAN_STATS_TX_BYTE_CNT 12
316
317#define WLAN_STATS_RX_BYTE_CNT 13
318#define WLAN_STATS_RX_RATE 14
319#define WLAN_STATS_TX_RATE 15
320
Jeff Johnsone7245742012-09-05 17:12:55 -0700321#define WLAN_STATS_RX_UC_BYTE_CNT 16
322#define WLAN_STATS_RX_MC_BYTE_CNT 17
323#define WLAN_STATS_RX_BC_BYTE_CNT 18
324#define WLAN_STATS_TX_UC_BYTE_CNT 19
325#define WLAN_STATS_TX_MC_BYTE_CNT 20
326#define WLAN_STATS_TX_BC_BYTE_CNT 21
327
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800328#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
329 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
330 { \
331 *__p++ = __type; \
332 *__p++ = __size; \
333 memcpy(__p, __val, __size); \
334 __p += __size; \
335 __tlen += __size + 2; \
336 } \
337 else \
338 { \
339 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!\n"); \
340 } \
341 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700342
343#define VERSION_VALUE_MAX_LEN 32
344
345#define TX_PER_TRACKING_DEFAULT_RATIO 5
346#define TX_PER_TRACKING_MAX_RATIO 10
347#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
348
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800349/*MCC Configuration parameters */
350enum {
351 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
352 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
353 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
354 MCC_RX_DRAIN_TIME_CFG_PARAM,
355 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
356 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
357 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
358 MCC_MIN_AFTER_DTIM_CFG_PARAM,
359 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
360};
361
362int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
363 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
364
Jeff Johnson295189b2012-06-20 16:38:30 -0700365#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -0700366int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
367 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700368#endif
369
Jeff Johnson295189b2012-06-20 16:38:30 -0700370/**---------------------------------------------------------------------------
371
372 \brief hdd_wlan_get_version() -
373
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800374 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700375
376 \param - pAdapter Pointer to the adapter.
377 wrqu - Pointer to IOCTL REQUEST Data.
378 extra - Pointer to char
379
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800380 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
382 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800383void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
384 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700385{
386 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800387 tSirVersionString wcnss_SW_version;
388 tSirVersionString wcnss_HW_version;
389 char *pSWversion;
390 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700392
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800393 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
394 sizeof(wcnss_SW_version));
395 if (VOS_IS_STATUS_SUCCESS(status))
396 {
397 pSWversion = wcnss_SW_version;
398 }
399 else
400 {
401 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700402 }
403
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800404 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
405 sizeof(wcnss_HW_version));
406 if (VOS_IS_STATUS_SUCCESS(status))
407 {
408 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800410 else
411 {
412 pHWversion = "Unknown";
413 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700414
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800415 wrqu->data.length = snprintf(extra, WE_MAX_STR_LEN,
416 "Host SW:%s, FW:%s, HW:%s",
417 QWLAN_VERSIONSTR,
418 pSWversion,
419 pHWversion);
420
421 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700422}
423
Jeff Johnson295189b2012-06-20 16:38:30 -0700424int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
425{
426 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
427 v_U32_t threshold = 0,status = 0;
428
429 ENTER();
430
431 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
433 "%s:LOGP in Progress. Ignore!!!",__func__);
434 return status;
435 }
436
437 if ( eHAL_STATUS_SUCCESS !=
438 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
439 {
440 return -EIO;
441 }
442 wrqu->rts.value = threshold;
443
444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
445 ("Rts-Threshold=%ld!!\n"), wrqu->rts.value);
446
447 EXIT();
448
449 return 0;
450}
451
452int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
453{
454 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
455 v_U32_t threshold = 0,status = 0;
456
457 ENTER();
458
459 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
461 "%s:LOGP in Progress. Ignore!!!",__func__);
462 return status;
463 }
464
465 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
466 != eHAL_STATUS_SUCCESS )
467 {
468 return -EIO;
469 }
470 wrqu->frag.value = threshold;
471
472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
473 ("Frag-Threshold=%ld!!\n"), wrqu->frag.value);
474
475 EXIT();
476
477 return 0;
478}
479
480int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
481{
Jeff Johnsone7245742012-09-05 17:12:55 -0700482 int i;
483 if (channel > 0)
484 {
485 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
486 {
487 if (channel == freq_chan_map[i].chan)
488 {
489 *pfreq = freq_chan_map[i].freq;
490 return 1;
491 }
492 }
493 }
494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
495 ("Invalid channel no=%d!!\n"), channel);
496 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700497}
498
499static v_BOOL_t
500hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
501{
502 v_BOOL_t rsnType = VOS_FALSE;
503 // is the authType supported?
504 switch (authType)
505 {
506 case eCSR_AUTH_TYPE_NONE: //never used
507 rsnType = eANI_BOOLEAN_FALSE;
508 break;
509 // MAC layer authentication types
510 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
511 rsnType = eANI_BOOLEAN_FALSE;
512 break;
513 case eCSR_AUTH_TYPE_SHARED_KEY:
514 rsnType = eANI_BOOLEAN_FALSE;
515 break;
516 case eCSR_AUTH_TYPE_AUTOSWITCH:
517 rsnType = eANI_BOOLEAN_FALSE;
518 break;
519
520 // Upper layer authentication types
521 case eCSR_AUTH_TYPE_WPA:
522 rsnType = eANI_BOOLEAN_TRUE;
523 break;
524 case eCSR_AUTH_TYPE_WPA_PSK:
525 rsnType = eANI_BOOLEAN_TRUE;
526 break;
527 case eCSR_AUTH_TYPE_WPA_NONE:
528 rsnType = eANI_BOOLEAN_TRUE;
529 break;
530#ifdef WLAN_FEATURE_VOWIFI_11R
531 case eCSR_AUTH_TYPE_FT_RSN:
532#endif
533 case eCSR_AUTH_TYPE_RSN:
534 rsnType = eANI_BOOLEAN_TRUE;
535 break;
536#ifdef WLAN_FEATURE_VOWIFI_11R
537 case eCSR_AUTH_TYPE_FT_RSN_PSK:
538#endif
539 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700540#ifdef WLAN_FEATURE_11W
541 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
542#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 rsnType = eANI_BOOLEAN_TRUE;
544 break;
545 //case eCSR_AUTH_TYPE_FAILED:
546 case eCSR_AUTH_TYPE_UNKNOWN:
547 rsnType = eANI_BOOLEAN_FALSE;
548 break;
549 default:
550 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700551 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 rsnType = eANI_BOOLEAN_FALSE;
553 break;
554 }
555 hddLog(LOGE, FL("%s called with authType: %d, returned: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700556 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 return rsnType;
558}
559
560static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
561{
562 struct statsContext *pStatsContext;
563 hdd_adapter_t *pAdapter;
564
565 if (ioctl_debug)
566 {
567 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700568 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 }
570
571 if (NULL == pContext)
572 {
573 hddLog(VOS_TRACE_LEVEL_ERROR,
574 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700575 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 return;
577 }
578
579 /* there is a race condition that exists between this callback function
580 and the caller since the caller could time out either before or
581 while this code is executing. we'll assume the timeout hasn't
582 occurred, but we'll verify that right before we save our work */
583
584 pStatsContext = pContext;
585 pAdapter = pStatsContext->pAdapter;
586 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
587 {
588 /* the caller presumably timed out so there is nothing we can do */
589 hddLog(VOS_TRACE_LEVEL_WARN,
590 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700591 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 if (ioctl_debug)
593 {
594 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700595 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 }
597 return;
598 }
599
600 /* the race is on. caller could have timed out immediately after
601 we verified the magic, but if so, caller will wait a short time
602 for us to copy over the rssi */
603 pAdapter->rssi = rssi;
604
605 /* and notify the caller */
606 complete(&pStatsContext->completion);
607}
608
609VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
610{
611 struct statsContext context;
612 hdd_context_t *pHddCtx;
613 hdd_station_ctx_t *pHddStaCtx;
614 eHalStatus hstatus;
615 long lrc;
616
617 if (NULL == pAdapter)
618 {
619 hddLog(VOS_TRACE_LEVEL_WARN,
620 "%s: Invalid context, pAdapter", __func__);
621 return VOS_STATUS_E_FAULT;
622 }
623 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
624 {
625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
626 /* return a cached value */
627 *rssi_value = pAdapter->rssi;
628 return VOS_STATUS_SUCCESS;
629 }
630
631 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
632 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
633
634 init_completion(&context.completion);
635 context.pAdapter = pAdapter;
636 context.magic = RSSI_CONTEXT_MAGIC;
637
638 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
639 pHddStaCtx->conn_info.staId[ 0 ],
640 pHddStaCtx->conn_info.bssId,
641 &context, pHddCtx->pvosContext);
642 if (eHAL_STATUS_SUCCESS != hstatus)
643 {
644 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700645 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 /* we'll returned a cached value below */
647 }
648 else
649 {
650 /* request was sent -- wait for the response */
651 lrc = wait_for_completion_interruptible_timeout(&context.completion,
652 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
653 /* either we have a response or we timed out
654 either way, first invalidate our magic */
655 context.magic = 0;
656 if (lrc <= 0)
657 {
658 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700659 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 /* there is a race condition such that the callback
661 function could be executing at the same time we are. of
662 primary concern is if the callback function had already
663 verified the "magic" but hasn't yet set the completion
664 variable. Since the completion variable is on our
665 stack, we'll delay just a bit to make sure the data is
666 still valid if that is the case */
667 msleep(50);
668 /* we'll now returned a cached value below */
669 }
670 }
671 *rssi_value = pAdapter->rssi;
672
673 return VOS_STATUS_SUCCESS;
674}
675
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800676#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
677
678static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
679{
680 struct statsContext *pStatsContext;
681 hdd_adapter_t *pAdapter;
682 if (ioctl_debug)
683 {
684 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
685 __func__, (int)rssi, (int)staId, pContext);
686 }
687
688 if (NULL == pContext)
689 {
690 hddLog(VOS_TRACE_LEVEL_ERROR,
691 "%s: Bad param, pContext [%p]",
692 __func__, pContext);
693 return;
694 }
695
696 /* there is a race condition that exists between this callback function
697 and the caller since the caller could time out either before or
698 while this code is executing. we'll assume the timeout hasn't
699 occurred, but we'll verify that right before we save our work */
700
701 pStatsContext = pContext;
702 pAdapter = pStatsContext->pAdapter;
703 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
704 {
705 /* the caller presumably timed out so there is nothing we can do */
706 hddLog(VOS_TRACE_LEVEL_WARN,
707 "%s: Invalid context, pAdapter [%p] magic [%08x]",
708 __func__, pAdapter, pStatsContext->magic);
709 if (ioctl_debug)
710 {
711 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
712 __func__, pAdapter, pStatsContext->magic);
713 }
714 return;
715 }
716
717 /* the race is on. caller could have timed out immediately after
718 we verified the magic, but if so, caller will wait a short time
719 for us to copy over the rssi */
720 pAdapter->rssi = rssi;
721
722 /* and notify the caller */
723 complete(&pStatsContext->completion);
724}
725
726
727
728VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
729{
730 struct statsContext context;
731 hdd_context_t *pHddCtx = NULL;
732 hdd_station_ctx_t *pHddStaCtx = NULL;
733 eHalStatus hstatus;
734 long lrc;
735
736 if (NULL == pAdapter)
737 {
738 hddLog(VOS_TRACE_LEVEL_WARN,
739 "%s: Invalid context, pAdapter", __func__);
740 return VOS_STATUS_E_FAULT;
741 }
742 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
743 {
744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
745 /* return a cached value */
746 *rssi_value = pAdapter->rssi;
747 return VOS_STATUS_SUCCESS;
748 }
749
750 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
751 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
752
753 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
754 {
755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
756 /* return a cached value */
757 *rssi_value = 0;
758 return VOS_STATUS_SUCCESS;
759 }
760 init_completion(&context.completion);
761 context.pAdapter = pAdapter;
762 context.magic = RSSI_CONTEXT_MAGIC;
763
764 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
765 pHddStaCtx->conn_info.staId[ 0 ],
766 pHddStaCtx->conn_info.bssId,
767 &context, pHddCtx->pvosContext);
768 if (eHAL_STATUS_SUCCESS != hstatus)
769 {
770 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
771 __func__);
772 /* we'll returned a cached value below */
773 }
774 else
775 {
776 /* request was sent -- wait for the response */
777 lrc = wait_for_completion_interruptible_timeout(&context.completion,
778 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
779 /* either we have a response or we timed out
780 either way, first invalidate our magic */
781 context.magic = 0;
782 if (lrc <= 0)
783 {
784 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ",
785 __func__, (0 == lrc) ? "timeout" : "interrupt");
786 /* there is a race condition such that the callback
787 function could be executing at the same time we are. of
788 primary concern is if the callback function had already
789 verified the "magic" but hasn't yet set the completion
790 variable. Since the completion variable is on our
791 stack, we'll delay just a bit to make sure the data is
792 still valid if that is the case */
793 msleep(50);
794 /* we'll now returned a cached value below */
795 }
796 }
797 *rssi_value = pAdapter->rssi;
798
799 return VOS_STATUS_SUCCESS;
800}
801#endif
802
803
Jeff Johnson295189b2012-06-20 16:38:30 -0700804void hdd_StatisticsCB( void *pStats, void *pContext )
805{
806 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
807 hdd_stats_t *pStatsCache = NULL;
808 hdd_wext_state_t *pWextState;
809 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
810
811 tCsrSummaryStatsInfo *pSummaryStats = NULL;
812 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
813 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
814 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
815 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
816 tCsrPerStaStatsInfo *pPerStaStats = NULL;
817
818 if (pAdapter!= NULL)
819 pStatsCache = &pAdapter->hdd_stats;
820
821
822 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
823 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
824 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
825 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
826 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
827 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
828
829 if (pStatsCache!=NULL)
830 {
831 // and copy the stats into the cache we keep in the adapter instance structure
832 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
833 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
834 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
835 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
836 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
837 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
838 }
839
840 if(pAdapter)
841 {
842 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
843 if(pWextState)
844 {
845 vos_status = vos_event_set(&pWextState->vosevent);
846 if (!VOS_IS_STATUS_SUCCESS(vos_status))
847 {
848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700849 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 return;
851 }
852 }
853 }
854}
855
856void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
857{
858 v_CONTEXT_t pVosContext;
859 hdd_context_t *pHddCtx;
860 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
861#if 0
862 hdd_wext_state_t *pWextState;
863 v_U32_t roamId;
864#endif
865
866 ENTER();
867
868 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
869
870 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
871 if (NULL == pHddCtx)
872 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700873 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 return;
875 }
876#if 0
877 pWextState = pAdapter->pWextState;
878#endif
879
880 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
881 {
882 //TODO Verify is this is really used. If yes need to fix it.
883 hdd_reconnect_all_adapters( pHddCtx );
884#if 0
885 pAdapter->conn_info.connState = eConnectionState_NotConnected;
886 INIT_COMPLETION(pAdapter->disconnect_comp_var);
887 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
888
889 if(VOS_STATUS_SUCCESS == vosStatus)
890 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
891 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
892
893 sme_RoamConnect(halHandle,
894 pAdapter->sessionId, &(pWextState->roamProfile),
895 &roamId);
896#endif
897 }
898
899 EXIT();
900
901}
902
903void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
904{
905 int i = 0;
906 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
907
908 /* clear WPA/RSN/WSC IE information in the profile */
909 pWextState->roamProfile.nWPAReqIELength = 0;
910 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
911 pWextState->roamProfile.nRSNReqIELength = 0;
912 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
913
Chet Lanctot186b5732013-03-18 10:26:30 -0700914#ifdef FEATURE_WLAN_WAPI
915 pWextState->roamProfile.nWAPIReqIELength = 0;
916 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
917#endif
918
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
920 pWextState->roamProfile.pAddIEScan = (tANI_U8 *)NULL;
921 pWextState->roamProfile.nAddIEScanLength = 0;
922 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
923 pWextState->roamProfile.nAddIEAssocLength = 0;
924
925 pWextState->roamProfile.EncryptionType.numEntries = 1;
926 pWextState->roamProfile.EncryptionType.encryptionType[0]
927 = eCSR_ENCRYPT_TYPE_NONE;
928
929 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
930 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
931 = eCSR_ENCRYPT_TYPE_NONE;
932
933 pWextState->roamProfile.AuthType.numEntries = 1;
934 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
935
Chet Lanctot186b5732013-03-18 10:26:30 -0700936#ifdef WLAN_FEATURE_11W
937 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
938 pWextState->roamProfile.MFPRequired = 0;
939 pWextState->roamProfile.MFPCapable = 0;
940#endif
941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 pWextState->authKeyMgmt = 0;
943
944 for (i=0; i < CSR_MAX_NUM_KEY; i++)
945 {
946 if (pWextState->roamProfile.Keys.KeyMaterial[i])
947 {
948 pWextState->roamProfile.Keys.KeyLength[i] = 0;
949 }
950 }
951#ifdef FEATURE_WLAN_WAPI
952 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
953 pAdapter->wapi_info.nWapiMode = 0;
954#endif
955
956 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
957
958}
959
960void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
961{
962 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -0700963
Jeff Johnson9efb9aa2013-03-15 13:59:27 -0700964 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
965 {
966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
967 "%s: Invalid pAdapter magic", __func__);
968 }
969 else
970 {
971 complete(&pAdapter->ula_complete);
972 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700973}
974
975VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
976{
977 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -0700979 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700980
981 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
982 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -0700983 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985 /*To avoid race condition between the set key and the last EAPOL
986 packet, notify TL to finish upper layer authentication incase if the
987 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -0800988 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700989
990 if ( vos_status != VOS_STATUS_SUCCESS )
991 {
992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
993 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
994 __LINE__, vos_status );
995 return vos_status;
996
997 }
998
Jeff Johnson9efb9aa2013-03-15 13:59:27 -0700999 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001001 if (0 == rc)
1002 {
1003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1004 "%s: Timeout waiting for ULA to complete", __func__);
1005 /* we'll still fall through and return success since the
1006 * connection may still get established but is just taking
1007 * too long for us to wait */
1008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 }
1010 return VOS_STATUS_SUCCESS;
1011}
1012
1013v_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)
1014{
1015
1016 int left = ie_len;
1017 v_U8_t *ptr = ie;
1018 v_U8_t elem_id,elem_len;
1019 v_U8_t eid = 0xDD;
1020
1021 if ( NULL == ie || 0 == ie_len )
1022 return NULL;
1023
1024 while(left >= 2)
1025 {
1026 elem_id = ptr[0];
1027 elem_len = ptr[1];
1028 left -= 2;
1029 if(elem_len > left)
1030 {
1031 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001032 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 eid,elem_len,left);
1034 return NULL;
1035 }
1036 if (elem_id == eid)
1037 {
1038 if(memcmp( &ptr[2], oui, oui_size)==0)
1039 return ptr;
1040 }
1041
1042 left -= elem_len;
1043 ptr += (elem_len + 2);
1044 }
1045 return NULL;
1046}
1047
1048static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1049 union iwreq_data *wrqu, char *extra)
1050{
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001051 hddLog( LOG1, "In %s\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 /* Do nothing for now */
1053 return 0;
1054}
1055
1056static int iw_get_name(struct net_device *dev,
1057 struct iw_request_info *info,
1058 char *wrqu, char *extra)
1059{
1060
1061 ENTER();
1062 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1063 EXIT();
1064 return 0;
1065}
1066
1067static int iw_set_mode(struct net_device *dev,
1068 struct iw_request_info *info,
1069 union iwreq_data *wrqu, char *extra)
1070{
1071 hdd_wext_state_t *pWextState;
1072 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1073 tCsrRoamProfile *pRoamProfile;
1074 eCsrRoamBssType LastBSSType;
1075 eMib_dot11DesiredBssType connectedBssType;
1076 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001078
1079 ENTER();
1080
1081 if (NULL == pAdapter)
1082 {
1083 hddLog(VOS_TRACE_LEVEL_WARN,
1084 "%s: Invalid context, pAdapter", __func__);
1085 return 0;
1086 }
1087
1088 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1090 return 0;
1091 }
1092
1093 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1094 if (pWextState == NULL)
1095 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001096 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 return -EINVAL;
1098 }
1099
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 pRoamProfile = &pWextState->roamProfile;
1102 LastBSSType = pRoamProfile->BSSType;
1103
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001104 hddLog( LOG1,"%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001105
1106 switch (wrqu->mode)
1107 {
1108 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001109 hddLog( LOG1,"%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1111 // Set the phymode correctly for IBSS.
1112 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1113 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001114 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 break;
1117 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001118 hddLog( LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 break;
1122 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001123 hddLog(LOG1,"%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1125 break;
1126 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001127 hddLog(LOG1,"%s Unknown AP Mode value", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 return -EOPNOTSUPP;
1129 }
1130
1131 if ( LastBSSType != pRoamProfile->BSSType )
1132 {
1133 //the BSS mode changed
1134 // We need to issue disconnect if connected or in IBSS disconnect state
1135 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1136 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1137 {
1138 VOS_STATUS vosStatus;
1139 // need to issue a disconnect to CSR.
1140 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1141 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1142 pAdapter->sessionId,
1143 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1144 if(VOS_STATUS_SUCCESS == vosStatus)
1145 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1146 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1147 }
1148 }
1149
1150
1151
1152 EXIT();
1153 return 0;
1154}
1155
1156
1157static int iw_get_mode(struct net_device *dev,
1158 struct iw_request_info *info,
1159 v_U32_t *uwrq, char *extra)
1160{
1161
1162 hdd_wext_state_t *pWextState;
1163 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1164
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001165 hddLog (LOG1, "In %s",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001166
1167 if (NULL == pAdapter)
1168 {
1169 hddLog(VOS_TRACE_LEVEL_WARN,
1170 "%s: Invalid context, pAdapter", __func__);
1171 return 0;
1172 }
1173
1174 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1176 return 0;
1177 }
1178
1179 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1180 if (pWextState == NULL)
1181 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001182 hddLog (LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 return -EINVAL;
1184 }
1185
1186 switch (pWextState->roamProfile.BSSType)
1187 {
1188 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001189 hddLog(LOG1, "%s returns IW_MODE_INFRA\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 *uwrq = IW_MODE_INFRA ;
1191 break;
1192 case eCSR_BSS_TYPE_IBSS:
1193 case eCSR_BSS_TYPE_START_IBSS:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001194 hddLog( LOG1,"%s returns IW_MODE_ADHOC\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 *uwrq= IW_MODE_ADHOC;
1196 break;
1197 case eCSR_BSS_TYPE_ANY:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001198 hddLog( LOG1,"%s returns IW_MODE_AUTO\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 *uwrq= IW_MODE_AUTO;
1200 break;
1201 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001202 hddLog( LOG1,"%s returns APMODE_UNKNOWN\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 break;
1204 }
1205 return 0;
1206}
1207
1208static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1209 union iwreq_data *wrqu, char *extra)
1210{
1211 v_U32_t numChans = 0;
1212 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1213 v_U32_t indx = 0;
1214 v_U32_t status = 0;
1215
1216 hdd_wext_state_t *pWextState;
1217 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1218 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1219 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1220 tCsrRoamProfile * pRoamProfile;
1221 ENTER();
1222
1223 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1225 return status;
1226 }
1227
1228 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1229
1230 pRoamProfile = &pWextState->roamProfile;
1231
1232 hddLog(LOG1,"setCHANNEL ioctl\n");
1233
1234 /* Link is up then return cant set channel*/
1235 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1236 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1237 {
1238 hddLog( LOGE, "IBSS Associated\n");
1239 return -EOPNOTSUPP;
1240 }
1241
1242 /* Settings by Frequency as input */
1243 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1244 (wrqu->freq.m <= (tANI_U32)5.825e8))
1245 {
1246 tANI_U32 freq = wrqu->freq.m / 100000;
1247
1248 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1249 indx++;
1250 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1251 {
1252 return -EINVAL;
1253 }
1254 wrqu->freq.e = 0;
1255 wrqu->freq.m = freq_chan_map[indx].chan;
1256
1257 }
1258
1259 if (wrqu->freq.e == 0)
1260 {
1261 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1262 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1263 {
1264 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001265 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1267 return -EINVAL;
1268 }
1269
1270 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1271
1272 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1273 validChan, &numChans) != eHAL_STATUS_SUCCESS){
1274 return -EIO;
1275 }
1276
1277 for (indx = 0; indx < numChans; indx++) {
1278 if (wrqu->freq.m == validChan[indx]){
1279 break;
1280 }
1281 }
1282 }
1283 else{
1284
1285 return -EINVAL;
1286 }
1287
1288 if(indx >= numChans)
1289 {
1290 return -EINVAL;
1291 }
1292
1293 /* Set the Operational Channel */
1294 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1295 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1296 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1297
1298 hddLog(LOG1,"pRoamProfile->operationChannel = %d\n", wrqu->freq.m);
1299
1300 EXIT();
1301
1302 return status;
1303}
1304
1305static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1306 struct iw_freq *fwrq, char *extra)
1307{
Jeff Johnsone7245742012-09-05 17:12:55 -07001308 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001309 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1310 tHalHandle hHal;
1311 hdd_wext_state_t *pWextState;
1312 tCsrRoamProfile * pRoamProfile;
1313 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1314
1315 ENTER();
1316
1317 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1319 return status;
1320 }
1321
1322 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1323 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1324
1325 pRoamProfile = &pWextState->roamProfile;
1326
1327 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1328 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001329 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 {
1331 return -EIO;
1332 }
1333 else
1334 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001335 status = hdd_wlan_get_freq(channel, &freq);
1336 if( TRUE == status )
1337 {
1338 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1339 * iwlist & iwconfig command shows frequency into proper
1340 * format (2.412 GHz instead of 246.2 MHz)*/
1341 fwrq->m = freq;
1342 fwrq->e = MHZ;
1343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 }
1345 }
1346 else
1347 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001348 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1349 * iwlist & iwconfig command shows frequency into proper
1350 * format (2.412 GHz instead of 246.2 MHz)*/
1351 fwrq->m = 0;
1352 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001353 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001354 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001355}
1356
1357static int iw_get_tx_power(struct net_device *dev,
1358 struct iw_request_info *info,
1359 union iwreq_data *wrqu, char *extra)
1360{
1361
1362 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1363 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1364 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1365
1366 if (pHddCtx->isLogpInProgress)
1367 {
1368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1369 "%s:LOGP in Progress. Ignore!!!",__func__);
1370 return -EBUSY;
1371 }
1372
1373 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1374 {
1375 wrqu->txpower.value = 0;
1376 return 0;
1377 }
1378 wlan_hdd_get_classAstats(pAdapter);
1379 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1380
1381 return 0;
1382}
1383
1384static int iw_set_tx_power(struct net_device *dev,
1385 struct iw_request_info *info,
1386 union iwreq_data *wrqu, char *extra)
1387{
1388 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1389 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1390
1391 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1392 {
1393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1394 return 0;
1395 }
1396
1397 ENTER();
1398
1399 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1400 {
1401 return -EIO;
1402 }
1403
1404 EXIT();
1405
1406 return 0;
1407}
1408
1409static int iw_get_bitrate(struct net_device *dev,
1410 struct iw_request_info *info,
1411 union iwreq_data *wrqu, char *extra)
1412{
1413 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1414 eHalStatus status = eHAL_STATUS_SUCCESS;
1415 hdd_wext_state_t *pWextState;
1416 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1417 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1418
1419 ENTER();
1420
1421 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1423 return status;
1424 }
1425
1426 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1427 wrqu->bitrate.value = 0;
1428 }
1429 else {
1430 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1431 SME_SUMMARY_STATS |
1432 SME_GLOBAL_CLASSA_STATS |
1433 SME_GLOBAL_CLASSB_STATS |
1434 SME_GLOBAL_CLASSC_STATS |
1435 SME_GLOBAL_CLASSD_STATS |
1436 SME_PER_STA_STATS,
1437 hdd_StatisticsCB, 0, FALSE,
1438 pHddStaCtx->conn_info.staId[0], pAdapter );
1439
1440 if(eHAL_STATUS_SUCCESS != status)
1441 {
1442 hddLog(VOS_TRACE_LEVEL_ERROR,
1443 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001444 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 return status;
1446 }
1447
1448 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1449
1450 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1451
1452 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1453 {
1454 hddLog(VOS_TRACE_LEVEL_ERROR,
1455 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001456 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 return VOS_STATUS_E_FAILURE;
1458 }
1459
1460 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1461 }
1462
1463 EXIT();
1464
1465 return vos_status;
1466}
1467/* ccm call back function */
1468
1469static int iw_set_bitrate(struct net_device *dev,
1470 struct iw_request_info *info,
1471 union iwreq_data *wrqu,
1472 char *extra)
1473{
1474 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1475 hdd_wext_state_t *pWextState;
1476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1477 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1478 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1479 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1480 v_U32_t i, rate;
1481 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1482
1483 ENTER();
1484
1485 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1487 return 0;
1488 }
1489
1490 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1491
1492 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1493 {
1494 return -ENXIO ;
1495 }
1496
1497 rate = wrqu->bitrate.value;
1498
1499 if (rate == -1)
1500 {
1501 rate = WNI_CFG_FIXED_RATE_AUTO;
1502 valid_rate = TRUE;
1503 }
1504 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1505 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1506 {
1507 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1508 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1509 {
1510 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1511 WNI_CFG_SUPPORTED_RATES_11A,
1512 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1513 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1514 WNI_CFG_SUPPORTED_RATES_11B,
1515 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1516 {
1517 for (i = 0; i < (b_len + a_len); ++i)
1518 {
1519 /* supported rates returned is double the actual rate so we divide it by 2 */
1520 if ((supp_rates[i]&0x7F)/2 == rate)
1521 {
1522 valid_rate = TRUE;
1523 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1524 break;
1525 }
1526 }
1527 }
1528 }
1529 }
1530 if (valid_rate != TRUE)
1531 {
1532 return -EINVAL;
1533 }
1534 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1535 WNI_CFG_FIXED_RATE, rate,
1536 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1537 {
1538 return -EIO;
1539 }
1540 return 0;
1541}
1542
1543
1544static int iw_set_genie(struct net_device *dev,
1545 struct iw_request_info *info,
1546 union iwreq_data *wrqu,
1547 char *extra)
1548{
1549 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1550 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1551 u_int8_t *genie;
1552 v_U16_t remLen;
1553
1554 ENTER();
1555 if(!wrqu->data.length) {
1556 hdd_clearRoamProfileIe(pAdapter);
1557 EXIT();
1558 return 0;
1559 }
1560
1561 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1563 return 0;
1564 }
1565
1566 genie = wrqu->data.pointer;
1567 remLen = wrqu->data.length;
1568
1569 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]\n", genie[0], genie[1]);
1570
1571 /* clear any previous genIE before this call */
1572 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1573
1574 while (remLen >= 2)
1575 {
1576 v_U16_t eLen = 0;
1577 v_U8_t elementId;
1578 elementId = *genie++;
1579 eLen = *genie++;
1580 remLen -= 2;
1581
1582 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
1583 __func__, elementId, eLen);
1584
1585 switch ( elementId )
1586 {
1587 case IE_EID_VENDOR:
1588 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
1589 return -EINVAL;
1590
1591 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1592 {
1593 v_U16_t curGenIELen = pWextState->genIE.length;
1594 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1595 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1596
1597 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1598 {
1599 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1600 "Need bigger buffer space\n");
1601 VOS_ASSERT(0);
1602 return -ENOMEM;
1603 }
1604 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1605 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1606 pWextState->genIE.length += eLen + 2;
1607 }
1608 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1609 {
1610 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1611 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1612 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1613 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1614 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1615 }
1616 else /* any vendorId except WPA IE should be accumulated to genIE */
1617 {
1618 v_U16_t curGenIELen = pWextState->genIE.length;
1619 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1620 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1621
1622 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1623 {
1624 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
1625 "Need bigger buffer space\n");
1626 VOS_ASSERT(0);
1627 return -ENOMEM;
1628 }
1629 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1630 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1631 pWextState->genIE.length += eLen + 2;
1632 }
1633 break;
1634 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001635 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1637 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1638 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1639 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1640 break;
1641
1642 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001643 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 return 0;
1645 }
1646 genie += eLen;
1647 remLen -= eLen;
1648 }
1649 EXIT();
1650 return 0;
1651}
1652
1653static int iw_get_genie(struct net_device *dev,
1654 struct iw_request_info *info,
1655 union iwreq_data *wrqu,
1656 char *extra)
1657{
1658 hdd_wext_state_t *pWextState;
1659 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1660 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1661 eHalStatus status;
1662 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1663 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1664
1665 ENTER();
1666
1667 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1669 return 0;
1670 }
1671
1672
1673 hddLog(LOG1,"getGEN_IE ioctl\n");
1674
1675 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1676
1677 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1678 {
1679 return -ENXIO;
1680 }
1681
1682 // Return something ONLY if we are associated with an RSN or WPA network
1683 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1684 pWextState->roamProfile.negotiatedAuthType))
1685 {
1686 return -ENXIO;
1687 }
1688
1689 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1690 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1691 pAdapter->sessionId,
1692 &length,
1693 genIeBytes);
1694 wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1695
1696 vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length);
1697
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001698 hddLog(LOG1,"%s: RSN IE of %d bytes returned\n", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699
1700 EXIT();
1701
1702 return 0;
1703}
1704
1705static int iw_get_encode(struct net_device *dev,
1706 struct iw_request_info *info,
1707 struct iw_point *dwrq, char *extra)
1708{
1709 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1710 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1711 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1712 int keyId;
1713 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1714 int i;
1715
1716 ENTER();
1717
1718 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1720 return 0;
1721 }
1722
1723 keyId = pRoamProfile->Keys.defaultIndex;
1724
1725 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1726 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001727 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 return -EINVAL;
1729 }
1730
1731 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1732 {
1733 dwrq->flags |= IW_ENCODE_ENABLED;
1734 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1735 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1736
1737 dwrq->flags |= (keyId + 1);
1738
1739 }
1740 else
1741 {
1742 dwrq->flags |= IW_ENCODE_DISABLED;
1743 }
1744
1745 for(i=0; i < MAX_WEP_KEYS; i++)
1746 {
1747 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
1748 {
1749 continue;
1750 }
1751 else
1752 {
1753 break;
1754 }
1755 }
1756
1757 if(MAX_WEP_KEYS == i)
1758 {
1759 dwrq->flags |= IW_ENCODE_NOKEY;
1760 }
1761
1762 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
1763
1764 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
1765 {
1766 dwrq->flags |= IW_ENCODE_OPEN;
1767 }
1768 else
1769 {
1770 dwrq->flags |= IW_ENCODE_RESTRICTED;
1771 }
1772 EXIT();
1773 return 0;
1774}
1775
1776#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
1777#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
1778
1779
1780/*
1781 * This function sends a single 'key' to LIM at all time.
1782 */
1783
1784static int iw_get_rts_threshold(struct net_device *dev,
1785 struct iw_request_info *info,
1786 union iwreq_data *wrqu, char *extra)
1787{
1788 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1789 v_U32_t status = 0;
1790
1791 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
1792
1793 return status;
1794}
1795
1796static int iw_set_rts_threshold(struct net_device *dev,
1797 struct iw_request_info *info,
1798 union iwreq_data *wrqu, char *extra)
1799{
1800 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1801 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1802
1803 ENTER();
1804
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001805 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1806 {
1807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1808 "%s:LOGP in Progress. Ignore!!!", __func__);
1809 return -EAGAIN;
1810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
1812 {
1813 return -EINVAL;
1814 }
1815
1816 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1817 {
1818 return -EIO;
1819 }
1820
1821 EXIT();
1822
1823 return 0;
1824}
1825
1826static int iw_get_frag_threshold(struct net_device *dev,
1827 struct iw_request_info *info,
1828 union iwreq_data *wrqu, char *extra)
1829{
1830 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1831 v_U32_t status = 0;
1832
1833 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
1834
1835 return status;
1836}
1837
1838static int iw_set_frag_threshold(struct net_device *dev,
1839 struct iw_request_info *info,
1840 union iwreq_data *wrqu, char *extra)
1841{
1842 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1843 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1844
1845 ENTER();
1846
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001847 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1848 {
1849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1850 "%s:LOGP in Progress. Ignore!!!", __func__);
1851 return -EBUSY;
1852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
1854 {
1855 return -EINVAL;
1856 }
1857
1858 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1859 {
1860 return -EIO;
1861 }
1862
1863 EXIT();
1864
1865 return 0;
1866}
1867
1868static int iw_get_power_mode(struct net_device *dev,
1869 struct iw_request_info *info,
1870 union iwreq_data *wrqu, char *extra)
1871{
1872 ENTER();
1873 return -EOPNOTSUPP;
1874}
1875
1876static int iw_set_power_mode(struct net_device *dev,
1877 struct iw_request_info *info,
1878 union iwreq_data *wrqu, char *extra)
1879{
1880 ENTER();
1881 return -EOPNOTSUPP;
1882}
1883
1884static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
1885 union iwreq_data *wrqu, char *extra)
1886{
1887 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1888 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1889 struct iw_range *range = (struct iw_range *) extra;
1890
1891 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1892
1893 v_U32_t num_channels = sizeof(channels);
1894 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1895 v_U32_t a_len;
1896 v_U32_t b_len;
1897 v_U32_t active_phy_mode = 0;
1898 v_U8_t index = 0, i;
1899
1900 ENTER();
1901
1902 wrqu->data.length = sizeof(struct iw_range);
1903 memset(range, 0, sizeof(struct iw_range));
1904
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08001905 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1906 {
1907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1908 "%s:LOGP in Progress. Ignore!!!", __func__);
1909 return -EBUSY;
1910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001911
1912 /*Get the phy mode*/
1913 if (ccmCfgGetInt(hHal,
1914 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1915 {
1916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1917 "active_phy_mode = %ld", active_phy_mode);
1918
1919 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
1920 {
1921 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07001922 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 if (ccmCfgGetStr(hHal,
1924 WNI_CFG_SUPPORTED_RATES_11A,
1925 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
1926 {
1927 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
1928 {
1929 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1930 }
1931 for (i = 0; i < a_len; i++)
1932 {
1933 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
1934 }
1935 range->num_bitrates = a_len;
1936 }
1937 else
1938 {
1939 return -EIO;
1940 }
1941 }
1942 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1943 {
1944 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07001945 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 if (ccmCfgGetStr(hHal,
1947 WNI_CFG_SUPPORTED_RATES_11B,
1948 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
1949 {
1950 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
1951 {
1952 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1953 }
1954 for (i = 0; i < b_len; i++)
1955 {
1956 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
1957 }
1958 range->num_bitrates = b_len;
1959 }
1960 else
1961 {
1962 return -EIO;
1963 }
1964 }
1965 }
1966
1967 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
1968 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
1969 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
1970
1971 range->encoding_size[0] = 5;
1972 range->encoding_size[1] = 13;
1973 range->num_encoding_sizes = 2;
1974 range->max_encoding_tokens = MAX_WEP_KEYS;
1975
1976 // we support through Wireless Extensions 22
1977 range->we_version_compiled = WIRELESS_EXT;
1978 range->we_version_source = 22;
1979
1980 /*Supported Channels and Frequencies*/
1981 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
1982 {
1983 return -EIO;
1984 }
1985 if (num_channels > IW_MAX_FREQUENCIES)
1986 {
1987 num_channels = IW_MAX_FREQUENCIES;
1988 }
1989
1990 range->num_channels = num_channels;
1991 range->num_frequency = num_channels;
1992
1993 for (index=0; index < num_channels; index++)
1994 {
1995 v_U32_t frq_indx = 0;
1996
1997 range->freq[index].i = channels[index];
1998 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
1999 {
2000 if(channels[index] == freq_chan_map[frq_indx].chan)
2001 {
2002 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2003 range->freq[index].e = 1;
2004 break;
2005 }
2006 frq_indx++;
2007 }
2008 }
2009
2010 /* Event capability (kernel + driver) */
2011 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2012 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2013 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2014 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2015
2016 /*Encryption capability*/
2017 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2018 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2019
2020 /* Txpower capability */
2021 range->txpower_capa = IW_TXPOW_MWATT;
2022
2023 /*Scanning capability*/
2024 #if WIRELESS_EXT >= 22
2025 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2026 #endif
2027
2028 EXIT();
2029 return 0;
2030}
2031
2032/* Callback function registered with PMC to know status of PMC request */
2033static void iw_power_callback_fn (void *pContext, eHalStatus status)
2034{
2035 struct statsContext *pStatsContext;
2036 hdd_adapter_t *pAdapter;
2037
2038 if (NULL == pContext)
2039 {
2040 hddLog(VOS_TRACE_LEVEL_ERROR,
2041 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002042 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 return;
2044 }
2045
2046 /* there is a race condition that exists between this callback function
2047 and the caller since the caller could time out either before or
2048 while this code is executing. we'll assume the timeout hasn't
2049 occurred, but we'll verify that right before we save our work */
2050
2051 pStatsContext = (struct statsContext *)pContext;
2052 pAdapter = pStatsContext->pAdapter;
2053
2054 if ((NULL == pAdapter) || (POWER_CONTEXT_MAGIC != pStatsContext->magic))
2055 {
2056 /* the caller presumably timed out so there is nothing we can do */
2057 hddLog(VOS_TRACE_LEVEL_WARN,
2058 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002059 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002060
2061 if (ioctl_debug)
2062 {
2063 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002064 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 }
2066 return;
2067 }
2068
2069 /* and notify the caller */
2070 complete(&pStatsContext->completion);
2071}
2072
2073/* Callback function for tx per hit */
2074void hdd_tx_per_hit_cb (void *pCallbackContext)
2075{
2076 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2077 unsigned char tx_fail[16];
2078 union iwreq_data wrqu;
2079
2080 if (NULL == pAdapter)
2081 {
2082 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL\n");
2083 return;
2084 }
2085 memset(&wrqu, 0, sizeof(wrqu));
2086 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2087 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2088}
2089
2090void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2091{
2092 struct statsContext *pStatsContext;
2093 tCsrGlobalClassAStatsInfo *pClassAStats;
2094 hdd_adapter_t *pAdapter;
2095
2096 if (ioctl_debug)
2097 {
2098 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002099 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 }
2101
2102 if ((NULL == pStats) || (NULL == pContext))
2103 {
2104 hddLog(VOS_TRACE_LEVEL_ERROR,
2105 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002106 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 return;
2108 }
2109
2110 /* there is a race condition that exists between this callback function
2111 and the caller since the caller could time out either before or
2112 while this code is executing. we'll assume the timeout hasn't
2113 occurred, but we'll verify that right before we save our work */
2114
2115 pClassAStats = pStats;
2116 pStatsContext = pContext;
2117 pAdapter = pStatsContext->pAdapter;
2118 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2119 {
2120 /* the caller presumably timed out so there is nothing we can do */
2121 hddLog(VOS_TRACE_LEVEL_WARN,
2122 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002123 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 if (ioctl_debug)
2125 {
2126 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002127 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 }
2129 return;
2130 }
2131
2132 /* the race is on. caller could have timed out immediately after
2133 we verified the magic, but if so, caller will wait a short time
2134 for us to copy over the stats. do so as a struct copy */
2135 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2136
2137 /* and notify the caller */
2138 complete(&pStatsContext->completion);
2139}
2140
2141VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2142{
2143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2144 eHalStatus hstatus;
2145 long lrc;
2146 struct statsContext context;
2147
2148 if (NULL == pAdapter)
2149 {
2150 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2151 return VOS_STATUS_E_FAULT;
2152 }
2153 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2154 {
2155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2156 return VOS_STATUS_SUCCESS;
2157 }
2158
2159 /* we are connected
2160 prepare our callback context */
2161 init_completion(&context.completion);
2162 context.pAdapter = pAdapter;
2163 context.magic = STATS_CONTEXT_MAGIC;
2164 /* query only for Class A statistics (which include link speed) */
2165 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2166 eCSR_HDD,
2167 SME_GLOBAL_CLASSA_STATS,
2168 hdd_GetClassA_statisticsCB,
2169 0, // not periodic
2170 FALSE, //non-cached results
2171 pHddStaCtx->conn_info.staId[0],
2172 &context);
2173 if (eHAL_STATUS_SUCCESS != hstatus)
2174 {
2175 hddLog(VOS_TRACE_LEVEL_ERROR,
2176 "%s: Unable to retrieve Class A statistics ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002177 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 /* we'll returned a cached value below */
2179 }
2180 else
2181 {
2182 /* request was sent -- wait for the response */
2183 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2184 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2185 /* either we have a response or we timed out
2186 either way, first invalidate our magic */
2187 context.magic = 0;
2188 if (lrc <= 0)
2189 {
2190 hddLog(VOS_TRACE_LEVEL_ERROR,
2191 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002192 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 /* there is a race condition such that the callback
2194 function could be executing at the same time we are. of
2195 primary concern is if the callback function had already
2196 verified the "magic" but hasn't yet set the completion
2197 variable. Since the completion variable is on our
2198 stack, we'll delay just a bit to make sure the data is
2199 still valid if that is the case */
2200 msleep(50);
2201 }
2202 }
2203 return VOS_STATUS_SUCCESS;
2204}
2205
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002206static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2207{
2208 struct statsContext *pStatsContext;
2209 tCsrSummaryStatsInfo *pSummaryStats;
2210 tCsrGlobalClassAStatsInfo *pClassAStats;
2211 hdd_adapter_t *pAdapter;
2212
2213 if (ioctl_debug)
2214 {
2215 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002216 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002217 }
2218
2219 if ((NULL == pStats) || (NULL == pContext))
2220 {
2221 hddLog(VOS_TRACE_LEVEL_ERROR,
2222 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002223 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002224 return;
2225 }
2226
2227 /* there is a race condition that exists between this callback function
2228 and the caller since the caller could time out either before or
2229 while this code is executing. we'll assume the timeout hasn't
2230 occurred, but we'll verify that right before we save our work */
2231
2232 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2233 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2234 pStatsContext = pContext;
2235 pAdapter = pStatsContext->pAdapter;
2236 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2237 {
2238 /* the caller presumably timed out so there is nothing we can do */
2239 hddLog(VOS_TRACE_LEVEL_WARN,
2240 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002241 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002242 if (ioctl_debug)
2243 {
2244 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002245 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002246 }
2247 return;
2248 }
2249
2250 /* the race is on. caller could have timed out immediately after
2251 we verified the magic, but if so, caller will wait a short time
2252 for us to copy over the stats. do so as a struct copy */
2253 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2254 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2255
2256 /* and notify the caller */
2257 complete(&pStatsContext->completion);
2258}
2259
2260VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2261{
2262 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2263 eHalStatus hstatus;
2264 long lrc;
2265 struct statsContext context;
2266
2267 if (NULL == pAdapter)
2268 {
2269 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2270 return VOS_STATUS_SUCCESS;
2271 }
2272
2273 /* we are connected
2274 prepare our callback context */
2275 init_completion(&context.completion);
2276 context.pAdapter = pAdapter;
2277 context.magic = STATS_CONTEXT_MAGIC;
2278
2279 /* query only for Summary & Class A statistics */
2280 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2281 eCSR_HDD,
2282 SME_SUMMARY_STATS |
2283 SME_GLOBAL_CLASSA_STATS,
2284 hdd_get_station_statisticsCB,
2285 0, // not periodic
2286 FALSE, //non-cached results
2287 pHddStaCtx->conn_info.staId[0],
2288 &context);
2289 if (eHAL_STATUS_SUCCESS != hstatus)
2290 {
2291 hddLog(VOS_TRACE_LEVEL_ERROR,
2292 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002293 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002294 /* we'll return with cached values */
2295 }
2296 else
2297 {
2298 /* request was sent -- wait for the response */
2299 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2300 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2301 /* either we have a response or we timed out
2302 either way, first invalidate our magic */
2303 context.magic = 0;
2304 if (lrc <= 0)
2305 {
2306 hddLog(VOS_TRACE_LEVEL_ERROR,
2307 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002308 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002309 /* there is a race condition such that the callback
2310 function could be executing at the same time we are. of
2311 primary concern is if the callback function had already
2312 verified the "magic" but hasn't yet set the completion
2313 variable. Since the completion variable is on our
2314 stack, we'll delay just a bit to make sure the data is
2315 still valid if that is the case */
2316 msleep(50);
2317 }
2318 }
2319 return VOS_STATUS_SUCCESS;
2320}
2321
2322
Jeff Johnson295189b2012-06-20 16:38:30 -07002323/*
2324 * Support for the LINKSPEED private command
2325 * Per the WiFi framework the response must be of the form
2326 * "LinkSpeed xx"
2327 */
2328static int iw_get_linkspeed(struct net_device *dev,
2329 struct iw_request_info *info,
2330 union iwreq_data *wrqu, char *extra)
2331{
2332 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302333 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302335 int len = sizeof(v_U32_t) + 1;
2336 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302338 VOS_STATUS status;
2339 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002340
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302341 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2342
2343 valid = wlan_hdd_validate_context(pHddCtx);
2344
2345 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002346 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302347 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2348 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002349 }
2350
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2352 {
2353 /* we are not connected so we don't have a classAstats */
2354 link_speed = 0;
2355 }
2356 else
2357 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302358 status = wlan_hdd_get_classAstats(pAdapter);
2359
2360 if (!VOS_IS_STATUS_SUCCESS(status ))
2361 {
2362 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2363 return -EINVAL;
2364 }
2365
2366 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2367 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2368 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2369 &link_speed);
2370
2371 link_speed = link_speed / 10;
2372
2373 if (0 == link_speed)
2374 {
2375 /* The linkspeed returned by HAL is in units of 500kbps.
2376 * converting it to mbps.
2377 * This is required to support legacy firmware which does
2378 * not return link capacity.
2379 */
2380 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2381 }
2382
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 }
2384
2385 wrqu->data.length = len;
2386 // return the linkspeed in the format required by the WiFi Framework
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302387 rc = snprintf(pLinkSpeed, len, "%lu", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 if ((rc < 0) || (rc >= len))
2389 {
2390 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302391 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 return -EIO;
2393 }
2394
2395 /* a value is being successfully returned */
2396 return 0;
2397}
2398
2399
2400/*
2401 * Support for the RSSI & RSSI-APPROX private commands
2402 * Per the WiFi framework the response must be of the form
2403 * "<ssid> rssi <xx>"
2404 * unless we are not associated, in which case the response is
2405 * "OK"
2406 */
2407static int iw_get_rssi(struct net_device *dev,
2408 struct iw_request_info *info,
2409 union iwreq_data *wrqu, char *extra)
2410{
2411 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2412 char *cmd = (char*)wrqu->data.pointer;
2413 int len = wrqu->data.length;
2414 v_S7_t s7Rssi = 0;
2415 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2416 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2417 VOS_STATUS vosStatus;
2418 int rc;
2419
2420 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2421 (0 == ssidlen) || (ssidlen >= len))
2422 {
2423 /* we are not connected or our SSID is too long
2424 so we cannot report an rssi */
2425 rc = snprintf(cmd, len, "OK");
2426 }
2427 else
2428 {
2429 /* we are connected with a valid SSID
2430 so we can write the SSID into the return buffer
2431 (note that it is not NUL-terminated) */
2432 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2433
2434 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2435
2436 if (VOS_STATUS_SUCCESS == vosStatus)
2437 {
2438 /* append the rssi to the ssid in the format required by
2439 the WiFI Framework */
2440 rc = snprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
2441 }
2442 else
2443 {
2444 rc = -1;
2445 }
2446 }
2447
2448 /* verify that we wrote a valid response */
2449 if ((rc < 0) || (rc >= len))
2450 {
2451 // encoding or length error?
2452 hddLog(VOS_TRACE_LEVEL_ERROR,
2453 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002454 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 return -EIO;
2456 }
2457
2458 /* a value is being successfully returned */
2459 return 0;
2460}
2461
2462/*
2463 * Support for SoftAP channel range private command
2464 */
2465static int iw_softap_set_channel_range( struct net_device *dev,
2466 int startChannel,
2467 int endChannel,
2468 int band)
2469{
Jeff Johnson43971f52012-07-17 12:26:56 -07002470 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 int ret = 0;
2472 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2473 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002474 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2475
Jeff Johnson295189b2012-06-20 16:38:30 -07002476
2477 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2478 if (VOS_STATUS_SUCCESS != status)
2479 {
2480 ret = -EINVAL;
2481 }
Yathish9f22e662012-12-10 14:21:35 -08002482 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 return ret;
2484}
2485
2486VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2487{
2488 struct statsContext context;
2489 eHalStatus status;
2490 hdd_context_t *pHddCtx;
2491
2492 if (NULL == pAdapter)
2493 {
2494 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2495 return VOS_STATUS_E_FAULT;
2496 }
2497
2498 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2499 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2500 init_completion(&context.completion);
2501
2502 context.pAdapter = pAdapter;
2503 context.magic = POWER_CONTEXT_MAGIC;
2504
2505 if (DRIVER_POWER_MODE_ACTIVE == mode)
2506 {
2507 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2508 "Full Power", __func__);
2509 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2510 iw_power_callback_fn, &context,
2511 eSME_FULL_PWR_NEEDED_BY_HDD);
2512 // Enter Full power command received from GUI this means we are disconnected
2513 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2514 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2515 if (eHAL_STATUS_PMC_PENDING == status)
2516 {
2517 int lrc = wait_for_completion_interruptible_timeout(
2518 &context.completion,
2519 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2520 context.magic = 0;
2521 if (lrc <= 0)
2522 {
2523 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002524 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 /* there is a race condition such that the callback
2526 function could be executing at the same time we are. of
2527 primary concern is if the callback function had already
2528 verified the "magic" but hasn't yet set the completion
2529 variable. Since the completion variable is on our
2530 stack, we'll delay just a bit to make sure the data is
2531 still valid if that is the case */
2532 msleep(50);
2533 /* we'll now returned a cached value below */
2534 }
2535 }
2536 }
2537 else if (DRIVER_POWER_MODE_AUTO == mode)
2538 {
2539 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2540 {
2541 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2542 __func__);
2543 // Enter BMPS command received from GUI this means DHCP is completed
2544 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2545 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2546 FALSE);
2547 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2548 iw_power_callback_fn, &context);
2549 if (eHAL_STATUS_PMC_PENDING == status)
2550 {
2551 int lrc = wait_for_completion_interruptible_timeout(
2552 &context.completion,
2553 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
2554 context.magic = 0;
2555 if (lrc <= 0)
2556 {
2557 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting BMPS ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002558 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 /* there is a race condition such that the callback
2560 function could be executing at the same time we are. of
2561 primary concern is if the callback function had already
2562 verified the "magic" but hasn't yet set the completion
2563 variable. Since the completion variable is on our
2564 stack, we'll delay just a bit to make sure the data is
2565 still valid if that is the case */
2566 msleep(50);
2567 /* we'll now returned a cached value below */
2568 }
2569 }
2570 }
2571 else
2572 {
2573 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2574 "enabled in the cfg");
2575 }
2576 }
2577 return VOS_STATUS_SUCCESS;
2578}
2579
2580VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2581 hdd_adapter_t *pAdapter)
2582{
2583 VOS_STATUS vos_Status;
2584
2585 if ((NULL == pAdapter) || (NULL == pHddCtx))
2586 {
2587 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2588 return VOS_STATUS_E_FAULT;
2589 }
2590
2591 /**Exit from Deep sleep or standby if we get the driver
2592 START cmd from android GUI
2593 */
2594 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2595 {
2596 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2597 "from Stand by",__func__);
2598 vos_Status = hdd_exit_standby(pHddCtx);
2599 }
2600 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2601 {
2602 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2603 "from deep sleep",__func__);
2604 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2605 }
2606 else
2607 {
2608 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2609 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2610 vos_Status = VOS_STATUS_SUCCESS;
2611 }
2612
2613 return vos_Status;
2614}
2615
2616VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2617{
2618 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2619
2620 if (NULL == pHddCtx)
2621 {
2622 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "HDD context NULL");
2623 return VOS_STATUS_E_FAULT;
2624 }
2625
2626 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2627 {
2628 //Execute standby procedure.
2629 //Executing standby procedure will cause the STA to
2630 //disassociate first and then the chip will be put into standby.
2631 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2632 vos_Status = hdd_enter_standby(pHddCtx);
2633 }
2634 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2635 pHddCtx->cfg_ini->nEnableDriverStop)
2636 {
2637 //Execute deep sleep procedure
2638 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
2639 "deep sleep mode\n");
2640 //Deep sleep not supported
2641 vos_Status = hdd_enter_standby(pHddCtx);
2642 }
2643 else
2644 {
2645 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2646 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2647 vos_Status = VOS_STATUS_SUCCESS;
2648 }
2649
2650 return vos_Status;
2651}
2652
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002653
2654void* wlan_hdd_change_country_code_callback(void *pAdapter)
2655{
2656
2657 hdd_adapter_t *call_back_pAdapter = pAdapter;
2658
2659 complete(&call_back_pAdapter->change_country_code);
2660
2661 return NULL;
2662}
2663
Jeff Johnson295189b2012-06-20 16:38:30 -07002664static int iw_set_priv(struct net_device *dev,
2665 struct iw_request_info *info,
2666 union iwreq_data *wrqu, char *extra)
2667{
2668 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2669 char *cmd = (char*)wrqu->data.pointer;
2670 int cmd_len = wrqu->data.length;
2671 int ret = 0;
2672 int status = 0;
2673 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2674
2675 ENTER();
2676
2677 if (ioctl_debug)
2678 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002679 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 }
2681
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002682 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2683 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002684
2685 if (pHddCtx->isLogpInProgress) {
2686 if (ioctl_debug)
2687 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002688 pr_info("%s: RESTART in progress\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 }
2690
2691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2692 "%s:LOGP in Progress. Ignore!!!",__func__);
2693 return status;
2694 }
2695
2696 if(strncmp(cmd, "CSCAN",5) == 0 )
2697 {
2698 status = iw_set_cscan(dev, info, wrqu, extra);
2699 }
2700 else if( strcasecmp(cmd, "start") == 0 ) {
2701
2702 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command\n");
2703 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
2704 status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
2705
2706 if(status == VOS_STATUS_SUCCESS)
2707 {
2708 union iwreq_data wrqu;
2709 char buf[10];
2710
2711 memset(&wrqu, 0, sizeof(wrqu));
2712 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
2713 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2714 }
2715 else
2716 {
2717 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: START CMD Status %d", __func__, status);
2718 }
2719 goto done;
2720 }
2721 else if( strcasecmp(cmd, "stop") == 0 )
2722 {
2723 union iwreq_data wrqu;
2724 char buf[10];
2725
2726 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command\n");
2727
2728 wlan_hdd_enter_lowpower(pHddCtx);
2729 memset(&wrqu, 0, sizeof(wrqu));
2730 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
2731 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
2732 status = VOS_STATUS_SUCCESS;
2733 goto done;
2734 }
2735 else if (strcasecmp(cmd, "macaddr") == 0)
2736 {
2737 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
2738 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
2739 }
2740 else if (strcasecmp(cmd, "scan-active") == 0)
2741 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002742 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 ret = snprintf(cmd, cmd_len, "OK");
2744 }
2745 else if (strcasecmp(cmd, "scan-passive") == 0)
2746 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002747 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 ret = snprintf(cmd, cmd_len, "OK");
2749 }
2750 else if( strcasecmp(cmd, "scan-mode") == 0 )
2751 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002752 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 }
2754 else if( strcasecmp(cmd, "linkspeed") == 0 )
2755 {
2756 status = iw_get_linkspeed(dev, info, wrqu, extra);
2757 }
2758 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
2759 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002760 long lrc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002761
2762 country_code = cmd + 8;
2763
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002764 init_completion(&pAdapter->change_country_code);
2765
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002767 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 country_code,
2769 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05302770 pHddCtx->pvosContext,
2771 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002772
2773 /* Wait for completion */
2774 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
2775 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2776
2777 if (lrc <= 0)
2778 {
2779 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002780 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002781 }
2782
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 if( 0 != status )
2784 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002785 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2786 "%s: SME Change Country code fail \n",__func__);
2787 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 }
2789 }
2790 else if( strncasecmp(cmd, "rssi", 4) == 0 )
2791 {
2792 status = iw_get_rssi(dev, info, wrqu, extra);
2793 }
2794 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
2795 int mode;
2796 char *ptr = (char*)(cmd + 9);
2797
2798 sscanf(ptr,"%d",&mode);
2799 wlan_hdd_enter_bmps(pAdapter, mode);
2800 /*TODO:Set the power mode*/
2801 }
2802 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
2803 v_U32_t pmc_state;
2804 v_U16_t value;
2805
2806 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
2807 if(pmc_state == BMPS) {
2808 value = DRIVER_POWER_MODE_AUTO;
2809 }
2810 else {
2811 value = DRIVER_POWER_MODE_ACTIVE;
2812 }
2813 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
2814 }
2815 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
2816 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode\n");
2817 /*TODO: set the btcoexmode*/
2818 }
2819 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
2820
2821 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status\n");
2822 /*TODO: Return the btcoex status*/
2823 }
2824 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
2825
2826 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command\n");
2827
2828 /*TODO: Enable Rx data Filter*/
2829 }
2830 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
2831
2832 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command\n");
2833
2834 /*TODO: Disable Rx data Filter*/
2835 }
2836 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
2837
2838 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command\n");
2839 /*TODO: rxfilter-statistics*/
2840 }
2841 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
2842
2843 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add\n");
2844 /*TODO: rxfilter-add*/
2845 }
2846 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
2847
2848 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove\n");
2849 /*TODO: rxfilter-remove*/
2850 }
2851#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07002852 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
2853 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
2854 /*TODO: support pnosetup*/
2855 }
2856 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
2857 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
2858 /*TODO: support pnoforce*/
2859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 else if( strncasecmp(cmd, "pno",3) == 0 ) {
2861
2862 hddLog( VOS_TRACE_LEVEL_INFO, "pno\n");
2863 status = iw_set_pno(dev, info, wrqu, extra, 3);
2864 return status;
2865 }
2866 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
2867
2868 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter\n");
2869 status = iw_set_rssi_filter(dev, info, wrqu, extra, 10);
2870 return status;
2871 }
2872#endif /*FEATURE_WLAN_SCAN_PNO*/
2873 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
2874 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams\n");
2875 status = iw_set_power_params(dev, info, wrqu, extra, 11);
2876 return status;
2877 }
2878 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
2879 tSirTxPerTrackingParam tTxPerTrackingParam;
2880 char *ptr = (char*)(cmd + 18);
2881 sscanf(ptr,"%hhu %hhu %hhu %lu",&(tTxPerTrackingParam.ucTxPerTrackingEnable), &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
2882 &(tTxPerTrackingParam.ucTxPerTrackingRatio), &(tTxPerTrackingParam.uTxPerTrackingWatermark));
2883
2884 // parameters checking
2885 // period has to be larger than 0
2886 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
2887 {
2888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
2889 return VOS_STATUS_E_FAILURE;
2890 }
2891
2892 // use default value 5 is the input is not reasonable. in unit of 10%
2893 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
2894 {
2895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
2896 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
2897 }
2898
2899 // default is 5
2900 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
2901 {
2902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
2903 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
2904 }
2905
2906 status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam);
2907 if(status != eHAL_STATUS_SUCCESS){
2908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
2909 }
2910 }
2911 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002912 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
2913 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 }
2915done:
2916 /* many of the commands write information back into the command
2917 string using snprintf(). check the return value here in one
2918 place */
2919 if ((ret < 0) || (ret >= cmd_len))
2920 {
2921 /* there was an encoding error or overflow */
2922 status = -EIO;
2923 }
2924
2925 if (ioctl_debug)
2926 {
2927 pr_info("%s: rsp [%s] len [%d] status %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002928 __func__, cmd, wrqu->data.length, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 }
2930 return status;
2931
2932}
2933
2934static int iw_set_nick(struct net_device *dev,
2935 struct iw_request_info *info,
2936 union iwreq_data *wrqu, char *extra)
2937{
2938 ENTER();
2939 return 0;
2940}
2941
2942static int iw_get_nick(struct net_device *dev,
2943 struct iw_request_info *info,
2944 union iwreq_data *wrqu, char *extra)
2945{
2946 ENTER();
2947 return 0;
2948}
2949
2950static struct iw_statistics *get_wireless_stats(struct net_device *dev)
2951{
2952 ENTER();
2953 return NULL;
2954}
2955
2956static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
2957 union iwreq_data *wrqu,char *extra)
2958
2959{
2960 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2961 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2962 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2963 struct iw_point *encoderq = &(wrqu->encoding);
2964 v_U32_t keyId;
2965 v_U8_t key_length;
2966 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
2967 v_BOOL_t fKeyPresent = 0;
2968 int i;
2969 eHalStatus status = eHAL_STATUS_SUCCESS;
2970
2971
2972 ENTER();
2973
2974 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2975 {
2976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2977 "%s:LOGP in Progress. Ignore!!!",__func__);
2978 return 0;
2979 }
2980
2981
2982 keyId = encoderq->flags & IW_ENCODE_INDEX;
2983
2984 if(keyId)
2985 {
2986 if(keyId > MAX_WEP_KEYS)
2987 {
2988 return -EINVAL;
2989 }
2990
2991 fKeyPresent = 1;
2992 keyId--;
2993 }
2994 else
2995 {
2996 fKeyPresent = 0;
2997 }
2998
2999
3000 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3001 {
3002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****\n");
3003 if(!fKeyPresent) {
3004
3005 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3006
3007 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3008 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3009 }
3010 }
3011 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3012 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3013 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3014 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3015
3016 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3017 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3018
3019 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3020 {
3021 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3022 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003023 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3025 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3026 }
3027
3028 return status;
3029
3030 }
3031
3032 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3033 {
3034 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3035
3036 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3037
3038 }
3039
3040
3041 if(wrqu->data.length > 0)
3042 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003043 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003044
3045 key_length = wrqu->data.length;
3046
3047 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3048
3049 if(5 == key_length)
3050 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003051 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003052
3053 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3054 {
3055 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3056 }
3057 else
3058 {
3059 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3060 }
3061 }
3062 else if(13 == key_length)
3063 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003064 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003065
3066 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3067 {
3068 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3069 }
3070 else
3071 {
3072 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3073 }
3074 }
3075 else
3076 {
3077 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003078 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 return -EINVAL;
3080 }
3081
3082 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3083 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3084 pWextState->roamProfile.EncryptionType.numEntries = 1;
3085 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3086 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3087 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3088
3089 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3090 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3091 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3092 {
3093
3094 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3095
3096 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3097 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3098
3099 return status;
3100 }
3101 }
3102
3103 return 0;
3104}
3105
3106static int iw_get_encodeext(struct net_device *dev,
3107 struct iw_request_info *info,
3108 struct iw_point *dwrq,
3109 char *extra)
3110{
3111 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3112 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3113 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3114 int keyId;
3115 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3116 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3117 int i;
3118
3119 ENTER();
3120
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003121 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3122 {
3123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3124 "%s:LOGP in Progress. Ignore!!!", __func__);
3125 return -EBUSY;
3126 }
3127
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 keyId = pRoamProfile->Keys.defaultIndex;
3129
3130 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3131 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003132 hddLog(LOG1,"%s: Invalid keyId : %d\n",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 return -EINVAL;
3134 }
3135
3136 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3137 {
3138 dwrq->flags |= IW_ENCODE_ENABLED;
3139 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
3140 palCopyMemory(dev,extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
3141 }
3142 else
3143 {
3144 dwrq->flags |= IW_ENCODE_DISABLED;
3145 }
3146
3147 for(i=0; i < MAX_WEP_KEYS; i++)
3148 {
3149 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3150 {
3151 continue;
3152 }
3153 else
3154 {
3155 break;
3156 }
3157 }
3158
3159 if(MAX_WEP_KEYS == i)
3160 {
3161 dwrq->flags |= IW_ENCODE_NOKEY;
3162 }
3163 else
3164 {
3165 dwrq->flags |= IW_ENCODE_ENABLED;
3166 }
3167
3168 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3169
3170 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3171 {
3172 dwrq->flags |= IW_ENCODE_DISABLED;
3173 }
3174
3175 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3176
3177 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3178 {
3179 dwrq->flags |= IW_ENCODE_OPEN;
3180 }
3181 else
3182 {
3183 dwrq->flags |= IW_ENCODE_RESTRICTED;
3184 }
3185 EXIT();
3186 return 0;
3187
3188}
3189
3190static int iw_set_encodeext(struct net_device *dev,
3191 struct iw_request_info *info,
3192 union iwreq_data *wrqu, char *extra)
3193{
3194 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3195 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3196 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3197 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3198
3199 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3200 v_U32_t status = 0;
3201
3202 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3203
3204 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3205
3206 int key_index;
3207 struct iw_point *encoding = &wrqu->encoding;
3208 tCsrRoamSetKey setKey;
3209 v_U32_t roamId= 0xFF;
3210 VOS_STATUS vos_status;
3211
3212 ENTER();
3213
3214 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3215 {
3216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3217 "%s:LOGP in Progress. Ignore!!!",__func__);
3218 return 0;
3219 }
3220
3221 key_index = encoding->flags & IW_ENCODE_INDEX;
3222
3223 if(key_index > 0) {
3224
3225 /*Convert from 1-based to 0-based keying*/
3226 key_index--;
3227 }
3228 if(!ext->key_len) {
3229
3230 /*Set the encrytion type to NONE*/
3231 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3232 return status;
3233 }
3234
3235 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3236 (IW_ENCODE_ALG_WEP == ext->alg))
3237 {
3238 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3239
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003240 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s \n"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 return -EINVAL;
3242 }
3243 else {
3244 /*Static wep, update the roam profile with the keys */
3245 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3246 key_index < CSR_MAX_NUM_KEY) {
3247 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3248 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3249
3250 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3251 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3252
3253 }
3254 }
3255 return status;
3256 }
3257
3258 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3259
3260 setKey.keyId = key_index;
3261 setKey.keyLength = ext->key_len;
3262
3263 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3264 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3265 }
3266
3267 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3268 /*Key direction for group is RX only*/
3269 setKey.keyDirection = eSIR_RX_ONLY;
3270 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3271 }
3272 else {
3273
3274 setKey.keyDirection = eSIR_TX_RX;
3275 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3276 }
3277
3278 /*For supplicant pae role is zero*/
3279 setKey.paeRole = 0;
3280
3281 switch(ext->alg)
3282 {
3283 case IW_ENCODE_ALG_NONE:
3284 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3285 break;
3286
3287 case IW_ENCODE_ALG_WEP:
3288 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3289 break;
3290
3291 case IW_ENCODE_ALG_TKIP:
3292 {
3293 v_U8_t *pKey = &setKey.Key[0];
3294
3295 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3296
3297 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3298
3299 /*Supplicant sends the 32bytes key in this order
3300
3301 |--------------|----------|----------|
3302 | Tk1 |TX-MIC | RX Mic |
3303 |--------------|----------|----------|
3304 <---16bytes---><--8bytes--><--8bytes-->
3305
3306 */
3307 /*Sme expects the 32 bytes key to be in the below order
3308
3309 |--------------|----------|----------|
3310 | Tk1 |RX-MIC | TX Mic |
3311 |--------------|----------|----------|
3312 <---16bytes---><--8bytes--><--8bytes-->
3313 */
3314 /* Copy the Temporal Key 1 (TK1) */
3315 vos_mem_copy(pKey,ext->key,16);
3316
3317 /*Copy the rx mic first*/
3318 vos_mem_copy(&pKey[16],&ext->key[24],8);
3319
3320 /*Copy the tx mic */
3321 vos_mem_copy(&pKey[24],&ext->key[16],8);
3322
3323 }
3324 break;
3325
3326 case IW_ENCODE_ALG_CCMP:
3327 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3328 break;
3329
3330#ifdef FEATURE_WLAN_CCX
3331#define IW_ENCODE_ALG_KRK 6
3332 case IW_ENCODE_ALG_KRK:
3333 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3334 break;
3335#endif /* FEATURE_WLAN_CCX */
3336
3337 default:
3338 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3339 break;
3340 }
3341
3342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003343 ("%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 -07003344
3345#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303346 /* The supplicant may attempt to set the PTK once pre-authentication
3347 is done. Save the key in the UMAC and include it in the ADD
3348 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303350 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303352 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3353 "%s: Update PreAuth Key success", __func__);
3354 return 0;
3355 }
3356 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3357 {
3358 hddLog(VOS_TRACE_LEVEL_ERROR,
3359 "%s: Update PreAuth Key failed", __func__);
3360 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 }
3362#endif /* WLAN_FEATURE_VOWIFI_11R */
3363
3364 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3365
3366 vos_status = wlan_hdd_check_ula_done(pAdapter);
3367 if ( vos_status != VOS_STATUS_SUCCESS )
3368 {
3369 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3370 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3371 __LINE__, vos_status );
3372
3373 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3374 }
3375
3376 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3377
3378 if ( halStatus != eHAL_STATUS_SUCCESS )
3379 {
3380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3381 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3382 __LINE__, halStatus );
3383
3384 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3385 }
3386
3387 return halStatus;
3388}
3389
3390static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3391 union iwreq_data *wrqu, char *extra)
3392{
3393 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3394 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3395
3396 ENTER();
3397
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003398 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3399 {
3400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3401 "%s:LOGP in Progress. Ignore!!!", __func__);
3402 return -EBUSY;
3403 }
3404
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3406 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3407
3408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%ld!!\n"),wrqu->retry.value);
3409
3410 return -EINVAL;
3411 }
3412
3413 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3414
3415 if((wrqu->retry.flags & IW_RETRY_LONG))
3416 {
3417 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3418 {
3419 return -EIO;
3420 }
3421 }
3422 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3423 {
3424 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3425 {
3426 return -EIO;
3427 }
3428 }
3429 }
3430 else
3431 {
3432 return -EOPNOTSUPP;
3433 }
3434
3435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%ld!!\n"),wrqu->retry.value);
3436
3437 EXIT();
3438
3439 return 0;
3440
3441}
3442
3443static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3444 union iwreq_data *wrqu, char *extra)
3445{
3446 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3447 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3448 v_U32_t retry = 0;
3449
3450 ENTER();
3451
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003452 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3453 {
3454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3455 "%s:LOGP in Progress. Ignore!!!", __func__);
3456 return -EBUSY;
3457 }
3458
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 if((wrqu->retry.flags & IW_RETRY_LONG))
3460 {
3461 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3462
3463 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3464 {
3465 return -EIO;
3466 }
3467
3468 wrqu->retry.value = retry;
3469 }
3470 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3471 {
3472 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3473
3474 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3475 {
3476 return -EIO;
3477 }
3478
3479 wrqu->retry.value = retry;
3480 }
3481 else {
3482 return -EOPNOTSUPP;
3483 }
3484
3485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%ld!!\n"),retry);
3486
3487 EXIT();
3488
3489 return 0;
3490}
3491
3492static int iw_set_mlme(struct net_device *dev,
3493 struct iw_request_info *info,
3494 union iwreq_data *wrqu,
3495 char *extra)
3496{
3497 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3498 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3499 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3500 eHalStatus status = eHAL_STATUS_SUCCESS;
3501
3502 ENTER();
3503
3504 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3505 {
3506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3507 "%s:LOGP in Progress. Ignore!!!",__func__);
3508 return 0;
3509 }
3510
3511 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3512 switch (mlme->cmd) {
3513 case IW_MLME_DISASSOC:
3514 case IW_MLME_DEAUTH:
3515
3516 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3517 {
3518 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3519
3520 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3521 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3522
3523 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3524 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3525
Jeff Johnson43971f52012-07-17 12:26:56 -07003526 if(eHAL_STATUS_SUCCESS == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3528 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3529 else
3530 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003531 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003532
3533 /* Resetting authKeyMgmt */
3534 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3535
3536 netif_tx_disable(dev);
3537 netif_carrier_off(dev);
3538
3539 }
3540 else
3541 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003542 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 -07003543 }
3544 break;
3545 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003546 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 return -EINVAL;
3548 }//end of switch
3549
3550 EXIT();
3551
3552 return status;
3553
3554}
3555
3556/* set param sub-ioctls */
3557static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3558 union iwreq_data *wrqu, char *extra)
3559{
3560 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3561 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3562 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3563 int *value = (int *)extra;
3564 int sub_cmd = value[0];
3565 int set_value = value[1];
3566 int ret = 0; /* success */
3567 int enable_pbm, enable_mp;
3568#ifdef CONFIG_HAS_EARLYSUSPEND
3569 v_U8_t nEnableSuspendOld;
3570#endif
3571 INIT_COMPLETION(pWextState->completion_var);
3572
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003573 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3574 {
3575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3576 "%s:LOGP in Progress. Ignore!!!", __func__);
3577 return -EBUSY;
3578 }
3579
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 switch(sub_cmd)
3581 {
3582 case WE_SET_11D_STATE:
3583 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003584 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003585 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3586
3587 sme_GetConfigParam(hHal,&smeConfig);
3588 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3589
3590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),smeConfig.csrConfig.Is11dSupportEnabled);
3591
3592 sme_UpdateConfig(hHal,&smeConfig);
3593 }
3594 else {
3595 return -EINVAL;
3596 }
3597 break;
3598 }
3599
3600 case WE_WOWL:
3601 {
3602 switch (set_value)
3603 {
3604 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003605 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 break;
3607 case 0x01:
3608 case 0x02:
3609 case 0x03:
3610 enable_mp = (set_value & 0x01) ? 1 : 0;
3611 enable_pbm = (set_value & 0x02) ? 1 : 0;
3612 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s\n",
3613 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3614 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3615 break;
3616 default:
3617 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL\n", set_value);
3618 ret = -EINVAL;
3619 break;
3620 }
3621
3622 break;
3623 }
3624 case WE_SET_POWER:
3625 {
3626 switch (set_value)
3627 {
3628 case 0: //Full Power
3629 {
3630 struct statsContext context;
3631 eHalStatus status;
3632
3633 init_completion(&context.completion);
3634
3635 context.pAdapter = pAdapter;
3636 context.magic = POWER_CONTEXT_MAGIC;
3637
3638 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3639 iw_power_callback_fn, &context,
3640 eSME_FULL_PWR_NEEDED_BY_HDD);
3641 if(eHAL_STATUS_PMC_PENDING == status)
3642 {
3643 int lrc = wait_for_completion_interruptible_timeout(
3644 &context.completion,
3645 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3646 context.magic = 0;
3647 if (lrc <= 0)
3648 {
3649 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3650 "requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003651 __func__, (0 == lrc) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 "timeout" : "interrupt");
3653 /* there is a race condition such that the callback
3654 function could be executing at the same time we are. of
3655 primary concern is if the callback function had already
3656 verified the "magic" but hasn't yet set the completion
3657 variable. Since the completion variable is on our
3658 stack, we'll delay just a bit to make sure the data is
3659 still valid if that is the case */
3660 msleep(50);
3661 /* we'll now returned a cached value below */
3662 }
3663 }
3664 hddLog(LOGE, "iwpriv Full Power completed\n");
3665 break;
3666 }
3667 case 1: //Enable BMPS
3668 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3669 break;
3670 case 2: //Disable BMPS
3671 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
3672 break;
3673 case 3: //Request Bmps
3674 {
3675 struct statsContext context;
3676 eHalStatus status;
3677
3678 init_completion(&context.completion);
3679
3680 context.pAdapter = pAdapter;
3681 context.magic = POWER_CONTEXT_MAGIC;
3682
3683 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3684 iw_power_callback_fn, &context);
3685 if(eHAL_STATUS_PMC_PENDING == status)
3686 {
3687 int lrc = wait_for_completion_interruptible_timeout(
3688 &context.completion,
3689 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
3690 context.magic = 0;
3691 if (lrc <= 0)
3692 {
3693 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while "
3694 "requesting BMPS",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003695 __func__, (0 == lrc) ? "timeout" :
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 "interrupt");
3697 /* there is a race condition such that the callback
3698 function could be executing at the same time we are. of
3699 primary concern is if the callback function had already
3700 verified the "magic" but hasn't yet set the completion
3701 variable. Since the completion variable is on our
3702 stack, we'll delay just a bit to make sure the data is
3703 still valid if that is the case */
3704 msleep(50);
3705 /* we'll now returned a cached value below */
3706 }
3707 }
3708 hddLog(LOGE, "iwpriv Request BMPS completed\n");
3709 break;
3710 }
3711 case 4: //Enable IMPS
3712 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3713 break;
3714 case 5: //Disable IMPS
3715 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
3716 break;
3717 case 6: //Enable Standby
3718 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3719 break;
3720 case 7: //Disable Standby
3721 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
3722 break;
3723 case 8: //Request Standby
3724#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003725#endif
3726 break;
3727 case 9: //Start Auto Bmps Timer
3728 sme_StartAutoBmpsTimer(hHal);
3729 break;
3730 case 10://Stop Auto BMPS Timer
3731 sme_StopAutoBmpsTimer(hHal);
3732 break;
3733#ifdef CONFIG_HAS_EARLYSUSPEND
3734 case 11://suspend to standby
3735#ifdef CONFIG_HAS_EARLYSUSPEND
3736 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3737 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3739#endif
3740 break;
3741 case 12://suspend to deep sleep
3742#ifdef CONFIG_HAS_EARLYSUSPEND
3743 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
3744 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
3746#endif
3747 break;
3748 case 13://resume from suspend
3749#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07003750#endif
3751 break;
3752#endif
3753 case 14://reset wlan (power down/power up)
3754 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
3755 break;
3756 default:
3757 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL\n", set_value);
3758 ret = -EINVAL;
3759 break;
3760 }
3761 break;
3762 }
3763
3764 case WE_SET_MAX_ASSOC:
3765 {
3766 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
3767 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
3768 {
3769 ret = -EINVAL;
3770 }
3771 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
3772 set_value, NULL, eANI_BOOLEAN_FALSE)
3773 != eHAL_STATUS_SUCCESS )
3774 {
3775 ret = -EIO;
3776 }
3777 break;
3778 }
3779
3780 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
3781 {
3782 if( 0 == set_value )
3783 {
3784 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
3785 }
3786 else if ( 1 == set_value )
3787 {
3788 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
3789 }
3790 else
3791 {
3792 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL\n", set_value);
3793 ret = -EINVAL;
3794 }
3795 break;
3796 }
3797
3798 case WE_SET_DATA_INACTIVITY_TO:
3799 {
3800 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
3801 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
3802 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
3803 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
3804 set_value,
3805 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
3806 {
3807 hddLog(LOGE,"Failure: Could not pass on "
3808 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
3809 "to CCM\n");
3810 ret = -EINVAL;
3811 }
3812 break;
3813 }
3814 case WE_SET_MAX_TX_POWER:
3815 {
3816 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3817 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3818
3819 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
3820 __func__, set_value);
3821 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
3822 eHAL_STATUS_SUCCESS )
3823 {
3824 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
3825 __func__);
3826 return -EIO;
3827 }
3828
3829 break;
3830 }
3831 case WE_SET_HIGHER_DTIM_TRANSITION:
3832 {
3833 if(!((set_value == eANI_BOOLEAN_FALSE) ||
3834 (set_value == eANI_BOOLEAN_TRUE)))
3835 {
3836 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
3837 ret = -EINVAL;
3838 }
3839 else
3840 {
3841 if(pAdapter->higherDtimTransition != set_value)
3842 {
3843 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003844 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 }
3846 }
3847
3848 break;
3849 }
3850
3851 case WE_SET_TM_LEVEL:
3852 {
3853 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
3854 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
3855 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
3856
3857 break;
3858 }
3859
3860 default:
3861 {
3862 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d \n",
3863 sub_cmd, set_value);
3864 break;
3865 }
3866 }
3867
3868 return ret;
3869}
3870
3871/* set param sub-ioctls */
3872static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
3873 union iwreq_data *wrqu, char *extra)
3874{
3875 VOS_STATUS vstatus;
3876 int sub_cmd = wrqu->data.flags;
3877 int ret = 0; /* success */
3878 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3879 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3880#ifdef WLAN_FEATURE_VOWIFI
3881 hdd_config_t *pConfig = pHddCtx->cfg_ini;
3882#endif /* WLAN_FEATURE_VOWIFI */
3883
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received length %d", __func__, wrqu->data.length);
3885 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 -07003886
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003887 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3888 {
3889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3890 "%s:LOGP in Progress. Ignore!!!", __func__);
3891 return -EBUSY;
3892 }
3893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 switch(sub_cmd)
3895 {
3896 case WE_WOWL_ADD_PTRN:
3897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003898 hdd_add_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 break;
3900 case WE_WOWL_DEL_PTRN:
3901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN\n");
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003902 hdd_del_wowl_ptrn(pAdapter, (char*)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 break;
3904#if defined WLAN_FEATURE_VOWIFI
3905 case WE_NEIGHBOR_REPORT_REQUEST:
3906 {
3907 tRrmNeighborReq neighborReq;
3908 tRrmNeighborRspCallbackInfo callbackInfo;
3909
3910 if (pConfig->fRrmEnable)
3911 {
3912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request\n");
3913 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
3914 if( !neighborReq.no_ssid )
3915 {
3916 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
3917 vos_mem_copy( neighborReq.ssid.ssId, wrqu->data.pointer, neighborReq.ssid.length );
3918 }
3919
3920 callbackInfo.neighborRspCallback = NULL;
3921 callbackInfo.neighborRspCallbackContext = NULL;
3922 callbackInfo.timeout = 5000; //5 seconds
3923 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
3924 }
3925 else
3926 {
3927 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled\n", __func__);
3928 ret = -EINVAL;
3929 }
3930 }
3931 break;
3932#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 case WE_SET_AP_WPS_IE:
3934 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), wrqu->data.pointer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 case WE_SET_CONFIG:
3938 vstatus = hdd_execute_config_command(pHddCtx, wrqu->data.pointer);
3939 if (VOS_STATUS_SUCCESS != vstatus)
3940 {
3941 ret = -EINVAL;
3942 }
3943 break;
3944 default:
3945 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003946 hddLog(LOGE, "%s: Invalid sub command %d\n",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 ret = -EINVAL;
3948 break;
3949 }
3950 }
3951 return ret;
3952}
3953
3954/* get param sub-ioctls */
3955static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
3956 union iwreq_data *wrqu, char *extra)
3957{
3958 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3959 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3960 int *value = (int *)extra;
3961 int ret = 0; /* success */
3962
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003963 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3964 {
3965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3966 "%s:LOGP in Progress. Ignore!!!", __func__);
3967 return -EBUSY;
3968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003969
3970 switch (value[0])
3971 {
3972 case WE_GET_11D_STATE:
3973 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003974 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003975
3976 sme_GetConfigParam(hHal,&smeConfig);
3977
3978 *value = smeConfig.csrConfig.Is11dSupportEnabled;
3979
3980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),*value);
3981
3982 break;
3983 }
3984
3985 case WE_IBSS_STATUS:
3986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****\n");
3987 break;
3988
3989 case WE_PMC_STATE:
3990 {
3991 *value = pmcGetPmcState(hHal);
3992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%ld!!\n"),*value);
3993 break;
3994 }
3995 case WE_GET_WLAN_DBG:
3996 {
3997 vos_trace_display();
3998 *value = 0;
3999 break;
4000 }
4001 case WE_MODULE_DOWN_IND:
4002 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4005#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4008#endif
4009 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4010
4011 *value = 0;
4012 break;
4013 }
4014 case WE_GET_MAX_ASSOC:
4015 {
4016 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4017 {
4018 ret = -EIO;
4019 }
4020 break;
4021 }
4022
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 case WE_GET_WDI_DBG:
4024 {
4025 wpalTraceDisplay();
4026 *value = 0;
4027 break;
4028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004029
4030 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4031 {
4032 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4033 break;
4034 }
4035 case WE_GET_CONCURRENCY_MODE:
4036 {
4037 *value = hdd_get_concurrency_mode ( );
4038
4039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d \n"),*value);
4040 break;
4041 }
4042
4043 default:
4044 {
4045 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4046 break;
4047 }
4048 }
4049
4050 return ret;
4051}
4052
4053/* set param sub-ioctls */
4054int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4055 union iwreq_data *wrqu, char *extra)
4056{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004057 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 int *value = (int *)extra;
4059 int sub_cmd = value[0];
4060 int ret = 0;
4061
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004062 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4063 {
4064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4065 "%s:LOGP in Progress. Ignore!!!", __func__);
4066 return -EBUSY;
4067 }
4068
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 switch(sub_cmd)
4070 {
4071 case WE_SET_WLAN_DBG:
4072 {
4073 vos_trace_setValue( value[1], value[2], value[3]);
4074 break;
4075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 case WE_SET_WDI_DBG:
4077 {
4078 wpalTraceSetLevel( value[1], value[2], value[3]);
4079 break;
4080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 case WE_SET_SAP_CHANNELS:
4082 {
4083 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4084 break;
4085 }
4086
4087 default:
4088 {
4089 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4090 break;
4091 }
4092 }
4093 return ret;
4094}
4095
4096static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4097 union iwreq_data *wrqu, char *extra)
4098{
4099 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4100 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004101#ifdef WLAN_FEATURE_11W
4102 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4103#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004104
4105 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4106 {
4107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4108 "%s:LOGP in Progress. Ignore!!!", __func__);
4109 return -EBUSY;
4110 }
4111
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 switch(sub_cmd)
4113 {
4114 case WE_WLAN_VERSION:
4115 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004116 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 break;
4118 }
4119
4120 case WE_GET_STATS:
4121 {
4122 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4123 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4124 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4125
4126 snprintf(extra, WE_MAX_STR_LEN,
4127 "\nTransmit"
4128 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4129 "\n dropped BK %u, BE %u, VI %u, VO %u"
4130 "\n classified BK %u, BE %u, VI %u, VO %u"
4131 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4132 "\n queued BK %u, BE %u, VI %u, VO %u"
4133 "\nfetched %u, empty %u, lowres %u, deqerr %u"
4134 "\ndequeued %u, depressured %u, completed %u, flushed %u"
4135 "\n fetched BK %u, BE %u, VI %u, VO %u"
4136 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4137 "\n depressured BK %u, BE %u, VI %u, VO %u"
4138 "\n flushed BK %u, BE %u, VI %u, VO %u"
4139 "\n\nReceive"
4140 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4141 "\n\nResetsStats"
4142 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4143 "\n",
4144 pStats->txXmitCalled,
4145 pStats->txXmitDropped,
4146 pStats->txXmitBackPressured,
4147 pStats->txXmitQueued,
4148
4149 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4150 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4151 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4152 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4153
4154 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4155 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4156 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4157 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4158
4159 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4160 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4161 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4162 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4163
4164 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4165 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4166 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4167 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4168
4169 pStats->txFetched,
4170 pStats->txFetchEmpty,
4171 pStats->txFetchLowResources,
4172 pStats->txFetchDequeueError,
4173
4174 pStats->txFetchDequeued,
4175 pStats->txFetchDePressured,
4176 pStats->txCompleted,
4177 pStats->txFlushed,
4178
4179 pStats->txFetchedAC[WLANTL_AC_BK],
4180 pStats->txFetchedAC[WLANTL_AC_BE],
4181 pStats->txFetchedAC[WLANTL_AC_VI],
4182 pStats->txFetchedAC[WLANTL_AC_VO],
4183
4184 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4185 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4186 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4187 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4188
4189 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4190 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4191 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4192 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4193
4194 pStats->txFlushedAC[WLANTL_AC_BK],
4195 pStats->txFlushedAC[WLANTL_AC_BE],
4196 pStats->txFlushedAC[WLANTL_AC_VI],
4197 pStats->txFlushedAC[WLANTL_AC_VO],
4198
4199 pStats->rxChains,
4200 pStats->rxPackets,
4201 pStats->rxDropped,
4202 pStats->rxDelivered,
4203 pStats->rxRefused,
4204
4205 pResetStats->totalLogpResets,
4206 pResetStats->totalCMD53Failures,
4207 pResetStats->totalMutexReadFailures,
4208 pResetStats->totalMIFErrorFailures,
4209 pResetStats->totalFWHearbeatFailures,
4210 pResetStats->totalUnknownExceptions
4211 );
4212 wrqu->data.length = strlen(extra)+1;
4213 break;
4214 }
4215
4216 case WE_GET_CFG:
4217 {
4218 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4219 wrqu->data.length = strlen(extra)+1;
4220 break;
4221 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004222#ifdef WLAN_FEATURE_11AC
4223 case WE_GET_RSSI:
4224 {
4225 v_S7_t s7Rssi = 0;
4226 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4227 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4228 wrqu->data.length = strlen(extra)+1;
4229 break;
4230 }
4231#endif
4232
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004233#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4234 case WE_GET_ROAM_RSSI:
4235 {
4236 v_S7_t s7Rssi = 0;
4237 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4238 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4239 wrqu->data.length = strlen(extra)+1;
4240 break;
4241 }
4242#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 case WE_GET_WMM_STATUS:
4244 {
4245 snprintf(extra, WE_MAX_STR_LEN,
4246 "\nDir: 0=up, 1=down, 3=both\n"
4247 "|------------------------|\n"
4248 "|AC | ACM |Admitted| Dir |\n"
4249 "|------------------------|\n"
4250 "|VO | %d | %3s | %d |\n"
4251 "|VI | %d | %3s | %d |\n"
4252 "|BE | %d | %3s | %d |\n"
4253 "|BK | %d | %3s | %d |\n"
4254 "|------------------------|\n",
4255 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4256 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4257 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4258 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4259 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4260 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4261 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4262 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4263 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4264 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4265 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4266 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4267
Jeff Johnsone7245742012-09-05 17:12:55 -07004268
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 wrqu->data.length = strlen(extra)+1;
4270 break;
4271 }
4272 case WE_GET_CHANNEL_LIST:
4273 {
4274 VOS_STATUS status;
4275 v_U8_t i, len;
4276 char* buf ;
4277 tChannelListInfo channel_list;
4278
4279 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
4280 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4281 {
4282 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!\n",__func__);
4283 return -EINVAL;
4284 }
4285 buf = extra;
4286
4287 /**
4288 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4289 * needed = 5 * number of channels. Check if sufficient buffer is available and
4290 * then proceed to fill the buffer.
4291 */
4292 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4293 {
4294 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Insufficient Buffer to populate channel list\n",__func__);
4295 return -EINVAL;
4296 }
4297 len = snprintf(buf, 5, "%u ", channel_list.num_channels);
4298 buf += len;
4299 for(i = 0 ; i < channel_list.num_channels; i++)
4300 {
4301 len = snprintf(buf, 5,
4302 "%u ", channel_list.channels[i]);
4303 buf += len;
4304 }
4305 wrqu->data.length = strlen(extra)+1;
4306
4307 break;
4308 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004309#ifdef FEATURE_WLAN_TDLS
4310 case WE_GET_TDLS_PEERS:
4311 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004312 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004313 break;
4314 }
4315#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004316#ifdef WLAN_FEATURE_11W
4317 case WE_GET_11W_INFO:
4318 {
4319 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4320
4321 snprintf(extra, WE_MAX_STR_LEN,
4322 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4323 "\n Number of Unprotected Disassocs %d"
4324 "\n Number of Unprotected Deauths %d",
4325 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4326 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4327 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4328 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4329 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4330
4331 wrqu->data.length = strlen(extra)+1;
4332 break;
4333 }
4334#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 default:
4336 {
4337 hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd );
4338 break;
4339 }
4340 }
4341
4342 return 0;
4343}
4344
4345/* action sub-ioctls */
4346static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4347 union iwreq_data *wrqu, char *extra)
4348{
4349 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4350 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004351 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004352
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004353 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4354 {
4355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4356 "%s:LOGP in Progress. Ignore!!!", __func__);
4357 return -EBUSY;
4358 }
4359
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 switch (sub_cmd)
4361 {
4362 case WE_CLEAR_STATS:
4363 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
4366 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
4367 break;
4368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 case WE_INIT_AP:
4370 {
4371 pr_info("Init AP trigger\n");
4372 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
4373 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
4374 break;
4375 }
4376 case WE_STOP_AP:
4377 {
4378 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
4379 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
4380 * this is a dead code and need to find the adpater by name rather than mode */
4381 hdd_adapter_t* pAdapter_to_stop =
4382 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
4383 if( pAdapter_to_stop )
4384 {
4385 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4386
4387 pr_info("Stopping AP mode\n");
4388
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05304389 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4390 {
4391 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
4392 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
4393 }
4394
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 /*Make sure that pAdapter cleaned properly*/
4396 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
4397 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
4398 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
4399
4400 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
4401 pAdapter_to_stop->macAddressCurrent.bytes);
4402 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
4403 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05304404
4405 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
4406 {
4407 /* put the device back into BMPS */
4408 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
4409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 }
4411 else
4412 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08004413 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 }
4415
4416 break;
4417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004418#ifdef WLAN_BTAMP_FEATURE
4419 case WE_ENABLE_AMP:
4420 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 WLANBAP_RegisterWithHCI(pAdapter);
4423 break;
4424 }
4425 case WE_DISABLE_AMP:
4426 {
4427 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4428 VOS_STATUS status;
4429
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004431
4432 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4433 status = WLANBAP_StopAmp();
4434 if(VOS_STATUS_SUCCESS != status )
4435 {
4436 pHddCtx->isAmpAllowed = VOS_TRUE;
4437 hddLog(VOS_TRACE_LEVEL_FATAL,
4438 "%s: Failed to stop AMP", __func__);
4439 }
4440 else
4441 {
4442 //a state m/c implementation in PAL is TBD to avoid this delay
4443 msleep(500);
4444 pHddCtx->isAmpAllowed = VOS_FALSE;
4445 WLANBAP_DeregisterFromHCI();
4446 }
4447
4448 break;
4449 }
4450#endif
4451
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004452 case WE_ENABLE_DXE_STALL_DETECT:
4453 {
schang6295e542013-03-12 15:31:23 -07004454 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4455 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004456 break;
4457 }
4458 case WE_DISPLAY_DXE_SNAP_SHOT:
4459 {
schang6295e542013-03-12 15:31:23 -07004460 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4461 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004462 break;
4463 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07004464 case WE_SET_REASSOC_TRIGGER:
4465 {
4466 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4467 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
4468 v_U32_t roamId = 0;
4469 tCsrRoamModifyProfileFields modProfileFields;
4470 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
4471 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
4472 return 0;
4473 }
4474
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07004475
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 default:
4477 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004478 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 break;
4480 }
4481 }
4482
4483 return ret;
4484}
4485
4486int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4487 union iwreq_data *wrqu, char *extra)
4488{
4489 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4490 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4491 int sub_cmd = wrqu->data.flags;
4492 int *value = (int*)wrqu->data.pointer;
4493 int apps_args[MAX_VAR_ARGS] = {0};
4494 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004495 hdd_station_ctx_t *pStaCtx = NULL ;
4496 hdd_ap_ctx_t *pAPCtx = NULL;
4497 int cmd = 0;
4498 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004499
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004500 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004501
4502 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4503 {
4504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4505 "%s:LOGP in Progress. Ignore!!!", __func__);
4506 return -EBUSY;
4507 }
4508
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 if (num_args > MAX_VAR_ARGS)
4510 {
4511 num_args = MAX_VAR_ARGS;
4512 }
4513 vos_mem_copy(apps_args, value, (sizeof(int)) * num_args);
4514
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004515 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
4516 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
4517 {
4518 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
4519 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
4520 {
4521 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4522 staId = pStaCtx->conn_info.staId[0];
4523 }
4524 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
4525 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
4526 {
4527 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
4528 staId = pAPCtx->uBCStaId;
4529 }
4530 else
4531 {
4532 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
4533 return 0;
4534 }
4535 }
4536
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 switch (sub_cmd)
4538 {
4539 case WE_LOG_DUMP_CMD:
4540 {
4541 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004542 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 apps_args[3], apps_args[4]);
4544
4545 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
4546 apps_args[3], apps_args[4]);
4547
4548 }
4549 break;
4550
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 case WE_P2P_NOA_CMD:
4552 {
4553 p2p_app_setP2pPs_t p2pNoA;
4554
4555 p2pNoA.opp_ps = apps_args[0];
4556 p2pNoA.ctWindow = apps_args[1];
4557 p2pNoA.duration = apps_args[2];
4558 p2pNoA.interval = apps_args[3];
4559 p2pNoA.count = apps_args[4];
4560 p2pNoA.single_noa_duration = apps_args[5];
4561 p2pNoA.psSelection = apps_args[6];
4562
4563 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
4564 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004565 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
4567
4568 hdd_setP2pPs(dev, &p2pNoA);
4569
4570 }
4571 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004572
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004573 case WE_MCC_CONFIG_CREDENTIAL :
4574 {
4575 cmd = 287; //Command should be updated if there is any change
4576 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08004577 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004578 {
4579 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
4580 }
4581 else
4582 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304583 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160\n", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004584 return 0;
4585 }
4586 }
4587 break;
4588
4589 case WE_MCC_CONFIG_PARAMS :
4590 {
4591 cmd = 288; //command Should be updated if there is any change
4592 // in the Riva dump command
4593 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
4594 }
4595 break;
4596
Chilam NG571c65a2013-01-19 12:27:36 +05304597#ifdef FEATURE_WLAN_TDLS
4598 case WE_TDLS_CONFIG_PARAMS :
4599 {
4600 tdls_config_params_t tdlsParams;
4601
Chilam Ng01120412013-02-19 18:32:21 -08004602 tdlsParams.tdls = apps_args[0];
4603 tdlsParams.tx_period_t = apps_args[1];
4604 tdlsParams.tx_packet_n = apps_args[2];
4605 tdlsParams.discovery_period_t = apps_args[3];
4606 tdlsParams.discovery_tries_n = apps_args[4];
4607 tdlsParams.idle_timeout_t = apps_args[5];
4608 tdlsParams.idle_packet_n = apps_args[6];
4609 tdlsParams.rssi_hysteresis = apps_args[7];
4610 tdlsParams.rssi_trigger_threshold = apps_args[8];
4611 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05304612
Chilam Ng01120412013-02-19 18:32:21 -08004613 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05304614 }
4615 break;
4616#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 default:
4618 {
4619 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
4620 }
4621 break;
4622 }
4623
4624 return 0;
4625}
4626
4627
4628static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
4629 union iwreq_data *wrqu, char *extra)
4630{
4631 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4632 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4633 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4634 int params[HDD_WLAN_WMM_PARAM_COUNT];
4635 sme_QosWmmTspecInfo tSpec;
4636 v_U32_t handle;
4637
4638 // make sure the application is sufficiently priviledged
4639 // note that the kernel will do this for "set" ioctls, but since
4640 // this ioctl wants to return status to user space it must be
4641 // defined as a "get" ioctl
4642 if (!capable(CAP_NET_ADMIN))
4643 {
4644 return -EPERM;
4645 }
4646
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004647 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4648 {
4649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4650 "%s:LOGP in Progress. Ignore!!!", __func__);
4651 return -EBUSY;
4652 }
4653
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 // we must be associated in order to add a tspec
4655 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4656 {
4657 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4658 return 0;
4659 }
4660
4661 // since we are defined to be a "get" ioctl, and since the number
4662 // of params exceeds the number of params that wireless extensions
4663 // will pass down in the iwreq_data, we must copy the "set" params
4664 // from user space ourselves
4665 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
4666 {
4667 // hmmm, can't get them
4668 return -EIO;
4669 }
4670
4671 // clear the tspec
4672 memset(&tSpec, 0, sizeof(tSpec));
4673
4674 // validate the handle
4675 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4676 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4677 {
4678 // that one is reserved
4679 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4680 return 0;
4681 }
4682
4683 // validate the TID
4684 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
4685 {
4686 // out of range
4687 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4688 return 0;
4689 }
4690 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
4691
4692 // validate the direction
4693 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
4694 {
4695 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
4696 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
4697 break;
4698
4699 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
4700 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
4701 break;
4702
4703 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
4704 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
4705 break;
4706
4707 default:
4708 // unknown
4709 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4710 return 0;
4711 }
4712
4713 // validate the user priority
4714 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
4715 {
4716 // out of range
4717 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4718 return 0;
4719 }
4720 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
4721
4722 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
4723 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
4724 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
4725 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
4726 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
4727 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
4728 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
4729 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
4730 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
4731 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
4732 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
4733 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
4734
4735 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
4736
4737 // validate the ts info ack policy
4738 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
4739 {
4740 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
4741 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
4742 break;
4743
4744 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
4745 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
4746 break;
4747
4748 default:
4749 // unknown
4750 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4751 return 0;
4752 }
4753
4754 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
4755 return 0;
4756}
4757
4758
4759static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
4760 union iwreq_data *wrqu, char *extra)
4761{
4762 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4763 int *params = (int *)extra;
4764 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4765 v_U32_t handle;
4766
4767 // make sure the application is sufficiently priviledged
4768 // note that the kernel will do this for "set" ioctls, but since
4769 // this ioctl wants to return status to user space it must be
4770 // defined as a "get" ioctl
4771 if (!capable(CAP_NET_ADMIN))
4772 {
4773 return -EPERM;
4774 }
4775
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004776 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4777 {
4778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4779 "%s:LOGP in Progress. Ignore!!!", __func__);
4780 return -EBUSY;
4781 }
4782
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 // although we are defined to be a "get" ioctl, the params we require
4784 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
4785 // is no need to copy the params from user space
4786
4787 // validate the handle
4788 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4789 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4790 {
4791 // that one is reserved
4792 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4793 return 0;
4794 }
4795
4796 *pStatus = hdd_wmm_delts(pAdapter, handle);
4797 return 0;
4798}
4799
4800
4801static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
4802 union iwreq_data *wrqu, char *extra)
4803{
4804 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4805 int *params = (int *)extra;
4806 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
4807 v_U32_t handle;
4808
4809 // although we are defined to be a "get" ioctl, the params we require
4810 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
4811 // is no need to copy the params from user space
4812
4813 // validate the handle
4814 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
4815 if (HDD_WMM_HANDLE_IMPLICIT == handle)
4816 {
4817 // that one is reserved
4818 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
4819 return 0;
4820 }
4821
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004822 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4823 {
4824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4825 "%s:LOGP in Progress. Ignore!!!", __func__);
4826 return -EBUSY;
4827 }
4828
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 *pStatus = hdd_wmm_checkts(pAdapter, handle);
4830 return 0;
4831}
4832
4833
4834#ifdef FEATURE_WLAN_WAPI
4835static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
4836 union iwreq_data *wrqu, char *extra)
4837{
4838 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4839 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4840 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4841 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4842
4843 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)wrqu->data.pointer;
4844
4845 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004846 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4847 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4848 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004849
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004850 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4851 {
4852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4853 "%s:LOGP in Progress. Ignore!!!", __func__);
4854 return -EBUSY;
4855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004856
4857 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004858 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
4860 pRoamProfile->EncryptionType.numEntries = 1;
4861 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4862 pRoamProfile->mcEncryptionType.numEntries = 1;
4863 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4864
4865 pRoamProfile->AuthType.numEntries = 1;
4866 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4867 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4868 }
4869 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004870 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 }
4872 else
4873 return -EINVAL;
4874
4875 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
4876
4877 return 0;
4878}
4879
4880static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
4881 union iwreq_data *wrqu, char *extra)
4882{
4883 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4884 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
4885
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004886 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4887 {
4888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4889 "%s:LOGP in Progress. Ignore!!!", __func__);
4890 return -EBUSY;
4891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
4893
4894 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004895 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode);
4897 return 0;
4898}
4899
4900static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
4901 union iwreq_data *wrqu, char *extra)
4902{
4903 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4904// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
4905 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
4906 int i = 0, j = 0;
4907 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004908 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4909 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4910 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004911
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004912 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4913 {
4914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4915 "%s:LOGP in Progress. Ignore!!!", __func__);
4916 return -EBUSY;
4917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 VOS_ASSERT(pWapiAssocInfo);
4919
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004920 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x\n",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
4921 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 for(i =0 ; i < 16 ; i++)
4923 hddLog(LOG1,"akm suite[%02d]:0x%08lx",i,pWapiAssocInfo->akmSuite[i]);
4924
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004925 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 for(i =0 ; i < 16 ; i++)
4927 hddLog(LOG1, "Unicast suite[%02d]:0x%08lx",i,pWapiAssocInfo->unicastSuite[i]);
4928
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004929 hddLog(LOG1,"%s: Multicast suite:0x%08lx Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
4930 hddLog(LOG1, "%s: BKID Cnt:0x%04x\n",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 for(i = 0 ; i < 16 ; i++) {
4932 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
4933 for(j = 0 ; j < 16 ; j++)
4934 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
4935 }
4936
4937 /* We are not using the entire IE as provided by the supplicant.
4938 * This is being calculated by SME. This is the same as in the
4939 * case of WPA. Only the auth mode information needs to be
4940 * extracted here*/
4941 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004942 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
4944 }
4945
4946 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004947 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
4949 }
4950 return 0;
4951}
4952
4953static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
4954 union iwreq_data *wrqu, char *extra)
4955{
4956 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4957 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4958 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
4959 tANI_U32 roamId = 0xFF;
4960 tANI_U8 *pKeyPtr = NULL;
4961 v_BOOL_t isConnected = TRUE;
4962 tCsrRoamSetKey setKey;
4963 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
4965
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004966 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4967 {
4968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4969 "%s:LOGP in Progress. Ignore!!!", __func__);
4970 return -EBUSY;
4971 }
4972
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004974 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
4975 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
4976 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004977
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304978 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 -07004979 hddLog(LOG1,"Add Index:0x");
4980 for(i =0 ; i < 12 ; i++)
4981 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
4982
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004983 hddLog(LOG1,"\n%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
4985 for(i =0 ; i < 16 ; i++)
4986 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
4987
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004988 hddLog(LOG1,"\n%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
4990 for(i =0 ; i < 16 ; i++)
4991 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
4992
4993 hddLog(LOG1,"\nWAPI PN NUMBER:0x");
4994 for(i = 0 ; i < 16 ; i++)
4995 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
4996
4997 // Clear the setkey memory
4998 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4999 // Store Key ID
5000 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5001 // SET WAPI Encryption
5002 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5003 // Key Directionn both TX and RX
5004 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5005 // the PAE role
5006 setKey.paeRole = 0 ;
5007
5008 switch ( pWapiKey->keyType )
5009 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005010 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 {
5012 isConnected = hdd_connIsConnected(pHddStaCtx);
5013 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5014 break;
5015 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005016 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 {
5018 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5019 break;
5020 }
5021 default:
5022 {
5023 //Any other option is invalid.
5024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005025 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005026
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005027 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5029 break; // NEED RETURN FROM HERE ????
5030 }
5031 }
5032
5033 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5034 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5035 pKeyPtr = setKey.Key;
5036 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5037 pKeyPtr += pWapiKey->wpiekLen;
5038 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5039
5040 // Set the new key with SME.
5041 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5042
5043 if ( isConnected ) {
5044 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5045 if ( halStatus != eHAL_STATUS_SUCCESS )
5046 {
5047 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5048 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5049
5050 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5051 }
5052 }
5053#if 0 /// NEED TO CHECK ON THIS
5054 else
5055 {
5056 // Store the keys in the adapter to be moved to the profile & passed to
5057 // SME in the ConnectRequest if we are not yet in connected state.
5058 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5059 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5060
5061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5062 " Saving key [idx= %d] to apply when moving to connected state ",
5063 setKey.keyId );
5064
5065 }
5066#endif
5067 return halStatus;
5068}
5069
5070static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5071 union iwreq_data *wrqu, char *extra)
5072{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005073 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005074#ifdef WLAN_DEBUG
5075 int i = 0;
5076 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) (wrqu->data.pointer);
5077#endif
5078
5079 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005080 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5081 hddLog(LOG1, "%s: Received data %s", __func__, (char*)wrqu->data.pointer);
5082 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005083
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005084 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08lx\n", __func__,pBkid->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 hddLog(LOG1,"%s: BKID Cnt:0x%04lx",pBkid->BKIDCount);
5086
5087 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005088
5089 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5090 {
5091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5092 "%s:LOGP in Progress. Ignore!!!", __func__);
5093 return -EBUSY;
5094 }
5095
Jeff Johnson295189b2012-06-20 16:38:30 -07005096#ifdef WLAN_DEBUG
5097 for(i =0 ; i < 16 ; i++)
5098 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5099#endif
5100
5101 return 0;
5102}
5103
5104static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5105 union iwreq_data *wrqu, char *extra)
5106{
5107 /* Yet to implement this function, 19th April 2010 */
5108 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5109
5110 return 0;
5111}
5112#endif /* FEATURE_WLAN_WAPI */
5113
5114#ifdef WLAN_FEATURE_VOWIFI_11R
5115//
5116//
5117// Each time the supplicant has the auth_request or reassoc request
5118// IEs ready. This is pushed to the driver. The driver will inturn use
5119// it to send out the auth req and reassoc req for 11r FT Assoc.
5120//
5121static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5122 union iwreq_data *wrqu, char *extra)
5123{
5124 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5125 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5126 //v_CONTEXT_t pVosContext;
5127
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005128 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5129 {
5130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5131 "%s:LOGP in Progress. Ignore!!!", __func__);
5132 return -EBUSY;
5133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 if (!wrqu->data.length)
5135 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305136 hddLog(LOGE, FL("called with 0 length IEs\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 return -EINVAL;
5138 }
5139 if (wrqu->data.pointer == NULL)
5140 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305141 hddLog(LOGE, FL("called with NULL IE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 return -EINVAL;
5143 }
5144
5145 // Added for debug on reception of Re-assoc Req.
5146 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5147 {
5148 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
5149 wrqu->data.length);
5150 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
5151 }
5152
5153#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
5154 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, wrqu->data.length);
5155#endif
5156
5157 // Pass the received FT IEs to SME
5158 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, wrqu->data.pointer,
5159 wrqu->data.length);
5160
5161 return 0;
5162}
5163#endif
5164
Amar Singhalf3a6e762013-02-19 15:06:50 -08005165static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005166 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005168{
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005170 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)wrqu->data.pointer;
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005172 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005173 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyyalamudi51d87f72012-09-24 12:05:23 -07005174 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005175 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5176 int idx;
5177 eHalStatus ret_val;
Chilam Ngc4244af2013-04-01 15:37:32 -07005178 tANI_U8 mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005179
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005180 if (pHddCtx->isLogpInProgress)
5181 {
5182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5183 "%s:LOGP in Progress. Ignore!!!", __func__);
5184 return -EBUSY;
5185 }
5186
Amar Singhalf3a6e762013-02-19 15:06:50 -08005187 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005188
Amar Singhalf3a6e762013-02-19 15:06:50 -08005189 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5190 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005191 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005192 hddLog(VOS_TRACE_LEVEL_ERROR,
5193 "%s: vos_mem_alloc failed", __func__);
5194 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005195 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005196
5197 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5198
5199 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5200 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5201
5202 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5203 mc_addr_list_ptr->ulMulticastAddrCnt);
5204
5205 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005206 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005207 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5208 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5209
5210 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5211 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005212 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005213
Amar Singhalf3a6e762013-02-19 15:06:50 -08005214 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5215 vos_mem_free(mc_addr_list_ptr);
5216 if (eHAL_STATUS_SUCCESS != ret_val)
5217 {
5218 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5219 __func__);
5220 return -EINVAL;
5221 }
5222 } else {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005223
Amar Singhalf3a6e762013-02-19 15:06:50 -08005224 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5225 "%s: Set MC BC Filter Config request: %d suspend %d",
5226 __func__, pRequest->mcastBcastFilterSetting,
5227 pHddCtx->hdd_wlan_suspended);
5228
Amar Singhalf3a6e762013-02-19 15:06:50 -08005229 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting =
5230 pRequest->mcastBcastFilterSetting;
5231 pHddCtx->dynamic_mcbc_filter.enableCfg = TRUE;
5232
5233 if (pHddCtx->hdd_wlan_suspended)
5234 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005235 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5236 if (NULL == wlanRxpFilterParam)
5237 {
5238 hddLog(VOS_TRACE_LEVEL_FATAL,
5239 "%s: vos_mem_alloc failed", __func__);
5240 return -EINVAL;
5241 }
5242
Amar Singhalf3a6e762013-02-19 15:06:50 -08005243 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5244 pRequest->mcastBcastFilterSetting;
5245 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5246
5247 if ((pHddCtx->cfg_ini->fhostArpOffload) &&
5248 (eConnectionState_Associated ==
5249 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
5250 {
5251 vstatus = hdd_conf_hostarpoffload(pAdapter, TRUE);
5252 if (!VOS_IS_STATUS_SUCCESS(vstatus))
5253 {
5254 hddLog(VOS_TRACE_LEVEL_INFO,
5255 "%s:Failed to enable ARPOFFLOAD Feature %d",
5256 __func__, vstatus);
5257 }
5258 else
5259 {
5260 if (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST ==
5261 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting)
5262 {
5263 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5264 HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST;
5265 }
5266 else if (HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST ==
5267 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting)
5268 {
5269 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5270 HDD_MCASTBCASTFILTER_FILTER_NONE;
5271 }
5272 }
5273 }
5274
5275 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5276 __func__,
5277 pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting,
5278 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5279 wlanRxpFilterParam->setMcstBcstFilter);
5280
Chilam Ngc4244af2013-04-01 15:37:32 -07005281 mcastBcastFilterSetting = wlanRxpFilterParam->configuredMcstBcstFilterSetting;
5282
Amar Singhalf3a6e762013-02-19 15:06:50 -08005283 if (eHAL_STATUS_SUCCESS != sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5284 wlanRxpFilterParam))
5285 {
5286 hddLog(VOS_TRACE_LEVEL_ERROR,
5287 "%s: Failure to execute set HW MC/BC Filter request",
5288 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005289 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005290 return -EINVAL;
5291 }
5292
5293 pHddCtx->dynamic_mcbc_filter.mcBcFilterSuspend =
Chilam Ngc4244af2013-04-01 15:37:32 -07005294 mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005295 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005297
5298 return 0;
5299}
5300
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005301static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
5302 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005303 union iwreq_data *wrqu, char *extra)
5304{
5305 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5306 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5307
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005308 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005309
5310 pHddCtx->dynamic_mcbc_filter.enableCfg = FALSE;
5311
5312 return 0;
5313}
5314
5315static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
5316 union iwreq_data *wrqu, char *extra)
5317{
5318 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5319 tpHostOffloadRequest pRequest = (tpHostOffloadRequest)wrqu->data.pointer;
5320 tSirHostOffloadReq offloadRequest;
5321
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005322 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5323 {
5324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5325 "%s:LOGP in Progress. Ignore!!!", __func__);
5326 return -EBUSY;
5327 }
5328
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 /* Debug display of request components. */
5330 switch (pRequest->offloadType)
5331 {
5332 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005333 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 switch (pRequest->enableOrDisable)
5335 {
5336 case WLAN_OFFLOAD_DISABLE:
5337 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
5338 break;
5339 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
5340 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
5341 case WLAN_OFFLOAD_ENABLE:
5342 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
5343 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
5344 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
5345 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
5346 }
5347 break;
5348
5349 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
5350 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005351 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005352 switch (pRequest->enableOrDisable)
5353 {
5354 case WLAN_OFFLOAD_DISABLE:
5355 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
5356 break;
5357 case WLAN_OFFLOAD_ENABLE:
5358 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
5359 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
5360 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
5361 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
5362 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
5363 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
5364 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
5365 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
5366 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
5367 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
5368 }
5369 }
5370
5371 /* Execute offload request. The reason that we can copy the request information
5372 from the ioctl structure to the SME structure is that they are laid out
5373 exactly the same. Otherwise, each piece of information would have to be
5374 copied individually. */
5375 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07005376 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
5377 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 {
5379 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request\n",
5380 __func__);
5381 return -EINVAL;
5382 }
5383
5384 return 0;
5385}
5386
5387static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
5388 union iwreq_data *wrqu, char *extra)
5389{
5390 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5391 tpKeepAliveRequest pRequest = (tpKeepAliveRequest)wrqu->data.pointer;
5392 tSirKeepAliveReq keepaliveRequest;
5393
5394 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5395 {
5396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005397 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 return 0;
5399 }
5400
5401 /* Debug display of request components. */
5402 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Keep Alive Request : TimePeriod %d size %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005403 __func__,pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005404
5405 switch (pRequest->packetType)
5406 {
5407 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005408 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 break;
5410
5411 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
5412
5413 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005414 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005415
5416 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
5417 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
5418 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
5419
5420 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
5421 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
5422 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
5423
5424 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
5425 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
5426 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
5427 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
5428 break;
5429
5430 }
5431
5432 /* Execute keep alive request. The reason that we can copy the request information
5433 from the ioctl structure to the SME structure is that they are laid out
5434 exactly the same. Otherwise, each piece of information would have to be
5435 copied individually. */
5436 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
5437
5438 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d\n", keepaliveRequest.timePeriod);
5439
Jeff Johnsone7245742012-09-05 17:12:55 -07005440 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
5441 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 {
5443 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive\n",
5444 __func__);
5445 return -EINVAL;
5446 }
5447
5448 return 0;
5449}
5450
5451#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -07005452int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
5453 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005454{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005455 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
5456 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 int i=0;
5458
5459 if (pHddCtx->cfg_ini->disablePacketFilter)
5460 {
5461 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005462 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 return 0;
5464 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005465 if (pHddCtx->isLogpInProgress)
5466 {
5467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5468 "%s:LOGP in Progress. Ignore!!!", __func__);
5469 return -EBUSY;
5470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 /* Debug display of request components. */
5472 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005473 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07005474
5475 switch (pRequest->filterAction)
5476 {
5477 case HDD_RCV_FILTER_SET:
5478 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005479 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005480
5481 packetFilterSetReq.filterId = pRequest->filterId;
5482 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
5483 {
5484 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d\n",
5485 __func__, pRequest->numParams);
5486 return -EINVAL;
5487 }
5488 packetFilterSetReq.numFieldParams = pRequest->numParams;
5489 packetFilterSetReq.coalesceTime = 0;
5490 packetFilterSetReq.filterType = 1;
5491 for (i=0; i < pRequest->numParams; i++)
5492 {
5493 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
5494 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
5495 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
5496 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
5497 packetFilterSetReq.paramsData[i].reserved = 0;
5498
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305499 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
5501 packetFilterSetReq.filterType);
5502
5503 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d\n",
5504 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
5505
5506 memcpy(&packetFilterSetReq.paramsData[i].compareData,
5507 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
5508 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
5509 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
5510
5511 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d\n",
5512 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
5513 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
5514 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
5515
5516 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d\n",
5517 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
5518 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
5519 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
5520 }
5521
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005522 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 {
5524 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter\n",
5525 __func__);
5526 return -EINVAL;
5527 }
5528
5529 break;
5530
5531 case HDD_RCV_FILTER_CLEAR:
5532
5533 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005534 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07005536 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 {
5538 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter\n",
5539 __func__);
5540 return -EINVAL;
5541 }
5542 break;
5543
5544 default :
5545 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005546 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 return -EINVAL;
5548 }
5549 return 0;
5550}
5551
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305552void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07005553{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305554 v_U8_t filterAction;
5555 tPacketFilterCfg request;
5556 v_U8_t i;
5557 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005558
5559 filterAction = set ? HDD_RCV_FILTER_SET : HDD_RCV_FILTER_CLEAR;
5560
5561 /*set mulitcast addr list*/
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305562 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 {
5564 memset(&request, 0, sizeof (tPacketFilterCfg));
5565 request.filterAction = filterAction;
5566 request.filterId = i;
5567 if (set)
5568 {
5569 request.numParams = 1;
5570 request.paramsData[0].protocolLayer = HDD_FILTER_PROTO_TYPE_MAC;
5571 request.paramsData[0].cmpFlag = HDD_FILTER_CMP_TYPE_EQUAL;
5572 request.paramsData[0].dataOffset = WLAN_HDD_80211_FRM_DA_OFFSET;
5573 request.paramsData[0].dataLength = ETH_ALEN;
5574 memcpy(&(request.paramsData[0].compareData[0]),
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305575 &(pAdapter->mc_addr_list.addr[i][0]), ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 /*set mulitcast filters*/
5577 hddLog(VOS_TRACE_LEVEL_INFO,
5578 "%s: %s multicast filter: addr ="
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305579 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 __func__, set ? "setting" : "clearing",
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305581 MAC_ADDR_ARRAY(request.paramsData[0].compareData));
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 }
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305583 wlan_hdd_set_filter(pHddCtx, &request, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 }
Gopichand Nakkala0f276812013-02-24 14:45:51 +05305585 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005586}
5587
5588static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
5589 union iwreq_data *wrqu, char *extra)
5590{
5591 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5592 tpPacketFilterCfg pRequest = (tpPacketFilterCfg)wrqu->data.pointer;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005593
Jeff Johnsone7245742012-09-05 17:12:55 -07005594 return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005595}
5596#endif
5597static int iw_get_statistics(struct net_device *dev,
5598 struct iw_request_info *info,
5599 union iwreq_data *wrqu, char *extra)
5600{
5601
5602 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
5603 eHalStatus status = eHAL_STATUS_SUCCESS;
5604 hdd_wext_state_t *pWextState;
5605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5606 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5607 char *p = extra;
5608 int tlen = 0;
5609 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
5610
5611 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
5612 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
5613
5614 ENTER();
5615
5616 if (pHddCtx->isLogpInProgress) {
5617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
5618 return -EINVAL;
5619 }
5620
5621 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
5622
5623 wrqu->txpower.value = 0;
5624 }
5625 else {
5626 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
5627 SME_SUMMARY_STATS |
5628 SME_GLOBAL_CLASSA_STATS |
5629 SME_GLOBAL_CLASSB_STATS |
5630 SME_GLOBAL_CLASSC_STATS |
5631 SME_GLOBAL_CLASSD_STATS |
5632 SME_PER_STA_STATS,
5633 hdd_StatisticsCB, 0, FALSE,
5634 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
5635
5636 if (eHAL_STATUS_SUCCESS != status)
5637 {
5638 hddLog(VOS_TRACE_LEVEL_ERROR,
5639 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005640 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 return -EINVAL;
5642 }
5643
5644 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5645
5646 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
5647 if (!VOS_IS_STATUS_SUCCESS(vos_status))
5648 {
5649 hddLog(VOS_TRACE_LEVEL_ERROR,
5650 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005651 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 /*Remove the SME statistics list by passing NULL in callback argument*/
5653 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
5654 SME_SUMMARY_STATS |
5655 SME_GLOBAL_CLASSA_STATS |
5656 SME_GLOBAL_CLASSB_STATS |
5657 SME_GLOBAL_CLASSC_STATS |
5658 SME_GLOBAL_CLASSD_STATS |
5659 SME_PER_STA_STATS,
5660 NULL, 0, FALSE,
5661 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
5662
5663 return -EINVAL;
5664 }
5665 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
5666 (tANI_U8) sizeof (pStats->retry_cnt),
5667 (char*) &(pStats->retry_cnt[0]),
5668 tlen);
5669
5670 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
5671 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
5672 (char*) &(pStats->multiple_retry_cnt[0]),
5673 tlen);
5674
5675 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
5676 (tANI_U8) sizeof (pStats->tx_frm_cnt),
5677 (char*) &(pStats->tx_frm_cnt[0]),
5678 tlen);
5679
5680 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
5681 (tANI_U8) sizeof (pStats->rx_frm_cnt),
5682 (char*) &(pStats->rx_frm_cnt),
5683 tlen);
5684
5685 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
5686 (tANI_U8) sizeof (pStats->frm_dup_cnt),
5687 (char*) &(pStats->frm_dup_cnt),
5688 tlen);
5689
5690 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
5691 (tANI_U8) sizeof (pStats->fail_cnt),
5692 (char*) &(pStats->fail_cnt[0]),
5693 tlen);
5694
5695 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
5696 (tANI_U8) sizeof (pStats->rts_fail_cnt),
5697 (char*) &(pStats->rts_fail_cnt),
5698 tlen);
5699
5700 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
5701 (tANI_U8) sizeof (pStats->ack_fail_cnt),
5702 (char*) &(pStats->ack_fail_cnt),
5703 tlen);
5704
5705 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
5706 (tANI_U8) sizeof (pStats->rts_succ_cnt),
5707 (char*) &(pStats->rts_succ_cnt),
5708 tlen);
5709
5710 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
5711 (tANI_U8) sizeof (pStats->rx_discard_cnt),
5712 (char*) &(pStats->rx_discard_cnt),
5713 tlen);
5714
5715 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
5716 (tANI_U8) sizeof (pStats->rx_error_cnt),
5717 (char*) &(pStats->rx_error_cnt),
5718 tlen);
5719
Jeff Johnsone7245742012-09-05 17:12:55 -07005720 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
5721 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
5722 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 tlen);
5724
5725 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
5726 (tANI_U8) sizeof (dStats->rx_byte_cnt),
5727 (char*) &(dStats->rx_byte_cnt),
5728 tlen);
5729
5730 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
5731 (tANI_U8) sizeof (dStats->rx_rate),
5732 (char*) &(dStats->rx_rate),
5733 tlen);
5734
5735 /* Transmit rate, in units of 500 kbit/sec */
5736 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
5737 (tANI_U8) sizeof (aStats->tx_rate),
5738 (char*) &(aStats->tx_rate),
5739 tlen);
5740
Jeff Johnsone7245742012-09-05 17:12:55 -07005741 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
5742 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
5743 (char*) &(dStats->rx_uc_byte_cnt[0]),
5744 tlen);
5745 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
5746 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
5747 (char*) &(dStats->rx_mc_byte_cnt),
5748 tlen);
5749 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
5750 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
5751 (char*) &(dStats->rx_bc_byte_cnt),
5752 tlen);
5753 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
5754 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
5755 (char*) &(dStats->tx_uc_byte_cnt[0]),
5756 tlen);
5757 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
5758 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
5759 (char*) &(dStats->tx_mc_byte_cnt),
5760 tlen);
5761 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
5762 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
5763 (char*) &(dStats->tx_bc_byte_cnt),
5764 tlen);
5765
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 wrqu->data.length = tlen;
5767
5768 }
5769
5770 EXIT();
5771
5772 return 0;
5773}
5774
5775
5776#ifdef FEATURE_WLAN_SCAN_PNO
5777
5778/*Max Len for PNO notification*/
5779#define MAX_PNO_NOTIFY_LEN 100
5780void found_pref_network_cb (void *callbackContext,
5781 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
5782{
5783 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
5784 union iwreq_data wrqu;
5785 char buf[MAX_PNO_NOTIFY_LEN+1];
5786
5787 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
5788 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
5789
5790 // create the event
5791 memset(&wrqu, 0, sizeof(wrqu));
5792 memset(buf, 0, sizeof(buf));
5793
5794 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
5795 pPrefNetworkFoundInd->ssId.ssId,
5796 (unsigned int)pPrefNetworkFoundInd->rssi);
5797
5798 wrqu.data.pointer = buf;
5799 wrqu.data.length = strlen(buf);
5800
5801 // send the event
5802
5803 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5804
5805}
5806
5807
5808/*string based input*/
5809VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
5810 union iwreq_data *wrqu, char *extra, int nOffset)
5811{
5812 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07005813 /* pnoRequest is a large struct, so we make it static to avoid stack
5814 overflow. This API is only invoked via ioctl, so it is
5815 serialized by the kernel rtnl_lock and hence does not need to be
5816 reentrant */
5817 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 char *ptr;
5819 v_U8_t i,j, ucParams, ucMode;
5820 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5821
5822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5823 "PNO data len %d data %s",
5824 wrqu->data.length,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305825 (char *)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005826
5827 if (wrqu->data.length <= nOffset )
5828 {
5829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
5830 return VOS_STATUS_E_FAILURE;
5831 }
5832
5833 pnoRequest.enable = 0;
5834 pnoRequest.ucNetworksCount = 0;
5835 /*-----------------------------------------------------------------------
5836 Input is string based and expected to be like this:
5837
5838 <enabled> <netw_count>
5839 for each network:
5840 <ssid_len> <ssid> <authentication> <encryption>
5841 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
5842 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
5843
5844 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07005845 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 -07005846
5847 this translates into:
5848 -----------------------------
5849 enable PNO
5850 look for 2 networks:
5851 test - with authentication type 0 and encryption type 0,
5852 that can be found on 3 channels: 1 6 and 11 ,
5853 SSID bcast type is unknown (directed probe will be sent if AP not found)
5854 and must meet -40dBm RSSI
5855
5856 test2 - with auth and enrytption type 4/4
5857 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
5858 bcast type is non-bcast (directed probe will be sent)
5859 and must not meet any RSSI threshold
5860
Jeff Johnson8301aa12013-03-28 14:27:29 -07005861 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 -----------------------------------------------------------------------*/
5863 ptr = (char*)(wrqu->data.pointer + nOffset);
5864
5865 sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset);
5866
5867 if ( 0 == pnoRequest.enable )
5868 {
5869 /*Disable PNO*/
5870 memset(&pnoRequest, 0, sizeof(pnoRequest));
5871 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
5872 pAdapter->sessionId,
5873 found_pref_network_cb, pAdapter);
5874 return VOS_STATUS_SUCCESS;
5875 }
5876
5877 ptr += nOffset;
5878 sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset);
5879
5880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5881 "PNO enable %d networks count %d offset %d",
5882 pnoRequest.enable,
5883 pnoRequest.ucNetworksCount,
5884 nOffset);
5885
5886 /* Parameters checking:
5887 ucNetworksCount has to be larger than 0*/
5888 if (( 0 == pnoRequest.ucNetworksCount ) ||
5889 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
5890 {
5891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
5892 return VOS_STATUS_E_FAILURE;
5893 }
5894
5895 ptr += nOffset;
5896
5897 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
5898 {
5899
5900 pnoRequest.aNetworks[i].ssId.length = 0;
5901
5902 sscanf(ptr,"%hhu %n",
5903 &(pnoRequest.aNetworks[i].ssId.length), &nOffset);
5904
5905 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
5906 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
5907 {
5908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5909 "SSID Len %d is not correct for network %d",
5910 pnoRequest.aNetworks[i].ssId.length, i);
5911 return VOS_STATUS_E_FAILURE;
5912 }
5913
5914 /*Advance to SSID*/
5915 ptr += nOffset;
5916
Jeff Johnson8301aa12013-03-28 14:27:29 -07005917 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08005918 pnoRequest.aNetworks[i].ssId.length);
5919 ptr += pnoRequest.aNetworks[i].ssId.length;
5920
5921 ucParams = sscanf(ptr,"%lu %lu %hhu %n",
5922 &(pnoRequest.aNetworks[i].authentication),
5923 &(pnoRequest.aNetworks[i].encryption),
5924 &(pnoRequest.aNetworks[i].ucChannelCount),
5925 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07005926
5927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal751e6072013-01-24 16:02:56 -08005928 "PNO len %d ssid 0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx"
5929 "auth %d encry %d channel count %d offset %d",
5930 pnoRequest.aNetworks[i].ssId.length,
5931 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
5932 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
5933 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
5934 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
5935 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
5936 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
5937 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
5938 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
5939 pnoRequest.aNetworks[i].authentication,
5940 pnoRequest.aNetworks[i].encryption,
5941 pnoRequest.aNetworks[i].ucChannelCount,
5942 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07005943
Amar Singhal751e6072013-01-24 16:02:56 -08005944 if ( 3 != ucParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 {
5946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5947 "Incorrect cmd");
5948 return VOS_STATUS_E_FAILURE;
5949 }
5950
5951 /*Advance to channel list*/
5952 ptr += nOffset;
5953
5954 if ( SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount )
5955 {
5956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5957 "Incorrect number of channels");
5958 return VOS_STATUS_E_FAILURE;
5959 }
5960
5961 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
5962 {
5963 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
5964 {
5965 sscanf(ptr,"%hhu %n",
5966 &(pnoRequest.aNetworks[i].aChannels[j]), &nOffset);
5967 /*Advance to next channel number*/
5968 ptr += nOffset;
5969 }
5970 }
5971
5972 sscanf(ptr,"%lu %n",
5973 &(pnoRequest.aNetworks[i].bcastNetwType), &nOffset);
5974
5975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5976 "PNO bcastNetwType %d offset %d",
5977 pnoRequest.aNetworks[i].bcastNetwType,
5978 nOffset );
5979
5980 /*Advance to rssi Threshold*/
5981 ptr += nOffset;
5982
5983 sscanf(ptr,"%hhu %n",
5984 &(pnoRequest.aNetworks[i].rssiThreshold), &nOffset);
5985
5986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5987 "PNO rssi %d offset %d",
5988 pnoRequest.aNetworks[i].rssiThreshold,
5989 nOffset );
5990 /*Advance to next network*/
5991 ptr += nOffset;
5992 }/*For ucNetworkCount*/
5993
5994 ucParams = sscanf(ptr,"%hhu %n",
5995 &(pnoRequest.scanTimers.ucScanTimersCount), &nOffset);
5996
5997 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07005998 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 {
6000 ptr += nOffset;
6001
Jeff Johnson8301aa12013-03-28 14:27:29 -07006002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6003 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 pnoRequest.scanTimers.ucScanTimersCount,
6005 nOffset );
6006
6007 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
6008 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 "Incorrect cmd - too many scan timers");
6011 return VOS_STATUS_E_FAILURE;
6012 }
6013
6014 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
6015 {
6016 ucParams = sscanf(ptr,"%lu %lu %n",
6017 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
6018 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
6019 &nOffset);
6020
Jeff Johnson8301aa12013-03-28 14:27:29 -07006021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6022 "PNO Timer value %d Timer repeat %d offset %d",
6023 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
6025 nOffset );
6026
6027 if ( 2 != ucParams )
6028 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 "Incorrect cmd - diff params then expected %d", ucParams);
6031 return VOS_STATUS_E_FAILURE;
6032 }
6033
6034 ptr += nOffset;
6035 }
6036
6037 }
6038 else
6039 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07006040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6041 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
6043
6044 /*Scan timers defaults to 5 minutes*/
6045 pnoRequest.scanTimers.ucScanTimersCount = 1;
6046 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
6047 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
6048 }
6049
6050 ucParams = sscanf(ptr,"%hhu %n",
6051 &(ucMode), &nOffset);
6052
6053 pnoRequest.modePNO = ucMode;
6054 /*for LA we just expose suspend option*/
6055 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
6056 {
6057 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
6058 }
6059
6060 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6061 pAdapter->sessionId,
6062 found_pref_network_cb, pAdapter);
6063
6064 return VOS_STATUS_SUCCESS;
6065}/*iw_set_pno*/
6066
6067VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
6068 union iwreq_data *wrqu, char *extra, int nOffset)
6069{
6070 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6071 v_U8_t rssiThreshold = 0;
6072 v_U8_t nRead;
6073
6074 nRead = sscanf(wrqu->data.pointer + nOffset,"%hhu",
6075 &rssiThreshold);
6076
6077 if ( 1 != nRead )
6078 {
6079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6080 "Incorrect format");
6081 return VOS_STATUS_E_FAILURE;
6082 }
6083
6084 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
6085 return VOS_STATUS_SUCCESS;
6086}
6087
6088
6089static int iw_set_pno_priv(struct net_device *dev,
6090 struct iw_request_info *info,
6091 union iwreq_data *wrqu, char *extra)
6092{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006093 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6094
6095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006097
6098 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6099 {
6100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6101 "%s:LOGP in Progress. Ignore!!!", __func__);
6102 return -EBUSY;
6103 }
6104 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006105}
6106#endif /*FEATURE_WLAN_SCAN_PNO*/
6107
6108//Common function to SetBand
6109int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
6110{
6111 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6112 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6113 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6114 tANI_U8 band = 0;
6115 eCsrBand currBand = eCSR_BAND_MAX;
6116
6117 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
6118
6119 switch(band)
6120 {
6121 case WLAN_HDD_UI_BAND_AUTO:
6122 band = eCSR_BAND_ALL;
6123 break;
6124 case WLAN_HDD_UI_BAND_5_GHZ:
6125 band = eCSR_BAND_5G;
6126 break;
6127 case WLAN_HDD_UI_BAND_2_4_GHZ:
6128 band = eCSR_BAND_24;
6129 break;
6130 default:
6131 band = eCSR_BAND_MAX;
6132 }
6133
6134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006135 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006136
6137 if (band == eCSR_BAND_MAX)
6138 {
6139 /* Received change band request with invalid band value */
6140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006141 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 return -EIO;
6143 }
6144
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006145 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
6146 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
6147 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
6148 {
6149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006150 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006151 band, pHddCtx->cfg_ini->nBandCapability);
6152 return -EIO;
6153 }
6154
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
6156 {
6157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6158 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006159 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 return -EIO;
6161 }
6162
6163 if (currBand != band)
6164 {
6165 /* Change band request received.
6166 * Abort pending scan requests, flush the existing scan results,
6167 * and change the band capability
6168 */
6169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6170 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006171 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006172
6173 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6174 {
6175 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
6176 eHalStatus status = eHAL_STATUS_SUCCESS;
6177 long lrc;
6178
6179 /* STA already connected on current band, So issue disconnect first,
6180 * then change the band*/
6181
6182 hddLog(VOS_TRACE_LEVEL_INFO,
6183 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
6184 __func__, csrGetCurrentBand(hHal), band);
6185
6186 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6187 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6188
6189 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6190 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6191
Jeff Johnson43971f52012-07-17 12:26:56 -07006192 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 {
6194 hddLog(VOS_TRACE_LEVEL_ERROR,
6195 "%s csrRoamDisconnect failure, returned %d \n",
6196 __func__, (int)status );
6197 return -EINVAL;
6198 }
6199
6200 lrc = wait_for_completion_interruptible_timeout(
6201 &pAdapter->disconnect_comp_var,
6202 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6203
6204 if(lrc <= 0) {
6205
6206 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006207 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07006208
6209 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6210 }
6211 }
6212
6213 hdd_abort_mac_scan(pHddCtx);
6214 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Srinivas Girigowdade697412013-02-14 16:31:48 -08006215#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
6216 sme_UpdateBgScanConfigIniChannelList(hHal, (eCsrBand) band);
6217#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 if(eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
6219 {
6220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6221 "%s: failed to set the band value to %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006222 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 return -EINVAL;
6224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 }
6227 return 0;
6228}
6229
6230static int iw_set_band_config(struct net_device *dev,
6231 struct iw_request_info *info,
6232 union iwreq_data *wrqu, char *extra)
6233{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006234 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 tANI_U8 *ptr = (tANI_U8*)wrqu->data.pointer;
6236 int ret = 0;
6237
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006239
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006240 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6241 {
6242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6243 "%s:LOGP in Progress. Ignore!!!", __func__);
6244 return -EBUSY;
6245 }
6246
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 if (memcmp(ptr, "SETBAND ", 8) == 0)
6248 {
6249 /* Change band request received */
6250 ret = hdd_setBand_helper(dev, ptr);
6251 return ret;
6252
6253 }
6254 return 0;
6255}
6256
6257static int iw_set_power_params_priv(struct net_device *dev,
6258 struct iw_request_info *info,
6259 union iwreq_data *wrqu, char *extra)
6260{
6261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6262 "Set power params Private");
6263 return iw_set_power_params(dev,info,wrqu,extra,0);
6264}
6265
6266
6267
6268/*string based input*/
6269VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
6270 union iwreq_data *wrqu, char *extra, int nOffset)
6271{
6272 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6273 tSirSetPowerParamsReq powerRequest;
6274 char *ptr;
6275 v_U8_t ucType;
6276 v_U32_t uTotalSize, uValue;
6277 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6278
6279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6280 "Power Params data len %d data %s",
6281 wrqu->data.length,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306282 (char *)wrqu->data.pointer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006283
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006284 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6285 {
6286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6287 "%s:LOGP in Progress. Ignore!!!", __func__);
6288 return -EBUSY;
6289 }
6290
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 if (wrqu->data.length <= nOffset )
6292 {
6293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
6294 return VOS_STATUS_E_FAILURE;
6295 }
6296
6297 uTotalSize = wrqu->data.length - nOffset;
6298
6299 /*-----------------------------------------------------------------------
6300 Input is string based and expected to be like this:
6301
6302 <param_type> <param_value> <param_type> <param_value> ...
6303
6304 e.g:
6305 1 2 2 3 3 0 4 1 5 1
6306
6307 e.g. setting just a few:
6308 1 2 4 1
6309
6310 parameter types:
6311 -----------------------------
6312 1 - Ignore DTIM
6313 2 - Listen Interval
6314 3 - Broadcast Multicas Filter
6315 4 - Beacon Early Termination
6316 5 - Beacon Early Termination Interval
6317 -----------------------------------------------------------------------*/
6318 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
6319 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
6320 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
6321 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
6322 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
6323
6324 ptr = (char*)(wrqu->data.pointer + nOffset);
6325
6326 while ( uTotalSize )
6327 {
6328 sscanf(ptr,"%hhu %n", &(ucType), &nOffset);
6329
6330 uTotalSize -= nOffset;
6331
6332 if (!uTotalSize)
6333 {
6334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006335 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 ucType, nOffset);
6337 return VOS_STATUS_E_FAILURE;
6338 }
6339
6340 ptr += nOffset;
6341 sscanf(ptr,"%lu %n", &(uValue), &nOffset);
6342
6343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6344 "Power request parameter %d value %d offset %d",
6345 ucType, uValue, nOffset);
6346
6347 switch (ucType)
6348 {
6349 case eSIR_IGNORE_DTIM:
6350 powerRequest.uIgnoreDTIM = uValue;
6351 break;
6352 case eSIR_LISTEN_INTERVAL:
6353 powerRequest.uListenInterval = uValue;
6354 break;
6355 case eSIR_MCAST_BCAST_FILTER:
6356 powerRequest.uBcastMcastFilter = uValue;
6357 break;
6358 case eSIR_ENABLE_BET:
6359 powerRequest.uEnableBET = uValue;
6360 break;
6361 case eSIR_BET_INTERVAL:
6362 powerRequest.uBETInterval = uValue;
6363 break;
6364 default:
6365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006366 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 ucType, uValue, nOffset);
6368 return VOS_STATUS_E_FAILURE;
6369 }
6370
6371 uTotalSize -= nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07006372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6373 "Power request parameter %d Total size",
6374 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07006376 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
6377 if(!(uTotalSize - nOffset) &&
6378 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
6379 {
6380 uTotalSize = 0;
6381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006382
6383 }/*Go for as long as we have a valid string*/
6384
6385 /* put the device into full power*/
6386 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6387
6388 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006389 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006390
6391 /* put the device back to power save*/
6392 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6393
6394 return VOS_STATUS_SUCCESS;
6395}/*iw_set_power_params*/
6396
6397
6398// Define the Wireless Extensions to the Linux Network Device structure
6399// A number of these routines are NULL (meaning they are not implemented.)
6400
6401static const iw_handler we_handler[] =
6402{
6403 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
6404 (iw_handler) iw_get_name, /* SIOCGIWNAME */
6405 (iw_handler) NULL, /* SIOCSIWNWID */
6406 (iw_handler) NULL, /* SIOCGIWNWID */
6407 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
6408 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
6409 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
6410 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
6411 (iw_handler) NULL, /* SIOCSIWSENS */
6412 (iw_handler) NULL, /* SIOCGIWSENS */
6413 (iw_handler) NULL, /* SIOCSIWRANGE */
6414 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
6415 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
6416 (iw_handler) NULL, /* SIOCGIWPRIV */
6417 (iw_handler) NULL, /* SIOCSIWSTATS */
6418 (iw_handler) NULL, /* SIOCGIWSTATS */
6419 iw_handler_set_spy, /* SIOCSIWSPY */
6420 iw_handler_get_spy, /* SIOCGIWSPY */
6421 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
6422 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
6423 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
6424 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
6425 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
6426 (iw_handler) NULL, /* SIOCGIWAPLIST */
6427 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
6428 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
6429 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
6430 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
6431 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
6432 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
6433 (iw_handler) NULL, /* -- hole -- */
6434 (iw_handler) NULL, /* -- hole -- */
6435 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
6436 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
6437 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
6438 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
6439 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
6440 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
6441 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
6442 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
6443 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
6444 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
6445 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
6446 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
6447 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
6448 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
6449 (iw_handler) NULL, /* -- hole -- */
6450 (iw_handler) NULL, /* -- hole -- */
6451 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
6452 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
6453 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
6454 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
6455 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
6456 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
6457 (iw_handler) NULL, /* SIOCSIWPMKSA */
6458};
6459
6460static const iw_handler we_private[] = {
6461
6462 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
6463 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
6464 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
6465 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
6466 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
6467 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
6468 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
6469 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
6470 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
6471 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07006472#ifdef FEATURE_OEM_DATA_SUPPORT
6473 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
6474 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
6475#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006476
6477#ifdef FEATURE_WLAN_WAPI
6478 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
6479 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
6480 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
6481 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
6482 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
6483 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
6484#endif /* FEATURE_WLAN_WAPI */
6485#ifdef WLAN_FEATURE_VOWIFI_11R
6486 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
6487#endif
6488 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
6489 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
6490 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
6491#ifdef WLAN_FEATURE_PACKET_FILTERING
6492 ,
6493 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
6494#endif
6495#ifdef FEATURE_WLAN_SCAN_PNO
6496 ,
6497 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
6498#endif
6499 ,
6500 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
6501 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
6502 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
6503 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006504 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07006505};
6506
6507/*Maximum command length can be only 15 */
6508static const struct iw_priv_args we_private_args[] = {
6509
6510 /* handlers for main ioctl */
6511 { WLAN_PRIV_SET_INT_GET_NONE,
6512 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6513 0,
6514 "" },
6515
6516 /* handlers for sub-ioctl */
6517 { WE_SET_11D_STATE,
6518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6519 0,
6520 "set11Dstate" },
6521
6522 { WE_WOWL,
6523 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6524 0,
6525 "wowl" },
6526
6527 { WE_SET_POWER,
6528 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6529 0,
6530 "setPower" },
6531
6532 { WE_SET_MAX_ASSOC,
6533 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6534 0,
6535 "setMaxAssoc" },
6536
6537 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
6538 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6539 0,
6540 "setAutoChannel" },
6541
6542 { WE_SET_DATA_INACTIVITY_TO,
6543 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6544 0,
6545 "inactivityTO" },
6546
6547 { WE_SET_MAX_TX_POWER,
6548 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6549 0,
6550 "setMaxTxPower" },
6551 /* set Higher DTIM Transition (DTIM1 to DTIM3)
6552 * 1 = enable and 0 = disable */
6553 {
6554 WE_SET_HIGHER_DTIM_TRANSITION,
6555 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6556 0,
6557 "setHDtimTransn" },
6558
6559 { WE_SET_TM_LEVEL,
6560 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6561 0,
6562 "setTmLevel" },
6563
6564 /* handlers for main ioctl */
6565 { WLAN_PRIV_SET_NONE_GET_INT,
6566 0,
6567 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6568 "" },
6569
6570 /* handlers for sub-ioctl */
6571 { WE_GET_11D_STATE,
6572 0,
6573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6574 "get11Dstate" },
6575
6576 { WE_IBSS_STATUS,
6577 0,
6578 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6579 "getAdhocStatus" },
6580
6581 { WE_PMC_STATE,
6582 0,
6583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6584 "pmcState" },
6585
6586 { WE_GET_WLAN_DBG,
6587 0,
6588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6589 "getwlandbg" },
6590
6591 { WE_MODULE_DOWN_IND,
6592 0,
6593 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6594 "moduleDownInd" },
6595
6596 { WE_GET_MAX_ASSOC,
6597 0,
6598 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6599 "getMaxAssoc" },
6600
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 { WE_GET_WDI_DBG,
6602 0,
6603 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6604 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07006605
6606 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
6607 0,
6608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6609 "getAutoChannel" },
6610
6611 { WE_GET_CONCURRENCY_MODE,
6612 0,
6613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6614 "getconcurrency" },
6615
6616 /* handlers for main ioctl */
6617 { WLAN_PRIV_SET_CHAR_GET_NONE,
6618 IW_PRIV_TYPE_CHAR| 512,
6619 0,
6620 "" },
6621
6622 /* handlers for sub-ioctl */
6623 { WE_WOWL_ADD_PTRN,
6624 IW_PRIV_TYPE_CHAR| 512,
6625 0,
6626 "wowlAddPtrn" },
6627
6628 { WE_WOWL_DEL_PTRN,
6629 IW_PRIV_TYPE_CHAR| 512,
6630 0,
6631 "wowlDelPtrn" },
6632
6633#if defined WLAN_FEATURE_VOWIFI
6634 /* handlers for sub-ioctl */
6635 { WE_NEIGHBOR_REPORT_REQUEST,
6636 IW_PRIV_TYPE_CHAR | 512,
6637 0,
6638 "neighbor" },
6639#endif
6640 { WE_SET_AP_WPS_IE,
6641 IW_PRIV_TYPE_CHAR| 512,
6642 0,
6643 "set_ap_wps_ie" },
6644
6645 { WE_SET_CONFIG,
6646 IW_PRIV_TYPE_CHAR| 512,
6647 0,
6648 "setConfig" },
6649
6650 /* handlers for main ioctl */
6651 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
6652 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6653 0,
6654 "" },
6655
6656 /* handlers for sub-ioctl */
6657 { WE_SET_WLAN_DBG,
6658 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6659 0,
6660 "setwlandbg" },
6661
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 { WE_SET_WDI_DBG,
6663 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6664 0,
6665 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07006666
6667 { WE_SET_SAP_CHANNELS,
6668 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
6669 0,
6670 "setsapchannels" },
6671
6672 /* handlers for main ioctl */
6673 { WLAN_PRIV_GET_CHAR_SET_NONE,
6674 0,
6675 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6676 "" },
6677
6678 /* handlers for sub-ioctl */
6679 { WE_WLAN_VERSION,
6680 0,
6681 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6682 "version" },
6683 { WE_GET_STATS,
6684 0,
6685 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6686 "getStats" },
6687 { WE_GET_CFG,
6688 0,
6689 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6690 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07006691#ifdef WLAN_FEATURE_11AC
6692 { WE_GET_RSSI,
6693 0,
6694 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6695 "getRSSI" },
6696#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006697#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
6698 { WE_GET_ROAM_RSSI,
6699 0,
6700 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6701 "getRoamRSSI" },
6702#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 { WE_GET_WMM_STATUS,
6704 0,
6705 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6706 "getWmmStatus" },
6707 {
6708 WE_GET_CHANNEL_LIST,
6709 0,
6710 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6711 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006712#ifdef FEATURE_WLAN_TDLS
6713 {
6714 WE_GET_TDLS_PEERS,
6715 0,
6716 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6717 "getTdlsPeers" },
6718#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006719#ifdef WLAN_FEATURE_11W
6720 {
6721 WE_GET_11W_INFO,
6722 0,
6723 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6724 "getPMFInfo" },
6725#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 /* handlers for main ioctl */
6727 { WLAN_PRIV_SET_NONE_GET_NONE,
6728 0,
6729 0,
6730 "" },
6731
6732 /* handlers for sub-ioctl */
6733 { WE_CLEAR_STATS,
6734 0,
6735 0,
6736 "clearStats" },
6737 { WE_INIT_AP,
6738 0,
6739 0,
6740 "initAP" },
6741 { WE_STOP_AP,
6742 0,
6743 0,
6744 "exitAP" },
6745 { WE_ENABLE_AMP,
6746 0,
6747 0,
6748 "enableAMP" },
6749 { WE_DISABLE_AMP,
6750 0,
6751 0,
6752 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006753 { WE_ENABLE_DXE_STALL_DETECT,
6754 0,
6755 0,
6756 "dxeStallDetect" },
6757 { WE_DISPLAY_DXE_SNAP_SHOT,
6758 0,
6759 0,
6760 "dxeSnapshot" },
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07006761 {
6762 WE_SET_REASSOC_TRIGGER,
6763 0,
6764 0,
6765 "reassoc" },
Jeff Johnson295189b2012-06-20 16:38:30 -07006766
6767 /* handlers for main ioctl */
6768 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
6769 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6770 0,
6771 "" },
6772
6773 /* handlers for sub-ioctl */
6774 { WE_LOG_DUMP_CMD,
6775 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6776 0,
6777 "dump" },
6778
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006779 /* handlers for sub ioctl */
6780 {
6781 WE_MCC_CONFIG_CREDENTIAL,
6782 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6783 0,
6784 "setMccCrdnl" },
6785
6786 /* handlers for sub ioctl */
6787 {
6788 WE_MCC_CONFIG_PARAMS,
6789 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6790 0,
6791 "setMccConfig" },
6792
Chilam NG571c65a2013-01-19 12:27:36 +05306793#ifdef FEATURE_WLAN_TDLS
6794 /* handlers for sub ioctl */
6795 {
6796 WE_TDLS_CONFIG_PARAMS,
6797 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
6798 0,
6799 "setTdlsConfig" },
6800#endif
6801
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 /* handlers for main ioctl */
6803 { WLAN_PRIV_ADD_TSPEC,
6804 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
6805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6806 "addTspec" },
6807
6808 /* handlers for main ioctl */
6809 { WLAN_PRIV_DEL_TSPEC,
6810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6811 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6812 "delTspec" },
6813
6814 /* handlers for main ioctl */
6815 { WLAN_PRIV_GET_TSPEC,
6816 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6817 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6818 "getTspec" },
6819
Jeff Johnsone7245742012-09-05 17:12:55 -07006820#ifdef FEATURE_OEM_DATA_SUPPORT
6821 /* handlers for main ioctl - OEM DATA */
6822 {
6823 WLAN_PRIV_SET_OEM_DATA_REQ,
6824 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
6825 0,
6826 "set_oem_data_req" },
6827
6828 /* handlers for main ioctl - OEM DATA */
6829 {
6830 WLAN_PRIV_GET_OEM_DATA_RSP,
6831 0,
6832 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
6833 "get_oem_data_rsp" },
6834#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006835
6836#ifdef FEATURE_WLAN_WAPI
6837 /* handlers for main ioctl SET_WAPI_MODE */
6838 { WLAN_PRIV_SET_WAPI_MODE,
6839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6840 0,
6841 "SET_WAPI_MODE" },
6842
6843 /* handlers for main ioctl GET_WAPI_MODE */
6844 { WLAN_PRIV_GET_WAPI_MODE,
6845 0,
6846 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6847 "GET_WAPI_MODE" },
6848
6849 /* handlers for main ioctl SET_ASSOC_INFO */
6850 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
6851 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
6852 0,
6853 "SET_WAPI_ASSOC" },
6854
6855 /* handlers for main ioctl SET_WAPI_KEY */
6856 { WLAN_PRIV_SET_WAPI_KEY,
6857 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
6858 0,
6859 "SET_WAPI_KEY" },
6860
6861 /* handlers for main ioctl SET_WAPI_BKID */
6862 { WLAN_PRIV_SET_WAPI_BKID,
6863 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
6864 0,
6865 "SET_WAPI_BKID" },
6866
6867 /* handlers for main ioctl GET_WAPI_BKID */
6868 { WLAN_PRIV_GET_WAPI_BKID,
6869 0,
6870 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
6871 "GET_WAPI_BKID" },
6872#endif /* FEATURE_WLAN_WAPI */
6873
6874 /* handlers for main ioctl - host offload */
6875 {
6876 WLAN_PRIV_SET_HOST_OFFLOAD,
6877 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
6878 0,
6879 "setHostOffload" },
6880
6881 {
6882 WLAN_GET_WLAN_STATISTICS,
6883 0,
6884 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
6885 "getWlanStats" },
6886
6887 {
6888 WLAN_SET_KEEPALIVE_PARAMS,
6889 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
6890 0,
6891 "setKeepAlive" },
6892#ifdef WLAN_FEATURE_PACKET_FILTERING
6893 {
6894 WLAN_SET_PACKET_FILTER_PARAMS,
6895 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
6896 0,
6897 "setPktFilter" },
6898#endif
6899#ifdef FEATURE_WLAN_SCAN_PNO
6900 {
6901 WLAN_SET_PNO,
6902 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6903 0,
6904 "setpno" },
6905#endif
6906 {
6907 WLAN_SET_BAND_CONFIG,
6908 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6909 0,
6910 "SETBAND" },
6911 /* handlers for dynamic MC BC ioctl */
6912 {
6913 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006914 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07006915 0,
6916 "setMCBCFilter" },
6917 {
6918 WLAN_PRIV_CLEAR_MCBC_FILTER,
6919 0,
6920 0,
6921 "clearMCBCFilter" },
6922 {
6923 WLAN_SET_POWER_PARAMS,
6924 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
6925 0,
6926 "setpowerparams" },
6927 {
6928 WLAN_GET_LINK_SPEED,
6929 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05306930 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07006931
Jeff Johnson295189b2012-06-20 16:38:30 -07006932};
6933
6934
6935
6936const struct iw_handler_def we_handler_def = {
6937 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
6938 .num_private = sizeof(we_private) / sizeof(we_private[0]),
6939 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
6940
6941 .standard = (iw_handler *)we_handler,
6942 .private = (iw_handler *)we_private,
6943 .private_args = we_private_args,
6944 .get_wireless_stats = get_wireless_stats,
6945};
6946
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006947int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
6948{
6949 v_U32_t cmd = 288; //Command to RIVA
6950 hdd_context_t *pHddCtx = NULL;
6951 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6952 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6953 /*
6954 *configMccParam : specify the bit which needs to be modified
6955 *allowed to update based on wlan_qcom_cfg.ini
6956 * configuration
6957 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
6958 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
6959 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
6960 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
6961 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
6962 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
6963 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
6964 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
6965 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
6966 * Bit 9 : Reserved
6967 */
6968 switch (arg1)
6969 {
6970 //Update MCC SCHEDULE_TIME_SLICE parameter
6971 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
6972 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
6973 {
6974 if((arg2 >= 5) && (arg2 <= 20))
6975 {
6976 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6977 }
6978 else
6979 {
6980 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6981 return 0;
6982 }
6983 }
6984 break;
6985
6986 //Update MCC MAX_NULL_SEND_TIME parameter
6987 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
6988 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
6989 {
6990 if((arg2 >= 1) && (arg2 <= 10))
6991 {
6992 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
6993 }
6994 else
6995 {
6996 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
6997 return 0;
6998 }
6999 }
7000 break;
7001
7002 //Update MCC TX_EARLY_STOP_TIME parameter
7003 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
7004 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
7005 {
7006 if((arg2 >= 1) && (arg2 <= 10))
7007 {
7008 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7009 }
7010 else
7011 {
7012 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7013 return 0;
7014 }
7015 }
7016 break;
7017
7018 //Update MCC RX_DRAIN_TIME parameter
7019 case MCC_RX_DRAIN_TIME_CFG_PARAM :
7020 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
7021 {
7022 if((arg2 >= 1) && (arg2 <= 10))
7023 {
7024 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7025 }
7026 else
7027 {
7028 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7029 return 0;
7030 }
7031 }
7032 break;
7033
7034 //Update MCC CHANNEL_SWITCH_TIME parameter
7035 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
7036 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
7037 {
7038 if((arg2 >= 1) && (arg2 <= 20))
7039 {
7040 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7041 }
7042 else
7043 {
7044 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7045 return 0;
7046 }
7047 }
7048 break;
7049
7050 //Update MCC MIN_CHANNEL_TIME parameter
7051 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
7052 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
7053 {
7054 if((arg2 >= 5) && (arg2 <= 20))
7055 {
7056 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7057 }
7058 else
7059 {
7060 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7061 return 0;
7062 }
7063 }
7064 break;
7065
7066 //Update MCC PARK_BEFORE_TBTT parameter
7067 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
7068 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
7069 {
7070 if((arg2 >= 1) && (arg2 <= 5))
7071 {
7072 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7073 }
7074 else
7075 {
7076 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7077 return 0;
7078 }
7079 }
7080 break;
7081
7082 //Update MCC MIN_AFTER_DTIM parameter
7083 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
7084 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
7085 {
7086 if((arg2 >= 5) && (arg2 <= 15))
7087 {
7088 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7089 }
7090 else
7091 {
7092 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7093 return 0;
7094 }
7095 }
7096 break;
7097
7098 //Update MCC TOO_CLOSE_MARGIN parameter
7099 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
7100 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
7101 {
7102 if((arg2 >= 1) && (arg2 <= 3))
7103 {
7104 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
7105 }
7106 else
7107 {
7108 hddLog(LOGE, "%s : Enter a valid MCC configuration value\n",__FUNCTION__);
7109 return 0;
7110 }
7111 }
7112 break;
7113
7114 default :
7115 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d\n",
7116 __FUNCTION__,arg1);
7117 break;
7118 }
7119 return 0;
7120}
7121
Jeff Johnson295189b2012-06-20 16:38:30 -07007122int hdd_set_wext(hdd_adapter_t *pAdapter)
7123{
7124 hdd_wext_state_t *pwextBuf;
7125 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007126 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007127
7128 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7129
7130 // Now configure the roaming profile links. To SSID and bssid.
7131 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
7132 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
7133
7134 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
7135 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
7136
7137 /*Set the numOfChannels to zero to scan all the channels*/
7138 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
7139 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
7140
7141 /* Default is no encryption */
7142 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
7143 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7144
7145 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
7146 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7147
7148 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
7149
7150 /* Default is no authentication */
7151 pwextBuf->roamProfile.AuthType.numEntries = 1;
7152 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
7153
7154 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
7155 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
7156
7157 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007158 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07007159
7160 hdd_clearRoamProfileIe(pAdapter);
7161
7162 return VOS_STATUS_SUCCESS;
7163
7164 }
7165
7166int hdd_register_wext(struct net_device *dev)
7167 {
7168 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7169 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7170 VOS_STATUS status;
7171
7172 ENTER();
7173
7174 // Zero the memory. This zeros the profile structure.
7175 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
7176
7177 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
7178
7179
7180 status = hdd_set_wext(pAdapter);
7181
7182 if(!VOS_IS_STATUS_SUCCESS(status)) {
7183
7184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!\n"));
7185 return eHAL_STATUS_FAILURE;
7186 }
7187
7188 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
7189 {
7190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!\n"));
7191 return eHAL_STATUS_FAILURE;
7192 }
7193
7194 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
7195 {
7196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!\n"));
7197 return eHAL_STATUS_FAILURE;
7198 }
7199
7200 // Register as a wireless device
7201 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
7202
7203 EXIT();
7204 return 0;
7205}
7206
7207int hdd_UnregisterWext(struct net_device *dev)
7208{
7209#if 0
7210 hdd_wext_state_t *wextBuf;
7211 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7212
7213 ENTER();
7214 // Set up the pointer to the Wireless Extensions state structure
7215 wextBuf = pAdapter->pWextState;
7216
7217 // De-allocate the Wireless Extensions state structure
7218 kfree(wextBuf);
7219
7220 // Clear out the pointer to the Wireless Extensions state structure
7221 pAdapter->pWextState = NULL;
7222
7223 EXIT();
7224#endif
7225 dev->wireless_handlers = NULL;
7226 return 0;
7227}
7228
7229