blob: 916a088fb07a57a93e411edb83ef8a07aacffd33 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/** ------------------------------------------------------------------------ *
7 ------------------------------------------------------------------------ *
8
9
10 \file wlan_hdd_wext.c
11
12 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
13 interfaces.
14
15 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
16
Kiet Lamaa8e15a2014-02-11 23:30:06 -080017 Copyright (C) 2007 Airgo Networks, Incorporated
18
Jeff Johnson295189b2012-06-20 16:38:30 -070019 This file defines all of the types that are utilized by the CCP module
20 of the "Portable" HDD. This file also includes the underlying Linux
21 Wireless Extensions Data types referred to by CCP.
22
23 ======================================================================== */
24
25#include <linux/version.h>
26#include <linux/module.h>
27#include <linux/kernel.h>
28#include <linux/init.h>
29#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053030#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070031#include <wlan_hdd_includes.h>
32#include <wlan_btc_svc.h>
33#include <wlan_nlink_common.h>
34#ifdef WLAN_BTAMP_FEATURE
35#include <bap_hdd_main.h>
36#endif
37#include <vos_api.h>
38#include <net/arp.h>
39#include "ccmApi.h"
40#include "sirParams.h"
41#include "csrApi.h"
42#include "csrInsideApi.h"
43#if defined WLAN_FEATURE_VOWIFI
44#include "smeRrmInternal.h"
45#endif
46#include <aniGlobal.h>
47#include "dot11f.h"
48#include <wlan_hdd_wowl.h>
49#include <wlan_hdd_cfg.h>
50#include <wlan_hdd_wmm.h>
51#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070052#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053053#ifdef FEATURE_WLAN_TDLS
54#include "wlan_hdd_tdls.h"
55#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070056
57#ifdef CONFIG_HAS_EARLYSUSPEND
58#include <linux/earlysuspend.h>
59#endif
60#include "wlan_hdd_power.h"
61#include "qwlan_version.h"
62#include <vos_power.h>
63#include "wlan_hdd_host_offload.h"
64#include "wlan_hdd_keep_alive.h"
65#ifdef WLAN_FEATURE_PACKET_FILTERING
66#include "wlan_hdd_packet_filtering.h"
67#endif
68
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include <linux/wireless.h>
70#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070071#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053072#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070073
74#include "wlan_hdd_misc.h"
75#include "bap_hdd_misc.h"
76
77#include "wlan_hdd_dev_pwr.h"
78#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +053079#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070080#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070081
82#ifdef CONFIG_HAS_EARLYSUSPEND
83extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
84extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
85#endif
86
Jeff Johnsone7245742012-09-05 17:12:55 -070087#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -080088#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -070089#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070090
91#define HDD_FINISH_ULA_TIME_OUT 800
92
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070093
Jeff Johnson295189b2012-06-20 16:38:30 -070094extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
95int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
96
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -070097static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -070098module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
99
Jeff Johnson295189b2012-06-20 16:38:30 -0700100/* To Validate Channel against the Frequency and Vice-Versa */
101static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
102 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
103 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
104 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
105 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
106 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
107 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
108 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
109 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
110
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800111#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
113/* Private ioctls and their sub-ioctls */
114#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
115#define WE_SET_11D_STATE 1
116#define WE_WOWL 2
117#define WE_SET_POWER 3
118#define WE_SET_MAX_ASSOC 4
119#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
120#define WE_SET_DATA_INACTIVITY_TO 6
121#define WE_SET_MAX_TX_POWER 7
122#define WE_SET_HIGHER_DTIM_TRANSITION 8
123#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530124#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700125#define WE_SET_MAX_TX_POWER_2_4 11
126#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800127/* Private IOCTL for debug connection issues */
128#define WE_SET_DEBUG_LOG 13
Jeff Johnson295189b2012-06-20 16:38:30 -0700129
130/* Private ioctls and their sub-ioctls */
131#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
132#define WE_GET_11D_STATE 1
133#define WE_IBSS_STATUS 2
134#define WE_PMC_STATE 3
135#define WE_GET_WLAN_DBG 4
136#define WE_MODULE_DOWN_IND 5
137#define WE_GET_MAX_ASSOC 6
138#define WE_GET_WDI_DBG 7
139#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
140#define WE_GET_CONCURRENCY_MODE 9
141/* Private ioctls and their sub-ioctls */
142#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
143
144/* Private ioctls and their sub-ioctls */
145#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
146#define WE_WOWL_ADD_PTRN 1
147#define WE_WOWL_DEL_PTRN 2
148#if defined WLAN_FEATURE_VOWIFI
149#define WE_NEIGHBOR_REPORT_REQUEST 3
150#endif
151#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
152#define WE_SET_CONFIG 5
153
154/* Private ioctls and their sub-ioctls */
155#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
156#define WE_SET_WLAN_DBG 1
157#define WE_SET_WDI_DBG 2
158#define WE_SET_SAP_CHANNELS 3
159
160/* Private ioctls and their sub-ioctls */
161#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
162#define WE_WLAN_VERSION 1
163#define WE_GET_STATS 2
164#define WE_GET_CFG 3
165#define WE_GET_WMM_STATUS 4
166#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700167#ifdef WLAN_FEATURE_11AC
168#define WE_GET_RSSI 6
169#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800170#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800171#ifdef FEATURE_WLAN_TDLS
172#define WE_GET_TDLS_PEERS 8
173#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700174#ifdef WLAN_FEATURE_11W
175#define WE_GET_11W_INFO 9
176#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530177#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700178
179/* Private ioctls and their sub-ioctls */
180#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
181#define WE_CLEAR_STATS 1
182#define WE_INIT_AP 2
183#define WE_STOP_AP 3
184#define WE_ENABLE_AMP 4
185#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700186#define WE_ENABLE_DXE_STALL_DETECT 6
187#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530188#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700189#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530190#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700191
192/* Private ioctls and their sub-ioctls */
193#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
194#define WE_LOG_DUMP_CMD 1
195
Jeff Johnson295189b2012-06-20 16:38:30 -0700196#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800197//IOCTL to configure MCC params
198#define WE_MCC_CONFIG_CREDENTIAL 3
199#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700200
Chilam NG571c65a2013-01-19 12:27:36 +0530201#ifdef FEATURE_WLAN_TDLS
202#define WE_TDLS_CONFIG_PARAMS 5
203#endif
204
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700205#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530206#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700207
Chilam Ng01120412013-02-19 18:32:21 -0800208#ifdef FEATURE_WLAN_TDLS
209#undef MAX_VAR_ARGS
210#define MAX_VAR_ARGS 10
211#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700212#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800213#endif
214
Jeff Johnson295189b2012-06-20 16:38:30 -0700215
216/* Private ioctls (with no sub-ioctls) */
217/* note that they must be odd so that they have "get" semantics */
218#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
219#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
220#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
221
222#ifdef FEATURE_WLAN_WAPI
223/* Private ioctls EVEN NO: SET, ODD NO:GET */
224#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
225#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
226#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
227#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
228#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
229#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
230#define WAPI_PSK_AKM_SUITE 0x02721400
231#define WAPI_CERT_AKM_SUITE 0x01721400
232#endif
233
Jeff Johnsone7245742012-09-05 17:12:55 -0700234#ifdef FEATURE_OEM_DATA_SUPPORT
235/* Private ioctls for setting the measurement configuration */
236#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
237#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
238#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700239
240#ifdef WLAN_FEATURE_VOWIFI_11R
241#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
242#endif
243
244/* Private ioctl for setting the host offload feature */
245#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
246
247/* Private ioctl to get the statistics */
248#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
249
250/* Private ioctl to set the Keep Alive Params */
251#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
252#ifdef WLAN_FEATURE_PACKET_FILTERING
253/* Private ioctl to set the Packet Filtering Params */
254#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
255#endif
256
257#ifdef FEATURE_WLAN_SCAN_PNO
258/* Private ioctl to get the statistics */
259#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
260#endif
261
262#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
263
264#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
265#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700266/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700267
Jeff Johnson295189b2012-06-20 16:38:30 -0700268#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
269#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
270
271#define WLAN_STATS_INVALID 0
272#define WLAN_STATS_RETRY_CNT 1
273#define WLAN_STATS_MUL_RETRY_CNT 2
274#define WLAN_STATS_TX_FRM_CNT 3
275#define WLAN_STATS_RX_FRM_CNT 4
276#define WLAN_STATS_FRM_DUP_CNT 5
277#define WLAN_STATS_FAIL_CNT 6
278#define WLAN_STATS_RTS_FAIL_CNT 7
279#define WLAN_STATS_ACK_FAIL_CNT 8
280#define WLAN_STATS_RTS_SUC_CNT 9
281#define WLAN_STATS_RX_DISCARD_CNT 10
282#define WLAN_STATS_RX_ERROR_CNT 11
283#define WLAN_STATS_TX_BYTE_CNT 12
284
285#define WLAN_STATS_RX_BYTE_CNT 13
286#define WLAN_STATS_RX_RATE 14
287#define WLAN_STATS_TX_RATE 15
288
Jeff Johnsone7245742012-09-05 17:12:55 -0700289#define WLAN_STATS_RX_UC_BYTE_CNT 16
290#define WLAN_STATS_RX_MC_BYTE_CNT 17
291#define WLAN_STATS_RX_BC_BYTE_CNT 18
292#define WLAN_STATS_TX_UC_BYTE_CNT 19
293#define WLAN_STATS_TX_MC_BYTE_CNT 20
294#define WLAN_STATS_TX_BC_BYTE_CNT 21
295
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800296#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
297 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
298 { \
299 *__p++ = __type; \
300 *__p++ = __size; \
301 memcpy(__p, __val, __size); \
302 __p += __size; \
303 __tlen += __size + 2; \
304 } \
305 else \
306 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800307 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800308 } \
309 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700310
311#define VERSION_VALUE_MAX_LEN 32
312
313#define TX_PER_TRACKING_DEFAULT_RATIO 5
314#define TX_PER_TRACKING_MAX_RATIO 10
315#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
316
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530317#define WLAN_ADAPTER 0
318#define P2P_ADAPTER 1
319
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800320/*MCC Configuration parameters */
321enum {
322 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
323 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
324 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
325 MCC_RX_DRAIN_TIME_CFG_PARAM,
326 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
327 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
328 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
329 MCC_MIN_AFTER_DTIM_CFG_PARAM,
330 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
331};
332
333int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
334 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
335
Jeff Johnson295189b2012-06-20 16:38:30 -0700336#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800337int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700338 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700339#endif
340
Jeff Johnson295189b2012-06-20 16:38:30 -0700341/**---------------------------------------------------------------------------
342
Arif Hussain0273cba2014-01-07 20:58:29 -0800343 \brief mem_alloc_copy_from_user_helper -
344
345 Helper function to allocate buffer and copy user data.
346
347 \param - wrqu - Pointer to IOCTL Data.
348 len - size
349
350 \return - On Success pointer to buffer, On failure NULL
351
352 --------------------------------------------------------------------------*/
353static void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
354{
355 u8 *ptr = NULL;
356
357 /* in order to protect the code, an extra byte is post appended to the buffer
358 * and the null termination is added. However, when allocating (len+1) byte
359 * of memory, we need to make sure that there is no uint overflow when doing
360 * addition. In theory check len < UINT_MAX protects the uint overflow. For
361 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
362 * guess, now, it is assumed that the private command buffer size is no
363 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
364 */
365 if (len > MAX_USER_COMMAND_SIZE)
366 {
367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
368 "Invalid length");
369 return NULL;
370 }
371
372 ptr = kmalloc(len + 1, GFP_KERNEL);
373 if (NULL == ptr)
374 {
375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
376 "unable to allocate memory");
377 return NULL;
378 }
379
380 if (copy_from_user(ptr, wrqu_data, len))
381 {
382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
383 "%s: failed to copy data to user buffer", __func__);
384 kfree(ptr);
385 return NULL;
386 }
387 ptr[len] = '\0';
388 return ptr;
389}
390
391/**---------------------------------------------------------------------------
392
Jeff Johnson295189b2012-06-20 16:38:30 -0700393 \brief hdd_wlan_get_version() -
394
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800395 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700396
397 \param - pAdapter Pointer to the adapter.
398 wrqu - Pointer to IOCTL REQUEST Data.
399 extra - Pointer to char
400
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800401 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700402
403 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800404void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
405 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700406{
407 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800408 tSirVersionString wcnss_SW_version;
409 tSirVersionString wcnss_HW_version;
410 char *pSWversion;
411 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700413
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800414 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
415 sizeof(wcnss_SW_version));
416 if (VOS_IS_STATUS_SUCCESS(status))
417 {
418 pSWversion = wcnss_SW_version;
419 }
420 else
421 {
422 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 }
424
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800425 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
426 sizeof(wcnss_HW_version));
427 if (VOS_IS_STATUS_SUCCESS(status))
428 {
429 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700430 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800431 else
432 {
433 pHWversion = "Unknown";
434 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700435
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700436 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800437 "Host SW:%s, FW:%s, HW:%s",
438 QWLAN_VERSIONSTR,
439 pSWversion,
440 pHWversion);
441
442 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700443}
444
Jeff Johnson295189b2012-06-20 16:38:30 -0700445int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
446{
447 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
448 v_U32_t threshold = 0,status = 0;
449
450 ENTER();
451
Agarwal Ashish971c2882013-10-30 20:11:12 +0530452 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
453 {
454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 "%s:LOGP in Progress. Ignore!!!",__func__);
456 return status;
457 }
458
459 if ( eHAL_STATUS_SUCCESS !=
460 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
461 {
c_hpothub8245442013-11-20 23:41:09 +0530462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
463 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 return -EIO;
465 }
466 wrqu->rts.value = threshold;
467
468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800469 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700470
471 EXIT();
472
473 return 0;
474}
475
476int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
477{
478 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
479 v_U32_t threshold = 0,status = 0;
480
481 ENTER();
482
Agarwal Ashish971c2882013-10-30 20:11:12 +0530483 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
484 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
486 "%s:LOGP in Progress. Ignore!!!",__func__);
487 return status;
488 }
489
490 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
491 != eHAL_STATUS_SUCCESS )
492 {
c_hpothub8245442013-11-20 23:41:09 +0530493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
494 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 return -EIO;
496 }
497 wrqu->frag.value = threshold;
498
499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800500 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700501
502 EXIT();
503
504 return 0;
505}
506
507int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
508{
Jeff Johnsone7245742012-09-05 17:12:55 -0700509 int i;
510 if (channel > 0)
511 {
512 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
513 {
514 if (channel == freq_chan_map[i].chan)
515 {
516 *pfreq = freq_chan_map[i].freq;
517 return 1;
518 }
519 }
520 }
521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800522 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700523 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700524}
525
526static v_BOOL_t
527hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
528{
529 v_BOOL_t rsnType = VOS_FALSE;
530 // is the authType supported?
531 switch (authType)
532 {
533 case eCSR_AUTH_TYPE_NONE: //never used
534 rsnType = eANI_BOOLEAN_FALSE;
535 break;
536 // MAC layer authentication types
537 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
538 rsnType = eANI_BOOLEAN_FALSE;
539 break;
540 case eCSR_AUTH_TYPE_SHARED_KEY:
541 rsnType = eANI_BOOLEAN_FALSE;
542 break;
543 case eCSR_AUTH_TYPE_AUTOSWITCH:
544 rsnType = eANI_BOOLEAN_FALSE;
545 break;
546
547 // Upper layer authentication types
548 case eCSR_AUTH_TYPE_WPA:
549 rsnType = eANI_BOOLEAN_TRUE;
550 break;
551 case eCSR_AUTH_TYPE_WPA_PSK:
552 rsnType = eANI_BOOLEAN_TRUE;
553 break;
554 case eCSR_AUTH_TYPE_WPA_NONE:
555 rsnType = eANI_BOOLEAN_TRUE;
556 break;
557#ifdef WLAN_FEATURE_VOWIFI_11R
558 case eCSR_AUTH_TYPE_FT_RSN:
559#endif
560 case eCSR_AUTH_TYPE_RSN:
561 rsnType = eANI_BOOLEAN_TRUE;
562 break;
563#ifdef WLAN_FEATURE_VOWIFI_11R
564 case eCSR_AUTH_TYPE_FT_RSN_PSK:
565#endif
566 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700567#ifdef WLAN_FEATURE_11W
568 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
569#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 rsnType = eANI_BOOLEAN_TRUE;
571 break;
572 //case eCSR_AUTH_TYPE_FAILED:
573 case eCSR_AUTH_TYPE_UNKNOWN:
574 rsnType = eANI_BOOLEAN_FALSE;
575 break;
576 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800577 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
578 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 rsnType = eANI_BOOLEAN_FALSE;
580 break;
581 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800582 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700583 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 return rsnType;
585}
586
587static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
588{
589 struct statsContext *pStatsContext;
590 hdd_adapter_t *pAdapter;
591
592 if (ioctl_debug)
593 {
594 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700595 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 }
597
598 if (NULL == pContext)
599 {
600 hddLog(VOS_TRACE_LEVEL_ERROR,
601 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700602 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 return;
604 }
605
Jeff Johnson295189b2012-06-20 16:38:30 -0700606 pStatsContext = pContext;
607 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800608
609 /* there is a race condition that exists between this callback
610 function and the caller since the caller could time out either
611 before or while this code is executing. we use a spinlock to
612 serialize these actions */
613 spin_lock(&hdd_context_lock);
614
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
616 {
617 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800618 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 hddLog(VOS_TRACE_LEVEL_WARN,
620 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700621 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 if (ioctl_debug)
623 {
624 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700625 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 }
627 return;
628 }
629
Jeff Johnson72a40512013-12-19 10:14:15 -0800630 /* context is valid so caller is still waiting */
631
632 /* paranoia: invalidate the magic */
633 pStatsContext->magic = 0;
634
635 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 pAdapter->rssi = rssi;
637
Jeff Johnson72a40512013-12-19 10:14:15 -0800638 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800640
641 /* serialization is complete */
642 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700643}
644
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530645static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
646{
647 struct statsContext *pStatsContext;
648 hdd_adapter_t *pAdapter;
649
650 if (ioctl_debug)
651 {
652 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
653 __func__, (int)snr, (int)staId, pContext);
654 }
655
656 if (NULL == pContext)
657 {
658 hddLog(VOS_TRACE_LEVEL_ERROR,
659 "%s: Bad param, pContext [%p]",
660 __func__, pContext);
661 return;
662 }
663
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530664 pStatsContext = pContext;
665 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800666
667 /* there is a race condition that exists between this callback
668 function and the caller since the caller could time out either
669 before or while this code is executing. we use a spinlock to
670 serialize these actions */
671 spin_lock(&hdd_context_lock);
672
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530673 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
674 {
675 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800676 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530677 hddLog(VOS_TRACE_LEVEL_WARN,
678 "%s: Invalid context, pAdapter [%p] magic [%08x]",
679 __func__, pAdapter, pStatsContext->magic);
680 if (ioctl_debug)
681 {
682 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
683 __func__, pAdapter, pStatsContext->magic);
684 }
685 return;
686 }
687
Jeff Johnson72a40512013-12-19 10:14:15 -0800688 /* context is valid so caller is still waiting */
689
690 /* paranoia: invalidate the magic */
691 pStatsContext->magic = 0;
692
693 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530694 pAdapter->snr = snr;
695
Jeff Johnson72a40512013-12-19 10:14:15 -0800696 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530697 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800698
699 /* serialization is complete */
700 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530701}
702
Jeff Johnson295189b2012-06-20 16:38:30 -0700703VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
704{
705 struct statsContext context;
706 hdd_context_t *pHddCtx;
707 hdd_station_ctx_t *pHddStaCtx;
708 eHalStatus hstatus;
709 long lrc;
710
711 if (NULL == pAdapter)
712 {
713 hddLog(VOS_TRACE_LEVEL_WARN,
714 "%s: Invalid context, pAdapter", __func__);
715 return VOS_STATUS_E_FAULT;
716 }
717 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
718 {
719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
720 /* return a cached value */
721 *rssi_value = pAdapter->rssi;
722 return VOS_STATUS_SUCCESS;
723 }
724
725 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
726 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
727
728 init_completion(&context.completion);
729 context.pAdapter = pAdapter;
730 context.magic = RSSI_CONTEXT_MAGIC;
731
732 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
733 pHddStaCtx->conn_info.staId[ 0 ],
734 pHddStaCtx->conn_info.bssId,
735 &context, pHddCtx->pvosContext);
736 if (eHAL_STATUS_SUCCESS != hstatus)
737 {
738 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700739 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 /* we'll returned a cached value below */
741 }
742 else
743 {
744 /* request was sent -- wait for the response */
745 lrc = wait_for_completion_interruptible_timeout(&context.completion,
746 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 if (lrc <= 0)
748 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800749 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700750 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 /* we'll now returned a cached value below */
752 }
753 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800754
755 /* either we never sent a request, we sent a request and received a
756 response or we sent a request and timed out. if we never sent a
757 request or if we sent a request and got a response, we want to
758 clear the magic out of paranoia. if we timed out there is a
759 race condition such that the callback function could be
760 executing at the same time we are. of primary concern is if the
761 callback function had already verified the "magic" but had not
762 yet set the completion variable when a timeout occurred. we
763 serialize these activities by invalidating the magic while
764 holding a shared spinlock which will cause us to block if the
765 callback is currently executing */
766 spin_lock(&hdd_context_lock);
767 context.magic = 0;
768 spin_unlock(&hdd_context_lock);
769
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 *rssi_value = pAdapter->rssi;
771
772 return VOS_STATUS_SUCCESS;
773}
774
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530775VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
776{
777 struct statsContext context;
778 hdd_context_t *pHddCtx;
779 hdd_station_ctx_t *pHddStaCtx;
780 eHalStatus hstatus;
781 long lrc;
782 int valid;
783
784 if (NULL == pAdapter)
785 {
786 hddLog(VOS_TRACE_LEVEL_ERROR,
787 "%s: Invalid context, pAdapter", __func__);
788 return VOS_STATUS_E_FAULT;
789 }
790
791 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
792
793 valid = wlan_hdd_validate_context(pHddCtx);
794 if (0 != valid)
795 {
796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
797 return VOS_STATUS_E_FAULT;
798 }
799
800 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
801 if (NULL == pHddStaCtx)
802 {
803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
804 return VOS_STATUS_E_FAULT;
805 }
806
807 init_completion(&context.completion);
808 context.pAdapter = pAdapter;
809 context.magic = SNR_CONTEXT_MAGIC;
810
811 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
812 pHddStaCtx->conn_info.staId[ 0 ],
813 pHddStaCtx->conn_info.bssId,
814 &context);
815 if (eHAL_STATUS_SUCCESS != hstatus)
816 {
817 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
818 __func__);
819 /* we'll returned a cached value below */
820 }
821 else
822 {
823 /* request was sent -- wait for the response */
824 lrc = wait_for_completion_interruptible_timeout(&context.completion,
825 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530826 if (lrc <= 0)
827 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800828 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530829 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530830 /* we'll now returned a cached value below */
831 }
832 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800833
834 /* either we never sent a request, we sent a request and received a
835 response or we sent a request and timed out. if we never sent a
836 request or if we sent a request and got a response, we want to
837 clear the magic out of paranoia. if we timed out there is a
838 race condition such that the callback function could be
839 executing at the same time we are. of primary concern is if the
840 callback function had already verified the "magic" but had not
841 yet set the completion variable when a timeout occurred. we
842 serialize these activities by invalidating the magic while
843 holding a shared spinlock which will cause us to block if the
844 callback is currently executing */
845 spin_lock(&hdd_context_lock);
846 context.magic = 0;
847 spin_unlock(&hdd_context_lock);
848
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530849 *snr = pAdapter->snr;
850
851 return VOS_STATUS_SUCCESS;
852}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800853#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
854
855static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
856{
857 struct statsContext *pStatsContext;
858 hdd_adapter_t *pAdapter;
859 if (ioctl_debug)
860 {
861 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
862 __func__, (int)rssi, (int)staId, pContext);
863 }
864
865 if (NULL == pContext)
866 {
867 hddLog(VOS_TRACE_LEVEL_ERROR,
868 "%s: Bad param, pContext [%p]",
869 __func__, pContext);
870 return;
871 }
872
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800873 pStatsContext = pContext;
874 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800875
876 /* there is a race condition that exists between this callback
877 function and the caller since the caller could time out either
878 before or while this code is executing. we use a spinlock to
879 serialize these actions */
880 spin_lock(&hdd_context_lock);
881
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800882 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
883 {
884 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800885 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800886 hddLog(VOS_TRACE_LEVEL_WARN,
887 "%s: Invalid context, pAdapter [%p] magic [%08x]",
888 __func__, pAdapter, pStatsContext->magic);
889 if (ioctl_debug)
890 {
891 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
892 __func__, pAdapter, pStatsContext->magic);
893 }
894 return;
895 }
896
Jeff Johnson72a40512013-12-19 10:14:15 -0800897 /* context is valid so caller is still waiting */
898
899 /* paranoia: invalidate the magic */
900 pStatsContext->magic = 0;
901
902 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800903 pAdapter->rssi = rssi;
904
Jeff Johnson72a40512013-12-19 10:14:15 -0800905 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800906 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800907
908 /* serialization is complete */
909 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800910}
911
912
913
914VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
915{
916 struct statsContext context;
917 hdd_context_t *pHddCtx = NULL;
918 hdd_station_ctx_t *pHddStaCtx = NULL;
919 eHalStatus hstatus;
920 long lrc;
921
922 if (NULL == pAdapter)
923 {
924 hddLog(VOS_TRACE_LEVEL_WARN,
925 "%s: Invalid context, pAdapter", __func__);
926 return VOS_STATUS_E_FAULT;
927 }
928 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
929 {
930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
931 /* return a cached value */
932 *rssi_value = pAdapter->rssi;
933 return VOS_STATUS_SUCCESS;
934 }
935
936 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
937 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
938
939 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
940 {
941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
942 /* return a cached value */
943 *rssi_value = 0;
944 return VOS_STATUS_SUCCESS;
945 }
946 init_completion(&context.completion);
947 context.pAdapter = pAdapter;
948 context.magic = RSSI_CONTEXT_MAGIC;
949
950 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
951 pHddStaCtx->conn_info.staId[ 0 ],
952 pHddStaCtx->conn_info.bssId,
953 &context, pHddCtx->pvosContext);
954 if (eHAL_STATUS_SUCCESS != hstatus)
955 {
956 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
957 __func__);
958 /* we'll returned a cached value below */
959 }
960 else
961 {
962 /* request was sent -- wait for the response */
963 lrc = wait_for_completion_interruptible_timeout(&context.completion,
964 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800965 if (lrc <= 0)
966 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800967 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800968 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800969 /* we'll now returned a cached value below */
970 }
971 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800972
973 /* either we never sent a request, we sent a request and received a
974 response or we sent a request and timed out. if we never sent a
975 request or if we sent a request and got a response, we want to
976 clear the magic out of paranoia. if we timed out there is a
977 race condition such that the callback function could be
978 executing at the same time we are. of primary concern is if the
979 callback function had already verified the "magic" but had not
980 yet set the completion variable when a timeout occurred. we
981 serialize these activities by invalidating the magic while
982 holding a shared spinlock which will cause us to block if the
983 callback is currently executing */
984 spin_lock(&hdd_context_lock);
985 context.magic = 0;
986 spin_unlock(&hdd_context_lock);
987
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800988 *rssi_value = pAdapter->rssi;
989
990 return VOS_STATUS_SUCCESS;
991}
992#endif
993
994
Jeff Johnson295189b2012-06-20 16:38:30 -0700995void hdd_StatisticsCB( void *pStats, void *pContext )
996{
997 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
998 hdd_stats_t *pStatsCache = NULL;
999 hdd_wext_state_t *pWextState;
1000 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1001
1002 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1003 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1004 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1005 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1006 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1007 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1008
1009 if (pAdapter!= NULL)
1010 pStatsCache = &pAdapter->hdd_stats;
1011
1012
1013 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1014 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1015 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1016 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1017 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1018 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1019
1020 if (pStatsCache!=NULL)
1021 {
1022 // and copy the stats into the cache we keep in the adapter instance structure
1023 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1024 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1025 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1026 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1027 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1028 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1029 }
1030
1031 if(pAdapter)
1032 {
1033 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1034 if(pWextState)
1035 {
1036 vos_status = vos_event_set(&pWextState->vosevent);
1037 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1038 {
1039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001040 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 return;
1042 }
1043 }
1044 }
1045}
1046
1047void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1048{
1049 v_CONTEXT_t pVosContext;
1050 hdd_context_t *pHddCtx;
1051 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1052#if 0
1053 hdd_wext_state_t *pWextState;
1054 v_U32_t roamId;
1055#endif
1056
1057 ENTER();
1058
1059 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1060
1061 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1062 if (NULL == pHddCtx)
1063 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001064 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 return;
1066 }
1067#if 0
1068 pWextState = pAdapter->pWextState;
1069#endif
1070
1071 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1072 {
1073 //TODO Verify is this is really used. If yes need to fix it.
1074 hdd_reconnect_all_adapters( pHddCtx );
1075#if 0
1076 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1077 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1078 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1079
1080 if(VOS_STATUS_SUCCESS == vosStatus)
1081 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1082 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1083
1084 sme_RoamConnect(halHandle,
1085 pAdapter->sessionId, &(pWextState->roamProfile),
1086 &roamId);
1087#endif
1088 }
1089
1090 EXIT();
1091
1092}
1093
1094void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1095{
1096 int i = 0;
1097 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1098
1099 /* clear WPA/RSN/WSC IE information in the profile */
1100 pWextState->roamProfile.nWPAReqIELength = 0;
1101 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1102 pWextState->roamProfile.nRSNReqIELength = 0;
1103 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1104
Chet Lanctot186b5732013-03-18 10:26:30 -07001105#ifdef FEATURE_WLAN_WAPI
1106 pWextState->roamProfile.nWAPIReqIELength = 0;
1107 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1108#endif
1109
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301112 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1114 pWextState->roamProfile.nAddIEAssocLength = 0;
1115
1116 pWextState->roamProfile.EncryptionType.numEntries = 1;
1117 pWextState->roamProfile.EncryptionType.encryptionType[0]
1118 = eCSR_ENCRYPT_TYPE_NONE;
1119
1120 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1121 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1122 = eCSR_ENCRYPT_TYPE_NONE;
1123
1124 pWextState->roamProfile.AuthType.numEntries = 1;
1125 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1126
Chet Lanctot186b5732013-03-18 10:26:30 -07001127#ifdef WLAN_FEATURE_11W
1128 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1129 pWextState->roamProfile.MFPRequired = 0;
1130 pWextState->roamProfile.MFPCapable = 0;
1131#endif
1132
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 pWextState->authKeyMgmt = 0;
1134
1135 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1136 {
1137 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1138 {
1139 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1140 }
1141 }
1142#ifdef FEATURE_WLAN_WAPI
1143 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1144 pAdapter->wapi_info.nWapiMode = 0;
1145#endif
1146
1147 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1148
1149}
1150
1151void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1152{
1153 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001155 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1156 {
1157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1158 "%s: Invalid pAdapter magic", __func__);
1159 }
1160 else
1161 {
1162 complete(&pAdapter->ula_complete);
1163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001164}
1165
1166VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1167{
1168 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001170 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001171
1172 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1173 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001174 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001175
1176 /*To avoid race condition between the set key and the last EAPOL
1177 packet, notify TL to finish upper layer authentication incase if the
1178 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001179 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001180
1181 if ( vos_status != VOS_STATUS_SUCCESS )
1182 {
1183 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1184 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1185 __LINE__, vos_status );
1186 return vos_status;
1187
1188 }
1189
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001190 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301192 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001193 {
1194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301195 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001196 /* we'll still fall through and return success since the
1197 * connection may still get established but is just taking
1198 * too long for us to wait */
1199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 }
1201 return VOS_STATUS_SUCCESS;
1202}
1203
1204v_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)
1205{
1206
1207 int left = ie_len;
1208 v_U8_t *ptr = ie;
1209 v_U8_t elem_id,elem_len;
1210 v_U8_t eid = 0xDD;
1211
1212 if ( NULL == ie || 0 == ie_len )
1213 return NULL;
1214
1215 while(left >= 2)
1216 {
1217 elem_id = ptr[0];
1218 elem_len = ptr[1];
1219 left -= 2;
1220 if(elem_len > left)
1221 {
1222 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001223 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 eid,elem_len,left);
1225 return NULL;
1226 }
1227 if (elem_id == eid)
1228 {
1229 if(memcmp( &ptr[2], oui, oui_size)==0)
1230 return ptr;
1231 }
1232
1233 left -= elem_len;
1234 ptr += (elem_len + 2);
1235 }
1236 return NULL;
1237}
1238
1239static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1240 union iwreq_data *wrqu, char *extra)
1241{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001242 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001243 /* Do nothing for now */
1244 return 0;
1245}
1246
1247static int iw_get_name(struct net_device *dev,
1248 struct iw_request_info *info,
1249 char *wrqu, char *extra)
1250{
1251
1252 ENTER();
1253 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1254 EXIT();
1255 return 0;
1256}
1257
1258static int iw_set_mode(struct net_device *dev,
1259 struct iw_request_info *info,
1260 union iwreq_data *wrqu, char *extra)
1261{
1262 hdd_wext_state_t *pWextState;
1263 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1264 tCsrRoamProfile *pRoamProfile;
1265 eCsrRoamBssType LastBSSType;
1266 eMib_dot11DesiredBssType connectedBssType;
1267 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001269
1270 ENTER();
1271
1272 if (NULL == pAdapter)
1273 {
1274 hddLog(VOS_TRACE_LEVEL_WARN,
1275 "%s: Invalid context, pAdapter", __func__);
1276 return 0;
1277 }
1278
1279 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1281 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 return 0;
1283 }
1284
1285 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1286 if (pWextState == NULL)
1287 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301288 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 return -EINVAL;
1290 }
1291
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 pRoamProfile = &pWextState->roamProfile;
1294 LastBSSType = pRoamProfile->BSSType;
1295
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301296 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001297
1298 switch (wrqu->mode)
1299 {
1300 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301301 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1303 // Set the phymode correctly for IBSS.
1304 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1305 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001306 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 break;
1309 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301310 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 break;
1314 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301315 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1317 break;
1318 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301319 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 return -EOPNOTSUPP;
1321 }
1322
1323 if ( LastBSSType != pRoamProfile->BSSType )
1324 {
1325 //the BSS mode changed
1326 // We need to issue disconnect if connected or in IBSS disconnect state
1327 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1328 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1329 {
1330 VOS_STATUS vosStatus;
1331 // need to issue a disconnect to CSR.
1332 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1333 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1334 pAdapter->sessionId,
1335 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1336 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301337 {
1338 long ret;
1339 ret = wait_for_completion_interruptible_timeout(
1340 &pAdapter->disconnect_comp_var,
1341 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1342 if (ret <= 0)
1343 hddLog(VOS_TRACE_LEVEL_ERROR,
1344 FL("failed wait on disconnect_comp_var %ld"), ret);
1345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 }
1347 }
1348
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 EXIT();
1350 return 0;
1351}
1352
1353
1354static int iw_get_mode(struct net_device *dev,
1355 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301356 union iwreq_data *wrqu,
1357 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001358{
1359
1360 hdd_wext_state_t *pWextState;
1361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1362
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301363 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001364
1365 if (NULL == pAdapter)
1366 {
1367 hddLog(VOS_TRACE_LEVEL_WARN,
1368 "%s: Invalid context, pAdapter", __func__);
1369 return 0;
1370 }
1371
1372 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1374 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 return 0;
1376 }
1377
1378 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1379 if (pWextState == NULL)
1380 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301381 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 return -EINVAL;
1383 }
1384
1385 switch (pWextState->roamProfile.BSSType)
1386 {
1387 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001388 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301389 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 break;
1391 case eCSR_BSS_TYPE_IBSS:
1392 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001393 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301394 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 break;
1396 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001397 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301398 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 break;
1400 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001401 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 break;
1403 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301404
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 return 0;
1406}
1407
1408static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1409 union iwreq_data *wrqu, char *extra)
1410{
1411 v_U32_t numChans = 0;
1412 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1413 v_U32_t indx = 0;
1414 v_U32_t status = 0;
1415
1416 hdd_wext_state_t *pWextState;
1417 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1418 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1419 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1420 tCsrRoamProfile * pRoamProfile;
1421 ENTER();
1422
1423 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1425 return status;
1426 }
1427
1428 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1429
1430 pRoamProfile = &pWextState->roamProfile;
1431
Arif Hussain6d2a3322013-11-17 19:50:10 -08001432 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
1434 /* Link is up then return cant set channel*/
1435 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1436 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1437 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001438 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 return -EOPNOTSUPP;
1440 }
1441
1442 /* Settings by Frequency as input */
1443 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1444 (wrqu->freq.m <= (tANI_U32)5.825e8))
1445 {
1446 tANI_U32 freq = wrqu->freq.m / 100000;
1447
1448 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1449 indx++;
1450 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1451 {
1452 return -EINVAL;
1453 }
1454 wrqu->freq.e = 0;
1455 wrqu->freq.m = freq_chan_map[indx].chan;
1456
1457 }
1458
1459 if (wrqu->freq.e == 0)
1460 {
1461 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1462 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1463 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001464 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001465 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1467 return -EINVAL;
1468 }
1469
1470 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1471
1472 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1473 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1475 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 return -EIO;
1477 }
1478
1479 for (indx = 0; indx < numChans; indx++) {
1480 if (wrqu->freq.m == validChan[indx]){
1481 break;
1482 }
1483 }
1484 }
1485 else{
1486
1487 return -EINVAL;
1488 }
1489
1490 if(indx >= numChans)
1491 {
1492 return -EINVAL;
1493 }
1494
1495 /* Set the Operational Channel */
1496 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1497 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1498 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1499
Arif Hussain6d2a3322013-11-17 19:50:10 -08001500 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001501
1502 EXIT();
1503
1504 return status;
1505}
1506
1507static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1508 struct iw_freq *fwrq, char *extra)
1509{
Jeff Johnsone7245742012-09-05 17:12:55 -07001510 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1512 tHalHandle hHal;
1513 hdd_wext_state_t *pWextState;
1514 tCsrRoamProfile * pRoamProfile;
1515 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1516
1517 ENTER();
1518
1519 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1521 return status;
1522 }
1523
1524 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1525 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1526
1527 pRoamProfile = &pWextState->roamProfile;
1528
1529 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1530 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001531 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 {
c_hpothub8245442013-11-20 23:41:09 +05301533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1534 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 return -EIO;
1536 }
1537 else
1538 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001539 status = hdd_wlan_get_freq(channel, &freq);
1540 if( TRUE == status )
1541 {
1542 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1543 * iwlist & iwconfig command shows frequency into proper
1544 * format (2.412 GHz instead of 246.2 MHz)*/
1545 fwrq->m = freq;
1546 fwrq->e = MHZ;
1547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001548 }
1549 }
1550 else
1551 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001552 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1553 * iwlist & iwconfig command shows frequency into proper
1554 * format (2.412 GHz instead of 246.2 MHz)*/
1555 fwrq->m = 0;
1556 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001558 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001559}
1560
1561static int iw_get_tx_power(struct net_device *dev,
1562 struct iw_request_info *info,
1563 union iwreq_data *wrqu, char *extra)
1564{
1565
1566 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1567 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1568 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1569
1570 if (pHddCtx->isLogpInProgress)
1571 {
1572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1573 "%s:LOGP in Progress. Ignore!!!",__func__);
1574 return -EBUSY;
1575 }
1576
1577 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1578 {
1579 wrqu->txpower.value = 0;
1580 return 0;
1581 }
1582 wlan_hdd_get_classAstats(pAdapter);
1583 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1584
1585 return 0;
1586}
1587
1588static int iw_set_tx_power(struct net_device *dev,
1589 struct iw_request_info *info,
1590 union iwreq_data *wrqu, char *extra)
1591{
1592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1593 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1594
1595 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1596 {
1597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1598 return 0;
1599 }
1600
1601 ENTER();
1602
1603 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1604 {
c_hpothub8245442013-11-20 23:41:09 +05301605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1606 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 return -EIO;
1608 }
1609
1610 EXIT();
1611
1612 return 0;
1613}
1614
1615static int iw_get_bitrate(struct net_device *dev,
1616 struct iw_request_info *info,
1617 union iwreq_data *wrqu, char *extra)
1618{
1619 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1620 eHalStatus status = eHAL_STATUS_SUCCESS;
1621 hdd_wext_state_t *pWextState;
1622 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1623 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1624
1625 ENTER();
1626
1627 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1629 return status;
1630 }
1631
1632 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1633 wrqu->bitrate.value = 0;
1634 }
1635 else {
1636 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1637 SME_SUMMARY_STATS |
1638 SME_GLOBAL_CLASSA_STATS |
1639 SME_GLOBAL_CLASSB_STATS |
1640 SME_GLOBAL_CLASSC_STATS |
1641 SME_GLOBAL_CLASSD_STATS |
1642 SME_PER_STA_STATS,
1643 hdd_StatisticsCB, 0, FALSE,
1644 pHddStaCtx->conn_info.staId[0], pAdapter );
1645
1646 if(eHAL_STATUS_SUCCESS != status)
1647 {
1648 hddLog(VOS_TRACE_LEVEL_ERROR,
1649 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001650 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 return status;
1652 }
1653
1654 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1655
1656 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1657
1658 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR,
1661 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001662 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 return VOS_STATUS_E_FAILURE;
1664 }
1665
1666 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1667 }
1668
1669 EXIT();
1670
1671 return vos_status;
1672}
1673/* ccm call back function */
1674
1675static int iw_set_bitrate(struct net_device *dev,
1676 struct iw_request_info *info,
1677 union iwreq_data *wrqu,
1678 char *extra)
1679{
1680 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1681 hdd_wext_state_t *pWextState;
1682 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1683 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1684 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1685 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1686 v_U32_t i, rate;
1687 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1688
1689 ENTER();
1690
1691 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1693 return 0;
1694 }
1695
1696 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1697
1698 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1699 {
1700 return -ENXIO ;
1701 }
1702
1703 rate = wrqu->bitrate.value;
1704
1705 if (rate == -1)
1706 {
1707 rate = WNI_CFG_FIXED_RATE_AUTO;
1708 valid_rate = TRUE;
1709 }
1710 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1711 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1712 {
1713 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1714 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1715 {
1716 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1717 WNI_CFG_SUPPORTED_RATES_11A,
1718 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1719 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1720 WNI_CFG_SUPPORTED_RATES_11B,
1721 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1722 {
1723 for (i = 0; i < (b_len + a_len); ++i)
1724 {
1725 /* supported rates returned is double the actual rate so we divide it by 2 */
1726 if ((supp_rates[i]&0x7F)/2 == rate)
1727 {
1728 valid_rate = TRUE;
1729 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1730 break;
1731 }
1732 }
1733 }
1734 }
1735 }
1736 if (valid_rate != TRUE)
1737 {
1738 return -EINVAL;
1739 }
1740 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1741 WNI_CFG_FIXED_RATE, rate,
1742 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1743 {
c_hpothub8245442013-11-20 23:41:09 +05301744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1745 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 return -EIO;
1747 }
1748 return 0;
1749}
1750
1751
1752static int iw_set_genie(struct net_device *dev,
1753 struct iw_request_info *info,
1754 union iwreq_data *wrqu,
1755 char *extra)
1756{
1757 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1758 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001759 u_int8_t *genie = NULL;
1760 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 v_U16_t remLen;
1762
1763 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1767 "%s:LOGP in Progress. Ignore!!!", __func__);
1768 return 0;
1769 }
1770
1771 if (!wrqu->data.length) {
1772 hdd_clearRoamProfileIe(pAdapter);
1773 EXIT();
1774 return 0;
1775 }
1776
1777 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1778 wrqu->data.length);
1779 if (NULL == base_genie)
1780 {
1781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1782 "mem_alloc_copy_from_user_helper fail");
1783 return -ENOMEM;
1784 }
1785
1786 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001787
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 remLen = wrqu->data.length;
1789
Arif Hussain6d2a3322013-11-17 19:50:10 -08001790 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001791
1792 /* clear any previous genIE before this call */
1793 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1794
1795 while (remLen >= 2)
1796 {
1797 v_U16_t eLen = 0;
1798 v_U8_t elementId;
1799 elementId = *genie++;
1800 eLen = *genie++;
1801 remLen -= 2;
1802
Arif Hussain6d2a3322013-11-17 19:50:10 -08001803 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 __func__, elementId, eLen);
1805
1806 switch ( elementId )
1807 {
1808 case IE_EID_VENDOR:
1809 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001810 {
1811 kfree(base_genie);
1812 return -EINVAL;
1813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001814
1815 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1816 {
1817 v_U16_t curGenIELen = pWextState->genIE.length;
1818 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1819 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1820
1821 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1822 {
1823 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001824 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001826 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 return -ENOMEM;
1828 }
1829 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1830 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1831 pWextState->genIE.length += eLen + 2;
1832 }
1833 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1834 {
1835 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1836 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1837 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1838 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1839 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1840 }
1841 else /* any vendorId except WPA IE should be accumulated to genIE */
1842 {
1843 v_U16_t curGenIELen = pWextState->genIE.length;
1844 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1845 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1846
1847 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1848 {
1849 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001850 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001852 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 return -ENOMEM;
1854 }
1855 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1856 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1857 pWextState->genIE.length += eLen + 2;
1858 }
1859 break;
1860 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001861 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001862 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1863 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1864 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1865 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1866 break;
1867
1868 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001869 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001870 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 return 0;
1872 }
1873 genie += eLen;
1874 remLen -= eLen;
1875 }
1876 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001877 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 return 0;
1879}
1880
1881static int iw_get_genie(struct net_device *dev,
1882 struct iw_request_info *info,
1883 union iwreq_data *wrqu,
1884 char *extra)
1885{
1886 hdd_wext_state_t *pWextState;
1887 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1888 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1889 eHalStatus status;
1890 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1891 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1892
1893 ENTER();
1894
1895 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1897 return 0;
1898 }
1899
1900
Arif Hussain6d2a3322013-11-17 19:50:10 -08001901 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001902
1903 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1904
1905 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1906 {
1907 return -ENXIO;
1908 }
1909
1910 // Return something ONLY if we are associated with an RSN or WPA network
1911 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1912 pWextState->roamProfile.negotiatedAuthType))
1913 {
1914 return -ENXIO;
1915 }
1916
1917 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1918 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1919 pAdapter->sessionId,
1920 &length,
1921 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001922 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1923 if (wrqu->data.length < length)
1924 {
1925 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1926 return -EFAULT;
1927 }
Arif Hussain9f05be02014-02-05 12:06:53 -08001928 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001929 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001930
Arif Hussain6d2a3322013-11-17 19:50:10 -08001931 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001932
1933 EXIT();
1934
1935 return 0;
1936}
1937
1938static int iw_get_encode(struct net_device *dev,
1939 struct iw_request_info *info,
1940 struct iw_point *dwrq, char *extra)
1941{
1942 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1943 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1944 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1945 int keyId;
1946 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1947 int i;
1948
1949 ENTER();
1950
1951 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1953 return 0;
1954 }
1955
1956 keyId = pRoamProfile->Keys.defaultIndex;
1957
1958 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1959 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001960 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 return -EINVAL;
1962 }
1963
1964 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1965 {
1966 dwrq->flags |= IW_ENCODE_ENABLED;
1967 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1968 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1969
1970 dwrq->flags |= (keyId + 1);
1971
1972 }
1973 else
1974 {
1975 dwrq->flags |= IW_ENCODE_DISABLED;
1976 }
1977
1978 for(i=0; i < MAX_WEP_KEYS; i++)
1979 {
1980 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
1981 {
1982 continue;
1983 }
1984 else
1985 {
1986 break;
1987 }
1988 }
1989
1990 if(MAX_WEP_KEYS == i)
1991 {
1992 dwrq->flags |= IW_ENCODE_NOKEY;
1993 }
1994
1995 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
1996
1997 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
1998 {
1999 dwrq->flags |= IW_ENCODE_OPEN;
2000 }
2001 else
2002 {
2003 dwrq->flags |= IW_ENCODE_RESTRICTED;
2004 }
2005 EXIT();
2006 return 0;
2007}
2008
2009#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2010#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2011
2012
2013/*
2014 * This function sends a single 'key' to LIM at all time.
2015 */
2016
2017static int iw_get_rts_threshold(struct net_device *dev,
2018 struct iw_request_info *info,
2019 union iwreq_data *wrqu, char *extra)
2020{
2021 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2022 v_U32_t status = 0;
2023
2024 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2025
2026 return status;
2027}
2028
2029static int iw_set_rts_threshold(struct net_device *dev,
2030 struct iw_request_info *info,
2031 union iwreq_data *wrqu, char *extra)
2032{
2033 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2034 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2035
2036 ENTER();
2037
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002038 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2039 {
2040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2041 "%s:LOGP in Progress. Ignore!!!", __func__);
2042 return -EAGAIN;
2043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2045 {
2046 return -EINVAL;
2047 }
2048
2049 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2050 {
c_hpothub8245442013-11-20 23:41:09 +05302051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2052 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 return -EIO;
2054 }
2055
2056 EXIT();
2057
2058 return 0;
2059}
2060
2061static int iw_get_frag_threshold(struct net_device *dev,
2062 struct iw_request_info *info,
2063 union iwreq_data *wrqu, char *extra)
2064{
2065 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2066 v_U32_t status = 0;
2067
2068 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2069
2070 return status;
2071}
2072
2073static int iw_set_frag_threshold(struct net_device *dev,
2074 struct iw_request_info *info,
2075 union iwreq_data *wrqu, char *extra)
2076{
2077 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2078 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2079
2080 ENTER();
2081
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002082 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2083 {
2084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2085 "%s:LOGP in Progress. Ignore!!!", __func__);
2086 return -EBUSY;
2087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2089 {
2090 return -EINVAL;
2091 }
2092
2093 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2094 {
c_hpothub8245442013-11-20 23:41:09 +05302095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2096 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 return -EIO;
2098 }
2099
2100 EXIT();
2101
2102 return 0;
2103}
2104
2105static int iw_get_power_mode(struct net_device *dev,
2106 struct iw_request_info *info,
2107 union iwreq_data *wrqu, char *extra)
2108{
2109 ENTER();
2110 return -EOPNOTSUPP;
2111}
2112
2113static int iw_set_power_mode(struct net_device *dev,
2114 struct iw_request_info *info,
2115 union iwreq_data *wrqu, char *extra)
2116{
2117 ENTER();
2118 return -EOPNOTSUPP;
2119}
2120
2121static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2122 union iwreq_data *wrqu, char *extra)
2123{
2124 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2125 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2126 struct iw_range *range = (struct iw_range *) extra;
2127
2128 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2129
2130 v_U32_t num_channels = sizeof(channels);
2131 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2132 v_U32_t a_len;
2133 v_U32_t b_len;
2134 v_U32_t active_phy_mode = 0;
2135 v_U8_t index = 0, i;
2136
2137 ENTER();
2138
2139 wrqu->data.length = sizeof(struct iw_range);
2140 memset(range, 0, sizeof(struct iw_range));
2141
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002142 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2143 {
2144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2145 "%s:LOGP in Progress. Ignore!!!", __func__);
2146 return -EBUSY;
2147 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002148
2149 /*Get the phy mode*/
2150 if (ccmCfgGetInt(hHal,
2151 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2152 {
2153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002154 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002155
2156 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2157 {
2158 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002159 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 if (ccmCfgGetStr(hHal,
2161 WNI_CFG_SUPPORTED_RATES_11A,
2162 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2163 {
2164 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2165 {
2166 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2167 }
2168 for (i = 0; i < a_len; i++)
2169 {
2170 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2171 }
2172 range->num_bitrates = a_len;
2173 }
2174 else
2175 {
2176 return -EIO;
2177 }
2178 }
2179 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2180 {
2181 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002182 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 if (ccmCfgGetStr(hHal,
2184 WNI_CFG_SUPPORTED_RATES_11B,
2185 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2186 {
2187 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2188 {
2189 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2190 }
2191 for (i = 0; i < b_len; i++)
2192 {
2193 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2194 }
2195 range->num_bitrates = b_len;
2196 }
2197 else
2198 {
2199 return -EIO;
2200 }
2201 }
2202 }
2203
2204 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2205 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2206 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2207
2208 range->encoding_size[0] = 5;
2209 range->encoding_size[1] = 13;
2210 range->num_encoding_sizes = 2;
2211 range->max_encoding_tokens = MAX_WEP_KEYS;
2212
2213 // we support through Wireless Extensions 22
2214 range->we_version_compiled = WIRELESS_EXT;
2215 range->we_version_source = 22;
2216
2217 /*Supported Channels and Frequencies*/
2218 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2219 {
c_hpothub8245442013-11-20 23:41:09 +05302220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2221 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 return -EIO;
2223 }
2224 if (num_channels > IW_MAX_FREQUENCIES)
2225 {
2226 num_channels = IW_MAX_FREQUENCIES;
2227 }
2228
2229 range->num_channels = num_channels;
2230 range->num_frequency = num_channels;
2231
2232 for (index=0; index < num_channels; index++)
2233 {
2234 v_U32_t frq_indx = 0;
2235
2236 range->freq[index].i = channels[index];
2237 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2238 {
2239 if(channels[index] == freq_chan_map[frq_indx].chan)
2240 {
2241 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2242 range->freq[index].e = 1;
2243 break;
2244 }
2245 frq_indx++;
2246 }
2247 }
2248
2249 /* Event capability (kernel + driver) */
2250 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2251 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2252 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2253 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2254
2255 /*Encryption capability*/
2256 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2257 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2258
2259 /* Txpower capability */
2260 range->txpower_capa = IW_TXPOW_MWATT;
2261
2262 /*Scanning capability*/
2263 #if WIRELESS_EXT >= 22
2264 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2265 #endif
2266
2267 EXIT();
2268 return 0;
2269}
2270
2271/* Callback function registered with PMC to know status of PMC request */
2272static void iw_power_callback_fn (void *pContext, eHalStatus status)
2273{
2274 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002275
2276 if (NULL == pContext)
2277 {
2278 hddLog(VOS_TRACE_LEVEL_ERROR,
2279 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002280 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 return;
2282 }
2283
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
Jeff Johnson72a40512013-12-19 10:14:15 -08002286 /* there is a race condition that exists between this callback
2287 function and the caller since the caller could time out either
2288 before or while this code is executing. we use a spinlock to
2289 serialize these actions */
2290 spin_lock(&hdd_context_lock);
2291
2292 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 {
2294 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002295 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002297 "%s: Invalid context, magic [%08x]",
2298 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002299
2300 if (ioctl_debug)
2301 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002302 pr_info("%s: Invalid context, magic [%08x]\n",
2303 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 }
2305 return;
2306 }
2307
Jeff Johnson72a40512013-12-19 10:14:15 -08002308 /* context is valid so caller is still waiting */
2309
2310 /* paranoia: invalidate the magic */
2311 pStatsContext->magic = 0;
2312
2313 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002315
2316 /* serialization is complete */
2317 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002318}
2319
2320/* Callback function for tx per hit */
2321void hdd_tx_per_hit_cb (void *pCallbackContext)
2322{
2323 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2324 unsigned char tx_fail[16];
2325 union iwreq_data wrqu;
2326
2327 if (NULL == pAdapter)
2328 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002329 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 return;
2331 }
2332 memset(&wrqu, 0, sizeof(wrqu));
2333 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2334 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2335}
2336
2337void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2338{
2339 struct statsContext *pStatsContext;
2340 tCsrGlobalClassAStatsInfo *pClassAStats;
2341 hdd_adapter_t *pAdapter;
2342
2343 if (ioctl_debug)
2344 {
2345 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002346 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 }
2348
2349 if ((NULL == pStats) || (NULL == pContext))
2350 {
2351 hddLog(VOS_TRACE_LEVEL_ERROR,
2352 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002353 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 return;
2355 }
2356
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 pClassAStats = pStats;
2358 pStatsContext = pContext;
2359 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002360
2361 /* there is a race condition that exists between this callback
2362 function and the caller since the caller could time out either
2363 before or while this code is executing. we use a spinlock to
2364 serialize these actions */
2365 spin_lock(&hdd_context_lock);
2366
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2368 {
2369 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002370 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 hddLog(VOS_TRACE_LEVEL_WARN,
2372 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002373 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 if (ioctl_debug)
2375 {
2376 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002377 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 }
2379 return;
2380 }
2381
Jeff Johnson72a40512013-12-19 10:14:15 -08002382 /* context is valid so caller is still waiting */
2383
2384 /* paranoia: invalidate the magic */
2385 pStatsContext->magic = 0;
2386
2387 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2389
Jeff Johnson72a40512013-12-19 10:14:15 -08002390 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002392
2393 /* serialization is complete */
2394 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002395}
2396
2397VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2398{
2399 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2400 eHalStatus hstatus;
2401 long lrc;
2402 struct statsContext context;
2403
2404 if (NULL == pAdapter)
2405 {
2406 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2407 return VOS_STATUS_E_FAULT;
2408 }
2409 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2410 {
2411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2412 return VOS_STATUS_SUCCESS;
2413 }
2414
2415 /* we are connected
2416 prepare our callback context */
2417 init_completion(&context.completion);
2418 context.pAdapter = pAdapter;
2419 context.magic = STATS_CONTEXT_MAGIC;
2420 /* query only for Class A statistics (which include link speed) */
2421 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2422 eCSR_HDD,
2423 SME_GLOBAL_CLASSA_STATS,
2424 hdd_GetClassA_statisticsCB,
2425 0, // not periodic
2426 FALSE, //non-cached results
2427 pHddStaCtx->conn_info.staId[0],
2428 &context);
2429 if (eHAL_STATUS_SUCCESS != hstatus)
2430 {
2431 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002432 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002433 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 /* we'll returned a cached value below */
2435 }
2436 else
2437 {
2438 /* request was sent -- wait for the response */
2439 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2440 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 if (lrc <= 0)
2442 {
2443 hddLog(VOS_TRACE_LEVEL_ERROR,
2444 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002445 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 }
2447 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002448
2449 /* either we never sent a request, we sent a request and received a
2450 response or we sent a request and timed out. if we never sent a
2451 request or if we sent a request and got a response, we want to
2452 clear the magic out of paranoia. if we timed out there is a
2453 race condition such that the callback function could be
2454 executing at the same time we are. of primary concern is if the
2455 callback function had already verified the "magic" but had not
2456 yet set the completion variable when a timeout occurred. we
2457 serialize these activities by invalidating the magic while
2458 holding a shared spinlock which will cause us to block if the
2459 callback is currently executing */
2460 spin_lock(&hdd_context_lock);
2461 context.magic = 0;
2462 spin_unlock(&hdd_context_lock);
2463
2464 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 return VOS_STATUS_SUCCESS;
2466}
2467
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002468static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2469{
2470 struct statsContext *pStatsContext;
2471 tCsrSummaryStatsInfo *pSummaryStats;
2472 tCsrGlobalClassAStatsInfo *pClassAStats;
2473 hdd_adapter_t *pAdapter;
2474
2475 if (ioctl_debug)
2476 {
2477 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002478 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002479 }
2480
2481 if ((NULL == pStats) || (NULL == pContext))
2482 {
2483 hddLog(VOS_TRACE_LEVEL_ERROR,
2484 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002485 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002486 return;
2487 }
2488
Jeff Johnson72a40512013-12-19 10:14:15 -08002489 /* there is a race condition that exists between this callback
2490 function and the caller since the caller could time out either
2491 before or while this code is executing. we use a spinlock to
2492 serialize these actions */
2493 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002494
2495 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2496 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2497 pStatsContext = pContext;
2498 pAdapter = pStatsContext->pAdapter;
2499 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2500 {
2501 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002502 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002503 hddLog(VOS_TRACE_LEVEL_WARN,
2504 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002505 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002506 if (ioctl_debug)
2507 {
2508 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002509 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002510 }
2511 return;
2512 }
2513
Jeff Johnson72a40512013-12-19 10:14:15 -08002514 /* context is valid so caller is still waiting */
2515
2516 /* paranoia: invalidate the magic */
2517 pStatsContext->magic = 0;
2518
2519 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002520 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2521 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2522
Jeff Johnson72a40512013-12-19 10:14:15 -08002523 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002524 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002525
2526 /* serialization is complete */
2527 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002528}
2529
2530VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2531{
2532 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2533 eHalStatus hstatus;
2534 long lrc;
2535 struct statsContext context;
2536
2537 if (NULL == pAdapter)
2538 {
2539 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2540 return VOS_STATUS_SUCCESS;
2541 }
2542
2543 /* we are connected
2544 prepare our callback context */
2545 init_completion(&context.completion);
2546 context.pAdapter = pAdapter;
2547 context.magic = STATS_CONTEXT_MAGIC;
2548
2549 /* query only for Summary & Class A statistics */
2550 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2551 eCSR_HDD,
2552 SME_SUMMARY_STATS |
2553 SME_GLOBAL_CLASSA_STATS,
2554 hdd_get_station_statisticsCB,
2555 0, // not periodic
2556 FALSE, //non-cached results
2557 pHddStaCtx->conn_info.staId[0],
2558 &context);
2559 if (eHAL_STATUS_SUCCESS != hstatus)
2560 {
2561 hddLog(VOS_TRACE_LEVEL_ERROR,
2562 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002563 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002564 /* we'll return with cached values */
2565 }
2566 else
2567 {
2568 /* request was sent -- wait for the response */
2569 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2570 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002571
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002572 if (lrc <= 0)
2573 {
2574 hddLog(VOS_TRACE_LEVEL_ERROR,
2575 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002576 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002577 }
2578 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002579
2580 /* either we never sent a request, we sent a request and received a
2581 response or we sent a request and timed out. if we never sent a
2582 request or if we sent a request and got a response, we want to
2583 clear the magic out of paranoia. if we timed out there is a
2584 race condition such that the callback function could be
2585 executing at the same time we are. of primary concern is if the
2586 callback function had already verified the "magic" but had not
2587 yet set the completion variable when a timeout occurred. we
2588 serialize these activities by invalidating the magic while
2589 holding a shared spinlock which will cause us to block if the
2590 callback is currently executing */
2591 spin_lock(&hdd_context_lock);
2592 context.magic = 0;
2593 spin_unlock(&hdd_context_lock);
2594
2595 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002596 return VOS_STATUS_SUCCESS;
2597}
2598
2599
Jeff Johnson295189b2012-06-20 16:38:30 -07002600/*
2601 * Support for the LINKSPEED private command
2602 * Per the WiFi framework the response must be of the form
2603 * "LinkSpeed xx"
2604 */
2605static int iw_get_linkspeed(struct net_device *dev,
2606 struct iw_request_info *info,
2607 union iwreq_data *wrqu, char *extra)
2608{
2609 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302610 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302612 int len = sizeof(v_U32_t) + 1;
2613 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302615 VOS_STATUS status;
2616 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002617
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302618 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2619
2620 valid = wlan_hdd_validate_context(pHddCtx);
2621
2622 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002623 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302624 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2625 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002626 }
2627
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2629 {
2630 /* we are not connected so we don't have a classAstats */
2631 link_speed = 0;
2632 }
2633 else
2634 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302635 status = wlan_hdd_get_classAstats(pAdapter);
2636
2637 if (!VOS_IS_STATUS_SUCCESS(status ))
2638 {
2639 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2640 return -EINVAL;
2641 }
2642
2643 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2644 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2645 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2646 &link_speed);
2647
2648 link_speed = link_speed / 10;
2649
2650 if (0 == link_speed)
2651 {
2652 /* The linkspeed returned by HAL is in units of 500kbps.
2653 * converting it to mbps.
2654 * This is required to support legacy firmware which does
2655 * not return link capacity.
2656 */
2657 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2658 }
2659
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 }
2661
2662 wrqu->data.length = len;
2663 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002664 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 if ((rc < 0) || (rc >= len))
2666 {
2667 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302668 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 return -EIO;
2670 }
2671
2672 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002673 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002674}
2675
2676
2677/*
2678 * Support for the RSSI & RSSI-APPROX private commands
2679 * Per the WiFi framework the response must be of the form
2680 * "<ssid> rssi <xx>"
2681 * unless we are not associated, in which case the response is
2682 * "OK"
2683 */
2684static int iw_get_rssi(struct net_device *dev,
2685 struct iw_request_info *info,
2686 union iwreq_data *wrqu, char *extra)
2687{
2688 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002689 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 int len = wrqu->data.length;
2691 v_S7_t s7Rssi = 0;
2692 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2693 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2694 VOS_STATUS vosStatus;
2695 int rc;
2696
2697 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2698 (0 == ssidlen) || (ssidlen >= len))
2699 {
2700 /* we are not connected or our SSID is too long
2701 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002702 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 }
2704 else
2705 {
2706 /* we are connected with a valid SSID
2707 so we can write the SSID into the return buffer
2708 (note that it is not NUL-terminated) */
2709 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2710
2711 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2712
2713 if (VOS_STATUS_SUCCESS == vosStatus)
2714 {
2715 /* append the rssi to the ssid in the format required by
2716 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002717 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 }
2719 else
2720 {
2721 rc = -1;
2722 }
2723 }
2724
2725 /* verify that we wrote a valid response */
2726 if ((rc < 0) || (rc >= len))
2727 {
2728 // encoding or length error?
2729 hddLog(VOS_TRACE_LEVEL_ERROR,
2730 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002731 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 return -EIO;
2733 }
2734
2735 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002736 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002737}
2738
2739/*
2740 * Support for SoftAP channel range private command
2741 */
2742static int iw_softap_set_channel_range( struct net_device *dev,
2743 int startChannel,
2744 int endChannel,
2745 int band)
2746{
Jeff Johnson43971f52012-07-17 12:26:56 -07002747 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 int ret = 0;
2749 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2750 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002751 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2752
Jeff Johnson295189b2012-06-20 16:38:30 -07002753
2754 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2755 if (VOS_STATUS_SUCCESS != status)
2756 {
2757 ret = -EINVAL;
2758 }
Yathish9f22e662012-12-10 14:21:35 -08002759 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 return ret;
2761}
2762
2763VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2764{
2765 struct statsContext context;
2766 eHalStatus status;
2767 hdd_context_t *pHddCtx;
2768
2769 if (NULL == pAdapter)
2770 {
2771 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2772 return VOS_STATUS_E_FAULT;
2773 }
2774
2775 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2776 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2777 init_completion(&context.completion);
2778
2779 context.pAdapter = pAdapter;
2780 context.magic = POWER_CONTEXT_MAGIC;
2781
2782 if (DRIVER_POWER_MODE_ACTIVE == mode)
2783 {
2784 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2785 "Full Power", __func__);
2786 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2787 iw_power_callback_fn, &context,
2788 eSME_FULL_PWR_NEEDED_BY_HDD);
2789 // Enter Full power command received from GUI this means we are disconnected
2790 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2791 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2792 if (eHAL_STATUS_PMC_PENDING == status)
2793 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002794 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 int lrc = wait_for_completion_interruptible_timeout(
2796 &context.completion,
2797 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002798
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 if (lrc <= 0)
2800 {
2801 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002802 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 }
2804 }
2805 }
2806 else if (DRIVER_POWER_MODE_AUTO == mode)
2807 {
2808 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2809 {
2810 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2811 __func__);
2812 // Enter BMPS command received from GUI this means DHCP is completed
2813 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2814 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2815 FALSE);
2816 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2817 iw_power_callback_fn, &context);
2818 if (eHAL_STATUS_PMC_PENDING == status)
2819 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002820 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 int lrc = wait_for_completion_interruptible_timeout(
2822 &context.completion,
2823 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 if (lrc <= 0)
2825 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002826 hddLog(VOS_TRACE_LEVEL_ERROR,
2827 "%s: SME %s while requesting BMPS",
2828 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 }
2830 }
2831 }
2832 else
2833 {
2834 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2835 "enabled in the cfg");
2836 }
2837 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002838
2839 /* either we never sent a request, we sent a request and received a
2840 response or we sent a request and timed out. if we never sent a
2841 request or if we sent a request and got a response, we want to
2842 clear the magic out of paranoia. if we timed out there is a
2843 race condition such that the callback function could be
2844 executing at the same time we are. of primary concern is if the
2845 callback function had already verified the "magic" but had not
2846 yet set the completion variable when a timeout occurred. we
2847 serialize these activities by invalidating the magic while
2848 holding a shared spinlock which will cause us to block if the
2849 callback is currently executing */
2850 spin_lock(&hdd_context_lock);
2851 context.magic = 0;
2852 spin_unlock(&hdd_context_lock);
2853
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 return VOS_STATUS_SUCCESS;
2855}
2856
2857VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2858 hdd_adapter_t *pAdapter)
2859{
2860 VOS_STATUS vos_Status;
2861
2862 if ((NULL == pAdapter) || (NULL == pHddCtx))
2863 {
2864 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2865 return VOS_STATUS_E_FAULT;
2866 }
2867
2868 /**Exit from Deep sleep or standby if we get the driver
2869 START cmd from android GUI
2870 */
2871 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2872 {
2873 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2874 "from Stand by",__func__);
2875 vos_Status = hdd_exit_standby(pHddCtx);
2876 }
2877 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2878 {
2879 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2880 "from deep sleep",__func__);
2881 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2882 }
2883 else
2884 {
2885 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2886 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2887 vos_Status = VOS_STATUS_SUCCESS;
2888 }
2889
2890 return vos_Status;
2891}
2892
2893VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2894{
2895 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2896
2897 if (NULL == pHddCtx)
2898 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302899 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 return VOS_STATUS_E_FAULT;
2901 }
2902
2903 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2904 {
2905 //Execute standby procedure.
2906 //Executing standby procedure will cause the STA to
2907 //disassociate first and then the chip will be put into standby.
2908 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2909 vos_Status = hdd_enter_standby(pHddCtx);
2910 }
2911 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2912 pHddCtx->cfg_ini->nEnableDriverStop)
2913 {
2914 //Execute deep sleep procedure
2915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002916 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 //Deep sleep not supported
2918 vos_Status = hdd_enter_standby(pHddCtx);
2919 }
2920 else
2921 {
2922 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2923 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2924 vos_Status = VOS_STATUS_SUCCESS;
2925 }
2926
2927 return vos_Status;
2928}
2929
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002930
2931void* wlan_hdd_change_country_code_callback(void *pAdapter)
2932{
2933
2934 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002935 complete(&call_back_pAdapter->change_country_code);
2936
2937 return NULL;
2938}
2939
Jeff Johnson295189b2012-06-20 16:38:30 -07002940static int iw_set_priv(struct net_device *dev,
2941 struct iw_request_info *info,
2942 union iwreq_data *wrqu, char *extra)
2943{
2944 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08002945 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 int cmd_len = wrqu->data.length;
2947 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08002948 int rc = 0;
2949 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2950
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2952
2953 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08002954 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2955 wrqu->data.length);
2956 if (NULL == cmd)
2957 {
2958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2959 "mem_alloc_copy_from_user_helper fail");
2960 return -ENOMEM;
2961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002962
2963 if (ioctl_debug)
2964 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002965 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 }
2967
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002968 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2969 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
2971 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08002972 if (ioctl_debug)
2973 {
2974 pr_info("%s: RESTART in progress\n", __func__);
2975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002976
Arif Hussain24bfa702014-01-22 13:51:30 -08002977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08002979 kfree(cmd);
2980 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 }
2982
Arif Hussain24bfa702014-01-22 13:51:30 -08002983 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 {
Arif Hussain24bfa702014-01-22 13:51:30 -08002985 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
2986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2987 "%s: Error in iw_set_scan!", __func__);
2988 rc = -EINVAL;
2989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 }
2991 else if( strcasecmp(cmd, "start") == 0 ) {
2992
Arif Hussain6d2a3322013-11-17 19:50:10 -08002993 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002995
Arif Hussain24bfa702014-01-22 13:51:30 -08002996 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
2997 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 {
2999 union iwreq_data wrqu;
3000 char buf[10];
3001
3002 memset(&wrqu, 0, sizeof(wrqu));
3003 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3004 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3005 }
3006 else
3007 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003008 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3009 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 }
3011 goto done;
3012 }
3013 else if( strcasecmp(cmd, "stop") == 0 )
3014 {
3015 union iwreq_data wrqu;
3016 char buf[10];
3017
Arif Hussain6d2a3322013-11-17 19:50:10 -08003018 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003019
3020 wlan_hdd_enter_lowpower(pHddCtx);
3021 memset(&wrqu, 0, sizeof(wrqu));
3022 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3023 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 goto done;
3025 }
3026 else if (strcasecmp(cmd, "macaddr") == 0)
3027 {
3028 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3029 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3030 }
3031 else if (strcasecmp(cmd, "scan-active") == 0)
3032 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003033 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 ret = snprintf(cmd, cmd_len, "OK");
3035 }
3036 else if (strcasecmp(cmd, "scan-passive") == 0)
3037 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003038 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 ret = snprintf(cmd, cmd_len, "OK");
3040 }
3041 else if( strcasecmp(cmd, "scan-mode") == 0 )
3042 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003043 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 }
3045 else if( strcasecmp(cmd, "linkspeed") == 0 )
3046 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003047 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 }
3049 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3050 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003051 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003052 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003053
3054 country_code = cmd + 8;
3055
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003056 init_completion(&pAdapter->change_country_code);
3057
Arif Hussain24bfa702014-01-22 13:51:30 -08003058 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003059 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 country_code,
3061 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303062 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303063 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303064 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003065
3066 /* Wait for completion */
3067 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3068 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3069
3070 if (lrc <= 0)
3071 {
3072 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003073 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003074 }
3075
Arif Hussain24bfa702014-01-22 13:51:30 -08003076 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003078 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003079 "%s: SME Change Country code fail", __func__);
3080 kfree(cmd);
3081 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 }
3083 }
3084 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3085 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003086 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 }
3088 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3089 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003090 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003091
Wilson Yang1be3e652013-10-09 15:18:31 -07003092 if (9 < cmd_len)
3093 {
3094 ptr = (char*)(cmd + 9);
3095
3096 }else{
3097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3098 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003099 kfree(cmd);
3100 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003101 }
3102
3103 if (1 != sscanf(ptr,"%d",&mode))
3104 {
3105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3106 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003107 kfree(cmd);
3108 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003109 }
3110
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 wlan_hdd_enter_bmps(pAdapter, mode);
3112 /*TODO:Set the power mode*/
3113 }
3114 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3115 v_U32_t pmc_state;
3116 v_U16_t value;
3117
3118 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3119 if(pmc_state == BMPS) {
3120 value = DRIVER_POWER_MODE_AUTO;
3121 }
3122 else {
3123 value = DRIVER_POWER_MODE_ACTIVE;
3124 }
3125 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3126 }
3127 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003128 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 /*TODO: set the btcoexmode*/
3130 }
3131 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3132
Arif Hussain6d2a3322013-11-17 19:50:10 -08003133 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 /*TODO: Return the btcoex status*/
3135 }
3136 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3137
Arif Hussain6d2a3322013-11-17 19:50:10 -08003138 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003139
3140 /*TODO: Enable Rx data Filter*/
3141 }
3142 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3143
Arif Hussain6d2a3322013-11-17 19:50:10 -08003144 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003145
3146 /*TODO: Disable Rx data Filter*/
3147 }
3148 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3149
Arif Hussain6d2a3322013-11-17 19:50:10 -08003150 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 /*TODO: rxfilter-statistics*/
3152 }
3153 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3154
Arif Hussain6d2a3322013-11-17 19:50:10 -08003155 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 /*TODO: rxfilter-add*/
3157 }
3158 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3159
Arif Hussain6d2a3322013-11-17 19:50:10 -08003160 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 /*TODO: rxfilter-remove*/
3162 }
3163#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003164 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3165 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3166 /*TODO: support pnosetup*/
3167 }
3168 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3169 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3170 /*TODO: support pnoforce*/
3171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3173
Arif Hussain6d2a3322013-11-17 19:50:10 -08003174 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003175 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3176 kfree(cmd);
3177 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 }
3179 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003180 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003181 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3182 kfree(cmd);
3183 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 }
3185#endif /*FEATURE_WLAN_SCAN_PNO*/
3186 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003187 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003188 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3189 kfree(cmd);
3190 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 }
3192 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3193 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003194 char *ptr;
3195
3196 if (18 < cmd_len)
3197 {
3198 ptr = (char*)(cmd + 18);
3199 }else{
3200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3201 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003202 kfree(cmd);
3203 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003204 }
3205
Jeff Johnson02797792013-10-26 19:17:13 -07003206 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003207 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3208 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3209 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3210 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3211 {
3212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3213 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003214 kfree(cmd);
3215 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003217
3218 // parameters checking
3219 // period has to be larger than 0
3220 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3221 {
3222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003223 kfree(cmd);
3224 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 }
3226
3227 // use default value 5 is the input is not reasonable. in unit of 10%
3228 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3229 {
3230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3231 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3232 }
3233
3234 // default is 5
3235 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3236 {
3237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3238 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3239 }
3240
Arif Hussain24bfa702014-01-22 13:51:30 -08003241 if (eHAL_STATUS_SUCCESS !=
3242 sme_SetTxPerTracking(pHddCtx->hHal,
3243 hdd_tx_per_hit_cb,
3244 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003246 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 }
3248 }
3249 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003250 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3251 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 }
3253done:
3254 /* many of the commands write information back into the command
3255 string using snprintf(). check the return value here in one
3256 place */
3257 if ((ret < 0) || (ret >= cmd_len))
3258 {
3259 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003260 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003262 else if (ret > 0)
3263 {
3264 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3265 {
3266 hddLog(VOS_TRACE_LEVEL_ERROR,
3267 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003268 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003269 return -EFAULT;
3270 }
3271 wrqu->data.length = ret;
3272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003273
3274 if (ioctl_debug)
3275 {
3276 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003277 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003279 kfree(cmd);
3280 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003281}
3282
3283static int iw_set_nick(struct net_device *dev,
3284 struct iw_request_info *info,
3285 union iwreq_data *wrqu, char *extra)
3286{
3287 ENTER();
3288 return 0;
3289}
3290
3291static int iw_get_nick(struct net_device *dev,
3292 struct iw_request_info *info,
3293 union iwreq_data *wrqu, char *extra)
3294{
3295 ENTER();
3296 return 0;
3297}
3298
3299static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3300{
3301 ENTER();
3302 return NULL;
3303}
3304
3305static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3306 union iwreq_data *wrqu,char *extra)
3307
3308{
3309 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3310 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3311 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3312 struct iw_point *encoderq = &(wrqu->encoding);
3313 v_U32_t keyId;
3314 v_U8_t key_length;
3315 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3316 v_BOOL_t fKeyPresent = 0;
3317 int i;
3318 eHalStatus status = eHAL_STATUS_SUCCESS;
3319
3320
3321 ENTER();
3322
3323 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3324 {
3325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3326 "%s:LOGP in Progress. Ignore!!!",__func__);
3327 return 0;
3328 }
3329
3330
3331 keyId = encoderq->flags & IW_ENCODE_INDEX;
3332
3333 if(keyId)
3334 {
3335 if(keyId > MAX_WEP_KEYS)
3336 {
3337 return -EINVAL;
3338 }
3339
3340 fKeyPresent = 1;
3341 keyId--;
3342 }
3343 else
3344 {
3345 fKeyPresent = 0;
3346 }
3347
3348
3349 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3350 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 if(!fKeyPresent) {
3353
3354 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3355
3356 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3357 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3358 }
3359 }
3360 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3361 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3362 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3363 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3364
3365 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3366 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3367
3368 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3369 {
3370 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3371 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003372 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303373 {
3374 long ret;
3375 ret = wait_for_completion_interruptible_timeout(
3376 &pAdapter->disconnect_comp_var,
3377 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3378 if (ret <= 0)
3379 hddLog(VOS_TRACE_LEVEL_ERROR,
3380 FL("failed wait on disconnect_comp_var %ld"), ret);
3381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 }
3383
3384 return status;
3385
3386 }
3387
3388 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3389 {
3390 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3391
3392 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3393
3394 }
3395
3396
3397 if(wrqu->data.length > 0)
3398 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003399 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003400
3401 key_length = wrqu->data.length;
3402
3403 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3404
3405 if(5 == key_length)
3406 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003407 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003408
3409 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3410 {
3411 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3412 }
3413 else
3414 {
3415 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3416 }
3417 }
3418 else if(13 == key_length)
3419 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003420 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003421
3422 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3423 {
3424 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3425 }
3426 else
3427 {
3428 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3429 }
3430 }
3431 else
3432 {
3433 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003434 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 return -EINVAL;
3436 }
3437
3438 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3439 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3440 pWextState->roamProfile.EncryptionType.numEntries = 1;
3441 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3442 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3443 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3444
3445 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3446 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3447 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3448 {
3449
3450 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3451
3452 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3453 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3454
3455 return status;
3456 }
3457 }
3458
3459 return 0;
3460}
3461
3462static int iw_get_encodeext(struct net_device *dev,
3463 struct iw_request_info *info,
3464 struct iw_point *dwrq,
3465 char *extra)
3466{
3467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3468 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3469 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3470 int keyId;
3471 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3472 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3473 int i;
3474
3475 ENTER();
3476
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003477 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3478 {
3479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3480 "%s:LOGP in Progress. Ignore!!!", __func__);
3481 return -EBUSY;
3482 }
3483
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 keyId = pRoamProfile->Keys.defaultIndex;
3485
3486 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3487 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003488 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 return -EINVAL;
3490 }
3491
3492 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3493 {
3494 dwrq->flags |= IW_ENCODE_ENABLED;
3495 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303496 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3497 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 }
3499 else
3500 {
3501 dwrq->flags |= IW_ENCODE_DISABLED;
3502 }
3503
3504 for(i=0; i < MAX_WEP_KEYS; i++)
3505 {
3506 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3507 {
3508 continue;
3509 }
3510 else
3511 {
3512 break;
3513 }
3514 }
3515
3516 if(MAX_WEP_KEYS == i)
3517 {
3518 dwrq->flags |= IW_ENCODE_NOKEY;
3519 }
3520 else
3521 {
3522 dwrq->flags |= IW_ENCODE_ENABLED;
3523 }
3524
3525 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3526
3527 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3528 {
3529 dwrq->flags |= IW_ENCODE_DISABLED;
3530 }
3531
3532 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3533
3534 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3535 {
3536 dwrq->flags |= IW_ENCODE_OPEN;
3537 }
3538 else
3539 {
3540 dwrq->flags |= IW_ENCODE_RESTRICTED;
3541 }
3542 EXIT();
3543 return 0;
3544
3545}
3546
3547static int iw_set_encodeext(struct net_device *dev,
3548 struct iw_request_info *info,
3549 union iwreq_data *wrqu, char *extra)
3550{
3551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3552 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3553 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3554 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3555
3556 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3557 v_U32_t status = 0;
3558
3559 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3560
3561 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3562
3563 int key_index;
3564 struct iw_point *encoding = &wrqu->encoding;
3565 tCsrRoamSetKey setKey;
3566 v_U32_t roamId= 0xFF;
3567 VOS_STATUS vos_status;
3568
3569 ENTER();
3570
3571 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3572 {
3573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3574 "%s:LOGP in Progress. Ignore!!!",__func__);
3575 return 0;
3576 }
3577
3578 key_index = encoding->flags & IW_ENCODE_INDEX;
3579
3580 if(key_index > 0) {
3581
3582 /*Convert from 1-based to 0-based keying*/
3583 key_index--;
3584 }
3585 if(!ext->key_len) {
3586
3587 /*Set the encrytion type to NONE*/
3588 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3589 return status;
3590 }
3591
3592 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3593 (IW_ENCODE_ALG_WEP == ext->alg))
3594 {
3595 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3596
Agarwal Ashish971c2882013-10-30 20:11:12 +05303597 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3598 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 return -EINVAL;
3600 }
3601 else {
3602 /*Static wep, update the roam profile with the keys */
3603 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3604 key_index < CSR_MAX_NUM_KEY) {
3605 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3606 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3607
3608 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3609 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3610
3611 }
3612 }
3613 return status;
3614 }
3615
3616 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3617
3618 setKey.keyId = key_index;
3619 setKey.keyLength = ext->key_len;
3620
3621 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3622 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3623 }
3624
3625 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3626 /*Key direction for group is RX only*/
3627 setKey.keyDirection = eSIR_RX_ONLY;
3628 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3629 }
3630 else {
3631
3632 setKey.keyDirection = eSIR_TX_RX;
3633 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3634 }
3635
3636 /*For supplicant pae role is zero*/
3637 setKey.paeRole = 0;
3638
3639 switch(ext->alg)
3640 {
3641 case IW_ENCODE_ALG_NONE:
3642 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3643 break;
3644
3645 case IW_ENCODE_ALG_WEP:
3646 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3647 break;
3648
3649 case IW_ENCODE_ALG_TKIP:
3650 {
3651 v_U8_t *pKey = &setKey.Key[0];
3652
3653 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3654
3655 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3656
3657 /*Supplicant sends the 32bytes key in this order
3658
3659 |--------------|----------|----------|
3660 | Tk1 |TX-MIC | RX Mic |
3661 |--------------|----------|----------|
3662 <---16bytes---><--8bytes--><--8bytes-->
3663
3664 */
3665 /*Sme expects the 32 bytes key to be in the below order
3666
3667 |--------------|----------|----------|
3668 | Tk1 |RX-MIC | TX Mic |
3669 |--------------|----------|----------|
3670 <---16bytes---><--8bytes--><--8bytes-->
3671 */
3672 /* Copy the Temporal Key 1 (TK1) */
3673 vos_mem_copy(pKey,ext->key,16);
3674
3675 /*Copy the rx mic first*/
3676 vos_mem_copy(&pKey[16],&ext->key[24],8);
3677
3678 /*Copy the tx mic */
3679 vos_mem_copy(&pKey[24],&ext->key[16],8);
3680
3681 }
3682 break;
3683
3684 case IW_ENCODE_ALG_CCMP:
3685 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3686 break;
3687
3688#ifdef FEATURE_WLAN_CCX
3689#define IW_ENCODE_ALG_KRK 6
3690 case IW_ENCODE_ALG_KRK:
3691 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3692 break;
3693#endif /* FEATURE_WLAN_CCX */
3694
3695 default:
3696 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3697 break;
3698 }
3699
3700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003701 ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d"),__func__,(int)ext->alg,(int)ext->key_len,setKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003702
3703#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303704 /* The supplicant may attempt to set the PTK once pre-authentication
3705 is done. Save the key in the UMAC and include it in the ADD
3706 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303708 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303710 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3711 "%s: Update PreAuth Key success", __func__);
3712 return 0;
3713 }
3714 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3715 {
3716 hddLog(VOS_TRACE_LEVEL_ERROR,
3717 "%s: Update PreAuth Key failed", __func__);
3718 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 }
3720#endif /* WLAN_FEATURE_VOWIFI_11R */
3721
3722 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3723
3724 vos_status = wlan_hdd_check_ula_done(pAdapter);
3725 if ( vos_status != VOS_STATUS_SUCCESS )
3726 {
3727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3728 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3729 __LINE__, vos_status );
3730
3731 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3732 }
3733
3734 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3735
3736 if ( halStatus != eHAL_STATUS_SUCCESS )
3737 {
3738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3739 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3740 __LINE__, halStatus );
3741
3742 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3743 }
3744
3745 return halStatus;
3746}
3747
3748static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3749 union iwreq_data *wrqu, char *extra)
3750{
3751 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3752 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3753
3754 ENTER();
3755
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003756 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3757 {
3758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3759 "%s:LOGP in Progress. Ignore!!!", __func__);
3760 return -EBUSY;
3761 }
3762
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3764 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3765
Arif Hussain6d2a3322013-11-17 19:50:10 -08003766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003767
3768 return -EINVAL;
3769 }
3770
3771 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3772
3773 if((wrqu->retry.flags & IW_RETRY_LONG))
3774 {
3775 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3776 {
c_hpothub8245442013-11-20 23:41:09 +05303777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3778 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 return -EIO;
3780 }
3781 }
3782 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3783 {
3784 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3785 {
c_hpothub8245442013-11-20 23:41:09 +05303786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3787 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 return -EIO;
3789 }
3790 }
3791 }
3792 else
3793 {
3794 return -EOPNOTSUPP;
3795 }
3796
Arif Hussain6d2a3322013-11-17 19:50:10 -08003797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003798
3799 EXIT();
3800
3801 return 0;
3802
3803}
3804
3805static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3806 union iwreq_data *wrqu, char *extra)
3807{
3808 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3809 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3810 v_U32_t retry = 0;
3811
3812 ENTER();
3813
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003814 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3815 {
3816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3817 "%s:LOGP in Progress. Ignore!!!", __func__);
3818 return -EBUSY;
3819 }
3820
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 if((wrqu->retry.flags & IW_RETRY_LONG))
3822 {
3823 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3824
3825 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3826 {
c_hpothub8245442013-11-20 23:41:09 +05303827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3828 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 return -EIO;
3830 }
3831
3832 wrqu->retry.value = retry;
3833 }
3834 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3835 {
3836 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3837
3838 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3839 {
c_hpothub8245442013-11-20 23:41:09 +05303840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3841 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 return -EIO;
3843 }
3844
3845 wrqu->retry.value = retry;
3846 }
3847 else {
3848 return -EOPNOTSUPP;
3849 }
3850
Arif Hussain6d2a3322013-11-17 19:50:10 -08003851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003852
3853 EXIT();
3854
3855 return 0;
3856}
3857
3858static int iw_set_mlme(struct net_device *dev,
3859 struct iw_request_info *info,
3860 union iwreq_data *wrqu,
3861 char *extra)
3862{
3863 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3864 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3865 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3866 eHalStatus status = eHAL_STATUS_SUCCESS;
3867
3868 ENTER();
3869
3870 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3871 {
3872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3873 "%s:LOGP in Progress. Ignore!!!",__func__);
3874 return 0;
3875 }
3876
3877 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3878 switch (mlme->cmd) {
3879 case IW_MLME_DISASSOC:
3880 case IW_MLME_DEAUTH:
3881
3882 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3883 {
3884 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3885
3886 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3887 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3888
3889 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3890 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3891
Jeff Johnson43971f52012-07-17 12:26:56 -07003892 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303893 {
3894 long ret;
3895 ret = wait_for_completion_interruptible_timeout(
3896 &pAdapter->disconnect_comp_var,
3897 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3898 if (ret <= 0)
3899 hddLog(VOS_TRACE_LEVEL_ERROR,
3900 FL("failed wait on disconnect_comp_var %ld"), ret);
3901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003903 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003904 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003905
3906 /* Resetting authKeyMgmt */
3907 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3908
3909 netif_tx_disable(dev);
3910 netif_carrier_off(dev);
3911
3912 }
3913 else
3914 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003915 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 }
3917 break;
3918 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003919 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 return -EINVAL;
3921 }//end of switch
3922
3923 EXIT();
3924
3925 return status;
3926
3927}
3928
3929/* set param sub-ioctls */
3930static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3931 union iwreq_data *wrqu, char *extra)
3932{
3933 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3934 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3935 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3936 int *value = (int *)extra;
3937 int sub_cmd = value[0];
3938 int set_value = value[1];
3939 int ret = 0; /* success */
3940 int enable_pbm, enable_mp;
3941#ifdef CONFIG_HAS_EARLYSUSPEND
3942 v_U8_t nEnableSuspendOld;
3943#endif
3944 INIT_COMPLETION(pWextState->completion_var);
3945
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003946 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3947 {
3948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3949 "%s:LOGP in Progress. Ignore!!!", __func__);
3950 return -EBUSY;
3951 }
3952
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 switch(sub_cmd)
3954 {
3955 case WE_SET_11D_STATE:
3956 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003957 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07003958 memset(&smeConfig, 0x00, sizeof(smeConfig));
3959
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3961
3962 sme_GetConfigParam(hHal,&smeConfig);
3963 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3964
Arif Hussain6d2a3322013-11-17 19:50:10 -08003965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07003966
3967 sme_UpdateConfig(hHal,&smeConfig);
3968 }
3969 else {
3970 return -EINVAL;
3971 }
3972 break;
3973 }
3974
3975 case WE_WOWL:
3976 {
3977 switch (set_value)
3978 {
3979 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003980 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 break;
3982 case 0x01:
3983 case 0x02:
3984 case 0x03:
3985 enable_mp = (set_value & 0x01) ? 1 : 0;
3986 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003987 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
3989 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
3990 break;
3991 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003992 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 ret = -EINVAL;
3994 break;
3995 }
3996
3997 break;
3998 }
3999 case WE_SET_POWER:
4000 {
4001 switch (set_value)
4002 {
4003 case 0: //Full Power
4004 {
4005 struct statsContext context;
4006 eHalStatus status;
4007
4008 init_completion(&context.completion);
4009
4010 context.pAdapter = pAdapter;
4011 context.magic = POWER_CONTEXT_MAGIC;
4012
4013 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4014 iw_power_callback_fn, &context,
4015 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004016 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 {
4018 int lrc = wait_for_completion_interruptible_timeout(
4019 &context.completion,
4020 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004021
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 if (lrc <= 0)
4023 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004024 hddLog(VOS_TRACE_LEVEL_ERROR,
4025 "%s: SME %s while requesting fullpower",
4026 __func__, (0 == lrc) ?
4027 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
4029 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004030 /* either we have a response or we timed out. if we timed
4031 out there is a race condition such that the callback
4032 function could be executing at the same time we are. of
4033 primary concern is if the callback function had already
4034 verified the "magic" but had not yet set the completion
4035 variable when a timeout occurred. we serialize these
4036 activities by invalidating the magic while holding a
4037 shared spinlock which will cause us to block if the
4038 callback is currently executing */
4039 spin_lock(&hdd_context_lock);
4040 context.magic = 0;
4041 spin_unlock(&hdd_context_lock);
4042
Arif Hussain6d2a3322013-11-17 19:50:10 -08004043 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 break;
4045 }
4046 case 1: //Enable BMPS
4047 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4048 break;
4049 case 2: //Disable BMPS
4050 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4051 break;
4052 case 3: //Request Bmps
4053 {
4054 struct statsContext context;
4055 eHalStatus status;
4056
4057 init_completion(&context.completion);
4058
4059 context.pAdapter = pAdapter;
4060 context.magic = POWER_CONTEXT_MAGIC;
4061
4062 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4063 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004064 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 {
4066 int lrc = wait_for_completion_interruptible_timeout(
4067 &context.completion,
4068 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 if (lrc <= 0)
4070 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004071 hddLog(VOS_TRACE_LEVEL_ERROR,
4072 "%s: SME %s while requesting BMPS",
4073 __func__, (0 == lrc) ? "timeout" :
4074 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 }
4076 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004077 /* either we have a response or we timed out. if we
4078 timed out there is a race condition such that the
4079 callback function could be executing at the same
4080 time we are. of primary concern is if the callback
4081 function had already verified the "magic" but had
4082 not yet set the completion variable when a timeout
4083 occurred. we serialize these activities by
4084 invalidating the magic while holding a shared
4085 spinlock which will cause us to block if the
4086 callback is currently executing */
4087 spin_lock(&hdd_context_lock);
4088 context.magic = 0;
4089 spin_unlock(&hdd_context_lock);
4090
Arif Hussain6d2a3322013-11-17 19:50:10 -08004091 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 break;
4093 }
4094 case 4: //Enable IMPS
4095 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4096 break;
4097 case 5: //Disable IMPS
4098 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4099 break;
4100 case 6: //Enable Standby
4101 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4102 break;
4103 case 7: //Disable Standby
4104 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4105 break;
4106 case 8: //Request Standby
4107#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004108#endif
4109 break;
4110 case 9: //Start Auto Bmps Timer
4111 sme_StartAutoBmpsTimer(hHal);
4112 break;
4113 case 10://Stop Auto BMPS Timer
4114 sme_StopAutoBmpsTimer(hHal);
4115 break;
4116#ifdef CONFIG_HAS_EARLYSUSPEND
4117 case 11://suspend to standby
4118#ifdef CONFIG_HAS_EARLYSUSPEND
4119 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4120 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4122#endif
4123 break;
4124 case 12://suspend to deep sleep
4125#ifdef CONFIG_HAS_EARLYSUSPEND
4126 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4127 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4129#endif
4130 break;
4131 case 13://resume from suspend
4132#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004133#endif
4134 break;
4135#endif
4136 case 14://reset wlan (power down/power up)
4137 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4138 break;
4139 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004140 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 ret = -EINVAL;
4142 break;
4143 }
4144 break;
4145 }
4146
4147 case WE_SET_MAX_ASSOC:
4148 {
4149 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4150 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4151 {
4152 ret = -EINVAL;
4153 }
4154 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4155 set_value, NULL, eANI_BOOLEAN_FALSE)
4156 != eHAL_STATUS_SUCCESS )
4157 {
c_hpothub8245442013-11-20 23:41:09 +05304158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4159 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 ret = -EIO;
4161 }
4162 break;
4163 }
4164
4165 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4166 {
4167 if( 0 == set_value )
4168 {
4169 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4170 }
4171 else if ( 1 == set_value )
4172 {
4173 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4174 }
4175 else
4176 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004177 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 ret = -EINVAL;
4179 }
4180 break;
4181 }
4182
4183 case WE_SET_DATA_INACTIVITY_TO:
4184 {
4185 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4186 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4187 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4188 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4189 set_value,
4190 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4191 {
4192 hddLog(LOGE,"Failure: Could not pass on "
4193 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004194 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 ret = -EINVAL;
4196 }
4197 break;
4198 }
4199 case WE_SET_MAX_TX_POWER:
4200 {
4201 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4202 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4203
4204 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4205 __func__, set_value);
4206 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4207 eHAL_STATUS_SUCCESS )
4208 {
4209 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4210 __func__);
4211 return -EIO;
4212 }
4213
4214 break;
4215 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004216 case WE_SET_MAX_TX_POWER_2_4:
4217 {
4218 hddLog(VOS_TRACE_LEVEL_INFO,
4219 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4220 __func__, set_value);
4221 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4222 eHAL_STATUS_SUCCESS)
4223 {
4224 hddLog(VOS_TRACE_LEVEL_ERROR,
4225 "%s: Setting maximum tx power failed for 2.4 GHz band",
4226 __func__);
4227 return -EIO;
4228 }
4229
4230 break;
4231 }
4232 case WE_SET_MAX_TX_POWER_5_0:
4233 {
4234 hddLog(VOS_TRACE_LEVEL_INFO,
4235 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4236 __func__, set_value);
4237 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4238 eHAL_STATUS_SUCCESS)
4239 {
4240 hddLog(VOS_TRACE_LEVEL_ERROR,
4241 "%s: Setting maximum tx power failed for 5.0 GHz band",
4242 __func__);
4243 return -EIO;
4244 }
4245
4246 break;
4247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 case WE_SET_HIGHER_DTIM_TRANSITION:
4249 {
4250 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4251 (set_value == eANI_BOOLEAN_TRUE)))
4252 {
4253 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4254 ret = -EINVAL;
4255 }
4256 else
4257 {
4258 if(pAdapter->higherDtimTransition != set_value)
4259 {
4260 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004261 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 }
4263 }
4264
4265 break;
4266 }
4267
4268 case WE_SET_TM_LEVEL:
4269 {
4270 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004271 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4273
4274 break;
4275 }
4276
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304277 case WE_ENABLE_STRICT_FCC_REG:
4278 {
4279 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4280 struct wiphy *wiphy = NULL;
4281 long lrc;
4282 int status;
4283
4284 wiphy = hddCtxt->wiphy;
4285 if(wiphy == NULL)
4286 {
4287 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4288 break;
4289 }
4290 init_completion(&hddCtxt->wiphy_channel_update_event);
4291
4292 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4293
4294 status = regulatory_hint(wiphy, "00");
4295 if(status < 0)
4296 {
4297 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4298 break;
4299 }
4300
4301 /* Wait for completion */
4302 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4303 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4304 if (lrc <= 0)
4305 {
4306 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4307 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4308 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4309 }
4310 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4311
4312 break;
4313 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004314 case WE_SET_DEBUG_LOG:
4315 {
4316 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4317 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4318 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4319 break;
4320 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304321
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 default:
4323 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004324 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 sub_cmd, set_value);
4326 break;
4327 }
4328 }
4329
4330 return ret;
4331}
4332
4333/* set param sub-ioctls */
4334static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4335 union iwreq_data *wrqu, char *extra)
4336{
4337 VOS_STATUS vstatus;
4338 int sub_cmd = wrqu->data.flags;
4339 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004340 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4342 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4343#ifdef WLAN_FEATURE_VOWIFI
4344 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4345#endif /* WLAN_FEATURE_VOWIFI */
4346
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004347 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4348 {
4349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4350 "%s:LOGP in Progress. Ignore!!!", __func__);
4351 return -EBUSY;
4352 }
4353
Arif Hussain0273cba2014-01-07 20:58:29 -08004354 /* ODD number is used for set, copy data using copy_from_user */
4355 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4356 wrqu->data.length);
4357 if (NULL == pBuffer)
4358 {
4359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4360 "mem_alloc_copy_from_user_helper fail");
4361 return -ENOMEM;
4362 }
4363
4364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4365 "%s: Received length %d", __func__, wrqu->data.length);
4366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4367 "%s: Received data %s", __func__, pBuffer);
4368
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 switch(sub_cmd)
4370 {
4371 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004373 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 break;
4375 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004377 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 break;
4379#if defined WLAN_FEATURE_VOWIFI
4380 case WE_NEIGHBOR_REPORT_REQUEST:
4381 {
4382 tRrmNeighborReq neighborReq;
4383 tRrmNeighborRspCallbackInfo callbackInfo;
4384
4385 if (pConfig->fRrmEnable)
4386 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4389 if( !neighborReq.no_ssid )
4390 {
4391 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004392 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 }
4394
4395 callbackInfo.neighborRspCallback = NULL;
4396 callbackInfo.neighborRspCallbackContext = NULL;
4397 callbackInfo.timeout = 5000; //5 seconds
4398 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4399 }
4400 else
4401 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004402 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 ret = -EINVAL;
4404 }
4405 }
4406 break;
4407#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 case WE_SET_AP_WPS_IE:
4409 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004410 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004413 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 if (VOS_STATUS_SUCCESS != vstatus)
4415 {
4416 ret = -EINVAL;
4417 }
4418 break;
4419 default:
4420 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004421 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 ret = -EINVAL;
4423 break;
4424 }
4425 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004426 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 return ret;
4428}
4429
4430/* get param sub-ioctls */
4431static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4432 union iwreq_data *wrqu, char *extra)
4433{
4434 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4435 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4436 int *value = (int *)extra;
4437 int ret = 0; /* success */
4438
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004439 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4440 {
4441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4442 "%s:LOGP in Progress. Ignore!!!", __func__);
4443 return -EBUSY;
4444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004445
4446 switch (value[0])
4447 {
4448 case WE_GET_11D_STATE:
4449 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004450 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304452
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4454
Arif Hussain6d2a3322013-11-17 19:50:10 -08004455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004456
4457 break;
4458 }
4459
4460 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 break;
4463
4464 case WE_PMC_STATE:
4465 {
4466 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 break;
4469 }
4470 case WE_GET_WLAN_DBG:
4471 {
4472 vos_trace_display();
4473 *value = 0;
4474 break;
4475 }
4476 case WE_MODULE_DOWN_IND:
4477 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4480#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4483#endif
4484 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4485
4486 *value = 0;
4487 break;
4488 }
4489 case WE_GET_MAX_ASSOC:
4490 {
4491 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4492 {
c_hpothub8245442013-11-20 23:41:09 +05304493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4494 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 ret = -EIO;
4496 }
4497 break;
4498 }
4499
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 case WE_GET_WDI_DBG:
4501 {
4502 wpalTraceDisplay();
4503 *value = 0;
4504 break;
4505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004506
4507 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4508 {
4509 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4510 break;
4511 }
4512 case WE_GET_CONCURRENCY_MODE:
4513 {
4514 *value = hdd_get_concurrency_mode ( );
4515
Arif Hussain6d2a3322013-11-17 19:50:10 -08004516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 break;
4518 }
4519
4520 default:
4521 {
4522 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4523 break;
4524 }
4525 }
4526
4527 return ret;
4528}
4529
4530/* set param sub-ioctls */
4531int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4532 union iwreq_data *wrqu, char *extra)
4533{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004534 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 int *value = (int *)extra;
4536 int sub_cmd = value[0];
4537 int ret = 0;
4538
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004539 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4540 {
4541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4542 "%s:LOGP in Progress. Ignore!!!", __func__);
4543 return -EBUSY;
4544 }
4545
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 switch(sub_cmd)
4547 {
4548 case WE_SET_WLAN_DBG:
4549 {
4550 vos_trace_setValue( value[1], value[2], value[3]);
4551 break;
4552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 case WE_SET_WDI_DBG:
4554 {
4555 wpalTraceSetLevel( value[1], value[2], value[3]);
4556 break;
4557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 case WE_SET_SAP_CHANNELS:
4559 {
4560 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4561 break;
4562 }
4563
4564 default:
4565 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004566 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 break;
4568 }
4569 }
4570 return ret;
4571}
4572
4573static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4574 union iwreq_data *wrqu, char *extra)
4575{
4576 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4577 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004578#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004579 hdd_wext_state_t *pWextState;
4580#endif
4581
4582 if (pAdapter == NULL)
4583 {
4584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4585 "%s: pAdapter is NULL!", __func__);
4586 return -EINVAL;
4587 }
4588#ifdef WLAN_FEATURE_11W
4589 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004590#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004591
Yue Ma3ede6052013-08-29 00:33:26 -07004592 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4593 {
4594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4595 "%s: HDD Context is NULL!", __func__);
4596
4597 return -EINVAL;
4598 }
4599
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004600 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4601 {
4602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4603 "%s:LOGP in Progress. Ignore!!!", __func__);
4604 return -EBUSY;
4605 }
4606
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 switch(sub_cmd)
4608 {
4609 case WE_WLAN_VERSION:
4610 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004611 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 break;
4613 }
4614
4615 case WE_GET_STATS:
4616 {
4617 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4618 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4619 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4620
4621 snprintf(extra, WE_MAX_STR_LEN,
4622 "\nTransmit"
4623 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4624 "\n dropped BK %u, BE %u, VI %u, VO %u"
4625 "\n classified BK %u, BE %u, VI %u, VO %u"
4626 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4627 "\n queued BK %u, BE %u, VI %u, VO %u"
4628 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004629 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 "\n fetched BK %u, BE %u, VI %u, VO %u"
4631 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4632 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004633 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 "\n flushed BK %u, BE %u, VI %u, VO %u"
4635 "\n\nReceive"
4636 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4637 "\n\nResetsStats"
4638 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4639 "\n",
4640 pStats->txXmitCalled,
4641 pStats->txXmitDropped,
4642 pStats->txXmitBackPressured,
4643 pStats->txXmitQueued,
4644
4645 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4646 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4647 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4648 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4649
4650 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4651 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4652 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4653 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4654
4655 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4656 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4657 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4658 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4659
4660 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4661 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4662 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4663 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4664
4665 pStats->txFetched,
4666 pStats->txFetchEmpty,
4667 pStats->txFetchLowResources,
4668 pStats->txFetchDequeueError,
4669
4670 pStats->txFetchDequeued,
4671 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004672 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 pStats->txCompleted,
4674 pStats->txFlushed,
4675
4676 pStats->txFetchedAC[WLANTL_AC_BK],
4677 pStats->txFetchedAC[WLANTL_AC_BE],
4678 pStats->txFetchedAC[WLANTL_AC_VI],
4679 pStats->txFetchedAC[WLANTL_AC_VO],
4680
4681 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4682 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4683 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4684 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4685
4686 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4687 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4688 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4689 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4690
Ravi Joshi41914632013-10-21 23:02:21 -07004691 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4692 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4693 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4694 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4695
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 pStats->txFlushedAC[WLANTL_AC_BK],
4697 pStats->txFlushedAC[WLANTL_AC_BE],
4698 pStats->txFlushedAC[WLANTL_AC_VI],
4699 pStats->txFlushedAC[WLANTL_AC_VO],
4700
4701 pStats->rxChains,
4702 pStats->rxPackets,
4703 pStats->rxDropped,
4704 pStats->rxDelivered,
4705 pStats->rxRefused,
4706
4707 pResetStats->totalLogpResets,
4708 pResetStats->totalCMD53Failures,
4709 pResetStats->totalMutexReadFailures,
4710 pResetStats->totalMIFErrorFailures,
4711 pResetStats->totalFWHearbeatFailures,
4712 pResetStats->totalUnknownExceptions
4713 );
4714 wrqu->data.length = strlen(extra)+1;
4715 break;
4716 }
4717
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304718/* The case prints the current state of the HDD, SME, CSR, PE, TL
4719 *it can be extended for WDI Global State as well.
4720 *And currently it only checks P2P_CLIENT adapter.
4721 *P2P_DEVICE and P2P_GO have not been added as of now.
4722*/
4723 case WE_GET_STATES:
4724 {
4725 int buf = 0, len = 0;
4726 int adapter_num = 0;
4727 int count = 0, check = 1;
4728
4729 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004730 tHalHandle hHal = NULL;
4731 tpAniSirGlobal pMac = NULL;
4732 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304733
4734 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4735 hdd_adapter_t *useAdapter = NULL;
4736
4737 /* Print wlan0 or p2p0 states based on the adapter_num
4738 *by using the correct adapter
4739 */
4740 while ( adapter_num < 2 )
4741 {
4742 if ( WLAN_ADAPTER == adapter_num )
4743 {
4744 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004745 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304746 "\n\n wlan0 States:-");
4747 len += buf;
4748 }
4749 else if ( P2P_ADAPTER == adapter_num )
4750 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004751 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304752 "\n\n p2p0 States:-");
4753 len += buf;
4754
4755 if( !pHddCtx )
4756 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004757 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304758 "\n pHddCtx is NULL");
4759 len += buf;
4760 break;
4761 }
4762
4763 /*Printing p2p0 states only in the case when the device is
4764 configured as a p2p_client*/
4765 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4766 if ( !useAdapter )
4767 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004768 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304769 "\n Device not configured as P2P_CLIENT.");
4770 len += buf;
4771 break;
4772 }
4773 }
4774
4775 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004776 if (!hHal) {
4777 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4778 "\n pMac is NULL");
4779 len += buf;
4780 break;
4781 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304782 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004783 if (!pMac) {
4784 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4785 "\n pMac is NULL");
4786 len += buf;
4787 break;
4788 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304789 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4790 if( !pHddStaCtx )
4791 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004792 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304793 "\n pHddStaCtx is NULL");
4794 len += buf;
4795 break;
4796 }
4797
4798 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4799
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004800 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304801 "\n HDD Conn State - %s "
4802 "\n \n SME State:"
4803 "\n Neighbour Roam State - %s"
4804 "\n CSR State - %s"
4805 "\n CSR Substate - %s"
4806 "\n \n TL STA %d State: %s",
4807 macTraceGetHDDWlanConnState(
4808 pHddStaCtx->conn_info.connState),
4809 macTraceGetNeighbourRoamState(
4810 pMac->roam.neighborRoamInfo.neighborRoamState),
4811 macTraceGetcsrRoamState(
4812 pMac->roam.curState[useAdapter->sessionId]),
4813 macTraceGetcsrRoamSubState(
4814 pMac->roam.curSubState[useAdapter->sessionId]),
4815 pHddStaCtx->conn_info.staId[0],
4816 macTraceGetTLState(tlState)
4817 );
4818 len += buf;
4819 adapter_num++;
4820 }
4821
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004822 if (pMac) {
4823 /* Printing Lim State starting with global lim states */
4824 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4825 "\n \n LIM STATES:-"
4826 "\n Global Sme State - %s "\
4827 "\n Global mlm State - %s "\
4828 "\n",
4829 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4830 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4831 );
4832 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304833
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004834 /*printing the PE Sme and Mlm states for valid lim sessions*/
4835 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304836 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004837 if ( pMac->lim.gpSession[count].valid )
4838 {
4839 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4840 "\n Lim Valid Session %d:-"
4841 "\n PE Sme State - %s "
4842 "\n PE Mlm State - %s "
4843 "\n",
4844 check,
4845 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4846 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4847 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304848
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004849 len += buf;
4850 check++;
4851 }
4852 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304853 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304854 }
4855
4856 wrqu->data.length = strlen(extra)+1;
4857 break;
4858 }
4859
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 case WE_GET_CFG:
4861 {
4862 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4863 wrqu->data.length = strlen(extra)+1;
4864 break;
4865 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004866#ifdef WLAN_FEATURE_11AC
4867 case WE_GET_RSSI:
4868 {
4869 v_S7_t s7Rssi = 0;
4870 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4871 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4872 wrqu->data.length = strlen(extra)+1;
4873 break;
4874 }
4875#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304876
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004877#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4878 case WE_GET_ROAM_RSSI:
4879 {
4880 v_S7_t s7Rssi = 0;
4881 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4882 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4883 wrqu->data.length = strlen(extra)+1;
4884 break;
4885 }
4886#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 case WE_GET_WMM_STATUS:
4888 {
4889 snprintf(extra, WE_MAX_STR_LEN,
4890 "\nDir: 0=up, 1=down, 3=both\n"
4891 "|------------------------|\n"
4892 "|AC | ACM |Admitted| Dir |\n"
4893 "|------------------------|\n"
4894 "|VO | %d | %3s | %d |\n"
4895 "|VI | %d | %3s | %d |\n"
4896 "|BE | %d | %3s | %d |\n"
4897 "|BK | %d | %3s | %d |\n"
4898 "|------------------------|\n",
4899 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4900 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4901 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4902 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4903 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4904 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4905 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4906 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4907 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4908 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4909 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4910 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4911
Jeff Johnsone7245742012-09-05 17:12:55 -07004912
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 wrqu->data.length = strlen(extra)+1;
4914 break;
4915 }
4916 case WE_GET_CHANNEL_LIST:
4917 {
4918 VOS_STATUS status;
4919 v_U8_t i, len;
4920 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004921
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 tChannelListInfo channel_list;
4923
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004924 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004926 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004928 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 return -EINVAL;
4930 }
4931 buf = extra;
4932
4933 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004934 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4935 * needed = 5 * number of channels. Check ifsufficient
4936 * buffer is available and then proceed to fill the buffer.
4937 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4939 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004940 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004941 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004942 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 return -EINVAL;
4944 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004945 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4946 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 for(i = 0 ; i < channel_list.num_channels; i++)
4948 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004949 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 }
4952 wrqu->data.length = strlen(extra)+1;
4953
4954 break;
4955 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004956#ifdef FEATURE_WLAN_TDLS
4957 case WE_GET_TDLS_PEERS:
4958 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004959 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004960 break;
4961 }
4962#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004963#ifdef WLAN_FEATURE_11W
4964 case WE_GET_11W_INFO:
4965 {
4966 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4967
4968 snprintf(extra, WE_MAX_STR_LEN,
4969 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4970 "\n Number of Unprotected Disassocs %d"
4971 "\n Number of Unprotected Deauths %d",
4972 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4973 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4974 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4975 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4976 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
4977
4978 wrqu->data.length = strlen(extra)+1;
4979 break;
4980 }
4981#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304982 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004984 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 break;
4986 }
4987 }
4988
4989 return 0;
4990}
4991
4992/* action sub-ioctls */
4993static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
4994 union iwreq_data *wrqu, char *extra)
4995{
4996 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4997 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004998 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07004999
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005000 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5001 {
5002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5003 "%s:LOGP in Progress. Ignore!!!", __func__);
5004 return -EBUSY;
5005 }
5006
Jeff Johnson295189b2012-06-20 16:38:30 -07005007 switch (sub_cmd)
5008 {
5009 case WE_CLEAR_STATS:
5010 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5013 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5014 break;
5015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 case WE_INIT_AP:
5017 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305018 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5019
5020 /* As Soft AP mode might been changed to STA already with
5021 * killing of Hostapd, need to find the adpater by name
5022 * rather than mode */
5023 hdd_adapter_t* pAdapter_to_stop =
5024 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5025 if( pAdapter_to_stop )
5026 {
5027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5028 "Adapter with name softap.0 already "
5029 "exist, ignoring the request.\nRemove the "
5030 "adapter and try again\n");
5031 break;
5032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 pr_info("Init AP trigger\n");
5034 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5035 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5036 break;
5037 }
5038 case WE_STOP_AP:
5039 {
5040 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5041 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5042 * this is a dead code and need to find the adpater by name rather than mode */
5043 hdd_adapter_t* pAdapter_to_stop =
5044 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5045 if( pAdapter_to_stop )
5046 {
5047 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5048
5049 pr_info("Stopping AP mode\n");
5050
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305051 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5052 {
5053 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5054 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5055 }
5056
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 /*Make sure that pAdapter cleaned properly*/
5058 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5059 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5060 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5061
5062 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5063 pAdapter_to_stop->macAddressCurrent.bytes);
5064 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5065 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305066
5067 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5068 {
5069 /* put the device back into BMPS */
5070 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 }
5073 else
5074 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005075 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 }
5077
5078 break;
5079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005080#ifdef WLAN_BTAMP_FEATURE
5081 case WE_ENABLE_AMP:
5082 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 WLANBAP_RegisterWithHCI(pAdapter);
5085 break;
5086 }
5087 case WE_DISABLE_AMP:
5088 {
5089 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5090 VOS_STATUS status;
5091
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005093
5094 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5095 status = WLANBAP_StopAmp();
5096 if(VOS_STATUS_SUCCESS != status )
5097 {
5098 pHddCtx->isAmpAllowed = VOS_TRUE;
5099 hddLog(VOS_TRACE_LEVEL_FATAL,
5100 "%s: Failed to stop AMP", __func__);
5101 }
5102 else
5103 {
5104 //a state m/c implementation in PAL is TBD to avoid this delay
5105 msleep(500);
5106 pHddCtx->isAmpAllowed = VOS_FALSE;
5107 WLANBAP_DeregisterFromHCI();
5108 }
5109
5110 break;
5111 }
5112#endif
5113
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005114 case WE_ENABLE_DXE_STALL_DETECT:
5115 {
schang6295e542013-03-12 15:31:23 -07005116 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5117 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005118 break;
5119 }
5120 case WE_DISPLAY_DXE_SNAP_SHOT:
5121 {
schang6295e542013-03-12 15:31:23 -07005122 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5123 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005124 break;
5125 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305126 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5127 {
5128 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5129 hdd_wmm_tx_snapshot(pAdapter);
5130 WLANTL_TLDebugMessage(VOS_TRUE);
5131 break;
5132 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07005133 case WE_SET_REASSOC_TRIGGER:
5134 {
5135 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5136 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5137 v_U32_t roamId = 0;
5138 tCsrRoamModifyProfileFields modProfileFields;
5139 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5140 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5141 return 0;
5142 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305143
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305144 case WE_STOP_OBSS_SCAN:
5145 {
5146 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5147 2.OBSS scan is stopped by Firmware during the disassociation
5148 3.OBSS stop comamnd is added for debugging purpose*/
5149 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5150 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005151
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305152 if (pAdapter == NULL)
5153 {
5154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5155 " pAdapter is NULL ");
5156 }
5157 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5158 if (pMac == NULL)
5159 {
5160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5161 " pMac is NULL ");
5162 }
5163 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5164 }
5165 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 default:
5167 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005168 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 break;
5170 }
5171 }
5172
5173 return ret;
5174}
5175
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305176void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5177{
5178 /*
5179 * Function to display HDD WMM information
5180 * for Tx Queues.
5181 * Prints globala as well as per client depending
5182 * whether the clients are registered or not.
5183 */
5184 int i = 0, j = 0;
5185 for ( i=0; i< NUM_TX_QUEUES; i++)
5186 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305187 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005188 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305189 i, pAdapter->wmm_tx_queue[i].count,
5190 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305191 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305192 }
5193
5194 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5195 {
5196 if(pAdapter->aStaInfo[i].isUsed)
5197 {
5198 hddLog(LOGE, "******STAIndex: %d*********", i);
5199 for ( j=0; j< NUM_TX_QUEUES; j++)
5200 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305201 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005202 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305203 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5204 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5205 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305206 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305207 }
5208 }
5209 }
5210
5211}
Jeff Johnson295189b2012-06-20 16:38:30 -07005212int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5213 union iwreq_data *wrqu, char *extra)
5214{
5215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5216 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5217 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 int apps_args[MAX_VAR_ARGS] = {0};
5219 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005220 hdd_station_ctx_t *pStaCtx = NULL ;
5221 hdd_ap_ctx_t *pAPCtx = NULL;
5222 int cmd = 0;
5223 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005224
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005225 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005226
5227 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5228 {
5229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5230 "%s:LOGP in Progress. Ignore!!!", __func__);
5231 return -EBUSY;
5232 }
5233
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 if (num_args > MAX_VAR_ARGS)
5235 {
5236 num_args = MAX_VAR_ARGS;
5237 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005238
5239 /* ODD number is used for set, copy data using copy_from_user */
5240 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5241 {
5242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5243 "%s: failed to copy data to user buffer", __func__);
5244 return -EFAULT;
5245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005246
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005247 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5248 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5249 {
5250 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5251 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5252 {
5253 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5254 staId = pStaCtx->conn_info.staId[0];
5255 }
5256 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5257 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5258 {
5259 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5260 staId = pAPCtx->uBCStaId;
5261 }
5262 else
5263 {
5264 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5265 return 0;
5266 }
5267 }
5268
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 switch (sub_cmd)
5270 {
5271 case WE_LOG_DUMP_CMD:
5272 {
5273 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005274 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 apps_args[3], apps_args[4]);
5276
5277 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5278 apps_args[3], apps_args[4]);
5279
5280 }
5281 break;
5282
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 case WE_P2P_NOA_CMD:
5284 {
5285 p2p_app_setP2pPs_t p2pNoA;
5286
5287 p2pNoA.opp_ps = apps_args[0];
5288 p2pNoA.ctWindow = apps_args[1];
5289 p2pNoA.duration = apps_args[2];
5290 p2pNoA.interval = apps_args[3];
5291 p2pNoA.count = apps_args[4];
5292 p2pNoA.single_noa_duration = apps_args[5];
5293 p2pNoA.psSelection = apps_args[6];
5294
5295 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5296 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005297 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5299
5300 hdd_setP2pPs(dev, &p2pNoA);
5301
5302 }
5303 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005304
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305305 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5306 {
5307 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5308 __func__, apps_args[0], apps_args[1]);
5309 vosTraceEnable(apps_args[0], apps_args[1]);
5310 }
5311 break;
5312
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005313 case WE_MTRACE_DUMP_CMD:
5314 {
5315 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5316 "bitmask_of_module %d ",
5317 __func__, apps_args[0], apps_args[1], apps_args[2],
5318 apps_args[3]);
5319 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5320 apps_args[2], apps_args[3]);
5321
5322 }
5323 break;
5324
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005325 case WE_MCC_CONFIG_CREDENTIAL :
5326 {
5327 cmd = 287; //Command should be updated if there is any change
5328 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005329 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005330 {
5331 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5332 }
5333 else
5334 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005335 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005336 return 0;
5337 }
5338 }
5339 break;
5340
5341 case WE_MCC_CONFIG_PARAMS :
5342 {
5343 cmd = 288; //command Should be updated if there is any change
5344 // in the Riva dump command
5345 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5346 }
5347 break;
5348
Chilam NG571c65a2013-01-19 12:27:36 +05305349#ifdef FEATURE_WLAN_TDLS
5350 case WE_TDLS_CONFIG_PARAMS :
5351 {
5352 tdls_config_params_t tdlsParams;
5353
Chilam Ng01120412013-02-19 18:32:21 -08005354 tdlsParams.tdls = apps_args[0];
5355 tdlsParams.tx_period_t = apps_args[1];
5356 tdlsParams.tx_packet_n = apps_args[2];
5357 tdlsParams.discovery_period_t = apps_args[3];
5358 tdlsParams.discovery_tries_n = apps_args[4];
5359 tdlsParams.idle_timeout_t = apps_args[5];
5360 tdlsParams.idle_packet_n = apps_args[6];
5361 tdlsParams.rssi_hysteresis = apps_args[7];
5362 tdlsParams.rssi_trigger_threshold = apps_args[8];
5363 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305364
Chilam Ng01120412013-02-19 18:32:21 -08005365 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305366 }
5367 break;
5368#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 default:
5370 {
5371 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
5372 }
5373 break;
5374 }
5375
5376 return 0;
5377}
5378
5379
5380static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5381 union iwreq_data *wrqu, char *extra)
5382{
5383 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5384 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5385 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5386 int params[HDD_WLAN_WMM_PARAM_COUNT];
5387 sme_QosWmmTspecInfo tSpec;
5388 v_U32_t handle;
5389
5390 // make sure the application is sufficiently priviledged
5391 // note that the kernel will do this for "set" ioctls, but since
5392 // this ioctl wants to return status to user space it must be
5393 // defined as a "get" ioctl
5394 if (!capable(CAP_NET_ADMIN))
5395 {
5396 return -EPERM;
5397 }
5398
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005399 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5400 {
5401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5402 "%s:LOGP in Progress. Ignore!!!", __func__);
5403 return -EBUSY;
5404 }
5405
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 // we must be associated in order to add a tspec
5407 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5408 {
5409 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5410 return 0;
5411 }
5412
5413 // since we are defined to be a "get" ioctl, and since the number
5414 // of params exceeds the number of params that wireless extensions
5415 // will pass down in the iwreq_data, we must copy the "set" params
5416 // from user space ourselves
5417 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5418 {
5419 // hmmm, can't get them
5420 return -EIO;
5421 }
5422
5423 // clear the tspec
5424 memset(&tSpec, 0, sizeof(tSpec));
5425
5426 // validate the handle
5427 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5428 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5429 {
5430 // that one is reserved
5431 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5432 return 0;
5433 }
5434
5435 // validate the TID
5436 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5437 {
5438 // out of range
5439 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5440 return 0;
5441 }
5442 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5443
5444 // validate the direction
5445 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5446 {
5447 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5448 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5449 break;
5450
5451 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5452 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5453 break;
5454
5455 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5456 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5457 break;
5458
5459 default:
5460 // unknown
5461 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5462 return 0;
5463 }
5464
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305465 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5466
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 // validate the user priority
5468 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5469 {
5470 // out of range
5471 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5472 return 0;
5473 }
5474 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305475 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5476 {
5477 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5478 return 0;
5479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005480
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5482 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5483 tSpec.ts_info.psb, tSpec.ts_info.up);
5484
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5486 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5487 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5488 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5489 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5490 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5491 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5492 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5493 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5494 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5495 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5496 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5497
5498 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5499
5500 // validate the ts info ack policy
5501 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5502 {
5503 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5504 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5505 break;
5506
5507 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5508 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5509 break;
5510
5511 default:
5512 // unknown
5513 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5514 return 0;
5515 }
5516
5517 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5518 return 0;
5519}
5520
5521
5522static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5523 union iwreq_data *wrqu, char *extra)
5524{
5525 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5526 int *params = (int *)extra;
5527 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5528 v_U32_t handle;
5529
5530 // make sure the application is sufficiently priviledged
5531 // note that the kernel will do this for "set" ioctls, but since
5532 // this ioctl wants to return status to user space it must be
5533 // defined as a "get" ioctl
5534 if (!capable(CAP_NET_ADMIN))
5535 {
5536 return -EPERM;
5537 }
5538
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005539 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5540 {
5541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5542 "%s:LOGP in Progress. Ignore!!!", __func__);
5543 return -EBUSY;
5544 }
5545
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 // although we are defined to be a "get" ioctl, the params we require
5547 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5548 // is no need to copy the params from user space
5549
5550 // validate the handle
5551 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5552 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5553 {
5554 // that one is reserved
5555 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5556 return 0;
5557 }
5558
5559 *pStatus = hdd_wmm_delts(pAdapter, handle);
5560 return 0;
5561}
5562
5563
5564static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5565 union iwreq_data *wrqu, char *extra)
5566{
5567 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5568 int *params = (int *)extra;
5569 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5570 v_U32_t handle;
5571
5572 // although we are defined to be a "get" ioctl, the params we require
5573 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5574 // is no need to copy the params from user space
5575
5576 // validate the handle
5577 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5578 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5579 {
5580 // that one is reserved
5581 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5582 return 0;
5583 }
5584
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005585 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5586 {
5587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5588 "%s:LOGP in Progress. Ignore!!!", __func__);
5589 return -EBUSY;
5590 }
5591
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5593 return 0;
5594}
5595
5596
5597#ifdef FEATURE_WLAN_WAPI
5598static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5599 union iwreq_data *wrqu, char *extra)
5600{
5601 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5602 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5603 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5604 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5605
Arif Hussain7adce1b2013-11-11 22:59:34 -08005606 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005607
5608 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005609 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005610 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5611 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005612
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005613 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5614 {
5615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5616 "%s:LOGP in Progress. Ignore!!!", __func__);
5617 return -EBUSY;
5618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005619
5620 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005621 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5623 pRoamProfile->EncryptionType.numEntries = 1;
5624 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5625 pRoamProfile->mcEncryptionType.numEntries = 1;
5626 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5627
5628 pRoamProfile->AuthType.numEntries = 1;
5629 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5630 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5631 }
5632 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005633 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 }
5635 else
5636 return -EINVAL;
5637
5638 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5639
5640 return 0;
5641}
5642
5643static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5644 union iwreq_data *wrqu, char *extra)
5645{
5646 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5647 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5648
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005649 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5650 {
5651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5652 "%s:LOGP in Progress. Ignore!!!", __func__);
5653 return -EBUSY;
5654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5656
5657 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005658 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 return 0;
5660}
5661
5662static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5663 union iwreq_data *wrqu, char *extra)
5664{
5665 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5666// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5667 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5668 int i = 0, j = 0;
5669 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005670 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005671 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005672
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005673 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5674 {
5675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5676 "%s:LOGP in Progress. Ignore!!!", __func__);
5677 return -EBUSY;
5678 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005679
5680 if (NULL == pWapiAssocInfo)
5681 {
5682 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5683 "%s: WDA NULL context", __func__);
5684 VOS_ASSERT(0);
5685 return VOS_STATUS_E_FAILURE;
5686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005687
Arif Hussain6d2a3322013-11-17 19:50:10 -08005688 hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x",__func__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005689 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005691 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005692
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005693 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005695 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005696
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005697 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005698 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 for(i = 0 ; i < 16 ; i++) {
5700 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5701 for(j = 0 ; j < 16 ; j++)
5702 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5703 }
5704
5705 /* We are not using the entire IE as provided by the supplicant.
5706 * This is being calculated by SME. This is the same as in the
5707 * case of WPA. Only the auth mode information needs to be
5708 * extracted here*/
5709 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005710 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5712 }
5713
5714 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005715 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5717 }
5718 return 0;
5719}
5720
5721static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5722 union iwreq_data *wrqu, char *extra)
5723{
5724 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5725 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5726 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5727 tANI_U32 roamId = 0xFF;
5728 tANI_U8 *pKeyPtr = NULL;
5729 v_BOOL_t isConnected = TRUE;
5730 tCsrRoamSetKey setKey;
5731 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5733
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005734 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5735 {
5736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5737 "%s:LOGP in Progress. Ignore!!!", __func__);
5738 return -EBUSY;
5739 }
5740
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005742 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005743 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005744
Arif Hussain6d2a3322013-11-17 19:50:10 -08005745 hddLog(LOG1,":%s: INPUT DATA:\nKey Type:0x%02x Key Direction:0x%02x KEY ID:0x%02x", __func__, pWapiKey->keyType, pWapiKey->keyDirection, pWapiKey->keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 hddLog(LOG1,"Add Index:0x");
5747 for(i =0 ; i < 12 ; i++)
5748 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5749
Arif Hussain6d2a3322013-11-17 19:50:10 -08005750 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5752 for(i =0 ; i < 16 ; i++)
5753 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5754
Arif Hussain6d2a3322013-11-17 19:50:10 -08005755 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5757 for(i =0 ; i < 16 ; i++)
5758 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5759
Arif Hussain6d2a3322013-11-17 19:50:10 -08005760 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 for(i = 0 ; i < 16 ; i++)
5762 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5763
5764 // Clear the setkey memory
5765 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5766 // Store Key ID
5767 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5768 // SET WAPI Encryption
5769 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5770 // Key Directionn both TX and RX
5771 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5772 // the PAE role
5773 setKey.paeRole = 0 ;
5774
5775 switch ( pWapiKey->keyType )
5776 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005777 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 {
5779 isConnected = hdd_connIsConnected(pHddStaCtx);
5780 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5781 break;
5782 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005783 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 {
5785 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5786 break;
5787 }
5788 default:
5789 {
5790 //Any other option is invalid.
5791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005792 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005793
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005794 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5796 break; // NEED RETURN FROM HERE ????
5797 }
5798 }
5799
5800 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5801 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5802 pKeyPtr = setKey.Key;
5803 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5804 pKeyPtr += pWapiKey->wpiekLen;
5805 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5806
5807 // Set the new key with SME.
5808 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5809
5810 if ( isConnected ) {
5811 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5812 if ( halStatus != eHAL_STATUS_SUCCESS )
5813 {
5814 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5815 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5816
5817 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5818 }
5819 }
5820#if 0 /// NEED TO CHECK ON THIS
5821 else
5822 {
5823 // Store the keys in the adapter to be moved to the profile & passed to
5824 // SME in the ConnectRequest if we are not yet in connected state.
5825 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5826 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5827
5828 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5829 " Saving key [idx= %d] to apply when moving to connected state ",
5830 setKey.keyId );
5831
5832 }
5833#endif
5834 return halStatus;
5835}
5836
5837static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5838 union iwreq_data *wrqu, char *extra)
5839{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005840 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005841#ifdef WLAN_DEBUG
5842 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005843 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005844#endif
5845
5846 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005847 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005848 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005849
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005850 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5851 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005852
5853 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005854
5855 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5856 {
5857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5858 "%s:LOGP in Progress. Ignore!!!", __func__);
5859 return -EBUSY;
5860 }
5861
Jeff Johnson295189b2012-06-20 16:38:30 -07005862#ifdef WLAN_DEBUG
5863 for(i =0 ; i < 16 ; i++)
5864 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5865#endif
5866
5867 return 0;
5868}
5869
5870static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5871 union iwreq_data *wrqu, char *extra)
5872{
5873 /* Yet to implement this function, 19th April 2010 */
5874 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5875
5876 return 0;
5877}
5878#endif /* FEATURE_WLAN_WAPI */
5879
5880#ifdef WLAN_FEATURE_VOWIFI_11R
5881//
5882//
5883// Each time the supplicant has the auth_request or reassoc request
5884// IEs ready. This is pushed to the driver. The driver will inturn use
5885// it to send out the auth req and reassoc req for 11r FT Assoc.
5886//
5887static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5888 union iwreq_data *wrqu, char *extra)
5889{
5890 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5891 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5892 //v_CONTEXT_t pVosContext;
5893
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005894 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5895 {
5896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5897 "%s:LOGP in Progress. Ignore!!!", __func__);
5898 return -EBUSY;
5899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 if (!wrqu->data.length)
5901 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005902 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 return -EINVAL;
5904 }
5905 if (wrqu->data.pointer == NULL)
5906 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005907 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 return -EINVAL;
5909 }
5910
5911 // Added for debug on reception of Re-assoc Req.
5912 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5913 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005914 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005916 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 }
5918
5919#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005920 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005921#endif
5922
5923 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005924 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 wrqu->data.length);
5926
5927 return 0;
5928}
5929#endif
5930
Amar Singhalf3a6e762013-02-19 15:06:50 -08005931static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005932 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005934{
Jeff Johnson295189b2012-06-20 16:38:30 -07005935 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005936 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005938 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005939 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005940 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5941 int idx;
5942 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005943
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005944 if (pHddCtx->isLogpInProgress)
5945 {
5946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5947 "%s:LOGP in Progress. Ignore!!!", __func__);
5948 return -EBUSY;
5949 }
5950
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305951 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5952 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305953#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005954
Amar Singhalf3a6e762013-02-19 15:06:50 -08005955 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5956 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005957 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005958 hddLog(VOS_TRACE_LEVEL_ERROR,
5959 "%s: vos_mem_alloc failed", __func__);
5960 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005961 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005962
5963 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5964
5965 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5966 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5967
5968 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5969 mc_addr_list_ptr->ulMulticastAddrCnt);
5970
5971 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005972 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005973 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5974 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5975
5976 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5977 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005978 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005979
Amar Singhalf3a6e762013-02-19 15:06:50 -08005980 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5981 vos_mem_free(mc_addr_list_ptr);
5982 if (eHAL_STATUS_SUCCESS != ret_val)
5983 {
5984 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5985 __func__);
5986 return -EINVAL;
5987 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305988#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305989 }
5990 else
5991 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005992
Amar Singhalf3a6e762013-02-19 15:06:50 -08005993 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5994 "%s: Set MC BC Filter Config request: %d suspend %d",
5995 __func__, pRequest->mcastBcastFilterSetting,
5996 pHddCtx->hdd_wlan_suspended);
5997
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305998 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005999
6000 if (pHddCtx->hdd_wlan_suspended)
6001 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006002 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6003 if (NULL == wlanRxpFilterParam)
6004 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306005 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006006 "%s: vos_mem_alloc failed", __func__);
6007 return -EINVAL;
6008 }
6009
Amar Singhalf3a6e762013-02-19 15:06:50 -08006010 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6011 pRequest->mcastBcastFilterSetting;
6012 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6013
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306014 hdd_conf_hostoffload(pAdapter, TRUE);
6015 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6016 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006017
6018 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6019 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306020 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006021 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6022 wlanRxpFilterParam->setMcstBcstFilter);
6023
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306024 if (eHAL_STATUS_SUCCESS !=
6025 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6026 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006027 {
6028 hddLog(VOS_TRACE_LEVEL_ERROR,
6029 "%s: Failure to execute set HW MC/BC Filter request",
6030 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006031 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006032 return -EINVAL;
6033 }
6034
Amar Singhalf3a6e762013-02-19 15:06:50 -08006035 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006037
6038 return 0;
6039}
6040
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006041static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006042 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 union iwreq_data *wrqu, char *extra)
6044{
6045 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6046 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306047 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006048 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006049
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306050 //Reset the filter to INI value as we have to clear the dynamic filter
6051 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006052
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306053 //Configure FW with new setting
6054 if (pHddCtx->hdd_wlan_suspended)
6055 {
6056 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6057 if (NULL == wlanRxpFilterParam)
6058 {
6059 hddLog(VOS_TRACE_LEVEL_ERROR,
6060 "%s: vos_mem_alloc failed", __func__);
6061 return -EINVAL;
6062 }
6063
6064 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6065 pHddCtx->configuredMcastBcastFilter;
6066 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6067
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306068 hdd_conf_hostoffload(pAdapter, TRUE);
6069 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6070 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306071
6072 if (eHAL_STATUS_SUCCESS !=
6073 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6074 wlanRxpFilterParam))
6075 {
6076 hddLog(VOS_TRACE_LEVEL_ERROR,
6077 "%s: Failure to execute set HW MC/BC Filter request",
6078 __func__);
6079 vos_mem_free(wlanRxpFilterParam);
6080 return -EINVAL;
6081 }
6082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 return 0;
6084}
6085
6086static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6087 union iwreq_data *wrqu, char *extra)
6088{
6089 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006090 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 tSirHostOffloadReq offloadRequest;
6092
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006093 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6094 {
6095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6096 "%s:LOGP in Progress. Ignore!!!", __func__);
6097 return -EBUSY;
6098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 /* Debug display of request components. */
6100 switch (pRequest->offloadType)
6101 {
6102 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006103 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 switch (pRequest->enableOrDisable)
6105 {
6106 case WLAN_OFFLOAD_DISABLE:
6107 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6108 break;
6109 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6110 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6111 case WLAN_OFFLOAD_ENABLE:
6112 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6113 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6114 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6115 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6116 }
6117 break;
6118
6119 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006120 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006121 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 switch (pRequest->enableOrDisable)
6123 {
6124 case WLAN_OFFLOAD_DISABLE:
6125 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6126 break;
6127 case WLAN_OFFLOAD_ENABLE:
6128 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6129 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6130 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6131 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6132 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6133 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6134 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6135 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6136 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6137 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6138 }
6139 }
6140
6141 /* Execute offload request. The reason that we can copy the request information
6142 from the ioctl structure to the SME structure is that they are laid out
6143 exactly the same. Otherwise, each piece of information would have to be
6144 copied individually. */
6145 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006146 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6147 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006149 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 __func__);
6151 return -EINVAL;
6152 }
6153
6154 return 0;
6155}
6156
6157static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6158 union iwreq_data *wrqu, char *extra)
6159{
6160 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006161 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 tSirKeepAliveReq keepaliveRequest;
6163
6164 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6165 {
6166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006167 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 return 0;
6169 }
6170
6171 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006172 hddLog(VOS_TRACE_LEVEL_INFO,
6173 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6174 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006175
6176 switch (pRequest->packetType)
6177 {
6178 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006179 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 break;
6181
6182 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6183
Arif Hussain6d2a3322013-11-17 19:50:10 -08006184 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006185 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186
6187 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6188 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6189 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6190
6191 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6192 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6193 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6194
6195 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6196 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6197 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6198 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6199 break;
6200
6201 }
6202
6203 /* Execute keep alive request. The reason that we can copy the request information
6204 from the ioctl structure to the SME structure is that they are laid out
6205 exactly the same. Otherwise, each piece of information would have to be
6206 copied individually. */
6207 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6208
Arif Hussain6d2a3322013-11-17 19:50:10 -08006209 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006210
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006211 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006212 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006214 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 __func__);
6216 return -EINVAL;
6217 }
6218
6219 return 0;
6220}
6221
6222#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006223int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006224 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006225{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006226 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6227 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 int i=0;
6229
6230 if (pHddCtx->cfg_ini->disablePacketFilter)
6231 {
6232 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006233 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 return 0;
6235 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006236 if (pHddCtx->isLogpInProgress)
6237 {
6238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6239 "%s:LOGP in Progress. Ignore!!!", __func__);
6240 return -EBUSY;
6241 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006242 /* Debug display of request components. */
6243 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006244 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006245
6246 switch (pRequest->filterAction)
6247 {
6248 case HDD_RCV_FILTER_SET:
6249 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006250 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006251
6252 packetFilterSetReq.filterId = pRequest->filterId;
6253 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6254 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006255 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 __func__, pRequest->numParams);
6257 return -EINVAL;
6258 }
6259 packetFilterSetReq.numFieldParams = pRequest->numParams;
6260 packetFilterSetReq.coalesceTime = 0;
6261 packetFilterSetReq.filterType = 1;
6262 for (i=0; i < pRequest->numParams; i++)
6263 {
6264 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6265 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6266 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6267 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6268 packetFilterSetReq.paramsData[i].reserved = 0;
6269
Arif Hussain6d2a3322013-11-17 19:50:10 -08006270 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6272 packetFilterSetReq.filterType);
6273
Arif Hussain6d2a3322013-11-17 19:50:10 -08006274 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6276
6277 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6278 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6279 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6280 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6281
Arif Hussain6d2a3322013-11-17 19:50:10 -08006282 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006283 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6284 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6285 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6286
Arif Hussain6d2a3322013-11-17 19:50:10 -08006287 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6289 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6290 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6291 }
6292
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006293 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006295 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 __func__);
6297 return -EINVAL;
6298 }
6299
6300 break;
6301
6302 case HDD_RCV_FILTER_CLEAR:
6303
Arif Hussain6d2a3322013-11-17 19:50:10 -08006304 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006305 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006307 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006309 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 __func__);
6311 return -EINVAL;
6312 }
6313 break;
6314
6315 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006316 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006317 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 return -EINVAL;
6319 }
6320 return 0;
6321}
6322
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306323int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6324 tANI_U8 sessionId)
6325{
6326 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6327 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6328
6329 if (NULL == pHddCtx)
6330 {
6331 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6332 return -EINVAL;
6333 }
6334
6335 if (pHddCtx->isLogpInProgress)
6336 {
6337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6338 "%s:LOGP in Progress. Ignore!!!", __func__);
6339 return -EBUSY;
6340 }
6341
6342 if (pHddCtx->cfg_ini->disablePacketFilter)
6343 {
6344 hddLog(VOS_TRACE_LEVEL_ERROR,
6345 "%s: Packet Filtering Disabled. Returning ",
6346 __func__ );
6347 return -EINVAL;
6348 }
6349
6350 switch (filterType)
6351 {
6352 /* For setting IPV6 MC and UC Filter we need to configure
6353 * 2 filters, one for MC and one for UC.
6354 * The Filter ID shouldn't be swapped, which results in making
6355 * UC Filter ineffective.
6356 * We have Hardcode all the values
6357 *
6358 * Reason for a seperate UC filter is because, driver need to
6359 * specify the FW that the specific filter is for unicast
6360 * otherwise FW will not pass the unicast frames by default
6361 * through the filter. This is required to avoid any performance
6362 * hits when no unicast filter is set and only MC/BC are set.
6363 * The way driver informs host is by using the MAC protocol
6364 * layer, CMP flag set to MAX, CMP Data set to 1.
6365 */
6366
6367 case HDD_FILTER_IPV6_MC_UC:
6368 /* Setting IPV6 MC Filter below
6369 */
6370 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6371 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6372 packetFilterSetReq.numFieldParams = 2;
6373 packetFilterSetReq.paramsData[0].protocolLayer =
6374 HDD_FILTER_PROTO_TYPE_MAC;
6375 packetFilterSetReq.paramsData[0].cmpFlag =
6376 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6377 packetFilterSetReq.paramsData[0].dataOffset =
6378 WLAN_HDD_80211_FRM_DA_OFFSET;
6379 packetFilterSetReq.paramsData[0].dataLength = 1;
6380 packetFilterSetReq.paramsData[0].compareData[0] =
6381 HDD_IPV6_MC_CMP_DATA;
6382
6383 packetFilterSetReq.paramsData[1].protocolLayer =
6384 HDD_FILTER_PROTO_TYPE_ARP;
6385 packetFilterSetReq.paramsData[1].cmpFlag =
6386 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6387 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6388 packetFilterSetReq.paramsData[1].dataLength = 2;
6389 packetFilterSetReq.paramsData[1].compareData[0] =
6390 HDD_IPV6_CMP_DATA_0;
6391 packetFilterSetReq.paramsData[1].compareData[1] =
6392 HDD_IPV6_CMP_DATA_1;
6393
6394
6395 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6396 &packetFilterSetReq, sessionId))
6397 {
6398 hddLog(VOS_TRACE_LEVEL_ERROR,
6399 "%s: Failure to execute Set IPv6 Mulicast Filter",
6400 __func__);
6401 return -EINVAL;
6402 }
6403
6404 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6405
6406 /*
6407 * Setting IPV6 UC Filter below
6408 */
6409 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6410 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6411 packetFilterSetReq.numFieldParams = 2;
6412 packetFilterSetReq.paramsData[0].protocolLayer =
6413 HDD_FILTER_PROTO_TYPE_MAC;
6414 packetFilterSetReq.paramsData[0].cmpFlag =
6415 HDD_FILTER_CMP_TYPE_MAX;
6416 packetFilterSetReq.paramsData[0].dataOffset = 0;
6417 packetFilterSetReq.paramsData[0].dataLength = 1;
6418 packetFilterSetReq.paramsData[0].compareData[0] =
6419 HDD_IPV6_UC_CMP_DATA;
6420
6421 packetFilterSetReq.paramsData[1].protocolLayer =
6422 HDD_FILTER_PROTO_TYPE_ARP;
6423 packetFilterSetReq.paramsData[1].cmpFlag =
6424 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6425 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6426 packetFilterSetReq.paramsData[1].dataLength = 2;
6427 packetFilterSetReq.paramsData[1].compareData[0] =
6428 HDD_IPV6_CMP_DATA_0;
6429 packetFilterSetReq.paramsData[1].compareData[1] =
6430 HDD_IPV6_CMP_DATA_1;
6431
6432 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6433 &packetFilterSetReq, sessionId))
6434 {
6435 hddLog(VOS_TRACE_LEVEL_ERROR,
6436 "%s: Failure to execute Set IPv6 Unicast Filter",
6437 __func__);
6438 return -EINVAL;
6439 }
6440
6441 break;
6442
6443 case HDD_FILTER_IPV6_MC:
6444 /*
6445 * IPV6 UC Filter might be already set,
6446 * clear the UC Filter. As the Filter
6447 * IDs are static, we can directly clear it.
6448 */
6449 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6450 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6451 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6452 &packetFilterClrReq, sessionId))
6453 {
6454 hddLog(VOS_TRACE_LEVEL_ERROR,
6455 "%s: Failure to execute Clear IPv6 Unicast Filter",
6456 __func__);
6457 return -EINVAL;
6458 }
6459
6460 /*
6461 * Setting IPV6 MC Filter below
6462 */
6463 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6464 packetFilterSetReq.numFieldParams = 2;
6465 packetFilterSetReq.paramsData[0].protocolLayer =
6466 HDD_FILTER_PROTO_TYPE_MAC;
6467 packetFilterSetReq.paramsData[0].cmpFlag =
6468 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6469 packetFilterSetReq.paramsData[0].dataOffset =
6470 WLAN_HDD_80211_FRM_DA_OFFSET;
6471 packetFilterSetReq.paramsData[0].dataLength = 1;
6472 packetFilterSetReq.paramsData[0].compareData[0] =
6473 HDD_IPV6_MC_CMP_DATA;
6474
6475 packetFilterSetReq.paramsData[1].protocolLayer =
6476 HDD_FILTER_PROTO_TYPE_ARP;
6477 packetFilterSetReq.paramsData[1].cmpFlag =
6478 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6479 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6480 packetFilterSetReq.paramsData[1].dataLength = 2;
6481 packetFilterSetReq.paramsData[1].compareData[0] =
6482 HDD_IPV6_CMP_DATA_0;
6483 packetFilterSetReq.paramsData[1].compareData[1] =
6484 HDD_IPV6_CMP_DATA_1;
6485
6486
6487 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6488 &packetFilterSetReq, sessionId))
6489 {
6490 hddLog(VOS_TRACE_LEVEL_ERROR,
6491 "%s: Failure to execute Set IPv6 Multicast Filter",
6492 __func__);
6493 return -EINVAL;
6494 }
6495 break;
6496
6497 default :
6498 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6499 "%s: Packet Filter Request: Invalid",
6500 __func__);
6501 return -EINVAL;
6502 }
6503 return 0;
6504}
6505
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306506void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006507{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306508 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306509 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006510 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306511 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006512
Yue Ma3ede6052013-08-29 00:33:26 -07006513 if (NULL == pHddCtx)
6514 {
6515 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6516 return;
6517 }
6518
6519 hHal = pHddCtx->hHal;
6520
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306521 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306523 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6524 return;
6525 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306526
6527 /* Check if INI is enabled or not, other wise just return
6528 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306529 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306530 {
6531 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6532 if (NULL == pMulticastAddrs)
6533 {
6534 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6535 return;
6536 }
6537
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 if (set)
6539 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306540 /* Following pre-conditions should be satisfied before wei
6541 * configure the MC address list.
6542 */
6543 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6544 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6545 && pAdapter->mc_addr_list.mc_cnt
6546 && (eConnectionState_Associated ==
6547 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6548 {
6549 pMulticastAddrs->ulMulticastAddrCnt =
6550 pAdapter->mc_addr_list.mc_cnt;
6551 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6552 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006553 memcpy(pMulticastAddrs->multicastAddr[i],
6554 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306555 sizeof(pAdapter->mc_addr_list.addr[i]));
6556 hddLog(VOS_TRACE_LEVEL_INFO,
6557 "%s: %s multicast filter: addr ="
6558 MAC_ADDRESS_STR,
6559 __func__, set ? "setting" : "clearing",
6560 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6561 }
6562 /* Set multicast filter */
6563 sme_8023MulticastList(hHal, pAdapter->sessionId,
6564 pMulticastAddrs);
6565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306567 else
6568 {
6569 /* Need to clear only if it was previously configured
6570 */
6571 if (pAdapter->mc_addr_list.isFilterApplied)
6572 {
6573 pMulticastAddrs->ulMulticastAddrCnt = 0;
6574 sme_8023MulticastList(hHal, pAdapter->sessionId,
6575 pMulticastAddrs);
6576 }
6577
6578 }
6579 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006580 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006581 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306582 else
6583 {
6584 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306585 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306586 }
6587 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006588}
6589
6590static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6591 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306592{
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006594 tpPacketFilterCfg pRequest = NULL;
6595 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006596
Arif Hussain0273cba2014-01-07 20:58:29 -08006597 /* ODD number is used for set, copy data using copy_from_user */
6598 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6599 wrqu->data.length);
6600 if (NULL == pRequest)
6601 {
6602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6603 "mem_alloc_copy_from_user_helper fail");
6604 return -ENOMEM;
6605 }
6606
6607 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6608 kfree(pRequest);
6609
6610 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006611}
6612#endif
6613static int iw_get_statistics(struct net_device *dev,
6614 struct iw_request_info *info,
6615 union iwreq_data *wrqu, char *extra)
6616{
6617
6618 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6619 eHalStatus status = eHAL_STATUS_SUCCESS;
6620 hdd_wext_state_t *pWextState;
6621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6622 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6623 char *p = extra;
6624 int tlen = 0;
6625 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6626
6627 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6628 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6629
6630 ENTER();
6631
6632 if (pHddCtx->isLogpInProgress) {
6633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6634 return -EINVAL;
6635 }
6636
6637 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6638
6639 wrqu->txpower.value = 0;
6640 }
6641 else {
6642 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6643 SME_SUMMARY_STATS |
6644 SME_GLOBAL_CLASSA_STATS |
6645 SME_GLOBAL_CLASSB_STATS |
6646 SME_GLOBAL_CLASSC_STATS |
6647 SME_GLOBAL_CLASSD_STATS |
6648 SME_PER_STA_STATS,
6649 hdd_StatisticsCB, 0, FALSE,
6650 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6651
6652 if (eHAL_STATUS_SUCCESS != status)
6653 {
6654 hddLog(VOS_TRACE_LEVEL_ERROR,
6655 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006656 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 return -EINVAL;
6658 }
6659
6660 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6661
6662 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6663 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6664 {
6665 hddLog(VOS_TRACE_LEVEL_ERROR,
6666 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006667 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 /*Remove the SME statistics list by passing NULL in callback argument*/
6669 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6670 SME_SUMMARY_STATS |
6671 SME_GLOBAL_CLASSA_STATS |
6672 SME_GLOBAL_CLASSB_STATS |
6673 SME_GLOBAL_CLASSC_STATS |
6674 SME_GLOBAL_CLASSD_STATS |
6675 SME_PER_STA_STATS,
6676 NULL, 0, FALSE,
6677 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6678
6679 return -EINVAL;
6680 }
6681 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6682 (tANI_U8) sizeof (pStats->retry_cnt),
6683 (char*) &(pStats->retry_cnt[0]),
6684 tlen);
6685
6686 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6687 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6688 (char*) &(pStats->multiple_retry_cnt[0]),
6689 tlen);
6690
6691 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6692 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6693 (char*) &(pStats->tx_frm_cnt[0]),
6694 tlen);
6695
6696 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6697 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6698 (char*) &(pStats->rx_frm_cnt),
6699 tlen);
6700
6701 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6702 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6703 (char*) &(pStats->frm_dup_cnt),
6704 tlen);
6705
6706 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6707 (tANI_U8) sizeof (pStats->fail_cnt),
6708 (char*) &(pStats->fail_cnt[0]),
6709 tlen);
6710
6711 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6712 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6713 (char*) &(pStats->rts_fail_cnt),
6714 tlen);
6715
6716 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6717 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6718 (char*) &(pStats->ack_fail_cnt),
6719 tlen);
6720
6721 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6722 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6723 (char*) &(pStats->rts_succ_cnt),
6724 tlen);
6725
6726 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6727 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6728 (char*) &(pStats->rx_discard_cnt),
6729 tlen);
6730
6731 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6732 (tANI_U8) sizeof (pStats->rx_error_cnt),
6733 (char*) &(pStats->rx_error_cnt),
6734 tlen);
6735
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006736 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006737 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006738 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 tlen);
6740
6741 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6742 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6743 (char*) &(dStats->rx_byte_cnt),
6744 tlen);
6745
6746 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6747 (tANI_U8) sizeof (dStats->rx_rate),
6748 (char*) &(dStats->rx_rate),
6749 tlen);
6750
6751 /* Transmit rate, in units of 500 kbit/sec */
6752 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6753 (tANI_U8) sizeof (aStats->tx_rate),
6754 (char*) &(aStats->tx_rate),
6755 tlen);
6756
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006757 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6758 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6759 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006760 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006761 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6762 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6763 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006764 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006765 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6766 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6767 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006768 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006769 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6770 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6771 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006772 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006773 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6774 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6775 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006776 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006777 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6778 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6779 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006780 tlen);
6781
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 wrqu->data.length = tlen;
6783
6784 }
6785
6786 EXIT();
6787
6788 return 0;
6789}
6790
6791
6792#ifdef FEATURE_WLAN_SCAN_PNO
6793
6794/*Max Len for PNO notification*/
6795#define MAX_PNO_NOTIFY_LEN 100
6796void found_pref_network_cb (void *callbackContext,
6797 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6798{
6799 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6800 union iwreq_data wrqu;
6801 char buf[MAX_PNO_NOTIFY_LEN+1];
6802
6803 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6804 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6805
6806 // create the event
6807 memset(&wrqu, 0, sizeof(wrqu));
6808 memset(buf, 0, sizeof(buf));
6809
6810 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6811 pPrefNetworkFoundInd->ssId.ssId,
6812 (unsigned int)pPrefNetworkFoundInd->rssi);
6813
6814 wrqu.data.pointer = buf;
6815 wrqu.data.length = strlen(buf);
6816
6817 // send the event
6818
6819 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6820
6821}
6822
6823
6824/*string based input*/
6825VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6826 union iwreq_data *wrqu, char *extra, int nOffset)
6827{
6828 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006829 /* pnoRequest is a large struct, so we make it static to avoid stack
6830 overflow. This API is only invoked via ioctl, so it is
6831 serialized by the kernel rtnl_lock and hence does not need to be
6832 reentrant */
6833 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 char *ptr;
6835 v_U8_t i,j, ucParams, ucMode;
6836 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6837
6838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6839 "PNO data len %d data %s",
6840 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006841 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006842
6843 if (wrqu->data.length <= nOffset )
6844 {
6845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6846 return VOS_STATUS_E_FAILURE;
6847 }
6848
6849 pnoRequest.enable = 0;
6850 pnoRequest.ucNetworksCount = 0;
6851 /*-----------------------------------------------------------------------
6852 Input is string based and expected to be like this:
6853
6854 <enabled> <netw_count>
6855 for each network:
6856 <ssid_len> <ssid> <authentication> <encryption>
6857 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6858 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6859
6860 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006861 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 -07006862
6863 this translates into:
6864 -----------------------------
6865 enable PNO
6866 look for 2 networks:
6867 test - with authentication type 0 and encryption type 0,
6868 that can be found on 3 channels: 1 6 and 11 ,
6869 SSID bcast type is unknown (directed probe will be sent if AP not found)
6870 and must meet -40dBm RSSI
6871
6872 test2 - with auth and enrytption type 4/4
6873 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6874 bcast type is non-bcast (directed probe will be sent)
6875 and must not meet any RSSI threshold
6876
Jeff Johnson8301aa12013-03-28 14:27:29 -07006877 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006879 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006880
Wilson Yang623f6592013-10-08 16:33:37 -07006881 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6882 {
6883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6884 "PNO enable input is not valid %s",ptr);
6885 return VOS_STATUS_E_FAILURE;
6886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006887
6888 if ( 0 == pnoRequest.enable )
6889 {
6890 /*Disable PNO*/
6891 memset(&pnoRequest, 0, sizeof(pnoRequest));
6892 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6893 pAdapter->sessionId,
6894 found_pref_network_cb, pAdapter);
6895 return VOS_STATUS_SUCCESS;
6896 }
6897
6898 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006899
6900 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6901 {
6902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6903 "PNO count input not valid %s",ptr);
6904 return VOS_STATUS_E_FAILURE;
6905
6906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006907
6908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6909 "PNO enable %d networks count %d offset %d",
6910 pnoRequest.enable,
6911 pnoRequest.ucNetworksCount,
6912 nOffset);
6913
6914 /* Parameters checking:
6915 ucNetworksCount has to be larger than 0*/
6916 if (( 0 == pnoRequest.ucNetworksCount ) ||
6917 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6918 {
6919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6920 return VOS_STATUS_E_FAILURE;
6921 }
6922
6923 ptr += nOffset;
6924
6925 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6926 {
6927
6928 pnoRequest.aNetworks[i].ssId.length = 0;
6929
Wilson Yang623f6592013-10-08 16:33:37 -07006930 ucParams = sscanf(ptr,"%hhu %n",
6931 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6932
6933 if (1 != ucParams)
6934 {
6935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6936 "PNO ssid length input is not valid %s",ptr);
6937 return VOS_STATUS_E_FAILURE;
6938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006939
6940 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6941 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6942 {
6943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6944 "SSID Len %d is not correct for network %d",
6945 pnoRequest.aNetworks[i].ssId.length, i);
6946 return VOS_STATUS_E_FAILURE;
6947 }
6948
6949 /*Advance to SSID*/
6950 ptr += nOffset;
6951
Jeff Johnson8301aa12013-03-28 14:27:29 -07006952 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006953 pnoRequest.aNetworks[i].ssId.length);
6954 ptr += pnoRequest.aNetworks[i].ssId.length;
6955
Jeff Johnson02797792013-10-26 19:17:13 -07006956 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006957 &(pnoRequest.aNetworks[i].authentication),
6958 &(pnoRequest.aNetworks[i].encryption),
6959 &(pnoRequest.aNetworks[i].ucChannelCount),
6960 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006961
Wilson Yang623f6592013-10-08 16:33:37 -07006962 if ( 3 != ucParams )
6963 {
6964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6965 "Incorrect cmd %s",ptr);
6966 return VOS_STATUS_E_FAILURE;
6967 }
6968
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006970 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006971 "auth %d encry %d channel count %d offset %d",
6972 pnoRequest.aNetworks[i].ssId.length,
6973 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6974 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6975 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6976 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6977 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6978 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6979 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6980 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6981 pnoRequest.aNetworks[i].authentication,
6982 pnoRequest.aNetworks[i].encryption,
6983 pnoRequest.aNetworks[i].ucChannelCount,
6984 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006985
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 /*Advance to channel list*/
6987 ptr += nOffset;
6988
Wilson Yang623f6592013-10-08 16:33:37 -07006989 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 {
6991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6992 "Incorrect number of channels");
6993 return VOS_STATUS_E_FAILURE;
6994 }
6995
6996 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6997 {
6998 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6999 {
Wilson Yang623f6592013-10-08 16:33:37 -07007000 if (1 != sscanf(ptr,"%hhu %n",
7001 &(pnoRequest.aNetworks[i].aChannels[j]),
7002 &nOffset))
7003 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7004 "PNO network channel input is not valid %s",ptr);
7005 return VOS_STATUS_E_FAILURE;
7006 }
7007 /*Advance to next channel number*/
7008 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 }
7010 }
7011
Jeff Johnson02797792013-10-26 19:17:13 -07007012 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007013 &(pnoRequest.aNetworks[i].bcastNetwType),
7014 &nOffset))
7015 {
7016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7017 "PNO broadcast network type input is not valid %s",ptr);
7018 return VOS_STATUS_E_FAILURE;
7019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007020
7021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7022 "PNO bcastNetwType %d offset %d",
7023 pnoRequest.aNetworks[i].bcastNetwType,
7024 nOffset );
7025
7026 /*Advance to rssi Threshold*/
7027 ptr += nOffset;
7028
Wilson Yang623f6592013-10-08 16:33:37 -07007029 if (1 != sscanf(ptr,"%hhu %n",
7030 &(pnoRequest.aNetworks[i].rssiThreshold),
7031 &nOffset))
7032 {
7033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7034 "PNO rssi threshold input is not valid %s",ptr);
7035 return VOS_STATUS_E_FAILURE;
7036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007037
7038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7039 "PNO rssi %d offset %d",
7040 pnoRequest.aNetworks[i].rssiThreshold,
7041 nOffset );
7042 /*Advance to next network*/
7043 ptr += nOffset;
7044 }/*For ucNetworkCount*/
7045
7046 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007047 &(pnoRequest.scanTimers.ucScanTimersCount),
7048 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007049
7050 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007051 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 {
7053 ptr += nOffset;
7054
Jeff Johnson8301aa12013-03-28 14:27:29 -07007055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7056 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 pnoRequest.scanTimers.ucScanTimersCount,
7058 nOffset );
7059
7060 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7061 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 "Incorrect cmd - too many scan timers");
7064 return VOS_STATUS_E_FAILURE;
7065 }
7066
7067 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7068 {
Jeff Johnson02797792013-10-26 19:17:13 -07007069 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7071 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7072 &nOffset);
7073
Wilson Yang623f6592013-10-08 16:33:37 -07007074 if (2 != ucParams)
7075 {
7076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7077 "Incorrect cmd - diff params then expected %d", ucParams);
7078 return VOS_STATUS_E_FAILURE;
7079 }
7080
Jeff Johnson8301aa12013-03-28 14:27:29 -07007081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7082 "PNO Timer value %d Timer repeat %d offset %d",
7083 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7085 nOffset );
7086
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 ptr += nOffset;
7088 }
7089
7090 }
7091 else
7092 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7094 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7096
7097 /*Scan timers defaults to 5 minutes*/
7098 pnoRequest.scanTimers.ucScanTimersCount = 1;
7099 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7100 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7101 }
7102
Wilson Yang623f6592013-10-08 16:33:37 -07007103 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007104
7105 pnoRequest.modePNO = ucMode;
7106 /*for LA we just expose suspend option*/
7107 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7108 {
7109 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7110 }
7111
7112 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
7113 pAdapter->sessionId,
7114 found_pref_network_cb, pAdapter);
7115
7116 return VOS_STATUS_SUCCESS;
7117}/*iw_set_pno*/
7118
7119VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7120 union iwreq_data *wrqu, char *extra, int nOffset)
7121{
7122 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7123 v_U8_t rssiThreshold = 0;
7124 v_U8_t nRead;
7125
Arif Hussain7adce1b2013-11-11 22:59:34 -08007126 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 &rssiThreshold);
7128
7129 if ( 1 != nRead )
7130 {
7131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7132 "Incorrect format");
7133 return VOS_STATUS_E_FAILURE;
7134 }
7135
7136 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7137 return VOS_STATUS_SUCCESS;
7138}
7139
7140
7141static int iw_set_pno_priv(struct net_device *dev,
7142 struct iw_request_info *info,
7143 union iwreq_data *wrqu, char *extra)
7144{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007145 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7146
7147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007149
7150 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7151 {
7152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7153 "%s:LOGP in Progress. Ignore!!!", __func__);
7154 return -EBUSY;
7155 }
7156 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007157}
7158#endif /*FEATURE_WLAN_SCAN_PNO*/
7159
7160//Common function to SetBand
7161int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
7162{
7163 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7164 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7165 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7166 tANI_U8 band = 0;
7167 eCsrBand currBand = eCSR_BAND_MAX;
7168
7169 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
7170
7171 switch(band)
7172 {
7173 case WLAN_HDD_UI_BAND_AUTO:
7174 band = eCSR_BAND_ALL;
7175 break;
7176 case WLAN_HDD_UI_BAND_5_GHZ:
7177 band = eCSR_BAND_5G;
7178 break;
7179 case WLAN_HDD_UI_BAND_2_4_GHZ:
7180 band = eCSR_BAND_24;
7181 break;
7182 default:
7183 band = eCSR_BAND_MAX;
7184 }
7185
7186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007187 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007188
7189 if (band == eCSR_BAND_MAX)
7190 {
7191 /* Received change band request with invalid band value */
7192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007193 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 return -EIO;
7195 }
7196
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307197 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7198 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7199 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7200 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007202 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007203 band, pHddCtx->cfg_ini->nBandCapability);
7204 return -EIO;
7205 }
7206
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7208 {
7209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7210 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007211 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 return -EIO;
7213 }
7214
7215 if (currBand != band)
7216 {
7217 /* Change band request received.
7218 * Abort pending scan requests, flush the existing scan results,
7219 * and change the band capability
7220 */
7221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7222 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007223 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007224
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307225 /* We need to change the band and flush the scan results here itself
7226 * as we may get timeout for disconnection in which we will return
7227 * with out doing any of these
7228 */
7229 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7230 {
7231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7232 "%s: failed to set the band value to %u ",
7233 __func__, band);
7234 return -EINVAL;
7235 }
7236 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7237 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7238 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7239 sme_FilterScanResults(hHal, pAdapter->sessionId);
7240
7241 if (band != eCSR_BAND_ALL &&
7242 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 {
7244 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7245 eHalStatus status = eHAL_STATUS_SUCCESS;
7246 long lrc;
7247
7248 /* STA already connected on current band, So issue disconnect first,
7249 * then change the band*/
7250
7251 hddLog(VOS_TRACE_LEVEL_INFO,
7252 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7253 __func__, csrGetCurrentBand(hHal), band);
7254
7255 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7256 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7257
7258 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7259 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7260
Jeff Johnson43971f52012-07-17 12:26:56 -07007261 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 {
7263 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007264 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 __func__, (int)status );
7266 return -EINVAL;
7267 }
7268
7269 lrc = wait_for_completion_interruptible_timeout(
7270 &pAdapter->disconnect_comp_var,
7271 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7272
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307273 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007274
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007275 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007276 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007277
7278 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7279 }
7280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 }
7282 return 0;
7283}
7284
7285static int iw_set_band_config(struct net_device *dev,
7286 struct iw_request_info *info,
7287 union iwreq_data *wrqu, char *extra)
7288{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007289 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007290 tANI_U8 *ptr = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 int ret = 0;
7292
Arif Hussain0273cba2014-01-07 20:58:29 -08007293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007294
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007295 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7296 {
7297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7298 "%s:LOGP in Progress. Ignore!!!", __func__);
7299 return -EBUSY;
7300 }
7301
Arif Hussain0273cba2014-01-07 20:58:29 -08007302 /* ODD number is used for set, copy data using copy_from_user */
7303 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7304 wrqu->data.length);
7305 if (NULL == ptr)
7306 {
7307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7308 "mem_alloc_copy_from_user_helper fail");
7309 return -ENOMEM;
7310 }
7311
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 if (memcmp(ptr, "SETBAND ", 8) == 0)
7313 {
7314 /* Change band request received */
7315 ret = hdd_setBand_helper(dev, ptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07007316 }
Arif Hussain0273cba2014-01-07 20:58:29 -08007317 kfree(ptr);
7318
7319 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007320}
7321
7322static int iw_set_power_params_priv(struct net_device *dev,
7323 struct iw_request_info *info,
7324 union iwreq_data *wrqu, char *extra)
7325{
Arif Hussain0273cba2014-01-07 20:58:29 -08007326 int ret;
7327 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7329 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007330 /* ODD number is used for set, copy data using copy_from_user */
7331 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7332 wrqu->data.length);
7333 if (NULL == ptr)
7334 {
7335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7336 "mem_alloc_copy_from_user_helper fail");
7337 return -ENOMEM;
7338 }
7339
7340 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7341 kfree(ptr);
7342 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007343}
7344
7345
7346
7347/*string based input*/
7348VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7349 union iwreq_data *wrqu, char *extra, int nOffset)
7350{
7351 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7352 tSirSetPowerParamsReq powerRequest;
7353 char *ptr;
7354 v_U8_t ucType;
7355 v_U32_t uTotalSize, uValue;
7356 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7357
7358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7359 "Power Params data len %d data %s",
7360 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007361 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007362
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007363 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7364 {
7365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7366 "%s:LOGP in Progress. Ignore!!!", __func__);
7367 return -EBUSY;
7368 }
7369
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 if (wrqu->data.length <= nOffset )
7371 {
7372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7373 return VOS_STATUS_E_FAILURE;
7374 }
7375
7376 uTotalSize = wrqu->data.length - nOffset;
7377
7378 /*-----------------------------------------------------------------------
7379 Input is string based and expected to be like this:
7380
7381 <param_type> <param_value> <param_type> <param_value> ...
7382
7383 e.g:
7384 1 2 2 3 3 0 4 1 5 1
7385
7386 e.g. setting just a few:
7387 1 2 4 1
7388
7389 parameter types:
7390 -----------------------------
7391 1 - Ignore DTIM
7392 2 - Listen Interval
7393 3 - Broadcast Multicas Filter
7394 4 - Beacon Early Termination
7395 5 - Beacon Early Termination Interval
7396 -----------------------------------------------------------------------*/
7397 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7398 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7399 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7400 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7401 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7402
Arif Hussain7adce1b2013-11-11 22:59:34 -08007403 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007404
7405 while ( uTotalSize )
7406 {
Wilson Yang6f971452013-10-08 15:00:00 -07007407 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7408 {
7409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7410 "Invalid input parameter type %s",ptr);
7411 return VOS_STATUS_E_FAILURE;
7412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007413
7414 uTotalSize -= nOffset;
7415
7416 if (!uTotalSize)
7417 {
7418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007419 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 ucType, nOffset);
7421 return VOS_STATUS_E_FAILURE;
7422 }
7423
7424 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007425
Jeff Johnson02797792013-10-26 19:17:13 -07007426 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007427 {
7428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7429 "Invalid input parameter value %s",ptr);
7430 return VOS_STATUS_E_FAILURE;
7431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007432
7433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7434 "Power request parameter %d value %d offset %d",
7435 ucType, uValue, nOffset);
7436
7437 switch (ucType)
7438 {
7439 case eSIR_IGNORE_DTIM:
7440 powerRequest.uIgnoreDTIM = uValue;
7441 break;
7442 case eSIR_LISTEN_INTERVAL:
7443 powerRequest.uListenInterval = uValue;
7444 break;
7445 case eSIR_MCAST_BCAST_FILTER:
7446 powerRequest.uBcastMcastFilter = uValue;
7447 break;
7448 case eSIR_ENABLE_BET:
7449 powerRequest.uEnableBET = uValue;
7450 break;
7451 case eSIR_BET_INTERVAL:
7452 powerRequest.uBETInterval = uValue;
7453 break;
7454 default:
7455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007456 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 ucType, uValue, nOffset);
7458 return VOS_STATUS_E_FAILURE;
7459 }
7460
7461 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7463 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007464 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007465 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007466 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007467 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007468 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7469 {
7470 uTotalSize = 0;
7471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007472
7473 }/*Go for as long as we have a valid string*/
7474
7475 /* put the device into full power*/
7476 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7477
7478 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007479 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007480
7481 /* put the device back to power save*/
7482 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7483
7484 return VOS_STATUS_SUCCESS;
7485}/*iw_set_power_params*/
7486
7487
7488// Define the Wireless Extensions to the Linux Network Device structure
7489// A number of these routines are NULL (meaning they are not implemented.)
7490
7491static const iw_handler we_handler[] =
7492{
7493 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7494 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7495 (iw_handler) NULL, /* SIOCSIWNWID */
7496 (iw_handler) NULL, /* SIOCGIWNWID */
7497 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7498 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7499 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7500 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7501 (iw_handler) NULL, /* SIOCSIWSENS */
7502 (iw_handler) NULL, /* SIOCGIWSENS */
7503 (iw_handler) NULL, /* SIOCSIWRANGE */
7504 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7505 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7506 (iw_handler) NULL, /* SIOCGIWPRIV */
7507 (iw_handler) NULL, /* SIOCSIWSTATS */
7508 (iw_handler) NULL, /* SIOCGIWSTATS */
7509 iw_handler_set_spy, /* SIOCSIWSPY */
7510 iw_handler_get_spy, /* SIOCGIWSPY */
7511 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7512 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7513 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7514 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7515 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7516 (iw_handler) NULL, /* SIOCGIWAPLIST */
7517 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7518 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7519 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7520 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7521 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7522 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7523 (iw_handler) NULL, /* -- hole -- */
7524 (iw_handler) NULL, /* -- hole -- */
7525 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7526 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7527 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7528 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7529 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7530 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7531 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7532 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7533 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7534 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7535 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7536 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7537 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7538 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7539 (iw_handler) NULL, /* -- hole -- */
7540 (iw_handler) NULL, /* -- hole -- */
7541 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7542 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7543 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7544 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7545 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7546 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7547 (iw_handler) NULL, /* SIOCSIWPMKSA */
7548};
7549
7550static const iw_handler we_private[] = {
7551
7552 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7553 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7554 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7555 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7556 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7557 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7558 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7559 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7560 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7561 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007562#ifdef FEATURE_OEM_DATA_SUPPORT
7563 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7564 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007566
7567#ifdef FEATURE_WLAN_WAPI
7568 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7569 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7570 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7571 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7572 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7573 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7574#endif /* FEATURE_WLAN_WAPI */
7575#ifdef WLAN_FEATURE_VOWIFI_11R
7576 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7577#endif
7578 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7579 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7580 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7581#ifdef WLAN_FEATURE_PACKET_FILTERING
7582 ,
7583 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7584#endif
7585#ifdef FEATURE_WLAN_SCAN_PNO
7586 ,
7587 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7588#endif
7589 ,
7590 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7591 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7592 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7593 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007594 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007595};
7596
7597/*Maximum command length can be only 15 */
7598static const struct iw_priv_args we_private_args[] = {
7599
7600 /* handlers for main ioctl */
7601 { WLAN_PRIV_SET_INT_GET_NONE,
7602 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7603 0,
7604 "" },
7605
7606 /* handlers for sub-ioctl */
7607 { WE_SET_11D_STATE,
7608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7609 0,
7610 "set11Dstate" },
7611
7612 { WE_WOWL,
7613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7614 0,
7615 "wowl" },
7616
7617 { WE_SET_POWER,
7618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7619 0,
7620 "setPower" },
7621
7622 { WE_SET_MAX_ASSOC,
7623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7624 0,
7625 "setMaxAssoc" },
7626
7627 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7628 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7629 0,
7630 "setAutoChannel" },
7631
7632 { WE_SET_DATA_INACTIVITY_TO,
7633 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7634 0,
7635 "inactivityTO" },
7636
7637 { WE_SET_MAX_TX_POWER,
7638 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7639 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007640 "setMaxTxPower" },
7641
7642 { WE_SET_MAX_TX_POWER_2_4,
7643 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7644 0,
7645 "setTxMaxPower2G" },
7646
7647 { WE_SET_MAX_TX_POWER_5_0,
7648 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7649 0,
7650 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007651
7652 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7653 * as well to keep same syntax as in SAP. Now onwards, STA
7654 * will support both */
7655 { WE_SET_MAX_TX_POWER,
7656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7657 0,
7658 "setTxMaxPower" },
7659
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7661 * 1 = enable and 0 = disable */
7662 {
7663 WE_SET_HIGHER_DTIM_TRANSITION,
7664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7665 0,
7666 "setHDtimTransn" },
7667
7668 { WE_SET_TM_LEVEL,
7669 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007670 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 "setTmLevel" },
7672
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307673 { WE_ENABLE_STRICT_FCC_REG,
7674 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7675 0,
7676 "setStrictFCCreg" },
7677
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007678 { WE_SET_DEBUG_LOG,
7679 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7680 0, "setDbgLvl" },
7681
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 /* handlers for main ioctl */
7683 { WLAN_PRIV_SET_NONE_GET_INT,
7684 0,
7685 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7686 "" },
7687
7688 /* handlers for sub-ioctl */
7689 { WE_GET_11D_STATE,
7690 0,
7691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7692 "get11Dstate" },
7693
7694 { WE_IBSS_STATUS,
7695 0,
7696 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7697 "getAdhocStatus" },
7698
7699 { WE_PMC_STATE,
7700 0,
7701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7702 "pmcState" },
7703
7704 { WE_GET_WLAN_DBG,
7705 0,
7706 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7707 "getwlandbg" },
7708
7709 { WE_MODULE_DOWN_IND,
7710 0,
7711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7712 "moduleDownInd" },
7713
7714 { WE_GET_MAX_ASSOC,
7715 0,
7716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7717 "getMaxAssoc" },
7718
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 { WE_GET_WDI_DBG,
7720 0,
7721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7722 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007723
7724 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7725 0,
7726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7727 "getAutoChannel" },
7728
7729 { WE_GET_CONCURRENCY_MODE,
7730 0,
7731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7732 "getconcurrency" },
7733
7734 /* handlers for main ioctl */
7735 { WLAN_PRIV_SET_CHAR_GET_NONE,
7736 IW_PRIV_TYPE_CHAR| 512,
7737 0,
7738 "" },
7739
7740 /* handlers for sub-ioctl */
7741 { WE_WOWL_ADD_PTRN,
7742 IW_PRIV_TYPE_CHAR| 512,
7743 0,
7744 "wowlAddPtrn" },
7745
7746 { WE_WOWL_DEL_PTRN,
7747 IW_PRIV_TYPE_CHAR| 512,
7748 0,
7749 "wowlDelPtrn" },
7750
7751#if defined WLAN_FEATURE_VOWIFI
7752 /* handlers for sub-ioctl */
7753 { WE_NEIGHBOR_REPORT_REQUEST,
7754 IW_PRIV_TYPE_CHAR | 512,
7755 0,
7756 "neighbor" },
7757#endif
7758 { WE_SET_AP_WPS_IE,
7759 IW_PRIV_TYPE_CHAR| 512,
7760 0,
7761 "set_ap_wps_ie" },
7762
7763 { WE_SET_CONFIG,
7764 IW_PRIV_TYPE_CHAR| 512,
7765 0,
7766 "setConfig" },
7767
7768 /* handlers for main ioctl */
7769 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7770 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7771 0,
7772 "" },
7773
7774 /* handlers for sub-ioctl */
7775 { WE_SET_WLAN_DBG,
7776 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7777 0,
7778 "setwlandbg" },
7779
Jeff Johnson295189b2012-06-20 16:38:30 -07007780 { WE_SET_WDI_DBG,
7781 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7782 0,
7783 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007784
7785 { WE_SET_SAP_CHANNELS,
7786 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7787 0,
7788 "setsapchannels" },
7789
7790 /* handlers for main ioctl */
7791 { WLAN_PRIV_GET_CHAR_SET_NONE,
7792 0,
7793 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7794 "" },
7795
7796 /* handlers for sub-ioctl */
7797 { WE_WLAN_VERSION,
7798 0,
7799 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7800 "version" },
7801 { WE_GET_STATS,
7802 0,
7803 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7804 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307805 { WE_GET_STATES,
7806 0,
7807 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7808 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 { WE_GET_CFG,
7810 0,
7811 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7812 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007813#ifdef WLAN_FEATURE_11AC
7814 { WE_GET_RSSI,
7815 0,
7816 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7817 "getRSSI" },
7818#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007819#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
7820 { WE_GET_ROAM_RSSI,
7821 0,
7822 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7823 "getRoamRSSI" },
7824#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 { WE_GET_WMM_STATUS,
7826 0,
7827 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7828 "getWmmStatus" },
7829 {
7830 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307831 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007832 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7833 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007834#ifdef FEATURE_WLAN_TDLS
7835 {
7836 WE_GET_TDLS_PEERS,
7837 0,
7838 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7839 "getTdlsPeers" },
7840#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007841#ifdef WLAN_FEATURE_11W
7842 {
7843 WE_GET_11W_INFO,
7844 0,
7845 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7846 "getPMFInfo" },
7847#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 /* handlers for main ioctl */
7849 { WLAN_PRIV_SET_NONE_GET_NONE,
7850 0,
7851 0,
7852 "" },
7853
7854 /* handlers for sub-ioctl */
7855 { WE_CLEAR_STATS,
7856 0,
7857 0,
7858 "clearStats" },
7859 { WE_INIT_AP,
7860 0,
7861 0,
7862 "initAP" },
7863 { WE_STOP_AP,
7864 0,
7865 0,
7866 "exitAP" },
7867 { WE_ENABLE_AMP,
7868 0,
7869 0,
7870 "enableAMP" },
7871 { WE_DISABLE_AMP,
7872 0,
7873 0,
7874 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007875 { WE_ENABLE_DXE_STALL_DETECT,
7876 0,
7877 0,
7878 "dxeStallDetect" },
7879 { WE_DISPLAY_DXE_SNAP_SHOT,
7880 0,
7881 0,
7882 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307883 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7884 0,
7885 0,
7886 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007887 {
7888 WE_SET_REASSOC_TRIGGER,
7889 0,
7890 0,
7891 "reassoc" },
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307892 {
7893 WE_STOP_OBSS_SCAN,
7894 0,
7895 0,
7896 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007897
7898 /* handlers for main ioctl */
7899 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7900 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7901 0,
7902 "" },
7903
7904 /* handlers for sub-ioctl */
7905 { WE_LOG_DUMP_CMD,
7906 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7907 0,
7908 "dump" },
7909
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007910 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307911 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
7912 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7913 0,
7914 "setdumplog" },
7915
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007916 { WE_MTRACE_DUMP_CMD,
7917 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7918 0,
7919 "dumplog" },
7920
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007921 /* handlers for sub ioctl */
7922 {
7923 WE_MCC_CONFIG_CREDENTIAL,
7924 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7925 0,
7926 "setMccCrdnl" },
7927
7928 /* handlers for sub ioctl */
7929 {
7930 WE_MCC_CONFIG_PARAMS,
7931 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7932 0,
7933 "setMccConfig" },
7934
Chilam NG571c65a2013-01-19 12:27:36 +05307935#ifdef FEATURE_WLAN_TDLS
7936 /* handlers for sub ioctl */
7937 {
7938 WE_TDLS_CONFIG_PARAMS,
7939 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7940 0,
7941 "setTdlsConfig" },
7942#endif
7943
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 /* handlers for main ioctl */
7945 { WLAN_PRIV_ADD_TSPEC,
7946 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7947 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7948 "addTspec" },
7949
7950 /* handlers for main ioctl */
7951 { WLAN_PRIV_DEL_TSPEC,
7952 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7953 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7954 "delTspec" },
7955
7956 /* handlers for main ioctl */
7957 { WLAN_PRIV_GET_TSPEC,
7958 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7959 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7960 "getTspec" },
7961
Jeff Johnsone7245742012-09-05 17:12:55 -07007962#ifdef FEATURE_OEM_DATA_SUPPORT
7963 /* handlers for main ioctl - OEM DATA */
7964 {
7965 WLAN_PRIV_SET_OEM_DATA_REQ,
7966 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7967 0,
7968 "set_oem_data_req" },
7969
7970 /* handlers for main ioctl - OEM DATA */
7971 {
7972 WLAN_PRIV_GET_OEM_DATA_RSP,
7973 0,
7974 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7975 "get_oem_data_rsp" },
7976#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007977
7978#ifdef FEATURE_WLAN_WAPI
7979 /* handlers for main ioctl SET_WAPI_MODE */
7980 { WLAN_PRIV_SET_WAPI_MODE,
7981 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7982 0,
7983 "SET_WAPI_MODE" },
7984
7985 /* handlers for main ioctl GET_WAPI_MODE */
7986 { WLAN_PRIV_GET_WAPI_MODE,
7987 0,
7988 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7989 "GET_WAPI_MODE" },
7990
7991 /* handlers for main ioctl SET_ASSOC_INFO */
7992 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
7993 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
7994 0,
7995 "SET_WAPI_ASSOC" },
7996
7997 /* handlers for main ioctl SET_WAPI_KEY */
7998 { WLAN_PRIV_SET_WAPI_KEY,
7999 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8000 0,
8001 "SET_WAPI_KEY" },
8002
8003 /* handlers for main ioctl SET_WAPI_BKID */
8004 { WLAN_PRIV_SET_WAPI_BKID,
8005 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8006 0,
8007 "SET_WAPI_BKID" },
8008
8009 /* handlers for main ioctl GET_WAPI_BKID */
8010 { WLAN_PRIV_GET_WAPI_BKID,
8011 0,
8012 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8013 "GET_WAPI_BKID" },
8014#endif /* FEATURE_WLAN_WAPI */
8015
8016 /* handlers for main ioctl - host offload */
8017 {
8018 WLAN_PRIV_SET_HOST_OFFLOAD,
8019 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8020 0,
8021 "setHostOffload" },
8022
8023 {
8024 WLAN_GET_WLAN_STATISTICS,
8025 0,
8026 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8027 "getWlanStats" },
8028
8029 {
8030 WLAN_SET_KEEPALIVE_PARAMS,
8031 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8032 0,
8033 "setKeepAlive" },
8034#ifdef WLAN_FEATURE_PACKET_FILTERING
8035 {
8036 WLAN_SET_PACKET_FILTER_PARAMS,
8037 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8038 0,
8039 "setPktFilter" },
8040#endif
8041#ifdef FEATURE_WLAN_SCAN_PNO
8042 {
8043 WLAN_SET_PNO,
8044 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8045 0,
8046 "setpno" },
8047#endif
8048 {
8049 WLAN_SET_BAND_CONFIG,
8050 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8051 0,
8052 "SETBAND" },
8053 /* handlers for dynamic MC BC ioctl */
8054 {
8055 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008056 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008057 0,
8058 "setMCBCFilter" },
8059 {
8060 WLAN_PRIV_CLEAR_MCBC_FILTER,
8061 0,
8062 0,
8063 "clearMCBCFilter" },
8064 {
8065 WLAN_SET_POWER_PARAMS,
8066 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8067 0,
8068 "setpowerparams" },
8069 {
8070 WLAN_GET_LINK_SPEED,
8071 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308072 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008073};
8074
8075
8076
8077const struct iw_handler_def we_handler_def = {
8078 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8079 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8080 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8081
8082 .standard = (iw_handler *)we_handler,
8083 .private = (iw_handler *)we_private,
8084 .private_args = we_private_args,
8085 .get_wireless_stats = get_wireless_stats,
8086};
8087
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008088int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8089{
8090 v_U32_t cmd = 288; //Command to RIVA
8091 hdd_context_t *pHddCtx = NULL;
8092 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8093 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8094 /*
8095 *configMccParam : specify the bit which needs to be modified
8096 *allowed to update based on wlan_qcom_cfg.ini
8097 * configuration
8098 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8099 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8100 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8101 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8102 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8103 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8104 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8105 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8106 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8107 * Bit 9 : Reserved
8108 */
8109 switch (arg1)
8110 {
8111 //Update MCC SCHEDULE_TIME_SLICE parameter
8112 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8113 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8114 {
8115 if((arg2 >= 5) && (arg2 <= 20))
8116 {
8117 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8118 }
8119 else
8120 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008121 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008122 return 0;
8123 }
8124 }
8125 break;
8126
8127 //Update MCC MAX_NULL_SEND_TIME parameter
8128 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8129 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8130 {
8131 if((arg2 >= 1) && (arg2 <= 10))
8132 {
8133 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8134 }
8135 else
8136 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008137 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008138 return 0;
8139 }
8140 }
8141 break;
8142
8143 //Update MCC TX_EARLY_STOP_TIME parameter
8144 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8145 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8146 {
8147 if((arg2 >= 1) && (arg2 <= 10))
8148 {
8149 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8150 }
8151 else
8152 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008153 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008154 return 0;
8155 }
8156 }
8157 break;
8158
8159 //Update MCC RX_DRAIN_TIME parameter
8160 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8161 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8162 {
8163 if((arg2 >= 1) && (arg2 <= 10))
8164 {
8165 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8166 }
8167 else
8168 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008169 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008170 return 0;
8171 }
8172 }
8173 break;
8174
8175 //Update MCC CHANNEL_SWITCH_TIME parameter
8176 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8177 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8178 {
8179 if((arg2 >= 1) && (arg2 <= 20))
8180 {
8181 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8182 }
8183 else
8184 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008185 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008186 return 0;
8187 }
8188 }
8189 break;
8190
8191 //Update MCC MIN_CHANNEL_TIME parameter
8192 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8193 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8194 {
8195 if((arg2 >= 5) && (arg2 <= 20))
8196 {
8197 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8198 }
8199 else
8200 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008201 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008202 return 0;
8203 }
8204 }
8205 break;
8206
8207 //Update MCC PARK_BEFORE_TBTT parameter
8208 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8209 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8210 {
8211 if((arg2 >= 1) && (arg2 <= 5))
8212 {
8213 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8214 }
8215 else
8216 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008217 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008218 return 0;
8219 }
8220 }
8221 break;
8222
8223 //Update MCC MIN_AFTER_DTIM parameter
8224 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8225 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8226 {
8227 if((arg2 >= 5) && (arg2 <= 15))
8228 {
8229 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8230 }
8231 else
8232 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008233 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008234 return 0;
8235 }
8236 }
8237 break;
8238
8239 //Update MCC TOO_CLOSE_MARGIN parameter
8240 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8241 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8242 {
8243 if((arg2 >= 1) && (arg2 <= 3))
8244 {
8245 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8246 }
8247 else
8248 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008249 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008250 return 0;
8251 }
8252 }
8253 break;
8254
8255 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008256 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008257 __FUNCTION__,arg1);
8258 break;
8259 }
8260 return 0;
8261}
8262
Jeff Johnson295189b2012-06-20 16:38:30 -07008263int hdd_set_wext(hdd_adapter_t *pAdapter)
8264{
8265 hdd_wext_state_t *pwextBuf;
8266 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008267 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008268
8269 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8270
8271 // Now configure the roaming profile links. To SSID and bssid.
8272 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8273 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8274
8275 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8276 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8277
8278 /*Set the numOfChannels to zero to scan all the channels*/
8279 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8280 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8281
8282 /* Default is no encryption */
8283 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8284 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8285
8286 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8287 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8288
8289 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8290
8291 /* Default is no authentication */
8292 pwextBuf->roamProfile.AuthType.numEntries = 1;
8293 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8294
8295 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8296 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8297
8298 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008299 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008300
8301 hdd_clearRoamProfileIe(pAdapter);
8302
8303 return VOS_STATUS_SUCCESS;
8304
8305 }
8306
8307int hdd_register_wext(struct net_device *dev)
8308 {
8309 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8310 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8311 VOS_STATUS status;
8312
8313 ENTER();
8314
8315 // Zero the memory. This zeros the profile structure.
8316 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8317
8318 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8319
8320
8321 status = hdd_set_wext(pAdapter);
8322
8323 if(!VOS_IS_STATUS_SUCCESS(status)) {
8324
Arif Hussain6d2a3322013-11-17 19:50:10 -08008325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 return eHAL_STATUS_FAILURE;
8327 }
8328
8329 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8330 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 return eHAL_STATUS_FAILURE;
8333 }
8334
8335 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8336 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 return eHAL_STATUS_FAILURE;
8339 }
8340
8341 // Register as a wireless device
8342 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8343
8344 EXIT();
8345 return 0;
8346}
8347
8348int hdd_UnregisterWext(struct net_device *dev)
8349{
8350#if 0
8351 hdd_wext_state_t *wextBuf;
8352 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8353
8354 ENTER();
8355 // Set up the pointer to the Wireless Extensions state structure
8356 wextBuf = pAdapter->pWextState;
8357
8358 // De-allocate the Wireless Extensions state structure
8359 kfree(wextBuf);
8360
8361 // Clear out the pointer to the Wireless Extensions state structure
8362 pAdapter->pWextState = NULL;
8363
8364 EXIT();
8365#endif
8366 dev->wireless_handlers = NULL;
8367 return 0;
8368}
8369
8370