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