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