blob: aa711771f7f37dc83aae18b9639731b04408ccf2 [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
Girish Gowli488ef492014-06-12 18:44:33 +0530414// Function to handle and get compatible struct iw_point passed to ioctl.
415int hdd_priv_get_data(struct iw_point *p_priv_data,
416 union iwreq_data *wrqu)
417{
418 if ((NULL == p_priv_data) || (NULL == wrqu))
419 {
420 return -EINVAL;
421 }
422
423#ifdef CONFIG_COMPAT
424 if (is_compat_task())
425 {
426 struct compat_iw_point *p_compat_priv_data;
427
428 // Compat task: typecast to campat structure and copy the members.
429 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
430
431 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
432 p_priv_data->length = p_compat_priv_data->length;
433 p_priv_data->flags = p_compat_priv_data->flags;
434 }//if(is_compat_task())
435 else
436 {
437#endif //#ifdef CONFIG_COMPAT
438
439 // Non compat task: directly copy the structure.
440 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
441
442#ifdef CONFIG_COMPAT
443 }//else of - if(is_compat_task())
444#endif //#ifdef CONFIG_COMPAT
445
446 return 0;
447}
448
Arif Hussain0273cba2014-01-07 20:58:29 -0800449/**---------------------------------------------------------------------------
450
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 \brief hdd_wlan_get_version() -
452
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800453 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700454
455 \param - pAdapter Pointer to the adapter.
456 wrqu - Pointer to IOCTL REQUEST Data.
457 extra - Pointer to char
458
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800459 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700460
461 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800462void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
463 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700464{
465 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800466 tSirVersionString wcnss_SW_version;
467 tSirVersionString wcnss_HW_version;
468 char *pSWversion;
469 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700471
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800472 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
473 sizeof(wcnss_SW_version));
474 if (VOS_IS_STATUS_SUCCESS(status))
475 {
476 pSWversion = wcnss_SW_version;
477 }
478 else
479 {
480 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 }
482
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800483 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
484 sizeof(wcnss_HW_version));
485 if (VOS_IS_STATUS_SUCCESS(status))
486 {
487 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800489 else
490 {
491 pHWversion = "Unknown";
492 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700494 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800495 "Host SW:%s, FW:%s, HW:%s",
496 QWLAN_VERSIONSTR,
497 pSWversion,
498 pHWversion);
499
500 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700501}
502
Jeff Johnson295189b2012-06-20 16:38:30 -0700503int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
504{
505 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
506 v_U32_t threshold = 0,status = 0;
507
508 ENTER();
509
Agarwal Ashish971c2882013-10-30 20:11:12 +0530510 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
511 {
512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 "%s:LOGP in Progress. Ignore!!!",__func__);
514 return status;
515 }
516
517 if ( eHAL_STATUS_SUCCESS !=
518 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
519 {
c_hpothub8245442013-11-20 23:41:09 +0530520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
521 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 return -EIO;
523 }
524 wrqu->rts.value = threshold;
525
526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800527 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700528
529 EXIT();
530
531 return 0;
532}
533
534int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
535{
536 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
537 v_U32_t threshold = 0,status = 0;
538
539 ENTER();
540
Agarwal Ashish971c2882013-10-30 20:11:12 +0530541 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
542 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
544 "%s:LOGP in Progress. Ignore!!!",__func__);
545 return status;
546 }
547
548 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
549 != eHAL_STATUS_SUCCESS )
550 {
c_hpothub8245442013-11-20 23:41:09 +0530551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
552 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 return -EIO;
554 }
555 wrqu->frag.value = threshold;
556
557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800558 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700559
560 EXIT();
561
562 return 0;
563}
564
565int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
566{
Jeff Johnsone7245742012-09-05 17:12:55 -0700567 int i;
568 if (channel > 0)
569 {
570 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
571 {
572 if (channel == freq_chan_map[i].chan)
573 {
574 *pfreq = freq_chan_map[i].freq;
575 return 1;
576 }
577 }
578 }
579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800580 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700581 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700582}
583
584static v_BOOL_t
585hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
586{
587 v_BOOL_t rsnType = VOS_FALSE;
588 // is the authType supported?
589 switch (authType)
590 {
591 case eCSR_AUTH_TYPE_NONE: //never used
592 rsnType = eANI_BOOLEAN_FALSE;
593 break;
594 // MAC layer authentication types
595 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
596 rsnType = eANI_BOOLEAN_FALSE;
597 break;
598 case eCSR_AUTH_TYPE_SHARED_KEY:
599 rsnType = eANI_BOOLEAN_FALSE;
600 break;
601 case eCSR_AUTH_TYPE_AUTOSWITCH:
602 rsnType = eANI_BOOLEAN_FALSE;
603 break;
604
605 // Upper layer authentication types
606 case eCSR_AUTH_TYPE_WPA:
607 rsnType = eANI_BOOLEAN_TRUE;
608 break;
609 case eCSR_AUTH_TYPE_WPA_PSK:
610 rsnType = eANI_BOOLEAN_TRUE;
611 break;
612 case eCSR_AUTH_TYPE_WPA_NONE:
613 rsnType = eANI_BOOLEAN_TRUE;
614 break;
615#ifdef WLAN_FEATURE_VOWIFI_11R
616 case eCSR_AUTH_TYPE_FT_RSN:
617#endif
618 case eCSR_AUTH_TYPE_RSN:
619 rsnType = eANI_BOOLEAN_TRUE;
620 break;
621#ifdef WLAN_FEATURE_VOWIFI_11R
622 case eCSR_AUTH_TYPE_FT_RSN_PSK:
623#endif
624 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700625#ifdef WLAN_FEATURE_11W
626 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
627#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 rsnType = eANI_BOOLEAN_TRUE;
629 break;
630 //case eCSR_AUTH_TYPE_FAILED:
631 case eCSR_AUTH_TYPE_UNKNOWN:
632 rsnType = eANI_BOOLEAN_FALSE;
633 break;
634 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800635 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
636 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 rsnType = eANI_BOOLEAN_FALSE;
638 break;
639 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800640 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700641 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 return rsnType;
643}
644
645static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
646{
647 struct statsContext *pStatsContext;
648 hdd_adapter_t *pAdapter;
649
650 if (ioctl_debug)
651 {
652 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700653 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 }
655
656 if (NULL == pContext)
657 {
658 hddLog(VOS_TRACE_LEVEL_ERROR,
659 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700660 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 return;
662 }
663
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 pStatsContext = pContext;
665 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800666
667 /* there is a race condition that exists between this callback
668 function and the caller since the caller could time out either
669 before or while this code is executing. we use a spinlock to
670 serialize these actions */
671 spin_lock(&hdd_context_lock);
672
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
674 {
675 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800676 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 hddLog(VOS_TRACE_LEVEL_WARN,
678 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700679 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 if (ioctl_debug)
681 {
682 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700683 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 }
685 return;
686 }
687
Jeff Johnson72a40512013-12-19 10:14:15 -0800688 /* context is valid so caller is still waiting */
689
690 /* paranoia: invalidate the magic */
691 pStatsContext->magic = 0;
692
693 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 pAdapter->rssi = rssi;
695
Jeff Johnson72a40512013-12-19 10:14:15 -0800696 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800698
699 /* serialization is complete */
700 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701}
702
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530703static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
704{
705 struct statsContext *pStatsContext;
706 hdd_adapter_t *pAdapter;
707
708 if (ioctl_debug)
709 {
710 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
711 __func__, (int)snr, (int)staId, pContext);
712 }
713
714 if (NULL == pContext)
715 {
716 hddLog(VOS_TRACE_LEVEL_ERROR,
717 "%s: Bad param, pContext [%p]",
718 __func__, pContext);
719 return;
720 }
721
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530722 pStatsContext = pContext;
723 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800724
725 /* there is a race condition that exists between this callback
726 function and the caller since the caller could time out either
727 before or while this code is executing. we use a spinlock to
728 serialize these actions */
729 spin_lock(&hdd_context_lock);
730
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530731 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
732 {
733 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800734 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530735 hddLog(VOS_TRACE_LEVEL_WARN,
736 "%s: Invalid context, pAdapter [%p] magic [%08x]",
737 __func__, pAdapter, pStatsContext->magic);
738 if (ioctl_debug)
739 {
740 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
741 __func__, pAdapter, pStatsContext->magic);
742 }
743 return;
744 }
745
Jeff Johnson72a40512013-12-19 10:14:15 -0800746 /* context is valid so caller is still waiting */
747
748 /* paranoia: invalidate the magic */
749 pStatsContext->magic = 0;
750
751 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530752 pAdapter->snr = snr;
753
Jeff Johnson72a40512013-12-19 10:14:15 -0800754 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530755 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800756
757 /* serialization is complete */
758 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530759}
760
Jeff Johnson295189b2012-06-20 16:38:30 -0700761VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
762{
763 struct statsContext context;
764 hdd_context_t *pHddCtx;
765 hdd_station_ctx_t *pHddStaCtx;
766 eHalStatus hstatus;
767 long lrc;
768
769 if (NULL == pAdapter)
770 {
771 hddLog(VOS_TRACE_LEVEL_WARN,
772 "%s: Invalid context, pAdapter", __func__);
773 return VOS_STATUS_E_FAULT;
774 }
775 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
776 {
777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
778 /* return a cached value */
779 *rssi_value = pAdapter->rssi;
780 return VOS_STATUS_SUCCESS;
781 }
782
783 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
784 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
785
786 init_completion(&context.completion);
787 context.pAdapter = pAdapter;
788 context.magic = RSSI_CONTEXT_MAGIC;
789
790 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
791 pHddStaCtx->conn_info.staId[ 0 ],
792 pHddStaCtx->conn_info.bssId,
793 &context, pHddCtx->pvosContext);
794 if (eHAL_STATUS_SUCCESS != hstatus)
795 {
796 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700797 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 /* we'll returned a cached value below */
799 }
800 else
801 {
802 /* request was sent -- wait for the response */
803 lrc = wait_for_completion_interruptible_timeout(&context.completion,
804 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 if (lrc <= 0)
806 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800807 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700808 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 /* we'll now returned a cached value below */
810 }
811 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800812
813 /* either we never sent a request, we sent a request and received a
814 response or we sent a request and timed out. if we never sent a
815 request or if we sent a request and got a response, we want to
816 clear the magic out of paranoia. if we timed out there is a
817 race condition such that the callback function could be
818 executing at the same time we are. of primary concern is if the
819 callback function had already verified the "magic" but had not
820 yet set the completion variable when a timeout occurred. we
821 serialize these activities by invalidating the magic while
822 holding a shared spinlock which will cause us to block if the
823 callback is currently executing */
824 spin_lock(&hdd_context_lock);
825 context.magic = 0;
826 spin_unlock(&hdd_context_lock);
827
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 *rssi_value = pAdapter->rssi;
829
830 return VOS_STATUS_SUCCESS;
831}
832
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530833VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
834{
835 struct statsContext context;
836 hdd_context_t *pHddCtx;
837 hdd_station_ctx_t *pHddStaCtx;
838 eHalStatus hstatus;
839 long lrc;
840 int valid;
841
842 if (NULL == pAdapter)
843 {
844 hddLog(VOS_TRACE_LEVEL_ERROR,
845 "%s: Invalid context, pAdapter", __func__);
846 return VOS_STATUS_E_FAULT;
847 }
848
849 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
850
851 valid = wlan_hdd_validate_context(pHddCtx);
852 if (0 != valid)
853 {
854 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
855 return VOS_STATUS_E_FAULT;
856 }
857
858 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
859 if (NULL == pHddStaCtx)
860 {
861 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
862 return VOS_STATUS_E_FAULT;
863 }
864
865 init_completion(&context.completion);
866 context.pAdapter = pAdapter;
867 context.magic = SNR_CONTEXT_MAGIC;
868
869 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
870 pHddStaCtx->conn_info.staId[ 0 ],
871 pHddStaCtx->conn_info.bssId,
872 &context);
873 if (eHAL_STATUS_SUCCESS != hstatus)
874 {
875 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
876 __func__);
877 /* we'll returned a cached value below */
878 }
879 else
880 {
881 /* request was sent -- wait for the response */
882 lrc = wait_for_completion_interruptible_timeout(&context.completion,
883 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530884 if (lrc <= 0)
885 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800886 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530887 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530888 /* we'll now returned a cached value below */
889 }
890 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800891
892 /* either we never sent a request, we sent a request and received a
893 response or we sent a request and timed out. if we never sent a
894 request or if we sent a request and got a response, we want to
895 clear the magic out of paranoia. if we timed out there is a
896 race condition such that the callback function could be
897 executing at the same time we are. of primary concern is if the
898 callback function had already verified the "magic" but had not
899 yet set the completion variable when a timeout occurred. we
900 serialize these activities by invalidating the magic while
901 holding a shared spinlock which will cause us to block if the
902 callback is currently executing */
903 spin_lock(&hdd_context_lock);
904 context.magic = 0;
905 spin_unlock(&hdd_context_lock);
906
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530907 *snr = pAdapter->snr;
908
909 return VOS_STATUS_SUCCESS;
910}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800911#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800912
913static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
914{
915 struct statsContext *pStatsContext;
916 hdd_adapter_t *pAdapter;
917 if (ioctl_debug)
918 {
919 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
920 __func__, (int)rssi, (int)staId, pContext);
921 }
922
923 if (NULL == pContext)
924 {
925 hddLog(VOS_TRACE_LEVEL_ERROR,
926 "%s: Bad param, pContext [%p]",
927 __func__, pContext);
928 return;
929 }
930
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800931 pStatsContext = pContext;
932 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800933
934 /* there is a race condition that exists between this callback
935 function and the caller since the caller could time out either
936 before or while this code is executing. we use a spinlock to
937 serialize these actions */
938 spin_lock(&hdd_context_lock);
939
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800940 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
941 {
942 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800943 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800944 hddLog(VOS_TRACE_LEVEL_WARN,
945 "%s: Invalid context, pAdapter [%p] magic [%08x]",
946 __func__, pAdapter, pStatsContext->magic);
947 if (ioctl_debug)
948 {
949 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
950 __func__, pAdapter, pStatsContext->magic);
951 }
952 return;
953 }
954
Jeff Johnson72a40512013-12-19 10:14:15 -0800955 /* context is valid so caller is still waiting */
956
957 /* paranoia: invalidate the magic */
958 pStatsContext->magic = 0;
959
960 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800961 pAdapter->rssi = rssi;
962
Jeff Johnson72a40512013-12-19 10:14:15 -0800963 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800964 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800965
966 /* serialization is complete */
967 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800968}
969
970
971
972VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
973{
974 struct statsContext context;
975 hdd_context_t *pHddCtx = NULL;
976 hdd_station_ctx_t *pHddStaCtx = NULL;
977 eHalStatus hstatus;
978 long lrc;
979
980 if (NULL == pAdapter)
981 {
982 hddLog(VOS_TRACE_LEVEL_WARN,
983 "%s: Invalid context, pAdapter", __func__);
984 return VOS_STATUS_E_FAULT;
985 }
986 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
987 {
988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
989 /* return a cached value */
990 *rssi_value = pAdapter->rssi;
991 return VOS_STATUS_SUCCESS;
992 }
993
994 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
995 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
996
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +0530997 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800998 {
999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1000 /* return a cached value */
1001 *rssi_value = 0;
1002 return VOS_STATUS_SUCCESS;
1003 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301004
1005 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1006 {
1007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1008 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1009 *rssi_value = pAdapter->rssi;
1010 return VOS_STATUS_SUCCESS;
1011 }
1012
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001013 init_completion(&context.completion);
1014 context.pAdapter = pAdapter;
1015 context.magic = RSSI_CONTEXT_MAGIC;
1016
1017 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1018 pHddStaCtx->conn_info.staId[ 0 ],
1019 pHddStaCtx->conn_info.bssId,
1020 &context, pHddCtx->pvosContext);
1021 if (eHAL_STATUS_SUCCESS != hstatus)
1022 {
1023 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1024 __func__);
1025 /* we'll returned a cached value below */
1026 }
1027 else
1028 {
1029 /* request was sent -- wait for the response */
1030 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1031 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001032 if (lrc <= 0)
1033 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001034 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001035 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001036 /* we'll now returned a cached value below */
1037 }
1038 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001039
1040 /* either we never sent a request, we sent a request and received a
1041 response or we sent a request and timed out. if we never sent a
1042 request or if we sent a request and got a response, we want to
1043 clear the magic out of paranoia. if we timed out there is a
1044 race condition such that the callback function could be
1045 executing at the same time we are. of primary concern is if the
1046 callback function had already verified the "magic" but had not
1047 yet set the completion variable when a timeout occurred. we
1048 serialize these activities by invalidating the magic while
1049 holding a shared spinlock which will cause us to block if the
1050 callback is currently executing */
1051 spin_lock(&hdd_context_lock);
1052 context.magic = 0;
1053 spin_unlock(&hdd_context_lock);
1054
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001055 *rssi_value = pAdapter->rssi;
1056
1057 return VOS_STATUS_SUCCESS;
1058}
1059#endif
1060
1061
Jeff Johnson295189b2012-06-20 16:38:30 -07001062void hdd_StatisticsCB( void *pStats, void *pContext )
1063{
1064 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1065 hdd_stats_t *pStatsCache = NULL;
1066 hdd_wext_state_t *pWextState;
1067 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1068
1069 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1070 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1071 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1072 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1073 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1074 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1075
1076 if (pAdapter!= NULL)
1077 pStatsCache = &pAdapter->hdd_stats;
1078
1079
1080 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1081 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1082 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1083 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1084 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1085 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1086
1087 if (pStatsCache!=NULL)
1088 {
1089 // and copy the stats into the cache we keep in the adapter instance structure
1090 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1091 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1092 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1093 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1094 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1095 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1096 }
1097
1098 if(pAdapter)
1099 {
1100 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1101 if(pWextState)
1102 {
1103 vos_status = vos_event_set(&pWextState->vosevent);
1104 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1105 {
1106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001107 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 return;
1109 }
1110 }
1111 }
1112}
1113
1114void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1115{
1116 v_CONTEXT_t pVosContext;
1117 hdd_context_t *pHddCtx;
1118 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1119#if 0
1120 hdd_wext_state_t *pWextState;
1121 v_U32_t roamId;
1122#endif
1123
1124 ENTER();
1125
1126 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1127
1128 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1129 if (NULL == pHddCtx)
1130 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001131 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 return;
1133 }
1134#if 0
1135 pWextState = pAdapter->pWextState;
1136#endif
1137
1138 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1139 {
1140 //TODO Verify is this is really used. If yes need to fix it.
1141 hdd_reconnect_all_adapters( pHddCtx );
1142#if 0
1143 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1144 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1145 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1146
1147 if(VOS_STATUS_SUCCESS == vosStatus)
1148 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1149 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1150
1151 sme_RoamConnect(halHandle,
1152 pAdapter->sessionId, &(pWextState->roamProfile),
1153 &roamId);
1154#endif
1155 }
1156
1157 EXIT();
1158
1159}
1160
1161void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1162{
1163 int i = 0;
1164 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1165
1166 /* clear WPA/RSN/WSC IE information in the profile */
1167 pWextState->roamProfile.nWPAReqIELength = 0;
1168 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1169 pWextState->roamProfile.nRSNReqIELength = 0;
1170 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1171
Chet Lanctot186b5732013-03-18 10:26:30 -07001172#ifdef FEATURE_WLAN_WAPI
1173 pWextState->roamProfile.nWAPIReqIELength = 0;
1174 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1175#endif
1176
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001178 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301180 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1182 pWextState->roamProfile.nAddIEAssocLength = 0;
1183
1184 pWextState->roamProfile.EncryptionType.numEntries = 1;
1185 pWextState->roamProfile.EncryptionType.encryptionType[0]
1186 = eCSR_ENCRYPT_TYPE_NONE;
1187
1188 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1189 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1190 = eCSR_ENCRYPT_TYPE_NONE;
1191
1192 pWextState->roamProfile.AuthType.numEntries = 1;
1193 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1194
Chet Lanctot186b5732013-03-18 10:26:30 -07001195#ifdef WLAN_FEATURE_11W
1196 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1197 pWextState->roamProfile.MFPRequired = 0;
1198 pWextState->roamProfile.MFPCapable = 0;
1199#endif
1200
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 pWextState->authKeyMgmt = 0;
1202
1203 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1204 {
1205 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1206 {
1207 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1208 }
1209 }
1210#ifdef FEATURE_WLAN_WAPI
1211 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1212 pAdapter->wapi_info.nWapiMode = 0;
1213#endif
1214
1215 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1216
1217}
1218
1219void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1220{
1221 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001222
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001223 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1224 {
1225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1226 "%s: Invalid pAdapter magic", __func__);
1227 }
1228 else
1229 {
1230 complete(&pAdapter->ula_complete);
1231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001232}
1233
1234VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1235{
1236 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001238 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001239
1240 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1241 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001242 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001243
1244 /*To avoid race condition between the set key and the last EAPOL
1245 packet, notify TL to finish upper layer authentication incase if the
1246 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001247 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001248
1249 if ( vos_status != VOS_STATUS_SUCCESS )
1250 {
1251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1252 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1253 __LINE__, vos_status );
1254 return vos_status;
1255
1256 }
1257
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001258 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301260 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001261 {
1262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301263 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001264 /* we'll still fall through and return success since the
1265 * connection may still get established but is just taking
1266 * too long for us to wait */
1267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 }
1269 return VOS_STATUS_SUCCESS;
1270}
1271
1272v_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)
1273{
1274
1275 int left = ie_len;
1276 v_U8_t *ptr = ie;
1277 v_U8_t elem_id,elem_len;
1278 v_U8_t eid = 0xDD;
1279
1280 if ( NULL == ie || 0 == ie_len )
1281 return NULL;
1282
1283 while(left >= 2)
1284 {
1285 elem_id = ptr[0];
1286 elem_len = ptr[1];
1287 left -= 2;
1288 if(elem_len > left)
1289 {
1290 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001291 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 eid,elem_len,left);
1293 return NULL;
1294 }
1295 if (elem_id == eid)
1296 {
1297 if(memcmp( &ptr[2], oui, oui_size)==0)
1298 return ptr;
1299 }
1300
1301 left -= elem_len;
1302 ptr += (elem_len + 2);
1303 }
1304 return NULL;
1305}
1306
1307static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1308 union iwreq_data *wrqu, char *extra)
1309{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001310 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 /* Do nothing for now */
1312 return 0;
1313}
1314
1315static int iw_get_name(struct net_device *dev,
1316 struct iw_request_info *info,
1317 char *wrqu, char *extra)
1318{
1319
1320 ENTER();
1321 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1322 EXIT();
1323 return 0;
1324}
1325
1326static int iw_set_mode(struct net_device *dev,
1327 struct iw_request_info *info,
1328 union iwreq_data *wrqu, char *extra)
1329{
1330 hdd_wext_state_t *pWextState;
1331 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1332 tCsrRoamProfile *pRoamProfile;
1333 eCsrRoamBssType LastBSSType;
1334 eMib_dot11DesiredBssType connectedBssType;
1335 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001337
1338 ENTER();
1339
1340 if (NULL == pAdapter)
1341 {
1342 hddLog(VOS_TRACE_LEVEL_WARN,
1343 "%s: Invalid context, pAdapter", __func__);
1344 return 0;
1345 }
1346
1347 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1349 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 return 0;
1351 }
1352
1353 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1354 if (pWextState == NULL)
1355 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301356 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 return -EINVAL;
1358 }
1359
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 pRoamProfile = &pWextState->roamProfile;
1362 LastBSSType = pRoamProfile->BSSType;
1363
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301364 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366 switch (wrqu->mode)
1367 {
1368 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301369 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1371 // Set the phymode correctly for IBSS.
1372 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1373 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001374 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 break;
1377 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301378 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 break;
1382 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301383 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1385 break;
1386 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301387 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 return -EOPNOTSUPP;
1389 }
1390
1391 if ( LastBSSType != pRoamProfile->BSSType )
1392 {
1393 //the BSS mode changed
1394 // We need to issue disconnect if connected or in IBSS disconnect state
1395 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1396 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1397 {
1398 VOS_STATUS vosStatus;
1399 // need to issue a disconnect to CSR.
1400 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1401 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1402 pAdapter->sessionId,
1403 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1404 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301405 {
1406 long ret;
1407 ret = wait_for_completion_interruptible_timeout(
1408 &pAdapter->disconnect_comp_var,
1409 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1410 if (ret <= 0)
1411 hddLog(VOS_TRACE_LEVEL_ERROR,
1412 FL("failed wait on disconnect_comp_var %ld"), ret);
1413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 }
1415 }
1416
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 EXIT();
1418 return 0;
1419}
1420
1421
1422static int iw_get_mode(struct net_device *dev,
1423 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301424 union iwreq_data *wrqu,
1425 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001426{
1427
1428 hdd_wext_state_t *pWextState;
1429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1430
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301431 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001432
1433 if (NULL == pAdapter)
1434 {
1435 hddLog(VOS_TRACE_LEVEL_WARN,
1436 "%s: Invalid context, pAdapter", __func__);
1437 return 0;
1438 }
1439
1440 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1442 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 return 0;
1444 }
1445
1446 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1447 if (pWextState == NULL)
1448 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301449 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 return -EINVAL;
1451 }
1452
1453 switch (pWextState->roamProfile.BSSType)
1454 {
1455 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001456 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301457 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 break;
1459 case eCSR_BSS_TYPE_IBSS:
1460 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001461 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301462 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 break;
1464 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001465 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301466 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 break;
1468 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001469 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 break;
1471 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301472
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 return 0;
1474}
1475
1476static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1477 union iwreq_data *wrqu, char *extra)
1478{
1479 v_U32_t numChans = 0;
1480 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1481 v_U32_t indx = 0;
1482 v_U32_t status = 0;
1483
1484 hdd_wext_state_t *pWextState;
1485 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1486 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1487 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1488 tCsrRoamProfile * pRoamProfile;
1489 ENTER();
1490
1491 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1493 return status;
1494 }
1495
1496 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1497
1498 pRoamProfile = &pWextState->roamProfile;
1499
Arif Hussain6d2a3322013-11-17 19:50:10 -08001500 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001501
1502 /* Link is up then return cant set channel*/
1503 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1504 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1505 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001506 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 return -EOPNOTSUPP;
1508 }
1509
1510 /* Settings by Frequency as input */
1511 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1512 (wrqu->freq.m <= (tANI_U32)5.825e8))
1513 {
1514 tANI_U32 freq = wrqu->freq.m / 100000;
1515
1516 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1517 indx++;
1518 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1519 {
1520 return -EINVAL;
1521 }
1522 wrqu->freq.e = 0;
1523 wrqu->freq.m = freq_chan_map[indx].chan;
1524
1525 }
1526
1527 if (wrqu->freq.e == 0)
1528 {
1529 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1530 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1531 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001532 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001533 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1535 return -EINVAL;
1536 }
1537
1538 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1539
1540 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1541 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1543 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 return -EIO;
1545 }
1546
1547 for (indx = 0; indx < numChans; indx++) {
1548 if (wrqu->freq.m == validChan[indx]){
1549 break;
1550 }
1551 }
1552 }
1553 else{
1554
1555 return -EINVAL;
1556 }
1557
1558 if(indx >= numChans)
1559 {
1560 return -EINVAL;
1561 }
1562
1563 /* Set the Operational Channel */
1564 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1565 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1566 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1567
Arif Hussain6d2a3322013-11-17 19:50:10 -08001568 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001569
1570 EXIT();
1571
1572 return status;
1573}
1574
1575static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1576 struct iw_freq *fwrq, char *extra)
1577{
Jeff Johnsone7245742012-09-05 17:12:55 -07001578 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1580 tHalHandle hHal;
1581 hdd_wext_state_t *pWextState;
1582 tCsrRoamProfile * pRoamProfile;
1583 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1584
1585 ENTER();
1586
1587 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1589 return status;
1590 }
1591
1592 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1593 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1594
1595 pRoamProfile = &pWextState->roamProfile;
1596
1597 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1598 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001599 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 {
c_hpothub8245442013-11-20 23:41:09 +05301601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1602 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 return -EIO;
1604 }
1605 else
1606 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001607 status = hdd_wlan_get_freq(channel, &freq);
1608 if( TRUE == status )
1609 {
1610 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1611 * iwlist & iwconfig command shows frequency into proper
1612 * format (2.412 GHz instead of 246.2 MHz)*/
1613 fwrq->m = freq;
1614 fwrq->e = MHZ;
1615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 }
1617 }
1618 else
1619 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001620 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1621 * iwlist & iwconfig command shows frequency into proper
1622 * format (2.412 GHz instead of 246.2 MHz)*/
1623 fwrq->m = 0;
1624 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001626 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001627}
1628
1629static int iw_get_tx_power(struct net_device *dev,
1630 struct iw_request_info *info,
1631 union iwreq_data *wrqu, char *extra)
1632{
1633
1634 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1635 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1636 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1637
1638 if (pHddCtx->isLogpInProgress)
1639 {
1640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1641 "%s:LOGP in Progress. Ignore!!!",__func__);
1642 return -EBUSY;
1643 }
1644
1645 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1646 {
1647 wrqu->txpower.value = 0;
1648 return 0;
1649 }
1650 wlan_hdd_get_classAstats(pAdapter);
1651 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1652
1653 return 0;
1654}
1655
1656static int iw_set_tx_power(struct net_device *dev,
1657 struct iw_request_info *info,
1658 union iwreq_data *wrqu, char *extra)
1659{
1660 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1661 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1662
1663 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1664 {
1665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1666 return 0;
1667 }
1668
1669 ENTER();
1670
1671 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1672 {
c_hpothub8245442013-11-20 23:41:09 +05301673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1674 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 return -EIO;
1676 }
1677
1678 EXIT();
1679
1680 return 0;
1681}
1682
1683static int iw_get_bitrate(struct net_device *dev,
1684 struct iw_request_info *info,
1685 union iwreq_data *wrqu, char *extra)
1686{
1687 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1688 eHalStatus status = eHAL_STATUS_SUCCESS;
1689 hdd_wext_state_t *pWextState;
1690 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1691 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1692
1693 ENTER();
1694
1695 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1697 return status;
1698 }
1699
1700 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1701 wrqu->bitrate.value = 0;
1702 }
1703 else {
1704 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1705 SME_SUMMARY_STATS |
1706 SME_GLOBAL_CLASSA_STATS |
1707 SME_GLOBAL_CLASSB_STATS |
1708 SME_GLOBAL_CLASSC_STATS |
1709 SME_GLOBAL_CLASSD_STATS |
1710 SME_PER_STA_STATS,
1711 hdd_StatisticsCB, 0, FALSE,
1712 pHddStaCtx->conn_info.staId[0], pAdapter );
1713
1714 if(eHAL_STATUS_SUCCESS != status)
1715 {
1716 hddLog(VOS_TRACE_LEVEL_ERROR,
1717 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001718 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 return status;
1720 }
1721
1722 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1723
1724 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1725
1726 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1727 {
1728 hddLog(VOS_TRACE_LEVEL_ERROR,
1729 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001730 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 return VOS_STATUS_E_FAILURE;
1732 }
1733
1734 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1735 }
1736
1737 EXIT();
1738
1739 return vos_status;
1740}
1741/* ccm call back function */
1742
1743static int iw_set_bitrate(struct net_device *dev,
1744 struct iw_request_info *info,
1745 union iwreq_data *wrqu,
1746 char *extra)
1747{
1748 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1749 hdd_wext_state_t *pWextState;
1750 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1751 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1752 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1753 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1754 v_U32_t i, rate;
1755 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1756
1757 ENTER();
1758
1759 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1761 return 0;
1762 }
1763
1764 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1765
1766 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1767 {
1768 return -ENXIO ;
1769 }
1770
1771 rate = wrqu->bitrate.value;
1772
1773 if (rate == -1)
1774 {
1775 rate = WNI_CFG_FIXED_RATE_AUTO;
1776 valid_rate = TRUE;
1777 }
1778 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1779 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1780 {
1781 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1782 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1783 {
1784 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1785 WNI_CFG_SUPPORTED_RATES_11A,
1786 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1787 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1788 WNI_CFG_SUPPORTED_RATES_11B,
1789 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1790 {
1791 for (i = 0; i < (b_len + a_len); ++i)
1792 {
1793 /* supported rates returned is double the actual rate so we divide it by 2 */
1794 if ((supp_rates[i]&0x7F)/2 == rate)
1795 {
1796 valid_rate = TRUE;
1797 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1798 break;
1799 }
1800 }
1801 }
1802 }
1803 }
1804 if (valid_rate != TRUE)
1805 {
1806 return -EINVAL;
1807 }
1808 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1809 WNI_CFG_FIXED_RATE, rate,
1810 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1811 {
c_hpothub8245442013-11-20 23:41:09 +05301812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1813 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 return -EIO;
1815 }
1816 return 0;
1817}
1818
1819
1820static int iw_set_genie(struct net_device *dev,
1821 struct iw_request_info *info,
1822 union iwreq_data *wrqu,
1823 char *extra)
1824{
1825 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1826 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001827 u_int8_t *genie = NULL;
1828 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 v_U16_t remLen;
1830
1831 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001832
1833 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1835 "%s:LOGP in Progress. Ignore!!!", __func__);
1836 return 0;
1837 }
1838
1839 if (!wrqu->data.length) {
1840 hdd_clearRoamProfileIe(pAdapter);
1841 EXIT();
1842 return 0;
1843 }
1844
1845 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1846 wrqu->data.length);
1847 if (NULL == base_genie)
1848 {
1849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1850 "mem_alloc_copy_from_user_helper fail");
1851 return -ENOMEM;
1852 }
1853
1854 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001855
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 remLen = wrqu->data.length;
1857
Arif Hussain6d2a3322013-11-17 19:50:10 -08001858 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001859
1860 /* clear any previous genIE before this call */
1861 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1862
1863 while (remLen >= 2)
1864 {
1865 v_U16_t eLen = 0;
1866 v_U8_t elementId;
1867 elementId = *genie++;
1868 eLen = *genie++;
1869 remLen -= 2;
1870
Arif Hussain6d2a3322013-11-17 19:50:10 -08001871 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 __func__, elementId, eLen);
1873
1874 switch ( elementId )
1875 {
1876 case IE_EID_VENDOR:
1877 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001878 {
1879 kfree(base_genie);
1880 return -EINVAL;
1881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001882
1883 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1884 {
1885 v_U16_t curGenIELen = pWextState->genIE.length;
1886 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1887 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1888
1889 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1890 {
1891 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001892 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001894 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 return -ENOMEM;
1896 }
1897 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1898 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1899 pWextState->genIE.length += eLen + 2;
1900 }
1901 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1902 {
1903 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1904 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1905 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1906 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1907 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1908 }
1909 else /* any vendorId except WPA IE should be accumulated to genIE */
1910 {
1911 v_U16_t curGenIELen = pWextState->genIE.length;
1912 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1913 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1914
1915 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1916 {
1917 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001918 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001920 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 return -ENOMEM;
1922 }
1923 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1924 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1925 pWextState->genIE.length += eLen + 2;
1926 }
1927 break;
1928 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001929 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1931 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1932 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1933 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1934 break;
1935
1936 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001937 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001938 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 return 0;
1940 }
1941 genie += eLen;
1942 remLen -= eLen;
1943 }
1944 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001945 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 return 0;
1947}
1948
1949static int iw_get_genie(struct net_device *dev,
1950 struct iw_request_info *info,
1951 union iwreq_data *wrqu,
1952 char *extra)
1953{
1954 hdd_wext_state_t *pWextState;
1955 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1956 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1957 eHalStatus status;
1958 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1959 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1960
1961 ENTER();
1962
1963 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1965 return 0;
1966 }
1967
1968
Arif Hussain6d2a3322013-11-17 19:50:10 -08001969 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001970
1971 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1972
1973 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1974 {
1975 return -ENXIO;
1976 }
1977
1978 // Return something ONLY if we are associated with an RSN or WPA network
1979 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1980 pWextState->roamProfile.negotiatedAuthType))
1981 {
1982 return -ENXIO;
1983 }
1984
1985 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1986 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1987 pAdapter->sessionId,
1988 &length,
1989 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001990 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1991 if (wrqu->data.length < length)
1992 {
1993 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1994 return -EFAULT;
1995 }
Arif Hussain9f05be02014-02-05 12:06:53 -08001996 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001997 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001998
Arif Hussain6d2a3322013-11-17 19:50:10 -08001999 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002000
2001 EXIT();
2002
2003 return 0;
2004}
2005
2006static int iw_get_encode(struct net_device *dev,
2007 struct iw_request_info *info,
2008 struct iw_point *dwrq, char *extra)
2009{
2010 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2011 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2012 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2013 int keyId;
2014 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2015 int i;
2016
2017 ENTER();
2018
2019 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2021 return 0;
2022 }
2023
2024 keyId = pRoamProfile->Keys.defaultIndex;
2025
2026 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2027 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002028 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 return -EINVAL;
2030 }
2031
2032 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2033 {
2034 dwrq->flags |= IW_ENCODE_ENABLED;
2035 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2036 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2037
2038 dwrq->flags |= (keyId + 1);
2039
2040 }
2041 else
2042 {
2043 dwrq->flags |= IW_ENCODE_DISABLED;
2044 }
2045
2046 for(i=0; i < MAX_WEP_KEYS; i++)
2047 {
2048 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2049 {
2050 continue;
2051 }
2052 else
2053 {
2054 break;
2055 }
2056 }
2057
2058 if(MAX_WEP_KEYS == i)
2059 {
2060 dwrq->flags |= IW_ENCODE_NOKEY;
2061 }
2062
2063 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2064
2065 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2066 {
2067 dwrq->flags |= IW_ENCODE_OPEN;
2068 }
2069 else
2070 {
2071 dwrq->flags |= IW_ENCODE_RESTRICTED;
2072 }
2073 EXIT();
2074 return 0;
2075}
2076
2077#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2078#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2079
2080
2081/*
2082 * This function sends a single 'key' to LIM at all time.
2083 */
2084
2085static int iw_get_rts_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_rts_threshold(pAdapter,wrqu);
2093
2094 return status;
2095}
2096
2097static int iw_set_rts_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_FATAL,
2109 "%s:LOGP in Progress. Ignore!!!", __func__);
2110 return -EAGAIN;
2111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2113 {
2114 return -EINVAL;
2115 }
2116
2117 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.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_RTS_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_frag_threshold(struct net_device *dev,
2130 struct iw_request_info *info,
2131 union iwreq_data *wrqu, char *extra)
2132{
2133 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2134 v_U32_t status = 0;
2135
2136 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2137
2138 return status;
2139}
2140
2141static int iw_set_frag_threshold(struct net_device *dev,
2142 struct iw_request_info *info,
2143 union iwreq_data *wrqu, char *extra)
2144{
2145 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2146 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2147
2148 ENTER();
2149
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002150 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2151 {
2152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2153 "%s:LOGP in Progress. Ignore!!!", __func__);
2154 return -EBUSY;
2155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2157 {
2158 return -EINVAL;
2159 }
2160
2161 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2162 {
c_hpothub8245442013-11-20 23:41:09 +05302163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2164 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 return -EIO;
2166 }
2167
2168 EXIT();
2169
2170 return 0;
2171}
2172
2173static int iw_get_power_mode(struct net_device *dev,
2174 struct iw_request_info *info,
2175 union iwreq_data *wrqu, char *extra)
2176{
2177 ENTER();
2178 return -EOPNOTSUPP;
2179}
2180
2181static int iw_set_power_mode(struct net_device *dev,
2182 struct iw_request_info *info,
2183 union iwreq_data *wrqu, char *extra)
2184{
2185 ENTER();
2186 return -EOPNOTSUPP;
2187}
2188
2189static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2190 union iwreq_data *wrqu, char *extra)
2191{
2192 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2193 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2194 struct iw_range *range = (struct iw_range *) extra;
2195
2196 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2197
2198 v_U32_t num_channels = sizeof(channels);
2199 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2200 v_U32_t a_len;
2201 v_U32_t b_len;
2202 v_U32_t active_phy_mode = 0;
2203 v_U8_t index = 0, i;
2204
2205 ENTER();
2206
2207 wrqu->data.length = sizeof(struct iw_range);
2208 memset(range, 0, sizeof(struct iw_range));
2209
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002210 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2211 {
2212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2213 "%s:LOGP in Progress. Ignore!!!", __func__);
2214 return -EBUSY;
2215 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
2217 /*Get the phy mode*/
2218 if (ccmCfgGetInt(hHal,
2219 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2220 {
2221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002222 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002223
2224 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2225 {
2226 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002227 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 if (ccmCfgGetStr(hHal,
2229 WNI_CFG_SUPPORTED_RATES_11A,
2230 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2231 {
2232 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2233 {
2234 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2235 }
2236 for (i = 0; i < a_len; i++)
2237 {
2238 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2239 }
2240 range->num_bitrates = a_len;
2241 }
2242 else
2243 {
2244 return -EIO;
2245 }
2246 }
2247 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2248 {
2249 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002250 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 if (ccmCfgGetStr(hHal,
2252 WNI_CFG_SUPPORTED_RATES_11B,
2253 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2254 {
2255 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2256 {
2257 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2258 }
2259 for (i = 0; i < b_len; i++)
2260 {
2261 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2262 }
2263 range->num_bitrates = b_len;
2264 }
2265 else
2266 {
2267 return -EIO;
2268 }
2269 }
2270 }
2271
2272 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2273 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2274 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2275
2276 range->encoding_size[0] = 5;
2277 range->encoding_size[1] = 13;
2278 range->num_encoding_sizes = 2;
2279 range->max_encoding_tokens = MAX_WEP_KEYS;
2280
2281 // we support through Wireless Extensions 22
2282 range->we_version_compiled = WIRELESS_EXT;
2283 range->we_version_source = 22;
2284
2285 /*Supported Channels and Frequencies*/
2286 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2287 {
c_hpothub8245442013-11-20 23:41:09 +05302288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2289 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 return -EIO;
2291 }
2292 if (num_channels > IW_MAX_FREQUENCIES)
2293 {
2294 num_channels = IW_MAX_FREQUENCIES;
2295 }
2296
2297 range->num_channels = num_channels;
2298 range->num_frequency = num_channels;
2299
2300 for (index=0; index < num_channels; index++)
2301 {
2302 v_U32_t frq_indx = 0;
2303
2304 range->freq[index].i = channels[index];
2305 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2306 {
2307 if(channels[index] == freq_chan_map[frq_indx].chan)
2308 {
2309 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2310 range->freq[index].e = 1;
2311 break;
2312 }
2313 frq_indx++;
2314 }
2315 }
2316
2317 /* Event capability (kernel + driver) */
2318 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2319 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2320 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2321 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2322
2323 /*Encryption capability*/
2324 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2325 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2326
2327 /* Txpower capability */
2328 range->txpower_capa = IW_TXPOW_MWATT;
2329
2330 /*Scanning capability*/
2331 #if WIRELESS_EXT >= 22
2332 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2333 #endif
2334
2335 EXIT();
2336 return 0;
2337}
2338
2339/* Callback function registered with PMC to know status of PMC request */
2340static void iw_power_callback_fn (void *pContext, eHalStatus status)
2341{
2342 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002343
2344 if (NULL == pContext)
2345 {
2346 hddLog(VOS_TRACE_LEVEL_ERROR,
2347 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002348 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 return;
2350 }
2351
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002353
Jeff Johnson72a40512013-12-19 10:14:15 -08002354 /* there is a race condition that exists between this callback
2355 function and the caller since the caller could time out either
2356 before or while this code is executing. we use a spinlock to
2357 serialize these actions */
2358 spin_lock(&hdd_context_lock);
2359
2360 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 {
2362 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002363 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002365 "%s: Invalid context, magic [%08x]",
2366 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002367
2368 if (ioctl_debug)
2369 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002370 pr_info("%s: Invalid context, magic [%08x]\n",
2371 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 }
2373 return;
2374 }
2375
Jeff Johnson72a40512013-12-19 10:14:15 -08002376 /* context is valid so caller is still waiting */
2377
2378 /* paranoia: invalidate the magic */
2379 pStatsContext->magic = 0;
2380
2381 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002383
2384 /* serialization is complete */
2385 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002386}
2387
2388/* Callback function for tx per hit */
2389void hdd_tx_per_hit_cb (void *pCallbackContext)
2390{
2391 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2392 unsigned char tx_fail[16];
2393 union iwreq_data wrqu;
2394
2395 if (NULL == pAdapter)
2396 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002397 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 return;
2399 }
2400 memset(&wrqu, 0, sizeof(wrqu));
2401 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2402 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2403}
2404
2405void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2406{
2407 struct statsContext *pStatsContext;
2408 tCsrGlobalClassAStatsInfo *pClassAStats;
2409 hdd_adapter_t *pAdapter;
2410
2411 if (ioctl_debug)
2412 {
2413 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002414 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 }
2416
2417 if ((NULL == pStats) || (NULL == pContext))
2418 {
2419 hddLog(VOS_TRACE_LEVEL_ERROR,
2420 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002421 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 return;
2423 }
2424
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 pClassAStats = pStats;
2426 pStatsContext = pContext;
2427 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002428
2429 /* there is a race condition that exists between this callback
2430 function and the caller since the caller could time out either
2431 before or while this code is executing. we use a spinlock to
2432 serialize these actions */
2433 spin_lock(&hdd_context_lock);
2434
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2436 {
2437 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002438 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 hddLog(VOS_TRACE_LEVEL_WARN,
2440 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002441 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 if (ioctl_debug)
2443 {
2444 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002445 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 }
2447 return;
2448 }
2449
Jeff Johnson72a40512013-12-19 10:14:15 -08002450 /* context is valid so caller is still waiting */
2451
2452 /* paranoia: invalidate the magic */
2453 pStatsContext->magic = 0;
2454
2455 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2457
Jeff Johnson72a40512013-12-19 10:14:15 -08002458 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002460
2461 /* serialization is complete */
2462 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002463}
2464
2465VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2466{
2467 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2468 eHalStatus hstatus;
2469 long lrc;
2470 struct statsContext context;
2471
2472 if (NULL == pAdapter)
2473 {
2474 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2475 return VOS_STATUS_E_FAULT;
2476 }
2477 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2478 {
2479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2480 return VOS_STATUS_SUCCESS;
2481 }
2482
2483 /* we are connected
2484 prepare our callback context */
2485 init_completion(&context.completion);
2486 context.pAdapter = pAdapter;
2487 context.magic = STATS_CONTEXT_MAGIC;
2488 /* query only for Class A statistics (which include link speed) */
2489 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2490 eCSR_HDD,
2491 SME_GLOBAL_CLASSA_STATS,
2492 hdd_GetClassA_statisticsCB,
2493 0, // not periodic
2494 FALSE, //non-cached results
2495 pHddStaCtx->conn_info.staId[0],
2496 &context);
2497 if (eHAL_STATUS_SUCCESS != hstatus)
2498 {
2499 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002500 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002501 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 /* we'll returned a cached value below */
2503 }
2504 else
2505 {
2506 /* request was sent -- wait for the response */
2507 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2508 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 if (lrc <= 0)
2510 {
2511 hddLog(VOS_TRACE_LEVEL_ERROR,
2512 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002513 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 }
2515 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002516
2517 /* either we never sent a request, we sent a request and received a
2518 response or we sent a request and timed out. if we never sent a
2519 request or if we sent a request and got a response, we want to
2520 clear the magic out of paranoia. if we timed out there is a
2521 race condition such that the callback function could be
2522 executing at the same time we are. of primary concern is if the
2523 callback function had already verified the "magic" but had not
2524 yet set the completion variable when a timeout occurred. we
2525 serialize these activities by invalidating the magic while
2526 holding a shared spinlock which will cause us to block if the
2527 callback is currently executing */
2528 spin_lock(&hdd_context_lock);
2529 context.magic = 0;
2530 spin_unlock(&hdd_context_lock);
2531
2532 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 return VOS_STATUS_SUCCESS;
2534}
2535
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002536static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2537{
2538 struct statsContext *pStatsContext;
2539 tCsrSummaryStatsInfo *pSummaryStats;
2540 tCsrGlobalClassAStatsInfo *pClassAStats;
2541 hdd_adapter_t *pAdapter;
2542
2543 if (ioctl_debug)
2544 {
2545 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002546 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002547 }
2548
2549 if ((NULL == pStats) || (NULL == pContext))
2550 {
2551 hddLog(VOS_TRACE_LEVEL_ERROR,
2552 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002553 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002554 return;
2555 }
2556
Jeff Johnson72a40512013-12-19 10:14:15 -08002557 /* there is a race condition that exists between this callback
2558 function and the caller since the caller could time out either
2559 before or while this code is executing. we use a spinlock to
2560 serialize these actions */
2561 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002562
2563 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2564 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2565 pStatsContext = pContext;
2566 pAdapter = pStatsContext->pAdapter;
2567 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2568 {
2569 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002570 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002571 hddLog(VOS_TRACE_LEVEL_WARN,
2572 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002573 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002574 if (ioctl_debug)
2575 {
2576 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002577 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002578 }
2579 return;
2580 }
2581
Jeff Johnson72a40512013-12-19 10:14:15 -08002582 /* context is valid so caller is still waiting */
2583
2584 /* paranoia: invalidate the magic */
2585 pStatsContext->magic = 0;
2586
2587 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002588 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2589 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2590
Jeff Johnson72a40512013-12-19 10:14:15 -08002591 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002592 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002593
2594 /* serialization is complete */
2595 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002596}
2597
2598VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2599{
2600 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2601 eHalStatus hstatus;
2602 long lrc;
2603 struct statsContext context;
2604
2605 if (NULL == pAdapter)
2606 {
2607 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2608 return VOS_STATUS_SUCCESS;
2609 }
2610
2611 /* we are connected
2612 prepare our callback context */
2613 init_completion(&context.completion);
2614 context.pAdapter = pAdapter;
2615 context.magic = STATS_CONTEXT_MAGIC;
2616
2617 /* query only for Summary & Class A statistics */
2618 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2619 eCSR_HDD,
2620 SME_SUMMARY_STATS |
2621 SME_GLOBAL_CLASSA_STATS,
2622 hdd_get_station_statisticsCB,
2623 0, // not periodic
2624 FALSE, //non-cached results
2625 pHddStaCtx->conn_info.staId[0],
2626 &context);
2627 if (eHAL_STATUS_SUCCESS != hstatus)
2628 {
2629 hddLog(VOS_TRACE_LEVEL_ERROR,
2630 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002631 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002632 /* we'll return with cached values */
2633 }
2634 else
2635 {
2636 /* request was sent -- wait for the response */
2637 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2638 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002639
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002640 if (lrc <= 0)
2641 {
2642 hddLog(VOS_TRACE_LEVEL_ERROR,
2643 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002644 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002645 }
2646 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002647
2648 /* either we never sent a request, we sent a request and received a
2649 response or we sent a request and timed out. if we never sent a
2650 request or if we sent a request and got a response, we want to
2651 clear the magic out of paranoia. if we timed out there is a
2652 race condition such that the callback function could be
2653 executing at the same time we are. of primary concern is if the
2654 callback function had already verified the "magic" but had not
2655 yet set the completion variable when a timeout occurred. we
2656 serialize these activities by invalidating the magic while
2657 holding a shared spinlock which will cause us to block if the
2658 callback is currently executing */
2659 spin_lock(&hdd_context_lock);
2660 context.magic = 0;
2661 spin_unlock(&hdd_context_lock);
2662
2663 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002664 return VOS_STATUS_SUCCESS;
2665}
2666
2667
Jeff Johnson295189b2012-06-20 16:38:30 -07002668/*
2669 * Support for the LINKSPEED private command
2670 * Per the WiFi framework the response must be of the form
2671 * "LinkSpeed xx"
2672 */
2673static int iw_get_linkspeed(struct net_device *dev,
2674 struct iw_request_info *info,
2675 union iwreq_data *wrqu, char *extra)
2676{
2677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302678 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302680 int len = sizeof(v_U32_t) + 1;
2681 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302683 VOS_STATUS status;
2684 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002685
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302686 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2687
2688 valid = wlan_hdd_validate_context(pHddCtx);
2689
2690 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002691 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2693 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002694 }
2695
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2697 {
2698 /* we are not connected so we don't have a classAstats */
2699 link_speed = 0;
2700 }
2701 else
2702 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302703 status = wlan_hdd_get_classAstats(pAdapter);
2704
2705 if (!VOS_IS_STATUS_SUCCESS(status ))
2706 {
2707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2708 return -EINVAL;
2709 }
2710
2711 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2712 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2713 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2714 &link_speed);
2715
2716 link_speed = link_speed / 10;
2717
2718 if (0 == link_speed)
2719 {
2720 /* The linkspeed returned by HAL is in units of 500kbps.
2721 * converting it to mbps.
2722 * This is required to support legacy firmware which does
2723 * not return link capacity.
2724 */
2725 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2726 }
2727
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 }
2729
2730 wrqu->data.length = len;
2731 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002732 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 if ((rc < 0) || (rc >= len))
2734 {
2735 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302736 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 return -EIO;
2738 }
2739
2740 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002741 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002742}
2743
Arif Hussain695279c2014-03-24 14:06:07 -07002744/*
2745 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2746 *
2747 */
2748static int iw_get_linkspeed_priv(struct net_device *dev,
2749 struct iw_request_info *info,
2750 union iwreq_data *wrqu, char *extra)
2751{
2752 int rc;
2753
2754 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2755
2756 if (rc < 0)
2757 return rc;
2758
2759 /* a value is being successfully returned */
2760 return 0;
2761}
Jeff Johnson295189b2012-06-20 16:38:30 -07002762
2763/*
2764 * Support for the RSSI & RSSI-APPROX private commands
2765 * Per the WiFi framework the response must be of the form
2766 * "<ssid> rssi <xx>"
2767 * unless we are not associated, in which case the response is
2768 * "OK"
2769 */
2770static int iw_get_rssi(struct net_device *dev,
2771 struct iw_request_info *info,
2772 union iwreq_data *wrqu, char *extra)
2773{
2774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002775 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 int len = wrqu->data.length;
2777 v_S7_t s7Rssi = 0;
2778 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2779 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2780 VOS_STATUS vosStatus;
2781 int rc;
2782
2783 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2784 (0 == ssidlen) || (ssidlen >= len))
2785 {
2786 /* we are not connected or our SSID is too long
2787 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002788 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 }
2790 else
2791 {
2792 /* we are connected with a valid SSID
2793 so we can write the SSID into the return buffer
2794 (note that it is not NUL-terminated) */
2795 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2796
2797 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2798
2799 if (VOS_STATUS_SUCCESS == vosStatus)
2800 {
2801 /* append the rssi to the ssid in the format required by
2802 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002803 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302804 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 }
2806 else
2807 {
2808 rc = -1;
2809 }
2810 }
2811
2812 /* verify that we wrote a valid response */
2813 if ((rc < 0) || (rc >= len))
2814 {
2815 // encoding or length error?
2816 hddLog(VOS_TRACE_LEVEL_ERROR,
2817 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002818 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 return -EIO;
2820 }
2821
2822 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002823 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002824}
2825
2826/*
2827 * Support for SoftAP channel range private command
2828 */
2829static int iw_softap_set_channel_range( struct net_device *dev,
2830 int startChannel,
2831 int endChannel,
2832 int band)
2833{
Jeff Johnson43971f52012-07-17 12:26:56 -07002834 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 int ret = 0;
2836 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2837 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002838 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2839
Jeff Johnson295189b2012-06-20 16:38:30 -07002840
2841 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2842 if (VOS_STATUS_SUCCESS != status)
2843 {
2844 ret = -EINVAL;
2845 }
Yathish9f22e662012-12-10 14:21:35 -08002846 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 return ret;
2848}
2849
2850VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2851{
2852 struct statsContext context;
2853 eHalStatus status;
2854 hdd_context_t *pHddCtx;
2855
2856 if (NULL == pAdapter)
2857 {
2858 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2859 return VOS_STATUS_E_FAULT;
2860 }
2861
2862 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2863 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05302864 if (pHddCtx->isLogpInProgress) {
2865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2866 "%s:LOGP in Progress. Ignore!!!", __func__);
2867 return VOS_STATUS_E_FAILURE;
2868 }
2869
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 init_completion(&context.completion);
2871
2872 context.pAdapter = pAdapter;
2873 context.magic = POWER_CONTEXT_MAGIC;
2874
2875 if (DRIVER_POWER_MODE_ACTIVE == mode)
2876 {
2877 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2878 "Full Power", __func__);
2879 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2880 iw_power_callback_fn, &context,
2881 eSME_FULL_PWR_NEEDED_BY_HDD);
2882 // Enter Full power command received from GUI this means we are disconnected
2883 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2884 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2885 if (eHAL_STATUS_PMC_PENDING == status)
2886 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002887 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 int lrc = wait_for_completion_interruptible_timeout(
2889 &context.completion,
2890 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002891
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 if (lrc <= 0)
2893 {
2894 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002895 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 }
2897 }
2898 }
2899 else if (DRIVER_POWER_MODE_AUTO == mode)
2900 {
2901 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2902 {
2903 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2904 __func__);
2905 // Enter BMPS command received from GUI this means DHCP is completed
2906 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2907 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2908 FALSE);
2909 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2910 iw_power_callback_fn, &context);
2911 if (eHAL_STATUS_PMC_PENDING == status)
2912 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002913 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 int lrc = wait_for_completion_interruptible_timeout(
2915 &context.completion,
2916 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 if (lrc <= 0)
2918 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002919 hddLog(VOS_TRACE_LEVEL_ERROR,
2920 "%s: SME %s while requesting BMPS",
2921 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 }
2923 }
2924 }
2925 else
2926 {
2927 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2928 "enabled in the cfg");
2929 }
2930 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002931
2932 /* either we never sent a request, we sent a request and received a
2933 response or we sent a request and timed out. if we never sent a
2934 request or if we sent a request and got a response, we want to
2935 clear the magic out of paranoia. if we timed out there is a
2936 race condition such that the callback function could be
2937 executing at the same time we are. of primary concern is if the
2938 callback function had already verified the "magic" but had not
2939 yet set the completion variable when a timeout occurred. we
2940 serialize these activities by invalidating the magic while
2941 holding a shared spinlock which will cause us to block if the
2942 callback is currently executing */
2943 spin_lock(&hdd_context_lock);
2944 context.magic = 0;
2945 spin_unlock(&hdd_context_lock);
2946
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 return VOS_STATUS_SUCCESS;
2948}
2949
2950VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2951 hdd_adapter_t *pAdapter)
2952{
2953 VOS_STATUS vos_Status;
2954
2955 if ((NULL == pAdapter) || (NULL == pHddCtx))
2956 {
2957 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2958 return VOS_STATUS_E_FAULT;
2959 }
2960
2961 /**Exit from Deep sleep or standby if we get the driver
2962 START cmd from android GUI
2963 */
2964 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2965 {
2966 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2967 "from Stand by",__func__);
2968 vos_Status = hdd_exit_standby(pHddCtx);
2969 }
2970 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2971 {
2972 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2973 "from deep sleep",__func__);
2974 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2975 }
2976 else
2977 {
2978 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2979 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2980 vos_Status = VOS_STATUS_SUCCESS;
2981 }
2982
2983 return vos_Status;
2984}
2985
2986VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2987{
2988 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2989
2990 if (NULL == pHddCtx)
2991 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302992 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 return VOS_STATUS_E_FAULT;
2994 }
2995
2996 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2997 {
2998 //Execute standby procedure.
2999 //Executing standby procedure will cause the STA to
3000 //disassociate first and then the chip will be put into standby.
3001 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3002 vos_Status = hdd_enter_standby(pHddCtx);
3003 }
3004 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3005 pHddCtx->cfg_ini->nEnableDriverStop)
3006 {
3007 //Execute deep sleep procedure
3008 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003009 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 //Deep sleep not supported
3011 vos_Status = hdd_enter_standby(pHddCtx);
3012 }
3013 else
3014 {
3015 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3016 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3017 vos_Status = VOS_STATUS_SUCCESS;
3018 }
3019
3020 return vos_Status;
3021}
3022
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003023
3024void* wlan_hdd_change_country_code_callback(void *pAdapter)
3025{
3026
3027 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003028 complete(&call_back_pAdapter->change_country_code);
3029
3030 return NULL;
3031}
3032
Jeff Johnson295189b2012-06-20 16:38:30 -07003033static int iw_set_priv(struct net_device *dev,
3034 struct iw_request_info *info,
3035 union iwreq_data *wrqu, char *extra)
3036{
3037 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003038 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 int cmd_len = wrqu->data.length;
3040 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003041 int rc = 0;
3042 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3043
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3045
3046 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003047 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3048 wrqu->data.length);
3049 if (NULL == cmd)
3050 {
3051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3052 "mem_alloc_copy_from_user_helper fail");
3053 return -ENOMEM;
3054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003055
3056 if (ioctl_debug)
3057 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003058 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 }
3060
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003061 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3062 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003063
3064 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003065 if (ioctl_debug)
3066 {
3067 pr_info("%s: RESTART in progress\n", __func__);
3068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003069
Arif Hussain24bfa702014-01-22 13:51:30 -08003070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003072 kfree(cmd);
3073 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 }
3075
Arif Hussain24bfa702014-01-22 13:51:30 -08003076 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003078 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3080 "%s: Error in iw_set_scan!", __func__);
3081 rc = -EINVAL;
3082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 }
3084 else if( strcasecmp(cmd, "start") == 0 ) {
3085
Arif Hussain6d2a3322013-11-17 19:50:10 -08003086 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003088
Arif Hussain24bfa702014-01-22 13:51:30 -08003089 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3090 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 {
3092 union iwreq_data wrqu;
3093 char buf[10];
3094
3095 memset(&wrqu, 0, sizeof(wrqu));
3096 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3097 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3098 }
3099 else
3100 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003101 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3102 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 }
3104 goto done;
3105 }
3106 else if( strcasecmp(cmd, "stop") == 0 )
3107 {
3108 union iwreq_data wrqu;
3109 char buf[10];
3110
Arif Hussain6d2a3322013-11-17 19:50:10 -08003111 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003112
3113 wlan_hdd_enter_lowpower(pHddCtx);
3114 memset(&wrqu, 0, sizeof(wrqu));
3115 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3116 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 goto done;
3118 }
3119 else if (strcasecmp(cmd, "macaddr") == 0)
3120 {
3121 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3122 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3123 }
3124 else if (strcasecmp(cmd, "scan-active") == 0)
3125 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303126 hddLog(VOS_TRACE_LEVEL_ERROR,
3127 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003128 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 ret = snprintf(cmd, cmd_len, "OK");
3130 }
3131 else if (strcasecmp(cmd, "scan-passive") == 0)
3132 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303133 hddLog(VOS_TRACE_LEVEL_ERROR,
3134 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003135 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 ret = snprintf(cmd, cmd_len, "OK");
3137 }
3138 else if( strcasecmp(cmd, "scan-mode") == 0 )
3139 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003140 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 }
3142 else if( strcasecmp(cmd, "linkspeed") == 0 )
3143 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003144 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 }
3146 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3147 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003148 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003149 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003150
3151 country_code = cmd + 8;
3152
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003153 init_completion(&pAdapter->change_country_code);
3154
Arif Hussain24bfa702014-01-22 13:51:30 -08003155 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003156 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 country_code,
3158 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303159 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303160 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303161 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003162
3163 /* Wait for completion */
3164 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3165 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3166
3167 if (lrc <= 0)
3168 {
3169 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003170 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003171 }
3172
Arif Hussain24bfa702014-01-22 13:51:30 -08003173 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003175 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003176 "%s: SME Change Country code fail", __func__);
3177 kfree(cmd);
3178 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 }
3180 }
3181 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3182 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003183 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 }
3185 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3186 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003187 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003188
Wilson Yang1be3e652013-10-09 15:18:31 -07003189 if (9 < cmd_len)
3190 {
3191 ptr = (char*)(cmd + 9);
3192
3193 }else{
3194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3195 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003196 kfree(cmd);
3197 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003198 }
3199
3200 if (1 != sscanf(ptr,"%d",&mode))
3201 {
3202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3203 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003204 kfree(cmd);
3205 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003206 }
3207
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 wlan_hdd_enter_bmps(pAdapter, mode);
3209 /*TODO:Set the power mode*/
3210 }
3211 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3212 v_U32_t pmc_state;
3213 v_U16_t value;
3214
3215 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3216 if(pmc_state == BMPS) {
3217 value = DRIVER_POWER_MODE_AUTO;
3218 }
3219 else {
3220 value = DRIVER_POWER_MODE_ACTIVE;
3221 }
3222 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3223 }
3224 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003225 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 /*TODO: set the btcoexmode*/
3227 }
3228 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3229
Arif Hussain6d2a3322013-11-17 19:50:10 -08003230 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 /*TODO: Return the btcoex status*/
3232 }
3233 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3234
Arif Hussain6d2a3322013-11-17 19:50:10 -08003235 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003236
3237 /*TODO: Enable Rx data Filter*/
3238 }
3239 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3240
Arif Hussain6d2a3322013-11-17 19:50:10 -08003241 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003242
3243 /*TODO: Disable Rx data Filter*/
3244 }
3245 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3246
Arif Hussain6d2a3322013-11-17 19:50:10 -08003247 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 /*TODO: rxfilter-statistics*/
3249 }
3250 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3251
Arif Hussain6d2a3322013-11-17 19:50:10 -08003252 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 /*TODO: rxfilter-add*/
3254 }
3255 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3256
Arif Hussain6d2a3322013-11-17 19:50:10 -08003257 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 /*TODO: rxfilter-remove*/
3259 }
3260#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003261 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3262 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3263 /*TODO: support pnosetup*/
3264 }
3265 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3266 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3267 /*TODO: support pnoforce*/
3268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3270
Arif Hussain6d2a3322013-11-17 19:50:10 -08003271 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003272 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3273 kfree(cmd);
3274 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 }
3276 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003277 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003278 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3279 kfree(cmd);
3280 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 }
3282#endif /*FEATURE_WLAN_SCAN_PNO*/
3283 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003284 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003285 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3286 kfree(cmd);
3287 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 }
3289 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3290 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003291 char *ptr;
3292
3293 if (18 < cmd_len)
3294 {
3295 ptr = (char*)(cmd + 18);
3296 }else{
3297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3298 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003299 kfree(cmd);
3300 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003301 }
3302
Jeff Johnson02797792013-10-26 19:17:13 -07003303 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003304 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3305 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3306 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3307 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3308 {
3309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3310 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003311 kfree(cmd);
3312 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003314
3315 // parameters checking
3316 // period has to be larger than 0
3317 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3318 {
3319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003320 kfree(cmd);
3321 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 }
3323
3324 // use default value 5 is the input is not reasonable. in unit of 10%
3325 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3326 {
3327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3328 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3329 }
3330
3331 // default is 5
3332 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3333 {
3334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3335 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3336 }
3337
Arif Hussain24bfa702014-01-22 13:51:30 -08003338 if (eHAL_STATUS_SUCCESS !=
3339 sme_SetTxPerTracking(pHddCtx->hHal,
3340 hdd_tx_per_hit_cb,
3341 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003343 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 }
3345 }
3346 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003347 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3348 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 }
3350done:
3351 /* many of the commands write information back into the command
3352 string using snprintf(). check the return value here in one
3353 place */
3354 if ((ret < 0) || (ret >= cmd_len))
3355 {
3356 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003357 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003359 else if (ret > 0)
3360 {
3361 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3362 {
3363 hddLog(VOS_TRACE_LEVEL_ERROR,
3364 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003365 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003366 return -EFAULT;
3367 }
3368 wrqu->data.length = ret;
3369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003370
3371 if (ioctl_debug)
3372 {
3373 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003374 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003376 kfree(cmd);
3377 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003378}
3379
3380static int iw_set_nick(struct net_device *dev,
3381 struct iw_request_info *info,
3382 union iwreq_data *wrqu, char *extra)
3383{
3384 ENTER();
3385 return 0;
3386}
3387
3388static int iw_get_nick(struct net_device *dev,
3389 struct iw_request_info *info,
3390 union iwreq_data *wrqu, char *extra)
3391{
3392 ENTER();
3393 return 0;
3394}
3395
3396static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3397{
3398 ENTER();
3399 return NULL;
3400}
3401
3402static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3403 union iwreq_data *wrqu,char *extra)
3404
3405{
3406 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3407 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3408 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3409 struct iw_point *encoderq = &(wrqu->encoding);
3410 v_U32_t keyId;
3411 v_U8_t key_length;
3412 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3413 v_BOOL_t fKeyPresent = 0;
3414 int i;
3415 eHalStatus status = eHAL_STATUS_SUCCESS;
3416
3417
3418 ENTER();
3419
3420 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3421 {
3422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3423 "%s:LOGP in Progress. Ignore!!!",__func__);
3424 return 0;
3425 }
3426
3427
3428 keyId = encoderq->flags & IW_ENCODE_INDEX;
3429
3430 if(keyId)
3431 {
3432 if(keyId > MAX_WEP_KEYS)
3433 {
3434 return -EINVAL;
3435 }
3436
3437 fKeyPresent = 1;
3438 keyId--;
3439 }
3440 else
3441 {
3442 fKeyPresent = 0;
3443 }
3444
3445
3446 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3447 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 if(!fKeyPresent) {
3450
3451 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3452
3453 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3454 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3455 }
3456 }
3457 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3458 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3459 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3460 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3461
3462 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3463 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3464
3465 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3466 {
3467 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3468 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003469 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303470 {
3471 long ret;
3472 ret = wait_for_completion_interruptible_timeout(
3473 &pAdapter->disconnect_comp_var,
3474 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3475 if (ret <= 0)
3476 hddLog(VOS_TRACE_LEVEL_ERROR,
3477 FL("failed wait on disconnect_comp_var %ld"), ret);
3478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 }
3480
3481 return status;
3482
3483 }
3484
3485 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3486 {
3487 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3488
3489 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3490
3491 }
3492
3493
3494 if(wrqu->data.length > 0)
3495 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003496 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003497
3498 key_length = wrqu->data.length;
3499
3500 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3501
3502 if(5 == key_length)
3503 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003504 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003505
3506 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3507 {
3508 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3509 }
3510 else
3511 {
3512 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3513 }
3514 }
3515 else if(13 == key_length)
3516 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003517 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003518
3519 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3520 {
3521 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3522 }
3523 else
3524 {
3525 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3526 }
3527 }
3528 else
3529 {
3530 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003531 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 return -EINVAL;
3533 }
3534
3535 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3536 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3537 pWextState->roamProfile.EncryptionType.numEntries = 1;
3538 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3539 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3540 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3541
3542 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3543 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3544 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3545 {
3546
3547 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3548
3549 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3550 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3551
3552 return status;
3553 }
3554 }
3555
3556 return 0;
3557}
3558
3559static int iw_get_encodeext(struct net_device *dev,
3560 struct iw_request_info *info,
3561 struct iw_point *dwrq,
3562 char *extra)
3563{
3564 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3565 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3566 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3567 int keyId;
3568 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3569 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3570 int i;
3571
3572 ENTER();
3573
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003574 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3575 {
3576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3577 "%s:LOGP in Progress. Ignore!!!", __func__);
3578 return -EBUSY;
3579 }
3580
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 keyId = pRoamProfile->Keys.defaultIndex;
3582
3583 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3584 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003585 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 return -EINVAL;
3587 }
3588
3589 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3590 {
3591 dwrq->flags |= IW_ENCODE_ENABLED;
3592 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303593 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3594 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 }
3596 else
3597 {
3598 dwrq->flags |= IW_ENCODE_DISABLED;
3599 }
3600
3601 for(i=0; i < MAX_WEP_KEYS; i++)
3602 {
3603 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3604 {
3605 continue;
3606 }
3607 else
3608 {
3609 break;
3610 }
3611 }
3612
3613 if(MAX_WEP_KEYS == i)
3614 {
3615 dwrq->flags |= IW_ENCODE_NOKEY;
3616 }
3617 else
3618 {
3619 dwrq->flags |= IW_ENCODE_ENABLED;
3620 }
3621
3622 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3623
3624 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3625 {
3626 dwrq->flags |= IW_ENCODE_DISABLED;
3627 }
3628
3629 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3630
3631 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3632 {
3633 dwrq->flags |= IW_ENCODE_OPEN;
3634 }
3635 else
3636 {
3637 dwrq->flags |= IW_ENCODE_RESTRICTED;
3638 }
3639 EXIT();
3640 return 0;
3641
3642}
3643
3644static int iw_set_encodeext(struct net_device *dev,
3645 struct iw_request_info *info,
3646 union iwreq_data *wrqu, char *extra)
3647{
3648 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3649 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3650 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3651 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3652
3653 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3654 v_U32_t status = 0;
3655
3656 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3657
3658 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3659
3660 int key_index;
3661 struct iw_point *encoding = &wrqu->encoding;
3662 tCsrRoamSetKey setKey;
3663 v_U32_t roamId= 0xFF;
3664 VOS_STATUS vos_status;
3665
3666 ENTER();
3667
3668 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3669 {
3670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3671 "%s:LOGP in Progress. Ignore!!!",__func__);
3672 return 0;
3673 }
3674
3675 key_index = encoding->flags & IW_ENCODE_INDEX;
3676
3677 if(key_index > 0) {
3678
3679 /*Convert from 1-based to 0-based keying*/
3680 key_index--;
3681 }
3682 if(!ext->key_len) {
3683
3684 /*Set the encrytion type to NONE*/
3685 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3686 return status;
3687 }
3688
3689 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3690 (IW_ENCODE_ALG_WEP == ext->alg))
3691 {
3692 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3693
Agarwal Ashish971c2882013-10-30 20:11:12 +05303694 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3695 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 return -EINVAL;
3697 }
3698 else {
3699 /*Static wep, update the roam profile with the keys */
3700 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3701 key_index < CSR_MAX_NUM_KEY) {
3702 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3703 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3704
3705 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3706 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3707
3708 }
3709 }
3710 return status;
3711 }
3712
3713 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3714
3715 setKey.keyId = key_index;
3716 setKey.keyLength = ext->key_len;
3717
3718 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3719 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3720 }
3721
3722 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3723 /*Key direction for group is RX only*/
3724 setKey.keyDirection = eSIR_RX_ONLY;
3725 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3726 }
3727 else {
3728
3729 setKey.keyDirection = eSIR_TX_RX;
3730 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3731 }
3732
3733 /*For supplicant pae role is zero*/
3734 setKey.paeRole = 0;
3735
3736 switch(ext->alg)
3737 {
3738 case IW_ENCODE_ALG_NONE:
3739 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3740 break;
3741
3742 case IW_ENCODE_ALG_WEP:
3743 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3744 break;
3745
3746 case IW_ENCODE_ALG_TKIP:
3747 {
3748 v_U8_t *pKey = &setKey.Key[0];
3749
3750 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3751
3752 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3753
3754 /*Supplicant sends the 32bytes key in this order
3755
3756 |--------------|----------|----------|
3757 | Tk1 |TX-MIC | RX Mic |
3758 |--------------|----------|----------|
3759 <---16bytes---><--8bytes--><--8bytes-->
3760
3761 */
3762 /*Sme expects the 32 bytes key to be in the below order
3763
3764 |--------------|----------|----------|
3765 | Tk1 |RX-MIC | TX Mic |
3766 |--------------|----------|----------|
3767 <---16bytes---><--8bytes--><--8bytes-->
3768 */
3769 /* Copy the Temporal Key 1 (TK1) */
3770 vos_mem_copy(pKey,ext->key,16);
3771
3772 /*Copy the rx mic first*/
3773 vos_mem_copy(&pKey[16],&ext->key[24],8);
3774
3775 /*Copy the tx mic */
3776 vos_mem_copy(&pKey[24],&ext->key[16],8);
3777
3778 }
3779 break;
3780
3781 case IW_ENCODE_ALG_CCMP:
3782 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3783 break;
3784
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003785#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003786#define IW_ENCODE_ALG_KRK 6
3787 case IW_ENCODE_ALG_KRK:
3788 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3789 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003790#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003791
3792 default:
3793 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3794 break;
3795 }
3796
3797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003798 ("%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 -07003799
3800#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303801 /* The supplicant may attempt to set the PTK once pre-authentication
3802 is done. Save the key in the UMAC and include it in the ADD
3803 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303805 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303807 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3808 "%s: Update PreAuth Key success", __func__);
3809 return 0;
3810 }
3811 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3812 {
3813 hddLog(VOS_TRACE_LEVEL_ERROR,
3814 "%s: Update PreAuth Key failed", __func__);
3815 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 }
3817#endif /* WLAN_FEATURE_VOWIFI_11R */
3818
3819 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3820
3821 vos_status = wlan_hdd_check_ula_done(pAdapter);
3822 if ( vos_status != VOS_STATUS_SUCCESS )
3823 {
3824 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3825 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3826 __LINE__, vos_status );
3827
3828 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3829 }
3830
3831 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3832
3833 if ( halStatus != eHAL_STATUS_SUCCESS )
3834 {
3835 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3836 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3837 __LINE__, halStatus );
3838
3839 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3840 }
3841
3842 return halStatus;
3843}
3844
3845static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3846 union iwreq_data *wrqu, char *extra)
3847{
3848 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3849 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3850
3851 ENTER();
3852
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003853 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3854 {
3855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3856 "%s:LOGP in Progress. Ignore!!!", __func__);
3857 return -EBUSY;
3858 }
3859
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3861 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3862
Arif Hussain6d2a3322013-11-17 19:50:10 -08003863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864
3865 return -EINVAL;
3866 }
3867
3868 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3869
3870 if((wrqu->retry.flags & IW_RETRY_LONG))
3871 {
3872 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3873 {
c_hpothub8245442013-11-20 23:41:09 +05303874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3875 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 return -EIO;
3877 }
3878 }
3879 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3880 {
3881 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3882 {
c_hpothub8245442013-11-20 23:41:09 +05303883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3884 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 return -EIO;
3886 }
3887 }
3888 }
3889 else
3890 {
3891 return -EOPNOTSUPP;
3892 }
3893
Arif Hussain6d2a3322013-11-17 19:50:10 -08003894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003895
3896 EXIT();
3897
3898 return 0;
3899
3900}
3901
3902static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3903 union iwreq_data *wrqu, char *extra)
3904{
3905 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3906 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3907 v_U32_t retry = 0;
3908
3909 ENTER();
3910
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003911 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3912 {
3913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3914 "%s:LOGP in Progress. Ignore!!!", __func__);
3915 return -EBUSY;
3916 }
3917
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 if((wrqu->retry.flags & IW_RETRY_LONG))
3919 {
3920 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3921
3922 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3923 {
c_hpothub8245442013-11-20 23:41:09 +05303924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3925 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 return -EIO;
3927 }
3928
3929 wrqu->retry.value = retry;
3930 }
3931 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3932 {
3933 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3934
3935 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3936 {
c_hpothub8245442013-11-20 23:41:09 +05303937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3938 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 return -EIO;
3940 }
3941
3942 wrqu->retry.value = retry;
3943 }
3944 else {
3945 return -EOPNOTSUPP;
3946 }
3947
Arif Hussain6d2a3322013-11-17 19:50:10 -08003948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003949
3950 EXIT();
3951
3952 return 0;
3953}
3954
3955static int iw_set_mlme(struct net_device *dev,
3956 struct iw_request_info *info,
3957 union iwreq_data *wrqu,
3958 char *extra)
3959{
3960 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3961 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3962 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3963 eHalStatus status = eHAL_STATUS_SUCCESS;
3964
3965 ENTER();
3966
3967 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3968 {
3969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3970 "%s:LOGP in Progress. Ignore!!!",__func__);
3971 return 0;
3972 }
3973
3974 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3975 switch (mlme->cmd) {
3976 case IW_MLME_DISASSOC:
3977 case IW_MLME_DEAUTH:
3978
3979 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3980 {
3981 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3982
3983 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3984 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3985
3986 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3987 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3988
Jeff Johnson43971f52012-07-17 12:26:56 -07003989 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303990 {
3991 long ret;
3992 ret = wait_for_completion_interruptible_timeout(
3993 &pAdapter->disconnect_comp_var,
3994 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3995 if (ret <= 0)
3996 hddLog(VOS_TRACE_LEVEL_ERROR,
3997 FL("failed wait on disconnect_comp_var %ld"), ret);
3998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08004000 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004001 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07004002
4003 /* Resetting authKeyMgmt */
4004 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
4005
4006 netif_tx_disable(dev);
4007 netif_carrier_off(dev);
4008
4009 }
4010 else
4011 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004012 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 -07004013 }
4014 break;
4015 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004016 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 return -EINVAL;
4018 }//end of switch
4019
4020 EXIT();
4021
4022 return status;
4023
4024}
4025
4026/* set param sub-ioctls */
4027static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
4028 union iwreq_data *wrqu, char *extra)
4029{
4030 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4031 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4032 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4033 int *value = (int *)extra;
4034 int sub_cmd = value[0];
4035 int set_value = value[1];
4036 int ret = 0; /* success */
4037 int enable_pbm, enable_mp;
4038#ifdef CONFIG_HAS_EARLYSUSPEND
4039 v_U8_t nEnableSuspendOld;
4040#endif
4041 INIT_COMPLETION(pWextState->completion_var);
4042
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004043 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4044 {
4045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4046 "%s:LOGP in Progress. Ignore!!!", __func__);
4047 return -EBUSY;
4048 }
4049
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 switch(sub_cmd)
4051 {
4052 case WE_SET_11D_STATE:
4053 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004054 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004055 memset(&smeConfig, 0x00, sizeof(smeConfig));
4056
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4058
4059 sme_GetConfigParam(hHal,&smeConfig);
4060 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4061
Arif Hussain6d2a3322013-11-17 19:50:10 -08004062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004063
4064 sme_UpdateConfig(hHal,&smeConfig);
4065 }
4066 else {
4067 return -EINVAL;
4068 }
4069 break;
4070 }
4071
4072 case WE_WOWL:
4073 {
4074 switch (set_value)
4075 {
4076 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004077 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 break;
4079 case 0x01:
4080 case 0x02:
4081 case 0x03:
4082 enable_mp = (set_value & 0x01) ? 1 : 0;
4083 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004084 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4086 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4087 break;
4088 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004089 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 ret = -EINVAL;
4091 break;
4092 }
4093
4094 break;
4095 }
4096 case WE_SET_POWER:
4097 {
4098 switch (set_value)
4099 {
4100 case 0: //Full Power
4101 {
4102 struct statsContext context;
4103 eHalStatus status;
4104
4105 init_completion(&context.completion);
4106
4107 context.pAdapter = pAdapter;
4108 context.magic = POWER_CONTEXT_MAGIC;
4109
4110 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4111 iw_power_callback_fn, &context,
4112 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004113 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 {
4115 int lrc = wait_for_completion_interruptible_timeout(
4116 &context.completion,
4117 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004118
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 if (lrc <= 0)
4120 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004121 hddLog(VOS_TRACE_LEVEL_ERROR,
4122 "%s: SME %s while requesting fullpower",
4123 __func__, (0 == lrc) ?
4124 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 }
4126 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004127 /* either we have a response or we timed out. if we timed
4128 out there is a race condition such that the callback
4129 function could be executing at the same time we are. of
4130 primary concern is if the callback function had already
4131 verified the "magic" but had not yet set the completion
4132 variable when a timeout occurred. we serialize these
4133 activities by invalidating the magic while holding a
4134 shared spinlock which will cause us to block if the
4135 callback is currently executing */
4136 spin_lock(&hdd_context_lock);
4137 context.magic = 0;
4138 spin_unlock(&hdd_context_lock);
4139
Arif Hussain6d2a3322013-11-17 19:50:10 -08004140 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 break;
4142 }
4143 case 1: //Enable BMPS
4144 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4145 break;
4146 case 2: //Disable BMPS
4147 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4148 break;
4149 case 3: //Request Bmps
4150 {
4151 struct statsContext context;
4152 eHalStatus status;
4153
4154 init_completion(&context.completion);
4155
4156 context.pAdapter = pAdapter;
4157 context.magic = POWER_CONTEXT_MAGIC;
4158
4159 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4160 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004161 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 {
4163 int lrc = wait_for_completion_interruptible_timeout(
4164 &context.completion,
4165 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 if (lrc <= 0)
4167 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004168 hddLog(VOS_TRACE_LEVEL_ERROR,
4169 "%s: SME %s while requesting BMPS",
4170 __func__, (0 == lrc) ? "timeout" :
4171 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004172 }
4173 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004174 /* either we have a response or we timed out. if we
4175 timed out there is a race condition such that the
4176 callback function could be executing at the same
4177 time we are. of primary concern is if the callback
4178 function had already verified the "magic" but had
4179 not yet set the completion variable when a timeout
4180 occurred. we serialize these activities by
4181 invalidating the magic while holding a shared
4182 spinlock which will cause us to block if the
4183 callback is currently executing */
4184 spin_lock(&hdd_context_lock);
4185 context.magic = 0;
4186 spin_unlock(&hdd_context_lock);
4187
Arif Hussain6d2a3322013-11-17 19:50:10 -08004188 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 break;
4190 }
4191 case 4: //Enable IMPS
4192 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4193 break;
4194 case 5: //Disable IMPS
4195 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4196 break;
4197 case 6: //Enable Standby
4198 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4199 break;
4200 case 7: //Disable Standby
4201 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4202 break;
4203 case 8: //Request Standby
4204#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004205#endif
4206 break;
4207 case 9: //Start Auto Bmps Timer
4208 sme_StartAutoBmpsTimer(hHal);
4209 break;
4210 case 10://Stop Auto BMPS Timer
4211 sme_StopAutoBmpsTimer(hHal);
4212 break;
4213#ifdef CONFIG_HAS_EARLYSUSPEND
4214 case 11://suspend to standby
4215#ifdef CONFIG_HAS_EARLYSUSPEND
4216 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4217 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4219#endif
4220 break;
4221 case 12://suspend to deep sleep
4222#ifdef CONFIG_HAS_EARLYSUSPEND
4223 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4224 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4226#endif
4227 break;
4228 case 13://resume from suspend
4229#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004230#endif
4231 break;
4232#endif
4233 case 14://reset wlan (power down/power up)
4234 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4235 break;
4236 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004237 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 ret = -EINVAL;
4239 break;
4240 }
4241 break;
4242 }
4243
4244 case WE_SET_MAX_ASSOC:
4245 {
4246 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4247 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4248 {
4249 ret = -EINVAL;
4250 }
4251 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4252 set_value, NULL, eANI_BOOLEAN_FALSE)
4253 != eHAL_STATUS_SUCCESS )
4254 {
c_hpothub8245442013-11-20 23:41:09 +05304255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4256 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 ret = -EIO;
4258 }
4259 break;
4260 }
4261
4262 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4263 {
4264 if( 0 == set_value )
4265 {
4266 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4267 }
4268 else if ( 1 == set_value )
4269 {
4270 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4271 }
4272 else
4273 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004274 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 ret = -EINVAL;
4276 }
4277 break;
4278 }
4279
4280 case WE_SET_DATA_INACTIVITY_TO:
4281 {
4282 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4283 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4284 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4285 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4286 set_value,
4287 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4288 {
4289 hddLog(LOGE,"Failure: Could not pass on "
4290 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004291 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 ret = -EINVAL;
4293 }
4294 break;
4295 }
4296 case WE_SET_MAX_TX_POWER:
4297 {
4298 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4299 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4300
4301 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4302 __func__, set_value);
4303 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4304 eHAL_STATUS_SUCCESS )
4305 {
4306 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4307 __func__);
4308 return -EIO;
4309 }
4310
4311 break;
4312 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004313 case WE_SET_MAX_TX_POWER_2_4:
4314 {
4315 hddLog(VOS_TRACE_LEVEL_INFO,
4316 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4317 __func__, set_value);
4318 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4319 eHAL_STATUS_SUCCESS)
4320 {
4321 hddLog(VOS_TRACE_LEVEL_ERROR,
4322 "%s: Setting maximum tx power failed for 2.4 GHz band",
4323 __func__);
4324 return -EIO;
4325 }
4326
4327 break;
4328 }
4329 case WE_SET_MAX_TX_POWER_5_0:
4330 {
4331 hddLog(VOS_TRACE_LEVEL_INFO,
4332 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4333 __func__, set_value);
4334 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4335 eHAL_STATUS_SUCCESS)
4336 {
4337 hddLog(VOS_TRACE_LEVEL_ERROR,
4338 "%s: Setting maximum tx power failed for 5.0 GHz band",
4339 __func__);
4340 return -EIO;
4341 }
4342
4343 break;
4344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 case WE_SET_HIGHER_DTIM_TRANSITION:
4346 {
4347 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4348 (set_value == eANI_BOOLEAN_TRUE)))
4349 {
4350 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4351 ret = -EINVAL;
4352 }
4353 else
4354 {
4355 if(pAdapter->higherDtimTransition != set_value)
4356 {
4357 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004358 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 }
4360 }
4361
4362 break;
4363 }
4364
4365 case WE_SET_TM_LEVEL:
4366 {
4367 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004368 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4370
4371 break;
4372 }
4373
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304374 case WE_ENABLE_STRICT_FCC_REG:
4375 {
4376 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4377 struct wiphy *wiphy = NULL;
4378 long lrc;
4379 int status;
4380
4381 wiphy = hddCtxt->wiphy;
4382 if(wiphy == NULL)
4383 {
4384 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4385 break;
4386 }
4387 init_completion(&hddCtxt->wiphy_channel_update_event);
4388
4389 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4390
4391 status = regulatory_hint(wiphy, "00");
4392 if(status < 0)
4393 {
4394 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4395 break;
4396 }
4397
4398 /* Wait for completion */
4399 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4400 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4401 if (lrc <= 0)
4402 {
4403 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4404 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4405 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4406 }
4407 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4408
4409 break;
4410 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004411 case WE_SET_DEBUG_LOG:
4412 {
4413 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4414 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4415 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4416 break;
4417 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304418
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 default:
4420 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004421 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 sub_cmd, set_value);
4423 break;
4424 }
4425 }
4426
4427 return ret;
4428}
4429
4430/* set param sub-ioctls */
4431static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4432 union iwreq_data *wrqu, char *extra)
4433{
4434 VOS_STATUS vstatus;
4435 int sub_cmd = wrqu->data.flags;
4436 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004437 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4439 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4440#ifdef WLAN_FEATURE_VOWIFI
4441 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4442#endif /* WLAN_FEATURE_VOWIFI */
4443
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004444 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4445 {
4446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4447 "%s:LOGP in Progress. Ignore!!!", __func__);
4448 return -EBUSY;
4449 }
4450
Arif Hussain0273cba2014-01-07 20:58:29 -08004451 /* ODD number is used for set, copy data using copy_from_user */
4452 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4453 wrqu->data.length);
4454 if (NULL == pBuffer)
4455 {
4456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4457 "mem_alloc_copy_from_user_helper fail");
4458 return -ENOMEM;
4459 }
4460
4461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4462 "%s: Received length %d", __func__, wrqu->data.length);
4463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4464 "%s: Received data %s", __func__, pBuffer);
4465
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 switch(sub_cmd)
4467 {
4468 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004470 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 break;
4472 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004474 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 break;
4476#if defined WLAN_FEATURE_VOWIFI
4477 case WE_NEIGHBOR_REPORT_REQUEST:
4478 {
4479 tRrmNeighborReq neighborReq;
4480 tRrmNeighborRspCallbackInfo callbackInfo;
4481
4482 if (pConfig->fRrmEnable)
4483 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4486 if( !neighborReq.no_ssid )
4487 {
4488 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004489 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 }
4491
4492 callbackInfo.neighborRspCallback = NULL;
4493 callbackInfo.neighborRspCallbackContext = NULL;
4494 callbackInfo.timeout = 5000; //5 seconds
4495 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4496 }
4497 else
4498 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004499 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 ret = -EINVAL;
4501 }
4502 }
4503 break;
4504#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 case WE_SET_AP_WPS_IE:
4506 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004507 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004510 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 if (VOS_STATUS_SUCCESS != vstatus)
4512 {
4513 ret = -EINVAL;
4514 }
4515 break;
4516 default:
4517 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004518 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 ret = -EINVAL;
4520 break;
4521 }
4522 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004523 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 return ret;
4525}
4526
4527/* get param sub-ioctls */
4528static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4529 union iwreq_data *wrqu, char *extra)
4530{
4531 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4532 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4533 int *value = (int *)extra;
4534 int ret = 0; /* success */
4535
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004536 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4537 {
4538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4539 "%s:LOGP in Progress. Ignore!!!", __func__);
4540 return -EBUSY;
4541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004542
4543 switch (value[0])
4544 {
4545 case WE_GET_11D_STATE:
4546 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004547 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304549
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4551
Arif Hussain6d2a3322013-11-17 19:50:10 -08004552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004553
4554 break;
4555 }
4556
4557 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 break;
4560
4561 case WE_PMC_STATE:
4562 {
4563 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 break;
4566 }
4567 case WE_GET_WLAN_DBG:
4568 {
4569 vos_trace_display();
4570 *value = 0;
4571 break;
4572 }
4573 case WE_MODULE_DOWN_IND:
4574 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4577#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4580#endif
4581 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4582
4583 *value = 0;
4584 break;
4585 }
4586 case WE_GET_MAX_ASSOC:
4587 {
4588 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4589 {
c_hpothub8245442013-11-20 23:41:09 +05304590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4591 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 ret = -EIO;
4593 }
4594 break;
4595 }
4596
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 case WE_GET_WDI_DBG:
4598 {
4599 wpalTraceDisplay();
4600 *value = 0;
4601 break;
4602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004603
4604 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4605 {
4606 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4607 break;
4608 }
4609 case WE_GET_CONCURRENCY_MODE:
4610 {
4611 *value = hdd_get_concurrency_mode ( );
4612
Arif Hussain6d2a3322013-11-17 19:50:10 -08004613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 break;
4615 }
4616
4617 default:
4618 {
4619 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4620 break;
4621 }
4622 }
4623
4624 return ret;
4625}
4626
4627/* set param sub-ioctls */
4628int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4629 union iwreq_data *wrqu, char *extra)
4630{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004631 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 int *value = (int *)extra;
4633 int sub_cmd = value[0];
4634 int ret = 0;
4635
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004636 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4637 {
4638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4639 "%s:LOGP in Progress. Ignore!!!", __func__);
4640 return -EBUSY;
4641 }
4642
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 switch(sub_cmd)
4644 {
4645 case WE_SET_WLAN_DBG:
4646 {
4647 vos_trace_setValue( value[1], value[2], value[3]);
4648 break;
4649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 case WE_SET_WDI_DBG:
4651 {
4652 wpalTraceSetLevel( value[1], value[2], value[3]);
4653 break;
4654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 case WE_SET_SAP_CHANNELS:
4656 {
4657 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4658 break;
4659 }
4660
4661 default:
4662 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004663 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 break;
4665 }
4666 }
4667 return ret;
4668}
4669
4670static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4671 union iwreq_data *wrqu, char *extra)
4672{
4673 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4674 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004675#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004676 hdd_wext_state_t *pWextState;
4677#endif
4678
4679 if (pAdapter == NULL)
4680 {
4681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4682 "%s: pAdapter is NULL!", __func__);
4683 return -EINVAL;
4684 }
4685#ifdef WLAN_FEATURE_11W
4686 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004687#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004688
Yue Ma3ede6052013-08-29 00:33:26 -07004689 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4690 {
4691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4692 "%s: HDD Context is NULL!", __func__);
4693
4694 return -EINVAL;
4695 }
4696
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004697 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4698 {
4699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4700 "%s:LOGP in Progress. Ignore!!!", __func__);
4701 return -EBUSY;
4702 }
4703
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 switch(sub_cmd)
4705 {
4706 case WE_WLAN_VERSION:
4707 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004708 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 break;
4710 }
4711
4712 case WE_GET_STATS:
4713 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304714 tHalHandle hHal = NULL;
4715 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4717 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4718 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4719
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304720
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 snprintf(extra, WE_MAX_STR_LEN,
4722 "\nTransmit"
4723 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4724 "\n dropped BK %u, BE %u, VI %u, VO %u"
4725 "\n classified BK %u, BE %u, VI %u, VO %u"
4726 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4727 "\n queued BK %u, BE %u, VI %u, VO %u"
4728 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004729 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 "\n fetched BK %u, BE %u, VI %u, VO %u"
4731 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4732 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004733 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 "\n flushed BK %u, BE %u, VI %u, VO %u"
4735 "\n\nReceive"
4736 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4737 "\n\nResetsStats"
4738 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4739 "\n",
4740 pStats->txXmitCalled,
4741 pStats->txXmitDropped,
4742 pStats->txXmitBackPressured,
4743 pStats->txXmitQueued,
4744
4745 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4746 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4747 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4748 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4749
4750 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4751 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4752 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4753 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4754
4755 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4756 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4757 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4758 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4759
4760 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4761 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4762 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4763 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4764
4765 pStats->txFetched,
4766 pStats->txFetchEmpty,
4767 pStats->txFetchLowResources,
4768 pStats->txFetchDequeueError,
4769
4770 pStats->txFetchDequeued,
4771 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004772 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 pStats->txCompleted,
4774 pStats->txFlushed,
4775
4776 pStats->txFetchedAC[WLANTL_AC_BK],
4777 pStats->txFetchedAC[WLANTL_AC_BE],
4778 pStats->txFetchedAC[WLANTL_AC_VI],
4779 pStats->txFetchedAC[WLANTL_AC_VO],
4780
4781 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4782 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4783 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4784 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4785
4786 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4787 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4788 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4789 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4790
Ravi Joshi41914632013-10-21 23:02:21 -07004791 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4792 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4793 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4794 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4795
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 pStats->txFlushedAC[WLANTL_AC_BK],
4797 pStats->txFlushedAC[WLANTL_AC_BE],
4798 pStats->txFlushedAC[WLANTL_AC_VI],
4799 pStats->txFlushedAC[WLANTL_AC_VO],
4800
4801 pStats->rxChains,
4802 pStats->rxPackets,
4803 pStats->rxDropped,
4804 pStats->rxDelivered,
4805 pStats->rxRefused,
4806
4807 pResetStats->totalLogpResets,
4808 pResetStats->totalCMD53Failures,
4809 pResetStats->totalMutexReadFailures,
4810 pResetStats->totalMIFErrorFailures,
4811 pResetStats->totalFWHearbeatFailures,
4812 pResetStats->totalUnknownExceptions
4813 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304814 wrqu->data.length = strlen(extra);
4815
4816 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
4817
4818 if (hHal)
4819 pMac = PMAC_STRUCT( hHal );
4820
4821 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
4822 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
4823 snprintf(extra+wrqu->data.length, pmmStatsLength,
4824 "\n BMPS sleepcnt %llx, BMPS awakecnt %llx"
4825 "\n BMPS sleepreqfailcnt %llx, BMPS wakeupreqfailcnt %llx"
4826 "\n IMPS sleepcnt %llx, IMPS awakecnt %llx"
4827 "\n IMPS sleeperrcnt %llx, IMPS wakeuperrcnt %llx, IMPS lasterr %llx"
4828 "\n",
4829 pMac->pmm.BmpscntSleep,
4830 pMac->pmm.BmpscntAwake,
4831 pMac->pmm.BmpsSleeReqFailCnt,
4832 pMac->pmm.BmpsWakeupReqFailCnt,
4833 pMac->pmm.ImpsCntSleep,
4834 pMac->pmm.ImpsCntAwake,
4835 pMac->pmm.ImpsSleepErrCnt,
4836 pMac->pmm.ImpsWakeupErrCnt,
4837 pMac->pmm.ImpsLastErr
4838 );
4839 }
4840
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 wrqu->data.length = strlen(extra)+1;
4842 break;
4843 }
4844
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304845/* The case prints the current state of the HDD, SME, CSR, PE, TL
4846 *it can be extended for WDI Global State as well.
4847 *And currently it only checks P2P_CLIENT adapter.
4848 *P2P_DEVICE and P2P_GO have not been added as of now.
4849*/
4850 case WE_GET_STATES:
4851 {
4852 int buf = 0, len = 0;
4853 int adapter_num = 0;
4854 int count = 0, check = 1;
4855
4856 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004857 tHalHandle hHal = NULL;
4858 tpAniSirGlobal pMac = NULL;
4859 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304860
4861 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4862 hdd_adapter_t *useAdapter = NULL;
4863
4864 /* Print wlan0 or p2p0 states based on the adapter_num
4865 *by using the correct adapter
4866 */
4867 while ( adapter_num < 2 )
4868 {
4869 if ( WLAN_ADAPTER == adapter_num )
4870 {
4871 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004872 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304873 "\n\n wlan0 States:-");
4874 len += buf;
4875 }
4876 else if ( P2P_ADAPTER == adapter_num )
4877 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004878 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304879 "\n\n p2p0 States:-");
4880 len += buf;
4881
4882 if( !pHddCtx )
4883 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004884 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304885 "\n pHddCtx is NULL");
4886 len += buf;
4887 break;
4888 }
4889
4890 /*Printing p2p0 states only in the case when the device is
4891 configured as a p2p_client*/
4892 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4893 if ( !useAdapter )
4894 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004895 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304896 "\n Device not configured as P2P_CLIENT.");
4897 len += buf;
4898 break;
4899 }
4900 }
4901
4902 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004903 if (!hHal) {
4904 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4905 "\n pMac is NULL");
4906 len += buf;
4907 break;
4908 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304909 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004910 if (!pMac) {
4911 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4912 "\n pMac is NULL");
4913 len += buf;
4914 break;
4915 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304916 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4917 if( !pHddStaCtx )
4918 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004919 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304920 "\n pHddStaCtx is NULL");
4921 len += buf;
4922 break;
4923 }
4924
4925 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4926
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004927 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304928 "\n HDD Conn State - %s "
4929 "\n \n SME State:"
4930 "\n Neighbour Roam State - %s"
4931 "\n CSR State - %s"
4932 "\n CSR Substate - %s"
4933 "\n \n TL STA %d State: %s",
4934 macTraceGetHDDWlanConnState(
4935 pHddStaCtx->conn_info.connState),
4936 macTraceGetNeighbourRoamState(
4937 pMac->roam.neighborRoamInfo.neighborRoamState),
4938 macTraceGetcsrRoamState(
4939 pMac->roam.curState[useAdapter->sessionId]),
4940 macTraceGetcsrRoamSubState(
4941 pMac->roam.curSubState[useAdapter->sessionId]),
4942 pHddStaCtx->conn_info.staId[0],
4943 macTraceGetTLState(tlState)
4944 );
4945 len += buf;
4946 adapter_num++;
4947 }
4948
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004949 if (pMac) {
4950 /* Printing Lim State starting with global lim states */
4951 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4952 "\n \n LIM STATES:-"
4953 "\n Global Sme State - %s "\
4954 "\n Global mlm State - %s "\
4955 "\n",
4956 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4957 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4958 );
4959 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304960
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004961 /*printing the PE Sme and Mlm states for valid lim sessions*/
4962 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304963 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004964 if ( pMac->lim.gpSession[count].valid )
4965 {
4966 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4967 "\n Lim Valid Session %d:-"
4968 "\n PE Sme State - %s "
4969 "\n PE Mlm State - %s "
4970 "\n",
4971 check,
4972 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4973 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4974 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304975
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004976 len += buf;
4977 check++;
4978 }
4979 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304980 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304981 }
4982
4983 wrqu->data.length = strlen(extra)+1;
4984 break;
4985 }
4986
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 case WE_GET_CFG:
4988 {
4989 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4990 wrqu->data.length = strlen(extra)+1;
4991 break;
4992 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004993#ifdef WLAN_FEATURE_11AC
4994 case WE_GET_RSSI:
4995 {
4996 v_S7_t s7Rssi = 0;
4997 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4998 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4999 wrqu->data.length = strlen(extra)+1;
5000 break;
5001 }
5002#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305003
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005004#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005005 case WE_GET_ROAM_RSSI:
5006 {
5007 v_S7_t s7Rssi = 0;
5008 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
5009 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
5010 wrqu->data.length = strlen(extra)+1;
5011 break;
5012 }
5013#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 case WE_GET_WMM_STATUS:
5015 {
5016 snprintf(extra, WE_MAX_STR_LEN,
5017 "\nDir: 0=up, 1=down, 3=both\n"
5018 "|------------------------|\n"
5019 "|AC | ACM |Admitted| Dir |\n"
5020 "|------------------------|\n"
5021 "|VO | %d | %3s | %d |\n"
5022 "|VI | %d | %3s | %d |\n"
5023 "|BE | %d | %3s | %d |\n"
5024 "|BK | %d | %3s | %d |\n"
5025 "|------------------------|\n",
5026 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
5027 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
5028 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
5029 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
5030 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
5031 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
5032 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
5033 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
5034 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5035 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5036 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5037 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5038
Jeff Johnsone7245742012-09-05 17:12:55 -07005039
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 wrqu->data.length = strlen(extra)+1;
5041 break;
5042 }
5043 case WE_GET_CHANNEL_LIST:
5044 {
5045 VOS_STATUS status;
5046 v_U8_t i, len;
5047 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305048 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5049 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5050 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 tChannelListInfo channel_list;
5052
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005053 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005055 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 return -EINVAL;
5059 }
5060 buf = extra;
5061
5062 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005063 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5064 * needed = 5 * number of channels. Check ifsufficient
5065 * buffer is available and then proceed to fill the buffer.
5066 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5068 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005069 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005070 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005071 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 return -EINVAL;
5073 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005074 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5075 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305076 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5077 {
5078 //Printing Country code in getChannelList
5079 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5080 {
5081 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5082 "%c ", pBuf[i]);
5083 }
5084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 for(i = 0 ; i < channel_list.num_channels; i++)
5086 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005087 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 }
5090 wrqu->data.length = strlen(extra)+1;
5091
5092 break;
5093 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005094#ifdef FEATURE_WLAN_TDLS
5095 case WE_GET_TDLS_PEERS:
5096 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005097 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005098 break;
5099 }
5100#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005101#ifdef WLAN_FEATURE_11W
5102 case WE_GET_11W_INFO:
5103 {
5104 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5105
5106 snprintf(extra, WE_MAX_STR_LEN,
5107 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5108 "\n Number of Unprotected Disassocs %d"
5109 "\n Number of Unprotected Deauths %d",
5110 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5111 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5112 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5113 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5114 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5115
5116 wrqu->data.length = strlen(extra)+1;
5117 break;
5118 }
5119#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305120 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005122 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 break;
5124 }
5125 }
5126
5127 return 0;
5128}
5129
5130/* action sub-ioctls */
5131static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5132 union iwreq_data *wrqu, char *extra)
5133{
5134 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305135 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005136 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305137 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005138
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005139 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5140 {
5141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5142 "%s:LOGP in Progress. Ignore!!!", __func__);
5143 return -EBUSY;
5144 }
5145
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305146 /* helper function to get iwreq_data with compat handling. */
5147 if (hdd_priv_get_data(&s_priv_data, wrqu))
5148 {
5149 return -EINVAL;
5150 }
5151
5152 sub_cmd = s_priv_data.flags;
5153
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 switch (sub_cmd)
5155 {
5156 case WE_CLEAR_STATS:
5157 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5160 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5161 break;
5162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 case WE_INIT_AP:
5164 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305165 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5166
5167 /* As Soft AP mode might been changed to STA already with
5168 * killing of Hostapd, need to find the adpater by name
5169 * rather than mode */
5170 hdd_adapter_t* pAdapter_to_stop =
5171 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5172 if( pAdapter_to_stop )
5173 {
5174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5175 "Adapter with name softap.0 already "
5176 "exist, ignoring the request.\nRemove the "
5177 "adapter and try again\n");
5178 break;
5179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 pr_info("Init AP trigger\n");
5181 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5182 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5183 break;
5184 }
5185 case WE_STOP_AP:
5186 {
5187 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5188 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5189 * this is a dead code and need to find the adpater by name rather than mode */
5190 hdd_adapter_t* pAdapter_to_stop =
5191 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5192 if( pAdapter_to_stop )
5193 {
5194 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5195
5196 pr_info("Stopping AP mode\n");
5197
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305198 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5199 {
5200 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5201 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5202 }
5203
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 /*Make sure that pAdapter cleaned properly*/
5205 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5206 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5207 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5208
5209 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5210 pAdapter_to_stop->macAddressCurrent.bytes);
5211 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5212 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305213
5214 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5215 {
5216 /* put the device back into BMPS */
5217 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 }
5220 else
5221 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005222 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 }
5224
5225 break;
5226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005227#ifdef WLAN_BTAMP_FEATURE
5228 case WE_ENABLE_AMP:
5229 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 WLANBAP_RegisterWithHCI(pAdapter);
5232 break;
5233 }
5234 case WE_DISABLE_AMP:
5235 {
5236 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5237 VOS_STATUS status;
5238
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005240
5241 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5242 status = WLANBAP_StopAmp();
5243 if(VOS_STATUS_SUCCESS != status )
5244 {
5245 pHddCtx->isAmpAllowed = VOS_TRUE;
5246 hddLog(VOS_TRACE_LEVEL_FATAL,
5247 "%s: Failed to stop AMP", __func__);
5248 }
5249 else
5250 {
5251 //a state m/c implementation in PAL is TBD to avoid this delay
5252 msleep(500);
5253 pHddCtx->isAmpAllowed = VOS_FALSE;
5254 WLANBAP_DeregisterFromHCI();
5255 }
5256
5257 break;
5258 }
5259#endif
5260
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005261 case WE_ENABLE_DXE_STALL_DETECT:
5262 {
schang6295e542013-03-12 15:31:23 -07005263 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5264 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005265 break;
5266 }
5267 case WE_DISPLAY_DXE_SNAP_SHOT:
5268 {
schang6295e542013-03-12 15:31:23 -07005269 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5270 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005271 break;
5272 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305273 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5274 {
5275 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5276 hdd_wmm_tx_snapshot(pAdapter);
5277 WLANTL_TLDebugMessage(VOS_TRUE);
5278 break;
5279 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305280
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305281 case WE_STOP_OBSS_SCAN:
5282 {
5283 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5284 2.OBSS scan is stopped by Firmware during the disassociation
5285 3.OBSS stop comamnd is added for debugging purpose*/
5286 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5287 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005288
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305289 if (pAdapter == NULL)
5290 {
5291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5292 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305293 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305294 }
5295 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5296 if (pMac == NULL)
5297 {
5298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5299 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305300 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305301 }
5302 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5303 }
5304 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 default:
5306 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005307 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 break;
5309 }
5310 }
5311
5312 return ret;
5313}
5314
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305315void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5316{
5317 /*
5318 * Function to display HDD WMM information
5319 * for Tx Queues.
5320 * Prints globala as well as per client depending
5321 * whether the clients are registered or not.
5322 */
5323 int i = 0, j = 0;
5324 for ( i=0; i< NUM_TX_QUEUES; i++)
5325 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305326 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005327 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305328 i, pAdapter->wmm_tx_queue[i].count,
5329 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305330 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305331 }
5332
5333 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5334 {
5335 if(pAdapter->aStaInfo[i].isUsed)
5336 {
5337 hddLog(LOGE, "******STAIndex: %d*********", i);
5338 for ( j=0; j< NUM_TX_QUEUES; j++)
5339 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305340 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005341 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305342 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5343 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5344 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305345 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305346 }
5347 }
5348 }
5349
5350}
Jeff Johnson295189b2012-06-20 16:38:30 -07005351int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5352 union iwreq_data *wrqu, char *extra)
5353{
5354 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5355 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05305356 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 int apps_args[MAX_VAR_ARGS] = {0};
Girish Gowlid4522fd2014-06-14 17:20:27 +05305358 int num_args;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005359 hdd_station_ctx_t *pStaCtx = NULL ;
5360 hdd_ap_ctx_t *pAPCtx = NULL;
5361 int cmd = 0;
5362 int staId = 0;
Girish Gowlid4522fd2014-06-14 17:20:27 +05305363 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005364
Girish Gowlid4522fd2014-06-14 17:20:27 +05305365 /* helper function to get iwreq_data with compat handling. */
5366 if (hdd_priv_get_data(&s_priv_data, wrqu))
5367 {
5368 return -EINVAL;
5369 }
5370
5371 if (NULL == s_priv_data.pointer)
5372 {
5373 return -EINVAL;
5374 }
5375
5376 sub_cmd = s_priv_data.flags;
5377 num_args = s_priv_data.length;
5378
5379 hddLog(LOG1, "%s: Received length %d", __func__, s_priv_data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005380
5381 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5382 {
5383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5384 "%s:LOGP in Progress. Ignore!!!", __func__);
5385 return -EBUSY;
5386 }
5387
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 if (num_args > MAX_VAR_ARGS)
5389 {
5390 num_args = MAX_VAR_ARGS;
5391 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005392
5393 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlid4522fd2014-06-14 17:20:27 +05305394 if (copy_from_user(apps_args, s_priv_data.pointer, (sizeof(int)) * num_args))
Arif Hussain0273cba2014-01-07 20:58:29 -08005395 {
5396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5397 "%s: failed to copy data to user buffer", __func__);
5398 return -EFAULT;
5399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005400
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005401 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5402 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5403 {
5404 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5405 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5406 {
5407 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5408 staId = pStaCtx->conn_info.staId[0];
5409 }
5410 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5411 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5412 {
5413 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5414 staId = pAPCtx->uBCStaId;
5415 }
5416 else
5417 {
5418 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5419 return 0;
5420 }
5421 }
5422
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 switch (sub_cmd)
5424 {
5425 case WE_LOG_DUMP_CMD:
5426 {
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305427 vos_ssr_protect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005429 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 apps_args[3], apps_args[4]);
5431
5432 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5433 apps_args[3], apps_args[4]);
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305434 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005435
5436 }
5437 break;
5438
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 case WE_P2P_NOA_CMD:
5440 {
5441 p2p_app_setP2pPs_t p2pNoA;
5442
5443 p2pNoA.opp_ps = apps_args[0];
5444 p2pNoA.ctWindow = apps_args[1];
5445 p2pNoA.duration = apps_args[2];
5446 p2pNoA.interval = apps_args[3];
5447 p2pNoA.count = apps_args[4];
5448 p2pNoA.single_noa_duration = apps_args[5];
5449 p2pNoA.psSelection = apps_args[6];
5450
5451 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5452 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005453 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5455
5456 hdd_setP2pPs(dev, &p2pNoA);
5457
5458 }
5459 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005460
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305461 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5462 {
5463 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5464 __func__, apps_args[0], apps_args[1]);
5465 vosTraceEnable(apps_args[0], apps_args[1]);
5466 }
5467 break;
5468
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005469 case WE_MTRACE_DUMP_CMD:
5470 {
5471 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5472 "bitmask_of_module %d ",
5473 __func__, apps_args[0], apps_args[1], apps_args[2],
5474 apps_args[3]);
5475 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5476 apps_args[2], apps_args[3]);
5477
5478 }
5479 break;
5480
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005481 case WE_MCC_CONFIG_CREDENTIAL :
5482 {
5483 cmd = 287; //Command should be updated if there is any change
5484 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005485 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005486 {
5487 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5488 }
5489 else
5490 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005491 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005492 return 0;
5493 }
5494 }
5495 break;
5496
5497 case WE_MCC_CONFIG_PARAMS :
5498 {
5499 cmd = 288; //command Should be updated if there is any change
5500 // in the Riva dump command
5501 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5502 }
5503 break;
5504
Chilam NG571c65a2013-01-19 12:27:36 +05305505#ifdef FEATURE_WLAN_TDLS
5506 case WE_TDLS_CONFIG_PARAMS :
5507 {
5508 tdls_config_params_t tdlsParams;
5509
Chilam Ng01120412013-02-19 18:32:21 -08005510 tdlsParams.tdls = apps_args[0];
5511 tdlsParams.tx_period_t = apps_args[1];
5512 tdlsParams.tx_packet_n = apps_args[2];
5513 tdlsParams.discovery_period_t = apps_args[3];
5514 tdlsParams.discovery_tries_n = apps_args[4];
5515 tdlsParams.idle_timeout_t = apps_args[5];
5516 tdlsParams.idle_packet_n = apps_args[6];
5517 tdlsParams.rssi_hysteresis = apps_args[7];
5518 tdlsParams.rssi_trigger_threshold = apps_args[8];
5519 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305520
Chilam Ng01120412013-02-19 18:32:21 -08005521 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305522 }
5523 break;
5524#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 default:
5526 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005527 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5528 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 }
5530 break;
5531 }
5532
5533 return 0;
5534}
5535
5536
5537static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5538 union iwreq_data *wrqu, char *extra)
5539{
5540 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5541 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5542 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5543 int params[HDD_WLAN_WMM_PARAM_COUNT];
5544 sme_QosWmmTspecInfo tSpec;
5545 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05305546 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005547
5548 // make sure the application is sufficiently priviledged
5549 // note that the kernel will do this for "set" ioctls, but since
5550 // this ioctl wants to return status to user space it must be
5551 // defined as a "get" ioctl
5552 if (!capable(CAP_NET_ADMIN))
5553 {
5554 return -EPERM;
5555 }
5556
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005557 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5558 {
5559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5560 "%s:LOGP in Progress. Ignore!!!", __func__);
5561 return -EBUSY;
5562 }
5563
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 // we must be associated in order to add a tspec
5565 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5566 {
5567 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5568 return 0;
5569 }
5570
5571 // since we are defined to be a "get" ioctl, and since the number
5572 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05305573 // will pass down in the iwreq_data, we must copy the "set" params.
5574 // We must handle the compat for iwreq_data in 32U/64K environment.
5575
5576 // helper fucntion to get iwreq_data with compat handling.
5577 if (hdd_priv_get_data(&s_priv_data, wrqu))
5578 {
5579 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5580 return 0;
5581 }
5582
5583 // make sure all params are correctly passed to function
5584 if ((NULL == s_priv_data.pointer) ||
5585 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
5586 {
5587 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5588 return 0;
5589 }
5590
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05305592 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 {
5594 // hmmm, can't get them
5595 return -EIO;
5596 }
5597
5598 // clear the tspec
5599 memset(&tSpec, 0, sizeof(tSpec));
5600
5601 // validate the handle
5602 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5603 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5604 {
5605 // that one is reserved
5606 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5607 return 0;
5608 }
5609
5610 // validate the TID
5611 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5612 {
5613 // out of range
5614 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5615 return 0;
5616 }
5617 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5618
5619 // validate the direction
5620 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5621 {
5622 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5623 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5624 break;
5625
5626 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5627 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5628 break;
5629
5630 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5631 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5632 break;
5633
5634 default:
5635 // unknown
5636 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5637 return 0;
5638 }
5639
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305640 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5641
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 // validate the user priority
5643 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5644 {
5645 // out of range
5646 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5647 return 0;
5648 }
5649 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305650 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5651 {
5652 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5653 return 0;
5654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005655
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5657 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5658 tSpec.ts_info.psb, tSpec.ts_info.up);
5659
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5661 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5662 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5663 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5664 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5665 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5666 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5667 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5668 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5669 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5670 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5671 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5672
5673 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5674
5675 // validate the ts info ack policy
5676 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5677 {
5678 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5679 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5680 break;
5681
5682 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5683 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5684 break;
5685
5686 default:
5687 // unknown
5688 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5689 return 0;
5690 }
5691
5692 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5693 return 0;
5694}
5695
5696
5697static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5698 union iwreq_data *wrqu, char *extra)
5699{
5700 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5701 int *params = (int *)extra;
5702 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5703 v_U32_t handle;
5704
5705 // make sure the application is sufficiently priviledged
5706 // note that the kernel will do this for "set" ioctls, but since
5707 // this ioctl wants to return status to user space it must be
5708 // defined as a "get" ioctl
5709 if (!capable(CAP_NET_ADMIN))
5710 {
5711 return -EPERM;
5712 }
5713
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005714 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5715 {
5716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5717 "%s:LOGP in Progress. Ignore!!!", __func__);
5718 return -EBUSY;
5719 }
5720
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 // although we are defined to be a "get" ioctl, the params we require
5722 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5723 // is no need to copy the params from user space
5724
5725 // validate the handle
5726 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5727 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5728 {
5729 // that one is reserved
5730 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5731 return 0;
5732 }
5733
5734 *pStatus = hdd_wmm_delts(pAdapter, handle);
5735 return 0;
5736}
5737
5738
5739static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5740 union iwreq_data *wrqu, char *extra)
5741{
5742 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5743 int *params = (int *)extra;
5744 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5745 v_U32_t handle;
5746
5747 // although we are defined to be a "get" ioctl, the params we require
5748 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5749 // is no need to copy the params from user space
5750
5751 // validate the handle
5752 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5753 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5754 {
5755 // that one is reserved
5756 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5757 return 0;
5758 }
5759
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005760 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5761 {
5762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5763 "%s:LOGP in Progress. Ignore!!!", __func__);
5764 return -EBUSY;
5765 }
5766
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5768 return 0;
5769}
5770
5771
5772#ifdef FEATURE_WLAN_WAPI
5773static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5774 union iwreq_data *wrqu, char *extra)
5775{
5776 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5777 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5778 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5779 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5780
Arif Hussain7adce1b2013-11-11 22:59:34 -08005781 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005782
5783 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005784 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005785 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5786 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005787
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005788 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5789 {
5790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5791 "%s:LOGP in Progress. Ignore!!!", __func__);
5792 return -EBUSY;
5793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005794
5795 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005796 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5798 pRoamProfile->EncryptionType.numEntries = 1;
5799 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5800 pRoamProfile->mcEncryptionType.numEntries = 1;
5801 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5802
5803 pRoamProfile->AuthType.numEntries = 1;
5804 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5805 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5806 }
5807 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005808 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 }
5810 else
5811 return -EINVAL;
5812
5813 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5814
5815 return 0;
5816}
5817
5818static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5819 union iwreq_data *wrqu, char *extra)
5820{
5821 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5822 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5823
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005824 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5825 {
5826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5827 "%s:LOGP in Progress. Ignore!!!", __func__);
5828 return -EBUSY;
5829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5831
5832 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005833 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 return 0;
5835}
5836
5837static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5838 union iwreq_data *wrqu, char *extra)
5839{
5840 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5841// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5842 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5843 int i = 0, j = 0;
5844 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005845 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005846 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005847
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005848 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5849 {
5850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5851 "%s:LOGP in Progress. Ignore!!!", __func__);
5852 return -EBUSY;
5853 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005854
5855 if (NULL == pWapiAssocInfo)
5856 {
5857 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5858 "%s: WDA NULL context", __func__);
5859 VOS_ASSERT(0);
5860 return VOS_STATUS_E_FAILURE;
5861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005862
Arif Hussain6d2a3322013-11-17 19:50:10 -08005863 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 -07005864 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005866 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005867
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005868 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005870 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005871
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005872 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005873 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 for(i = 0 ; i < 16 ; i++) {
5875 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5876 for(j = 0 ; j < 16 ; j++)
5877 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5878 }
5879
5880 /* We are not using the entire IE as provided by the supplicant.
5881 * This is being calculated by SME. This is the same as in the
5882 * case of WPA. Only the auth mode information needs to be
5883 * extracted here*/
5884 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005885 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5887 }
5888
5889 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005890 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5892 }
5893 return 0;
5894}
5895
5896static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5897 union iwreq_data *wrqu, char *extra)
5898{
5899 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5900 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5901 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5902 tANI_U32 roamId = 0xFF;
5903 tANI_U8 *pKeyPtr = NULL;
5904 v_BOOL_t isConnected = TRUE;
5905 tCsrRoamSetKey setKey;
5906 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5908
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005909 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5910 {
5911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5912 "%s:LOGP in Progress. Ignore!!!", __func__);
5913 return -EBUSY;
5914 }
5915
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005917 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005918 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005919
Arif Hussain6d2a3322013-11-17 19:50:10 -08005920 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 -07005921 hddLog(LOG1,"Add Index:0x");
5922 for(i =0 ; i < 12 ; i++)
5923 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5924
Arif Hussain6d2a3322013-11-17 19:50:10 -08005925 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5927 for(i =0 ; i < 16 ; i++)
5928 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5929
Arif Hussain6d2a3322013-11-17 19:50:10 -08005930 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5932 for(i =0 ; i < 16 ; i++)
5933 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5934
Arif Hussain6d2a3322013-11-17 19:50:10 -08005935 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 for(i = 0 ; i < 16 ; i++)
5937 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5938
5939 // Clear the setkey memory
5940 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5941 // Store Key ID
5942 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5943 // SET WAPI Encryption
5944 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5945 // Key Directionn both TX and RX
5946 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5947 // the PAE role
5948 setKey.paeRole = 0 ;
5949
5950 switch ( pWapiKey->keyType )
5951 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005952 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 {
5954 isConnected = hdd_connIsConnected(pHddStaCtx);
5955 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5956 break;
5957 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005958 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 {
5960 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5961 break;
5962 }
5963 default:
5964 {
5965 //Any other option is invalid.
5966 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005967 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005969 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5971 break; // NEED RETURN FROM HERE ????
5972 }
5973 }
5974
5975 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5976 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5977 pKeyPtr = setKey.Key;
5978 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5979 pKeyPtr += pWapiKey->wpiekLen;
5980 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5981
5982 // Set the new key with SME.
5983 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5984
5985 if ( isConnected ) {
5986 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5987 if ( halStatus != eHAL_STATUS_SUCCESS )
5988 {
5989 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5990 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5991
5992 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5993 }
5994 }
5995#if 0 /// NEED TO CHECK ON THIS
5996 else
5997 {
5998 // Store the keys in the adapter to be moved to the profile & passed to
5999 // SME in the ConnectRequest if we are not yet in connected state.
6000 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
6001 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
6002
6003 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
6004 " Saving key [idx= %d] to apply when moving to connected state ",
6005 setKey.keyId );
6006
6007 }
6008#endif
6009 return halStatus;
6010}
6011
6012static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
6013 union iwreq_data *wrqu, char *extra)
6014{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006015 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006016#ifdef WLAN_DEBUG
6017 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08006018 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006019#endif
6020
6021 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006022 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006023 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006024
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006025 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
6026 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07006027
6028 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006029
6030 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6031 {
6032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6033 "%s:LOGP in Progress. Ignore!!!", __func__);
6034 return -EBUSY;
6035 }
6036
Jeff Johnson295189b2012-06-20 16:38:30 -07006037#ifdef WLAN_DEBUG
6038 for(i =0 ; i < 16 ; i++)
6039 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
6040#endif
6041
6042 return 0;
6043}
6044
6045static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
6046 union iwreq_data *wrqu, char *extra)
6047{
6048 /* Yet to implement this function, 19th April 2010 */
6049 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
6050
6051 return 0;
6052}
6053#endif /* FEATURE_WLAN_WAPI */
6054
6055#ifdef WLAN_FEATURE_VOWIFI_11R
6056//
6057//
6058// Each time the supplicant has the auth_request or reassoc request
6059// IEs ready. This is pushed to the driver. The driver will inturn use
6060// it to send out the auth req and reassoc req for 11r FT Assoc.
6061//
6062static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
6063 union iwreq_data *wrqu, char *extra)
6064{
6065 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6066 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6067 //v_CONTEXT_t pVosContext;
6068
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006069 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6070 {
6071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6072 "%s:LOGP in Progress. Ignore!!!", __func__);
6073 return -EBUSY;
6074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 if (!wrqu->data.length)
6076 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006077 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 return -EINVAL;
6079 }
6080 if (wrqu->data.pointer == NULL)
6081 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006082 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 return -EINVAL;
6084 }
6085
6086 // Added for debug on reception of Re-assoc Req.
6087 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6088 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006089 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006091 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 }
6093
6094#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08006095 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07006096#endif
6097
6098 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08006099 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 wrqu->data.length);
6101
6102 return 0;
6103}
6104#endif
6105
Amar Singhalf3a6e762013-02-19 15:06:50 -08006106static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006107 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08006109{
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006111 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006113 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006114 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006115 tpSirRcvFltMcAddrList mc_addr_list_ptr;
6116 int idx;
6117 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07006118
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006119 if (pHddCtx->isLogpInProgress)
6120 {
6121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6122 "%s:LOGP in Progress. Ignore!!!", __func__);
6123 return -EBUSY;
6124 }
6125
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306126 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
6127 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306128#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07006129
Amar Singhalf3a6e762013-02-19 15:06:50 -08006130 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6131 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006132 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006133 hddLog(VOS_TRACE_LEVEL_ERROR,
6134 "%s: vos_mem_alloc failed", __func__);
6135 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006136 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006137
6138 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6139
6140 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6141 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6142
6143 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6144 mc_addr_list_ptr->ulMulticastAddrCnt);
6145
6146 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006147 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006148 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6149 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6150
6151 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6152 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006153 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006154
Amar Singhalf3a6e762013-02-19 15:06:50 -08006155 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6156 vos_mem_free(mc_addr_list_ptr);
6157 if (eHAL_STATUS_SUCCESS != ret_val)
6158 {
6159 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6160 __func__);
6161 return -EINVAL;
6162 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306163#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306164 }
6165 else
6166 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006167
Amar Singhalf3a6e762013-02-19 15:06:50 -08006168 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6169 "%s: Set MC BC Filter Config request: %d suspend %d",
6170 __func__, pRequest->mcastBcastFilterSetting,
6171 pHddCtx->hdd_wlan_suspended);
6172
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306173 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006174
6175 if (pHddCtx->hdd_wlan_suspended)
6176 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006177 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6178 if (NULL == wlanRxpFilterParam)
6179 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306180 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006181 "%s: vos_mem_alloc failed", __func__);
6182 return -EINVAL;
6183 }
6184
Amar Singhalf3a6e762013-02-19 15:06:50 -08006185 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6186 pRequest->mcastBcastFilterSetting;
6187 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6188
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306189 hdd_conf_hostoffload(pAdapter, TRUE);
6190 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6191 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006192
6193 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6194 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306195 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006196 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6197 wlanRxpFilterParam->setMcstBcstFilter);
6198
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306199 if (eHAL_STATUS_SUCCESS !=
6200 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6201 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006202 {
6203 hddLog(VOS_TRACE_LEVEL_ERROR,
6204 "%s: Failure to execute set HW MC/BC Filter request",
6205 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006206 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006207 return -EINVAL;
6208 }
6209
Amar Singhalf3a6e762013-02-19 15:06:50 -08006210 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006212
6213 return 0;
6214}
6215
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006216static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006217 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 union iwreq_data *wrqu, char *extra)
6219{
6220 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6221 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306222 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006223 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006224
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306225 //Reset the filter to INI value as we have to clear the dynamic filter
6226 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006227
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306228 //Configure FW with new setting
6229 if (pHddCtx->hdd_wlan_suspended)
6230 {
6231 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6232 if (NULL == wlanRxpFilterParam)
6233 {
6234 hddLog(VOS_TRACE_LEVEL_ERROR,
6235 "%s: vos_mem_alloc failed", __func__);
6236 return -EINVAL;
6237 }
6238
6239 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6240 pHddCtx->configuredMcastBcastFilter;
6241 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6242
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306243 hdd_conf_hostoffload(pAdapter, TRUE);
6244 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6245 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306246
6247 if (eHAL_STATUS_SUCCESS !=
6248 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6249 wlanRxpFilterParam))
6250 {
6251 hddLog(VOS_TRACE_LEVEL_ERROR,
6252 "%s: Failure to execute set HW MC/BC Filter request",
6253 __func__);
6254 vos_mem_free(wlanRxpFilterParam);
6255 return -EINVAL;
6256 }
6257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 return 0;
6259}
6260
6261static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6262 union iwreq_data *wrqu, char *extra)
6263{
6264 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006265 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 tSirHostOffloadReq offloadRequest;
6267
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006268 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6269 {
6270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6271 "%s:LOGP in Progress. Ignore!!!", __func__);
6272 return -EBUSY;
6273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 /* Debug display of request components. */
6275 switch (pRequest->offloadType)
6276 {
6277 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006278 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 switch (pRequest->enableOrDisable)
6280 {
6281 case WLAN_OFFLOAD_DISABLE:
6282 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6283 break;
6284 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6285 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6286 case WLAN_OFFLOAD_ENABLE:
6287 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6288 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6289 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6290 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6291 }
6292 break;
6293
6294 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006295 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006296 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 switch (pRequest->enableOrDisable)
6298 {
6299 case WLAN_OFFLOAD_DISABLE:
6300 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6301 break;
6302 case WLAN_OFFLOAD_ENABLE:
6303 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6304 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6305 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6306 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6307 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6308 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6309 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6310 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6311 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6312 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6313 }
6314 }
6315
6316 /* Execute offload request. The reason that we can copy the request information
6317 from the ioctl structure to the SME structure is that they are laid out
6318 exactly the same. Otherwise, each piece of information would have to be
6319 copied individually. */
6320 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006321 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6322 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006324 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 __func__);
6326 return -EINVAL;
6327 }
6328
6329 return 0;
6330}
6331
6332static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6333 union iwreq_data *wrqu, char *extra)
6334{
6335 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006336 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 tSirKeepAliveReq keepaliveRequest;
6338
6339 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6340 {
6341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006342 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 return 0;
6344 }
6345
6346 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006347 hddLog(VOS_TRACE_LEVEL_INFO,
6348 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6349 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006350
6351 switch (pRequest->packetType)
6352 {
6353 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006354 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 break;
6356
6357 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6358
Arif Hussain6d2a3322013-11-17 19:50:10 -08006359 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006360 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006361
6362 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6363 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6364 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6365
6366 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6367 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6368 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6369
6370 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6371 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6372 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6373 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6374 break;
6375
6376 }
6377
6378 /* Execute keep alive request. The reason that we can copy the request information
6379 from the ioctl structure to the SME structure is that they are laid out
6380 exactly the same. Otherwise, each piece of information would have to be
6381 copied individually. */
6382 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6383
Arif Hussain6d2a3322013-11-17 19:50:10 -08006384 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006385
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006386 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006387 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006389 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 __func__);
6391 return -EINVAL;
6392 }
6393
6394 return 0;
6395}
6396
6397#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006398int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006399 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006400{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006401 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6402 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 int i=0;
6404
6405 if (pHddCtx->cfg_ini->disablePacketFilter)
6406 {
6407 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006408 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 return 0;
6410 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006411 if (pHddCtx->isLogpInProgress)
6412 {
6413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6414 "%s:LOGP in Progress. Ignore!!!", __func__);
6415 return -EBUSY;
6416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 /* Debug display of request components. */
6418 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006419 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006420
6421 switch (pRequest->filterAction)
6422 {
6423 case HDD_RCV_FILTER_SET:
6424 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006425 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006426
6427 packetFilterSetReq.filterId = pRequest->filterId;
6428 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6429 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006430 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 __func__, pRequest->numParams);
6432 return -EINVAL;
6433 }
6434 packetFilterSetReq.numFieldParams = pRequest->numParams;
6435 packetFilterSetReq.coalesceTime = 0;
6436 packetFilterSetReq.filterType = 1;
6437 for (i=0; i < pRequest->numParams; i++)
6438 {
6439 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6440 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6441 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6442 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6443 packetFilterSetReq.paramsData[i].reserved = 0;
6444
Arif Hussain6d2a3322013-11-17 19:50:10 -08006445 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6447 packetFilterSetReq.filterType);
6448
Arif Hussain6d2a3322013-11-17 19:50:10 -08006449 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6451
6452 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6453 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6454 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6455 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6456
Arif Hussain6d2a3322013-11-17 19:50:10 -08006457 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006458 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6459 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6460 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6461
Arif Hussain6d2a3322013-11-17 19:50:10 -08006462 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6464 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6465 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6466 }
6467
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006468 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006469 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006470 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 __func__);
6472 return -EINVAL;
6473 }
6474
6475 break;
6476
6477 case HDD_RCV_FILTER_CLEAR:
6478
Arif Hussain6d2a3322013-11-17 19:50:10 -08006479 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006480 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006482 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006484 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 __func__);
6486 return -EINVAL;
6487 }
6488 break;
6489
6490 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006491 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006492 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 return -EINVAL;
6494 }
6495 return 0;
6496}
6497
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306498int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6499 tANI_U8 sessionId)
6500{
6501 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6502 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6503
6504 if (NULL == pHddCtx)
6505 {
6506 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6507 return -EINVAL;
6508 }
6509
6510 if (pHddCtx->isLogpInProgress)
6511 {
6512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6513 "%s:LOGP in Progress. Ignore!!!", __func__);
6514 return -EBUSY;
6515 }
6516
6517 if (pHddCtx->cfg_ini->disablePacketFilter)
6518 {
6519 hddLog(VOS_TRACE_LEVEL_ERROR,
6520 "%s: Packet Filtering Disabled. Returning ",
6521 __func__ );
6522 return -EINVAL;
6523 }
6524
6525 switch (filterType)
6526 {
6527 /* For setting IPV6 MC and UC Filter we need to configure
6528 * 2 filters, one for MC and one for UC.
6529 * The Filter ID shouldn't be swapped, which results in making
6530 * UC Filter ineffective.
6531 * We have Hardcode all the values
6532 *
6533 * Reason for a seperate UC filter is because, driver need to
6534 * specify the FW that the specific filter is for unicast
6535 * otherwise FW will not pass the unicast frames by default
6536 * through the filter. This is required to avoid any performance
6537 * hits when no unicast filter is set and only MC/BC are set.
6538 * The way driver informs host is by using the MAC protocol
6539 * layer, CMP flag set to MAX, CMP Data set to 1.
6540 */
6541
6542 case HDD_FILTER_IPV6_MC_UC:
6543 /* Setting IPV6 MC Filter below
6544 */
6545 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6546 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6547 packetFilterSetReq.numFieldParams = 2;
6548 packetFilterSetReq.paramsData[0].protocolLayer =
6549 HDD_FILTER_PROTO_TYPE_MAC;
6550 packetFilterSetReq.paramsData[0].cmpFlag =
6551 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6552 packetFilterSetReq.paramsData[0].dataOffset =
6553 WLAN_HDD_80211_FRM_DA_OFFSET;
6554 packetFilterSetReq.paramsData[0].dataLength = 1;
6555 packetFilterSetReq.paramsData[0].compareData[0] =
6556 HDD_IPV6_MC_CMP_DATA;
6557
6558 packetFilterSetReq.paramsData[1].protocolLayer =
6559 HDD_FILTER_PROTO_TYPE_ARP;
6560 packetFilterSetReq.paramsData[1].cmpFlag =
6561 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6562 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6563 packetFilterSetReq.paramsData[1].dataLength = 2;
6564 packetFilterSetReq.paramsData[1].compareData[0] =
6565 HDD_IPV6_CMP_DATA_0;
6566 packetFilterSetReq.paramsData[1].compareData[1] =
6567 HDD_IPV6_CMP_DATA_1;
6568
6569
6570 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6571 &packetFilterSetReq, sessionId))
6572 {
6573 hddLog(VOS_TRACE_LEVEL_ERROR,
6574 "%s: Failure to execute Set IPv6 Mulicast Filter",
6575 __func__);
6576 return -EINVAL;
6577 }
6578
6579 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6580
6581 /*
6582 * Setting IPV6 UC Filter below
6583 */
6584 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6585 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6586 packetFilterSetReq.numFieldParams = 2;
6587 packetFilterSetReq.paramsData[0].protocolLayer =
6588 HDD_FILTER_PROTO_TYPE_MAC;
6589 packetFilterSetReq.paramsData[0].cmpFlag =
6590 HDD_FILTER_CMP_TYPE_MAX;
6591 packetFilterSetReq.paramsData[0].dataOffset = 0;
6592 packetFilterSetReq.paramsData[0].dataLength = 1;
6593 packetFilterSetReq.paramsData[0].compareData[0] =
6594 HDD_IPV6_UC_CMP_DATA;
6595
6596 packetFilterSetReq.paramsData[1].protocolLayer =
6597 HDD_FILTER_PROTO_TYPE_ARP;
6598 packetFilterSetReq.paramsData[1].cmpFlag =
6599 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6600 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6601 packetFilterSetReq.paramsData[1].dataLength = 2;
6602 packetFilterSetReq.paramsData[1].compareData[0] =
6603 HDD_IPV6_CMP_DATA_0;
6604 packetFilterSetReq.paramsData[1].compareData[1] =
6605 HDD_IPV6_CMP_DATA_1;
6606
6607 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6608 &packetFilterSetReq, sessionId))
6609 {
6610 hddLog(VOS_TRACE_LEVEL_ERROR,
6611 "%s: Failure to execute Set IPv6 Unicast Filter",
6612 __func__);
6613 return -EINVAL;
6614 }
6615
6616 break;
6617
6618 case HDD_FILTER_IPV6_MC:
6619 /*
6620 * IPV6 UC Filter might be already set,
6621 * clear the UC Filter. As the Filter
6622 * IDs are static, we can directly clear it.
6623 */
6624 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6625 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6626 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6627 &packetFilterClrReq, sessionId))
6628 {
6629 hddLog(VOS_TRACE_LEVEL_ERROR,
6630 "%s: Failure to execute Clear IPv6 Unicast Filter",
6631 __func__);
6632 return -EINVAL;
6633 }
6634
6635 /*
6636 * Setting IPV6 MC Filter below
6637 */
6638 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6639 packetFilterSetReq.numFieldParams = 2;
6640 packetFilterSetReq.paramsData[0].protocolLayer =
6641 HDD_FILTER_PROTO_TYPE_MAC;
6642 packetFilterSetReq.paramsData[0].cmpFlag =
6643 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6644 packetFilterSetReq.paramsData[0].dataOffset =
6645 WLAN_HDD_80211_FRM_DA_OFFSET;
6646 packetFilterSetReq.paramsData[0].dataLength = 1;
6647 packetFilterSetReq.paramsData[0].compareData[0] =
6648 HDD_IPV6_MC_CMP_DATA;
6649
6650 packetFilterSetReq.paramsData[1].protocolLayer =
6651 HDD_FILTER_PROTO_TYPE_ARP;
6652 packetFilterSetReq.paramsData[1].cmpFlag =
6653 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6654 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6655 packetFilterSetReq.paramsData[1].dataLength = 2;
6656 packetFilterSetReq.paramsData[1].compareData[0] =
6657 HDD_IPV6_CMP_DATA_0;
6658 packetFilterSetReq.paramsData[1].compareData[1] =
6659 HDD_IPV6_CMP_DATA_1;
6660
6661
6662 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6663 &packetFilterSetReq, sessionId))
6664 {
6665 hddLog(VOS_TRACE_LEVEL_ERROR,
6666 "%s: Failure to execute Set IPv6 Multicast Filter",
6667 __func__);
6668 return -EINVAL;
6669 }
6670 break;
6671
6672 default :
6673 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6674 "%s: Packet Filter Request: Invalid",
6675 __func__);
6676 return -EINVAL;
6677 }
6678 return 0;
6679}
6680
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306681void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006682{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306683 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306684 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006685 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306686 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006687
Yue Ma3ede6052013-08-29 00:33:26 -07006688 if (NULL == pHddCtx)
6689 {
6690 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6691 return;
6692 }
6693
6694 hHal = pHddCtx->hHal;
6695
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306696 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306698 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6699 return;
6700 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306701
6702 /* Check if INI is enabled or not, other wise just return
6703 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306704 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306705 {
6706 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6707 if (NULL == pMulticastAddrs)
6708 {
6709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6710 return;
6711 }
6712
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 if (set)
6714 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306715 /* Following pre-conditions should be satisfied before wei
6716 * configure the MC address list.
6717 */
6718 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6719 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6720 && pAdapter->mc_addr_list.mc_cnt
6721 && (eConnectionState_Associated ==
6722 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6723 {
6724 pMulticastAddrs->ulMulticastAddrCnt =
6725 pAdapter->mc_addr_list.mc_cnt;
6726 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6727 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006728 memcpy(pMulticastAddrs->multicastAddr[i],
6729 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306730 sizeof(pAdapter->mc_addr_list.addr[i]));
6731 hddLog(VOS_TRACE_LEVEL_INFO,
6732 "%s: %s multicast filter: addr ="
6733 MAC_ADDRESS_STR,
6734 __func__, set ? "setting" : "clearing",
6735 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6736 }
6737 /* Set multicast filter */
6738 sme_8023MulticastList(hHal, pAdapter->sessionId,
6739 pMulticastAddrs);
6740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306742 else
6743 {
6744 /* Need to clear only if it was previously configured
6745 */
6746 if (pAdapter->mc_addr_list.isFilterApplied)
6747 {
6748 pMulticastAddrs->ulMulticastAddrCnt = 0;
6749 sme_8023MulticastList(hHal, pAdapter->sessionId,
6750 pMulticastAddrs);
6751 }
6752
6753 }
6754 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006755 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306757 else
6758 {
6759 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306760 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306761 }
6762 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006763}
6764
6765static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6766 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306767{
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006769 tpPacketFilterCfg pRequest = NULL;
6770 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306771 struct iw_point s_priv_data;
6772
6773 if (hdd_priv_get_data(&s_priv_data, wrqu))
6774 {
6775 return -EINVAL;
6776 }
6777
6778 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6779 {
6780 return -EINVAL;
6781 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006782
Arif Hussain0273cba2014-01-07 20:58:29 -08006783 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306784 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6785 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006786 if (NULL == pRequest)
6787 {
6788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6789 "mem_alloc_copy_from_user_helper fail");
6790 return -ENOMEM;
6791 }
6792
6793 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6794 kfree(pRequest);
6795
6796 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006797}
6798#endif
6799static int iw_get_statistics(struct net_device *dev,
6800 struct iw_request_info *info,
6801 union iwreq_data *wrqu, char *extra)
6802{
6803
6804 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6805 eHalStatus status = eHAL_STATUS_SUCCESS;
6806 hdd_wext_state_t *pWextState;
6807 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6808 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6809 char *p = extra;
6810 int tlen = 0;
6811 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6812
6813 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6814 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6815
6816 ENTER();
6817
6818 if (pHddCtx->isLogpInProgress) {
6819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6820 return -EINVAL;
6821 }
6822
6823 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6824
6825 wrqu->txpower.value = 0;
6826 }
6827 else {
6828 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6829 SME_SUMMARY_STATS |
6830 SME_GLOBAL_CLASSA_STATS |
6831 SME_GLOBAL_CLASSB_STATS |
6832 SME_GLOBAL_CLASSC_STATS |
6833 SME_GLOBAL_CLASSD_STATS |
6834 SME_PER_STA_STATS,
6835 hdd_StatisticsCB, 0, FALSE,
6836 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6837
6838 if (eHAL_STATUS_SUCCESS != status)
6839 {
6840 hddLog(VOS_TRACE_LEVEL_ERROR,
6841 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006842 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 return -EINVAL;
6844 }
6845
6846 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6847
6848 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6849 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6850 {
6851 hddLog(VOS_TRACE_LEVEL_ERROR,
6852 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006853 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 /*Remove the SME statistics list by passing NULL in callback argument*/
6855 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6856 SME_SUMMARY_STATS |
6857 SME_GLOBAL_CLASSA_STATS |
6858 SME_GLOBAL_CLASSB_STATS |
6859 SME_GLOBAL_CLASSC_STATS |
6860 SME_GLOBAL_CLASSD_STATS |
6861 SME_PER_STA_STATS,
6862 NULL, 0, FALSE,
6863 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6864
6865 return -EINVAL;
6866 }
6867 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6868 (tANI_U8) sizeof (pStats->retry_cnt),
6869 (char*) &(pStats->retry_cnt[0]),
6870 tlen);
6871
6872 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6873 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6874 (char*) &(pStats->multiple_retry_cnt[0]),
6875 tlen);
6876
6877 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6878 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6879 (char*) &(pStats->tx_frm_cnt[0]),
6880 tlen);
6881
6882 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6883 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6884 (char*) &(pStats->rx_frm_cnt),
6885 tlen);
6886
6887 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6888 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6889 (char*) &(pStats->frm_dup_cnt),
6890 tlen);
6891
6892 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6893 (tANI_U8) sizeof (pStats->fail_cnt),
6894 (char*) &(pStats->fail_cnt[0]),
6895 tlen);
6896
6897 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6898 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6899 (char*) &(pStats->rts_fail_cnt),
6900 tlen);
6901
6902 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6903 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6904 (char*) &(pStats->ack_fail_cnt),
6905 tlen);
6906
6907 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6908 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6909 (char*) &(pStats->rts_succ_cnt),
6910 tlen);
6911
6912 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6913 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6914 (char*) &(pStats->rx_discard_cnt),
6915 tlen);
6916
6917 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6918 (tANI_U8) sizeof (pStats->rx_error_cnt),
6919 (char*) &(pStats->rx_error_cnt),
6920 tlen);
6921
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006922 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006923 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006924 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 tlen);
6926
6927 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6928 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6929 (char*) &(dStats->rx_byte_cnt),
6930 tlen);
6931
6932 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6933 (tANI_U8) sizeof (dStats->rx_rate),
6934 (char*) &(dStats->rx_rate),
6935 tlen);
6936
6937 /* Transmit rate, in units of 500 kbit/sec */
6938 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6939 (tANI_U8) sizeof (aStats->tx_rate),
6940 (char*) &(aStats->tx_rate),
6941 tlen);
6942
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006943 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6944 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6945 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006946 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006947 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6948 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6949 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006950 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006951 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6952 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6953 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006954 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006955 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6956 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6957 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006958 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006959 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6960 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6961 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006962 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006963 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6964 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6965 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006966 tlen);
6967
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 wrqu->data.length = tlen;
6969
6970 }
6971
6972 EXIT();
6973
6974 return 0;
6975}
6976
6977
6978#ifdef FEATURE_WLAN_SCAN_PNO
6979
6980/*Max Len for PNO notification*/
6981#define MAX_PNO_NOTIFY_LEN 100
6982void found_pref_network_cb (void *callbackContext,
6983 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6984{
6985 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6986 union iwreq_data wrqu;
6987 char buf[MAX_PNO_NOTIFY_LEN+1];
6988
6989 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6990 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6991
6992 // create the event
6993 memset(&wrqu, 0, sizeof(wrqu));
6994 memset(buf, 0, sizeof(buf));
6995
6996 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6997 pPrefNetworkFoundInd->ssId.ssId,
6998 (unsigned int)pPrefNetworkFoundInd->rssi);
6999
7000 wrqu.data.pointer = buf;
7001 wrqu.data.length = strlen(buf);
7002
7003 // send the event
7004
7005 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
7006
7007}
7008
7009
7010/*string based input*/
7011VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
7012 union iwreq_data *wrqu, char *extra, int nOffset)
7013{
7014 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05307015 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07007016 /* pnoRequest is a large struct, so we make it static to avoid stack
7017 overflow. This API is only invoked via ioctl, so it is
7018 serialized by the kernel rtnl_lock and hence does not need to be
7019 reentrant */
7020 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 char *ptr;
7022 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05307023 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7025
7026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7027 "PNO data len %d data %s",
7028 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007029 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007030
7031 if (wrqu->data.length <= nOffset )
7032 {
7033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
7034 return VOS_STATUS_E_FAILURE;
7035 }
7036
7037 pnoRequest.enable = 0;
7038 pnoRequest.ucNetworksCount = 0;
7039 /*-----------------------------------------------------------------------
7040 Input is string based and expected to be like this:
7041
7042 <enabled> <netw_count>
7043 for each network:
7044 <ssid_len> <ssid> <authentication> <encryption>
7045 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
7046 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
7047
7048 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07007049 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 -07007050
7051 this translates into:
7052 -----------------------------
7053 enable PNO
7054 look for 2 networks:
7055 test - with authentication type 0 and encryption type 0,
7056 that can be found on 3 channels: 1 6 and 11 ,
7057 SSID bcast type is unknown (directed probe will be sent if AP not found)
7058 and must meet -40dBm RSSI
7059
7060 test2 - with auth and enrytption type 4/4
7061 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
7062 bcast type is non-bcast (directed probe will be sent)
7063 and must not meet any RSSI threshold
7064
Jeff Johnson8301aa12013-03-28 14:27:29 -07007065 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07007066 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08007067 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007068
Wilson Yang623f6592013-10-08 16:33:37 -07007069 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
7070 {
7071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7072 "PNO enable input is not valid %s",ptr);
7073 return VOS_STATUS_E_FAILURE;
7074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007075
7076 if ( 0 == pnoRequest.enable )
7077 {
7078 /*Disable PNO*/
7079 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05307080 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7081 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 pAdapter->sessionId,
7083 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307084 if (eHAL_STATUS_SUCCESS != status)
7085 {
7086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7087 "%s: failed to disable PNO", __func__);
7088 return VOS_STATUS_E_FAILURE;
7089 }
7090 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007091 return VOS_STATUS_SUCCESS;
7092 }
7093
c_hpothu37f21312014-04-09 21:49:54 +05307094 if (TRUE == pHddCtx->isPnoEnable)
7095 {
7096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7097 FL("already PNO is enabled"));
7098 return -EBUSY;
7099 }
7100 pHddCtx->isPnoEnable = TRUE;
7101
Jeff Johnson295189b2012-06-20 16:38:30 -07007102 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07007103
7104 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
7105 {
7106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7107 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307108 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007110
7111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7112 "PNO enable %d networks count %d offset %d",
7113 pnoRequest.enable,
7114 pnoRequest.ucNetworksCount,
7115 nOffset);
7116
7117 /* Parameters checking:
7118 ucNetworksCount has to be larger than 0*/
7119 if (( 0 == pnoRequest.ucNetworksCount ) ||
7120 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7121 {
7122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05307123 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 }
7125
7126 ptr += nOffset;
7127
7128 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
7129 {
7130
7131 pnoRequest.aNetworks[i].ssId.length = 0;
7132
Wilson Yang623f6592013-10-08 16:33:37 -07007133 ucParams = sscanf(ptr,"%hhu %n",
7134 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
7135
7136 if (1 != ucParams)
7137 {
7138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7139 "PNO ssid length input is not valid %s",ptr);
7140 return VOS_STATUS_E_FAILURE;
7141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007142
7143 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
7144 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
7145 {
7146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7147 "SSID Len %d is not correct for network %d",
7148 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05307149 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007150 }
7151
7152 /*Advance to SSID*/
7153 ptr += nOffset;
7154
Jeff Johnson8301aa12013-03-28 14:27:29 -07007155 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08007156 pnoRequest.aNetworks[i].ssId.length);
7157 ptr += pnoRequest.aNetworks[i].ssId.length;
7158
Jeff Johnson02797792013-10-26 19:17:13 -07007159 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007160 &(pnoRequest.aNetworks[i].authentication),
7161 &(pnoRequest.aNetworks[i].encryption),
7162 &(pnoRequest.aNetworks[i].ucChannelCount),
7163 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007164
Wilson Yang623f6592013-10-08 16:33:37 -07007165 if ( 3 != ucParams )
7166 {
7167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7168 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307169 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007170 }
7171
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007173 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08007174 "auth %d encry %d channel count %d offset %d",
7175 pnoRequest.aNetworks[i].ssId.length,
7176 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
7177 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7178 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7179 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7180 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7181 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7182 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7183 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7184 pnoRequest.aNetworks[i].authentication,
7185 pnoRequest.aNetworks[i].encryption,
7186 pnoRequest.aNetworks[i].ucChannelCount,
7187 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007188
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 /*Advance to channel list*/
7190 ptr += nOffset;
7191
Wilson Yang623f6592013-10-08 16:33:37 -07007192 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007193 {
7194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7195 "Incorrect number of channels");
7196 return VOS_STATUS_E_FAILURE;
7197 }
7198
7199 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7200 {
7201 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7202 {
Wilson Yang623f6592013-10-08 16:33:37 -07007203 if (1 != sscanf(ptr,"%hhu %n",
7204 &(pnoRequest.aNetworks[i].aChannels[j]),
7205 &nOffset))
7206 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7207 "PNO network channel input is not valid %s",ptr);
7208 return VOS_STATUS_E_FAILURE;
7209 }
7210 /*Advance to next channel number*/
7211 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 }
7213 }
7214
Jeff Johnson02797792013-10-26 19:17:13 -07007215 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007216 &(pnoRequest.aNetworks[i].bcastNetwType),
7217 &nOffset))
7218 {
7219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7220 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307221 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007223
7224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7225 "PNO bcastNetwType %d offset %d",
7226 pnoRequest.aNetworks[i].bcastNetwType,
7227 nOffset );
7228
7229 /*Advance to rssi Threshold*/
7230 ptr += nOffset;
7231
Wilson Yang623f6592013-10-08 16:33:37 -07007232 if (1 != sscanf(ptr,"%hhu %n",
7233 &(pnoRequest.aNetworks[i].rssiThreshold),
7234 &nOffset))
7235 {
7236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7237 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307238 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007240
7241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7242 "PNO rssi %d offset %d",
7243 pnoRequest.aNetworks[i].rssiThreshold,
7244 nOffset );
7245 /*Advance to next network*/
7246 ptr += nOffset;
7247 }/*For ucNetworkCount*/
7248
7249 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007250 &(pnoRequest.scanTimers.ucScanTimersCount),
7251 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007252
7253 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007254 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 {
7256 ptr += nOffset;
7257
Jeff Johnson8301aa12013-03-28 14:27:29 -07007258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7259 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 pnoRequest.scanTimers.ucScanTimersCount,
7261 nOffset );
7262
7263 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7264 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307267 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 }
7269
7270 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7271 {
Jeff Johnson02797792013-10-26 19:17:13 -07007272 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7274 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7275 &nOffset);
7276
Wilson Yang623f6592013-10-08 16:33:37 -07007277 if (2 != ucParams)
7278 {
7279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7280 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307281 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007282 }
7283
Jeff Johnson8301aa12013-03-28 14:27:29 -07007284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7285 "PNO Timer value %d Timer repeat %d offset %d",
7286 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7288 nOffset );
7289
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 ptr += nOffset;
7291 }
7292
7293 }
7294 else
7295 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7297 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7299
7300 /*Scan timers defaults to 5 minutes*/
7301 pnoRequest.scanTimers.ucScanTimersCount = 1;
7302 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7303 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7304 }
7305
Wilson Yang623f6592013-10-08 16:33:37 -07007306 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007307
7308 pnoRequest.modePNO = ucMode;
7309 /*for LA we just expose suspend option*/
7310 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7311 {
7312 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7313 }
7314
c_hpothu37f21312014-04-09 21:49:54 +05307315 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007316 pAdapter->sessionId,
7317 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307318 if (eHAL_STATUS_SUCCESS == status)
7319 {
7320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7321 "%s: PNO enabled", __func__);
7322 return VOS_STATUS_SUCCESS;
7323 }
7324error:
7325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7326 "%s: Failed to enable PNO", __func__);
7327 pHddCtx->isPnoEnable = FALSE;
7328 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007329}/*iw_set_pno*/
7330
7331VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7332 union iwreq_data *wrqu, char *extra, int nOffset)
7333{
7334 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7335 v_U8_t rssiThreshold = 0;
7336 v_U8_t nRead;
7337
Arif Hussain7adce1b2013-11-11 22:59:34 -08007338 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007339 &rssiThreshold);
7340
7341 if ( 1 != nRead )
7342 {
7343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7344 "Incorrect format");
7345 return VOS_STATUS_E_FAILURE;
7346 }
7347
7348 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7349 return VOS_STATUS_SUCCESS;
7350}
7351
7352
7353static int iw_set_pno_priv(struct net_device *dev,
7354 struct iw_request_info *info,
7355 union iwreq_data *wrqu, char *extra)
7356{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007357 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7358
7359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007361
7362 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7363 {
7364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7365 "%s:LOGP in Progress. Ignore!!!", __func__);
7366 return -EBUSY;
7367 }
7368 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007369}
7370#endif /*FEATURE_WLAN_SCAN_PNO*/
7371
7372//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307373int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007374{
7375 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7376 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7377 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307378 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307380 eCsrBand connectedBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007381
Atul Mittal54378cb2014-04-02 16:51:50 +05307382 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 {
7384 case WLAN_HDD_UI_BAND_AUTO:
7385 band = eCSR_BAND_ALL;
7386 break;
7387 case WLAN_HDD_UI_BAND_5_GHZ:
7388 band = eCSR_BAND_5G;
7389 break;
7390 case WLAN_HDD_UI_BAND_2_4_GHZ:
7391 band = eCSR_BAND_24;
7392 break;
7393 default:
7394 band = eCSR_BAND_MAX;
7395 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307396 connectedBand =
7397 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007398
Atul Mittal54378cb2014-04-02 16:51:50 +05307399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007400 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007401
7402 if (band == eCSR_BAND_MAX)
7403 {
7404 /* Received change band request with invalid band value */
7405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307406 "%s: Invalid band value %u", __func__, ui_band);
7407 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 }
7409
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307410 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7411 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7412 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7413 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007415 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007416 band, pHddCtx->cfg_ini->nBandCapability);
7417 return -EIO;
7418 }
7419
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7421 {
7422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7423 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007424 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 return -EIO;
7426 }
7427
7428 if (currBand != band)
7429 {
7430 /* Change band request received.
7431 * Abort pending scan requests, flush the existing scan results,
7432 * and change the band capability
7433 */
7434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7435 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007436 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007437
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307438 /* We need to change the band and flush the scan results here itself
7439 * as we may get timeout for disconnection in which we will return
7440 * with out doing any of these
7441 */
7442 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7443 {
7444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7445 "%s: failed to set the band value to %u ",
7446 __func__, band);
7447 return -EINVAL;
7448 }
7449 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7450 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7451 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7452 sme_FilterScanResults(hHal, pAdapter->sessionId);
7453
7454 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307455 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7456 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 {
7458 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7459 eHalStatus status = eHAL_STATUS_SUCCESS;
7460 long lrc;
7461
7462 /* STA already connected on current band, So issue disconnect first,
7463 * then change the band*/
7464
7465 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05307466 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
7467 " Set HDD connState to eConnectionState_NotConnected",
Jeff Johnson295189b2012-06-20 16:38:30 -07007468 __func__, csrGetCurrentBand(hHal), band);
7469
7470 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7471 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7472
7473 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7474 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7475
Jeff Johnson43971f52012-07-17 12:26:56 -07007476 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007477 {
7478 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007479 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 __func__, (int)status );
7481 return -EINVAL;
7482 }
7483
7484 lrc = wait_for_completion_interruptible_timeout(
7485 &pAdapter->disconnect_comp_var,
7486 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7487
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307488 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007489
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007490 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007491 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007492
7493 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7494 }
7495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 }
7497 return 0;
7498}
7499
Atul Mittal54378cb2014-04-02 16:51:50 +05307500int hdd_setBand_helper(struct net_device *dev, const char *command)
7501{
7502 u8 band;
7503
7504 /*convert the band value from ascii to integer*/
7505 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7506
7507 return hdd_setBand(dev, band);
7508
7509}
7510
Jeff Johnson295189b2012-06-20 16:38:30 -07007511static int iw_set_band_config(struct net_device *dev,
7512 struct iw_request_info *info,
7513 union iwreq_data *wrqu, char *extra)
7514{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307516 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007517
Arif Hussain0273cba2014-01-07 20:58:29 -08007518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007519
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007520 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7521 {
7522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7523 "%s:LOGP in Progress. Ignore!!!", __func__);
7524 return -EBUSY;
7525 }
7526
Atul Mittal54378cb2014-04-02 16:51:50 +05307527 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007528}
7529
7530static int iw_set_power_params_priv(struct net_device *dev,
7531 struct iw_request_info *info,
7532 union iwreq_data *wrqu, char *extra)
7533{
Arif Hussain0273cba2014-01-07 20:58:29 -08007534 int ret;
7535 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7537 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007538 /* ODD number is used for set, copy data using copy_from_user */
7539 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7540 wrqu->data.length);
7541 if (NULL == ptr)
7542 {
7543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7544 "mem_alloc_copy_from_user_helper fail");
7545 return -ENOMEM;
7546 }
7547
7548 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7549 kfree(ptr);
7550 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007551}
7552
7553
7554
7555/*string based input*/
7556VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7557 union iwreq_data *wrqu, char *extra, int nOffset)
7558{
7559 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7560 tSirSetPowerParamsReq powerRequest;
7561 char *ptr;
7562 v_U8_t ucType;
7563 v_U32_t uTotalSize, uValue;
7564 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7565
7566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7567 "Power Params data len %d data %s",
7568 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007569 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007570
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007571 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7572 {
7573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7574 "%s:LOGP in Progress. Ignore!!!", __func__);
7575 return -EBUSY;
7576 }
7577
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 if (wrqu->data.length <= nOffset )
7579 {
7580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7581 return VOS_STATUS_E_FAILURE;
7582 }
7583
7584 uTotalSize = wrqu->data.length - nOffset;
7585
7586 /*-----------------------------------------------------------------------
7587 Input is string based and expected to be like this:
7588
7589 <param_type> <param_value> <param_type> <param_value> ...
7590
7591 e.g:
7592 1 2 2 3 3 0 4 1 5 1
7593
7594 e.g. setting just a few:
7595 1 2 4 1
7596
7597 parameter types:
7598 -----------------------------
7599 1 - Ignore DTIM
7600 2 - Listen Interval
7601 3 - Broadcast Multicas Filter
7602 4 - Beacon Early Termination
7603 5 - Beacon Early Termination Interval
7604 -----------------------------------------------------------------------*/
7605 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7606 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7607 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7608 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7609 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7610
Arif Hussain7adce1b2013-11-11 22:59:34 -08007611 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007612
7613 while ( uTotalSize )
7614 {
Wilson Yang6f971452013-10-08 15:00:00 -07007615 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7616 {
7617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7618 "Invalid input parameter type %s",ptr);
7619 return VOS_STATUS_E_FAILURE;
7620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007621
7622 uTotalSize -= nOffset;
7623
7624 if (!uTotalSize)
7625 {
7626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007627 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 ucType, nOffset);
7629 return VOS_STATUS_E_FAILURE;
7630 }
7631
7632 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007633
Jeff Johnson02797792013-10-26 19:17:13 -07007634 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007635 {
7636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7637 "Invalid input parameter value %s",ptr);
7638 return VOS_STATUS_E_FAILURE;
7639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007640
7641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7642 "Power request parameter %d value %d offset %d",
7643 ucType, uValue, nOffset);
7644
7645 switch (ucType)
7646 {
7647 case eSIR_IGNORE_DTIM:
7648 powerRequest.uIgnoreDTIM = uValue;
7649 break;
7650 case eSIR_LISTEN_INTERVAL:
7651 powerRequest.uListenInterval = uValue;
7652 break;
7653 case eSIR_MCAST_BCAST_FILTER:
7654 powerRequest.uBcastMcastFilter = uValue;
7655 break;
7656 case eSIR_ENABLE_BET:
7657 powerRequest.uEnableBET = uValue;
7658 break;
7659 case eSIR_BET_INTERVAL:
7660 powerRequest.uBETInterval = uValue;
7661 break;
7662 default:
7663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007664 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007665 ucType, uValue, nOffset);
7666 return VOS_STATUS_E_FAILURE;
7667 }
7668
7669 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7671 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007672 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007674 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007675 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007676 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7677 {
7678 uTotalSize = 0;
7679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007680
7681 }/*Go for as long as we have a valid string*/
7682
7683 /* put the device into full power*/
7684 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7685
7686 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007687 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007688
7689 /* put the device back to power save*/
7690 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7691
7692 return VOS_STATUS_SUCCESS;
7693}/*iw_set_power_params*/
7694
7695
7696// Define the Wireless Extensions to the Linux Network Device structure
7697// A number of these routines are NULL (meaning they are not implemented.)
7698
7699static const iw_handler we_handler[] =
7700{
7701 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7702 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7703 (iw_handler) NULL, /* SIOCSIWNWID */
7704 (iw_handler) NULL, /* SIOCGIWNWID */
7705 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7706 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7707 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7708 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7709 (iw_handler) NULL, /* SIOCSIWSENS */
7710 (iw_handler) NULL, /* SIOCGIWSENS */
7711 (iw_handler) NULL, /* SIOCSIWRANGE */
7712 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7713 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7714 (iw_handler) NULL, /* SIOCGIWPRIV */
7715 (iw_handler) NULL, /* SIOCSIWSTATS */
7716 (iw_handler) NULL, /* SIOCGIWSTATS */
7717 iw_handler_set_spy, /* SIOCSIWSPY */
7718 iw_handler_get_spy, /* SIOCGIWSPY */
7719 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7720 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7721 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7722 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7723 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7724 (iw_handler) NULL, /* SIOCGIWAPLIST */
7725 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7726 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7727 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7728 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7729 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7730 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7731 (iw_handler) NULL, /* -- hole -- */
7732 (iw_handler) NULL, /* -- hole -- */
7733 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7734 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7735 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7736 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7737 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7738 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7739 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7740 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7741 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7742 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7743 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7744 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7745 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7746 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7747 (iw_handler) NULL, /* -- hole -- */
7748 (iw_handler) NULL, /* -- hole -- */
7749 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7750 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7751 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7752 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7753 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7754 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7755 (iw_handler) NULL, /* SIOCSIWPMKSA */
7756};
7757
7758static const iw_handler we_private[] = {
7759
7760 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7761 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7762 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7763 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7764 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7765 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7766 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7767 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7768 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7769 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007770#ifdef FEATURE_OEM_DATA_SUPPORT
7771 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7772 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7773#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007774
7775#ifdef FEATURE_WLAN_WAPI
7776 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7777 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7778 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7779 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7780 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7781 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7782#endif /* FEATURE_WLAN_WAPI */
7783#ifdef WLAN_FEATURE_VOWIFI_11R
7784 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7785#endif
7786 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7787 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7788 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7789#ifdef WLAN_FEATURE_PACKET_FILTERING
7790 ,
7791 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7792#endif
7793#ifdef FEATURE_WLAN_SCAN_PNO
7794 ,
7795 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7796#endif
7797 ,
7798 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7799 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7800 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7801 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007802 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007803};
7804
7805/*Maximum command length can be only 15 */
7806static const struct iw_priv_args we_private_args[] = {
7807
7808 /* handlers for main ioctl */
7809 { WLAN_PRIV_SET_INT_GET_NONE,
7810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7811 0,
7812 "" },
7813
7814 /* handlers for sub-ioctl */
7815 { WE_SET_11D_STATE,
7816 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7817 0,
7818 "set11Dstate" },
7819
7820 { WE_WOWL,
7821 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7822 0,
7823 "wowl" },
7824
7825 { WE_SET_POWER,
7826 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7827 0,
7828 "setPower" },
7829
7830 { WE_SET_MAX_ASSOC,
7831 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7832 0,
7833 "setMaxAssoc" },
7834
7835 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7836 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7837 0,
7838 "setAutoChannel" },
7839
7840 { WE_SET_DATA_INACTIVITY_TO,
7841 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7842 0,
7843 "inactivityTO" },
7844
7845 { WE_SET_MAX_TX_POWER,
7846 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7847 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007848 "setMaxTxPower" },
7849
7850 { WE_SET_MAX_TX_POWER_2_4,
7851 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7852 0,
7853 "setTxMaxPower2G" },
7854
7855 { WE_SET_MAX_TX_POWER_5_0,
7856 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7857 0,
7858 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007859
7860 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7861 * as well to keep same syntax as in SAP. Now onwards, STA
7862 * will support both */
7863 { WE_SET_MAX_TX_POWER,
7864 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7865 0,
7866 "setTxMaxPower" },
7867
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7869 * 1 = enable and 0 = disable */
7870 {
7871 WE_SET_HIGHER_DTIM_TRANSITION,
7872 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7873 0,
7874 "setHDtimTransn" },
7875
7876 { WE_SET_TM_LEVEL,
7877 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007878 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 "setTmLevel" },
7880
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307881 { WE_ENABLE_STRICT_FCC_REG,
7882 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7883 0,
7884 "setStrictFCCreg" },
7885
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007886 { WE_SET_DEBUG_LOG,
7887 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7888 0, "setDbgLvl" },
7889
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 /* handlers for main ioctl */
7891 { WLAN_PRIV_SET_NONE_GET_INT,
7892 0,
7893 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7894 "" },
7895
7896 /* handlers for sub-ioctl */
7897 { WE_GET_11D_STATE,
7898 0,
7899 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7900 "get11Dstate" },
7901
7902 { WE_IBSS_STATUS,
7903 0,
7904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7905 "getAdhocStatus" },
7906
7907 { WE_PMC_STATE,
7908 0,
7909 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7910 "pmcState" },
7911
7912 { WE_GET_WLAN_DBG,
7913 0,
7914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7915 "getwlandbg" },
7916
7917 { WE_MODULE_DOWN_IND,
7918 0,
7919 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7920 "moduleDownInd" },
7921
7922 { WE_GET_MAX_ASSOC,
7923 0,
7924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7925 "getMaxAssoc" },
7926
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 { WE_GET_WDI_DBG,
7928 0,
7929 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7930 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007931
7932 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7933 0,
7934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7935 "getAutoChannel" },
7936
7937 { WE_GET_CONCURRENCY_MODE,
7938 0,
7939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7940 "getconcurrency" },
7941
7942 /* handlers for main ioctl */
7943 { WLAN_PRIV_SET_CHAR_GET_NONE,
7944 IW_PRIV_TYPE_CHAR| 512,
7945 0,
7946 "" },
7947
7948 /* handlers for sub-ioctl */
7949 { WE_WOWL_ADD_PTRN,
7950 IW_PRIV_TYPE_CHAR| 512,
7951 0,
7952 "wowlAddPtrn" },
7953
7954 { WE_WOWL_DEL_PTRN,
7955 IW_PRIV_TYPE_CHAR| 512,
7956 0,
7957 "wowlDelPtrn" },
7958
7959#if defined WLAN_FEATURE_VOWIFI
7960 /* handlers for sub-ioctl */
7961 { WE_NEIGHBOR_REPORT_REQUEST,
7962 IW_PRIV_TYPE_CHAR | 512,
7963 0,
7964 "neighbor" },
7965#endif
7966 { WE_SET_AP_WPS_IE,
7967 IW_PRIV_TYPE_CHAR| 512,
7968 0,
7969 "set_ap_wps_ie" },
7970
7971 { WE_SET_CONFIG,
7972 IW_PRIV_TYPE_CHAR| 512,
7973 0,
7974 "setConfig" },
7975
7976 /* handlers for main ioctl */
7977 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7978 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7979 0,
7980 "" },
7981
7982 /* handlers for sub-ioctl */
7983 { WE_SET_WLAN_DBG,
7984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7985 0,
7986 "setwlandbg" },
7987
Jeff Johnson295189b2012-06-20 16:38:30 -07007988 { WE_SET_WDI_DBG,
7989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7990 0,
7991 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007992
7993 { WE_SET_SAP_CHANNELS,
7994 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7995 0,
7996 "setsapchannels" },
7997
7998 /* handlers for main ioctl */
7999 { WLAN_PRIV_GET_CHAR_SET_NONE,
8000 0,
8001 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8002 "" },
8003
8004 /* handlers for sub-ioctl */
8005 { WE_WLAN_VERSION,
8006 0,
8007 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8008 "version" },
8009 { WE_GET_STATS,
8010 0,
8011 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8012 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308013 { WE_GET_STATES,
8014 0,
8015 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8016 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 { WE_GET_CFG,
8018 0,
8019 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8020 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07008021#ifdef WLAN_FEATURE_11AC
8022 { WE_GET_RSSI,
8023 0,
8024 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8025 "getRSSI" },
8026#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008027#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008028 { WE_GET_ROAM_RSSI,
8029 0,
8030 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8031 "getRoamRSSI" },
8032#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 { WE_GET_WMM_STATUS,
8034 0,
8035 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8036 "getWmmStatus" },
8037 {
8038 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308039 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8041 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08008042#ifdef FEATURE_WLAN_TDLS
8043 {
8044 WE_GET_TDLS_PEERS,
8045 0,
8046 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8047 "getTdlsPeers" },
8048#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008049#ifdef WLAN_FEATURE_11W
8050 {
8051 WE_GET_11W_INFO,
8052 0,
8053 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8054 "getPMFInfo" },
8055#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 /* handlers for main ioctl */
8057 { WLAN_PRIV_SET_NONE_GET_NONE,
8058 0,
8059 0,
8060 "" },
8061
8062 /* handlers for sub-ioctl */
8063 { WE_CLEAR_STATS,
8064 0,
8065 0,
8066 "clearStats" },
8067 { WE_INIT_AP,
8068 0,
8069 0,
8070 "initAP" },
8071 { WE_STOP_AP,
8072 0,
8073 0,
8074 "exitAP" },
8075 { WE_ENABLE_AMP,
8076 0,
8077 0,
8078 "enableAMP" },
8079 { WE_DISABLE_AMP,
8080 0,
8081 0,
8082 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008083 { WE_ENABLE_DXE_STALL_DETECT,
8084 0,
8085 0,
8086 "dxeStallDetect" },
8087 { WE_DISPLAY_DXE_SNAP_SHOT,
8088 0,
8089 0,
8090 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308091 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
8092 0,
8093 0,
8094 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07008095 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05308096 WE_STOP_OBSS_SCAN,
8097 0,
8098 0,
8099 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008100
8101 /* handlers for main ioctl */
8102 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
8103 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8104 0,
8105 "" },
8106
8107 /* handlers for sub-ioctl */
8108 { WE_LOG_DUMP_CMD,
8109 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8110 0,
8111 "dump" },
8112
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008113 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308114 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8115 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8116 0,
8117 "setdumplog" },
8118
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008119 { WE_MTRACE_DUMP_CMD,
8120 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8121 0,
8122 "dumplog" },
8123
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008124 /* handlers for sub ioctl */
8125 {
8126 WE_MCC_CONFIG_CREDENTIAL,
8127 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8128 0,
8129 "setMccCrdnl" },
8130
8131 /* handlers for sub ioctl */
8132 {
8133 WE_MCC_CONFIG_PARAMS,
8134 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8135 0,
8136 "setMccConfig" },
8137
Chilam NG571c65a2013-01-19 12:27:36 +05308138#ifdef FEATURE_WLAN_TDLS
8139 /* handlers for sub ioctl */
8140 {
8141 WE_TDLS_CONFIG_PARAMS,
8142 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8143 0,
8144 "setTdlsConfig" },
8145#endif
8146
Jeff Johnson295189b2012-06-20 16:38:30 -07008147 /* handlers for main ioctl */
8148 { WLAN_PRIV_ADD_TSPEC,
8149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8151 "addTspec" },
8152
8153 /* handlers for main ioctl */
8154 { WLAN_PRIV_DEL_TSPEC,
8155 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8157 "delTspec" },
8158
8159 /* handlers for main ioctl */
8160 { WLAN_PRIV_GET_TSPEC,
8161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8163 "getTspec" },
8164
Jeff Johnsone7245742012-09-05 17:12:55 -07008165#ifdef FEATURE_OEM_DATA_SUPPORT
8166 /* handlers for main ioctl - OEM DATA */
8167 {
8168 WLAN_PRIV_SET_OEM_DATA_REQ,
8169 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8170 0,
8171 "set_oem_data_req" },
8172
8173 /* handlers for main ioctl - OEM DATA */
8174 {
8175 WLAN_PRIV_GET_OEM_DATA_RSP,
8176 0,
8177 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8178 "get_oem_data_rsp" },
8179#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008180
8181#ifdef FEATURE_WLAN_WAPI
8182 /* handlers for main ioctl SET_WAPI_MODE */
8183 { WLAN_PRIV_SET_WAPI_MODE,
8184 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8185 0,
8186 "SET_WAPI_MODE" },
8187
8188 /* handlers for main ioctl GET_WAPI_MODE */
8189 { WLAN_PRIV_GET_WAPI_MODE,
8190 0,
8191 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8192 "GET_WAPI_MODE" },
8193
8194 /* handlers for main ioctl SET_ASSOC_INFO */
8195 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
8196 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
8197 0,
8198 "SET_WAPI_ASSOC" },
8199
8200 /* handlers for main ioctl SET_WAPI_KEY */
8201 { WLAN_PRIV_SET_WAPI_KEY,
8202 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8203 0,
8204 "SET_WAPI_KEY" },
8205
8206 /* handlers for main ioctl SET_WAPI_BKID */
8207 { WLAN_PRIV_SET_WAPI_BKID,
8208 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8209 0,
8210 "SET_WAPI_BKID" },
8211
8212 /* handlers for main ioctl GET_WAPI_BKID */
8213 { WLAN_PRIV_GET_WAPI_BKID,
8214 0,
8215 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8216 "GET_WAPI_BKID" },
8217#endif /* FEATURE_WLAN_WAPI */
8218
8219 /* handlers for main ioctl - host offload */
8220 {
8221 WLAN_PRIV_SET_HOST_OFFLOAD,
8222 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8223 0,
8224 "setHostOffload" },
8225
8226 {
8227 WLAN_GET_WLAN_STATISTICS,
8228 0,
8229 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8230 "getWlanStats" },
8231
8232 {
8233 WLAN_SET_KEEPALIVE_PARAMS,
8234 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8235 0,
8236 "setKeepAlive" },
8237#ifdef WLAN_FEATURE_PACKET_FILTERING
8238 {
8239 WLAN_SET_PACKET_FILTER_PARAMS,
8240 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8241 0,
8242 "setPktFilter" },
8243#endif
8244#ifdef FEATURE_WLAN_SCAN_PNO
8245 {
8246 WLAN_SET_PNO,
8247 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8248 0,
8249 "setpno" },
8250#endif
8251 {
8252 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308253 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 0,
8255 "SETBAND" },
8256 /* handlers for dynamic MC BC ioctl */
8257 {
8258 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008259 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 0,
8261 "setMCBCFilter" },
8262 {
8263 WLAN_PRIV_CLEAR_MCBC_FILTER,
8264 0,
8265 0,
8266 "clearMCBCFilter" },
8267 {
8268 WLAN_SET_POWER_PARAMS,
8269 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8270 0,
8271 "setpowerparams" },
8272 {
8273 WLAN_GET_LINK_SPEED,
8274 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308275 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008276};
8277
8278
8279
8280const struct iw_handler_def we_handler_def = {
8281 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8282 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8283 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8284
8285 .standard = (iw_handler *)we_handler,
8286 .private = (iw_handler *)we_private,
8287 .private_args = we_private_args,
8288 .get_wireless_stats = get_wireless_stats,
8289};
8290
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008291int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8292{
8293 v_U32_t cmd = 288; //Command to RIVA
8294 hdd_context_t *pHddCtx = NULL;
8295 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8296 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8297 /*
8298 *configMccParam : specify the bit which needs to be modified
8299 *allowed to update based on wlan_qcom_cfg.ini
8300 * configuration
8301 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8302 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8303 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8304 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8305 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8306 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8307 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8308 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8309 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8310 * Bit 9 : Reserved
8311 */
8312 switch (arg1)
8313 {
8314 //Update MCC SCHEDULE_TIME_SLICE parameter
8315 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8316 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8317 {
8318 if((arg2 >= 5) && (arg2 <= 20))
8319 {
8320 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8321 }
8322 else
8323 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008324 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008325 return 0;
8326 }
8327 }
8328 break;
8329
8330 //Update MCC MAX_NULL_SEND_TIME parameter
8331 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8332 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8333 {
8334 if((arg2 >= 1) && (arg2 <= 10))
8335 {
8336 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8337 }
8338 else
8339 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008340 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008341 return 0;
8342 }
8343 }
8344 break;
8345
8346 //Update MCC TX_EARLY_STOP_TIME parameter
8347 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8348 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8349 {
8350 if((arg2 >= 1) && (arg2 <= 10))
8351 {
8352 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8353 }
8354 else
8355 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008356 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008357 return 0;
8358 }
8359 }
8360 break;
8361
8362 //Update MCC RX_DRAIN_TIME parameter
8363 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8364 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8365 {
8366 if((arg2 >= 1) && (arg2 <= 10))
8367 {
8368 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8369 }
8370 else
8371 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008372 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008373 return 0;
8374 }
8375 }
8376 break;
8377
8378 //Update MCC CHANNEL_SWITCH_TIME parameter
8379 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8380 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8381 {
8382 if((arg2 >= 1) && (arg2 <= 20))
8383 {
8384 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8385 }
8386 else
8387 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008388 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008389 return 0;
8390 }
8391 }
8392 break;
8393
8394 //Update MCC MIN_CHANNEL_TIME parameter
8395 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8396 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8397 {
8398 if((arg2 >= 5) && (arg2 <= 20))
8399 {
8400 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8401 }
8402 else
8403 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008404 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008405 return 0;
8406 }
8407 }
8408 break;
8409
8410 //Update MCC PARK_BEFORE_TBTT parameter
8411 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8412 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8413 {
8414 if((arg2 >= 1) && (arg2 <= 5))
8415 {
8416 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8417 }
8418 else
8419 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008420 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008421 return 0;
8422 }
8423 }
8424 break;
8425
8426 //Update MCC MIN_AFTER_DTIM parameter
8427 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8428 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8429 {
8430 if((arg2 >= 5) && (arg2 <= 15))
8431 {
8432 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8433 }
8434 else
8435 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008436 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008437 return 0;
8438 }
8439 }
8440 break;
8441
8442 //Update MCC TOO_CLOSE_MARGIN parameter
8443 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8444 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8445 {
8446 if((arg2 >= 1) && (arg2 <= 3))
8447 {
8448 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8449 }
8450 else
8451 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008452 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008453 return 0;
8454 }
8455 }
8456 break;
8457
8458 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008459 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008460 __FUNCTION__,arg1);
8461 break;
8462 }
8463 return 0;
8464}
8465
Jeff Johnson295189b2012-06-20 16:38:30 -07008466int hdd_set_wext(hdd_adapter_t *pAdapter)
8467{
8468 hdd_wext_state_t *pwextBuf;
8469 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008470 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008471
8472 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8473
8474 // Now configure the roaming profile links. To SSID and bssid.
8475 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8476 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8477
8478 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8479 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8480
8481 /*Set the numOfChannels to zero to scan all the channels*/
8482 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8483 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8484
8485 /* Default is no encryption */
8486 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8487 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8488
8489 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8490 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8491
8492 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8493
8494 /* Default is no authentication */
8495 pwextBuf->roamProfile.AuthType.numEntries = 1;
8496 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8497
8498 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8499 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8500
8501 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008502 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008503
8504 hdd_clearRoamProfileIe(pAdapter);
8505
8506 return VOS_STATUS_SUCCESS;
8507
8508 }
8509
8510int hdd_register_wext(struct net_device *dev)
8511 {
8512 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8513 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8514 VOS_STATUS status;
8515
8516 ENTER();
8517
8518 // Zero the memory. This zeros the profile structure.
8519 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8520
8521 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8522
8523
8524 status = hdd_set_wext(pAdapter);
8525
8526 if(!VOS_IS_STATUS_SUCCESS(status)) {
8527
Arif Hussain6d2a3322013-11-17 19:50:10 -08008528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 return eHAL_STATUS_FAILURE;
8530 }
8531
8532 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 return eHAL_STATUS_FAILURE;
8536 }
8537
8538 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8539 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 return eHAL_STATUS_FAILURE;
8542 }
8543
8544 // Register as a wireless device
8545 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8546
8547 EXIT();
8548 return 0;
8549}
8550
8551int hdd_UnregisterWext(struct net_device *dev)
8552{
8553#if 0
8554 hdd_wext_state_t *wextBuf;
8555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8556
8557 ENTER();
8558 // Set up the pointer to the Wireless Extensions state structure
8559 wextBuf = pAdapter->pWextState;
8560
8561 // De-allocate the Wireless Extensions state structure
8562 kfree(wextBuf);
8563
8564 // Clear out the pointer to the Wireless Extensions state structure
8565 pAdapter->pWextState = NULL;
8566
8567 EXIT();
8568#endif
8569 dev->wireless_handlers = NULL;
8570 return 0;
8571}
8572
8573