blob: 32996b93061366d6ed906dddf2b7b1bad44e2925 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/** ------------------------------------------------------------------------ *
31 ------------------------------------------------------------------------ *
32
33
34 \file wlan_hdd_wext.c
35
36 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
37 interfaces.
38
39 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041 This file defines all of the types that are utilized by the CCP module
42 of the "Portable" HDD. This file also includes the underlying Linux
43 Wireless Extensions Data types referred to by CCP.
44
45 ======================================================================== */
46
47#include <linux/version.h>
48#include <linux/module.h>
49#include <linux/kernel.h>
50#include <linux/init.h>
51#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053052#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include <wlan_hdd_includes.h>
54#include <wlan_btc_svc.h>
55#include <wlan_nlink_common.h>
56#ifdef WLAN_BTAMP_FEATURE
57#include <bap_hdd_main.h>
58#endif
59#include <vos_api.h>
60#include <net/arp.h>
61#include "ccmApi.h"
62#include "sirParams.h"
63#include "csrApi.h"
64#include "csrInsideApi.h"
65#if defined WLAN_FEATURE_VOWIFI
66#include "smeRrmInternal.h"
67#endif
68#include <aniGlobal.h>
69#include "dot11f.h"
70#include <wlan_hdd_wowl.h>
71#include <wlan_hdd_cfg.h>
72#include <wlan_hdd_wmm.h>
73#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053075#ifdef FEATURE_WLAN_TDLS
76#include "wlan_hdd_tdls.h"
77#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070078
79#ifdef CONFIG_HAS_EARLYSUSPEND
80#include <linux/earlysuspend.h>
81#endif
82#include "wlan_hdd_power.h"
83#include "qwlan_version.h"
84#include <vos_power.h>
85#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
105#ifdef CONFIG_HAS_EARLYSUSPEND
106extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
107extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
108#endif
109
Jeff Johnsone7245742012-09-05 17:12:55 -0700110#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800111#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700112#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700113
114#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530115#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700119static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122/* To Validate Channel against the Frequency and Vice-Versa */
123static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
124 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
125 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
126 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
127 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
128 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
129 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
130 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800131 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
132 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800134#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136/* Private ioctls and their sub-ioctls */
137#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
138#define WE_SET_11D_STATE 1
139#define WE_WOWL 2
140#define WE_SET_POWER 3
141#define WE_SET_MAX_ASSOC 4
142#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
143#define WE_SET_DATA_INACTIVITY_TO 6
144#define WE_SET_MAX_TX_POWER 7
145#define WE_SET_HIGHER_DTIM_TRANSITION 8
146#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530147#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700148#define WE_SET_MAX_TX_POWER_2_4 11
149#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800150/* Private IOCTL for debug connection issues */
151#define WE_SET_DEBUG_LOG 13
Jeff Johnson295189b2012-06-20 16:38:30 -0700152
153/* Private ioctls and their sub-ioctls */
154#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
155#define WE_GET_11D_STATE 1
156#define WE_IBSS_STATUS 2
157#define WE_PMC_STATE 3
158#define WE_GET_WLAN_DBG 4
159#define WE_MODULE_DOWN_IND 5
160#define WE_GET_MAX_ASSOC 6
161#define WE_GET_WDI_DBG 7
162#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
163#define WE_GET_CONCURRENCY_MODE 9
164/* Private ioctls and their sub-ioctls */
165#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
166
167/* Private ioctls and their sub-ioctls */
168#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
169#define WE_WOWL_ADD_PTRN 1
170#define WE_WOWL_DEL_PTRN 2
171#if defined WLAN_FEATURE_VOWIFI
172#define WE_NEIGHBOR_REPORT_REQUEST 3
173#endif
174#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
175#define WE_SET_CONFIG 5
176
177/* Private ioctls and their sub-ioctls */
178#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
179#define WE_SET_WLAN_DBG 1
180#define WE_SET_WDI_DBG 2
181#define WE_SET_SAP_CHANNELS 3
182
183/* Private ioctls and their sub-ioctls */
184#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
185#define WE_WLAN_VERSION 1
186#define WE_GET_STATS 2
187#define WE_GET_CFG 3
188#define WE_GET_WMM_STATUS 4
189#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700190#ifdef WLAN_FEATURE_11AC
191#define WE_GET_RSSI 6
192#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800193#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800194#ifdef FEATURE_WLAN_TDLS
195#define WE_GET_TDLS_PEERS 8
196#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700197#ifdef WLAN_FEATURE_11W
198#define WE_GET_11W_INFO 9
199#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530200#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202/* Private ioctls and their sub-ioctls */
203#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
204#define WE_CLEAR_STATS 1
205#define WE_INIT_AP 2
206#define WE_STOP_AP 3
207#define WE_ENABLE_AMP 4
208#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700209#define WE_ENABLE_DXE_STALL_DETECT 6
210#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530211#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700212#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530213#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700214
215/* Private ioctls and their sub-ioctls */
216#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
217#define WE_LOG_DUMP_CMD 1
218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800220//IOCTL to configure MCC params
221#define WE_MCC_CONFIG_CREDENTIAL 3
222#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
Chilam NG571c65a2013-01-19 12:27:36 +0530224#ifdef FEATURE_WLAN_TDLS
225#define WE_TDLS_CONFIG_PARAMS 5
226#endif
227
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700228#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530229#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700230
Chilam Ng01120412013-02-19 18:32:21 -0800231#ifdef FEATURE_WLAN_TDLS
232#undef MAX_VAR_ARGS
233#define MAX_VAR_ARGS 10
234#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700235#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800236#endif
237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
239/* Private ioctls (with no sub-ioctls) */
240/* note that they must be odd so that they have "get" semantics */
241#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
242#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
243#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
244
245#ifdef FEATURE_WLAN_WAPI
246/* Private ioctls EVEN NO: SET, ODD NO:GET */
247#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
248#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
249#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
250#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
251#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
252#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
253#define WAPI_PSK_AKM_SUITE 0x02721400
254#define WAPI_CERT_AKM_SUITE 0x01721400
255#endif
256
Jeff Johnsone7245742012-09-05 17:12:55 -0700257#ifdef FEATURE_OEM_DATA_SUPPORT
258/* Private ioctls for setting the measurement configuration */
259#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
260#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
261#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700262
263#ifdef WLAN_FEATURE_VOWIFI_11R
264#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
265#endif
266
267/* Private ioctl for setting the host offload feature */
268#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
269
270/* Private ioctl to get the statistics */
271#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
272
273/* Private ioctl to set the Keep Alive Params */
274#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
275#ifdef WLAN_FEATURE_PACKET_FILTERING
276/* Private ioctl to set the Packet Filtering Params */
277#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
278#endif
279
280#ifdef FEATURE_WLAN_SCAN_PNO
281/* Private ioctl to get the statistics */
282#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
283#endif
284
285#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
286
287#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
288#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700289/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700290
Jeff Johnson295189b2012-06-20 16:38:30 -0700291#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
292#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
293
294#define WLAN_STATS_INVALID 0
295#define WLAN_STATS_RETRY_CNT 1
296#define WLAN_STATS_MUL_RETRY_CNT 2
297#define WLAN_STATS_TX_FRM_CNT 3
298#define WLAN_STATS_RX_FRM_CNT 4
299#define WLAN_STATS_FRM_DUP_CNT 5
300#define WLAN_STATS_FAIL_CNT 6
301#define WLAN_STATS_RTS_FAIL_CNT 7
302#define WLAN_STATS_ACK_FAIL_CNT 8
303#define WLAN_STATS_RTS_SUC_CNT 9
304#define WLAN_STATS_RX_DISCARD_CNT 10
305#define WLAN_STATS_RX_ERROR_CNT 11
306#define WLAN_STATS_TX_BYTE_CNT 12
307
308#define WLAN_STATS_RX_BYTE_CNT 13
309#define WLAN_STATS_RX_RATE 14
310#define WLAN_STATS_TX_RATE 15
311
Jeff Johnsone7245742012-09-05 17:12:55 -0700312#define WLAN_STATS_RX_UC_BYTE_CNT 16
313#define WLAN_STATS_RX_MC_BYTE_CNT 17
314#define WLAN_STATS_RX_BC_BYTE_CNT 18
315#define WLAN_STATS_TX_UC_BYTE_CNT 19
316#define WLAN_STATS_TX_MC_BYTE_CNT 20
317#define WLAN_STATS_TX_BC_BYTE_CNT 21
318
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800319#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
320 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
321 { \
322 *__p++ = __type; \
323 *__p++ = __size; \
324 memcpy(__p, __val, __size); \
325 __p += __size; \
326 __tlen += __size + 2; \
327 } \
328 else \
329 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800330 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800331 } \
332 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700333
334#define VERSION_VALUE_MAX_LEN 32
335
336#define TX_PER_TRACKING_DEFAULT_RATIO 5
337#define TX_PER_TRACKING_MAX_RATIO 10
338#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
339
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530340#define WLAN_ADAPTER 0
341#define P2P_ADAPTER 1
342
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800343/*MCC Configuration parameters */
344enum {
345 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
346 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
347 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
348 MCC_RX_DRAIN_TIME_CFG_PARAM,
349 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
350 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
351 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
352 MCC_MIN_AFTER_DTIM_CFG_PARAM,
353 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
354};
355
356int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
357 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800360int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700361 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700362#endif
363
Jeff Johnson295189b2012-06-20 16:38:30 -0700364/**---------------------------------------------------------------------------
365
Arif Hussain0273cba2014-01-07 20:58:29 -0800366 \brief mem_alloc_copy_from_user_helper -
367
368 Helper function to allocate buffer and copy user data.
369
370 \param - wrqu - Pointer to IOCTL Data.
371 len - size
372
373 \return - On Success pointer to buffer, On failure NULL
374
375 --------------------------------------------------------------------------*/
376static void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
377{
378 u8 *ptr = NULL;
379
380 /* in order to protect the code, an extra byte is post appended to the buffer
381 * and the null termination is added. However, when allocating (len+1) byte
382 * of memory, we need to make sure that there is no uint overflow when doing
383 * addition. In theory check len < UINT_MAX protects the uint overflow. For
384 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
385 * guess, now, it is assumed that the private command buffer size is no
386 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
387 */
388 if (len > MAX_USER_COMMAND_SIZE)
389 {
390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
391 "Invalid length");
392 return NULL;
393 }
394
395 ptr = kmalloc(len + 1, GFP_KERNEL);
396 if (NULL == ptr)
397 {
398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
399 "unable to allocate memory");
400 return NULL;
401 }
402
403 if (copy_from_user(ptr, wrqu_data, len))
404 {
405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
406 "%s: failed to copy data to user buffer", __func__);
407 kfree(ptr);
408 return NULL;
409 }
410 ptr[len] = '\0';
411 return ptr;
412}
413
414/**---------------------------------------------------------------------------
415
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 \brief hdd_wlan_get_version() -
417
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800418 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700419
420 \param - pAdapter Pointer to the adapter.
421 wrqu - Pointer to IOCTL REQUEST Data.
422 extra - Pointer to char
423
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800424 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700425
426 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800427void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
428 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700429{
430 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800431 tSirVersionString wcnss_SW_version;
432 tSirVersionString wcnss_HW_version;
433 char *pSWversion;
434 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700436
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800437 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
438 sizeof(wcnss_SW_version));
439 if (VOS_IS_STATUS_SUCCESS(status))
440 {
441 pSWversion = wcnss_SW_version;
442 }
443 else
444 {
445 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 }
447
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800448 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
449 sizeof(wcnss_HW_version));
450 if (VOS_IS_STATUS_SUCCESS(status))
451 {
452 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800454 else
455 {
456 pHWversion = "Unknown";
457 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700458
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700459 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800460 "Host SW:%s, FW:%s, HW:%s",
461 QWLAN_VERSIONSTR,
462 pSWversion,
463 pHWversion);
464
465 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466}
467
Jeff Johnson295189b2012-06-20 16:38:30 -0700468int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
469{
470 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
471 v_U32_t threshold = 0,status = 0;
472
473 ENTER();
474
Agarwal Ashish971c2882013-10-30 20:11:12 +0530475 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
476 {
477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 "%s:LOGP in Progress. Ignore!!!",__func__);
479 return status;
480 }
481
482 if ( eHAL_STATUS_SUCCESS !=
483 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
484 {
c_hpothub8245442013-11-20 23:41:09 +0530485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
486 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 return -EIO;
488 }
489 wrqu->rts.value = threshold;
490
491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800492 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
494 EXIT();
495
496 return 0;
497}
498
499int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
500{
501 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
502 v_U32_t threshold = 0,status = 0;
503
504 ENTER();
505
Agarwal Ashish971c2882013-10-30 20:11:12 +0530506 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
507 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
509 "%s:LOGP in Progress. Ignore!!!",__func__);
510 return status;
511 }
512
513 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
514 != eHAL_STATUS_SUCCESS )
515 {
c_hpothub8245442013-11-20 23:41:09 +0530516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
517 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 return -EIO;
519 }
520 wrqu->frag.value = threshold;
521
522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800523 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700524
525 EXIT();
526
527 return 0;
528}
529
530int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
531{
Jeff Johnsone7245742012-09-05 17:12:55 -0700532 int i;
533 if (channel > 0)
534 {
535 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
536 {
537 if (channel == freq_chan_map[i].chan)
538 {
539 *pfreq = freq_chan_map[i].freq;
540 return 1;
541 }
542 }
543 }
544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800545 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700546 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700547}
548
549static v_BOOL_t
550hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
551{
552 v_BOOL_t rsnType = VOS_FALSE;
553 // is the authType supported?
554 switch (authType)
555 {
556 case eCSR_AUTH_TYPE_NONE: //never used
557 rsnType = eANI_BOOLEAN_FALSE;
558 break;
559 // MAC layer authentication types
560 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
561 rsnType = eANI_BOOLEAN_FALSE;
562 break;
563 case eCSR_AUTH_TYPE_SHARED_KEY:
564 rsnType = eANI_BOOLEAN_FALSE;
565 break;
566 case eCSR_AUTH_TYPE_AUTOSWITCH:
567 rsnType = eANI_BOOLEAN_FALSE;
568 break;
569
570 // Upper layer authentication types
571 case eCSR_AUTH_TYPE_WPA:
572 rsnType = eANI_BOOLEAN_TRUE;
573 break;
574 case eCSR_AUTH_TYPE_WPA_PSK:
575 rsnType = eANI_BOOLEAN_TRUE;
576 break;
577 case eCSR_AUTH_TYPE_WPA_NONE:
578 rsnType = eANI_BOOLEAN_TRUE;
579 break;
580#ifdef WLAN_FEATURE_VOWIFI_11R
581 case eCSR_AUTH_TYPE_FT_RSN:
582#endif
583 case eCSR_AUTH_TYPE_RSN:
584 rsnType = eANI_BOOLEAN_TRUE;
585 break;
586#ifdef WLAN_FEATURE_VOWIFI_11R
587 case eCSR_AUTH_TYPE_FT_RSN_PSK:
588#endif
589 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700590#ifdef WLAN_FEATURE_11W
591 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
592#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 rsnType = eANI_BOOLEAN_TRUE;
594 break;
595 //case eCSR_AUTH_TYPE_FAILED:
596 case eCSR_AUTH_TYPE_UNKNOWN:
597 rsnType = eANI_BOOLEAN_FALSE;
598 break;
599 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800600 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
601 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 rsnType = eANI_BOOLEAN_FALSE;
603 break;
604 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800605 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700606 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 return rsnType;
608}
609
610static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
611{
612 struct statsContext *pStatsContext;
613 hdd_adapter_t *pAdapter;
614
615 if (ioctl_debug)
616 {
617 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700618 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 }
620
621 if (NULL == pContext)
622 {
623 hddLog(VOS_TRACE_LEVEL_ERROR,
624 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700625 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 return;
627 }
628
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 pStatsContext = pContext;
630 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800631
632 /* there is a race condition that exists between this callback
633 function and the caller since the caller could time out either
634 before or while this code is executing. we use a spinlock to
635 serialize these actions */
636 spin_lock(&hdd_context_lock);
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
639 {
640 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800641 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 hddLog(VOS_TRACE_LEVEL_WARN,
643 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700644 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 if (ioctl_debug)
646 {
647 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700648 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 }
650 return;
651 }
652
Jeff Johnson72a40512013-12-19 10:14:15 -0800653 /* context is valid so caller is still waiting */
654
655 /* paranoia: invalidate the magic */
656 pStatsContext->magic = 0;
657
658 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 pAdapter->rssi = rssi;
660
Jeff Johnson72a40512013-12-19 10:14:15 -0800661 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800663
664 /* serialization is complete */
665 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700666}
667
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530668static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
669{
670 struct statsContext *pStatsContext;
671 hdd_adapter_t *pAdapter;
672
673 if (ioctl_debug)
674 {
675 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
676 __func__, (int)snr, (int)staId, pContext);
677 }
678
679 if (NULL == pContext)
680 {
681 hddLog(VOS_TRACE_LEVEL_ERROR,
682 "%s: Bad param, pContext [%p]",
683 __func__, pContext);
684 return;
685 }
686
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530687 pStatsContext = pContext;
688 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800689
690 /* there is a race condition that exists between this callback
691 function and the caller since the caller could time out either
692 before or while this code is executing. we use a spinlock to
693 serialize these actions */
694 spin_lock(&hdd_context_lock);
695
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530696 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
697 {
698 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800699 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530700 hddLog(VOS_TRACE_LEVEL_WARN,
701 "%s: Invalid context, pAdapter [%p] magic [%08x]",
702 __func__, pAdapter, pStatsContext->magic);
703 if (ioctl_debug)
704 {
705 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
706 __func__, pAdapter, pStatsContext->magic);
707 }
708 return;
709 }
710
Jeff Johnson72a40512013-12-19 10:14:15 -0800711 /* context is valid so caller is still waiting */
712
713 /* paranoia: invalidate the magic */
714 pStatsContext->magic = 0;
715
716 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530717 pAdapter->snr = snr;
718
Jeff Johnson72a40512013-12-19 10:14:15 -0800719 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530720 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800721
722 /* serialization is complete */
723 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530724}
725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
727{
728 struct statsContext context;
729 hdd_context_t *pHddCtx;
730 hdd_station_ctx_t *pHddStaCtx;
731 eHalStatus hstatus;
732 long lrc;
733
734 if (NULL == pAdapter)
735 {
736 hddLog(VOS_TRACE_LEVEL_WARN,
737 "%s: Invalid context, pAdapter", __func__);
738 return VOS_STATUS_E_FAULT;
739 }
740 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
741 {
742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
743 /* return a cached value */
744 *rssi_value = pAdapter->rssi;
745 return VOS_STATUS_SUCCESS;
746 }
747
748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
749 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
750
751 init_completion(&context.completion);
752 context.pAdapter = pAdapter;
753 context.magic = RSSI_CONTEXT_MAGIC;
754
755 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
756 pHddStaCtx->conn_info.staId[ 0 ],
757 pHddStaCtx->conn_info.bssId,
758 &context, pHddCtx->pvosContext);
759 if (eHAL_STATUS_SUCCESS != hstatus)
760 {
761 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700762 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 /* we'll returned a cached value below */
764 }
765 else
766 {
767 /* request was sent -- wait for the response */
768 lrc = wait_for_completion_interruptible_timeout(&context.completion,
769 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 if (lrc <= 0)
771 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800772 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700773 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 /* we'll now returned a cached value below */
775 }
776 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800777
778 /* either we never sent a request, we sent a request and received a
779 response or we sent a request and timed out. if we never sent a
780 request or if we sent a request and got a response, we want to
781 clear the magic out of paranoia. if we timed out there is a
782 race condition such that the callback function could be
783 executing at the same time we are. of primary concern is if the
784 callback function had already verified the "magic" but had not
785 yet set the completion variable when a timeout occurred. we
786 serialize these activities by invalidating the magic while
787 holding a shared spinlock which will cause us to block if the
788 callback is currently executing */
789 spin_lock(&hdd_context_lock);
790 context.magic = 0;
791 spin_unlock(&hdd_context_lock);
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 *rssi_value = pAdapter->rssi;
794
795 return VOS_STATUS_SUCCESS;
796}
797
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530798VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
799{
800 struct statsContext context;
801 hdd_context_t *pHddCtx;
802 hdd_station_ctx_t *pHddStaCtx;
803 eHalStatus hstatus;
804 long lrc;
805 int valid;
806
807 if (NULL == pAdapter)
808 {
809 hddLog(VOS_TRACE_LEVEL_ERROR,
810 "%s: Invalid context, pAdapter", __func__);
811 return VOS_STATUS_E_FAULT;
812 }
813
814 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
815
816 valid = wlan_hdd_validate_context(pHddCtx);
817 if (0 != valid)
818 {
819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
820 return VOS_STATUS_E_FAULT;
821 }
822
823 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
824 if (NULL == pHddStaCtx)
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
827 return VOS_STATUS_E_FAULT;
828 }
829
830 init_completion(&context.completion);
831 context.pAdapter = pAdapter;
832 context.magic = SNR_CONTEXT_MAGIC;
833
834 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
835 pHddStaCtx->conn_info.staId[ 0 ],
836 pHddStaCtx->conn_info.bssId,
837 &context);
838 if (eHAL_STATUS_SUCCESS != hstatus)
839 {
840 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
841 __func__);
842 /* we'll returned a cached value below */
843 }
844 else
845 {
846 /* request was sent -- wait for the response */
847 lrc = wait_for_completion_interruptible_timeout(&context.completion,
848 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530849 if (lrc <= 0)
850 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530852 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530853 /* we'll now returned a cached value below */
854 }
855 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800856
857 /* either we never sent a request, we sent a request and received a
858 response or we sent a request and timed out. if we never sent a
859 request or if we sent a request and got a response, we want to
860 clear the magic out of paranoia. if we timed out there is a
861 race condition such that the callback function could be
862 executing at the same time we are. of primary concern is if the
863 callback function had already verified the "magic" but had not
864 yet set the completion variable when a timeout occurred. we
865 serialize these activities by invalidating the magic while
866 holding a shared spinlock which will cause us to block if the
867 callback is currently executing */
868 spin_lock(&hdd_context_lock);
869 context.magic = 0;
870 spin_unlock(&hdd_context_lock);
871
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530872 *snr = pAdapter->snr;
873
874 return VOS_STATUS_SUCCESS;
875}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800876#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800877
878static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
879{
880 struct statsContext *pStatsContext;
881 hdd_adapter_t *pAdapter;
882 if (ioctl_debug)
883 {
884 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
885 __func__, (int)rssi, (int)staId, pContext);
886 }
887
888 if (NULL == pContext)
889 {
890 hddLog(VOS_TRACE_LEVEL_ERROR,
891 "%s: Bad param, pContext [%p]",
892 __func__, pContext);
893 return;
894 }
895
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800896 pStatsContext = pContext;
897 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800898
899 /* there is a race condition that exists between this callback
900 function and the caller since the caller could time out either
901 before or while this code is executing. we use a spinlock to
902 serialize these actions */
903 spin_lock(&hdd_context_lock);
904
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800905 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
906 {
907 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800908 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800909 hddLog(VOS_TRACE_LEVEL_WARN,
910 "%s: Invalid context, pAdapter [%p] magic [%08x]",
911 __func__, pAdapter, pStatsContext->magic);
912 if (ioctl_debug)
913 {
914 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
915 __func__, pAdapter, pStatsContext->magic);
916 }
917 return;
918 }
919
Jeff Johnson72a40512013-12-19 10:14:15 -0800920 /* context is valid so caller is still waiting */
921
922 /* paranoia: invalidate the magic */
923 pStatsContext->magic = 0;
924
925 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800926 pAdapter->rssi = rssi;
927
Jeff Johnson72a40512013-12-19 10:14:15 -0800928 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800929 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800930
931 /* serialization is complete */
932 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800933}
934
935
936
937VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
938{
939 struct statsContext context;
940 hdd_context_t *pHddCtx = NULL;
941 hdd_station_ctx_t *pHddStaCtx = NULL;
942 eHalStatus hstatus;
943 long lrc;
944
945 if (NULL == pAdapter)
946 {
947 hddLog(VOS_TRACE_LEVEL_WARN,
948 "%s: Invalid context, pAdapter", __func__);
949 return VOS_STATUS_E_FAULT;
950 }
951 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
952 {
953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
954 /* return a cached value */
955 *rssi_value = pAdapter->rssi;
956 return VOS_STATUS_SUCCESS;
957 }
958
959 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
960 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
961
962 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
963 {
964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
965 /* return a cached value */
966 *rssi_value = 0;
967 return VOS_STATUS_SUCCESS;
968 }
969 init_completion(&context.completion);
970 context.pAdapter = pAdapter;
971 context.magic = RSSI_CONTEXT_MAGIC;
972
973 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
974 pHddStaCtx->conn_info.staId[ 0 ],
975 pHddStaCtx->conn_info.bssId,
976 &context, pHddCtx->pvosContext);
977 if (eHAL_STATUS_SUCCESS != hstatus)
978 {
979 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
980 __func__);
981 /* we'll returned a cached value below */
982 }
983 else
984 {
985 /* request was sent -- wait for the response */
986 lrc = wait_for_completion_interruptible_timeout(&context.completion,
987 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800988 if (lrc <= 0)
989 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800990 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800991 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800992 /* we'll now returned a cached value below */
993 }
994 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800995
996 /* either we never sent a request, we sent a request and received a
997 response or we sent a request and timed out. if we never sent a
998 request or if we sent a request and got a response, we want to
999 clear the magic out of paranoia. if we timed out there is a
1000 race condition such that the callback function could be
1001 executing at the same time we are. of primary concern is if the
1002 callback function had already verified the "magic" but had not
1003 yet set the completion variable when a timeout occurred. we
1004 serialize these activities by invalidating the magic while
1005 holding a shared spinlock which will cause us to block if the
1006 callback is currently executing */
1007 spin_lock(&hdd_context_lock);
1008 context.magic = 0;
1009 spin_unlock(&hdd_context_lock);
1010
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001011 *rssi_value = pAdapter->rssi;
1012
1013 return VOS_STATUS_SUCCESS;
1014}
1015#endif
1016
1017
Jeff Johnson295189b2012-06-20 16:38:30 -07001018void hdd_StatisticsCB( void *pStats, void *pContext )
1019{
1020 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1021 hdd_stats_t *pStatsCache = NULL;
1022 hdd_wext_state_t *pWextState;
1023 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1024
1025 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1026 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1027 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1028 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1029 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1030 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1031
1032 if (pAdapter!= NULL)
1033 pStatsCache = &pAdapter->hdd_stats;
1034
1035
1036 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1037 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1038 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1039 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1040 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1041 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1042
1043 if (pStatsCache!=NULL)
1044 {
1045 // and copy the stats into the cache we keep in the adapter instance structure
1046 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1047 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1048 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1049 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1050 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1051 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1052 }
1053
1054 if(pAdapter)
1055 {
1056 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1057 if(pWextState)
1058 {
1059 vos_status = vos_event_set(&pWextState->vosevent);
1060 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1061 {
1062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001063 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 return;
1065 }
1066 }
1067 }
1068}
1069
1070void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1071{
1072 v_CONTEXT_t pVosContext;
1073 hdd_context_t *pHddCtx;
1074 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1075#if 0
1076 hdd_wext_state_t *pWextState;
1077 v_U32_t roamId;
1078#endif
1079
1080 ENTER();
1081
1082 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1083
1084 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1085 if (NULL == pHddCtx)
1086 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001087 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 return;
1089 }
1090#if 0
1091 pWextState = pAdapter->pWextState;
1092#endif
1093
1094 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1095 {
1096 //TODO Verify is this is really used. If yes need to fix it.
1097 hdd_reconnect_all_adapters( pHddCtx );
1098#if 0
1099 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1100 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1101 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1102
1103 if(VOS_STATUS_SUCCESS == vosStatus)
1104 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1105 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1106
1107 sme_RoamConnect(halHandle,
1108 pAdapter->sessionId, &(pWextState->roamProfile),
1109 &roamId);
1110#endif
1111 }
1112
1113 EXIT();
1114
1115}
1116
1117void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1118{
1119 int i = 0;
1120 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1121
1122 /* clear WPA/RSN/WSC IE information in the profile */
1123 pWextState->roamProfile.nWPAReqIELength = 0;
1124 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1125 pWextState->roamProfile.nRSNReqIELength = 0;
1126 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1127
Chet Lanctot186b5732013-03-18 10:26:30 -07001128#ifdef FEATURE_WLAN_WAPI
1129 pWextState->roamProfile.nWAPIReqIELength = 0;
1130 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1131#endif
1132
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001134 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301136 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1138 pWextState->roamProfile.nAddIEAssocLength = 0;
1139
1140 pWextState->roamProfile.EncryptionType.numEntries = 1;
1141 pWextState->roamProfile.EncryptionType.encryptionType[0]
1142 = eCSR_ENCRYPT_TYPE_NONE;
1143
1144 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1145 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1146 = eCSR_ENCRYPT_TYPE_NONE;
1147
1148 pWextState->roamProfile.AuthType.numEntries = 1;
1149 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1150
Chet Lanctot186b5732013-03-18 10:26:30 -07001151#ifdef WLAN_FEATURE_11W
1152 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1153 pWextState->roamProfile.MFPRequired = 0;
1154 pWextState->roamProfile.MFPCapable = 0;
1155#endif
1156
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 pWextState->authKeyMgmt = 0;
1158
1159 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1160 {
1161 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1162 {
1163 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1164 }
1165 }
1166#ifdef FEATURE_WLAN_WAPI
1167 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1168 pAdapter->wapi_info.nWapiMode = 0;
1169#endif
1170
1171 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1172
1173}
1174
1175void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1176{
1177 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001178
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001179 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1180 {
1181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1182 "%s: Invalid pAdapter magic", __func__);
1183 }
1184 else
1185 {
1186 complete(&pAdapter->ula_complete);
1187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001188}
1189
1190VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1191{
1192 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001194 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001195
1196 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1197 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001198 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001199
1200 /*To avoid race condition between the set key and the last EAPOL
1201 packet, notify TL to finish upper layer authentication incase if the
1202 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001203 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001204
1205 if ( vos_status != VOS_STATUS_SUCCESS )
1206 {
1207 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1208 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1209 __LINE__, vos_status );
1210 return vos_status;
1211
1212 }
1213
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001214 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301216 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001217 {
1218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301219 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001220 /* we'll still fall through and return success since the
1221 * connection may still get established but is just taking
1222 * too long for us to wait */
1223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 }
1225 return VOS_STATUS_SUCCESS;
1226}
1227
1228v_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)
1229{
1230
1231 int left = ie_len;
1232 v_U8_t *ptr = ie;
1233 v_U8_t elem_id,elem_len;
1234 v_U8_t eid = 0xDD;
1235
1236 if ( NULL == ie || 0 == ie_len )
1237 return NULL;
1238
1239 while(left >= 2)
1240 {
1241 elem_id = ptr[0];
1242 elem_len = ptr[1];
1243 left -= 2;
1244 if(elem_len > left)
1245 {
1246 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001247 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 eid,elem_len,left);
1249 return NULL;
1250 }
1251 if (elem_id == eid)
1252 {
1253 if(memcmp( &ptr[2], oui, oui_size)==0)
1254 return ptr;
1255 }
1256
1257 left -= elem_len;
1258 ptr += (elem_len + 2);
1259 }
1260 return NULL;
1261}
1262
1263static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1264 union iwreq_data *wrqu, char *extra)
1265{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001266 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 /* Do nothing for now */
1268 return 0;
1269}
1270
1271static int iw_get_name(struct net_device *dev,
1272 struct iw_request_info *info,
1273 char *wrqu, char *extra)
1274{
1275
1276 ENTER();
1277 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1278 EXIT();
1279 return 0;
1280}
1281
1282static int iw_set_mode(struct net_device *dev,
1283 struct iw_request_info *info,
1284 union iwreq_data *wrqu, char *extra)
1285{
1286 hdd_wext_state_t *pWextState;
1287 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1288 tCsrRoamProfile *pRoamProfile;
1289 eCsrRoamBssType LastBSSType;
1290 eMib_dot11DesiredBssType connectedBssType;
1291 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001293
1294 ENTER();
1295
1296 if (NULL == pAdapter)
1297 {
1298 hddLog(VOS_TRACE_LEVEL_WARN,
1299 "%s: Invalid context, pAdapter", __func__);
1300 return 0;
1301 }
1302
1303 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1305 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001306 return 0;
1307 }
1308
1309 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1310 if (pWextState == NULL)
1311 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301312 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 return -EINVAL;
1314 }
1315
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 pRoamProfile = &pWextState->roamProfile;
1318 LastBSSType = pRoamProfile->BSSType;
1319
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301320 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001321
1322 switch (wrqu->mode)
1323 {
1324 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301325 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1327 // Set the phymode correctly for IBSS.
1328 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1329 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001330 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 break;
1333 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301334 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 break;
1338 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301339 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1341 break;
1342 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301343 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 return -EOPNOTSUPP;
1345 }
1346
1347 if ( LastBSSType != pRoamProfile->BSSType )
1348 {
1349 //the BSS mode changed
1350 // We need to issue disconnect if connected or in IBSS disconnect state
1351 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1352 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1353 {
1354 VOS_STATUS vosStatus;
1355 // need to issue a disconnect to CSR.
1356 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1357 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1358 pAdapter->sessionId,
1359 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1360 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301361 {
1362 long ret;
1363 ret = wait_for_completion_interruptible_timeout(
1364 &pAdapter->disconnect_comp_var,
1365 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1366 if (ret <= 0)
1367 hddLog(VOS_TRACE_LEVEL_ERROR,
1368 FL("failed wait on disconnect_comp_var %ld"), ret);
1369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 }
1371 }
1372
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 EXIT();
1374 return 0;
1375}
1376
1377
1378static int iw_get_mode(struct net_device *dev,
1379 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301380 union iwreq_data *wrqu,
1381 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001382{
1383
1384 hdd_wext_state_t *pWextState;
1385 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1386
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301387 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
1389 if (NULL == pAdapter)
1390 {
1391 hddLog(VOS_TRACE_LEVEL_WARN,
1392 "%s: Invalid context, pAdapter", __func__);
1393 return 0;
1394 }
1395
1396 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1398 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 return 0;
1400 }
1401
1402 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1403 if (pWextState == NULL)
1404 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301405 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 return -EINVAL;
1407 }
1408
1409 switch (pWextState->roamProfile.BSSType)
1410 {
1411 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001412 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301413 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 break;
1415 case eCSR_BSS_TYPE_IBSS:
1416 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001417 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301418 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 break;
1420 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001421 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301422 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 break;
1424 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001425 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 break;
1427 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301428
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 return 0;
1430}
1431
1432static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1433 union iwreq_data *wrqu, char *extra)
1434{
1435 v_U32_t numChans = 0;
1436 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1437 v_U32_t indx = 0;
1438 v_U32_t status = 0;
1439
1440 hdd_wext_state_t *pWextState;
1441 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1442 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1443 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1444 tCsrRoamProfile * pRoamProfile;
1445 ENTER();
1446
1447 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1449 return status;
1450 }
1451
1452 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1453
1454 pRoamProfile = &pWextState->roamProfile;
1455
Arif Hussain6d2a3322013-11-17 19:50:10 -08001456 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001457
1458 /* Link is up then return cant set channel*/
1459 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1460 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1461 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001462 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 return -EOPNOTSUPP;
1464 }
1465
1466 /* Settings by Frequency as input */
1467 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1468 (wrqu->freq.m <= (tANI_U32)5.825e8))
1469 {
1470 tANI_U32 freq = wrqu->freq.m / 100000;
1471
1472 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1473 indx++;
1474 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1475 {
1476 return -EINVAL;
1477 }
1478 wrqu->freq.e = 0;
1479 wrqu->freq.m = freq_chan_map[indx].chan;
1480
1481 }
1482
1483 if (wrqu->freq.e == 0)
1484 {
1485 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1486 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1487 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001488 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001489 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1491 return -EINVAL;
1492 }
1493
1494 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1495
1496 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1497 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1499 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 return -EIO;
1501 }
1502
1503 for (indx = 0; indx < numChans; indx++) {
1504 if (wrqu->freq.m == validChan[indx]){
1505 break;
1506 }
1507 }
1508 }
1509 else{
1510
1511 return -EINVAL;
1512 }
1513
1514 if(indx >= numChans)
1515 {
1516 return -EINVAL;
1517 }
1518
1519 /* Set the Operational Channel */
1520 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1521 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1522 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1523
Arif Hussain6d2a3322013-11-17 19:50:10 -08001524 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001525
1526 EXIT();
1527
1528 return status;
1529}
1530
1531static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1532 struct iw_freq *fwrq, char *extra)
1533{
Jeff Johnsone7245742012-09-05 17:12:55 -07001534 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1536 tHalHandle hHal;
1537 hdd_wext_state_t *pWextState;
1538 tCsrRoamProfile * pRoamProfile;
1539 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1540
1541 ENTER();
1542
1543 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1545 return status;
1546 }
1547
1548 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1549 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1550
1551 pRoamProfile = &pWextState->roamProfile;
1552
1553 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1554 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001555 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 {
c_hpothub8245442013-11-20 23:41:09 +05301557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1558 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 return -EIO;
1560 }
1561 else
1562 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001563 status = hdd_wlan_get_freq(channel, &freq);
1564 if( TRUE == status )
1565 {
1566 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1567 * iwlist & iwconfig command shows frequency into proper
1568 * format (2.412 GHz instead of 246.2 MHz)*/
1569 fwrq->m = freq;
1570 fwrq->e = MHZ;
1571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 }
1573 }
1574 else
1575 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001576 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1577 * iwlist & iwconfig command shows frequency into proper
1578 * format (2.412 GHz instead of 246.2 MHz)*/
1579 fwrq->m = 0;
1580 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001582 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001583}
1584
1585static int iw_get_tx_power(struct net_device *dev,
1586 struct iw_request_info *info,
1587 union iwreq_data *wrqu, char *extra)
1588{
1589
1590 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1591 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1592 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1593
1594 if (pHddCtx->isLogpInProgress)
1595 {
1596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1597 "%s:LOGP in Progress. Ignore!!!",__func__);
1598 return -EBUSY;
1599 }
1600
1601 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1602 {
1603 wrqu->txpower.value = 0;
1604 return 0;
1605 }
1606 wlan_hdd_get_classAstats(pAdapter);
1607 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1608
1609 return 0;
1610}
1611
1612static int iw_set_tx_power(struct net_device *dev,
1613 struct iw_request_info *info,
1614 union iwreq_data *wrqu, char *extra)
1615{
1616 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1617 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1618
1619 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1620 {
1621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1622 return 0;
1623 }
1624
1625 ENTER();
1626
1627 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1628 {
c_hpothub8245442013-11-20 23:41:09 +05301629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1630 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 return -EIO;
1632 }
1633
1634 EXIT();
1635
1636 return 0;
1637}
1638
1639static int iw_get_bitrate(struct net_device *dev,
1640 struct iw_request_info *info,
1641 union iwreq_data *wrqu, char *extra)
1642{
1643 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1644 eHalStatus status = eHAL_STATUS_SUCCESS;
1645 hdd_wext_state_t *pWextState;
1646 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1647 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1648
1649 ENTER();
1650
1651 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1653 return status;
1654 }
1655
1656 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1657 wrqu->bitrate.value = 0;
1658 }
1659 else {
1660 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1661 SME_SUMMARY_STATS |
1662 SME_GLOBAL_CLASSA_STATS |
1663 SME_GLOBAL_CLASSB_STATS |
1664 SME_GLOBAL_CLASSC_STATS |
1665 SME_GLOBAL_CLASSD_STATS |
1666 SME_PER_STA_STATS,
1667 hdd_StatisticsCB, 0, FALSE,
1668 pHddStaCtx->conn_info.staId[0], pAdapter );
1669
1670 if(eHAL_STATUS_SUCCESS != status)
1671 {
1672 hddLog(VOS_TRACE_LEVEL_ERROR,
1673 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001674 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 return status;
1676 }
1677
1678 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1679
1680 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1681
1682 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1683 {
1684 hddLog(VOS_TRACE_LEVEL_ERROR,
1685 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001686 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 return VOS_STATUS_E_FAILURE;
1688 }
1689
1690 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1691 }
1692
1693 EXIT();
1694
1695 return vos_status;
1696}
1697/* ccm call back function */
1698
1699static int iw_set_bitrate(struct net_device *dev,
1700 struct iw_request_info *info,
1701 union iwreq_data *wrqu,
1702 char *extra)
1703{
1704 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1705 hdd_wext_state_t *pWextState;
1706 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1707 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1708 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1709 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1710 v_U32_t i, rate;
1711 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1712
1713 ENTER();
1714
1715 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1717 return 0;
1718 }
1719
1720 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1721
1722 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1723 {
1724 return -ENXIO ;
1725 }
1726
1727 rate = wrqu->bitrate.value;
1728
1729 if (rate == -1)
1730 {
1731 rate = WNI_CFG_FIXED_RATE_AUTO;
1732 valid_rate = TRUE;
1733 }
1734 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1735 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1736 {
1737 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1738 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1739 {
1740 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1741 WNI_CFG_SUPPORTED_RATES_11A,
1742 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1743 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1744 WNI_CFG_SUPPORTED_RATES_11B,
1745 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1746 {
1747 for (i = 0; i < (b_len + a_len); ++i)
1748 {
1749 /* supported rates returned is double the actual rate so we divide it by 2 */
1750 if ((supp_rates[i]&0x7F)/2 == rate)
1751 {
1752 valid_rate = TRUE;
1753 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1754 break;
1755 }
1756 }
1757 }
1758 }
1759 }
1760 if (valid_rate != TRUE)
1761 {
1762 return -EINVAL;
1763 }
1764 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1765 WNI_CFG_FIXED_RATE, rate,
1766 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1767 {
c_hpothub8245442013-11-20 23:41:09 +05301768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1769 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 return -EIO;
1771 }
1772 return 0;
1773}
1774
1775
1776static int iw_set_genie(struct net_device *dev,
1777 struct iw_request_info *info,
1778 union iwreq_data *wrqu,
1779 char *extra)
1780{
1781 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1782 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001783 u_int8_t *genie = NULL;
1784 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 v_U16_t remLen;
1786
1787 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001788
1789 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1791 "%s:LOGP in Progress. Ignore!!!", __func__);
1792 return 0;
1793 }
1794
1795 if (!wrqu->data.length) {
1796 hdd_clearRoamProfileIe(pAdapter);
1797 EXIT();
1798 return 0;
1799 }
1800
1801 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1802 wrqu->data.length);
1803 if (NULL == base_genie)
1804 {
1805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1806 "mem_alloc_copy_from_user_helper fail");
1807 return -ENOMEM;
1808 }
1809
1810 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001811
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 remLen = wrqu->data.length;
1813
Arif Hussain6d2a3322013-11-17 19:50:10 -08001814 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001815
1816 /* clear any previous genIE before this call */
1817 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1818
1819 while (remLen >= 2)
1820 {
1821 v_U16_t eLen = 0;
1822 v_U8_t elementId;
1823 elementId = *genie++;
1824 eLen = *genie++;
1825 remLen -= 2;
1826
Arif Hussain6d2a3322013-11-17 19:50:10 -08001827 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 __func__, elementId, eLen);
1829
1830 switch ( elementId )
1831 {
1832 case IE_EID_VENDOR:
1833 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001834 {
1835 kfree(base_genie);
1836 return -EINVAL;
1837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001838
1839 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1840 {
1841 v_U16_t curGenIELen = pWextState->genIE.length;
1842 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1843 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1844
1845 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1846 {
1847 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001848 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001850 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 return -ENOMEM;
1852 }
1853 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1854 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1855 pWextState->genIE.length += eLen + 2;
1856 }
1857 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1858 {
1859 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1860 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1861 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1862 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1863 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1864 }
1865 else /* any vendorId except WPA IE should be accumulated to genIE */
1866 {
1867 v_U16_t curGenIELen = pWextState->genIE.length;
1868 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1869 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1870
1871 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1872 {
1873 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001874 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001876 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 return -ENOMEM;
1878 }
1879 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1880 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1881 pWextState->genIE.length += eLen + 2;
1882 }
1883 break;
1884 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001885 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1887 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1888 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1889 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1890 break;
1891
1892 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001893 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001894 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 return 0;
1896 }
1897 genie += eLen;
1898 remLen -= eLen;
1899 }
1900 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001901 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 return 0;
1903}
1904
1905static int iw_get_genie(struct net_device *dev,
1906 struct iw_request_info *info,
1907 union iwreq_data *wrqu,
1908 char *extra)
1909{
1910 hdd_wext_state_t *pWextState;
1911 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1912 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1913 eHalStatus status;
1914 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1915 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1916
1917 ENTER();
1918
1919 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1921 return 0;
1922 }
1923
1924
Arif Hussain6d2a3322013-11-17 19:50:10 -08001925 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001926
1927 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1928
1929 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1930 {
1931 return -ENXIO;
1932 }
1933
1934 // Return something ONLY if we are associated with an RSN or WPA network
1935 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1936 pWextState->roamProfile.negotiatedAuthType))
1937 {
1938 return -ENXIO;
1939 }
1940
1941 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1942 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1943 pAdapter->sessionId,
1944 &length,
1945 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001946 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1947 if (wrqu->data.length < length)
1948 {
1949 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1950 return -EFAULT;
1951 }
Arif Hussain9f05be02014-02-05 12:06:53 -08001952 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001953 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001954
Arif Hussain6d2a3322013-11-17 19:50:10 -08001955 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001956
1957 EXIT();
1958
1959 return 0;
1960}
1961
1962static int iw_get_encode(struct net_device *dev,
1963 struct iw_request_info *info,
1964 struct iw_point *dwrq, char *extra)
1965{
1966 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1967 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1968 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1969 int keyId;
1970 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1971 int i;
1972
1973 ENTER();
1974
1975 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1977 return 0;
1978 }
1979
1980 keyId = pRoamProfile->Keys.defaultIndex;
1981
1982 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1983 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001984 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 return -EINVAL;
1986 }
1987
1988 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1989 {
1990 dwrq->flags |= IW_ENCODE_ENABLED;
1991 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1992 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1993
1994 dwrq->flags |= (keyId + 1);
1995
1996 }
1997 else
1998 {
1999 dwrq->flags |= IW_ENCODE_DISABLED;
2000 }
2001
2002 for(i=0; i < MAX_WEP_KEYS; i++)
2003 {
2004 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2005 {
2006 continue;
2007 }
2008 else
2009 {
2010 break;
2011 }
2012 }
2013
2014 if(MAX_WEP_KEYS == i)
2015 {
2016 dwrq->flags |= IW_ENCODE_NOKEY;
2017 }
2018
2019 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2020
2021 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2022 {
2023 dwrq->flags |= IW_ENCODE_OPEN;
2024 }
2025 else
2026 {
2027 dwrq->flags |= IW_ENCODE_RESTRICTED;
2028 }
2029 EXIT();
2030 return 0;
2031}
2032
2033#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2034#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2035
2036
2037/*
2038 * This function sends a single 'key' to LIM at all time.
2039 */
2040
2041static int iw_get_rts_threshold(struct net_device *dev,
2042 struct iw_request_info *info,
2043 union iwreq_data *wrqu, char *extra)
2044{
2045 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2046 v_U32_t status = 0;
2047
2048 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2049
2050 return status;
2051}
2052
2053static int iw_set_rts_threshold(struct net_device *dev,
2054 struct iw_request_info *info,
2055 union iwreq_data *wrqu, char *extra)
2056{
2057 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2058 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2059
2060 ENTER();
2061
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002062 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2063 {
2064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2065 "%s:LOGP in Progress. Ignore!!!", __func__);
2066 return -EAGAIN;
2067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2069 {
2070 return -EINVAL;
2071 }
2072
2073 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2074 {
c_hpothub8245442013-11-20 23:41:09 +05302075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2076 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 return -EIO;
2078 }
2079
2080 EXIT();
2081
2082 return 0;
2083}
2084
2085static int iw_get_frag_threshold(struct net_device *dev,
2086 struct iw_request_info *info,
2087 union iwreq_data *wrqu, char *extra)
2088{
2089 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2090 v_U32_t status = 0;
2091
2092 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2093
2094 return status;
2095}
2096
2097static int iw_set_frag_threshold(struct net_device *dev,
2098 struct iw_request_info *info,
2099 union iwreq_data *wrqu, char *extra)
2100{
2101 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2102 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2103
2104 ENTER();
2105
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002106 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2107 {
2108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2109 "%s:LOGP in Progress. Ignore!!!", __func__);
2110 return -EBUSY;
2111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2113 {
2114 return -EINVAL;
2115 }
2116
2117 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2118 {
c_hpothub8245442013-11-20 23:41:09 +05302119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2120 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 return -EIO;
2122 }
2123
2124 EXIT();
2125
2126 return 0;
2127}
2128
2129static int iw_get_power_mode(struct net_device *dev,
2130 struct iw_request_info *info,
2131 union iwreq_data *wrqu, char *extra)
2132{
2133 ENTER();
2134 return -EOPNOTSUPP;
2135}
2136
2137static int iw_set_power_mode(struct net_device *dev,
2138 struct iw_request_info *info,
2139 union iwreq_data *wrqu, char *extra)
2140{
2141 ENTER();
2142 return -EOPNOTSUPP;
2143}
2144
2145static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2146 union iwreq_data *wrqu, char *extra)
2147{
2148 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2149 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2150 struct iw_range *range = (struct iw_range *) extra;
2151
2152 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2153
2154 v_U32_t num_channels = sizeof(channels);
2155 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2156 v_U32_t a_len;
2157 v_U32_t b_len;
2158 v_U32_t active_phy_mode = 0;
2159 v_U8_t index = 0, i;
2160
2161 ENTER();
2162
2163 wrqu->data.length = sizeof(struct iw_range);
2164 memset(range, 0, sizeof(struct iw_range));
2165
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002166 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2167 {
2168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2169 "%s:LOGP in Progress. Ignore!!!", __func__);
2170 return -EBUSY;
2171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002172
2173 /*Get the phy mode*/
2174 if (ccmCfgGetInt(hHal,
2175 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2176 {
2177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002178 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002179
2180 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2181 {
2182 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002183 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 if (ccmCfgGetStr(hHal,
2185 WNI_CFG_SUPPORTED_RATES_11A,
2186 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2187 {
2188 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2189 {
2190 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2191 }
2192 for (i = 0; i < a_len; i++)
2193 {
2194 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2195 }
2196 range->num_bitrates = a_len;
2197 }
2198 else
2199 {
2200 return -EIO;
2201 }
2202 }
2203 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2204 {
2205 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002206 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 if (ccmCfgGetStr(hHal,
2208 WNI_CFG_SUPPORTED_RATES_11B,
2209 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2210 {
2211 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2212 {
2213 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2214 }
2215 for (i = 0; i < b_len; i++)
2216 {
2217 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2218 }
2219 range->num_bitrates = b_len;
2220 }
2221 else
2222 {
2223 return -EIO;
2224 }
2225 }
2226 }
2227
2228 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2229 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2230 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2231
2232 range->encoding_size[0] = 5;
2233 range->encoding_size[1] = 13;
2234 range->num_encoding_sizes = 2;
2235 range->max_encoding_tokens = MAX_WEP_KEYS;
2236
2237 // we support through Wireless Extensions 22
2238 range->we_version_compiled = WIRELESS_EXT;
2239 range->we_version_source = 22;
2240
2241 /*Supported Channels and Frequencies*/
2242 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2243 {
c_hpothub8245442013-11-20 23:41:09 +05302244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2245 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 return -EIO;
2247 }
2248 if (num_channels > IW_MAX_FREQUENCIES)
2249 {
2250 num_channels = IW_MAX_FREQUENCIES;
2251 }
2252
2253 range->num_channels = num_channels;
2254 range->num_frequency = num_channels;
2255
2256 for (index=0; index < num_channels; index++)
2257 {
2258 v_U32_t frq_indx = 0;
2259
2260 range->freq[index].i = channels[index];
2261 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2262 {
2263 if(channels[index] == freq_chan_map[frq_indx].chan)
2264 {
2265 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2266 range->freq[index].e = 1;
2267 break;
2268 }
2269 frq_indx++;
2270 }
2271 }
2272
2273 /* Event capability (kernel + driver) */
2274 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2275 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2276 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2277 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2278
2279 /*Encryption capability*/
2280 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2281 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2282
2283 /* Txpower capability */
2284 range->txpower_capa = IW_TXPOW_MWATT;
2285
2286 /*Scanning capability*/
2287 #if WIRELESS_EXT >= 22
2288 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2289 #endif
2290
2291 EXIT();
2292 return 0;
2293}
2294
2295/* Callback function registered with PMC to know status of PMC request */
2296static void iw_power_callback_fn (void *pContext, eHalStatus status)
2297{
2298 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002299
2300 if (NULL == pContext)
2301 {
2302 hddLog(VOS_TRACE_LEVEL_ERROR,
2303 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002304 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 return;
2306 }
2307
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002309
Jeff Johnson72a40512013-12-19 10:14:15 -08002310 /* there is a race condition that exists between this callback
2311 function and the caller since the caller could time out either
2312 before or while this code is executing. we use a spinlock to
2313 serialize these actions */
2314 spin_lock(&hdd_context_lock);
2315
2316 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 {
2318 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002319 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002321 "%s: Invalid context, magic [%08x]",
2322 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002323
2324 if (ioctl_debug)
2325 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002326 pr_info("%s: Invalid context, magic [%08x]\n",
2327 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 }
2329 return;
2330 }
2331
Jeff Johnson72a40512013-12-19 10:14:15 -08002332 /* context is valid so caller is still waiting */
2333
2334 /* paranoia: invalidate the magic */
2335 pStatsContext->magic = 0;
2336
2337 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002339
2340 /* serialization is complete */
2341 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002342}
2343
2344/* Callback function for tx per hit */
2345void hdd_tx_per_hit_cb (void *pCallbackContext)
2346{
2347 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2348 unsigned char tx_fail[16];
2349 union iwreq_data wrqu;
2350
2351 if (NULL == pAdapter)
2352 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002353 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 return;
2355 }
2356 memset(&wrqu, 0, sizeof(wrqu));
2357 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2358 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2359}
2360
2361void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2362{
2363 struct statsContext *pStatsContext;
2364 tCsrGlobalClassAStatsInfo *pClassAStats;
2365 hdd_adapter_t *pAdapter;
2366
2367 if (ioctl_debug)
2368 {
2369 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002370 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 }
2372
2373 if ((NULL == pStats) || (NULL == pContext))
2374 {
2375 hddLog(VOS_TRACE_LEVEL_ERROR,
2376 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002377 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 return;
2379 }
2380
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 pClassAStats = pStats;
2382 pStatsContext = pContext;
2383 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002384
2385 /* there is a race condition that exists between this callback
2386 function and the caller since the caller could time out either
2387 before or while this code is executing. we use a spinlock to
2388 serialize these actions */
2389 spin_lock(&hdd_context_lock);
2390
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2392 {
2393 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002394 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 hddLog(VOS_TRACE_LEVEL_WARN,
2396 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002397 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 if (ioctl_debug)
2399 {
2400 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002401 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 }
2403 return;
2404 }
2405
Jeff Johnson72a40512013-12-19 10:14:15 -08002406 /* context is valid so caller is still waiting */
2407
2408 /* paranoia: invalidate the magic */
2409 pStatsContext->magic = 0;
2410
2411 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2413
Jeff Johnson72a40512013-12-19 10:14:15 -08002414 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002416
2417 /* serialization is complete */
2418 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002419}
2420
2421VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2422{
2423 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2424 eHalStatus hstatus;
2425 long lrc;
2426 struct statsContext context;
2427
2428 if (NULL == pAdapter)
2429 {
2430 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2431 return VOS_STATUS_E_FAULT;
2432 }
2433 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2434 {
2435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2436 return VOS_STATUS_SUCCESS;
2437 }
2438
2439 /* we are connected
2440 prepare our callback context */
2441 init_completion(&context.completion);
2442 context.pAdapter = pAdapter;
2443 context.magic = STATS_CONTEXT_MAGIC;
2444 /* query only for Class A statistics (which include link speed) */
2445 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2446 eCSR_HDD,
2447 SME_GLOBAL_CLASSA_STATS,
2448 hdd_GetClassA_statisticsCB,
2449 0, // not periodic
2450 FALSE, //non-cached results
2451 pHddStaCtx->conn_info.staId[0],
2452 &context);
2453 if (eHAL_STATUS_SUCCESS != hstatus)
2454 {
2455 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002456 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002457 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 /* we'll returned a cached value below */
2459 }
2460 else
2461 {
2462 /* request was sent -- wait for the response */
2463 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2464 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 if (lrc <= 0)
2466 {
2467 hddLog(VOS_TRACE_LEVEL_ERROR,
2468 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002469 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 }
2471 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002472
2473 /* either we never sent a request, we sent a request and received a
2474 response or we sent a request and timed out. if we never sent a
2475 request or if we sent a request and got a response, we want to
2476 clear the magic out of paranoia. if we timed out there is a
2477 race condition such that the callback function could be
2478 executing at the same time we are. of primary concern is if the
2479 callback function had already verified the "magic" but had not
2480 yet set the completion variable when a timeout occurred. we
2481 serialize these activities by invalidating the magic while
2482 holding a shared spinlock which will cause us to block if the
2483 callback is currently executing */
2484 spin_lock(&hdd_context_lock);
2485 context.magic = 0;
2486 spin_unlock(&hdd_context_lock);
2487
2488 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 return VOS_STATUS_SUCCESS;
2490}
2491
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002492static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2493{
2494 struct statsContext *pStatsContext;
2495 tCsrSummaryStatsInfo *pSummaryStats;
2496 tCsrGlobalClassAStatsInfo *pClassAStats;
2497 hdd_adapter_t *pAdapter;
2498
2499 if (ioctl_debug)
2500 {
2501 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002502 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002503 }
2504
2505 if ((NULL == pStats) || (NULL == pContext))
2506 {
2507 hddLog(VOS_TRACE_LEVEL_ERROR,
2508 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002509 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002510 return;
2511 }
2512
Jeff Johnson72a40512013-12-19 10:14:15 -08002513 /* there is a race condition that exists between this callback
2514 function and the caller since the caller could time out either
2515 before or while this code is executing. we use a spinlock to
2516 serialize these actions */
2517 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002518
2519 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2520 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2521 pStatsContext = pContext;
2522 pAdapter = pStatsContext->pAdapter;
2523 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2524 {
2525 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002526 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002527 hddLog(VOS_TRACE_LEVEL_WARN,
2528 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002529 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002530 if (ioctl_debug)
2531 {
2532 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002533 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002534 }
2535 return;
2536 }
2537
Jeff Johnson72a40512013-12-19 10:14:15 -08002538 /* context is valid so caller is still waiting */
2539
2540 /* paranoia: invalidate the magic */
2541 pStatsContext->magic = 0;
2542
2543 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002544 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2545 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2546
Jeff Johnson72a40512013-12-19 10:14:15 -08002547 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002548 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002549
2550 /* serialization is complete */
2551 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002552}
2553
2554VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2555{
2556 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2557 eHalStatus hstatus;
2558 long lrc;
2559 struct statsContext context;
2560
2561 if (NULL == pAdapter)
2562 {
2563 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2564 return VOS_STATUS_SUCCESS;
2565 }
2566
2567 /* we are connected
2568 prepare our callback context */
2569 init_completion(&context.completion);
2570 context.pAdapter = pAdapter;
2571 context.magic = STATS_CONTEXT_MAGIC;
2572
2573 /* query only for Summary & Class A statistics */
2574 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2575 eCSR_HDD,
2576 SME_SUMMARY_STATS |
2577 SME_GLOBAL_CLASSA_STATS,
2578 hdd_get_station_statisticsCB,
2579 0, // not periodic
2580 FALSE, //non-cached results
2581 pHddStaCtx->conn_info.staId[0],
2582 &context);
2583 if (eHAL_STATUS_SUCCESS != hstatus)
2584 {
2585 hddLog(VOS_TRACE_LEVEL_ERROR,
2586 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002587 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002588 /* we'll return with cached values */
2589 }
2590 else
2591 {
2592 /* request was sent -- wait for the response */
2593 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2594 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002595
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002596 if (lrc <= 0)
2597 {
2598 hddLog(VOS_TRACE_LEVEL_ERROR,
2599 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002600 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002601 }
2602 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002603
2604 /* either we never sent a request, we sent a request and received a
2605 response or we sent a request and timed out. if we never sent a
2606 request or if we sent a request and got a response, we want to
2607 clear the magic out of paranoia. if we timed out there is a
2608 race condition such that the callback function could be
2609 executing at the same time we are. of primary concern is if the
2610 callback function had already verified the "magic" but had not
2611 yet set the completion variable when a timeout occurred. we
2612 serialize these activities by invalidating the magic while
2613 holding a shared spinlock which will cause us to block if the
2614 callback is currently executing */
2615 spin_lock(&hdd_context_lock);
2616 context.magic = 0;
2617 spin_unlock(&hdd_context_lock);
2618
2619 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002620 return VOS_STATUS_SUCCESS;
2621}
2622
2623
Jeff Johnson295189b2012-06-20 16:38:30 -07002624/*
2625 * Support for the LINKSPEED private command
2626 * Per the WiFi framework the response must be of the form
2627 * "LinkSpeed xx"
2628 */
2629static int iw_get_linkspeed(struct net_device *dev,
2630 struct iw_request_info *info,
2631 union iwreq_data *wrqu, char *extra)
2632{
2633 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302634 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302636 int len = sizeof(v_U32_t) + 1;
2637 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302639 VOS_STATUS status;
2640 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302642 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2643
2644 valid = wlan_hdd_validate_context(pHddCtx);
2645
2646 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002647 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302648 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2649 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002650 }
2651
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2653 {
2654 /* we are not connected so we don't have a classAstats */
2655 link_speed = 0;
2656 }
2657 else
2658 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302659 status = wlan_hdd_get_classAstats(pAdapter);
2660
2661 if (!VOS_IS_STATUS_SUCCESS(status ))
2662 {
2663 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2664 return -EINVAL;
2665 }
2666
2667 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2668 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2669 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2670 &link_speed);
2671
2672 link_speed = link_speed / 10;
2673
2674 if (0 == link_speed)
2675 {
2676 /* The linkspeed returned by HAL is in units of 500kbps.
2677 * converting it to mbps.
2678 * This is required to support legacy firmware which does
2679 * not return link capacity.
2680 */
2681 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2682 }
2683
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 }
2685
2686 wrqu->data.length = len;
2687 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002688 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 if ((rc < 0) || (rc >= len))
2690 {
2691 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302692 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 return -EIO;
2694 }
2695
2696 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002697 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002698}
2699
Arif Hussain695279c2014-03-24 14:06:07 -07002700/*
2701 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2702 *
2703 */
2704static int iw_get_linkspeed_priv(struct net_device *dev,
2705 struct iw_request_info *info,
2706 union iwreq_data *wrqu, char *extra)
2707{
2708 int rc;
2709
2710 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2711
2712 if (rc < 0)
2713 return rc;
2714
2715 /* a value is being successfully returned */
2716 return 0;
2717}
Jeff Johnson295189b2012-06-20 16:38:30 -07002718
2719/*
2720 * Support for the RSSI & RSSI-APPROX private commands
2721 * Per the WiFi framework the response must be of the form
2722 * "<ssid> rssi <xx>"
2723 * unless we are not associated, in which case the response is
2724 * "OK"
2725 */
2726static int iw_get_rssi(struct net_device *dev,
2727 struct iw_request_info *info,
2728 union iwreq_data *wrqu, char *extra)
2729{
2730 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002731 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 int len = wrqu->data.length;
2733 v_S7_t s7Rssi = 0;
2734 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2735 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2736 VOS_STATUS vosStatus;
2737 int rc;
2738
2739 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2740 (0 == ssidlen) || (ssidlen >= len))
2741 {
2742 /* we are not connected or our SSID is too long
2743 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002744 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 }
2746 else
2747 {
2748 /* we are connected with a valid SSID
2749 so we can write the SSID into the return buffer
2750 (note that it is not NUL-terminated) */
2751 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2752
2753 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2754
2755 if (VOS_STATUS_SUCCESS == vosStatus)
2756 {
2757 /* append the rssi to the ssid in the format required by
2758 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002759 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302760 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 }
2762 else
2763 {
2764 rc = -1;
2765 }
2766 }
2767
2768 /* verify that we wrote a valid response */
2769 if ((rc < 0) || (rc >= len))
2770 {
2771 // encoding or length error?
2772 hddLog(VOS_TRACE_LEVEL_ERROR,
2773 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002774 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 return -EIO;
2776 }
2777
2778 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002779 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002780}
2781
2782/*
2783 * Support for SoftAP channel range private command
2784 */
2785static int iw_softap_set_channel_range( struct net_device *dev,
2786 int startChannel,
2787 int endChannel,
2788 int band)
2789{
Jeff Johnson43971f52012-07-17 12:26:56 -07002790 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 int ret = 0;
2792 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2793 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002794 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2795
Jeff Johnson295189b2012-06-20 16:38:30 -07002796
2797 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2798 if (VOS_STATUS_SUCCESS != status)
2799 {
2800 ret = -EINVAL;
2801 }
Yathish9f22e662012-12-10 14:21:35 -08002802 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 return ret;
2804}
2805
2806VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2807{
2808 struct statsContext context;
2809 eHalStatus status;
2810 hdd_context_t *pHddCtx;
2811
2812 if (NULL == pAdapter)
2813 {
2814 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2815 return VOS_STATUS_E_FAULT;
2816 }
2817
2818 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2819 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05302820 if (pHddCtx->isLogpInProgress) {
2821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2822 "%s:LOGP in Progress. Ignore!!!", __func__);
2823 return VOS_STATUS_E_FAILURE;
2824 }
2825
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 init_completion(&context.completion);
2827
2828 context.pAdapter = pAdapter;
2829 context.magic = POWER_CONTEXT_MAGIC;
2830
2831 if (DRIVER_POWER_MODE_ACTIVE == mode)
2832 {
2833 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2834 "Full Power", __func__);
2835 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2836 iw_power_callback_fn, &context,
2837 eSME_FULL_PWR_NEEDED_BY_HDD);
2838 // Enter Full power command received from GUI this means we are disconnected
2839 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2840 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2841 if (eHAL_STATUS_PMC_PENDING == status)
2842 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002843 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 int lrc = wait_for_completion_interruptible_timeout(
2845 &context.completion,
2846 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002847
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 if (lrc <= 0)
2849 {
2850 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002851 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 }
2853 }
2854 }
2855 else if (DRIVER_POWER_MODE_AUTO == mode)
2856 {
2857 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2858 {
2859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2860 __func__);
2861 // Enter BMPS command received from GUI this means DHCP is completed
2862 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2863 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2864 FALSE);
2865 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2866 iw_power_callback_fn, &context);
2867 if (eHAL_STATUS_PMC_PENDING == status)
2868 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002869 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 int lrc = wait_for_completion_interruptible_timeout(
2871 &context.completion,
2872 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 if (lrc <= 0)
2874 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002875 hddLog(VOS_TRACE_LEVEL_ERROR,
2876 "%s: SME %s while requesting BMPS",
2877 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 }
2879 }
2880 }
2881 else
2882 {
2883 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2884 "enabled in the cfg");
2885 }
2886 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002887
2888 /* either we never sent a request, we sent a request and received a
2889 response or we sent a request and timed out. if we never sent a
2890 request or if we sent a request and got a response, we want to
2891 clear the magic out of paranoia. if we timed out there is a
2892 race condition such that the callback function could be
2893 executing at the same time we are. of primary concern is if the
2894 callback function had already verified the "magic" but had not
2895 yet set the completion variable when a timeout occurred. we
2896 serialize these activities by invalidating the magic while
2897 holding a shared spinlock which will cause us to block if the
2898 callback is currently executing */
2899 spin_lock(&hdd_context_lock);
2900 context.magic = 0;
2901 spin_unlock(&hdd_context_lock);
2902
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 return VOS_STATUS_SUCCESS;
2904}
2905
2906VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2907 hdd_adapter_t *pAdapter)
2908{
2909 VOS_STATUS vos_Status;
2910
2911 if ((NULL == pAdapter) || (NULL == pHddCtx))
2912 {
2913 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2914 return VOS_STATUS_E_FAULT;
2915 }
2916
2917 /**Exit from Deep sleep or standby if we get the driver
2918 START cmd from android GUI
2919 */
2920 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2921 {
2922 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2923 "from Stand by",__func__);
2924 vos_Status = hdd_exit_standby(pHddCtx);
2925 }
2926 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2927 {
2928 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2929 "from deep sleep",__func__);
2930 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2931 }
2932 else
2933 {
2934 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2935 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2936 vos_Status = VOS_STATUS_SUCCESS;
2937 }
2938
2939 return vos_Status;
2940}
2941
2942VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2943{
2944 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2945
2946 if (NULL == pHddCtx)
2947 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302948 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 return VOS_STATUS_E_FAULT;
2950 }
2951
2952 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2953 {
2954 //Execute standby procedure.
2955 //Executing standby procedure will cause the STA to
2956 //disassociate first and then the chip will be put into standby.
2957 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2958 vos_Status = hdd_enter_standby(pHddCtx);
2959 }
2960 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2961 pHddCtx->cfg_ini->nEnableDriverStop)
2962 {
2963 //Execute deep sleep procedure
2964 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002965 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 //Deep sleep not supported
2967 vos_Status = hdd_enter_standby(pHddCtx);
2968 }
2969 else
2970 {
2971 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2972 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2973 vos_Status = VOS_STATUS_SUCCESS;
2974 }
2975
2976 return vos_Status;
2977}
2978
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002979
2980void* wlan_hdd_change_country_code_callback(void *pAdapter)
2981{
2982
2983 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002984 complete(&call_back_pAdapter->change_country_code);
2985
2986 return NULL;
2987}
2988
Jeff Johnson295189b2012-06-20 16:38:30 -07002989static int iw_set_priv(struct net_device *dev,
2990 struct iw_request_info *info,
2991 union iwreq_data *wrqu, char *extra)
2992{
2993 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08002994 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 int cmd_len = wrqu->data.length;
2996 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08002997 int rc = 0;
2998 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2999
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3001
3002 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003003 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3004 wrqu->data.length);
3005 if (NULL == cmd)
3006 {
3007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3008 "mem_alloc_copy_from_user_helper fail");
3009 return -ENOMEM;
3010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003011
3012 if (ioctl_debug)
3013 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003014 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 }
3016
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003017 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3018 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003019
3020 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003021 if (ioctl_debug)
3022 {
3023 pr_info("%s: RESTART in progress\n", __func__);
3024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003025
Arif Hussain24bfa702014-01-22 13:51:30 -08003026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003028 kfree(cmd);
3029 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 }
3031
Arif Hussain24bfa702014-01-22 13:51:30 -08003032 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003034 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3036 "%s: Error in iw_set_scan!", __func__);
3037 rc = -EINVAL;
3038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 }
3040 else if( strcasecmp(cmd, "start") == 0 ) {
3041
Arif Hussain6d2a3322013-11-17 19:50:10 -08003042 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003044
Arif Hussain24bfa702014-01-22 13:51:30 -08003045 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3046 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 {
3048 union iwreq_data wrqu;
3049 char buf[10];
3050
3051 memset(&wrqu, 0, sizeof(wrqu));
3052 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3053 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3054 }
3055 else
3056 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3058 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 }
3060 goto done;
3061 }
3062 else if( strcasecmp(cmd, "stop") == 0 )
3063 {
3064 union iwreq_data wrqu;
3065 char buf[10];
3066
Arif Hussain6d2a3322013-11-17 19:50:10 -08003067 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003068
3069 wlan_hdd_enter_lowpower(pHddCtx);
3070 memset(&wrqu, 0, sizeof(wrqu));
3071 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3072 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 goto done;
3074 }
3075 else if (strcasecmp(cmd, "macaddr") == 0)
3076 {
3077 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3078 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3079 }
3080 else if (strcasecmp(cmd, "scan-active") == 0)
3081 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303082 hddLog(VOS_TRACE_LEVEL_ERROR,
3083 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003084 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 ret = snprintf(cmd, cmd_len, "OK");
3086 }
3087 else if (strcasecmp(cmd, "scan-passive") == 0)
3088 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303089 hddLog(VOS_TRACE_LEVEL_ERROR,
3090 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003091 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 ret = snprintf(cmd, cmd_len, "OK");
3093 }
3094 else if( strcasecmp(cmd, "scan-mode") == 0 )
3095 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003096 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 }
3098 else if( strcasecmp(cmd, "linkspeed") == 0 )
3099 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003100 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 }
3102 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3103 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003104 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003105 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003106
3107 country_code = cmd + 8;
3108
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003109 init_completion(&pAdapter->change_country_code);
3110
Arif Hussain24bfa702014-01-22 13:51:30 -08003111 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003112 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 country_code,
3114 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303115 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303116 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303117 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003118
3119 /* Wait for completion */
3120 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3121 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3122
3123 if (lrc <= 0)
3124 {
3125 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003126 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003127 }
3128
Arif Hussain24bfa702014-01-22 13:51:30 -08003129 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003131 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003132 "%s: SME Change Country code fail", __func__);
3133 kfree(cmd);
3134 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 }
3136 }
3137 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3138 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003139 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 }
3141 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3142 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003143 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003144
Wilson Yang1be3e652013-10-09 15:18:31 -07003145 if (9 < cmd_len)
3146 {
3147 ptr = (char*)(cmd + 9);
3148
3149 }else{
3150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3151 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003152 kfree(cmd);
3153 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003154 }
3155
3156 if (1 != sscanf(ptr,"%d",&mode))
3157 {
3158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3159 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003160 kfree(cmd);
3161 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003162 }
3163
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 wlan_hdd_enter_bmps(pAdapter, mode);
3165 /*TODO:Set the power mode*/
3166 }
3167 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3168 v_U32_t pmc_state;
3169 v_U16_t value;
3170
3171 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3172 if(pmc_state == BMPS) {
3173 value = DRIVER_POWER_MODE_AUTO;
3174 }
3175 else {
3176 value = DRIVER_POWER_MODE_ACTIVE;
3177 }
3178 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3179 }
3180 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003181 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 /*TODO: set the btcoexmode*/
3183 }
3184 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3185
Arif Hussain6d2a3322013-11-17 19:50:10 -08003186 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 /*TODO: Return the btcoex status*/
3188 }
3189 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3190
Arif Hussain6d2a3322013-11-17 19:50:10 -08003191 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003192
3193 /*TODO: Enable Rx data Filter*/
3194 }
3195 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3196
Arif Hussain6d2a3322013-11-17 19:50:10 -08003197 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003198
3199 /*TODO: Disable Rx data Filter*/
3200 }
3201 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3202
Arif Hussain6d2a3322013-11-17 19:50:10 -08003203 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 /*TODO: rxfilter-statistics*/
3205 }
3206 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3207
Arif Hussain6d2a3322013-11-17 19:50:10 -08003208 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 /*TODO: rxfilter-add*/
3210 }
3211 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3212
Arif Hussain6d2a3322013-11-17 19:50:10 -08003213 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 /*TODO: rxfilter-remove*/
3215 }
3216#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003217 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3218 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3219 /*TODO: support pnosetup*/
3220 }
3221 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3222 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3223 /*TODO: support pnoforce*/
3224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3226
Arif Hussain6d2a3322013-11-17 19:50:10 -08003227 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003228 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3229 kfree(cmd);
3230 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 }
3232 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003233 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003234 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3235 kfree(cmd);
3236 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 }
3238#endif /*FEATURE_WLAN_SCAN_PNO*/
3239 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003240 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003241 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3242 kfree(cmd);
3243 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 }
3245 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3246 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003247 char *ptr;
3248
3249 if (18 < cmd_len)
3250 {
3251 ptr = (char*)(cmd + 18);
3252 }else{
3253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3254 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003255 kfree(cmd);
3256 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003257 }
3258
Jeff Johnson02797792013-10-26 19:17:13 -07003259 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003260 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3261 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3262 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3263 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3264 {
3265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3266 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003267 kfree(cmd);
3268 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003270
3271 // parameters checking
3272 // period has to be larger than 0
3273 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3274 {
3275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003276 kfree(cmd);
3277 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 }
3279
3280 // use default value 5 is the input is not reasonable. in unit of 10%
3281 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3282 {
3283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3284 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3285 }
3286
3287 // default is 5
3288 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3289 {
3290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3291 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3292 }
3293
Arif Hussain24bfa702014-01-22 13:51:30 -08003294 if (eHAL_STATUS_SUCCESS !=
3295 sme_SetTxPerTracking(pHddCtx->hHal,
3296 hdd_tx_per_hit_cb,
3297 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003299 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 }
3301 }
3302 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003303 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3304 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 }
3306done:
3307 /* many of the commands write information back into the command
3308 string using snprintf(). check the return value here in one
3309 place */
3310 if ((ret < 0) || (ret >= cmd_len))
3311 {
3312 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003313 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003315 else if (ret > 0)
3316 {
3317 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3318 {
3319 hddLog(VOS_TRACE_LEVEL_ERROR,
3320 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003321 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003322 return -EFAULT;
3323 }
3324 wrqu->data.length = ret;
3325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003326
3327 if (ioctl_debug)
3328 {
3329 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003330 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003332 kfree(cmd);
3333 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003334}
3335
3336static int iw_set_nick(struct net_device *dev,
3337 struct iw_request_info *info,
3338 union iwreq_data *wrqu, char *extra)
3339{
3340 ENTER();
3341 return 0;
3342}
3343
3344static int iw_get_nick(struct net_device *dev,
3345 struct iw_request_info *info,
3346 union iwreq_data *wrqu, char *extra)
3347{
3348 ENTER();
3349 return 0;
3350}
3351
3352static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3353{
3354 ENTER();
3355 return NULL;
3356}
3357
3358static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3359 union iwreq_data *wrqu,char *extra)
3360
3361{
3362 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3363 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3364 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3365 struct iw_point *encoderq = &(wrqu->encoding);
3366 v_U32_t keyId;
3367 v_U8_t key_length;
3368 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3369 v_BOOL_t fKeyPresent = 0;
3370 int i;
3371 eHalStatus status = eHAL_STATUS_SUCCESS;
3372
3373
3374 ENTER();
3375
3376 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3377 {
3378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3379 "%s:LOGP in Progress. Ignore!!!",__func__);
3380 return 0;
3381 }
3382
3383
3384 keyId = encoderq->flags & IW_ENCODE_INDEX;
3385
3386 if(keyId)
3387 {
3388 if(keyId > MAX_WEP_KEYS)
3389 {
3390 return -EINVAL;
3391 }
3392
3393 fKeyPresent = 1;
3394 keyId--;
3395 }
3396 else
3397 {
3398 fKeyPresent = 0;
3399 }
3400
3401
3402 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3403 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 if(!fKeyPresent) {
3406
3407 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3408
3409 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3410 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3411 }
3412 }
3413 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3414 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3415 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3416 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3417
3418 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3419 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3420
3421 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3422 {
3423 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3424 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003425 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303426 {
3427 long ret;
3428 ret = wait_for_completion_interruptible_timeout(
3429 &pAdapter->disconnect_comp_var,
3430 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3431 if (ret <= 0)
3432 hddLog(VOS_TRACE_LEVEL_ERROR,
3433 FL("failed wait on disconnect_comp_var %ld"), ret);
3434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 }
3436
3437 return status;
3438
3439 }
3440
3441 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3442 {
3443 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3444
3445 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3446
3447 }
3448
3449
3450 if(wrqu->data.length > 0)
3451 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003452 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003453
3454 key_length = wrqu->data.length;
3455
3456 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3457
3458 if(5 == key_length)
3459 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003460 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003461
3462 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3463 {
3464 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3465 }
3466 else
3467 {
3468 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3469 }
3470 }
3471 else if(13 == key_length)
3472 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003473 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003474
3475 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3476 {
3477 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3478 }
3479 else
3480 {
3481 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3482 }
3483 }
3484 else
3485 {
3486 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003487 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 return -EINVAL;
3489 }
3490
3491 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3492 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3493 pWextState->roamProfile.EncryptionType.numEntries = 1;
3494 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3495 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3496 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3497
3498 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3499 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3500 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3501 {
3502
3503 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3504
3505 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3506 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3507
3508 return status;
3509 }
3510 }
3511
3512 return 0;
3513}
3514
3515static int iw_get_encodeext(struct net_device *dev,
3516 struct iw_request_info *info,
3517 struct iw_point *dwrq,
3518 char *extra)
3519{
3520 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3521 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3522 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3523 int keyId;
3524 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3525 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3526 int i;
3527
3528 ENTER();
3529
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003530 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3531 {
3532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3533 "%s:LOGP in Progress. Ignore!!!", __func__);
3534 return -EBUSY;
3535 }
3536
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 keyId = pRoamProfile->Keys.defaultIndex;
3538
3539 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3540 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003541 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 return -EINVAL;
3543 }
3544
3545 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3546 {
3547 dwrq->flags |= IW_ENCODE_ENABLED;
3548 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303549 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3550 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 }
3552 else
3553 {
3554 dwrq->flags |= IW_ENCODE_DISABLED;
3555 }
3556
3557 for(i=0; i < MAX_WEP_KEYS; i++)
3558 {
3559 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3560 {
3561 continue;
3562 }
3563 else
3564 {
3565 break;
3566 }
3567 }
3568
3569 if(MAX_WEP_KEYS == i)
3570 {
3571 dwrq->flags |= IW_ENCODE_NOKEY;
3572 }
3573 else
3574 {
3575 dwrq->flags |= IW_ENCODE_ENABLED;
3576 }
3577
3578 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3579
3580 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3581 {
3582 dwrq->flags |= IW_ENCODE_DISABLED;
3583 }
3584
3585 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3586
3587 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3588 {
3589 dwrq->flags |= IW_ENCODE_OPEN;
3590 }
3591 else
3592 {
3593 dwrq->flags |= IW_ENCODE_RESTRICTED;
3594 }
3595 EXIT();
3596 return 0;
3597
3598}
3599
3600static int iw_set_encodeext(struct net_device *dev,
3601 struct iw_request_info *info,
3602 union iwreq_data *wrqu, char *extra)
3603{
3604 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3605 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3606 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3607 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3608
3609 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3610 v_U32_t status = 0;
3611
3612 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3613
3614 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3615
3616 int key_index;
3617 struct iw_point *encoding = &wrqu->encoding;
3618 tCsrRoamSetKey setKey;
3619 v_U32_t roamId= 0xFF;
3620 VOS_STATUS vos_status;
3621
3622 ENTER();
3623
3624 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3625 {
3626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3627 "%s:LOGP in Progress. Ignore!!!",__func__);
3628 return 0;
3629 }
3630
3631 key_index = encoding->flags & IW_ENCODE_INDEX;
3632
3633 if(key_index > 0) {
3634
3635 /*Convert from 1-based to 0-based keying*/
3636 key_index--;
3637 }
3638 if(!ext->key_len) {
3639
3640 /*Set the encrytion type to NONE*/
3641 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3642 return status;
3643 }
3644
3645 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3646 (IW_ENCODE_ALG_WEP == ext->alg))
3647 {
3648 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3649
Agarwal Ashish971c2882013-10-30 20:11:12 +05303650 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3651 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 return -EINVAL;
3653 }
3654 else {
3655 /*Static wep, update the roam profile with the keys */
3656 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3657 key_index < CSR_MAX_NUM_KEY) {
3658 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3659 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3660
3661 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3662 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3663
3664 }
3665 }
3666 return status;
3667 }
3668
3669 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3670
3671 setKey.keyId = key_index;
3672 setKey.keyLength = ext->key_len;
3673
3674 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3675 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3676 }
3677
3678 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3679 /*Key direction for group is RX only*/
3680 setKey.keyDirection = eSIR_RX_ONLY;
3681 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3682 }
3683 else {
3684
3685 setKey.keyDirection = eSIR_TX_RX;
3686 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3687 }
3688
3689 /*For supplicant pae role is zero*/
3690 setKey.paeRole = 0;
3691
3692 switch(ext->alg)
3693 {
3694 case IW_ENCODE_ALG_NONE:
3695 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3696 break;
3697
3698 case IW_ENCODE_ALG_WEP:
3699 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3700 break;
3701
3702 case IW_ENCODE_ALG_TKIP:
3703 {
3704 v_U8_t *pKey = &setKey.Key[0];
3705
3706 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3707
3708 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3709
3710 /*Supplicant sends the 32bytes key in this order
3711
3712 |--------------|----------|----------|
3713 | Tk1 |TX-MIC | RX Mic |
3714 |--------------|----------|----------|
3715 <---16bytes---><--8bytes--><--8bytes-->
3716
3717 */
3718 /*Sme expects the 32 bytes key to be in the below order
3719
3720 |--------------|----------|----------|
3721 | Tk1 |RX-MIC | TX Mic |
3722 |--------------|----------|----------|
3723 <---16bytes---><--8bytes--><--8bytes-->
3724 */
3725 /* Copy the Temporal Key 1 (TK1) */
3726 vos_mem_copy(pKey,ext->key,16);
3727
3728 /*Copy the rx mic first*/
3729 vos_mem_copy(&pKey[16],&ext->key[24],8);
3730
3731 /*Copy the tx mic */
3732 vos_mem_copy(&pKey[24],&ext->key[16],8);
3733
3734 }
3735 break;
3736
3737 case IW_ENCODE_ALG_CCMP:
3738 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3739 break;
3740
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003741#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003742#define IW_ENCODE_ALG_KRK 6
3743 case IW_ENCODE_ALG_KRK:
3744 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3745 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003746#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003747
3748 default:
3749 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3750 break;
3751 }
3752
3753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003754 ("%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 -07003755
3756#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303757 /* The supplicant may attempt to set the PTK once pre-authentication
3758 is done. Save the key in the UMAC and include it in the ADD
3759 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303761 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303763 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3764 "%s: Update PreAuth Key success", __func__);
3765 return 0;
3766 }
3767 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3768 {
3769 hddLog(VOS_TRACE_LEVEL_ERROR,
3770 "%s: Update PreAuth Key failed", __func__);
3771 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 }
3773#endif /* WLAN_FEATURE_VOWIFI_11R */
3774
3775 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3776
3777 vos_status = wlan_hdd_check_ula_done(pAdapter);
3778 if ( vos_status != VOS_STATUS_SUCCESS )
3779 {
3780 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3781 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3782 __LINE__, vos_status );
3783
3784 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3785 }
3786
3787 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3788
3789 if ( halStatus != eHAL_STATUS_SUCCESS )
3790 {
3791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3792 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3793 __LINE__, halStatus );
3794
3795 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3796 }
3797
3798 return halStatus;
3799}
3800
3801static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3802 union iwreq_data *wrqu, char *extra)
3803{
3804 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3805 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3806
3807 ENTER();
3808
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003809 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3810 {
3811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3812 "%s:LOGP in Progress. Ignore!!!", __func__);
3813 return -EBUSY;
3814 }
3815
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3817 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3818
Arif Hussain6d2a3322013-11-17 19:50:10 -08003819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003820
3821 return -EINVAL;
3822 }
3823
3824 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3825
3826 if((wrqu->retry.flags & IW_RETRY_LONG))
3827 {
3828 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3829 {
c_hpothub8245442013-11-20 23:41:09 +05303830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3831 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 return -EIO;
3833 }
3834 }
3835 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3836 {
3837 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3838 {
c_hpothub8245442013-11-20 23:41:09 +05303839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3840 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 return -EIO;
3842 }
3843 }
3844 }
3845 else
3846 {
3847 return -EOPNOTSUPP;
3848 }
3849
Arif Hussain6d2a3322013-11-17 19:50:10 -08003850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003851
3852 EXIT();
3853
3854 return 0;
3855
3856}
3857
3858static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3859 union iwreq_data *wrqu, char *extra)
3860{
3861 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3862 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3863 v_U32_t retry = 0;
3864
3865 ENTER();
3866
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003867 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3868 {
3869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3870 "%s:LOGP in Progress. Ignore!!!", __func__);
3871 return -EBUSY;
3872 }
3873
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 if((wrqu->retry.flags & IW_RETRY_LONG))
3875 {
3876 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3877
3878 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3879 {
c_hpothub8245442013-11-20 23:41:09 +05303880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3881 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 return -EIO;
3883 }
3884
3885 wrqu->retry.value = retry;
3886 }
3887 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3888 {
3889 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3890
3891 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3892 {
c_hpothub8245442013-11-20 23:41:09 +05303893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3894 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 return -EIO;
3896 }
3897
3898 wrqu->retry.value = retry;
3899 }
3900 else {
3901 return -EOPNOTSUPP;
3902 }
3903
Arif Hussain6d2a3322013-11-17 19:50:10 -08003904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003905
3906 EXIT();
3907
3908 return 0;
3909}
3910
3911static int iw_set_mlme(struct net_device *dev,
3912 struct iw_request_info *info,
3913 union iwreq_data *wrqu,
3914 char *extra)
3915{
3916 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3917 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3918 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3919 eHalStatus status = eHAL_STATUS_SUCCESS;
3920
3921 ENTER();
3922
3923 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3924 {
3925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3926 "%s:LOGP in Progress. Ignore!!!",__func__);
3927 return 0;
3928 }
3929
3930 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3931 switch (mlme->cmd) {
3932 case IW_MLME_DISASSOC:
3933 case IW_MLME_DEAUTH:
3934
3935 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3936 {
3937 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3938
3939 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3940 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3941
3942 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3943 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3944
Jeff Johnson43971f52012-07-17 12:26:56 -07003945 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303946 {
3947 long ret;
3948 ret = wait_for_completion_interruptible_timeout(
3949 &pAdapter->disconnect_comp_var,
3950 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3951 if (ret <= 0)
3952 hddLog(VOS_TRACE_LEVEL_ERROR,
3953 FL("failed wait on disconnect_comp_var %ld"), ret);
3954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003956 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003957 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003958
3959 /* Resetting authKeyMgmt */
3960 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3961
3962 netif_tx_disable(dev);
3963 netif_carrier_off(dev);
3964
3965 }
3966 else
3967 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003968 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 -07003969 }
3970 break;
3971 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003972 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 return -EINVAL;
3974 }//end of switch
3975
3976 EXIT();
3977
3978 return status;
3979
3980}
3981
3982/* set param sub-ioctls */
3983static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3984 union iwreq_data *wrqu, char *extra)
3985{
3986 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3987 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3988 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3989 int *value = (int *)extra;
3990 int sub_cmd = value[0];
3991 int set_value = value[1];
3992 int ret = 0; /* success */
3993 int enable_pbm, enable_mp;
3994#ifdef CONFIG_HAS_EARLYSUSPEND
3995 v_U8_t nEnableSuspendOld;
3996#endif
3997 INIT_COMPLETION(pWextState->completion_var);
3998
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003999 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4000 {
4001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4002 "%s:LOGP in Progress. Ignore!!!", __func__);
4003 return -EBUSY;
4004 }
4005
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 switch(sub_cmd)
4007 {
4008 case WE_SET_11D_STATE:
4009 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004010 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004011 memset(&smeConfig, 0x00, sizeof(smeConfig));
4012
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4014
4015 sme_GetConfigParam(hHal,&smeConfig);
4016 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4017
Arif Hussain6d2a3322013-11-17 19:50:10 -08004018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004019
4020 sme_UpdateConfig(hHal,&smeConfig);
4021 }
4022 else {
4023 return -EINVAL;
4024 }
4025 break;
4026 }
4027
4028 case WE_WOWL:
4029 {
4030 switch (set_value)
4031 {
4032 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004033 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 break;
4035 case 0x01:
4036 case 0x02:
4037 case 0x03:
4038 enable_mp = (set_value & 0x01) ? 1 : 0;
4039 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004040 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4042 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4043 break;
4044 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004045 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 ret = -EINVAL;
4047 break;
4048 }
4049
4050 break;
4051 }
4052 case WE_SET_POWER:
4053 {
4054 switch (set_value)
4055 {
4056 case 0: //Full Power
4057 {
4058 struct statsContext context;
4059 eHalStatus status;
4060
4061 init_completion(&context.completion);
4062
4063 context.pAdapter = pAdapter;
4064 context.magic = POWER_CONTEXT_MAGIC;
4065
4066 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4067 iw_power_callback_fn, &context,
4068 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004069 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 {
4071 int lrc = wait_for_completion_interruptible_timeout(
4072 &context.completion,
4073 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004074
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 if (lrc <= 0)
4076 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004077 hddLog(VOS_TRACE_LEVEL_ERROR,
4078 "%s: SME %s while requesting fullpower",
4079 __func__, (0 == lrc) ?
4080 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 }
4082 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004083 /* either we have a response or we timed out. if we timed
4084 out there is a race condition such that the callback
4085 function could be executing at the same time we are. of
4086 primary concern is if the callback function had already
4087 verified the "magic" but had not yet set the completion
4088 variable when a timeout occurred. we serialize these
4089 activities by invalidating the magic while holding a
4090 shared spinlock which will cause us to block if the
4091 callback is currently executing */
4092 spin_lock(&hdd_context_lock);
4093 context.magic = 0;
4094 spin_unlock(&hdd_context_lock);
4095
Arif Hussain6d2a3322013-11-17 19:50:10 -08004096 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 break;
4098 }
4099 case 1: //Enable BMPS
4100 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4101 break;
4102 case 2: //Disable BMPS
4103 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4104 break;
4105 case 3: //Request Bmps
4106 {
4107 struct statsContext context;
4108 eHalStatus status;
4109
4110 init_completion(&context.completion);
4111
4112 context.pAdapter = pAdapter;
4113 context.magic = POWER_CONTEXT_MAGIC;
4114
4115 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4116 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004117 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 {
4119 int lrc = wait_for_completion_interruptible_timeout(
4120 &context.completion,
4121 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 if (lrc <= 0)
4123 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004124 hddLog(VOS_TRACE_LEVEL_ERROR,
4125 "%s: SME %s while requesting BMPS",
4126 __func__, (0 == lrc) ? "timeout" :
4127 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 }
4129 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004130 /* either we have a response or we timed out. if we
4131 timed out there is a race condition such that the
4132 callback function could be executing at the same
4133 time we are. of primary concern is if the callback
4134 function had already verified the "magic" but had
4135 not yet set the completion variable when a timeout
4136 occurred. we serialize these activities by
4137 invalidating the magic while holding a shared
4138 spinlock which will cause us to block if the
4139 callback is currently executing */
4140 spin_lock(&hdd_context_lock);
4141 context.magic = 0;
4142 spin_unlock(&hdd_context_lock);
4143
Arif Hussain6d2a3322013-11-17 19:50:10 -08004144 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 break;
4146 }
4147 case 4: //Enable IMPS
4148 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4149 break;
4150 case 5: //Disable IMPS
4151 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4152 break;
4153 case 6: //Enable Standby
4154 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4155 break;
4156 case 7: //Disable Standby
4157 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4158 break;
4159 case 8: //Request Standby
4160#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004161#endif
4162 break;
4163 case 9: //Start Auto Bmps Timer
4164 sme_StartAutoBmpsTimer(hHal);
4165 break;
4166 case 10://Stop Auto BMPS Timer
4167 sme_StopAutoBmpsTimer(hHal);
4168 break;
4169#ifdef CONFIG_HAS_EARLYSUSPEND
4170 case 11://suspend to standby
4171#ifdef CONFIG_HAS_EARLYSUSPEND
4172 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4173 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4175#endif
4176 break;
4177 case 12://suspend to deep sleep
4178#ifdef CONFIG_HAS_EARLYSUSPEND
4179 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4180 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4182#endif
4183 break;
4184 case 13://resume from suspend
4185#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004186#endif
4187 break;
4188#endif
4189 case 14://reset wlan (power down/power up)
4190 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4191 break;
4192 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004193 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 ret = -EINVAL;
4195 break;
4196 }
4197 break;
4198 }
4199
4200 case WE_SET_MAX_ASSOC:
4201 {
4202 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4203 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4204 {
4205 ret = -EINVAL;
4206 }
4207 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4208 set_value, NULL, eANI_BOOLEAN_FALSE)
4209 != eHAL_STATUS_SUCCESS )
4210 {
c_hpothub8245442013-11-20 23:41:09 +05304211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4212 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 ret = -EIO;
4214 }
4215 break;
4216 }
4217
4218 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4219 {
4220 if( 0 == set_value )
4221 {
4222 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4223 }
4224 else if ( 1 == set_value )
4225 {
4226 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4227 }
4228 else
4229 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004230 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 ret = -EINVAL;
4232 }
4233 break;
4234 }
4235
4236 case WE_SET_DATA_INACTIVITY_TO:
4237 {
4238 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4239 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4240 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4241 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4242 set_value,
4243 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4244 {
4245 hddLog(LOGE,"Failure: Could not pass on "
4246 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004247 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 ret = -EINVAL;
4249 }
4250 break;
4251 }
4252 case WE_SET_MAX_TX_POWER:
4253 {
4254 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4255 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4256
4257 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4258 __func__, set_value);
4259 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4260 eHAL_STATUS_SUCCESS )
4261 {
4262 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4263 __func__);
4264 return -EIO;
4265 }
4266
4267 break;
4268 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004269 case WE_SET_MAX_TX_POWER_2_4:
4270 {
4271 hddLog(VOS_TRACE_LEVEL_INFO,
4272 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4273 __func__, set_value);
4274 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4275 eHAL_STATUS_SUCCESS)
4276 {
4277 hddLog(VOS_TRACE_LEVEL_ERROR,
4278 "%s: Setting maximum tx power failed for 2.4 GHz band",
4279 __func__);
4280 return -EIO;
4281 }
4282
4283 break;
4284 }
4285 case WE_SET_MAX_TX_POWER_5_0:
4286 {
4287 hddLog(VOS_TRACE_LEVEL_INFO,
4288 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4289 __func__, set_value);
4290 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4291 eHAL_STATUS_SUCCESS)
4292 {
4293 hddLog(VOS_TRACE_LEVEL_ERROR,
4294 "%s: Setting maximum tx power failed for 5.0 GHz band",
4295 __func__);
4296 return -EIO;
4297 }
4298
4299 break;
4300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 case WE_SET_HIGHER_DTIM_TRANSITION:
4302 {
4303 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4304 (set_value == eANI_BOOLEAN_TRUE)))
4305 {
4306 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4307 ret = -EINVAL;
4308 }
4309 else
4310 {
4311 if(pAdapter->higherDtimTransition != set_value)
4312 {
4313 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004314 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 }
4316 }
4317
4318 break;
4319 }
4320
4321 case WE_SET_TM_LEVEL:
4322 {
4323 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004324 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4326
4327 break;
4328 }
4329
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304330 case WE_ENABLE_STRICT_FCC_REG:
4331 {
4332 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4333 struct wiphy *wiphy = NULL;
4334 long lrc;
4335 int status;
4336
4337 wiphy = hddCtxt->wiphy;
4338 if(wiphy == NULL)
4339 {
4340 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4341 break;
4342 }
4343 init_completion(&hddCtxt->wiphy_channel_update_event);
4344
4345 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4346
4347 status = regulatory_hint(wiphy, "00");
4348 if(status < 0)
4349 {
4350 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4351 break;
4352 }
4353
4354 /* Wait for completion */
4355 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4356 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4357 if (lrc <= 0)
4358 {
4359 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4360 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4361 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4362 }
4363 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4364
4365 break;
4366 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004367 case WE_SET_DEBUG_LOG:
4368 {
4369 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4370 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4371 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4372 break;
4373 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304374
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 default:
4376 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004377 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 sub_cmd, set_value);
4379 break;
4380 }
4381 }
4382
4383 return ret;
4384}
4385
4386/* set param sub-ioctls */
4387static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4388 union iwreq_data *wrqu, char *extra)
4389{
4390 VOS_STATUS vstatus;
4391 int sub_cmd = wrqu->data.flags;
4392 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004393 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4395 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4396#ifdef WLAN_FEATURE_VOWIFI
4397 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4398#endif /* WLAN_FEATURE_VOWIFI */
4399
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004400 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4401 {
4402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4403 "%s:LOGP in Progress. Ignore!!!", __func__);
4404 return -EBUSY;
4405 }
4406
Arif Hussain0273cba2014-01-07 20:58:29 -08004407 /* ODD number is used for set, copy data using copy_from_user */
4408 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4409 wrqu->data.length);
4410 if (NULL == pBuffer)
4411 {
4412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4413 "mem_alloc_copy_from_user_helper fail");
4414 return -ENOMEM;
4415 }
4416
4417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4418 "%s: Received length %d", __func__, wrqu->data.length);
4419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4420 "%s: Received data %s", __func__, pBuffer);
4421
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 switch(sub_cmd)
4423 {
4424 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004426 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 break;
4428 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004430 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 break;
4432#if defined WLAN_FEATURE_VOWIFI
4433 case WE_NEIGHBOR_REPORT_REQUEST:
4434 {
4435 tRrmNeighborReq neighborReq;
4436 tRrmNeighborRspCallbackInfo callbackInfo;
4437
4438 if (pConfig->fRrmEnable)
4439 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4442 if( !neighborReq.no_ssid )
4443 {
4444 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004445 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 }
4447
4448 callbackInfo.neighborRspCallback = NULL;
4449 callbackInfo.neighborRspCallbackContext = NULL;
4450 callbackInfo.timeout = 5000; //5 seconds
4451 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4452 }
4453 else
4454 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004455 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 ret = -EINVAL;
4457 }
4458 }
4459 break;
4460#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 case WE_SET_AP_WPS_IE:
4462 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004463 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004466 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 if (VOS_STATUS_SUCCESS != vstatus)
4468 {
4469 ret = -EINVAL;
4470 }
4471 break;
4472 default:
4473 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004474 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 ret = -EINVAL;
4476 break;
4477 }
4478 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004479 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 return ret;
4481}
4482
4483/* get param sub-ioctls */
4484static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4485 union iwreq_data *wrqu, char *extra)
4486{
4487 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4488 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4489 int *value = (int *)extra;
4490 int ret = 0; /* success */
4491
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004492 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4493 {
4494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4495 "%s:LOGP in Progress. Ignore!!!", __func__);
4496 return -EBUSY;
4497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004498
4499 switch (value[0])
4500 {
4501 case WE_GET_11D_STATE:
4502 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004503 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304505
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4507
Arif Hussain6d2a3322013-11-17 19:50:10 -08004508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004509
4510 break;
4511 }
4512
4513 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 break;
4516
4517 case WE_PMC_STATE:
4518 {
4519 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 break;
4522 }
4523 case WE_GET_WLAN_DBG:
4524 {
4525 vos_trace_display();
4526 *value = 0;
4527 break;
4528 }
4529 case WE_MODULE_DOWN_IND:
4530 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4533#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4536#endif
4537 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4538
4539 *value = 0;
4540 break;
4541 }
4542 case WE_GET_MAX_ASSOC:
4543 {
4544 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4545 {
c_hpothub8245442013-11-20 23:41:09 +05304546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4547 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 ret = -EIO;
4549 }
4550 break;
4551 }
4552
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 case WE_GET_WDI_DBG:
4554 {
4555 wpalTraceDisplay();
4556 *value = 0;
4557 break;
4558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004559
4560 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4561 {
4562 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4563 break;
4564 }
4565 case WE_GET_CONCURRENCY_MODE:
4566 {
4567 *value = hdd_get_concurrency_mode ( );
4568
Arif Hussain6d2a3322013-11-17 19:50:10 -08004569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 break;
4571 }
4572
4573 default:
4574 {
4575 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4576 break;
4577 }
4578 }
4579
4580 return ret;
4581}
4582
4583/* set param sub-ioctls */
4584int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4585 union iwreq_data *wrqu, char *extra)
4586{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004587 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 int *value = (int *)extra;
4589 int sub_cmd = value[0];
4590 int ret = 0;
4591
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004592 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4593 {
4594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4595 "%s:LOGP in Progress. Ignore!!!", __func__);
4596 return -EBUSY;
4597 }
4598
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 switch(sub_cmd)
4600 {
4601 case WE_SET_WLAN_DBG:
4602 {
4603 vos_trace_setValue( value[1], value[2], value[3]);
4604 break;
4605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 case WE_SET_WDI_DBG:
4607 {
4608 wpalTraceSetLevel( value[1], value[2], value[3]);
4609 break;
4610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 case WE_SET_SAP_CHANNELS:
4612 {
4613 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4614 break;
4615 }
4616
4617 default:
4618 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004619 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 break;
4621 }
4622 }
4623 return ret;
4624}
4625
4626static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4627 union iwreq_data *wrqu, char *extra)
4628{
4629 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4630 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004631#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004632 hdd_wext_state_t *pWextState;
4633#endif
4634
4635 if (pAdapter == NULL)
4636 {
4637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4638 "%s: pAdapter is NULL!", __func__);
4639 return -EINVAL;
4640 }
4641#ifdef WLAN_FEATURE_11W
4642 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004643#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004644
Yue Ma3ede6052013-08-29 00:33:26 -07004645 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4646 {
4647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4648 "%s: HDD Context is NULL!", __func__);
4649
4650 return -EINVAL;
4651 }
4652
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004653 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4654 {
4655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4656 "%s:LOGP in Progress. Ignore!!!", __func__);
4657 return -EBUSY;
4658 }
4659
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 switch(sub_cmd)
4661 {
4662 case WE_WLAN_VERSION:
4663 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004664 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 break;
4666 }
4667
4668 case WE_GET_STATS:
4669 {
4670 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4671 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4672 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4673
4674 snprintf(extra, WE_MAX_STR_LEN,
4675 "\nTransmit"
4676 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4677 "\n dropped BK %u, BE %u, VI %u, VO %u"
4678 "\n classified BK %u, BE %u, VI %u, VO %u"
4679 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4680 "\n queued BK %u, BE %u, VI %u, VO %u"
4681 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004682 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 "\n fetched BK %u, BE %u, VI %u, VO %u"
4684 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4685 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004686 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 "\n flushed BK %u, BE %u, VI %u, VO %u"
4688 "\n\nReceive"
4689 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4690 "\n\nResetsStats"
4691 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4692 "\n",
4693 pStats->txXmitCalled,
4694 pStats->txXmitDropped,
4695 pStats->txXmitBackPressured,
4696 pStats->txXmitQueued,
4697
4698 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4699 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4700 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4701 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4702
4703 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4704 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4705 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4706 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4707
4708 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4709 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4710 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4711 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4712
4713 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4714 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4715 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4716 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4717
4718 pStats->txFetched,
4719 pStats->txFetchEmpty,
4720 pStats->txFetchLowResources,
4721 pStats->txFetchDequeueError,
4722
4723 pStats->txFetchDequeued,
4724 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004725 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 pStats->txCompleted,
4727 pStats->txFlushed,
4728
4729 pStats->txFetchedAC[WLANTL_AC_BK],
4730 pStats->txFetchedAC[WLANTL_AC_BE],
4731 pStats->txFetchedAC[WLANTL_AC_VI],
4732 pStats->txFetchedAC[WLANTL_AC_VO],
4733
4734 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4735 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4736 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4737 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4738
4739 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4740 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4741 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4742 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4743
Ravi Joshi41914632013-10-21 23:02:21 -07004744 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4745 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4746 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4747 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4748
Jeff Johnson295189b2012-06-20 16:38:30 -07004749 pStats->txFlushedAC[WLANTL_AC_BK],
4750 pStats->txFlushedAC[WLANTL_AC_BE],
4751 pStats->txFlushedAC[WLANTL_AC_VI],
4752 pStats->txFlushedAC[WLANTL_AC_VO],
4753
4754 pStats->rxChains,
4755 pStats->rxPackets,
4756 pStats->rxDropped,
4757 pStats->rxDelivered,
4758 pStats->rxRefused,
4759
4760 pResetStats->totalLogpResets,
4761 pResetStats->totalCMD53Failures,
4762 pResetStats->totalMutexReadFailures,
4763 pResetStats->totalMIFErrorFailures,
4764 pResetStats->totalFWHearbeatFailures,
4765 pResetStats->totalUnknownExceptions
4766 );
4767 wrqu->data.length = strlen(extra)+1;
4768 break;
4769 }
4770
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304771/* The case prints the current state of the HDD, SME, CSR, PE, TL
4772 *it can be extended for WDI Global State as well.
4773 *And currently it only checks P2P_CLIENT adapter.
4774 *P2P_DEVICE and P2P_GO have not been added as of now.
4775*/
4776 case WE_GET_STATES:
4777 {
4778 int buf = 0, len = 0;
4779 int adapter_num = 0;
4780 int count = 0, check = 1;
4781
4782 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004783 tHalHandle hHal = NULL;
4784 tpAniSirGlobal pMac = NULL;
4785 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304786
4787 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4788 hdd_adapter_t *useAdapter = NULL;
4789
4790 /* Print wlan0 or p2p0 states based on the adapter_num
4791 *by using the correct adapter
4792 */
4793 while ( adapter_num < 2 )
4794 {
4795 if ( WLAN_ADAPTER == adapter_num )
4796 {
4797 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004798 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304799 "\n\n wlan0 States:-");
4800 len += buf;
4801 }
4802 else if ( P2P_ADAPTER == adapter_num )
4803 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004804 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304805 "\n\n p2p0 States:-");
4806 len += buf;
4807
4808 if( !pHddCtx )
4809 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004810 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304811 "\n pHddCtx is NULL");
4812 len += buf;
4813 break;
4814 }
4815
4816 /*Printing p2p0 states only in the case when the device is
4817 configured as a p2p_client*/
4818 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4819 if ( !useAdapter )
4820 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004821 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304822 "\n Device not configured as P2P_CLIENT.");
4823 len += buf;
4824 break;
4825 }
4826 }
4827
4828 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004829 if (!hHal) {
4830 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4831 "\n pMac is NULL");
4832 len += buf;
4833 break;
4834 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304835 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004836 if (!pMac) {
4837 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4838 "\n pMac is NULL");
4839 len += buf;
4840 break;
4841 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304842 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4843 if( !pHddStaCtx )
4844 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004845 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304846 "\n pHddStaCtx is NULL");
4847 len += buf;
4848 break;
4849 }
4850
4851 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4852
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004853 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304854 "\n HDD Conn State - %s "
4855 "\n \n SME State:"
4856 "\n Neighbour Roam State - %s"
4857 "\n CSR State - %s"
4858 "\n CSR Substate - %s"
4859 "\n \n TL STA %d State: %s",
4860 macTraceGetHDDWlanConnState(
4861 pHddStaCtx->conn_info.connState),
4862 macTraceGetNeighbourRoamState(
4863 pMac->roam.neighborRoamInfo.neighborRoamState),
4864 macTraceGetcsrRoamState(
4865 pMac->roam.curState[useAdapter->sessionId]),
4866 macTraceGetcsrRoamSubState(
4867 pMac->roam.curSubState[useAdapter->sessionId]),
4868 pHddStaCtx->conn_info.staId[0],
4869 macTraceGetTLState(tlState)
4870 );
4871 len += buf;
4872 adapter_num++;
4873 }
4874
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004875 if (pMac) {
4876 /* Printing Lim State starting with global lim states */
4877 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4878 "\n \n LIM STATES:-"
4879 "\n Global Sme State - %s "\
4880 "\n Global mlm State - %s "\
4881 "\n",
4882 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4883 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4884 );
4885 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304886
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004887 /*printing the PE Sme and Mlm states for valid lim sessions*/
4888 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304889 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004890 if ( pMac->lim.gpSession[count].valid )
4891 {
4892 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4893 "\n Lim Valid Session %d:-"
4894 "\n PE Sme State - %s "
4895 "\n PE Mlm State - %s "
4896 "\n",
4897 check,
4898 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4899 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4900 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304901
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004902 len += buf;
4903 check++;
4904 }
4905 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304906 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304907 }
4908
4909 wrqu->data.length = strlen(extra)+1;
4910 break;
4911 }
4912
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 case WE_GET_CFG:
4914 {
4915 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4916 wrqu->data.length = strlen(extra)+1;
4917 break;
4918 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004919#ifdef WLAN_FEATURE_11AC
4920 case WE_GET_RSSI:
4921 {
4922 v_S7_t s7Rssi = 0;
4923 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4924 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4925 wrqu->data.length = strlen(extra)+1;
4926 break;
4927 }
4928#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304929
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004930#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004931 case WE_GET_ROAM_RSSI:
4932 {
4933 v_S7_t s7Rssi = 0;
4934 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4935 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4936 wrqu->data.length = strlen(extra)+1;
4937 break;
4938 }
4939#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 case WE_GET_WMM_STATUS:
4941 {
4942 snprintf(extra, WE_MAX_STR_LEN,
4943 "\nDir: 0=up, 1=down, 3=both\n"
4944 "|------------------------|\n"
4945 "|AC | ACM |Admitted| Dir |\n"
4946 "|------------------------|\n"
4947 "|VO | %d | %3s | %d |\n"
4948 "|VI | %d | %3s | %d |\n"
4949 "|BE | %d | %3s | %d |\n"
4950 "|BK | %d | %3s | %d |\n"
4951 "|------------------------|\n",
4952 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4953 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4954 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4955 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4956 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4957 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4958 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4959 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4960 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4961 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4962 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4963 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4964
Jeff Johnsone7245742012-09-05 17:12:55 -07004965
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 wrqu->data.length = strlen(extra)+1;
4967 break;
4968 }
4969 case WE_GET_CHANNEL_LIST:
4970 {
4971 VOS_STATUS status;
4972 v_U8_t i, len;
4973 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05304974 tANI_U8 pBuf[COUNTRY_CODE_LEN];
4975 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
4976 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 tChannelListInfo channel_list;
4978
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004979 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004981 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004983 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 return -EINVAL;
4985 }
4986 buf = extra;
4987
4988 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004989 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4990 * needed = 5 * number of channels. Check ifsufficient
4991 * buffer is available and then proceed to fill the buffer.
4992 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4994 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004995 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004996 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004997 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 return -EINVAL;
4999 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005000 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5001 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305002 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5003 {
5004 //Printing Country code in getChannelList
5005 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5006 {
5007 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5008 "%c ", pBuf[i]);
5009 }
5010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 for(i = 0 ; i < channel_list.num_channels; i++)
5012 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005013 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 }
5016 wrqu->data.length = strlen(extra)+1;
5017
5018 break;
5019 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005020#ifdef FEATURE_WLAN_TDLS
5021 case WE_GET_TDLS_PEERS:
5022 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005023 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005024 break;
5025 }
5026#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005027#ifdef WLAN_FEATURE_11W
5028 case WE_GET_11W_INFO:
5029 {
5030 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5031
5032 snprintf(extra, WE_MAX_STR_LEN,
5033 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5034 "\n Number of Unprotected Disassocs %d"
5035 "\n Number of Unprotected Deauths %d",
5036 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5037 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5038 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5039 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5040 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5041
5042 wrqu->data.length = strlen(extra)+1;
5043 break;
5044 }
5045#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305046 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005048 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 break;
5050 }
5051 }
5052
5053 return 0;
5054}
5055
5056/* action sub-ioctls */
5057static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5058 union iwreq_data *wrqu, char *extra)
5059{
5060 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5061 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005062 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07005063
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005064 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5065 {
5066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5067 "%s:LOGP in Progress. Ignore!!!", __func__);
5068 return -EBUSY;
5069 }
5070
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 switch (sub_cmd)
5072 {
5073 case WE_CLEAR_STATS:
5074 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5077 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5078 break;
5079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 case WE_INIT_AP:
5081 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305082 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5083
5084 /* As Soft AP mode might been changed to STA already with
5085 * killing of Hostapd, need to find the adpater by name
5086 * rather than mode */
5087 hdd_adapter_t* pAdapter_to_stop =
5088 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5089 if( pAdapter_to_stop )
5090 {
5091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5092 "Adapter with name softap.0 already "
5093 "exist, ignoring the request.\nRemove the "
5094 "adapter and try again\n");
5095 break;
5096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 pr_info("Init AP trigger\n");
5098 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5099 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5100 break;
5101 }
5102 case WE_STOP_AP:
5103 {
5104 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5105 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5106 * this is a dead code and need to find the adpater by name rather than mode */
5107 hdd_adapter_t* pAdapter_to_stop =
5108 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5109 if( pAdapter_to_stop )
5110 {
5111 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5112
5113 pr_info("Stopping AP mode\n");
5114
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305115 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5116 {
5117 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5118 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5119 }
5120
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 /*Make sure that pAdapter cleaned properly*/
5122 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5123 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5124 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5125
5126 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5127 pAdapter_to_stop->macAddressCurrent.bytes);
5128 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5129 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305130
5131 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5132 {
5133 /* put the device back into BMPS */
5134 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 }
5137 else
5138 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005139 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 }
5141
5142 break;
5143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005144#ifdef WLAN_BTAMP_FEATURE
5145 case WE_ENABLE_AMP:
5146 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005148 WLANBAP_RegisterWithHCI(pAdapter);
5149 break;
5150 }
5151 case WE_DISABLE_AMP:
5152 {
5153 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5154 VOS_STATUS status;
5155
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005157
5158 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5159 status = WLANBAP_StopAmp();
5160 if(VOS_STATUS_SUCCESS != status )
5161 {
5162 pHddCtx->isAmpAllowed = VOS_TRUE;
5163 hddLog(VOS_TRACE_LEVEL_FATAL,
5164 "%s: Failed to stop AMP", __func__);
5165 }
5166 else
5167 {
5168 //a state m/c implementation in PAL is TBD to avoid this delay
5169 msleep(500);
5170 pHddCtx->isAmpAllowed = VOS_FALSE;
5171 WLANBAP_DeregisterFromHCI();
5172 }
5173
5174 break;
5175 }
5176#endif
5177
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005178 case WE_ENABLE_DXE_STALL_DETECT:
5179 {
schang6295e542013-03-12 15:31:23 -07005180 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5181 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005182 break;
5183 }
5184 case WE_DISPLAY_DXE_SNAP_SHOT:
5185 {
schang6295e542013-03-12 15:31:23 -07005186 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5187 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005188 break;
5189 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305190 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5191 {
5192 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5193 hdd_wmm_tx_snapshot(pAdapter);
5194 WLANTL_TLDebugMessage(VOS_TRUE);
5195 break;
5196 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07005197 case WE_SET_REASSOC_TRIGGER:
5198 {
5199 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5200 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5201 v_U32_t roamId = 0;
5202 tCsrRoamModifyProfileFields modProfileFields;
5203 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5204 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5205 return 0;
5206 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305207
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305208 case WE_STOP_OBSS_SCAN:
5209 {
5210 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5211 2.OBSS scan is stopped by Firmware during the disassociation
5212 3.OBSS stop comamnd is added for debugging purpose*/
5213 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5214 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005215
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305216 if (pAdapter == NULL)
5217 {
5218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5219 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305220 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305221 }
5222 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5223 if (pMac == NULL)
5224 {
5225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5226 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305227 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305228 }
5229 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5230 }
5231 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 default:
5233 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005234 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 break;
5236 }
5237 }
5238
5239 return ret;
5240}
5241
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305242void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5243{
5244 /*
5245 * Function to display HDD WMM information
5246 * for Tx Queues.
5247 * Prints globala as well as per client depending
5248 * whether the clients are registered or not.
5249 */
5250 int i = 0, j = 0;
5251 for ( i=0; i< NUM_TX_QUEUES; i++)
5252 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305253 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005254 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305255 i, pAdapter->wmm_tx_queue[i].count,
5256 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305257 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305258 }
5259
5260 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5261 {
5262 if(pAdapter->aStaInfo[i].isUsed)
5263 {
5264 hddLog(LOGE, "******STAIndex: %d*********", i);
5265 for ( j=0; j< NUM_TX_QUEUES; j++)
5266 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305267 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005268 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305269 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5270 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5271 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305272 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305273 }
5274 }
5275 }
5276
5277}
Jeff Johnson295189b2012-06-20 16:38:30 -07005278int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5279 union iwreq_data *wrqu, char *extra)
5280{
5281 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5282 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5283 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 int apps_args[MAX_VAR_ARGS] = {0};
5285 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005286 hdd_station_ctx_t *pStaCtx = NULL ;
5287 hdd_ap_ctx_t *pAPCtx = NULL;
5288 int cmd = 0;
5289 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005290
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005291 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005292
5293 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5294 {
5295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5296 "%s:LOGP in Progress. Ignore!!!", __func__);
5297 return -EBUSY;
5298 }
5299
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 if (num_args > MAX_VAR_ARGS)
5301 {
5302 num_args = MAX_VAR_ARGS;
5303 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005304
5305 /* ODD number is used for set, copy data using copy_from_user */
5306 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5307 {
5308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5309 "%s: failed to copy data to user buffer", __func__);
5310 return -EFAULT;
5311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005312
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005313 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5314 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5315 {
5316 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5317 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5318 {
5319 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5320 staId = pStaCtx->conn_info.staId[0];
5321 }
5322 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5323 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5324 {
5325 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5326 staId = pAPCtx->uBCStaId;
5327 }
5328 else
5329 {
5330 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5331 return 0;
5332 }
5333 }
5334
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 switch (sub_cmd)
5336 {
5337 case WE_LOG_DUMP_CMD:
5338 {
5339 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005340 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 apps_args[3], apps_args[4]);
5342
5343 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5344 apps_args[3], apps_args[4]);
5345
5346 }
5347 break;
5348
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 case WE_P2P_NOA_CMD:
5350 {
5351 p2p_app_setP2pPs_t p2pNoA;
5352
5353 p2pNoA.opp_ps = apps_args[0];
5354 p2pNoA.ctWindow = apps_args[1];
5355 p2pNoA.duration = apps_args[2];
5356 p2pNoA.interval = apps_args[3];
5357 p2pNoA.count = apps_args[4];
5358 p2pNoA.single_noa_duration = apps_args[5];
5359 p2pNoA.psSelection = apps_args[6];
5360
5361 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5362 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005363 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5365
5366 hdd_setP2pPs(dev, &p2pNoA);
5367
5368 }
5369 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005370
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305371 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5372 {
5373 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5374 __func__, apps_args[0], apps_args[1]);
5375 vosTraceEnable(apps_args[0], apps_args[1]);
5376 }
5377 break;
5378
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005379 case WE_MTRACE_DUMP_CMD:
5380 {
5381 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5382 "bitmask_of_module %d ",
5383 __func__, apps_args[0], apps_args[1], apps_args[2],
5384 apps_args[3]);
5385 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5386 apps_args[2], apps_args[3]);
5387
5388 }
5389 break;
5390
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005391 case WE_MCC_CONFIG_CREDENTIAL :
5392 {
5393 cmd = 287; //Command should be updated if there is any change
5394 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005395 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005396 {
5397 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5398 }
5399 else
5400 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005401 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005402 return 0;
5403 }
5404 }
5405 break;
5406
5407 case WE_MCC_CONFIG_PARAMS :
5408 {
5409 cmd = 288; //command Should be updated if there is any change
5410 // in the Riva dump command
5411 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5412 }
5413 break;
5414
Chilam NG571c65a2013-01-19 12:27:36 +05305415#ifdef FEATURE_WLAN_TDLS
5416 case WE_TDLS_CONFIG_PARAMS :
5417 {
5418 tdls_config_params_t tdlsParams;
5419
Chilam Ng01120412013-02-19 18:32:21 -08005420 tdlsParams.tdls = apps_args[0];
5421 tdlsParams.tx_period_t = apps_args[1];
5422 tdlsParams.tx_packet_n = apps_args[2];
5423 tdlsParams.discovery_period_t = apps_args[3];
5424 tdlsParams.discovery_tries_n = apps_args[4];
5425 tdlsParams.idle_timeout_t = apps_args[5];
5426 tdlsParams.idle_packet_n = apps_args[6];
5427 tdlsParams.rssi_hysteresis = apps_args[7];
5428 tdlsParams.rssi_trigger_threshold = apps_args[8];
5429 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305430
Chilam Ng01120412013-02-19 18:32:21 -08005431 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305432 }
5433 break;
5434#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 default:
5436 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005437 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5438 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 }
5440 break;
5441 }
5442
5443 return 0;
5444}
5445
5446
5447static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5448 union iwreq_data *wrqu, char *extra)
5449{
5450 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5451 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5452 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5453 int params[HDD_WLAN_WMM_PARAM_COUNT];
5454 sme_QosWmmTspecInfo tSpec;
5455 v_U32_t handle;
5456
5457 // make sure the application is sufficiently priviledged
5458 // note that the kernel will do this for "set" ioctls, but since
5459 // this ioctl wants to return status to user space it must be
5460 // defined as a "get" ioctl
5461 if (!capable(CAP_NET_ADMIN))
5462 {
5463 return -EPERM;
5464 }
5465
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005466 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5467 {
5468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5469 "%s:LOGP in Progress. Ignore!!!", __func__);
5470 return -EBUSY;
5471 }
5472
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 // we must be associated in order to add a tspec
5474 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5475 {
5476 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5477 return 0;
5478 }
5479
5480 // since we are defined to be a "get" ioctl, and since the number
5481 // of params exceeds the number of params that wireless extensions
5482 // will pass down in the iwreq_data, we must copy the "set" params
5483 // from user space ourselves
5484 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5485 {
5486 // hmmm, can't get them
5487 return -EIO;
5488 }
5489
5490 // clear the tspec
5491 memset(&tSpec, 0, sizeof(tSpec));
5492
5493 // validate the handle
5494 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5495 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5496 {
5497 // that one is reserved
5498 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5499 return 0;
5500 }
5501
5502 // validate the TID
5503 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5504 {
5505 // out of range
5506 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5507 return 0;
5508 }
5509 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5510
5511 // validate the direction
5512 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5513 {
5514 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5515 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5516 break;
5517
5518 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5519 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5520 break;
5521
5522 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5523 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5524 break;
5525
5526 default:
5527 // unknown
5528 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5529 return 0;
5530 }
5531
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305532 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5533
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 // validate the user priority
5535 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5536 {
5537 // out of range
5538 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5539 return 0;
5540 }
5541 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305542 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5543 {
5544 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5545 return 0;
5546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005547
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5549 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5550 tSpec.ts_info.psb, tSpec.ts_info.up);
5551
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5553 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5554 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5555 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5556 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5557 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5558 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5559 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5560 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5561 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5562 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5563 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5564
5565 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5566
5567 // validate the ts info ack policy
5568 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5569 {
5570 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5571 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5572 break;
5573
5574 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5575 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5576 break;
5577
5578 default:
5579 // unknown
5580 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5581 return 0;
5582 }
5583
5584 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5585 return 0;
5586}
5587
5588
5589static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5590 union iwreq_data *wrqu, char *extra)
5591{
5592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5593 int *params = (int *)extra;
5594 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5595 v_U32_t handle;
5596
5597 // make sure the application is sufficiently priviledged
5598 // note that the kernel will do this for "set" ioctls, but since
5599 // this ioctl wants to return status to user space it must be
5600 // defined as a "get" ioctl
5601 if (!capable(CAP_NET_ADMIN))
5602 {
5603 return -EPERM;
5604 }
5605
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005606 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5607 {
5608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5609 "%s:LOGP in Progress. Ignore!!!", __func__);
5610 return -EBUSY;
5611 }
5612
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 // although we are defined to be a "get" ioctl, the params we require
5614 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5615 // is no need to copy the params from user space
5616
5617 // validate the handle
5618 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5619 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5620 {
5621 // that one is reserved
5622 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5623 return 0;
5624 }
5625
5626 *pStatus = hdd_wmm_delts(pAdapter, handle);
5627 return 0;
5628}
5629
5630
5631static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5632 union iwreq_data *wrqu, char *extra)
5633{
5634 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5635 int *params = (int *)extra;
5636 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5637 v_U32_t handle;
5638
5639 // although we are defined to be a "get" ioctl, the params we require
5640 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5641 // is no need to copy the params from user space
5642
5643 // validate the handle
5644 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5645 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5646 {
5647 // that one is reserved
5648 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5649 return 0;
5650 }
5651
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005652 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5653 {
5654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5655 "%s:LOGP in Progress. Ignore!!!", __func__);
5656 return -EBUSY;
5657 }
5658
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5660 return 0;
5661}
5662
5663
5664#ifdef FEATURE_WLAN_WAPI
5665static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5666 union iwreq_data *wrqu, char *extra)
5667{
5668 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5669 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5670 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5671 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5672
Arif Hussain7adce1b2013-11-11 22:59:34 -08005673 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005674
5675 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005676 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005677 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5678 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005679
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005680 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5681 {
5682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5683 "%s:LOGP in Progress. Ignore!!!", __func__);
5684 return -EBUSY;
5685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005686
5687 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005688 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5690 pRoamProfile->EncryptionType.numEntries = 1;
5691 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5692 pRoamProfile->mcEncryptionType.numEntries = 1;
5693 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5694
5695 pRoamProfile->AuthType.numEntries = 1;
5696 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5697 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5698 }
5699 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005700 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 }
5702 else
5703 return -EINVAL;
5704
5705 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5706
5707 return 0;
5708}
5709
5710static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5711 union iwreq_data *wrqu, char *extra)
5712{
5713 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5714 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5715
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005716 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5717 {
5718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5719 "%s:LOGP in Progress. Ignore!!!", __func__);
5720 return -EBUSY;
5721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5723
5724 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005725 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 return 0;
5727}
5728
5729static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5730 union iwreq_data *wrqu, char *extra)
5731{
5732 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5733// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5734 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5735 int i = 0, j = 0;
5736 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005737 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005738 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005739
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005740 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5741 {
5742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5743 "%s:LOGP in Progress. Ignore!!!", __func__);
5744 return -EBUSY;
5745 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005746
5747 if (NULL == pWapiAssocInfo)
5748 {
5749 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5750 "%s: WDA NULL context", __func__);
5751 VOS_ASSERT(0);
5752 return VOS_STATUS_E_FAILURE;
5753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005754
Arif Hussain6d2a3322013-11-17 19:50:10 -08005755 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 -07005756 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005758 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005759
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005760 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005762 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005763
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005764 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005765 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 for(i = 0 ; i < 16 ; i++) {
5767 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5768 for(j = 0 ; j < 16 ; j++)
5769 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5770 }
5771
5772 /* We are not using the entire IE as provided by the supplicant.
5773 * This is being calculated by SME. This is the same as in the
5774 * case of WPA. Only the auth mode information needs to be
5775 * extracted here*/
5776 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005777 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5779 }
5780
5781 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005782 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5784 }
5785 return 0;
5786}
5787
5788static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5789 union iwreq_data *wrqu, char *extra)
5790{
5791 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5792 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5793 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5794 tANI_U32 roamId = 0xFF;
5795 tANI_U8 *pKeyPtr = NULL;
5796 v_BOOL_t isConnected = TRUE;
5797 tCsrRoamSetKey setKey;
5798 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5800
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005801 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5802 {
5803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5804 "%s:LOGP in Progress. Ignore!!!", __func__);
5805 return -EBUSY;
5806 }
5807
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005809 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005810 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005811
Arif Hussain6d2a3322013-11-17 19:50:10 -08005812 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 -07005813 hddLog(LOG1,"Add Index:0x");
5814 for(i =0 ; i < 12 ; i++)
5815 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5816
Arif Hussain6d2a3322013-11-17 19:50:10 -08005817 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5819 for(i =0 ; i < 16 ; i++)
5820 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5821
Arif Hussain6d2a3322013-11-17 19:50:10 -08005822 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5824 for(i =0 ; i < 16 ; i++)
5825 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5826
Arif Hussain6d2a3322013-11-17 19:50:10 -08005827 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 for(i = 0 ; i < 16 ; i++)
5829 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5830
5831 // Clear the setkey memory
5832 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5833 // Store Key ID
5834 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5835 // SET WAPI Encryption
5836 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5837 // Key Directionn both TX and RX
5838 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5839 // the PAE role
5840 setKey.paeRole = 0 ;
5841
5842 switch ( pWapiKey->keyType )
5843 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005844 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 {
5846 isConnected = hdd_connIsConnected(pHddStaCtx);
5847 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5848 break;
5849 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005850 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 {
5852 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5853 break;
5854 }
5855 default:
5856 {
5857 //Any other option is invalid.
5858 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005859 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005860
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005861 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5863 break; // NEED RETURN FROM HERE ????
5864 }
5865 }
5866
5867 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5868 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5869 pKeyPtr = setKey.Key;
5870 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5871 pKeyPtr += pWapiKey->wpiekLen;
5872 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5873
5874 // Set the new key with SME.
5875 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5876
5877 if ( isConnected ) {
5878 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5879 if ( halStatus != eHAL_STATUS_SUCCESS )
5880 {
5881 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5882 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5883
5884 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5885 }
5886 }
5887#if 0 /// NEED TO CHECK ON THIS
5888 else
5889 {
5890 // Store the keys in the adapter to be moved to the profile & passed to
5891 // SME in the ConnectRequest if we are not yet in connected state.
5892 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5893 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5894
5895 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5896 " Saving key [idx= %d] to apply when moving to connected state ",
5897 setKey.keyId );
5898
5899 }
5900#endif
5901 return halStatus;
5902}
5903
5904static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5905 union iwreq_data *wrqu, char *extra)
5906{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005907 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005908#ifdef WLAN_DEBUG
5909 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005910 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005911#endif
5912
5913 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005914 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005915 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005916
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005917 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5918 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005919
5920 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005921
5922 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5923 {
5924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5925 "%s:LOGP in Progress. Ignore!!!", __func__);
5926 return -EBUSY;
5927 }
5928
Jeff Johnson295189b2012-06-20 16:38:30 -07005929#ifdef WLAN_DEBUG
5930 for(i =0 ; i < 16 ; i++)
5931 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5932#endif
5933
5934 return 0;
5935}
5936
5937static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5938 union iwreq_data *wrqu, char *extra)
5939{
5940 /* Yet to implement this function, 19th April 2010 */
5941 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5942
5943 return 0;
5944}
5945#endif /* FEATURE_WLAN_WAPI */
5946
5947#ifdef WLAN_FEATURE_VOWIFI_11R
5948//
5949//
5950// Each time the supplicant has the auth_request or reassoc request
5951// IEs ready. This is pushed to the driver. The driver will inturn use
5952// it to send out the auth req and reassoc req for 11r FT Assoc.
5953//
5954static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5955 union iwreq_data *wrqu, char *extra)
5956{
5957 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5958 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5959 //v_CONTEXT_t pVosContext;
5960
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005961 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5962 {
5963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5964 "%s:LOGP in Progress. Ignore!!!", __func__);
5965 return -EBUSY;
5966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 if (!wrqu->data.length)
5968 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005969 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 return -EINVAL;
5971 }
5972 if (wrqu->data.pointer == NULL)
5973 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005974 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 return -EINVAL;
5976 }
5977
5978 // Added for debug on reception of Re-assoc Req.
5979 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5980 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005981 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005983 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 }
5985
5986#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005987 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005988#endif
5989
5990 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005991 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 wrqu->data.length);
5993
5994 return 0;
5995}
5996#endif
5997
Amar Singhalf3a6e762013-02-19 15:06:50 -08005998static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005999 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08006001{
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006003 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006005 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006006 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006007 tpSirRcvFltMcAddrList mc_addr_list_ptr;
6008 int idx;
6009 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07006010
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006011 if (pHddCtx->isLogpInProgress)
6012 {
6013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6014 "%s:LOGP in Progress. Ignore!!!", __func__);
6015 return -EBUSY;
6016 }
6017
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306018 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
6019 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306020#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07006021
Amar Singhalf3a6e762013-02-19 15:06:50 -08006022 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6023 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006024 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006025 hddLog(VOS_TRACE_LEVEL_ERROR,
6026 "%s: vos_mem_alloc failed", __func__);
6027 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006028 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006029
6030 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6031
6032 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6033 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6034
6035 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6036 mc_addr_list_ptr->ulMulticastAddrCnt);
6037
6038 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006039 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006040 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6041 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6042
6043 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6044 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006045 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006046
Amar Singhalf3a6e762013-02-19 15:06:50 -08006047 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6048 vos_mem_free(mc_addr_list_ptr);
6049 if (eHAL_STATUS_SUCCESS != ret_val)
6050 {
6051 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6052 __func__);
6053 return -EINVAL;
6054 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306055#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306056 }
6057 else
6058 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006059
Amar Singhalf3a6e762013-02-19 15:06:50 -08006060 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6061 "%s: Set MC BC Filter Config request: %d suspend %d",
6062 __func__, pRequest->mcastBcastFilterSetting,
6063 pHddCtx->hdd_wlan_suspended);
6064
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306065 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006066
6067 if (pHddCtx->hdd_wlan_suspended)
6068 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006069 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6070 if (NULL == wlanRxpFilterParam)
6071 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306072 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006073 "%s: vos_mem_alloc failed", __func__);
6074 return -EINVAL;
6075 }
6076
Amar Singhalf3a6e762013-02-19 15:06:50 -08006077 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6078 pRequest->mcastBcastFilterSetting;
6079 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6080
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306081 hdd_conf_hostoffload(pAdapter, TRUE);
6082 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6083 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006084
6085 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6086 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306087 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006088 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6089 wlanRxpFilterParam->setMcstBcstFilter);
6090
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306091 if (eHAL_STATUS_SUCCESS !=
6092 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6093 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006094 {
6095 hddLog(VOS_TRACE_LEVEL_ERROR,
6096 "%s: Failure to execute set HW MC/BC Filter request",
6097 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006098 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006099 return -EINVAL;
6100 }
6101
Amar Singhalf3a6e762013-02-19 15:06:50 -08006102 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006104
6105 return 0;
6106}
6107
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006108static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006109 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 union iwreq_data *wrqu, char *extra)
6111{
6112 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6113 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306114 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006115 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006116
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306117 //Reset the filter to INI value as we have to clear the dynamic filter
6118 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006119
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306120 //Configure FW with new setting
6121 if (pHddCtx->hdd_wlan_suspended)
6122 {
6123 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6124 if (NULL == wlanRxpFilterParam)
6125 {
6126 hddLog(VOS_TRACE_LEVEL_ERROR,
6127 "%s: vos_mem_alloc failed", __func__);
6128 return -EINVAL;
6129 }
6130
6131 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6132 pHddCtx->configuredMcastBcastFilter;
6133 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6134
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306135 hdd_conf_hostoffload(pAdapter, TRUE);
6136 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6137 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306138
6139 if (eHAL_STATUS_SUCCESS !=
6140 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6141 wlanRxpFilterParam))
6142 {
6143 hddLog(VOS_TRACE_LEVEL_ERROR,
6144 "%s: Failure to execute set HW MC/BC Filter request",
6145 __func__);
6146 vos_mem_free(wlanRxpFilterParam);
6147 return -EINVAL;
6148 }
6149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 return 0;
6151}
6152
6153static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6154 union iwreq_data *wrqu, char *extra)
6155{
6156 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006157 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 tSirHostOffloadReq offloadRequest;
6159
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006160 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6161 {
6162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6163 "%s:LOGP in Progress. Ignore!!!", __func__);
6164 return -EBUSY;
6165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 /* Debug display of request components. */
6167 switch (pRequest->offloadType)
6168 {
6169 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006170 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006171 switch (pRequest->enableOrDisable)
6172 {
6173 case WLAN_OFFLOAD_DISABLE:
6174 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6175 break;
6176 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6177 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6178 case WLAN_OFFLOAD_ENABLE:
6179 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6180 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6181 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6182 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6183 }
6184 break;
6185
6186 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006187 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006188 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 switch (pRequest->enableOrDisable)
6190 {
6191 case WLAN_OFFLOAD_DISABLE:
6192 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6193 break;
6194 case WLAN_OFFLOAD_ENABLE:
6195 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6196 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6197 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6198 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6199 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6200 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6201 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6202 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6203 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6204 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6205 }
6206 }
6207
6208 /* Execute offload request. The reason that we can copy the request information
6209 from the ioctl structure to the SME structure is that they are laid out
6210 exactly the same. Otherwise, each piece of information would have to be
6211 copied individually. */
6212 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006213 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6214 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006216 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 __func__);
6218 return -EINVAL;
6219 }
6220
6221 return 0;
6222}
6223
6224static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6225 union iwreq_data *wrqu, char *extra)
6226{
6227 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006228 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 tSirKeepAliveReq keepaliveRequest;
6230
6231 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6232 {
6233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006234 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 return 0;
6236 }
6237
6238 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006239 hddLog(VOS_TRACE_LEVEL_INFO,
6240 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6241 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006242
6243 switch (pRequest->packetType)
6244 {
6245 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006246 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 break;
6248
6249 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6250
Arif Hussain6d2a3322013-11-17 19:50:10 -08006251 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006252 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253
6254 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6255 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6256 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6257
6258 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6259 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6260 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6261
6262 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6263 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6264 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6265 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6266 break;
6267
6268 }
6269
6270 /* Execute keep alive request. The reason that we can copy the request information
6271 from the ioctl structure to the SME structure is that they are laid out
6272 exactly the same. Otherwise, each piece of information would have to be
6273 copied individually. */
6274 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6275
Arif Hussain6d2a3322013-11-17 19:50:10 -08006276 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006277
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006278 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006279 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006281 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 __func__);
6283 return -EINVAL;
6284 }
6285
6286 return 0;
6287}
6288
6289#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006290int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006291 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006292{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006293 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6294 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 int i=0;
6296
6297 if (pHddCtx->cfg_ini->disablePacketFilter)
6298 {
6299 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006300 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 return 0;
6302 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006303 if (pHddCtx->isLogpInProgress)
6304 {
6305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6306 "%s:LOGP in Progress. Ignore!!!", __func__);
6307 return -EBUSY;
6308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 /* Debug display of request components. */
6310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006311 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006312
6313 switch (pRequest->filterAction)
6314 {
6315 case HDD_RCV_FILTER_SET:
6316 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006317 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006318
6319 packetFilterSetReq.filterId = pRequest->filterId;
6320 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6321 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 __func__, pRequest->numParams);
6324 return -EINVAL;
6325 }
6326 packetFilterSetReq.numFieldParams = pRequest->numParams;
6327 packetFilterSetReq.coalesceTime = 0;
6328 packetFilterSetReq.filterType = 1;
6329 for (i=0; i < pRequest->numParams; i++)
6330 {
6331 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6332 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6333 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6334 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6335 packetFilterSetReq.paramsData[i].reserved = 0;
6336
Arif Hussain6d2a3322013-11-17 19:50:10 -08006337 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6339 packetFilterSetReq.filterType);
6340
Arif Hussain6d2a3322013-11-17 19:50:10 -08006341 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6343
6344 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6345 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6346 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6347 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6348
Arif Hussain6d2a3322013-11-17 19:50:10 -08006349 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6351 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6352 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6353
Arif Hussain6d2a3322013-11-17 19:50:10 -08006354 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6356 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6357 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6358 }
6359
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006360 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006362 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 __func__);
6364 return -EINVAL;
6365 }
6366
6367 break;
6368
6369 case HDD_RCV_FILTER_CLEAR:
6370
Arif Hussain6d2a3322013-11-17 19:50:10 -08006371 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006372 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006374 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006376 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 __func__);
6378 return -EINVAL;
6379 }
6380 break;
6381
6382 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006383 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006384 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 return -EINVAL;
6386 }
6387 return 0;
6388}
6389
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306390int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6391 tANI_U8 sessionId)
6392{
6393 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6394 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6395
6396 if (NULL == pHddCtx)
6397 {
6398 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6399 return -EINVAL;
6400 }
6401
6402 if (pHddCtx->isLogpInProgress)
6403 {
6404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6405 "%s:LOGP in Progress. Ignore!!!", __func__);
6406 return -EBUSY;
6407 }
6408
6409 if (pHddCtx->cfg_ini->disablePacketFilter)
6410 {
6411 hddLog(VOS_TRACE_LEVEL_ERROR,
6412 "%s: Packet Filtering Disabled. Returning ",
6413 __func__ );
6414 return -EINVAL;
6415 }
6416
6417 switch (filterType)
6418 {
6419 /* For setting IPV6 MC and UC Filter we need to configure
6420 * 2 filters, one for MC and one for UC.
6421 * The Filter ID shouldn't be swapped, which results in making
6422 * UC Filter ineffective.
6423 * We have Hardcode all the values
6424 *
6425 * Reason for a seperate UC filter is because, driver need to
6426 * specify the FW that the specific filter is for unicast
6427 * otherwise FW will not pass the unicast frames by default
6428 * through the filter. This is required to avoid any performance
6429 * hits when no unicast filter is set and only MC/BC are set.
6430 * The way driver informs host is by using the MAC protocol
6431 * layer, CMP flag set to MAX, CMP Data set to 1.
6432 */
6433
6434 case HDD_FILTER_IPV6_MC_UC:
6435 /* Setting IPV6 MC Filter below
6436 */
6437 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6438 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6439 packetFilterSetReq.numFieldParams = 2;
6440 packetFilterSetReq.paramsData[0].protocolLayer =
6441 HDD_FILTER_PROTO_TYPE_MAC;
6442 packetFilterSetReq.paramsData[0].cmpFlag =
6443 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6444 packetFilterSetReq.paramsData[0].dataOffset =
6445 WLAN_HDD_80211_FRM_DA_OFFSET;
6446 packetFilterSetReq.paramsData[0].dataLength = 1;
6447 packetFilterSetReq.paramsData[0].compareData[0] =
6448 HDD_IPV6_MC_CMP_DATA;
6449
6450 packetFilterSetReq.paramsData[1].protocolLayer =
6451 HDD_FILTER_PROTO_TYPE_ARP;
6452 packetFilterSetReq.paramsData[1].cmpFlag =
6453 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6454 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6455 packetFilterSetReq.paramsData[1].dataLength = 2;
6456 packetFilterSetReq.paramsData[1].compareData[0] =
6457 HDD_IPV6_CMP_DATA_0;
6458 packetFilterSetReq.paramsData[1].compareData[1] =
6459 HDD_IPV6_CMP_DATA_1;
6460
6461
6462 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6463 &packetFilterSetReq, sessionId))
6464 {
6465 hddLog(VOS_TRACE_LEVEL_ERROR,
6466 "%s: Failure to execute Set IPv6 Mulicast Filter",
6467 __func__);
6468 return -EINVAL;
6469 }
6470
6471 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6472
6473 /*
6474 * Setting IPV6 UC Filter below
6475 */
6476 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6477 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6478 packetFilterSetReq.numFieldParams = 2;
6479 packetFilterSetReq.paramsData[0].protocolLayer =
6480 HDD_FILTER_PROTO_TYPE_MAC;
6481 packetFilterSetReq.paramsData[0].cmpFlag =
6482 HDD_FILTER_CMP_TYPE_MAX;
6483 packetFilterSetReq.paramsData[0].dataOffset = 0;
6484 packetFilterSetReq.paramsData[0].dataLength = 1;
6485 packetFilterSetReq.paramsData[0].compareData[0] =
6486 HDD_IPV6_UC_CMP_DATA;
6487
6488 packetFilterSetReq.paramsData[1].protocolLayer =
6489 HDD_FILTER_PROTO_TYPE_ARP;
6490 packetFilterSetReq.paramsData[1].cmpFlag =
6491 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6492 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6493 packetFilterSetReq.paramsData[1].dataLength = 2;
6494 packetFilterSetReq.paramsData[1].compareData[0] =
6495 HDD_IPV6_CMP_DATA_0;
6496 packetFilterSetReq.paramsData[1].compareData[1] =
6497 HDD_IPV6_CMP_DATA_1;
6498
6499 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6500 &packetFilterSetReq, sessionId))
6501 {
6502 hddLog(VOS_TRACE_LEVEL_ERROR,
6503 "%s: Failure to execute Set IPv6 Unicast Filter",
6504 __func__);
6505 return -EINVAL;
6506 }
6507
6508 break;
6509
6510 case HDD_FILTER_IPV6_MC:
6511 /*
6512 * IPV6 UC Filter might be already set,
6513 * clear the UC Filter. As the Filter
6514 * IDs are static, we can directly clear it.
6515 */
6516 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6517 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6518 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6519 &packetFilterClrReq, sessionId))
6520 {
6521 hddLog(VOS_TRACE_LEVEL_ERROR,
6522 "%s: Failure to execute Clear IPv6 Unicast Filter",
6523 __func__);
6524 return -EINVAL;
6525 }
6526
6527 /*
6528 * Setting IPV6 MC Filter below
6529 */
6530 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6531 packetFilterSetReq.numFieldParams = 2;
6532 packetFilterSetReq.paramsData[0].protocolLayer =
6533 HDD_FILTER_PROTO_TYPE_MAC;
6534 packetFilterSetReq.paramsData[0].cmpFlag =
6535 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6536 packetFilterSetReq.paramsData[0].dataOffset =
6537 WLAN_HDD_80211_FRM_DA_OFFSET;
6538 packetFilterSetReq.paramsData[0].dataLength = 1;
6539 packetFilterSetReq.paramsData[0].compareData[0] =
6540 HDD_IPV6_MC_CMP_DATA;
6541
6542 packetFilterSetReq.paramsData[1].protocolLayer =
6543 HDD_FILTER_PROTO_TYPE_ARP;
6544 packetFilterSetReq.paramsData[1].cmpFlag =
6545 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6546 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6547 packetFilterSetReq.paramsData[1].dataLength = 2;
6548 packetFilterSetReq.paramsData[1].compareData[0] =
6549 HDD_IPV6_CMP_DATA_0;
6550 packetFilterSetReq.paramsData[1].compareData[1] =
6551 HDD_IPV6_CMP_DATA_1;
6552
6553
6554 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6555 &packetFilterSetReq, sessionId))
6556 {
6557 hddLog(VOS_TRACE_LEVEL_ERROR,
6558 "%s: Failure to execute Set IPv6 Multicast Filter",
6559 __func__);
6560 return -EINVAL;
6561 }
6562 break;
6563
6564 default :
6565 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6566 "%s: Packet Filter Request: Invalid",
6567 __func__);
6568 return -EINVAL;
6569 }
6570 return 0;
6571}
6572
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306573void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006574{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306575 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306576 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006577 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306578 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006579
Yue Ma3ede6052013-08-29 00:33:26 -07006580 if (NULL == pHddCtx)
6581 {
6582 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6583 return;
6584 }
6585
6586 hHal = pHddCtx->hHal;
6587
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306588 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306590 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6591 return;
6592 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306593
6594 /* Check if INI is enabled or not, other wise just return
6595 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306596 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306597 {
6598 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6599 if (NULL == pMulticastAddrs)
6600 {
6601 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6602 return;
6603 }
6604
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 if (set)
6606 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306607 /* Following pre-conditions should be satisfied before wei
6608 * configure the MC address list.
6609 */
6610 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6611 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6612 && pAdapter->mc_addr_list.mc_cnt
6613 && (eConnectionState_Associated ==
6614 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6615 {
6616 pMulticastAddrs->ulMulticastAddrCnt =
6617 pAdapter->mc_addr_list.mc_cnt;
6618 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6619 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006620 memcpy(pMulticastAddrs->multicastAddr[i],
6621 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306622 sizeof(pAdapter->mc_addr_list.addr[i]));
6623 hddLog(VOS_TRACE_LEVEL_INFO,
6624 "%s: %s multicast filter: addr ="
6625 MAC_ADDRESS_STR,
6626 __func__, set ? "setting" : "clearing",
6627 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6628 }
6629 /* Set multicast filter */
6630 sme_8023MulticastList(hHal, pAdapter->sessionId,
6631 pMulticastAddrs);
6632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306634 else
6635 {
6636 /* Need to clear only if it was previously configured
6637 */
6638 if (pAdapter->mc_addr_list.isFilterApplied)
6639 {
6640 pMulticastAddrs->ulMulticastAddrCnt = 0;
6641 sme_8023MulticastList(hHal, pAdapter->sessionId,
6642 pMulticastAddrs);
6643 }
6644
6645 }
6646 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006647 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306649 else
6650 {
6651 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306652 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306653 }
6654 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006655}
6656
6657static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6658 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306659{
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006661 tpPacketFilterCfg pRequest = NULL;
6662 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006663
Arif Hussain0273cba2014-01-07 20:58:29 -08006664 /* ODD number is used for set, copy data using copy_from_user */
6665 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6666 wrqu->data.length);
6667 if (NULL == pRequest)
6668 {
6669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6670 "mem_alloc_copy_from_user_helper fail");
6671 return -ENOMEM;
6672 }
6673
6674 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6675 kfree(pRequest);
6676
6677 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006678}
6679#endif
6680static int iw_get_statistics(struct net_device *dev,
6681 struct iw_request_info *info,
6682 union iwreq_data *wrqu, char *extra)
6683{
6684
6685 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6686 eHalStatus status = eHAL_STATUS_SUCCESS;
6687 hdd_wext_state_t *pWextState;
6688 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6689 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6690 char *p = extra;
6691 int tlen = 0;
6692 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6693
6694 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6695 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6696
6697 ENTER();
6698
6699 if (pHddCtx->isLogpInProgress) {
6700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6701 return -EINVAL;
6702 }
6703
6704 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6705
6706 wrqu->txpower.value = 0;
6707 }
6708 else {
6709 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6710 SME_SUMMARY_STATS |
6711 SME_GLOBAL_CLASSA_STATS |
6712 SME_GLOBAL_CLASSB_STATS |
6713 SME_GLOBAL_CLASSC_STATS |
6714 SME_GLOBAL_CLASSD_STATS |
6715 SME_PER_STA_STATS,
6716 hdd_StatisticsCB, 0, FALSE,
6717 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6718
6719 if (eHAL_STATUS_SUCCESS != status)
6720 {
6721 hddLog(VOS_TRACE_LEVEL_ERROR,
6722 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006723 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 return -EINVAL;
6725 }
6726
6727 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6728
6729 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6730 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6731 {
6732 hddLog(VOS_TRACE_LEVEL_ERROR,
6733 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006734 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 /*Remove the SME statistics list by passing NULL in callback argument*/
6736 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6737 SME_SUMMARY_STATS |
6738 SME_GLOBAL_CLASSA_STATS |
6739 SME_GLOBAL_CLASSB_STATS |
6740 SME_GLOBAL_CLASSC_STATS |
6741 SME_GLOBAL_CLASSD_STATS |
6742 SME_PER_STA_STATS,
6743 NULL, 0, FALSE,
6744 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6745
6746 return -EINVAL;
6747 }
6748 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6749 (tANI_U8) sizeof (pStats->retry_cnt),
6750 (char*) &(pStats->retry_cnt[0]),
6751 tlen);
6752
6753 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6754 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6755 (char*) &(pStats->multiple_retry_cnt[0]),
6756 tlen);
6757
6758 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6759 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6760 (char*) &(pStats->tx_frm_cnt[0]),
6761 tlen);
6762
6763 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6764 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6765 (char*) &(pStats->rx_frm_cnt),
6766 tlen);
6767
6768 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6769 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6770 (char*) &(pStats->frm_dup_cnt),
6771 tlen);
6772
6773 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6774 (tANI_U8) sizeof (pStats->fail_cnt),
6775 (char*) &(pStats->fail_cnt[0]),
6776 tlen);
6777
6778 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6779 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6780 (char*) &(pStats->rts_fail_cnt),
6781 tlen);
6782
6783 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6784 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6785 (char*) &(pStats->ack_fail_cnt),
6786 tlen);
6787
6788 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6789 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6790 (char*) &(pStats->rts_succ_cnt),
6791 tlen);
6792
6793 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6794 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6795 (char*) &(pStats->rx_discard_cnt),
6796 tlen);
6797
6798 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6799 (tANI_U8) sizeof (pStats->rx_error_cnt),
6800 (char*) &(pStats->rx_error_cnt),
6801 tlen);
6802
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006803 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006804 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006805 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 tlen);
6807
6808 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6809 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6810 (char*) &(dStats->rx_byte_cnt),
6811 tlen);
6812
6813 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6814 (tANI_U8) sizeof (dStats->rx_rate),
6815 (char*) &(dStats->rx_rate),
6816 tlen);
6817
6818 /* Transmit rate, in units of 500 kbit/sec */
6819 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6820 (tANI_U8) sizeof (aStats->tx_rate),
6821 (char*) &(aStats->tx_rate),
6822 tlen);
6823
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006824 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6825 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6826 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006827 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006828 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6829 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6830 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006831 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006832 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6833 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6834 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006835 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006836 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6837 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6838 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006839 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006840 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6841 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6842 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006843 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006844 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6845 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6846 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006847 tlen);
6848
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 wrqu->data.length = tlen;
6850
6851 }
6852
6853 EXIT();
6854
6855 return 0;
6856}
6857
6858
6859#ifdef FEATURE_WLAN_SCAN_PNO
6860
6861/*Max Len for PNO notification*/
6862#define MAX_PNO_NOTIFY_LEN 100
6863void found_pref_network_cb (void *callbackContext,
6864 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6865{
6866 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6867 union iwreq_data wrqu;
6868 char buf[MAX_PNO_NOTIFY_LEN+1];
6869
6870 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6871 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6872
6873 // create the event
6874 memset(&wrqu, 0, sizeof(wrqu));
6875 memset(buf, 0, sizeof(buf));
6876
6877 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6878 pPrefNetworkFoundInd->ssId.ssId,
6879 (unsigned int)pPrefNetworkFoundInd->rssi);
6880
6881 wrqu.data.pointer = buf;
6882 wrqu.data.length = strlen(buf);
6883
6884 // send the event
6885
6886 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6887
6888}
6889
6890
6891/*string based input*/
6892VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6893 union iwreq_data *wrqu, char *extra, int nOffset)
6894{
6895 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05306896 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006897 /* pnoRequest is a large struct, so we make it static to avoid stack
6898 overflow. This API is only invoked via ioctl, so it is
6899 serialized by the kernel rtnl_lock and hence does not need to be
6900 reentrant */
6901 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 char *ptr;
6903 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05306904 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6906
6907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6908 "PNO data len %d data %s",
6909 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006910 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006911
6912 if (wrqu->data.length <= nOffset )
6913 {
6914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6915 return VOS_STATUS_E_FAILURE;
6916 }
6917
6918 pnoRequest.enable = 0;
6919 pnoRequest.ucNetworksCount = 0;
6920 /*-----------------------------------------------------------------------
6921 Input is string based and expected to be like this:
6922
6923 <enabled> <netw_count>
6924 for each network:
6925 <ssid_len> <ssid> <authentication> <encryption>
6926 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6927 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6928
6929 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006930 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 -07006931
6932 this translates into:
6933 -----------------------------
6934 enable PNO
6935 look for 2 networks:
6936 test - with authentication type 0 and encryption type 0,
6937 that can be found on 3 channels: 1 6 and 11 ,
6938 SSID bcast type is unknown (directed probe will be sent if AP not found)
6939 and must meet -40dBm RSSI
6940
6941 test2 - with auth and enrytption type 4/4
6942 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6943 bcast type is non-bcast (directed probe will be sent)
6944 and must not meet any RSSI threshold
6945
Jeff Johnson8301aa12013-03-28 14:27:29 -07006946 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006948 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006949
Wilson Yang623f6592013-10-08 16:33:37 -07006950 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6951 {
6952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6953 "PNO enable input is not valid %s",ptr);
6954 return VOS_STATUS_E_FAILURE;
6955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006956
6957 if ( 0 == pnoRequest.enable )
6958 {
6959 /*Disable PNO*/
6960 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05306961 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
6962 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 pAdapter->sessionId,
6964 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05306965 if (eHAL_STATUS_SUCCESS != status)
6966 {
6967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6968 "%s: failed to disable PNO", __func__);
6969 return VOS_STATUS_E_FAILURE;
6970 }
6971 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 return VOS_STATUS_SUCCESS;
6973 }
6974
c_hpothu37f21312014-04-09 21:49:54 +05306975 if (TRUE == pHddCtx->isPnoEnable)
6976 {
6977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6978 FL("already PNO is enabled"));
6979 return -EBUSY;
6980 }
6981 pHddCtx->isPnoEnable = TRUE;
6982
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006984
6985 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6986 {
6987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6988 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306989 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006990 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006991
6992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6993 "PNO enable %d networks count %d offset %d",
6994 pnoRequest.enable,
6995 pnoRequest.ucNetworksCount,
6996 nOffset);
6997
6998 /* Parameters checking:
6999 ucNetworksCount has to be larger than 0*/
7000 if (( 0 == pnoRequest.ucNetworksCount ) ||
7001 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7002 {
7003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05307004 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 }
7006
7007 ptr += nOffset;
7008
7009 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
7010 {
7011
7012 pnoRequest.aNetworks[i].ssId.length = 0;
7013
Wilson Yang623f6592013-10-08 16:33:37 -07007014 ucParams = sscanf(ptr,"%hhu %n",
7015 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
7016
7017 if (1 != ucParams)
7018 {
7019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7020 "PNO ssid length input is not valid %s",ptr);
7021 return VOS_STATUS_E_FAILURE;
7022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007023
7024 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
7025 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
7026 {
7027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7028 "SSID Len %d is not correct for network %d",
7029 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05307030 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 }
7032
7033 /*Advance to SSID*/
7034 ptr += nOffset;
7035
Jeff Johnson8301aa12013-03-28 14:27:29 -07007036 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08007037 pnoRequest.aNetworks[i].ssId.length);
7038 ptr += pnoRequest.aNetworks[i].ssId.length;
7039
Jeff Johnson02797792013-10-26 19:17:13 -07007040 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007041 &(pnoRequest.aNetworks[i].authentication),
7042 &(pnoRequest.aNetworks[i].encryption),
7043 &(pnoRequest.aNetworks[i].ucChannelCount),
7044 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007045
Wilson Yang623f6592013-10-08 16:33:37 -07007046 if ( 3 != ucParams )
7047 {
7048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7049 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307050 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007051 }
7052
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007054 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08007055 "auth %d encry %d channel count %d offset %d",
7056 pnoRequest.aNetworks[i].ssId.length,
7057 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
7058 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7059 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7060 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7061 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7062 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7063 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7064 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7065 pnoRequest.aNetworks[i].authentication,
7066 pnoRequest.aNetworks[i].encryption,
7067 pnoRequest.aNetworks[i].ucChannelCount,
7068 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007069
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 /*Advance to channel list*/
7071 ptr += nOffset;
7072
Wilson Yang623f6592013-10-08 16:33:37 -07007073 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 {
7075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7076 "Incorrect number of channels");
7077 return VOS_STATUS_E_FAILURE;
7078 }
7079
7080 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7081 {
7082 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7083 {
Wilson Yang623f6592013-10-08 16:33:37 -07007084 if (1 != sscanf(ptr,"%hhu %n",
7085 &(pnoRequest.aNetworks[i].aChannels[j]),
7086 &nOffset))
7087 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7088 "PNO network channel input is not valid %s",ptr);
7089 return VOS_STATUS_E_FAILURE;
7090 }
7091 /*Advance to next channel number*/
7092 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 }
7094 }
7095
Jeff Johnson02797792013-10-26 19:17:13 -07007096 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007097 &(pnoRequest.aNetworks[i].bcastNetwType),
7098 &nOffset))
7099 {
7100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7101 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307102 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007104
7105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7106 "PNO bcastNetwType %d offset %d",
7107 pnoRequest.aNetworks[i].bcastNetwType,
7108 nOffset );
7109
7110 /*Advance to rssi Threshold*/
7111 ptr += nOffset;
7112
Wilson Yang623f6592013-10-08 16:33:37 -07007113 if (1 != sscanf(ptr,"%hhu %n",
7114 &(pnoRequest.aNetworks[i].rssiThreshold),
7115 &nOffset))
7116 {
7117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7118 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307119 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007121
7122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7123 "PNO rssi %d offset %d",
7124 pnoRequest.aNetworks[i].rssiThreshold,
7125 nOffset );
7126 /*Advance to next network*/
7127 ptr += nOffset;
7128 }/*For ucNetworkCount*/
7129
7130 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007131 &(pnoRequest.scanTimers.ucScanTimersCount),
7132 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007133
7134 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007135 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 {
7137 ptr += nOffset;
7138
Jeff Johnson8301aa12013-03-28 14:27:29 -07007139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7140 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 pnoRequest.scanTimers.ucScanTimersCount,
7142 nOffset );
7143
7144 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7145 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307148 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 }
7150
7151 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7152 {
Jeff Johnson02797792013-10-26 19:17:13 -07007153 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7155 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7156 &nOffset);
7157
Wilson Yang623f6592013-10-08 16:33:37 -07007158 if (2 != ucParams)
7159 {
7160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7161 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307162 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007163 }
7164
Jeff Johnson8301aa12013-03-28 14:27:29 -07007165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7166 "PNO Timer value %d Timer repeat %d offset %d",
7167 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7169 nOffset );
7170
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 ptr += nOffset;
7172 }
7173
7174 }
7175 else
7176 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7178 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7180
7181 /*Scan timers defaults to 5 minutes*/
7182 pnoRequest.scanTimers.ucScanTimersCount = 1;
7183 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7184 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7185 }
7186
Wilson Yang623f6592013-10-08 16:33:37 -07007187 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007188
7189 pnoRequest.modePNO = ucMode;
7190 /*for LA we just expose suspend option*/
7191 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7192 {
7193 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7194 }
7195
c_hpothu37f21312014-04-09 21:49:54 +05307196 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 pAdapter->sessionId,
7198 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307199 if (eHAL_STATUS_SUCCESS == status)
7200 {
7201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7202 "%s: PNO enabled", __func__);
7203 return VOS_STATUS_SUCCESS;
7204 }
7205error:
7206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7207 "%s: Failed to enable PNO", __func__);
7208 pHddCtx->isPnoEnable = FALSE;
7209 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007210}/*iw_set_pno*/
7211
7212VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7213 union iwreq_data *wrqu, char *extra, int nOffset)
7214{
7215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7216 v_U8_t rssiThreshold = 0;
7217 v_U8_t nRead;
7218
Arif Hussain7adce1b2013-11-11 22:59:34 -08007219 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 &rssiThreshold);
7221
7222 if ( 1 != nRead )
7223 {
7224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7225 "Incorrect format");
7226 return VOS_STATUS_E_FAILURE;
7227 }
7228
7229 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7230 return VOS_STATUS_SUCCESS;
7231}
7232
7233
7234static int iw_set_pno_priv(struct net_device *dev,
7235 struct iw_request_info *info,
7236 union iwreq_data *wrqu, char *extra)
7237{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007238 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7239
7240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007242
7243 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7244 {
7245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7246 "%s:LOGP in Progress. Ignore!!!", __func__);
7247 return -EBUSY;
7248 }
7249 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007250}
7251#endif /*FEATURE_WLAN_SCAN_PNO*/
7252
7253//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307254int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007255{
7256 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7257 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7258 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307259 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307261 eCsrBand connectedBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007262
Atul Mittal54378cb2014-04-02 16:51:50 +05307263 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007264 {
7265 case WLAN_HDD_UI_BAND_AUTO:
7266 band = eCSR_BAND_ALL;
7267 break;
7268 case WLAN_HDD_UI_BAND_5_GHZ:
7269 band = eCSR_BAND_5G;
7270 break;
7271 case WLAN_HDD_UI_BAND_2_4_GHZ:
7272 band = eCSR_BAND_24;
7273 break;
7274 default:
7275 band = eCSR_BAND_MAX;
7276 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307277 connectedBand =
7278 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007279
Atul Mittal54378cb2014-04-02 16:51:50 +05307280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007281 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007282
7283 if (band == eCSR_BAND_MAX)
7284 {
7285 /* Received change band request with invalid band value */
7286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307287 "%s: Invalid band value %u", __func__, ui_band);
7288 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 }
7290
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307291 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7292 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7293 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7294 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007296 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007297 band, pHddCtx->cfg_ini->nBandCapability);
7298 return -EIO;
7299 }
7300
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7302 {
7303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7304 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007305 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007306 return -EIO;
7307 }
7308
7309 if (currBand != band)
7310 {
7311 /* Change band request received.
7312 * Abort pending scan requests, flush the existing scan results,
7313 * and change the band capability
7314 */
7315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7316 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007317 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007318
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307319 /* We need to change the band and flush the scan results here itself
7320 * as we may get timeout for disconnection in which we will return
7321 * with out doing any of these
7322 */
7323 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7324 {
7325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7326 "%s: failed to set the band value to %u ",
7327 __func__, band);
7328 return -EINVAL;
7329 }
7330 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7331 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7332 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7333 sme_FilterScanResults(hHal, pAdapter->sessionId);
7334
7335 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307336 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7337 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 {
7339 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7340 eHalStatus status = eHAL_STATUS_SUCCESS;
7341 long lrc;
7342
7343 /* STA already connected on current band, So issue disconnect first,
7344 * then change the band*/
7345
7346 hddLog(VOS_TRACE_LEVEL_INFO,
7347 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7348 __func__, csrGetCurrentBand(hHal), band);
7349
7350 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7351 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7352
7353 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7354 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7355
Jeff Johnson43971f52012-07-17 12:26:56 -07007356 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007357 {
7358 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007359 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 __func__, (int)status );
7361 return -EINVAL;
7362 }
7363
7364 lrc = wait_for_completion_interruptible_timeout(
7365 &pAdapter->disconnect_comp_var,
7366 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7367
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307368 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007369
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007370 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007371 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007372
7373 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7374 }
7375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007376 }
7377 return 0;
7378}
7379
Atul Mittal54378cb2014-04-02 16:51:50 +05307380int hdd_setBand_helper(struct net_device *dev, const char *command)
7381{
7382 u8 band;
7383
7384 /*convert the band value from ascii to integer*/
7385 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7386
7387 return hdd_setBand(dev, band);
7388
7389}
7390
Jeff Johnson295189b2012-06-20 16:38:30 -07007391static int iw_set_band_config(struct net_device *dev,
7392 struct iw_request_info *info,
7393 union iwreq_data *wrqu, char *extra)
7394{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007395 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307396 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007397
Arif Hussain0273cba2014-01-07 20:58:29 -08007398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007399
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007400 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7401 {
7402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7403 "%s:LOGP in Progress. Ignore!!!", __func__);
7404 return -EBUSY;
7405 }
7406
Atul Mittal54378cb2014-04-02 16:51:50 +05307407 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007408}
7409
7410static int iw_set_power_params_priv(struct net_device *dev,
7411 struct iw_request_info *info,
7412 union iwreq_data *wrqu, char *extra)
7413{
Arif Hussain0273cba2014-01-07 20:58:29 -08007414 int ret;
7415 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7417 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007418 /* ODD number is used for set, copy data using copy_from_user */
7419 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7420 wrqu->data.length);
7421 if (NULL == ptr)
7422 {
7423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7424 "mem_alloc_copy_from_user_helper fail");
7425 return -ENOMEM;
7426 }
7427
7428 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7429 kfree(ptr);
7430 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007431}
7432
7433
7434
7435/*string based input*/
7436VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7437 union iwreq_data *wrqu, char *extra, int nOffset)
7438{
7439 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7440 tSirSetPowerParamsReq powerRequest;
7441 char *ptr;
7442 v_U8_t ucType;
7443 v_U32_t uTotalSize, uValue;
7444 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7445
7446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7447 "Power Params data len %d data %s",
7448 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007449 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007450
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007451 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7452 {
7453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7454 "%s:LOGP in Progress. Ignore!!!", __func__);
7455 return -EBUSY;
7456 }
7457
Jeff Johnson295189b2012-06-20 16:38:30 -07007458 if (wrqu->data.length <= nOffset )
7459 {
7460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7461 return VOS_STATUS_E_FAILURE;
7462 }
7463
7464 uTotalSize = wrqu->data.length - nOffset;
7465
7466 /*-----------------------------------------------------------------------
7467 Input is string based and expected to be like this:
7468
7469 <param_type> <param_value> <param_type> <param_value> ...
7470
7471 e.g:
7472 1 2 2 3 3 0 4 1 5 1
7473
7474 e.g. setting just a few:
7475 1 2 4 1
7476
7477 parameter types:
7478 -----------------------------
7479 1 - Ignore DTIM
7480 2 - Listen Interval
7481 3 - Broadcast Multicas Filter
7482 4 - Beacon Early Termination
7483 5 - Beacon Early Termination Interval
7484 -----------------------------------------------------------------------*/
7485 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7486 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7487 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7488 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7489 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7490
Arif Hussain7adce1b2013-11-11 22:59:34 -08007491 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007492
7493 while ( uTotalSize )
7494 {
Wilson Yang6f971452013-10-08 15:00:00 -07007495 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7496 {
7497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7498 "Invalid input parameter type %s",ptr);
7499 return VOS_STATUS_E_FAILURE;
7500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007501
7502 uTotalSize -= nOffset;
7503
7504 if (!uTotalSize)
7505 {
7506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007507 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 ucType, nOffset);
7509 return VOS_STATUS_E_FAILURE;
7510 }
7511
7512 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007513
Jeff Johnson02797792013-10-26 19:17:13 -07007514 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007515 {
7516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7517 "Invalid input parameter value %s",ptr);
7518 return VOS_STATUS_E_FAILURE;
7519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007520
7521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7522 "Power request parameter %d value %d offset %d",
7523 ucType, uValue, nOffset);
7524
7525 switch (ucType)
7526 {
7527 case eSIR_IGNORE_DTIM:
7528 powerRequest.uIgnoreDTIM = uValue;
7529 break;
7530 case eSIR_LISTEN_INTERVAL:
7531 powerRequest.uListenInterval = uValue;
7532 break;
7533 case eSIR_MCAST_BCAST_FILTER:
7534 powerRequest.uBcastMcastFilter = uValue;
7535 break;
7536 case eSIR_ENABLE_BET:
7537 powerRequest.uEnableBET = uValue;
7538 break;
7539 case eSIR_BET_INTERVAL:
7540 powerRequest.uBETInterval = uValue;
7541 break;
7542 default:
7543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007544 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 ucType, uValue, nOffset);
7546 return VOS_STATUS_E_FAILURE;
7547 }
7548
7549 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7551 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007552 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007554 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007555 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007556 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7557 {
7558 uTotalSize = 0;
7559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007560
7561 }/*Go for as long as we have a valid string*/
7562
7563 /* put the device into full power*/
7564 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7565
7566 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007567 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007568
7569 /* put the device back to power save*/
7570 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7571
7572 return VOS_STATUS_SUCCESS;
7573}/*iw_set_power_params*/
7574
7575
7576// Define the Wireless Extensions to the Linux Network Device structure
7577// A number of these routines are NULL (meaning they are not implemented.)
7578
7579static const iw_handler we_handler[] =
7580{
7581 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7582 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7583 (iw_handler) NULL, /* SIOCSIWNWID */
7584 (iw_handler) NULL, /* SIOCGIWNWID */
7585 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7586 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7587 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7588 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7589 (iw_handler) NULL, /* SIOCSIWSENS */
7590 (iw_handler) NULL, /* SIOCGIWSENS */
7591 (iw_handler) NULL, /* SIOCSIWRANGE */
7592 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7593 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7594 (iw_handler) NULL, /* SIOCGIWPRIV */
7595 (iw_handler) NULL, /* SIOCSIWSTATS */
7596 (iw_handler) NULL, /* SIOCGIWSTATS */
7597 iw_handler_set_spy, /* SIOCSIWSPY */
7598 iw_handler_get_spy, /* SIOCGIWSPY */
7599 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7600 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7601 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7602 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7603 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7604 (iw_handler) NULL, /* SIOCGIWAPLIST */
7605 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7606 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7607 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7608 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7609 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7610 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7611 (iw_handler) NULL, /* -- hole -- */
7612 (iw_handler) NULL, /* -- hole -- */
7613 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7614 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7615 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7616 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7617 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7618 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7619 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7620 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7621 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7622 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7623 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7624 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7625 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7626 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7627 (iw_handler) NULL, /* -- hole -- */
7628 (iw_handler) NULL, /* -- hole -- */
7629 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7630 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7631 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7632 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7633 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7634 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7635 (iw_handler) NULL, /* SIOCSIWPMKSA */
7636};
7637
7638static const iw_handler we_private[] = {
7639
7640 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7641 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7642 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7643 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7644 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7645 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7646 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7647 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7648 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7649 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007650#ifdef FEATURE_OEM_DATA_SUPPORT
7651 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7652 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7653#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007654
7655#ifdef FEATURE_WLAN_WAPI
7656 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7657 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7658 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7659 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7660 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7661 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7662#endif /* FEATURE_WLAN_WAPI */
7663#ifdef WLAN_FEATURE_VOWIFI_11R
7664 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7665#endif
7666 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7667 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7668 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7669#ifdef WLAN_FEATURE_PACKET_FILTERING
7670 ,
7671 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7672#endif
7673#ifdef FEATURE_WLAN_SCAN_PNO
7674 ,
7675 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7676#endif
7677 ,
7678 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7679 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7680 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7681 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007682 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007683};
7684
7685/*Maximum command length can be only 15 */
7686static const struct iw_priv_args we_private_args[] = {
7687
7688 /* handlers for main ioctl */
7689 { WLAN_PRIV_SET_INT_GET_NONE,
7690 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7691 0,
7692 "" },
7693
7694 /* handlers for sub-ioctl */
7695 { WE_SET_11D_STATE,
7696 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7697 0,
7698 "set11Dstate" },
7699
7700 { WE_WOWL,
7701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7702 0,
7703 "wowl" },
7704
7705 { WE_SET_POWER,
7706 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7707 0,
7708 "setPower" },
7709
7710 { WE_SET_MAX_ASSOC,
7711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7712 0,
7713 "setMaxAssoc" },
7714
7715 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7717 0,
7718 "setAutoChannel" },
7719
7720 { WE_SET_DATA_INACTIVITY_TO,
7721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7722 0,
7723 "inactivityTO" },
7724
7725 { WE_SET_MAX_TX_POWER,
7726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7727 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007728 "setMaxTxPower" },
7729
7730 { WE_SET_MAX_TX_POWER_2_4,
7731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7732 0,
7733 "setTxMaxPower2G" },
7734
7735 { WE_SET_MAX_TX_POWER_5_0,
7736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7737 0,
7738 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007739
7740 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7741 * as well to keep same syntax as in SAP. Now onwards, STA
7742 * will support both */
7743 { WE_SET_MAX_TX_POWER,
7744 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7745 0,
7746 "setTxMaxPower" },
7747
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7749 * 1 = enable and 0 = disable */
7750 {
7751 WE_SET_HIGHER_DTIM_TRANSITION,
7752 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7753 0,
7754 "setHDtimTransn" },
7755
7756 { WE_SET_TM_LEVEL,
7757 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007758 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 "setTmLevel" },
7760
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307761 { WE_ENABLE_STRICT_FCC_REG,
7762 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7763 0,
7764 "setStrictFCCreg" },
7765
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007766 { WE_SET_DEBUG_LOG,
7767 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7768 0, "setDbgLvl" },
7769
Jeff Johnson295189b2012-06-20 16:38:30 -07007770 /* handlers for main ioctl */
7771 { WLAN_PRIV_SET_NONE_GET_INT,
7772 0,
7773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7774 "" },
7775
7776 /* handlers for sub-ioctl */
7777 { WE_GET_11D_STATE,
7778 0,
7779 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7780 "get11Dstate" },
7781
7782 { WE_IBSS_STATUS,
7783 0,
7784 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7785 "getAdhocStatus" },
7786
7787 { WE_PMC_STATE,
7788 0,
7789 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7790 "pmcState" },
7791
7792 { WE_GET_WLAN_DBG,
7793 0,
7794 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7795 "getwlandbg" },
7796
7797 { WE_MODULE_DOWN_IND,
7798 0,
7799 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7800 "moduleDownInd" },
7801
7802 { WE_GET_MAX_ASSOC,
7803 0,
7804 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7805 "getMaxAssoc" },
7806
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 { WE_GET_WDI_DBG,
7808 0,
7809 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7810 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007811
7812 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7813 0,
7814 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7815 "getAutoChannel" },
7816
7817 { WE_GET_CONCURRENCY_MODE,
7818 0,
7819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7820 "getconcurrency" },
7821
7822 /* handlers for main ioctl */
7823 { WLAN_PRIV_SET_CHAR_GET_NONE,
7824 IW_PRIV_TYPE_CHAR| 512,
7825 0,
7826 "" },
7827
7828 /* handlers for sub-ioctl */
7829 { WE_WOWL_ADD_PTRN,
7830 IW_PRIV_TYPE_CHAR| 512,
7831 0,
7832 "wowlAddPtrn" },
7833
7834 { WE_WOWL_DEL_PTRN,
7835 IW_PRIV_TYPE_CHAR| 512,
7836 0,
7837 "wowlDelPtrn" },
7838
7839#if defined WLAN_FEATURE_VOWIFI
7840 /* handlers for sub-ioctl */
7841 { WE_NEIGHBOR_REPORT_REQUEST,
7842 IW_PRIV_TYPE_CHAR | 512,
7843 0,
7844 "neighbor" },
7845#endif
7846 { WE_SET_AP_WPS_IE,
7847 IW_PRIV_TYPE_CHAR| 512,
7848 0,
7849 "set_ap_wps_ie" },
7850
7851 { WE_SET_CONFIG,
7852 IW_PRIV_TYPE_CHAR| 512,
7853 0,
7854 "setConfig" },
7855
7856 /* handlers for main ioctl */
7857 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7858 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7859 0,
7860 "" },
7861
7862 /* handlers for sub-ioctl */
7863 { WE_SET_WLAN_DBG,
7864 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7865 0,
7866 "setwlandbg" },
7867
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 { WE_SET_WDI_DBG,
7869 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7870 0,
7871 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007872
7873 { WE_SET_SAP_CHANNELS,
7874 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7875 0,
7876 "setsapchannels" },
7877
7878 /* handlers for main ioctl */
7879 { WLAN_PRIV_GET_CHAR_SET_NONE,
7880 0,
7881 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7882 "" },
7883
7884 /* handlers for sub-ioctl */
7885 { WE_WLAN_VERSION,
7886 0,
7887 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7888 "version" },
7889 { WE_GET_STATS,
7890 0,
7891 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7892 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307893 { WE_GET_STATES,
7894 0,
7895 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7896 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007897 { WE_GET_CFG,
7898 0,
7899 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7900 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007901#ifdef WLAN_FEATURE_11AC
7902 { WE_GET_RSSI,
7903 0,
7904 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7905 "getRSSI" },
7906#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007907#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007908 { WE_GET_ROAM_RSSI,
7909 0,
7910 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7911 "getRoamRSSI" },
7912#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 { WE_GET_WMM_STATUS,
7914 0,
7915 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7916 "getWmmStatus" },
7917 {
7918 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307919 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7921 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007922#ifdef FEATURE_WLAN_TDLS
7923 {
7924 WE_GET_TDLS_PEERS,
7925 0,
7926 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7927 "getTdlsPeers" },
7928#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007929#ifdef WLAN_FEATURE_11W
7930 {
7931 WE_GET_11W_INFO,
7932 0,
7933 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7934 "getPMFInfo" },
7935#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 /* handlers for main ioctl */
7937 { WLAN_PRIV_SET_NONE_GET_NONE,
7938 0,
7939 0,
7940 "" },
7941
7942 /* handlers for sub-ioctl */
7943 { WE_CLEAR_STATS,
7944 0,
7945 0,
7946 "clearStats" },
7947 { WE_INIT_AP,
7948 0,
7949 0,
7950 "initAP" },
7951 { WE_STOP_AP,
7952 0,
7953 0,
7954 "exitAP" },
7955 { WE_ENABLE_AMP,
7956 0,
7957 0,
7958 "enableAMP" },
7959 { WE_DISABLE_AMP,
7960 0,
7961 0,
7962 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007963 { WE_ENABLE_DXE_STALL_DETECT,
7964 0,
7965 0,
7966 "dxeStallDetect" },
7967 { WE_DISPLAY_DXE_SNAP_SHOT,
7968 0,
7969 0,
7970 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307971 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7972 0,
7973 0,
7974 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007975 {
7976 WE_SET_REASSOC_TRIGGER,
7977 0,
7978 0,
7979 "reassoc" },
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307980 {
7981 WE_STOP_OBSS_SCAN,
7982 0,
7983 0,
7984 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007985
7986 /* handlers for main ioctl */
7987 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7988 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7989 0,
7990 "" },
7991
7992 /* handlers for sub-ioctl */
7993 { WE_LOG_DUMP_CMD,
7994 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7995 0,
7996 "dump" },
7997
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007998 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307999 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8000 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8001 0,
8002 "setdumplog" },
8003
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008004 { WE_MTRACE_DUMP_CMD,
8005 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8006 0,
8007 "dumplog" },
8008
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008009 /* handlers for sub ioctl */
8010 {
8011 WE_MCC_CONFIG_CREDENTIAL,
8012 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8013 0,
8014 "setMccCrdnl" },
8015
8016 /* handlers for sub ioctl */
8017 {
8018 WE_MCC_CONFIG_PARAMS,
8019 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8020 0,
8021 "setMccConfig" },
8022
Chilam NG571c65a2013-01-19 12:27:36 +05308023#ifdef FEATURE_WLAN_TDLS
8024 /* handlers for sub ioctl */
8025 {
8026 WE_TDLS_CONFIG_PARAMS,
8027 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8028 0,
8029 "setTdlsConfig" },
8030#endif
8031
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 /* handlers for main ioctl */
8033 { WLAN_PRIV_ADD_TSPEC,
8034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8035 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8036 "addTspec" },
8037
8038 /* handlers for main ioctl */
8039 { WLAN_PRIV_DEL_TSPEC,
8040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8042 "delTspec" },
8043
8044 /* handlers for main ioctl */
8045 { WLAN_PRIV_GET_TSPEC,
8046 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8047 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8048 "getTspec" },
8049
Jeff Johnsone7245742012-09-05 17:12:55 -07008050#ifdef FEATURE_OEM_DATA_SUPPORT
8051 /* handlers for main ioctl - OEM DATA */
8052 {
8053 WLAN_PRIV_SET_OEM_DATA_REQ,
8054 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8055 0,
8056 "set_oem_data_req" },
8057
8058 /* handlers for main ioctl - OEM DATA */
8059 {
8060 WLAN_PRIV_GET_OEM_DATA_RSP,
8061 0,
8062 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8063 "get_oem_data_rsp" },
8064#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008065
8066#ifdef FEATURE_WLAN_WAPI
8067 /* handlers for main ioctl SET_WAPI_MODE */
8068 { WLAN_PRIV_SET_WAPI_MODE,
8069 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8070 0,
8071 "SET_WAPI_MODE" },
8072
8073 /* handlers for main ioctl GET_WAPI_MODE */
8074 { WLAN_PRIV_GET_WAPI_MODE,
8075 0,
8076 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8077 "GET_WAPI_MODE" },
8078
8079 /* handlers for main ioctl SET_ASSOC_INFO */
8080 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
8081 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
8082 0,
8083 "SET_WAPI_ASSOC" },
8084
8085 /* handlers for main ioctl SET_WAPI_KEY */
8086 { WLAN_PRIV_SET_WAPI_KEY,
8087 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8088 0,
8089 "SET_WAPI_KEY" },
8090
8091 /* handlers for main ioctl SET_WAPI_BKID */
8092 { WLAN_PRIV_SET_WAPI_BKID,
8093 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8094 0,
8095 "SET_WAPI_BKID" },
8096
8097 /* handlers for main ioctl GET_WAPI_BKID */
8098 { WLAN_PRIV_GET_WAPI_BKID,
8099 0,
8100 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8101 "GET_WAPI_BKID" },
8102#endif /* FEATURE_WLAN_WAPI */
8103
8104 /* handlers for main ioctl - host offload */
8105 {
8106 WLAN_PRIV_SET_HOST_OFFLOAD,
8107 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8108 0,
8109 "setHostOffload" },
8110
8111 {
8112 WLAN_GET_WLAN_STATISTICS,
8113 0,
8114 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8115 "getWlanStats" },
8116
8117 {
8118 WLAN_SET_KEEPALIVE_PARAMS,
8119 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8120 0,
8121 "setKeepAlive" },
8122#ifdef WLAN_FEATURE_PACKET_FILTERING
8123 {
8124 WLAN_SET_PACKET_FILTER_PARAMS,
8125 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8126 0,
8127 "setPktFilter" },
8128#endif
8129#ifdef FEATURE_WLAN_SCAN_PNO
8130 {
8131 WLAN_SET_PNO,
8132 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8133 0,
8134 "setpno" },
8135#endif
8136 {
8137 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308138 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 0,
8140 "SETBAND" },
8141 /* handlers for dynamic MC BC ioctl */
8142 {
8143 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008144 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 0,
8146 "setMCBCFilter" },
8147 {
8148 WLAN_PRIV_CLEAR_MCBC_FILTER,
8149 0,
8150 0,
8151 "clearMCBCFilter" },
8152 {
8153 WLAN_SET_POWER_PARAMS,
8154 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8155 0,
8156 "setpowerparams" },
8157 {
8158 WLAN_GET_LINK_SPEED,
8159 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308160 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008161};
8162
8163
8164
8165const struct iw_handler_def we_handler_def = {
8166 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8167 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8168 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8169
8170 .standard = (iw_handler *)we_handler,
8171 .private = (iw_handler *)we_private,
8172 .private_args = we_private_args,
8173 .get_wireless_stats = get_wireless_stats,
8174};
8175
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008176int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8177{
8178 v_U32_t cmd = 288; //Command to RIVA
8179 hdd_context_t *pHddCtx = NULL;
8180 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8181 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8182 /*
8183 *configMccParam : specify the bit which needs to be modified
8184 *allowed to update based on wlan_qcom_cfg.ini
8185 * configuration
8186 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8187 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8188 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8189 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8190 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8191 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8192 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8193 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8194 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8195 * Bit 9 : Reserved
8196 */
8197 switch (arg1)
8198 {
8199 //Update MCC SCHEDULE_TIME_SLICE parameter
8200 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8201 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8202 {
8203 if((arg2 >= 5) && (arg2 <= 20))
8204 {
8205 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8206 }
8207 else
8208 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008209 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008210 return 0;
8211 }
8212 }
8213 break;
8214
8215 //Update MCC MAX_NULL_SEND_TIME parameter
8216 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8217 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8218 {
8219 if((arg2 >= 1) && (arg2 <= 10))
8220 {
8221 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8222 }
8223 else
8224 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008225 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008226 return 0;
8227 }
8228 }
8229 break;
8230
8231 //Update MCC TX_EARLY_STOP_TIME parameter
8232 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8233 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8234 {
8235 if((arg2 >= 1) && (arg2 <= 10))
8236 {
8237 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8238 }
8239 else
8240 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008241 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008242 return 0;
8243 }
8244 }
8245 break;
8246
8247 //Update MCC RX_DRAIN_TIME parameter
8248 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8249 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8250 {
8251 if((arg2 >= 1) && (arg2 <= 10))
8252 {
8253 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8254 }
8255 else
8256 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008257 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008258 return 0;
8259 }
8260 }
8261 break;
8262
8263 //Update MCC CHANNEL_SWITCH_TIME parameter
8264 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8265 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8266 {
8267 if((arg2 >= 1) && (arg2 <= 20))
8268 {
8269 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8270 }
8271 else
8272 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008273 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008274 return 0;
8275 }
8276 }
8277 break;
8278
8279 //Update MCC MIN_CHANNEL_TIME parameter
8280 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8281 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8282 {
8283 if((arg2 >= 5) && (arg2 <= 20))
8284 {
8285 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8286 }
8287 else
8288 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008289 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008290 return 0;
8291 }
8292 }
8293 break;
8294
8295 //Update MCC PARK_BEFORE_TBTT parameter
8296 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8297 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8298 {
8299 if((arg2 >= 1) && (arg2 <= 5))
8300 {
8301 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8302 }
8303 else
8304 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008305 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008306 return 0;
8307 }
8308 }
8309 break;
8310
8311 //Update MCC MIN_AFTER_DTIM parameter
8312 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8313 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8314 {
8315 if((arg2 >= 5) && (arg2 <= 15))
8316 {
8317 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8318 }
8319 else
8320 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008321 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008322 return 0;
8323 }
8324 }
8325 break;
8326
8327 //Update MCC TOO_CLOSE_MARGIN parameter
8328 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8329 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8330 {
8331 if((arg2 >= 1) && (arg2 <= 3))
8332 {
8333 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8334 }
8335 else
8336 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008337 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008338 return 0;
8339 }
8340 }
8341 break;
8342
8343 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008344 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008345 __FUNCTION__,arg1);
8346 break;
8347 }
8348 return 0;
8349}
8350
Jeff Johnson295189b2012-06-20 16:38:30 -07008351int hdd_set_wext(hdd_adapter_t *pAdapter)
8352{
8353 hdd_wext_state_t *pwextBuf;
8354 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008355 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008356
8357 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8358
8359 // Now configure the roaming profile links. To SSID and bssid.
8360 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8361 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8362
8363 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8364 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8365
8366 /*Set the numOfChannels to zero to scan all the channels*/
8367 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8368 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8369
8370 /* Default is no encryption */
8371 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8372 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8373
8374 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8375 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8376
8377 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8378
8379 /* Default is no authentication */
8380 pwextBuf->roamProfile.AuthType.numEntries = 1;
8381 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8382
8383 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8384 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8385
8386 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008387 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008388
8389 hdd_clearRoamProfileIe(pAdapter);
8390
8391 return VOS_STATUS_SUCCESS;
8392
8393 }
8394
8395int hdd_register_wext(struct net_device *dev)
8396 {
8397 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8398 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8399 VOS_STATUS status;
8400
8401 ENTER();
8402
8403 // Zero the memory. This zeros the profile structure.
8404 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8405
8406 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8407
8408
8409 status = hdd_set_wext(pAdapter);
8410
8411 if(!VOS_IS_STATUS_SUCCESS(status)) {
8412
Arif Hussain6d2a3322013-11-17 19:50:10 -08008413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 return eHAL_STATUS_FAILURE;
8415 }
8416
8417 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8418 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 return eHAL_STATUS_FAILURE;
8421 }
8422
8423 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8424 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 return eHAL_STATUS_FAILURE;
8427 }
8428
8429 // Register as a wireless device
8430 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8431
8432 EXIT();
8433 return 0;
8434}
8435
8436int hdd_UnregisterWext(struct net_device *dev)
8437{
8438#if 0
8439 hdd_wext_state_t *wextBuf;
8440 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8441
8442 ENTER();
8443 // Set up the pointer to the Wireless Extensions state structure
8444 wextBuf = pAdapter->pWextState;
8445
8446 // De-allocate the Wireless Extensions state structure
8447 kfree(wextBuf);
8448
8449 // Clear out the pointer to the Wireless Extensions state structure
8450 pAdapter->pWextState = NULL;
8451
8452 EXIT();
8453#endif
8454 dev->wireless_handlers = NULL;
8455 return 0;
8456}
8457
8458