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