blob: ac8027ec76f63fcfac2d04323748ed0449e7bf36 [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 {
5018 pr_info("Init AP trigger\n");
5019 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5020 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5021 break;
5022 }
5023 case WE_STOP_AP:
5024 {
5025 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5026 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5027 * this is a dead code and need to find the adpater by name rather than mode */
5028 hdd_adapter_t* pAdapter_to_stop =
5029 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5030 if( pAdapter_to_stop )
5031 {
5032 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5033
5034 pr_info("Stopping AP mode\n");
5035
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305036 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5037 {
5038 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5039 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5040 }
5041
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 /*Make sure that pAdapter cleaned properly*/
5043 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5044 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5045 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5046
5047 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5048 pAdapter_to_stop->macAddressCurrent.bytes);
5049 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5050 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305051
5052 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5053 {
5054 /* put the device back into BMPS */
5055 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 }
5058 else
5059 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005060 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 }
5062
5063 break;
5064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005065#ifdef WLAN_BTAMP_FEATURE
5066 case WE_ENABLE_AMP:
5067 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 WLANBAP_RegisterWithHCI(pAdapter);
5070 break;
5071 }
5072 case WE_DISABLE_AMP:
5073 {
5074 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5075 VOS_STATUS status;
5076
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005078
5079 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5080 status = WLANBAP_StopAmp();
5081 if(VOS_STATUS_SUCCESS != status )
5082 {
5083 pHddCtx->isAmpAllowed = VOS_TRUE;
5084 hddLog(VOS_TRACE_LEVEL_FATAL,
5085 "%s: Failed to stop AMP", __func__);
5086 }
5087 else
5088 {
5089 //a state m/c implementation in PAL is TBD to avoid this delay
5090 msleep(500);
5091 pHddCtx->isAmpAllowed = VOS_FALSE;
5092 WLANBAP_DeregisterFromHCI();
5093 }
5094
5095 break;
5096 }
5097#endif
5098
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005099 case WE_ENABLE_DXE_STALL_DETECT:
5100 {
schang6295e542013-03-12 15:31:23 -07005101 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5102 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005103 break;
5104 }
5105 case WE_DISPLAY_DXE_SNAP_SHOT:
5106 {
schang6295e542013-03-12 15:31:23 -07005107 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5108 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005109 break;
5110 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305111 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5112 {
5113 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5114 hdd_wmm_tx_snapshot(pAdapter);
5115 WLANTL_TLDebugMessage(VOS_TRUE);
5116 break;
5117 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07005118 case WE_SET_REASSOC_TRIGGER:
5119 {
5120 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5121 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5122 v_U32_t roamId = 0;
5123 tCsrRoamModifyProfileFields modProfileFields;
5124 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5125 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5126 return 0;
5127 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305128
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305129 case WE_STOP_OBSS_SCAN:
5130 {
5131 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5132 2.OBSS scan is stopped by Firmware during the disassociation
5133 3.OBSS stop comamnd is added for debugging purpose*/
5134 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5135 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005136
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305137 if (pAdapter == NULL)
5138 {
5139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5140 " pAdapter is NULL ");
5141 }
5142 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5143 if (pMac == NULL)
5144 {
5145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5146 " pMac is NULL ");
5147 }
5148 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5149 }
5150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 default:
5152 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005153 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 break;
5155 }
5156 }
5157
5158 return ret;
5159}
5160
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305161void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5162{
5163 /*
5164 * Function to display HDD WMM information
5165 * for Tx Queues.
5166 * Prints globala as well as per client depending
5167 * whether the clients are registered or not.
5168 */
5169 int i = 0, j = 0;
5170 for ( i=0; i< NUM_TX_QUEUES; i++)
5171 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305172 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005173 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305174 i, pAdapter->wmm_tx_queue[i].count,
5175 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305176 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305177 }
5178
5179 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5180 {
5181 if(pAdapter->aStaInfo[i].isUsed)
5182 {
5183 hddLog(LOGE, "******STAIndex: %d*********", i);
5184 for ( j=0; j< NUM_TX_QUEUES; j++)
5185 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305186 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005187 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305188 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5189 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5190 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305191 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305192 }
5193 }
5194 }
5195
5196}
Jeff Johnson295189b2012-06-20 16:38:30 -07005197int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5198 union iwreq_data *wrqu, char *extra)
5199{
5200 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5201 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5202 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005203 int apps_args[MAX_VAR_ARGS] = {0};
5204 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005205 hdd_station_ctx_t *pStaCtx = NULL ;
5206 hdd_ap_ctx_t *pAPCtx = NULL;
5207 int cmd = 0;
5208 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005209
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005210 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005211
5212 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5213 {
5214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5215 "%s:LOGP in Progress. Ignore!!!", __func__);
5216 return -EBUSY;
5217 }
5218
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 if (num_args > MAX_VAR_ARGS)
5220 {
5221 num_args = MAX_VAR_ARGS;
5222 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005223
5224 /* ODD number is used for set, copy data using copy_from_user */
5225 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5226 {
5227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5228 "%s: failed to copy data to user buffer", __func__);
5229 return -EFAULT;
5230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005231
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005232 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5233 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5234 {
5235 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5236 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5237 {
5238 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5239 staId = pStaCtx->conn_info.staId[0];
5240 }
5241 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5242 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5243 {
5244 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5245 staId = pAPCtx->uBCStaId;
5246 }
5247 else
5248 {
5249 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5250 return 0;
5251 }
5252 }
5253
Jeff Johnson295189b2012-06-20 16:38:30 -07005254 switch (sub_cmd)
5255 {
5256 case WE_LOG_DUMP_CMD:
5257 {
5258 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005259 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 apps_args[3], apps_args[4]);
5261
5262 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5263 apps_args[3], apps_args[4]);
5264
5265 }
5266 break;
5267
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 case WE_P2P_NOA_CMD:
5269 {
5270 p2p_app_setP2pPs_t p2pNoA;
5271
5272 p2pNoA.opp_ps = apps_args[0];
5273 p2pNoA.ctWindow = apps_args[1];
5274 p2pNoA.duration = apps_args[2];
5275 p2pNoA.interval = apps_args[3];
5276 p2pNoA.count = apps_args[4];
5277 p2pNoA.single_noa_duration = apps_args[5];
5278 p2pNoA.psSelection = apps_args[6];
5279
5280 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5281 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005282 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5284
5285 hdd_setP2pPs(dev, &p2pNoA);
5286
5287 }
5288 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005289
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305290 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5291 {
5292 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5293 __func__, apps_args[0], apps_args[1]);
5294 vosTraceEnable(apps_args[0], apps_args[1]);
5295 }
5296 break;
5297
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005298 case WE_MTRACE_DUMP_CMD:
5299 {
5300 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5301 "bitmask_of_module %d ",
5302 __func__, apps_args[0], apps_args[1], apps_args[2],
5303 apps_args[3]);
5304 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5305 apps_args[2], apps_args[3]);
5306
5307 }
5308 break;
5309
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005310 case WE_MCC_CONFIG_CREDENTIAL :
5311 {
5312 cmd = 287; //Command should be updated if there is any change
5313 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005314 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005315 {
5316 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5317 }
5318 else
5319 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005320 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005321 return 0;
5322 }
5323 }
5324 break;
5325
5326 case WE_MCC_CONFIG_PARAMS :
5327 {
5328 cmd = 288; //command Should be updated if there is any change
5329 // in the Riva dump command
5330 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5331 }
5332 break;
5333
Chilam NG571c65a2013-01-19 12:27:36 +05305334#ifdef FEATURE_WLAN_TDLS
5335 case WE_TDLS_CONFIG_PARAMS :
5336 {
5337 tdls_config_params_t tdlsParams;
5338
Chilam Ng01120412013-02-19 18:32:21 -08005339 tdlsParams.tdls = apps_args[0];
5340 tdlsParams.tx_period_t = apps_args[1];
5341 tdlsParams.tx_packet_n = apps_args[2];
5342 tdlsParams.discovery_period_t = apps_args[3];
5343 tdlsParams.discovery_tries_n = apps_args[4];
5344 tdlsParams.idle_timeout_t = apps_args[5];
5345 tdlsParams.idle_packet_n = apps_args[6];
5346 tdlsParams.rssi_hysteresis = apps_args[7];
5347 tdlsParams.rssi_trigger_threshold = apps_args[8];
5348 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305349
Chilam Ng01120412013-02-19 18:32:21 -08005350 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305351 }
5352 break;
5353#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 default:
5355 {
5356 hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd );
5357 }
5358 break;
5359 }
5360
5361 return 0;
5362}
5363
5364
5365static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5366 union iwreq_data *wrqu, char *extra)
5367{
5368 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5369 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5370 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5371 int params[HDD_WLAN_WMM_PARAM_COUNT];
5372 sme_QosWmmTspecInfo tSpec;
5373 v_U32_t handle;
5374
5375 // make sure the application is sufficiently priviledged
5376 // note that the kernel will do this for "set" ioctls, but since
5377 // this ioctl wants to return status to user space it must be
5378 // defined as a "get" ioctl
5379 if (!capable(CAP_NET_ADMIN))
5380 {
5381 return -EPERM;
5382 }
5383
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005384 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5385 {
5386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5387 "%s:LOGP in Progress. Ignore!!!", __func__);
5388 return -EBUSY;
5389 }
5390
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 // we must be associated in order to add a tspec
5392 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5393 {
5394 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5395 return 0;
5396 }
5397
5398 // since we are defined to be a "get" ioctl, and since the number
5399 // of params exceeds the number of params that wireless extensions
5400 // will pass down in the iwreq_data, we must copy the "set" params
5401 // from user space ourselves
5402 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5403 {
5404 // hmmm, can't get them
5405 return -EIO;
5406 }
5407
5408 // clear the tspec
5409 memset(&tSpec, 0, sizeof(tSpec));
5410
5411 // validate the handle
5412 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5413 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5414 {
5415 // that one is reserved
5416 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5417 return 0;
5418 }
5419
5420 // validate the TID
5421 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5422 {
5423 // out of range
5424 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5425 return 0;
5426 }
5427 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5428
5429 // validate the direction
5430 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5431 {
5432 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5433 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5434 break;
5435
5436 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5437 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5438 break;
5439
5440 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5441 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5442 break;
5443
5444 default:
5445 // unknown
5446 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5447 return 0;
5448 }
5449
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305450 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5451
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 // validate the user priority
5453 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5454 {
5455 // out of range
5456 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5457 return 0;
5458 }
5459 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305460 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5461 {
5462 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5463 return 0;
5464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005465
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5467 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5468 tSpec.ts_info.psb, tSpec.ts_info.up);
5469
Jeff Johnson295189b2012-06-20 16:38:30 -07005470 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5471 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5472 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5473 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5474 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5475 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5476 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5477 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5478 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5479 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5480 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5481 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5482
5483 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5484
5485 // validate the ts info ack policy
5486 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5487 {
5488 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5489 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5490 break;
5491
5492 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5493 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5494 break;
5495
5496 default:
5497 // unknown
5498 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5499 return 0;
5500 }
5501
5502 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5503 return 0;
5504}
5505
5506
5507static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5508 union iwreq_data *wrqu, char *extra)
5509{
5510 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5511 int *params = (int *)extra;
5512 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5513 v_U32_t handle;
5514
5515 // make sure the application is sufficiently priviledged
5516 // note that the kernel will do this for "set" ioctls, but since
5517 // this ioctl wants to return status to user space it must be
5518 // defined as a "get" ioctl
5519 if (!capable(CAP_NET_ADMIN))
5520 {
5521 return -EPERM;
5522 }
5523
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005524 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5525 {
5526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5527 "%s:LOGP in Progress. Ignore!!!", __func__);
5528 return -EBUSY;
5529 }
5530
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 // although we are defined to be a "get" ioctl, the params we require
5532 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5533 // is no need to copy the params from user space
5534
5535 // validate the handle
5536 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5537 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5538 {
5539 // that one is reserved
5540 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5541 return 0;
5542 }
5543
5544 *pStatus = hdd_wmm_delts(pAdapter, handle);
5545 return 0;
5546}
5547
5548
5549static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5550 union iwreq_data *wrqu, char *extra)
5551{
5552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5553 int *params = (int *)extra;
5554 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5555 v_U32_t handle;
5556
5557 // although we are defined to be a "get" ioctl, the params we require
5558 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5559 // is no need to copy the params from user space
5560
5561 // validate the handle
5562 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5563 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5564 {
5565 // that one is reserved
5566 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5567 return 0;
5568 }
5569
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005570 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5571 {
5572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5573 "%s:LOGP in Progress. Ignore!!!", __func__);
5574 return -EBUSY;
5575 }
5576
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5578 return 0;
5579}
5580
5581
5582#ifdef FEATURE_WLAN_WAPI
5583static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5584 union iwreq_data *wrqu, char *extra)
5585{
5586 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5587 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5588 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5589 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5590
Arif Hussain7adce1b2013-11-11 22:59:34 -08005591 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005592
5593 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005594 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005595 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5596 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005597
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005598 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5599 {
5600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5601 "%s:LOGP in Progress. Ignore!!!", __func__);
5602 return -EBUSY;
5603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005604
5605 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005606 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5608 pRoamProfile->EncryptionType.numEntries = 1;
5609 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5610 pRoamProfile->mcEncryptionType.numEntries = 1;
5611 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5612
5613 pRoamProfile->AuthType.numEntries = 1;
5614 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5615 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5616 }
5617 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005618 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 }
5620 else
5621 return -EINVAL;
5622
5623 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5624
5625 return 0;
5626}
5627
5628static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5629 union iwreq_data *wrqu, char *extra)
5630{
5631 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5632 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5633
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005634 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5635 {
5636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5637 "%s:LOGP in Progress. Ignore!!!", __func__);
5638 return -EBUSY;
5639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5641
5642 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005643 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 return 0;
5645}
5646
5647static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5648 union iwreq_data *wrqu, char *extra)
5649{
5650 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5651// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5652 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5653 int i = 0, j = 0;
5654 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005655 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005656 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005657
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005658 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5659 {
5660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5661 "%s:LOGP in Progress. Ignore!!!", __func__);
5662 return -EBUSY;
5663 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005664
5665 if (NULL == pWapiAssocInfo)
5666 {
5667 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5668 "%s: WDA NULL context", __func__);
5669 VOS_ASSERT(0);
5670 return VOS_STATUS_E_FAILURE;
5671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005672
Arif Hussain6d2a3322013-11-17 19:50:10 -08005673 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 -07005674 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005675 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005676 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005677
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005678 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005680 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005681
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005682 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005683 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 for(i = 0 ; i < 16 ; i++) {
5685 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5686 for(j = 0 ; j < 16 ; j++)
5687 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5688 }
5689
5690 /* We are not using the entire IE as provided by the supplicant.
5691 * This is being calculated by SME. This is the same as in the
5692 * case of WPA. Only the auth mode information needs to be
5693 * extracted here*/
5694 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005695 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5697 }
5698
5699 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005700 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5702 }
5703 return 0;
5704}
5705
5706static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5707 union iwreq_data *wrqu, char *extra)
5708{
5709 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5710 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5711 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5712 tANI_U32 roamId = 0xFF;
5713 tANI_U8 *pKeyPtr = NULL;
5714 v_BOOL_t isConnected = TRUE;
5715 tCsrRoamSetKey setKey;
5716 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5718
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005719 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5720 {
5721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5722 "%s:LOGP in Progress. Ignore!!!", __func__);
5723 return -EBUSY;
5724 }
5725
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005727 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005728 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005729
Arif Hussain6d2a3322013-11-17 19:50:10 -08005730 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 -07005731 hddLog(LOG1,"Add Index:0x");
5732 for(i =0 ; i < 12 ; i++)
5733 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5734
Arif Hussain6d2a3322013-11-17 19:50:10 -08005735 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005736 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5737 for(i =0 ; i < 16 ; i++)
5738 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5739
Arif Hussain6d2a3322013-11-17 19:50:10 -08005740 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5742 for(i =0 ; i < 16 ; i++)
5743 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5744
Arif Hussain6d2a3322013-11-17 19:50:10 -08005745 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 for(i = 0 ; i < 16 ; i++)
5747 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5748
5749 // Clear the setkey memory
5750 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5751 // Store Key ID
5752 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5753 // SET WAPI Encryption
5754 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5755 // Key Directionn both TX and RX
5756 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5757 // the PAE role
5758 setKey.paeRole = 0 ;
5759
5760 switch ( pWapiKey->keyType )
5761 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005762 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 {
5764 isConnected = hdd_connIsConnected(pHddStaCtx);
5765 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5766 break;
5767 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005768 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 {
5770 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5771 break;
5772 }
5773 default:
5774 {
5775 //Any other option is invalid.
5776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005777 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005778
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005779 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5781 break; // NEED RETURN FROM HERE ????
5782 }
5783 }
5784
5785 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5786 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5787 pKeyPtr = setKey.Key;
5788 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5789 pKeyPtr += pWapiKey->wpiekLen;
5790 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5791
5792 // Set the new key with SME.
5793 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5794
5795 if ( isConnected ) {
5796 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5797 if ( halStatus != eHAL_STATUS_SUCCESS )
5798 {
5799 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5800 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5801
5802 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5803 }
5804 }
5805#if 0 /// NEED TO CHECK ON THIS
5806 else
5807 {
5808 // Store the keys in the adapter to be moved to the profile & passed to
5809 // SME in the ConnectRequest if we are not yet in connected state.
5810 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5811 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5812
5813 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5814 " Saving key [idx= %d] to apply when moving to connected state ",
5815 setKey.keyId );
5816
5817 }
5818#endif
5819 return halStatus;
5820}
5821
5822static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5823 union iwreq_data *wrqu, char *extra)
5824{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005825 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005826#ifdef WLAN_DEBUG
5827 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005828 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005829#endif
5830
5831 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005832 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005833 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005834
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005835 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5836 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005837
5838 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005839
5840 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5841 {
5842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5843 "%s:LOGP in Progress. Ignore!!!", __func__);
5844 return -EBUSY;
5845 }
5846
Jeff Johnson295189b2012-06-20 16:38:30 -07005847#ifdef WLAN_DEBUG
5848 for(i =0 ; i < 16 ; i++)
5849 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5850#endif
5851
5852 return 0;
5853}
5854
5855static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5856 union iwreq_data *wrqu, char *extra)
5857{
5858 /* Yet to implement this function, 19th April 2010 */
5859 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5860
5861 return 0;
5862}
5863#endif /* FEATURE_WLAN_WAPI */
5864
5865#ifdef WLAN_FEATURE_VOWIFI_11R
5866//
5867//
5868// Each time the supplicant has the auth_request or reassoc request
5869// IEs ready. This is pushed to the driver. The driver will inturn use
5870// it to send out the auth req and reassoc req for 11r FT Assoc.
5871//
5872static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5873 union iwreq_data *wrqu, char *extra)
5874{
5875 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5876 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5877 //v_CONTEXT_t pVosContext;
5878
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005879 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5880 {
5881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5882 "%s:LOGP in Progress. Ignore!!!", __func__);
5883 return -EBUSY;
5884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 if (!wrqu->data.length)
5886 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005887 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 return -EINVAL;
5889 }
5890 if (wrqu->data.pointer == NULL)
5891 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005892 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 return -EINVAL;
5894 }
5895
5896 // Added for debug on reception of Re-assoc Req.
5897 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5898 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005899 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005901 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 }
5903
5904#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005905 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005906#endif
5907
5908 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005909 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 wrqu->data.length);
5911
5912 return 0;
5913}
5914#endif
5915
Amar Singhalf3a6e762013-02-19 15:06:50 -08005916static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005917 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005919{
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005921 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005923 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005924 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005925 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5926 int idx;
5927 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005928
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005929 if (pHddCtx->isLogpInProgress)
5930 {
5931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5932 "%s:LOGP in Progress. Ignore!!!", __func__);
5933 return -EBUSY;
5934 }
5935
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305936 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5937 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305938#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005939
Amar Singhalf3a6e762013-02-19 15:06:50 -08005940 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5941 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005942 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005943 hddLog(VOS_TRACE_LEVEL_ERROR,
5944 "%s: vos_mem_alloc failed", __func__);
5945 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005946 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005947
5948 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5949
5950 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5951 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5952
5953 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5954 mc_addr_list_ptr->ulMulticastAddrCnt);
5955
5956 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005957 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005958 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5959 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5960
5961 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5962 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005963 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005964
Amar Singhalf3a6e762013-02-19 15:06:50 -08005965 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5966 vos_mem_free(mc_addr_list_ptr);
5967 if (eHAL_STATUS_SUCCESS != ret_val)
5968 {
5969 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5970 __func__);
5971 return -EINVAL;
5972 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305973#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305974 }
5975 else
5976 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005977
Amar Singhalf3a6e762013-02-19 15:06:50 -08005978 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5979 "%s: Set MC BC Filter Config request: %d suspend %d",
5980 __func__, pRequest->mcastBcastFilterSetting,
5981 pHddCtx->hdd_wlan_suspended);
5982
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305983 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005984
5985 if (pHddCtx->hdd_wlan_suspended)
5986 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005987 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5988 if (NULL == wlanRxpFilterParam)
5989 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305990 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005991 "%s: vos_mem_alloc failed", __func__);
5992 return -EINVAL;
5993 }
5994
Amar Singhalf3a6e762013-02-19 15:06:50 -08005995 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5996 pRequest->mcastBcastFilterSetting;
5997 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5998
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305999 hdd_conf_hostoffload(pAdapter, TRUE);
6000 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6001 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006002
6003 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6004 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306005 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006006 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6007 wlanRxpFilterParam->setMcstBcstFilter);
6008
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306009 if (eHAL_STATUS_SUCCESS !=
6010 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6011 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006012 {
6013 hddLog(VOS_TRACE_LEVEL_ERROR,
6014 "%s: Failure to execute set HW MC/BC Filter request",
6015 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006016 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006017 return -EINVAL;
6018 }
6019
Amar Singhalf3a6e762013-02-19 15:06:50 -08006020 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006022
6023 return 0;
6024}
6025
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006026static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006027 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 union iwreq_data *wrqu, char *extra)
6029{
6030 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6031 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306032 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006033 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006034
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306035 //Reset the filter to INI value as we have to clear the dynamic filter
6036 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006037
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306038 //Configure FW with new setting
6039 if (pHddCtx->hdd_wlan_suspended)
6040 {
6041 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6042 if (NULL == wlanRxpFilterParam)
6043 {
6044 hddLog(VOS_TRACE_LEVEL_ERROR,
6045 "%s: vos_mem_alloc failed", __func__);
6046 return -EINVAL;
6047 }
6048
6049 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6050 pHddCtx->configuredMcastBcastFilter;
6051 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6052
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306053 hdd_conf_hostoffload(pAdapter, TRUE);
6054 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6055 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306056
6057 if (eHAL_STATUS_SUCCESS !=
6058 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6059 wlanRxpFilterParam))
6060 {
6061 hddLog(VOS_TRACE_LEVEL_ERROR,
6062 "%s: Failure to execute set HW MC/BC Filter request",
6063 __func__);
6064 vos_mem_free(wlanRxpFilterParam);
6065 return -EINVAL;
6066 }
6067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 return 0;
6069}
6070
6071static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6072 union iwreq_data *wrqu, char *extra)
6073{
6074 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006075 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 tSirHostOffloadReq offloadRequest;
6077
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006078 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6079 {
6080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6081 "%s:LOGP in Progress. Ignore!!!", __func__);
6082 return -EBUSY;
6083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 /* Debug display of request components. */
6085 switch (pRequest->offloadType)
6086 {
6087 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006088 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 switch (pRequest->enableOrDisable)
6090 {
6091 case WLAN_OFFLOAD_DISABLE:
6092 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6093 break;
6094 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6095 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6096 case WLAN_OFFLOAD_ENABLE:
6097 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6098 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6099 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6100 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6101 }
6102 break;
6103
6104 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006105 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006106 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 switch (pRequest->enableOrDisable)
6108 {
6109 case WLAN_OFFLOAD_DISABLE:
6110 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6111 break;
6112 case WLAN_OFFLOAD_ENABLE:
6113 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6114 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6115 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6116 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6117 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6118 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6119 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6120 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6121 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6122 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6123 }
6124 }
6125
6126 /* Execute offload request. The reason that we can copy the request information
6127 from the ioctl structure to the SME structure is that they are laid out
6128 exactly the same. Otherwise, each piece of information would have to be
6129 copied individually. */
6130 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006131 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6132 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006134 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 __func__);
6136 return -EINVAL;
6137 }
6138
6139 return 0;
6140}
6141
6142static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6143 union iwreq_data *wrqu, char *extra)
6144{
6145 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006146 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 tSirKeepAliveReq keepaliveRequest;
6148
6149 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6150 {
6151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006152 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 return 0;
6154 }
6155
6156 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006157 hddLog(VOS_TRACE_LEVEL_INFO,
6158 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6159 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006160
6161 switch (pRequest->packetType)
6162 {
6163 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006164 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 break;
6166
6167 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6168
Arif Hussain6d2a3322013-11-17 19:50:10 -08006169 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006170 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006171
6172 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6173 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6174 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6175
6176 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6177 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6178 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6179
6180 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6181 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6182 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6183 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6184 break;
6185
6186 }
6187
6188 /* Execute keep alive request. The reason that we can copy the request information
6189 from the ioctl structure to the SME structure is that they are laid out
6190 exactly the same. Otherwise, each piece of information would have to be
6191 copied individually. */
6192 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6193
Arif Hussain6d2a3322013-11-17 19:50:10 -08006194 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006195
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006196 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006197 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006199 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 __func__);
6201 return -EINVAL;
6202 }
6203
6204 return 0;
6205}
6206
6207#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006208int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006209 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006210{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006211 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6212 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 int i=0;
6214
6215 if (pHddCtx->cfg_ini->disablePacketFilter)
6216 {
6217 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006218 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 return 0;
6220 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006221 if (pHddCtx->isLogpInProgress)
6222 {
6223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6224 "%s:LOGP in Progress. Ignore!!!", __func__);
6225 return -EBUSY;
6226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 /* Debug display of request components. */
6228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006229 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006230
6231 switch (pRequest->filterAction)
6232 {
6233 case HDD_RCV_FILTER_SET:
6234 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006235 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006236
6237 packetFilterSetReq.filterId = pRequest->filterId;
6238 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6239 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006240 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 __func__, pRequest->numParams);
6242 return -EINVAL;
6243 }
6244 packetFilterSetReq.numFieldParams = pRequest->numParams;
6245 packetFilterSetReq.coalesceTime = 0;
6246 packetFilterSetReq.filterType = 1;
6247 for (i=0; i < pRequest->numParams; i++)
6248 {
6249 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6250 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6251 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6252 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6253 packetFilterSetReq.paramsData[i].reserved = 0;
6254
Arif Hussain6d2a3322013-11-17 19:50:10 -08006255 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6257 packetFilterSetReq.filterType);
6258
Arif Hussain6d2a3322013-11-17 19:50:10 -08006259 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6261
6262 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6263 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6264 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6265 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6266
Arif Hussain6d2a3322013-11-17 19:50:10 -08006267 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6269 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6270 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6271
Arif Hussain6d2a3322013-11-17 19:50:10 -08006272 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6274 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6275 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6276 }
6277
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006278 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006280 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 __func__);
6282 return -EINVAL;
6283 }
6284
6285 break;
6286
6287 case HDD_RCV_FILTER_CLEAR:
6288
Arif Hussain6d2a3322013-11-17 19:50:10 -08006289 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006290 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006292 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006294 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 __func__);
6296 return -EINVAL;
6297 }
6298 break;
6299
6300 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006301 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006302 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 return -EINVAL;
6304 }
6305 return 0;
6306}
6307
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306308int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6309 tANI_U8 sessionId)
6310{
6311 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6312 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6313
6314 if (NULL == pHddCtx)
6315 {
6316 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6317 return -EINVAL;
6318 }
6319
6320 if (pHddCtx->isLogpInProgress)
6321 {
6322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6323 "%s:LOGP in Progress. Ignore!!!", __func__);
6324 return -EBUSY;
6325 }
6326
6327 if (pHddCtx->cfg_ini->disablePacketFilter)
6328 {
6329 hddLog(VOS_TRACE_LEVEL_ERROR,
6330 "%s: Packet Filtering Disabled. Returning ",
6331 __func__ );
6332 return -EINVAL;
6333 }
6334
6335 switch (filterType)
6336 {
6337 /* For setting IPV6 MC and UC Filter we need to configure
6338 * 2 filters, one for MC and one for UC.
6339 * The Filter ID shouldn't be swapped, which results in making
6340 * UC Filter ineffective.
6341 * We have Hardcode all the values
6342 *
6343 * Reason for a seperate UC filter is because, driver need to
6344 * specify the FW that the specific filter is for unicast
6345 * otherwise FW will not pass the unicast frames by default
6346 * through the filter. This is required to avoid any performance
6347 * hits when no unicast filter is set and only MC/BC are set.
6348 * The way driver informs host is by using the MAC protocol
6349 * layer, CMP flag set to MAX, CMP Data set to 1.
6350 */
6351
6352 case HDD_FILTER_IPV6_MC_UC:
6353 /* Setting IPV6 MC Filter below
6354 */
6355 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6356 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6357 packetFilterSetReq.numFieldParams = 2;
6358 packetFilterSetReq.paramsData[0].protocolLayer =
6359 HDD_FILTER_PROTO_TYPE_MAC;
6360 packetFilterSetReq.paramsData[0].cmpFlag =
6361 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6362 packetFilterSetReq.paramsData[0].dataOffset =
6363 WLAN_HDD_80211_FRM_DA_OFFSET;
6364 packetFilterSetReq.paramsData[0].dataLength = 1;
6365 packetFilterSetReq.paramsData[0].compareData[0] =
6366 HDD_IPV6_MC_CMP_DATA;
6367
6368 packetFilterSetReq.paramsData[1].protocolLayer =
6369 HDD_FILTER_PROTO_TYPE_ARP;
6370 packetFilterSetReq.paramsData[1].cmpFlag =
6371 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6372 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6373 packetFilterSetReq.paramsData[1].dataLength = 2;
6374 packetFilterSetReq.paramsData[1].compareData[0] =
6375 HDD_IPV6_CMP_DATA_0;
6376 packetFilterSetReq.paramsData[1].compareData[1] =
6377 HDD_IPV6_CMP_DATA_1;
6378
6379
6380 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6381 &packetFilterSetReq, sessionId))
6382 {
6383 hddLog(VOS_TRACE_LEVEL_ERROR,
6384 "%s: Failure to execute Set IPv6 Mulicast Filter",
6385 __func__);
6386 return -EINVAL;
6387 }
6388
6389 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6390
6391 /*
6392 * Setting IPV6 UC Filter below
6393 */
6394 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6395 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6396 packetFilterSetReq.numFieldParams = 2;
6397 packetFilterSetReq.paramsData[0].protocolLayer =
6398 HDD_FILTER_PROTO_TYPE_MAC;
6399 packetFilterSetReq.paramsData[0].cmpFlag =
6400 HDD_FILTER_CMP_TYPE_MAX;
6401 packetFilterSetReq.paramsData[0].dataOffset = 0;
6402 packetFilterSetReq.paramsData[0].dataLength = 1;
6403 packetFilterSetReq.paramsData[0].compareData[0] =
6404 HDD_IPV6_UC_CMP_DATA;
6405
6406 packetFilterSetReq.paramsData[1].protocolLayer =
6407 HDD_FILTER_PROTO_TYPE_ARP;
6408 packetFilterSetReq.paramsData[1].cmpFlag =
6409 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6410 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6411 packetFilterSetReq.paramsData[1].dataLength = 2;
6412 packetFilterSetReq.paramsData[1].compareData[0] =
6413 HDD_IPV6_CMP_DATA_0;
6414 packetFilterSetReq.paramsData[1].compareData[1] =
6415 HDD_IPV6_CMP_DATA_1;
6416
6417 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6418 &packetFilterSetReq, sessionId))
6419 {
6420 hddLog(VOS_TRACE_LEVEL_ERROR,
6421 "%s: Failure to execute Set IPv6 Unicast Filter",
6422 __func__);
6423 return -EINVAL;
6424 }
6425
6426 break;
6427
6428 case HDD_FILTER_IPV6_MC:
6429 /*
6430 * IPV6 UC Filter might be already set,
6431 * clear the UC Filter. As the Filter
6432 * IDs are static, we can directly clear it.
6433 */
6434 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6435 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6436 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6437 &packetFilterClrReq, sessionId))
6438 {
6439 hddLog(VOS_TRACE_LEVEL_ERROR,
6440 "%s: Failure to execute Clear IPv6 Unicast Filter",
6441 __func__);
6442 return -EINVAL;
6443 }
6444
6445 /*
6446 * Setting IPV6 MC Filter below
6447 */
6448 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6449 packetFilterSetReq.numFieldParams = 2;
6450 packetFilterSetReq.paramsData[0].protocolLayer =
6451 HDD_FILTER_PROTO_TYPE_MAC;
6452 packetFilterSetReq.paramsData[0].cmpFlag =
6453 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6454 packetFilterSetReq.paramsData[0].dataOffset =
6455 WLAN_HDD_80211_FRM_DA_OFFSET;
6456 packetFilterSetReq.paramsData[0].dataLength = 1;
6457 packetFilterSetReq.paramsData[0].compareData[0] =
6458 HDD_IPV6_MC_CMP_DATA;
6459
6460 packetFilterSetReq.paramsData[1].protocolLayer =
6461 HDD_FILTER_PROTO_TYPE_ARP;
6462 packetFilterSetReq.paramsData[1].cmpFlag =
6463 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6464 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6465 packetFilterSetReq.paramsData[1].dataLength = 2;
6466 packetFilterSetReq.paramsData[1].compareData[0] =
6467 HDD_IPV6_CMP_DATA_0;
6468 packetFilterSetReq.paramsData[1].compareData[1] =
6469 HDD_IPV6_CMP_DATA_1;
6470
6471
6472 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6473 &packetFilterSetReq, sessionId))
6474 {
6475 hddLog(VOS_TRACE_LEVEL_ERROR,
6476 "%s: Failure to execute Set IPv6 Multicast Filter",
6477 __func__);
6478 return -EINVAL;
6479 }
6480 break;
6481
6482 default :
6483 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6484 "%s: Packet Filter Request: Invalid",
6485 __func__);
6486 return -EINVAL;
6487 }
6488 return 0;
6489}
6490
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306491void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006492{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306493 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306494 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006495 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306496 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006497
Yue Ma3ede6052013-08-29 00:33:26 -07006498 if (NULL == pHddCtx)
6499 {
6500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6501 return;
6502 }
6503
6504 hHal = pHddCtx->hHal;
6505
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306506 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306508 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6509 return;
6510 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306511
6512 /* Check if INI is enabled or not, other wise just return
6513 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306514 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306515 {
6516 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6517 if (NULL == pMulticastAddrs)
6518 {
6519 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6520 return;
6521 }
6522
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 if (set)
6524 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306525 /* Following pre-conditions should be satisfied before wei
6526 * configure the MC address list.
6527 */
6528 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6529 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6530 && pAdapter->mc_addr_list.mc_cnt
6531 && (eConnectionState_Associated ==
6532 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6533 {
6534 pMulticastAddrs->ulMulticastAddrCnt =
6535 pAdapter->mc_addr_list.mc_cnt;
6536 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6537 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006538 memcpy(pMulticastAddrs->multicastAddr[i],
6539 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306540 sizeof(pAdapter->mc_addr_list.addr[i]));
6541 hddLog(VOS_TRACE_LEVEL_INFO,
6542 "%s: %s multicast filter: addr ="
6543 MAC_ADDRESS_STR,
6544 __func__, set ? "setting" : "clearing",
6545 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6546 }
6547 /* Set multicast filter */
6548 sme_8023MulticastList(hHal, pAdapter->sessionId,
6549 pMulticastAddrs);
6550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306552 else
6553 {
6554 /* Need to clear only if it was previously configured
6555 */
6556 if (pAdapter->mc_addr_list.isFilterApplied)
6557 {
6558 pMulticastAddrs->ulMulticastAddrCnt = 0;
6559 sme_8023MulticastList(hHal, pAdapter->sessionId,
6560 pMulticastAddrs);
6561 }
6562
6563 }
6564 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006565 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306567 else
6568 {
6569 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306570 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306571 }
6572 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006573}
6574
6575static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6576 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306577{
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006579 tpPacketFilterCfg pRequest = NULL;
6580 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006581
Arif Hussain0273cba2014-01-07 20:58:29 -08006582 /* ODD number is used for set, copy data using copy_from_user */
6583 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6584 wrqu->data.length);
6585 if (NULL == pRequest)
6586 {
6587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6588 "mem_alloc_copy_from_user_helper fail");
6589 return -ENOMEM;
6590 }
6591
6592 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6593 kfree(pRequest);
6594
6595 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006596}
6597#endif
6598static int iw_get_statistics(struct net_device *dev,
6599 struct iw_request_info *info,
6600 union iwreq_data *wrqu, char *extra)
6601{
6602
6603 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6604 eHalStatus status = eHAL_STATUS_SUCCESS;
6605 hdd_wext_state_t *pWextState;
6606 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6607 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6608 char *p = extra;
6609 int tlen = 0;
6610 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6611
6612 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6613 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6614
6615 ENTER();
6616
6617 if (pHddCtx->isLogpInProgress) {
6618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6619 return -EINVAL;
6620 }
6621
6622 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6623
6624 wrqu->txpower.value = 0;
6625 }
6626 else {
6627 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6628 SME_SUMMARY_STATS |
6629 SME_GLOBAL_CLASSA_STATS |
6630 SME_GLOBAL_CLASSB_STATS |
6631 SME_GLOBAL_CLASSC_STATS |
6632 SME_GLOBAL_CLASSD_STATS |
6633 SME_PER_STA_STATS,
6634 hdd_StatisticsCB, 0, FALSE,
6635 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6636
6637 if (eHAL_STATUS_SUCCESS != status)
6638 {
6639 hddLog(VOS_TRACE_LEVEL_ERROR,
6640 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006641 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 return -EINVAL;
6643 }
6644
6645 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6646
6647 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6648 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6649 {
6650 hddLog(VOS_TRACE_LEVEL_ERROR,
6651 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006652 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 /*Remove the SME statistics list by passing NULL in callback argument*/
6654 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6655 SME_SUMMARY_STATS |
6656 SME_GLOBAL_CLASSA_STATS |
6657 SME_GLOBAL_CLASSB_STATS |
6658 SME_GLOBAL_CLASSC_STATS |
6659 SME_GLOBAL_CLASSD_STATS |
6660 SME_PER_STA_STATS,
6661 NULL, 0, FALSE,
6662 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6663
6664 return -EINVAL;
6665 }
6666 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6667 (tANI_U8) sizeof (pStats->retry_cnt),
6668 (char*) &(pStats->retry_cnt[0]),
6669 tlen);
6670
6671 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6672 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6673 (char*) &(pStats->multiple_retry_cnt[0]),
6674 tlen);
6675
6676 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6677 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6678 (char*) &(pStats->tx_frm_cnt[0]),
6679 tlen);
6680
6681 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6682 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6683 (char*) &(pStats->rx_frm_cnt),
6684 tlen);
6685
6686 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6687 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6688 (char*) &(pStats->frm_dup_cnt),
6689 tlen);
6690
6691 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6692 (tANI_U8) sizeof (pStats->fail_cnt),
6693 (char*) &(pStats->fail_cnt[0]),
6694 tlen);
6695
6696 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6697 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6698 (char*) &(pStats->rts_fail_cnt),
6699 tlen);
6700
6701 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6702 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6703 (char*) &(pStats->ack_fail_cnt),
6704 tlen);
6705
6706 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6707 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6708 (char*) &(pStats->rts_succ_cnt),
6709 tlen);
6710
6711 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6712 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6713 (char*) &(pStats->rx_discard_cnt),
6714 tlen);
6715
6716 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6717 (tANI_U8) sizeof (pStats->rx_error_cnt),
6718 (char*) &(pStats->rx_error_cnt),
6719 tlen);
6720
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006721 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006722 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006723 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 tlen);
6725
6726 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6727 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6728 (char*) &(dStats->rx_byte_cnt),
6729 tlen);
6730
6731 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6732 (tANI_U8) sizeof (dStats->rx_rate),
6733 (char*) &(dStats->rx_rate),
6734 tlen);
6735
6736 /* Transmit rate, in units of 500 kbit/sec */
6737 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6738 (tANI_U8) sizeof (aStats->tx_rate),
6739 (char*) &(aStats->tx_rate),
6740 tlen);
6741
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006742 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6743 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6744 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006745 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006746 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6747 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6748 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006749 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006750 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6751 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6752 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006753 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006754 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6755 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6756 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006757 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006758 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6759 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6760 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006761 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006762 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6763 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6764 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006765 tlen);
6766
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 wrqu->data.length = tlen;
6768
6769 }
6770
6771 EXIT();
6772
6773 return 0;
6774}
6775
6776
6777#ifdef FEATURE_WLAN_SCAN_PNO
6778
6779/*Max Len for PNO notification*/
6780#define MAX_PNO_NOTIFY_LEN 100
6781void found_pref_network_cb (void *callbackContext,
6782 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6783{
6784 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6785 union iwreq_data wrqu;
6786 char buf[MAX_PNO_NOTIFY_LEN+1];
6787
6788 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6789 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6790
6791 // create the event
6792 memset(&wrqu, 0, sizeof(wrqu));
6793 memset(buf, 0, sizeof(buf));
6794
6795 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6796 pPrefNetworkFoundInd->ssId.ssId,
6797 (unsigned int)pPrefNetworkFoundInd->rssi);
6798
6799 wrqu.data.pointer = buf;
6800 wrqu.data.length = strlen(buf);
6801
6802 // send the event
6803
6804 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6805
6806}
6807
6808
6809/*string based input*/
6810VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6811 union iwreq_data *wrqu, char *extra, int nOffset)
6812{
6813 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006814 /* pnoRequest is a large struct, so we make it static to avoid stack
6815 overflow. This API is only invoked via ioctl, so it is
6816 serialized by the kernel rtnl_lock and hence does not need to be
6817 reentrant */
6818 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 char *ptr;
6820 v_U8_t i,j, ucParams, ucMode;
6821 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6822
6823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6824 "PNO data len %d data %s",
6825 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006826 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006827
6828 if (wrqu->data.length <= nOffset )
6829 {
6830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6831 return VOS_STATUS_E_FAILURE;
6832 }
6833
6834 pnoRequest.enable = 0;
6835 pnoRequest.ucNetworksCount = 0;
6836 /*-----------------------------------------------------------------------
6837 Input is string based and expected to be like this:
6838
6839 <enabled> <netw_count>
6840 for each network:
6841 <ssid_len> <ssid> <authentication> <encryption>
6842 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6843 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6844
6845 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006846 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 -07006847
6848 this translates into:
6849 -----------------------------
6850 enable PNO
6851 look for 2 networks:
6852 test - with authentication type 0 and encryption type 0,
6853 that can be found on 3 channels: 1 6 and 11 ,
6854 SSID bcast type is unknown (directed probe will be sent if AP not found)
6855 and must meet -40dBm RSSI
6856
6857 test2 - with auth and enrytption type 4/4
6858 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6859 bcast type is non-bcast (directed probe will be sent)
6860 and must not meet any RSSI threshold
6861
Jeff Johnson8301aa12013-03-28 14:27:29 -07006862 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006864 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006865
Wilson Yang623f6592013-10-08 16:33:37 -07006866 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6867 {
6868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6869 "PNO enable input is not valid %s",ptr);
6870 return VOS_STATUS_E_FAILURE;
6871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006872
6873 if ( 0 == pnoRequest.enable )
6874 {
6875 /*Disable PNO*/
6876 memset(&pnoRequest, 0, sizeof(pnoRequest));
6877 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6878 pAdapter->sessionId,
6879 found_pref_network_cb, pAdapter);
6880 return VOS_STATUS_SUCCESS;
6881 }
6882
6883 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006884
6885 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6886 {
6887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6888 "PNO count input not valid %s",ptr);
6889 return VOS_STATUS_E_FAILURE;
6890
6891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006892
6893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6894 "PNO enable %d networks count %d offset %d",
6895 pnoRequest.enable,
6896 pnoRequest.ucNetworksCount,
6897 nOffset);
6898
6899 /* Parameters checking:
6900 ucNetworksCount has to be larger than 0*/
6901 if (( 0 == pnoRequest.ucNetworksCount ) ||
6902 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6903 {
6904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6905 return VOS_STATUS_E_FAILURE;
6906 }
6907
6908 ptr += nOffset;
6909
6910 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6911 {
6912
6913 pnoRequest.aNetworks[i].ssId.length = 0;
6914
Wilson Yang623f6592013-10-08 16:33:37 -07006915 ucParams = sscanf(ptr,"%hhu %n",
6916 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6917
6918 if (1 != ucParams)
6919 {
6920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6921 "PNO ssid length input is not valid %s",ptr);
6922 return VOS_STATUS_E_FAILURE;
6923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006924
6925 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6926 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6927 {
6928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6929 "SSID Len %d is not correct for network %d",
6930 pnoRequest.aNetworks[i].ssId.length, i);
6931 return VOS_STATUS_E_FAILURE;
6932 }
6933
6934 /*Advance to SSID*/
6935 ptr += nOffset;
6936
Jeff Johnson8301aa12013-03-28 14:27:29 -07006937 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006938 pnoRequest.aNetworks[i].ssId.length);
6939 ptr += pnoRequest.aNetworks[i].ssId.length;
6940
Jeff Johnson02797792013-10-26 19:17:13 -07006941 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006942 &(pnoRequest.aNetworks[i].authentication),
6943 &(pnoRequest.aNetworks[i].encryption),
6944 &(pnoRequest.aNetworks[i].ucChannelCount),
6945 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006946
Wilson Yang623f6592013-10-08 16:33:37 -07006947 if ( 3 != ucParams )
6948 {
6949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6950 "Incorrect cmd %s",ptr);
6951 return VOS_STATUS_E_FAILURE;
6952 }
6953
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006955 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006956 "auth %d encry %d channel count %d offset %d",
6957 pnoRequest.aNetworks[i].ssId.length,
6958 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6959 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6960 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6961 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6962 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6963 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6964 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6965 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6966 pnoRequest.aNetworks[i].authentication,
6967 pnoRequest.aNetworks[i].encryption,
6968 pnoRequest.aNetworks[i].ucChannelCount,
6969 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006970
Jeff Johnson295189b2012-06-20 16:38:30 -07006971 /*Advance to channel list*/
6972 ptr += nOffset;
6973
Wilson Yang623f6592013-10-08 16:33:37 -07006974 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 {
6976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6977 "Incorrect number of channels");
6978 return VOS_STATUS_E_FAILURE;
6979 }
6980
6981 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6982 {
6983 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6984 {
Wilson Yang623f6592013-10-08 16:33:37 -07006985 if (1 != sscanf(ptr,"%hhu %n",
6986 &(pnoRequest.aNetworks[i].aChannels[j]),
6987 &nOffset))
6988 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6989 "PNO network channel input is not valid %s",ptr);
6990 return VOS_STATUS_E_FAILURE;
6991 }
6992 /*Advance to next channel number*/
6993 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 }
6995 }
6996
Jeff Johnson02797792013-10-26 19:17:13 -07006997 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006998 &(pnoRequest.aNetworks[i].bcastNetwType),
6999 &nOffset))
7000 {
7001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7002 "PNO broadcast network type input is not valid %s",ptr);
7003 return VOS_STATUS_E_FAILURE;
7004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007005
7006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7007 "PNO bcastNetwType %d offset %d",
7008 pnoRequest.aNetworks[i].bcastNetwType,
7009 nOffset );
7010
7011 /*Advance to rssi Threshold*/
7012 ptr += nOffset;
7013
Wilson Yang623f6592013-10-08 16:33:37 -07007014 if (1 != sscanf(ptr,"%hhu %n",
7015 &(pnoRequest.aNetworks[i].rssiThreshold),
7016 &nOffset))
7017 {
7018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7019 "PNO rssi threshold input is not valid %s",ptr);
7020 return VOS_STATUS_E_FAILURE;
7021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007022
7023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7024 "PNO rssi %d offset %d",
7025 pnoRequest.aNetworks[i].rssiThreshold,
7026 nOffset );
7027 /*Advance to next network*/
7028 ptr += nOffset;
7029 }/*For ucNetworkCount*/
7030
7031 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007032 &(pnoRequest.scanTimers.ucScanTimersCount),
7033 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007034
7035 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007036 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 {
7038 ptr += nOffset;
7039
Jeff Johnson8301aa12013-03-28 14:27:29 -07007040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7041 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 pnoRequest.scanTimers.ucScanTimersCount,
7043 nOffset );
7044
7045 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7046 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 "Incorrect cmd - too many scan timers");
7049 return VOS_STATUS_E_FAILURE;
7050 }
7051
7052 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7053 {
Jeff Johnson02797792013-10-26 19:17:13 -07007054 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7056 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7057 &nOffset);
7058
Wilson Yang623f6592013-10-08 16:33:37 -07007059 if (2 != ucParams)
7060 {
7061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7062 "Incorrect cmd - diff params then expected %d", ucParams);
7063 return VOS_STATUS_E_FAILURE;
7064 }
7065
Jeff Johnson8301aa12013-03-28 14:27:29 -07007066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7067 "PNO Timer value %d Timer repeat %d offset %d",
7068 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7070 nOffset );
7071
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 ptr += nOffset;
7073 }
7074
7075 }
7076 else
7077 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7079 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7081
7082 /*Scan timers defaults to 5 minutes*/
7083 pnoRequest.scanTimers.ucScanTimersCount = 1;
7084 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7085 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7086 }
7087
Wilson Yang623f6592013-10-08 16:33:37 -07007088 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007089
7090 pnoRequest.modePNO = ucMode;
7091 /*for LA we just expose suspend option*/
7092 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7093 {
7094 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7095 }
7096
7097 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
7098 pAdapter->sessionId,
7099 found_pref_network_cb, pAdapter);
7100
7101 return VOS_STATUS_SUCCESS;
7102}/*iw_set_pno*/
7103
7104VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7105 union iwreq_data *wrqu, char *extra, int nOffset)
7106{
7107 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7108 v_U8_t rssiThreshold = 0;
7109 v_U8_t nRead;
7110
Arif Hussain7adce1b2013-11-11 22:59:34 -08007111 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 &rssiThreshold);
7113
7114 if ( 1 != nRead )
7115 {
7116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7117 "Incorrect format");
7118 return VOS_STATUS_E_FAILURE;
7119 }
7120
7121 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7122 return VOS_STATUS_SUCCESS;
7123}
7124
7125
7126static int iw_set_pno_priv(struct net_device *dev,
7127 struct iw_request_info *info,
7128 union iwreq_data *wrqu, char *extra)
7129{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007130 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7131
7132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007134
7135 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7136 {
7137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7138 "%s:LOGP in Progress. Ignore!!!", __func__);
7139 return -EBUSY;
7140 }
7141 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007142}
7143#endif /*FEATURE_WLAN_SCAN_PNO*/
7144
7145//Common function to SetBand
7146int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
7147{
7148 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7149 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7150 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7151 tANI_U8 band = 0;
7152 eCsrBand currBand = eCSR_BAND_MAX;
7153
7154 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
7155
7156 switch(band)
7157 {
7158 case WLAN_HDD_UI_BAND_AUTO:
7159 band = eCSR_BAND_ALL;
7160 break;
7161 case WLAN_HDD_UI_BAND_5_GHZ:
7162 band = eCSR_BAND_5G;
7163 break;
7164 case WLAN_HDD_UI_BAND_2_4_GHZ:
7165 band = eCSR_BAND_24;
7166 break;
7167 default:
7168 band = eCSR_BAND_MAX;
7169 }
7170
7171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007172 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007173
7174 if (band == eCSR_BAND_MAX)
7175 {
7176 /* Received change band request with invalid band value */
7177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007178 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 return -EIO;
7180 }
7181
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307182 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7183 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7184 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7185 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007187 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007188 band, pHddCtx->cfg_ini->nBandCapability);
7189 return -EIO;
7190 }
7191
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7193 {
7194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7195 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007196 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 return -EIO;
7198 }
7199
7200 if (currBand != band)
7201 {
7202 /* Change band request received.
7203 * Abort pending scan requests, flush the existing scan results,
7204 * and change the band capability
7205 */
7206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7207 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007208 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007209
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307210 /* We need to change the band and flush the scan results here itself
7211 * as we may get timeout for disconnection in which we will return
7212 * with out doing any of these
7213 */
7214 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7215 {
7216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7217 "%s: failed to set the band value to %u ",
7218 __func__, band);
7219 return -EINVAL;
7220 }
7221 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7222 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7223 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7224 sme_FilterScanResults(hHal, pAdapter->sessionId);
7225
7226 if (band != eCSR_BAND_ALL &&
7227 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 {
7229 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7230 eHalStatus status = eHAL_STATUS_SUCCESS;
7231 long lrc;
7232
7233 /* STA already connected on current band, So issue disconnect first,
7234 * then change the band*/
7235
7236 hddLog(VOS_TRACE_LEVEL_INFO,
7237 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7238 __func__, csrGetCurrentBand(hHal), band);
7239
7240 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7241 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7242
7243 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7244 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7245
Jeff Johnson43971f52012-07-17 12:26:56 -07007246 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 {
7248 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007249 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 __func__, (int)status );
7251 return -EINVAL;
7252 }
7253
7254 lrc = wait_for_completion_interruptible_timeout(
7255 &pAdapter->disconnect_comp_var,
7256 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7257
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307258 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007259
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007260 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007261 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007262
7263 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7264 }
7265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 }
7267 return 0;
7268}
7269
7270static int iw_set_band_config(struct net_device *dev,
7271 struct iw_request_info *info,
7272 union iwreq_data *wrqu, char *extra)
7273{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007274 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007275 tANI_U8 *ptr = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 int ret = 0;
7277
Arif Hussain0273cba2014-01-07 20:58:29 -08007278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007279
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007280 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7281 {
7282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7283 "%s:LOGP in Progress. Ignore!!!", __func__);
7284 return -EBUSY;
7285 }
7286
Arif Hussain0273cba2014-01-07 20:58:29 -08007287 /* ODD number is used for set, copy data using copy_from_user */
7288 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7289 wrqu->data.length);
7290 if (NULL == ptr)
7291 {
7292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7293 "mem_alloc_copy_from_user_helper fail");
7294 return -ENOMEM;
7295 }
7296
Jeff Johnson295189b2012-06-20 16:38:30 -07007297 if (memcmp(ptr, "SETBAND ", 8) == 0)
7298 {
7299 /* Change band request received */
7300 ret = hdd_setBand_helper(dev, ptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 }
Arif Hussain0273cba2014-01-07 20:58:29 -08007302 kfree(ptr);
7303
7304 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007305}
7306
7307static int iw_set_power_params_priv(struct net_device *dev,
7308 struct iw_request_info *info,
7309 union iwreq_data *wrqu, char *extra)
7310{
Arif Hussain0273cba2014-01-07 20:58:29 -08007311 int ret;
7312 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7314 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007315 /* ODD number is used for set, copy data using copy_from_user */
7316 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7317 wrqu->data.length);
7318 if (NULL == ptr)
7319 {
7320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7321 "mem_alloc_copy_from_user_helper fail");
7322 return -ENOMEM;
7323 }
7324
7325 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7326 kfree(ptr);
7327 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007328}
7329
7330
7331
7332/*string based input*/
7333VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7334 union iwreq_data *wrqu, char *extra, int nOffset)
7335{
7336 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7337 tSirSetPowerParamsReq powerRequest;
7338 char *ptr;
7339 v_U8_t ucType;
7340 v_U32_t uTotalSize, uValue;
7341 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7342
7343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7344 "Power Params data len %d data %s",
7345 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007346 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007347
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007348 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7349 {
7350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7351 "%s:LOGP in Progress. Ignore!!!", __func__);
7352 return -EBUSY;
7353 }
7354
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 if (wrqu->data.length <= nOffset )
7356 {
7357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7358 return VOS_STATUS_E_FAILURE;
7359 }
7360
7361 uTotalSize = wrqu->data.length - nOffset;
7362
7363 /*-----------------------------------------------------------------------
7364 Input is string based and expected to be like this:
7365
7366 <param_type> <param_value> <param_type> <param_value> ...
7367
7368 e.g:
7369 1 2 2 3 3 0 4 1 5 1
7370
7371 e.g. setting just a few:
7372 1 2 4 1
7373
7374 parameter types:
7375 -----------------------------
7376 1 - Ignore DTIM
7377 2 - Listen Interval
7378 3 - Broadcast Multicas Filter
7379 4 - Beacon Early Termination
7380 5 - Beacon Early Termination Interval
7381 -----------------------------------------------------------------------*/
7382 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7383 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7384 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7385 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7386 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7387
Arif Hussain7adce1b2013-11-11 22:59:34 -08007388 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007389
7390 while ( uTotalSize )
7391 {
Wilson Yang6f971452013-10-08 15:00:00 -07007392 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7393 {
7394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7395 "Invalid input parameter type %s",ptr);
7396 return VOS_STATUS_E_FAILURE;
7397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007398
7399 uTotalSize -= nOffset;
7400
7401 if (!uTotalSize)
7402 {
7403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007404 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 ucType, nOffset);
7406 return VOS_STATUS_E_FAILURE;
7407 }
7408
7409 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007410
Jeff Johnson02797792013-10-26 19:17:13 -07007411 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007412 {
7413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7414 "Invalid input parameter value %s",ptr);
7415 return VOS_STATUS_E_FAILURE;
7416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007417
7418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7419 "Power request parameter %d value %d offset %d",
7420 ucType, uValue, nOffset);
7421
7422 switch (ucType)
7423 {
7424 case eSIR_IGNORE_DTIM:
7425 powerRequest.uIgnoreDTIM = uValue;
7426 break;
7427 case eSIR_LISTEN_INTERVAL:
7428 powerRequest.uListenInterval = uValue;
7429 break;
7430 case eSIR_MCAST_BCAST_FILTER:
7431 powerRequest.uBcastMcastFilter = uValue;
7432 break;
7433 case eSIR_ENABLE_BET:
7434 powerRequest.uEnableBET = uValue;
7435 break;
7436 case eSIR_BET_INTERVAL:
7437 powerRequest.uBETInterval = uValue;
7438 break;
7439 default:
7440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007441 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007442 ucType, uValue, nOffset);
7443 return VOS_STATUS_E_FAILURE;
7444 }
7445
7446 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7448 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007449 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007451 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007452 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007453 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7454 {
7455 uTotalSize = 0;
7456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007457
7458 }/*Go for as long as we have a valid string*/
7459
7460 /* put the device into full power*/
7461 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7462
7463 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007464 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007465
7466 /* put the device back to power save*/
7467 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7468
7469 return VOS_STATUS_SUCCESS;
7470}/*iw_set_power_params*/
7471
7472
7473// Define the Wireless Extensions to the Linux Network Device structure
7474// A number of these routines are NULL (meaning they are not implemented.)
7475
7476static const iw_handler we_handler[] =
7477{
7478 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7479 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7480 (iw_handler) NULL, /* SIOCSIWNWID */
7481 (iw_handler) NULL, /* SIOCGIWNWID */
7482 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7483 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7484 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7485 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7486 (iw_handler) NULL, /* SIOCSIWSENS */
7487 (iw_handler) NULL, /* SIOCGIWSENS */
7488 (iw_handler) NULL, /* SIOCSIWRANGE */
7489 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7490 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7491 (iw_handler) NULL, /* SIOCGIWPRIV */
7492 (iw_handler) NULL, /* SIOCSIWSTATS */
7493 (iw_handler) NULL, /* SIOCGIWSTATS */
7494 iw_handler_set_spy, /* SIOCSIWSPY */
7495 iw_handler_get_spy, /* SIOCGIWSPY */
7496 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7497 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7498 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7499 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7500 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7501 (iw_handler) NULL, /* SIOCGIWAPLIST */
7502 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7503 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7504 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7505 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7506 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7507 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7508 (iw_handler) NULL, /* -- hole -- */
7509 (iw_handler) NULL, /* -- hole -- */
7510 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7511 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7512 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7513 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7514 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7515 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7516 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7517 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7518 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7519 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7520 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7521 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7522 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7523 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7524 (iw_handler) NULL, /* -- hole -- */
7525 (iw_handler) NULL, /* -- hole -- */
7526 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7527 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7528 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7529 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7530 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7531 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7532 (iw_handler) NULL, /* SIOCSIWPMKSA */
7533};
7534
7535static const iw_handler we_private[] = {
7536
7537 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7538 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7539 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7540 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7541 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7542 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7543 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7544 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7545 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7546 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007547#ifdef FEATURE_OEM_DATA_SUPPORT
7548 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7549 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7550#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007551
7552#ifdef FEATURE_WLAN_WAPI
7553 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7554 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7555 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7556 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7557 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7558 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7559#endif /* FEATURE_WLAN_WAPI */
7560#ifdef WLAN_FEATURE_VOWIFI_11R
7561 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7562#endif
7563 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7564 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7565 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7566#ifdef WLAN_FEATURE_PACKET_FILTERING
7567 ,
7568 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7569#endif
7570#ifdef FEATURE_WLAN_SCAN_PNO
7571 ,
7572 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7573#endif
7574 ,
7575 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7576 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7577 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7578 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007579 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007580};
7581
7582/*Maximum command length can be only 15 */
7583static const struct iw_priv_args we_private_args[] = {
7584
7585 /* handlers for main ioctl */
7586 { WLAN_PRIV_SET_INT_GET_NONE,
7587 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7588 0,
7589 "" },
7590
7591 /* handlers for sub-ioctl */
7592 { WE_SET_11D_STATE,
7593 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7594 0,
7595 "set11Dstate" },
7596
7597 { WE_WOWL,
7598 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7599 0,
7600 "wowl" },
7601
7602 { WE_SET_POWER,
7603 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7604 0,
7605 "setPower" },
7606
7607 { WE_SET_MAX_ASSOC,
7608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7609 0,
7610 "setMaxAssoc" },
7611
7612 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7614 0,
7615 "setAutoChannel" },
7616
7617 { WE_SET_DATA_INACTIVITY_TO,
7618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7619 0,
7620 "inactivityTO" },
7621
7622 { WE_SET_MAX_TX_POWER,
7623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7624 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007625 "setMaxTxPower" },
7626
7627 { WE_SET_MAX_TX_POWER_2_4,
7628 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7629 0,
7630 "setTxMaxPower2G" },
7631
7632 { WE_SET_MAX_TX_POWER_5_0,
7633 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7634 0,
7635 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007636
7637 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7638 * as well to keep same syntax as in SAP. Now onwards, STA
7639 * will support both */
7640 { WE_SET_MAX_TX_POWER,
7641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7642 0,
7643 "setTxMaxPower" },
7644
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7646 * 1 = enable and 0 = disable */
7647 {
7648 WE_SET_HIGHER_DTIM_TRANSITION,
7649 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7650 0,
7651 "setHDtimTransn" },
7652
7653 { WE_SET_TM_LEVEL,
7654 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007655 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007656 "setTmLevel" },
7657
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307658 { WE_ENABLE_STRICT_FCC_REG,
7659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7660 0,
7661 "setStrictFCCreg" },
7662
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007663 { WE_SET_DEBUG_LOG,
7664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7665 0, "setDbgLvl" },
7666
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 /* handlers for main ioctl */
7668 { WLAN_PRIV_SET_NONE_GET_INT,
7669 0,
7670 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7671 "" },
7672
7673 /* handlers for sub-ioctl */
7674 { WE_GET_11D_STATE,
7675 0,
7676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7677 "get11Dstate" },
7678
7679 { WE_IBSS_STATUS,
7680 0,
7681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7682 "getAdhocStatus" },
7683
7684 { WE_PMC_STATE,
7685 0,
7686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7687 "pmcState" },
7688
7689 { WE_GET_WLAN_DBG,
7690 0,
7691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7692 "getwlandbg" },
7693
7694 { WE_MODULE_DOWN_IND,
7695 0,
7696 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7697 "moduleDownInd" },
7698
7699 { WE_GET_MAX_ASSOC,
7700 0,
7701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7702 "getMaxAssoc" },
7703
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 { WE_GET_WDI_DBG,
7705 0,
7706 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7707 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007708
7709 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7710 0,
7711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7712 "getAutoChannel" },
7713
7714 { WE_GET_CONCURRENCY_MODE,
7715 0,
7716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7717 "getconcurrency" },
7718
7719 /* handlers for main ioctl */
7720 { WLAN_PRIV_SET_CHAR_GET_NONE,
7721 IW_PRIV_TYPE_CHAR| 512,
7722 0,
7723 "" },
7724
7725 /* handlers for sub-ioctl */
7726 { WE_WOWL_ADD_PTRN,
7727 IW_PRIV_TYPE_CHAR| 512,
7728 0,
7729 "wowlAddPtrn" },
7730
7731 { WE_WOWL_DEL_PTRN,
7732 IW_PRIV_TYPE_CHAR| 512,
7733 0,
7734 "wowlDelPtrn" },
7735
7736#if defined WLAN_FEATURE_VOWIFI
7737 /* handlers for sub-ioctl */
7738 { WE_NEIGHBOR_REPORT_REQUEST,
7739 IW_PRIV_TYPE_CHAR | 512,
7740 0,
7741 "neighbor" },
7742#endif
7743 { WE_SET_AP_WPS_IE,
7744 IW_PRIV_TYPE_CHAR| 512,
7745 0,
7746 "set_ap_wps_ie" },
7747
7748 { WE_SET_CONFIG,
7749 IW_PRIV_TYPE_CHAR| 512,
7750 0,
7751 "setConfig" },
7752
7753 /* handlers for main ioctl */
7754 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7755 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7756 0,
7757 "" },
7758
7759 /* handlers for sub-ioctl */
7760 { WE_SET_WLAN_DBG,
7761 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7762 0,
7763 "setwlandbg" },
7764
Jeff Johnson295189b2012-06-20 16:38:30 -07007765 { WE_SET_WDI_DBG,
7766 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7767 0,
7768 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007769
7770 { WE_SET_SAP_CHANNELS,
7771 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7772 0,
7773 "setsapchannels" },
7774
7775 /* handlers for main ioctl */
7776 { WLAN_PRIV_GET_CHAR_SET_NONE,
7777 0,
7778 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7779 "" },
7780
7781 /* handlers for sub-ioctl */
7782 { WE_WLAN_VERSION,
7783 0,
7784 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7785 "version" },
7786 { WE_GET_STATS,
7787 0,
7788 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7789 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307790 { WE_GET_STATES,
7791 0,
7792 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7793 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007794 { WE_GET_CFG,
7795 0,
7796 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7797 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007798#ifdef WLAN_FEATURE_11AC
7799 { WE_GET_RSSI,
7800 0,
7801 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7802 "getRSSI" },
7803#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007804#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
7805 { WE_GET_ROAM_RSSI,
7806 0,
7807 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7808 "getRoamRSSI" },
7809#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 { WE_GET_WMM_STATUS,
7811 0,
7812 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7813 "getWmmStatus" },
7814 {
7815 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307816 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7818 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007819#ifdef FEATURE_WLAN_TDLS
7820 {
7821 WE_GET_TDLS_PEERS,
7822 0,
7823 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7824 "getTdlsPeers" },
7825#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007826#ifdef WLAN_FEATURE_11W
7827 {
7828 WE_GET_11W_INFO,
7829 0,
7830 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7831 "getPMFInfo" },
7832#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 /* handlers for main ioctl */
7834 { WLAN_PRIV_SET_NONE_GET_NONE,
7835 0,
7836 0,
7837 "" },
7838
7839 /* handlers for sub-ioctl */
7840 { WE_CLEAR_STATS,
7841 0,
7842 0,
7843 "clearStats" },
7844 { WE_INIT_AP,
7845 0,
7846 0,
7847 "initAP" },
7848 { WE_STOP_AP,
7849 0,
7850 0,
7851 "exitAP" },
7852 { WE_ENABLE_AMP,
7853 0,
7854 0,
7855 "enableAMP" },
7856 { WE_DISABLE_AMP,
7857 0,
7858 0,
7859 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007860 { WE_ENABLE_DXE_STALL_DETECT,
7861 0,
7862 0,
7863 "dxeStallDetect" },
7864 { WE_DISPLAY_DXE_SNAP_SHOT,
7865 0,
7866 0,
7867 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307868 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7869 0,
7870 0,
7871 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007872 {
7873 WE_SET_REASSOC_TRIGGER,
7874 0,
7875 0,
7876 "reassoc" },
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307877 {
7878 WE_STOP_OBSS_SCAN,
7879 0,
7880 0,
7881 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007882
7883 /* handlers for main ioctl */
7884 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7885 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7886 0,
7887 "" },
7888
7889 /* handlers for sub-ioctl */
7890 { WE_LOG_DUMP_CMD,
7891 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7892 0,
7893 "dump" },
7894
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007895 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307896 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
7897 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7898 0,
7899 "setdumplog" },
7900
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007901 { WE_MTRACE_DUMP_CMD,
7902 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7903 0,
7904 "dumplog" },
7905
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007906 /* handlers for sub ioctl */
7907 {
7908 WE_MCC_CONFIG_CREDENTIAL,
7909 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7910 0,
7911 "setMccCrdnl" },
7912
7913 /* handlers for sub ioctl */
7914 {
7915 WE_MCC_CONFIG_PARAMS,
7916 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7917 0,
7918 "setMccConfig" },
7919
Chilam NG571c65a2013-01-19 12:27:36 +05307920#ifdef FEATURE_WLAN_TDLS
7921 /* handlers for sub ioctl */
7922 {
7923 WE_TDLS_CONFIG_PARAMS,
7924 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7925 0,
7926 "setTdlsConfig" },
7927#endif
7928
Jeff Johnson295189b2012-06-20 16:38:30 -07007929 /* handlers for main ioctl */
7930 { WLAN_PRIV_ADD_TSPEC,
7931 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7932 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7933 "addTspec" },
7934
7935 /* handlers for main ioctl */
7936 { WLAN_PRIV_DEL_TSPEC,
7937 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7939 "delTspec" },
7940
7941 /* handlers for main ioctl */
7942 { WLAN_PRIV_GET_TSPEC,
7943 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7944 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7945 "getTspec" },
7946
Jeff Johnsone7245742012-09-05 17:12:55 -07007947#ifdef FEATURE_OEM_DATA_SUPPORT
7948 /* handlers for main ioctl - OEM DATA */
7949 {
7950 WLAN_PRIV_SET_OEM_DATA_REQ,
7951 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7952 0,
7953 "set_oem_data_req" },
7954
7955 /* handlers for main ioctl - OEM DATA */
7956 {
7957 WLAN_PRIV_GET_OEM_DATA_RSP,
7958 0,
7959 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7960 "get_oem_data_rsp" },
7961#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007962
7963#ifdef FEATURE_WLAN_WAPI
7964 /* handlers for main ioctl SET_WAPI_MODE */
7965 { WLAN_PRIV_SET_WAPI_MODE,
7966 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7967 0,
7968 "SET_WAPI_MODE" },
7969
7970 /* handlers for main ioctl GET_WAPI_MODE */
7971 { WLAN_PRIV_GET_WAPI_MODE,
7972 0,
7973 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7974 "GET_WAPI_MODE" },
7975
7976 /* handlers for main ioctl SET_ASSOC_INFO */
7977 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
7978 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
7979 0,
7980 "SET_WAPI_ASSOC" },
7981
7982 /* handlers for main ioctl SET_WAPI_KEY */
7983 { WLAN_PRIV_SET_WAPI_KEY,
7984 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
7985 0,
7986 "SET_WAPI_KEY" },
7987
7988 /* handlers for main ioctl SET_WAPI_BKID */
7989 { WLAN_PRIV_SET_WAPI_BKID,
7990 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7991 0,
7992 "SET_WAPI_BKID" },
7993
7994 /* handlers for main ioctl GET_WAPI_BKID */
7995 { WLAN_PRIV_GET_WAPI_BKID,
7996 0,
7997 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
7998 "GET_WAPI_BKID" },
7999#endif /* FEATURE_WLAN_WAPI */
8000
8001 /* handlers for main ioctl - host offload */
8002 {
8003 WLAN_PRIV_SET_HOST_OFFLOAD,
8004 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8005 0,
8006 "setHostOffload" },
8007
8008 {
8009 WLAN_GET_WLAN_STATISTICS,
8010 0,
8011 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8012 "getWlanStats" },
8013
8014 {
8015 WLAN_SET_KEEPALIVE_PARAMS,
8016 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8017 0,
8018 "setKeepAlive" },
8019#ifdef WLAN_FEATURE_PACKET_FILTERING
8020 {
8021 WLAN_SET_PACKET_FILTER_PARAMS,
8022 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8023 0,
8024 "setPktFilter" },
8025#endif
8026#ifdef FEATURE_WLAN_SCAN_PNO
8027 {
8028 WLAN_SET_PNO,
8029 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8030 0,
8031 "setpno" },
8032#endif
8033 {
8034 WLAN_SET_BAND_CONFIG,
8035 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8036 0,
8037 "SETBAND" },
8038 /* handlers for dynamic MC BC ioctl */
8039 {
8040 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008041 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 0,
8043 "setMCBCFilter" },
8044 {
8045 WLAN_PRIV_CLEAR_MCBC_FILTER,
8046 0,
8047 0,
8048 "clearMCBCFilter" },
8049 {
8050 WLAN_SET_POWER_PARAMS,
8051 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8052 0,
8053 "setpowerparams" },
8054 {
8055 WLAN_GET_LINK_SPEED,
8056 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308057 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008058};
8059
8060
8061
8062const struct iw_handler_def we_handler_def = {
8063 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8064 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8065 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8066
8067 .standard = (iw_handler *)we_handler,
8068 .private = (iw_handler *)we_private,
8069 .private_args = we_private_args,
8070 .get_wireless_stats = get_wireless_stats,
8071};
8072
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008073int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8074{
8075 v_U32_t cmd = 288; //Command to RIVA
8076 hdd_context_t *pHddCtx = NULL;
8077 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8078 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8079 /*
8080 *configMccParam : specify the bit which needs to be modified
8081 *allowed to update based on wlan_qcom_cfg.ini
8082 * configuration
8083 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8084 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8085 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8086 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8087 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8088 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8089 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8090 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8091 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8092 * Bit 9 : Reserved
8093 */
8094 switch (arg1)
8095 {
8096 //Update MCC SCHEDULE_TIME_SLICE parameter
8097 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8098 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8099 {
8100 if((arg2 >= 5) && (arg2 <= 20))
8101 {
8102 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8103 }
8104 else
8105 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008106 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008107 return 0;
8108 }
8109 }
8110 break;
8111
8112 //Update MCC MAX_NULL_SEND_TIME parameter
8113 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8114 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8115 {
8116 if((arg2 >= 1) && (arg2 <= 10))
8117 {
8118 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8119 }
8120 else
8121 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008122 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008123 return 0;
8124 }
8125 }
8126 break;
8127
8128 //Update MCC TX_EARLY_STOP_TIME parameter
8129 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8130 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8131 {
8132 if((arg2 >= 1) && (arg2 <= 10))
8133 {
8134 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8135 }
8136 else
8137 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008138 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008139 return 0;
8140 }
8141 }
8142 break;
8143
8144 //Update MCC RX_DRAIN_TIME parameter
8145 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8146 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8147 {
8148 if((arg2 >= 1) && (arg2 <= 10))
8149 {
8150 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8151 }
8152 else
8153 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008154 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008155 return 0;
8156 }
8157 }
8158 break;
8159
8160 //Update MCC CHANNEL_SWITCH_TIME parameter
8161 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8162 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8163 {
8164 if((arg2 >= 1) && (arg2 <= 20))
8165 {
8166 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8167 }
8168 else
8169 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008170 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008171 return 0;
8172 }
8173 }
8174 break;
8175
8176 //Update MCC MIN_CHANNEL_TIME parameter
8177 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8178 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8179 {
8180 if((arg2 >= 5) && (arg2 <= 20))
8181 {
8182 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8183 }
8184 else
8185 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008186 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008187 return 0;
8188 }
8189 }
8190 break;
8191
8192 //Update MCC PARK_BEFORE_TBTT parameter
8193 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8194 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8195 {
8196 if((arg2 >= 1) && (arg2 <= 5))
8197 {
8198 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8199 }
8200 else
8201 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008202 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008203 return 0;
8204 }
8205 }
8206 break;
8207
8208 //Update MCC MIN_AFTER_DTIM parameter
8209 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8210 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8211 {
8212 if((arg2 >= 5) && (arg2 <= 15))
8213 {
8214 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8215 }
8216 else
8217 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008218 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008219 return 0;
8220 }
8221 }
8222 break;
8223
8224 //Update MCC TOO_CLOSE_MARGIN parameter
8225 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8226 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8227 {
8228 if((arg2 >= 1) && (arg2 <= 3))
8229 {
8230 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8231 }
8232 else
8233 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008234 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008235 return 0;
8236 }
8237 }
8238 break;
8239
8240 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008241 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008242 __FUNCTION__,arg1);
8243 break;
8244 }
8245 return 0;
8246}
8247
Jeff Johnson295189b2012-06-20 16:38:30 -07008248int hdd_set_wext(hdd_adapter_t *pAdapter)
8249{
8250 hdd_wext_state_t *pwextBuf;
8251 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008252 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008253
8254 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8255
8256 // Now configure the roaming profile links. To SSID and bssid.
8257 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8258 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8259
8260 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8261 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8262
8263 /*Set the numOfChannels to zero to scan all the channels*/
8264 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8265 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8266
8267 /* Default is no encryption */
8268 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8269 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8270
8271 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8272 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8273
8274 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8275
8276 /* Default is no authentication */
8277 pwextBuf->roamProfile.AuthType.numEntries = 1;
8278 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8279
8280 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8281 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8282
8283 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008284 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008285
8286 hdd_clearRoamProfileIe(pAdapter);
8287
8288 return VOS_STATUS_SUCCESS;
8289
8290 }
8291
8292int hdd_register_wext(struct net_device *dev)
8293 {
8294 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8295 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8296 VOS_STATUS status;
8297
8298 ENTER();
8299
8300 // Zero the memory. This zeros the profile structure.
8301 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8302
8303 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8304
8305
8306 status = hdd_set_wext(pAdapter);
8307
8308 if(!VOS_IS_STATUS_SUCCESS(status)) {
8309
Arif Hussain6d2a3322013-11-17 19:50:10 -08008310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 return eHAL_STATUS_FAILURE;
8312 }
8313
8314 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8315 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008317 return eHAL_STATUS_FAILURE;
8318 }
8319
8320 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8321 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 return eHAL_STATUS_FAILURE;
8324 }
8325
8326 // Register as a wireless device
8327 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8328
8329 EXIT();
8330 return 0;
8331}
8332
8333int hdd_UnregisterWext(struct net_device *dev)
8334{
8335#if 0
8336 hdd_wext_state_t *wextBuf;
8337 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8338
8339 ENTER();
8340 // Set up the pointer to the Wireless Extensions state structure
8341 wextBuf = pAdapter->pWextState;
8342
8343 // De-allocate the Wireless Extensions state structure
8344 kfree(wextBuf);
8345
8346 // Clear out the pointer to the Wireless Extensions state structure
8347 pAdapter->pWextState = NULL;
8348
8349 EXIT();
8350#endif
8351 dev->wireless_handlers = NULL;
8352 return 0;
8353}
8354
8355