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