blob: 635653a006186d5cbf3b0c7462d9145cc229c583 [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"
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
104#ifdef CONFIG_HAS_EARLYSUSPEND
105extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
106extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
107#endif
108
Jeff Johnsone7245742012-09-05 17:12:55 -0700109#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800110#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700111#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
113#define HDD_FINISH_ULA_TIME_OUT 800
114
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
117int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
118
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700119static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122/* To Validate Channel against the Frequency and Vice-Versa */
123static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
124 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
125 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
126 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
127 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
128 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
129 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
130 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800131 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
132 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800134#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136/* Private ioctls and their sub-ioctls */
137#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
138#define WE_SET_11D_STATE 1
139#define WE_WOWL 2
140#define WE_SET_POWER 3
141#define WE_SET_MAX_ASSOC 4
142#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
143#define WE_SET_DATA_INACTIVITY_TO 6
144#define WE_SET_MAX_TX_POWER 7
145#define WE_SET_HIGHER_DTIM_TRANSITION 8
146#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530147#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700148#define WE_SET_MAX_TX_POWER_2_4 11
149#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800150/* Private IOCTL for debug connection issues */
151#define WE_SET_DEBUG_LOG 13
Jeff Johnson295189b2012-06-20 16:38:30 -0700152
153/* Private ioctls and their sub-ioctls */
154#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
155#define WE_GET_11D_STATE 1
156#define WE_IBSS_STATUS 2
157#define WE_PMC_STATE 3
158#define WE_GET_WLAN_DBG 4
159#define WE_MODULE_DOWN_IND 5
160#define WE_GET_MAX_ASSOC 6
161#define WE_GET_WDI_DBG 7
162#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
163#define WE_GET_CONCURRENCY_MODE 9
164/* Private ioctls and their sub-ioctls */
165#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
166
167/* Private ioctls and their sub-ioctls */
168#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
169#define WE_WOWL_ADD_PTRN 1
170#define WE_WOWL_DEL_PTRN 2
171#if defined WLAN_FEATURE_VOWIFI
172#define WE_NEIGHBOR_REPORT_REQUEST 3
173#endif
174#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
175#define WE_SET_CONFIG 5
176
177/* Private ioctls and their sub-ioctls */
178#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
179#define WE_SET_WLAN_DBG 1
180#define WE_SET_WDI_DBG 2
181#define WE_SET_SAP_CHANNELS 3
182
183/* Private ioctls and their sub-ioctls */
184#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
185#define WE_WLAN_VERSION 1
186#define WE_GET_STATS 2
187#define WE_GET_CFG 3
188#define WE_GET_WMM_STATUS 4
189#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700190#ifdef WLAN_FEATURE_11AC
191#define WE_GET_RSSI 6
192#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800193#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800194#ifdef FEATURE_WLAN_TDLS
195#define WE_GET_TDLS_PEERS 8
196#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700197#ifdef WLAN_FEATURE_11W
198#define WE_GET_11W_INFO 9
199#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530200#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202/* Private ioctls and their sub-ioctls */
203#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
204#define WE_CLEAR_STATS 1
205#define WE_INIT_AP 2
206#define WE_STOP_AP 3
207#define WE_ENABLE_AMP 4
208#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700209#define WE_ENABLE_DXE_STALL_DETECT 6
210#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530211#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700212#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530213#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700214
215/* Private ioctls and their sub-ioctls */
216#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
217#define WE_LOG_DUMP_CMD 1
218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800220//IOCTL to configure MCC params
221#define WE_MCC_CONFIG_CREDENTIAL 3
222#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
Chilam NG571c65a2013-01-19 12:27:36 +0530224#ifdef FEATURE_WLAN_TDLS
225#define WE_TDLS_CONFIG_PARAMS 5
226#endif
227
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700228#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530229#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700230
Chilam Ng01120412013-02-19 18:32:21 -0800231#ifdef FEATURE_WLAN_TDLS
232#undef MAX_VAR_ARGS
233#define MAX_VAR_ARGS 10
234#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700235#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800236#endif
237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
239/* Private ioctls (with no sub-ioctls) */
240/* note that they must be odd so that they have "get" semantics */
241#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
242#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
243#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
244
245#ifdef FEATURE_WLAN_WAPI
246/* Private ioctls EVEN NO: SET, ODD NO:GET */
247#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
248#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
249#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
250#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
251#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
252#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
253#define WAPI_PSK_AKM_SUITE 0x02721400
254#define WAPI_CERT_AKM_SUITE 0x01721400
255#endif
256
Jeff Johnsone7245742012-09-05 17:12:55 -0700257#ifdef FEATURE_OEM_DATA_SUPPORT
258/* Private ioctls for setting the measurement configuration */
259#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
260#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
261#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700262
263#ifdef WLAN_FEATURE_VOWIFI_11R
264#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
265#endif
266
267/* Private ioctl for setting the host offload feature */
268#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
269
270/* Private ioctl to get the statistics */
271#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
272
273/* Private ioctl to set the Keep Alive Params */
274#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
275#ifdef WLAN_FEATURE_PACKET_FILTERING
276/* Private ioctl to set the Packet Filtering Params */
277#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
278#endif
279
280#ifdef FEATURE_WLAN_SCAN_PNO
281/* Private ioctl to get the statistics */
282#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
283#endif
284
285#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
286
287#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
288#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700289/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700290
Jeff Johnson295189b2012-06-20 16:38:30 -0700291#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
292#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
293
294#define WLAN_STATS_INVALID 0
295#define WLAN_STATS_RETRY_CNT 1
296#define WLAN_STATS_MUL_RETRY_CNT 2
297#define WLAN_STATS_TX_FRM_CNT 3
298#define WLAN_STATS_RX_FRM_CNT 4
299#define WLAN_STATS_FRM_DUP_CNT 5
300#define WLAN_STATS_FAIL_CNT 6
301#define WLAN_STATS_RTS_FAIL_CNT 7
302#define WLAN_STATS_ACK_FAIL_CNT 8
303#define WLAN_STATS_RTS_SUC_CNT 9
304#define WLAN_STATS_RX_DISCARD_CNT 10
305#define WLAN_STATS_RX_ERROR_CNT 11
306#define WLAN_STATS_TX_BYTE_CNT 12
307
308#define WLAN_STATS_RX_BYTE_CNT 13
309#define WLAN_STATS_RX_RATE 14
310#define WLAN_STATS_TX_RATE 15
311
Jeff Johnsone7245742012-09-05 17:12:55 -0700312#define WLAN_STATS_RX_UC_BYTE_CNT 16
313#define WLAN_STATS_RX_MC_BYTE_CNT 17
314#define WLAN_STATS_RX_BC_BYTE_CNT 18
315#define WLAN_STATS_TX_UC_BYTE_CNT 19
316#define WLAN_STATS_TX_MC_BYTE_CNT 20
317#define WLAN_STATS_TX_BC_BYTE_CNT 21
318
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800319#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
320 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
321 { \
322 *__p++ = __type; \
323 *__p++ = __size; \
324 memcpy(__p, __val, __size); \
325 __p += __size; \
326 __tlen += __size + 2; \
327 } \
328 else \
329 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800330 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800331 } \
332 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700333
334#define VERSION_VALUE_MAX_LEN 32
335
336#define TX_PER_TRACKING_DEFAULT_RATIO 5
337#define TX_PER_TRACKING_MAX_RATIO 10
338#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
339
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530340#define WLAN_ADAPTER 0
341#define P2P_ADAPTER 1
342
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800343/*MCC Configuration parameters */
344enum {
345 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
346 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
347 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
348 MCC_RX_DRAIN_TIME_CFG_PARAM,
349 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
350 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
351 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
352 MCC_MIN_AFTER_DTIM_CFG_PARAM,
353 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
354};
355
356int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
357 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800360int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700361 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700362#endif
363
Jeff Johnson295189b2012-06-20 16:38:30 -0700364/**---------------------------------------------------------------------------
365
Arif Hussain0273cba2014-01-07 20:58:29 -0800366 \brief mem_alloc_copy_from_user_helper -
367
368 Helper function to allocate buffer and copy user data.
369
370 \param - wrqu - Pointer to IOCTL Data.
371 len - size
372
373 \return - On Success pointer to buffer, On failure NULL
374
375 --------------------------------------------------------------------------*/
376static void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
377{
378 u8 *ptr = NULL;
379
380 /* in order to protect the code, an extra byte is post appended to the buffer
381 * and the null termination is added. However, when allocating (len+1) byte
382 * of memory, we need to make sure that there is no uint overflow when doing
383 * addition. In theory check len < UINT_MAX protects the uint overflow. For
384 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
385 * guess, now, it is assumed that the private command buffer size is no
386 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
387 */
388 if (len > MAX_USER_COMMAND_SIZE)
389 {
390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
391 "Invalid length");
392 return NULL;
393 }
394
395 ptr = kmalloc(len + 1, GFP_KERNEL);
396 if (NULL == ptr)
397 {
398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
399 "unable to allocate memory");
400 return NULL;
401 }
402
403 if (copy_from_user(ptr, wrqu_data, len))
404 {
405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
406 "%s: failed to copy data to user buffer", __func__);
407 kfree(ptr);
408 return NULL;
409 }
410 ptr[len] = '\0';
411 return ptr;
412}
413
414/**---------------------------------------------------------------------------
415
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 \brief hdd_wlan_get_version() -
417
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800418 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700419
420 \param - pAdapter Pointer to the adapter.
421 wrqu - Pointer to IOCTL REQUEST Data.
422 extra - Pointer to char
423
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800424 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700425
426 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800427void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
428 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700429{
430 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800431 tSirVersionString wcnss_SW_version;
432 tSirVersionString wcnss_HW_version;
433 char *pSWversion;
434 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700436
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800437 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
438 sizeof(wcnss_SW_version));
439 if (VOS_IS_STATUS_SUCCESS(status))
440 {
441 pSWversion = wcnss_SW_version;
442 }
443 else
444 {
445 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 }
447
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800448 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
449 sizeof(wcnss_HW_version));
450 if (VOS_IS_STATUS_SUCCESS(status))
451 {
452 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800454 else
455 {
456 pHWversion = "Unknown";
457 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700458
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700459 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800460 "Host SW:%s, FW:%s, HW:%s",
461 QWLAN_VERSIONSTR,
462 pSWversion,
463 pHWversion);
464
465 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466}
467
Jeff Johnson295189b2012-06-20 16:38:30 -0700468int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
469{
470 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
471 v_U32_t threshold = 0,status = 0;
472
473 ENTER();
474
Agarwal Ashish971c2882013-10-30 20:11:12 +0530475 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
476 {
477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 "%s:LOGP in Progress. Ignore!!!",__func__);
479 return status;
480 }
481
482 if ( eHAL_STATUS_SUCCESS !=
483 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
484 {
c_hpothub8245442013-11-20 23:41:09 +0530485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
486 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 return -EIO;
488 }
489 wrqu->rts.value = threshold;
490
491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800492 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
494 EXIT();
495
496 return 0;
497}
498
499int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
500{
501 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
502 v_U32_t threshold = 0,status = 0;
503
504 ENTER();
505
Agarwal Ashish971c2882013-10-30 20:11:12 +0530506 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
507 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
509 "%s:LOGP in Progress. Ignore!!!",__func__);
510 return status;
511 }
512
513 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
514 != eHAL_STATUS_SUCCESS )
515 {
c_hpothub8245442013-11-20 23:41:09 +0530516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
517 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 return -EIO;
519 }
520 wrqu->frag.value = threshold;
521
522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800523 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700524
525 EXIT();
526
527 return 0;
528}
529
530int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
531{
Jeff Johnsone7245742012-09-05 17:12:55 -0700532 int i;
533 if (channel > 0)
534 {
535 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
536 {
537 if (channel == freq_chan_map[i].chan)
538 {
539 *pfreq = freq_chan_map[i].freq;
540 return 1;
541 }
542 }
543 }
544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800545 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700546 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700547}
548
549static v_BOOL_t
550hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
551{
552 v_BOOL_t rsnType = VOS_FALSE;
553 // is the authType supported?
554 switch (authType)
555 {
556 case eCSR_AUTH_TYPE_NONE: //never used
557 rsnType = eANI_BOOLEAN_FALSE;
558 break;
559 // MAC layer authentication types
560 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
561 rsnType = eANI_BOOLEAN_FALSE;
562 break;
563 case eCSR_AUTH_TYPE_SHARED_KEY:
564 rsnType = eANI_BOOLEAN_FALSE;
565 break;
566 case eCSR_AUTH_TYPE_AUTOSWITCH:
567 rsnType = eANI_BOOLEAN_FALSE;
568 break;
569
570 // Upper layer authentication types
571 case eCSR_AUTH_TYPE_WPA:
572 rsnType = eANI_BOOLEAN_TRUE;
573 break;
574 case eCSR_AUTH_TYPE_WPA_PSK:
575 rsnType = eANI_BOOLEAN_TRUE;
576 break;
577 case eCSR_AUTH_TYPE_WPA_NONE:
578 rsnType = eANI_BOOLEAN_TRUE;
579 break;
580#ifdef WLAN_FEATURE_VOWIFI_11R
581 case eCSR_AUTH_TYPE_FT_RSN:
582#endif
583 case eCSR_AUTH_TYPE_RSN:
584 rsnType = eANI_BOOLEAN_TRUE;
585 break;
586#ifdef WLAN_FEATURE_VOWIFI_11R
587 case eCSR_AUTH_TYPE_FT_RSN_PSK:
588#endif
589 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700590#ifdef WLAN_FEATURE_11W
591 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
592#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 rsnType = eANI_BOOLEAN_TRUE;
594 break;
595 //case eCSR_AUTH_TYPE_FAILED:
596 case eCSR_AUTH_TYPE_UNKNOWN:
597 rsnType = eANI_BOOLEAN_FALSE;
598 break;
599 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800600 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
601 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 rsnType = eANI_BOOLEAN_FALSE;
603 break;
604 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800605 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700606 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 return rsnType;
608}
609
610static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
611{
612 struct statsContext *pStatsContext;
613 hdd_adapter_t *pAdapter;
614
615 if (ioctl_debug)
616 {
617 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700618 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 }
620
621 if (NULL == pContext)
622 {
623 hddLog(VOS_TRACE_LEVEL_ERROR,
624 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700625 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 return;
627 }
628
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 pStatsContext = pContext;
630 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800631
632 /* there is a race condition that exists between this callback
633 function and the caller since the caller could time out either
634 before or while this code is executing. we use a spinlock to
635 serialize these actions */
636 spin_lock(&hdd_context_lock);
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
639 {
640 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800641 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 hddLog(VOS_TRACE_LEVEL_WARN,
643 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700644 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 if (ioctl_debug)
646 {
647 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700648 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 }
650 return;
651 }
652
Jeff Johnson72a40512013-12-19 10:14:15 -0800653 /* context is valid so caller is still waiting */
654
655 /* paranoia: invalidate the magic */
656 pStatsContext->magic = 0;
657
658 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 pAdapter->rssi = rssi;
660
Jeff Johnson72a40512013-12-19 10:14:15 -0800661 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800663
664 /* serialization is complete */
665 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700666}
667
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530668static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
669{
670 struct statsContext *pStatsContext;
671 hdd_adapter_t *pAdapter;
672
673 if (ioctl_debug)
674 {
675 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
676 __func__, (int)snr, (int)staId, pContext);
677 }
678
679 if (NULL == pContext)
680 {
681 hddLog(VOS_TRACE_LEVEL_ERROR,
682 "%s: Bad param, pContext [%p]",
683 __func__, pContext);
684 return;
685 }
686
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530687 pStatsContext = pContext;
688 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800689
690 /* there is a race condition that exists between this callback
691 function and the caller since the caller could time out either
692 before or while this code is executing. we use a spinlock to
693 serialize these actions */
694 spin_lock(&hdd_context_lock);
695
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530696 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
697 {
698 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800699 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530700 hddLog(VOS_TRACE_LEVEL_WARN,
701 "%s: Invalid context, pAdapter [%p] magic [%08x]",
702 __func__, pAdapter, pStatsContext->magic);
703 if (ioctl_debug)
704 {
705 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
706 __func__, pAdapter, pStatsContext->magic);
707 }
708 return;
709 }
710
Jeff Johnson72a40512013-12-19 10:14:15 -0800711 /* context is valid so caller is still waiting */
712
713 /* paranoia: invalidate the magic */
714 pStatsContext->magic = 0;
715
716 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530717 pAdapter->snr = snr;
718
Jeff Johnson72a40512013-12-19 10:14:15 -0800719 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530720 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800721
722 /* serialization is complete */
723 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530724}
725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
727{
728 struct statsContext context;
729 hdd_context_t *pHddCtx;
730 hdd_station_ctx_t *pHddStaCtx;
731 eHalStatus hstatus;
732 long lrc;
733
734 if (NULL == pAdapter)
735 {
736 hddLog(VOS_TRACE_LEVEL_WARN,
737 "%s: Invalid context, pAdapter", __func__);
738 return VOS_STATUS_E_FAULT;
739 }
740 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
741 {
742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
743 /* return a cached value */
744 *rssi_value = pAdapter->rssi;
745 return VOS_STATUS_SUCCESS;
746 }
747
748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
749 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
750
751 init_completion(&context.completion);
752 context.pAdapter = pAdapter;
753 context.magic = RSSI_CONTEXT_MAGIC;
754
755 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
756 pHddStaCtx->conn_info.staId[ 0 ],
757 pHddStaCtx->conn_info.bssId,
758 &context, pHddCtx->pvosContext);
759 if (eHAL_STATUS_SUCCESS != hstatus)
760 {
761 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700762 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 /* we'll returned a cached value below */
764 }
765 else
766 {
767 /* request was sent -- wait for the response */
768 lrc = wait_for_completion_interruptible_timeout(&context.completion,
769 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 if (lrc <= 0)
771 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800772 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700773 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 /* we'll now returned a cached value below */
775 }
776 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800777
778 /* either we never sent a request, we sent a request and received a
779 response or we sent a request and timed out. if we never sent a
780 request or if we sent a request and got a response, we want to
781 clear the magic out of paranoia. if we timed out there is a
782 race condition such that the callback function could be
783 executing at the same time we are. of primary concern is if the
784 callback function had already verified the "magic" but had not
785 yet set the completion variable when a timeout occurred. we
786 serialize these activities by invalidating the magic while
787 holding a shared spinlock which will cause us to block if the
788 callback is currently executing */
789 spin_lock(&hdd_context_lock);
790 context.magic = 0;
791 spin_unlock(&hdd_context_lock);
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 *rssi_value = pAdapter->rssi;
794
795 return VOS_STATUS_SUCCESS;
796}
797
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530798VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
799{
800 struct statsContext context;
801 hdd_context_t *pHddCtx;
802 hdd_station_ctx_t *pHddStaCtx;
803 eHalStatus hstatus;
804 long lrc;
805 int valid;
806
807 if (NULL == pAdapter)
808 {
809 hddLog(VOS_TRACE_LEVEL_ERROR,
810 "%s: Invalid context, pAdapter", __func__);
811 return VOS_STATUS_E_FAULT;
812 }
813
814 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
815
816 valid = wlan_hdd_validate_context(pHddCtx);
817 if (0 != valid)
818 {
819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
820 return VOS_STATUS_E_FAULT;
821 }
822
823 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
824 if (NULL == pHddStaCtx)
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
827 return VOS_STATUS_E_FAULT;
828 }
829
830 init_completion(&context.completion);
831 context.pAdapter = pAdapter;
832 context.magic = SNR_CONTEXT_MAGIC;
833
834 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
835 pHddStaCtx->conn_info.staId[ 0 ],
836 pHddStaCtx->conn_info.bssId,
837 &context);
838 if (eHAL_STATUS_SUCCESS != hstatus)
839 {
840 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
841 __func__);
842 /* we'll returned a cached value below */
843 }
844 else
845 {
846 /* request was sent -- wait for the response */
847 lrc = wait_for_completion_interruptible_timeout(&context.completion,
848 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530849 if (lrc <= 0)
850 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530852 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530853 /* we'll now returned a cached value below */
854 }
855 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800856
857 /* either we never sent a request, we sent a request and received a
858 response or we sent a request and timed out. if we never sent a
859 request or if we sent a request and got a response, we want to
860 clear the magic out of paranoia. if we timed out there is a
861 race condition such that the callback function could be
862 executing at the same time we are. of primary concern is if the
863 callback function had already verified the "magic" but had not
864 yet set the completion variable when a timeout occurred. we
865 serialize these activities by invalidating the magic while
866 holding a shared spinlock which will cause us to block if the
867 callback is currently executing */
868 spin_lock(&hdd_context_lock);
869 context.magic = 0;
870 spin_unlock(&hdd_context_lock);
871
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530872 *snr = pAdapter->snr;
873
874 return VOS_STATUS_SUCCESS;
875}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800876#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800877
878static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
879{
880 struct statsContext *pStatsContext;
881 hdd_adapter_t *pAdapter;
882 if (ioctl_debug)
883 {
884 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
885 __func__, (int)rssi, (int)staId, pContext);
886 }
887
888 if (NULL == pContext)
889 {
890 hddLog(VOS_TRACE_LEVEL_ERROR,
891 "%s: Bad param, pContext [%p]",
892 __func__, pContext);
893 return;
894 }
895
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800896 pStatsContext = pContext;
897 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800898
899 /* there is a race condition that exists between this callback
900 function and the caller since the caller could time out either
901 before or while this code is executing. we use a spinlock to
902 serialize these actions */
903 spin_lock(&hdd_context_lock);
904
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800905 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
906 {
907 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800908 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800909 hddLog(VOS_TRACE_LEVEL_WARN,
910 "%s: Invalid context, pAdapter [%p] magic [%08x]",
911 __func__, pAdapter, pStatsContext->magic);
912 if (ioctl_debug)
913 {
914 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
915 __func__, pAdapter, pStatsContext->magic);
916 }
917 return;
918 }
919
Jeff Johnson72a40512013-12-19 10:14:15 -0800920 /* context is valid so caller is still waiting */
921
922 /* paranoia: invalidate the magic */
923 pStatsContext->magic = 0;
924
925 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800926 pAdapter->rssi = rssi;
927
Jeff Johnson72a40512013-12-19 10:14:15 -0800928 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800929 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800930
931 /* serialization is complete */
932 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800933}
934
935
936
937VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
938{
939 struct statsContext context;
940 hdd_context_t *pHddCtx = NULL;
941 hdd_station_ctx_t *pHddStaCtx = NULL;
942 eHalStatus hstatus;
943 long lrc;
944
945 if (NULL == pAdapter)
946 {
947 hddLog(VOS_TRACE_LEVEL_WARN,
948 "%s: Invalid context, pAdapter", __func__);
949 return VOS_STATUS_E_FAULT;
950 }
951 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
952 {
953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
954 /* return a cached value */
955 *rssi_value = pAdapter->rssi;
956 return VOS_STATUS_SUCCESS;
957 }
958
959 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
960 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
961
962 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
963 {
964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
965 /* return a cached value */
966 *rssi_value = 0;
967 return VOS_STATUS_SUCCESS;
968 }
969 init_completion(&context.completion);
970 context.pAdapter = pAdapter;
971 context.magic = RSSI_CONTEXT_MAGIC;
972
973 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
974 pHddStaCtx->conn_info.staId[ 0 ],
975 pHddStaCtx->conn_info.bssId,
976 &context, pHddCtx->pvosContext);
977 if (eHAL_STATUS_SUCCESS != hstatus)
978 {
979 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
980 __func__);
981 /* we'll returned a cached value below */
982 }
983 else
984 {
985 /* request was sent -- wait for the response */
986 lrc = wait_for_completion_interruptible_timeout(&context.completion,
987 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800988 if (lrc <= 0)
989 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800990 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800991 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800992 /* we'll now returned a cached value below */
993 }
994 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800995
996 /* either we never sent a request, we sent a request and received a
997 response or we sent a request and timed out. if we never sent a
998 request or if we sent a request and got a response, we want to
999 clear the magic out of paranoia. if we timed out there is a
1000 race condition such that the callback function could be
1001 executing at the same time we are. of primary concern is if the
1002 callback function had already verified the "magic" but had not
1003 yet set the completion variable when a timeout occurred. we
1004 serialize these activities by invalidating the magic while
1005 holding a shared spinlock which will cause us to block if the
1006 callback is currently executing */
1007 spin_lock(&hdd_context_lock);
1008 context.magic = 0;
1009 spin_unlock(&hdd_context_lock);
1010
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001011 *rssi_value = pAdapter->rssi;
1012
1013 return VOS_STATUS_SUCCESS;
1014}
1015#endif
1016
1017
Jeff Johnson295189b2012-06-20 16:38:30 -07001018void hdd_StatisticsCB( void *pStats, void *pContext )
1019{
1020 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1021 hdd_stats_t *pStatsCache = NULL;
1022 hdd_wext_state_t *pWextState;
1023 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1024
1025 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1026 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1027 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1028 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1029 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1030 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1031
1032 if (pAdapter!= NULL)
1033 pStatsCache = &pAdapter->hdd_stats;
1034
1035
1036 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1037 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1038 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1039 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1040 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1041 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1042
1043 if (pStatsCache!=NULL)
1044 {
1045 // and copy the stats into the cache we keep in the adapter instance structure
1046 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1047 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1048 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1049 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1050 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1051 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1052 }
1053
1054 if(pAdapter)
1055 {
1056 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1057 if(pWextState)
1058 {
1059 vos_status = vos_event_set(&pWextState->vosevent);
1060 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1061 {
1062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001063 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 return;
1065 }
1066 }
1067 }
1068}
1069
1070void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1071{
1072 v_CONTEXT_t pVosContext;
1073 hdd_context_t *pHddCtx;
1074 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1075#if 0
1076 hdd_wext_state_t *pWextState;
1077 v_U32_t roamId;
1078#endif
1079
1080 ENTER();
1081
1082 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1083
1084 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1085 if (NULL == pHddCtx)
1086 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001087 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 return;
1089 }
1090#if 0
1091 pWextState = pAdapter->pWextState;
1092#endif
1093
1094 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1095 {
1096 //TODO Verify is this is really used. If yes need to fix it.
1097 hdd_reconnect_all_adapters( pHddCtx );
1098#if 0
1099 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1100 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1101 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1102
1103 if(VOS_STATUS_SUCCESS == vosStatus)
1104 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1105 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1106
1107 sme_RoamConnect(halHandle,
1108 pAdapter->sessionId, &(pWextState->roamProfile),
1109 &roamId);
1110#endif
1111 }
1112
1113 EXIT();
1114
1115}
1116
1117void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1118{
1119 int i = 0;
1120 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1121
1122 /* clear WPA/RSN/WSC IE information in the profile */
1123 pWextState->roamProfile.nWPAReqIELength = 0;
1124 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1125 pWextState->roamProfile.nRSNReqIELength = 0;
1126 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1127
Chet Lanctot186b5732013-03-18 10:26:30 -07001128#ifdef FEATURE_WLAN_WAPI
1129 pWextState->roamProfile.nWAPIReqIELength = 0;
1130 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1131#endif
1132
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301135 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1137 pWextState->roamProfile.nAddIEAssocLength = 0;
1138
1139 pWextState->roamProfile.EncryptionType.numEntries = 1;
1140 pWextState->roamProfile.EncryptionType.encryptionType[0]
1141 = eCSR_ENCRYPT_TYPE_NONE;
1142
1143 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1144 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1145 = eCSR_ENCRYPT_TYPE_NONE;
1146
1147 pWextState->roamProfile.AuthType.numEntries = 1;
1148 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1149
Chet Lanctot186b5732013-03-18 10:26:30 -07001150#ifdef WLAN_FEATURE_11W
1151 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1152 pWextState->roamProfile.MFPRequired = 0;
1153 pWextState->roamProfile.MFPCapable = 0;
1154#endif
1155
Jeff Johnson295189b2012-06-20 16:38:30 -07001156 pWextState->authKeyMgmt = 0;
1157
1158 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1159 {
1160 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1161 {
1162 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1163 }
1164 }
1165#ifdef FEATURE_WLAN_WAPI
1166 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1167 pAdapter->wapi_info.nWapiMode = 0;
1168#endif
1169
1170 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1171
1172}
1173
1174void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1175{
1176 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001177
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001178 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1179 {
1180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1181 "%s: Invalid pAdapter magic", __func__);
1182 }
1183 else
1184 {
1185 complete(&pAdapter->ula_complete);
1186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001187}
1188
1189VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1190{
1191 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001193 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001194
1195 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1196 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001197 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001198
1199 /*To avoid race condition between the set key and the last EAPOL
1200 packet, notify TL to finish upper layer authentication incase if the
1201 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001202 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001203
1204 if ( vos_status != VOS_STATUS_SUCCESS )
1205 {
1206 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1207 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1208 __LINE__, vos_status );
1209 return vos_status;
1210
1211 }
1212
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001213 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301215 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001216 {
1217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301218 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001219 /* we'll still fall through and return success since the
1220 * connection may still get established but is just taking
1221 * too long for us to wait */
1222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 }
1224 return VOS_STATUS_SUCCESS;
1225}
1226
1227v_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)
1228{
1229
1230 int left = ie_len;
1231 v_U8_t *ptr = ie;
1232 v_U8_t elem_id,elem_len;
1233 v_U8_t eid = 0xDD;
1234
1235 if ( NULL == ie || 0 == ie_len )
1236 return NULL;
1237
1238 while(left >= 2)
1239 {
1240 elem_id = ptr[0];
1241 elem_len = ptr[1];
1242 left -= 2;
1243 if(elem_len > left)
1244 {
1245 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001246 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 eid,elem_len,left);
1248 return NULL;
1249 }
1250 if (elem_id == eid)
1251 {
1252 if(memcmp( &ptr[2], oui, oui_size)==0)
1253 return ptr;
1254 }
1255
1256 left -= elem_len;
1257 ptr += (elem_len + 2);
1258 }
1259 return NULL;
1260}
1261
1262static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1263 union iwreq_data *wrqu, char *extra)
1264{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001265 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 /* Do nothing for now */
1267 return 0;
1268}
1269
1270static int iw_get_name(struct net_device *dev,
1271 struct iw_request_info *info,
1272 char *wrqu, char *extra)
1273{
1274
1275 ENTER();
1276 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1277 EXIT();
1278 return 0;
1279}
1280
1281static int iw_set_mode(struct net_device *dev,
1282 struct iw_request_info *info,
1283 union iwreq_data *wrqu, char *extra)
1284{
1285 hdd_wext_state_t *pWextState;
1286 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1287 tCsrRoamProfile *pRoamProfile;
1288 eCsrRoamBssType LastBSSType;
1289 eMib_dot11DesiredBssType connectedBssType;
1290 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001292
1293 ENTER();
1294
1295 if (NULL == pAdapter)
1296 {
1297 hddLog(VOS_TRACE_LEVEL_WARN,
1298 "%s: Invalid context, pAdapter", __func__);
1299 return 0;
1300 }
1301
1302 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1304 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 return 0;
1306 }
1307
1308 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1309 if (pWextState == NULL)
1310 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301311 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 return -EINVAL;
1313 }
1314
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 pRoamProfile = &pWextState->roamProfile;
1317 LastBSSType = pRoamProfile->BSSType;
1318
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301319 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001320
1321 switch (wrqu->mode)
1322 {
1323 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301324 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1326 // Set the phymode correctly for IBSS.
1327 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1328 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001329 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 break;
1332 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301333 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 break;
1337 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301338 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1340 break;
1341 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301342 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 return -EOPNOTSUPP;
1344 }
1345
1346 if ( LastBSSType != pRoamProfile->BSSType )
1347 {
1348 //the BSS mode changed
1349 // We need to issue disconnect if connected or in IBSS disconnect state
1350 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1351 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1352 {
1353 VOS_STATUS vosStatus;
1354 // need to issue a disconnect to CSR.
1355 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1356 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1357 pAdapter->sessionId,
1358 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1359 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301360 {
1361 long ret;
1362 ret = wait_for_completion_interruptible_timeout(
1363 &pAdapter->disconnect_comp_var,
1364 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1365 if (ret <= 0)
1366 hddLog(VOS_TRACE_LEVEL_ERROR,
1367 FL("failed wait on disconnect_comp_var %ld"), ret);
1368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 }
1370 }
1371
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 EXIT();
1373 return 0;
1374}
1375
1376
1377static int iw_get_mode(struct net_device *dev,
1378 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301379 union iwreq_data *wrqu,
1380 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001381{
1382
1383 hdd_wext_state_t *pWextState;
1384 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1385
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301386 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387
1388 if (NULL == pAdapter)
1389 {
1390 hddLog(VOS_TRACE_LEVEL_WARN,
1391 "%s: Invalid context, pAdapter", __func__);
1392 return 0;
1393 }
1394
1395 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1397 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001398 return 0;
1399 }
1400
1401 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1402 if (pWextState == NULL)
1403 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301404 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 return -EINVAL;
1406 }
1407
1408 switch (pWextState->roamProfile.BSSType)
1409 {
1410 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001411 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301412 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 break;
1414 case eCSR_BSS_TYPE_IBSS:
1415 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001416 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301417 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 break;
1419 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001420 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301421 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 break;
1423 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001424 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 break;
1426 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301427
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 return 0;
1429}
1430
1431static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1432 union iwreq_data *wrqu, char *extra)
1433{
1434 v_U32_t numChans = 0;
1435 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1436 v_U32_t indx = 0;
1437 v_U32_t status = 0;
1438
1439 hdd_wext_state_t *pWextState;
1440 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1441 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1442 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1443 tCsrRoamProfile * pRoamProfile;
1444 ENTER();
1445
1446 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1448 return status;
1449 }
1450
1451 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1452
1453 pRoamProfile = &pWextState->roamProfile;
1454
Arif Hussain6d2a3322013-11-17 19:50:10 -08001455 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001456
1457 /* Link is up then return cant set channel*/
1458 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1459 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1460 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001461 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 return -EOPNOTSUPP;
1463 }
1464
1465 /* Settings by Frequency as input */
1466 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1467 (wrqu->freq.m <= (tANI_U32)5.825e8))
1468 {
1469 tANI_U32 freq = wrqu->freq.m / 100000;
1470
1471 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1472 indx++;
1473 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1474 {
1475 return -EINVAL;
1476 }
1477 wrqu->freq.e = 0;
1478 wrqu->freq.m = freq_chan_map[indx].chan;
1479
1480 }
1481
1482 if (wrqu->freq.e == 0)
1483 {
1484 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1485 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1486 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001487 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001488 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1490 return -EINVAL;
1491 }
1492
1493 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1494
1495 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1496 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1498 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 return -EIO;
1500 }
1501
1502 for (indx = 0; indx < numChans; indx++) {
1503 if (wrqu->freq.m == validChan[indx]){
1504 break;
1505 }
1506 }
1507 }
1508 else{
1509
1510 return -EINVAL;
1511 }
1512
1513 if(indx >= numChans)
1514 {
1515 return -EINVAL;
1516 }
1517
1518 /* Set the Operational Channel */
1519 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1520 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1521 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1522
Arif Hussain6d2a3322013-11-17 19:50:10 -08001523 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001524
1525 EXIT();
1526
1527 return status;
1528}
1529
1530static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1531 struct iw_freq *fwrq, char *extra)
1532{
Jeff Johnsone7245742012-09-05 17:12:55 -07001533 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1535 tHalHandle hHal;
1536 hdd_wext_state_t *pWextState;
1537 tCsrRoamProfile * pRoamProfile;
1538 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1539
1540 ENTER();
1541
1542 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1544 return status;
1545 }
1546
1547 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1548 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1549
1550 pRoamProfile = &pWextState->roamProfile;
1551
1552 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1553 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001554 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 {
c_hpothub8245442013-11-20 23:41:09 +05301556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1557 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 return -EIO;
1559 }
1560 else
1561 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001562 status = hdd_wlan_get_freq(channel, &freq);
1563 if( TRUE == status )
1564 {
1565 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1566 * iwlist & iwconfig command shows frequency into proper
1567 * format (2.412 GHz instead of 246.2 MHz)*/
1568 fwrq->m = freq;
1569 fwrq->e = MHZ;
1570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 }
1572 }
1573 else
1574 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001575 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1576 * iwlist & iwconfig command shows frequency into proper
1577 * format (2.412 GHz instead of 246.2 MHz)*/
1578 fwrq->m = 0;
1579 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001582}
1583
1584static int iw_get_tx_power(struct net_device *dev,
1585 struct iw_request_info *info,
1586 union iwreq_data *wrqu, char *extra)
1587{
1588
1589 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1590 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1591 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1592
1593 if (pHddCtx->isLogpInProgress)
1594 {
1595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1596 "%s:LOGP in Progress. Ignore!!!",__func__);
1597 return -EBUSY;
1598 }
1599
1600 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1601 {
1602 wrqu->txpower.value = 0;
1603 return 0;
1604 }
1605 wlan_hdd_get_classAstats(pAdapter);
1606 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1607
1608 return 0;
1609}
1610
1611static int iw_set_tx_power(struct net_device *dev,
1612 struct iw_request_info *info,
1613 union iwreq_data *wrqu, char *extra)
1614{
1615 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1616 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1617
1618 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1619 {
1620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1621 return 0;
1622 }
1623
1624 ENTER();
1625
1626 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1627 {
c_hpothub8245442013-11-20 23:41:09 +05301628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1629 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 return -EIO;
1631 }
1632
1633 EXIT();
1634
1635 return 0;
1636}
1637
1638static int iw_get_bitrate(struct net_device *dev,
1639 struct iw_request_info *info,
1640 union iwreq_data *wrqu, char *extra)
1641{
1642 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1643 eHalStatus status = eHAL_STATUS_SUCCESS;
1644 hdd_wext_state_t *pWextState;
1645 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1646 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1647
1648 ENTER();
1649
1650 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1652 return status;
1653 }
1654
1655 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1656 wrqu->bitrate.value = 0;
1657 }
1658 else {
1659 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1660 SME_SUMMARY_STATS |
1661 SME_GLOBAL_CLASSA_STATS |
1662 SME_GLOBAL_CLASSB_STATS |
1663 SME_GLOBAL_CLASSC_STATS |
1664 SME_GLOBAL_CLASSD_STATS |
1665 SME_PER_STA_STATS,
1666 hdd_StatisticsCB, 0, FALSE,
1667 pHddStaCtx->conn_info.staId[0], pAdapter );
1668
1669 if(eHAL_STATUS_SUCCESS != status)
1670 {
1671 hddLog(VOS_TRACE_LEVEL_ERROR,
1672 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001673 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 return status;
1675 }
1676
1677 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1678
1679 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1680
1681 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1682 {
1683 hddLog(VOS_TRACE_LEVEL_ERROR,
1684 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001685 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 return VOS_STATUS_E_FAILURE;
1687 }
1688
1689 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1690 }
1691
1692 EXIT();
1693
1694 return vos_status;
1695}
1696/* ccm call back function */
1697
1698static int iw_set_bitrate(struct net_device *dev,
1699 struct iw_request_info *info,
1700 union iwreq_data *wrqu,
1701 char *extra)
1702{
1703 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1704 hdd_wext_state_t *pWextState;
1705 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1706 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1707 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1708 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1709 v_U32_t i, rate;
1710 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1711
1712 ENTER();
1713
1714 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1716 return 0;
1717 }
1718
1719 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1720
1721 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1722 {
1723 return -ENXIO ;
1724 }
1725
1726 rate = wrqu->bitrate.value;
1727
1728 if (rate == -1)
1729 {
1730 rate = WNI_CFG_FIXED_RATE_AUTO;
1731 valid_rate = TRUE;
1732 }
1733 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1734 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1735 {
1736 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1737 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1738 {
1739 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1740 WNI_CFG_SUPPORTED_RATES_11A,
1741 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1742 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1743 WNI_CFG_SUPPORTED_RATES_11B,
1744 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1745 {
1746 for (i = 0; i < (b_len + a_len); ++i)
1747 {
1748 /* supported rates returned is double the actual rate so we divide it by 2 */
1749 if ((supp_rates[i]&0x7F)/2 == rate)
1750 {
1751 valid_rate = TRUE;
1752 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1753 break;
1754 }
1755 }
1756 }
1757 }
1758 }
1759 if (valid_rate != TRUE)
1760 {
1761 return -EINVAL;
1762 }
1763 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1764 WNI_CFG_FIXED_RATE, rate,
1765 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1766 {
c_hpothub8245442013-11-20 23:41:09 +05301767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1768 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 return -EIO;
1770 }
1771 return 0;
1772}
1773
1774
1775static int iw_set_genie(struct net_device *dev,
1776 struct iw_request_info *info,
1777 union iwreq_data *wrqu,
1778 char *extra)
1779{
1780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1781 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001782 u_int8_t *genie = NULL;
1783 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 v_U16_t remLen;
1785
1786 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001787
1788 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1790 "%s:LOGP in Progress. Ignore!!!", __func__);
1791 return 0;
1792 }
1793
1794 if (!wrqu->data.length) {
1795 hdd_clearRoamProfileIe(pAdapter);
1796 EXIT();
1797 return 0;
1798 }
1799
1800 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1801 wrqu->data.length);
1802 if (NULL == base_genie)
1803 {
1804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1805 "mem_alloc_copy_from_user_helper fail");
1806 return -ENOMEM;
1807 }
1808
1809 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001810
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 remLen = wrqu->data.length;
1812
Arif Hussain6d2a3322013-11-17 19:50:10 -08001813 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001814
1815 /* clear any previous genIE before this call */
1816 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1817
1818 while (remLen >= 2)
1819 {
1820 v_U16_t eLen = 0;
1821 v_U8_t elementId;
1822 elementId = *genie++;
1823 eLen = *genie++;
1824 remLen -= 2;
1825
Arif Hussain6d2a3322013-11-17 19:50:10 -08001826 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 __func__, elementId, eLen);
1828
1829 switch ( elementId )
1830 {
1831 case IE_EID_VENDOR:
1832 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001833 {
1834 kfree(base_genie);
1835 return -EINVAL;
1836 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001837
1838 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1839 {
1840 v_U16_t curGenIELen = pWextState->genIE.length;
1841 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1842 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1843
1844 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1845 {
1846 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001847 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001849 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 return -ENOMEM;
1851 }
1852 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1853 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1854 pWextState->genIE.length += eLen + 2;
1855 }
1856 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1857 {
1858 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1859 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1860 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1861 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1862 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1863 }
1864 else /* any vendorId except WPA IE should be accumulated to genIE */
1865 {
1866 v_U16_t curGenIELen = pWextState->genIE.length;
1867 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1868 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1869
1870 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1871 {
1872 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001873 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001875 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 return -ENOMEM;
1877 }
1878 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1879 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1880 pWextState->genIE.length += eLen + 2;
1881 }
1882 break;
1883 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001884 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1886 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1887 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1888 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1889 break;
1890
1891 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001892 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001893 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 return 0;
1895 }
1896 genie += eLen;
1897 remLen -= eLen;
1898 }
1899 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001900 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 return 0;
1902}
1903
1904static int iw_get_genie(struct net_device *dev,
1905 struct iw_request_info *info,
1906 union iwreq_data *wrqu,
1907 char *extra)
1908{
1909 hdd_wext_state_t *pWextState;
1910 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1911 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1912 eHalStatus status;
1913 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1914 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1915
1916 ENTER();
1917
1918 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1920 return 0;
1921 }
1922
1923
Arif Hussain6d2a3322013-11-17 19:50:10 -08001924 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001925
1926 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1927
1928 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1929 {
1930 return -ENXIO;
1931 }
1932
1933 // Return something ONLY if we are associated with an RSN or WPA network
1934 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1935 pWextState->roamProfile.negotiatedAuthType))
1936 {
1937 return -ENXIO;
1938 }
1939
1940 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1941 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1942 pAdapter->sessionId,
1943 &length,
1944 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001945 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1946 if (wrqu->data.length < length)
1947 {
1948 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1949 return -EFAULT;
1950 }
Arif Hussain9f05be02014-02-05 12:06:53 -08001951 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001952 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001953
Arif Hussain6d2a3322013-11-17 19:50:10 -08001954 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001955
1956 EXIT();
1957
1958 return 0;
1959}
1960
1961static int iw_get_encode(struct net_device *dev,
1962 struct iw_request_info *info,
1963 struct iw_point *dwrq, char *extra)
1964{
1965 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1966 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1967 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1968 int keyId;
1969 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1970 int i;
1971
1972 ENTER();
1973
1974 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1976 return 0;
1977 }
1978
1979 keyId = pRoamProfile->Keys.defaultIndex;
1980
1981 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1982 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001983 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 return -EINVAL;
1985 }
1986
1987 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1988 {
1989 dwrq->flags |= IW_ENCODE_ENABLED;
1990 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1991 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1992
1993 dwrq->flags |= (keyId + 1);
1994
1995 }
1996 else
1997 {
1998 dwrq->flags |= IW_ENCODE_DISABLED;
1999 }
2000
2001 for(i=0; i < MAX_WEP_KEYS; i++)
2002 {
2003 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2004 {
2005 continue;
2006 }
2007 else
2008 {
2009 break;
2010 }
2011 }
2012
2013 if(MAX_WEP_KEYS == i)
2014 {
2015 dwrq->flags |= IW_ENCODE_NOKEY;
2016 }
2017
2018 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2019
2020 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2021 {
2022 dwrq->flags |= IW_ENCODE_OPEN;
2023 }
2024 else
2025 {
2026 dwrq->flags |= IW_ENCODE_RESTRICTED;
2027 }
2028 EXIT();
2029 return 0;
2030}
2031
2032#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2033#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2034
2035
2036/*
2037 * This function sends a single 'key' to LIM at all time.
2038 */
2039
2040static int iw_get_rts_threshold(struct net_device *dev,
2041 struct iw_request_info *info,
2042 union iwreq_data *wrqu, char *extra)
2043{
2044 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2045 v_U32_t status = 0;
2046
2047 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2048
2049 return status;
2050}
2051
2052static int iw_set_rts_threshold(struct net_device *dev,
2053 struct iw_request_info *info,
2054 union iwreq_data *wrqu, char *extra)
2055{
2056 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2057 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2058
2059 ENTER();
2060
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002061 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2062 {
2063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2064 "%s:LOGP in Progress. Ignore!!!", __func__);
2065 return -EAGAIN;
2066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2068 {
2069 return -EINVAL;
2070 }
2071
2072 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2073 {
c_hpothub8245442013-11-20 23:41:09 +05302074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2075 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 return -EIO;
2077 }
2078
2079 EXIT();
2080
2081 return 0;
2082}
2083
2084static int iw_get_frag_threshold(struct net_device *dev,
2085 struct iw_request_info *info,
2086 union iwreq_data *wrqu, char *extra)
2087{
2088 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2089 v_U32_t status = 0;
2090
2091 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2092
2093 return status;
2094}
2095
2096static int iw_set_frag_threshold(struct net_device *dev,
2097 struct iw_request_info *info,
2098 union iwreq_data *wrqu, char *extra)
2099{
2100 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2101 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2102
2103 ENTER();
2104
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002105 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2106 {
2107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2108 "%s:LOGP in Progress. Ignore!!!", __func__);
2109 return -EBUSY;
2110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2112 {
2113 return -EINVAL;
2114 }
2115
2116 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2117 {
c_hpothub8245442013-11-20 23:41:09 +05302118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2119 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 return -EIO;
2121 }
2122
2123 EXIT();
2124
2125 return 0;
2126}
2127
2128static int iw_get_power_mode(struct net_device *dev,
2129 struct iw_request_info *info,
2130 union iwreq_data *wrqu, char *extra)
2131{
2132 ENTER();
2133 return -EOPNOTSUPP;
2134}
2135
2136static int iw_set_power_mode(struct net_device *dev,
2137 struct iw_request_info *info,
2138 union iwreq_data *wrqu, char *extra)
2139{
2140 ENTER();
2141 return -EOPNOTSUPP;
2142}
2143
2144static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2145 union iwreq_data *wrqu, char *extra)
2146{
2147 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2148 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2149 struct iw_range *range = (struct iw_range *) extra;
2150
2151 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2152
2153 v_U32_t num_channels = sizeof(channels);
2154 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2155 v_U32_t a_len;
2156 v_U32_t b_len;
2157 v_U32_t active_phy_mode = 0;
2158 v_U8_t index = 0, i;
2159
2160 ENTER();
2161
2162 wrqu->data.length = sizeof(struct iw_range);
2163 memset(range, 0, sizeof(struct iw_range));
2164
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002165 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2166 {
2167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2168 "%s:LOGP in Progress. Ignore!!!", __func__);
2169 return -EBUSY;
2170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002171
2172 /*Get the phy mode*/
2173 if (ccmCfgGetInt(hHal,
2174 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2175 {
2176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002177 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002178
2179 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2180 {
2181 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002182 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 if (ccmCfgGetStr(hHal,
2184 WNI_CFG_SUPPORTED_RATES_11A,
2185 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2186 {
2187 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2188 {
2189 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2190 }
2191 for (i = 0; i < a_len; i++)
2192 {
2193 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2194 }
2195 range->num_bitrates = a_len;
2196 }
2197 else
2198 {
2199 return -EIO;
2200 }
2201 }
2202 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2203 {
2204 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002205 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 if (ccmCfgGetStr(hHal,
2207 WNI_CFG_SUPPORTED_RATES_11B,
2208 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2209 {
2210 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2211 {
2212 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2213 }
2214 for (i = 0; i < b_len; i++)
2215 {
2216 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2217 }
2218 range->num_bitrates = b_len;
2219 }
2220 else
2221 {
2222 return -EIO;
2223 }
2224 }
2225 }
2226
2227 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2228 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2229 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2230
2231 range->encoding_size[0] = 5;
2232 range->encoding_size[1] = 13;
2233 range->num_encoding_sizes = 2;
2234 range->max_encoding_tokens = MAX_WEP_KEYS;
2235
2236 // we support through Wireless Extensions 22
2237 range->we_version_compiled = WIRELESS_EXT;
2238 range->we_version_source = 22;
2239
2240 /*Supported Channels and Frequencies*/
2241 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2242 {
c_hpothub8245442013-11-20 23:41:09 +05302243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2244 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 return -EIO;
2246 }
2247 if (num_channels > IW_MAX_FREQUENCIES)
2248 {
2249 num_channels = IW_MAX_FREQUENCIES;
2250 }
2251
2252 range->num_channels = num_channels;
2253 range->num_frequency = num_channels;
2254
2255 for (index=0; index < num_channels; index++)
2256 {
2257 v_U32_t frq_indx = 0;
2258
2259 range->freq[index].i = channels[index];
2260 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2261 {
2262 if(channels[index] == freq_chan_map[frq_indx].chan)
2263 {
2264 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2265 range->freq[index].e = 1;
2266 break;
2267 }
2268 frq_indx++;
2269 }
2270 }
2271
2272 /* Event capability (kernel + driver) */
2273 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2274 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2275 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2276 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2277
2278 /*Encryption capability*/
2279 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2280 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2281
2282 /* Txpower capability */
2283 range->txpower_capa = IW_TXPOW_MWATT;
2284
2285 /*Scanning capability*/
2286 #if WIRELESS_EXT >= 22
2287 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2288 #endif
2289
2290 EXIT();
2291 return 0;
2292}
2293
2294/* Callback function registered with PMC to know status of PMC request */
2295static void iw_power_callback_fn (void *pContext, eHalStatus status)
2296{
2297 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002298
2299 if (NULL == pContext)
2300 {
2301 hddLog(VOS_TRACE_LEVEL_ERROR,
2302 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002303 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 return;
2305 }
2306
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002308
Jeff Johnson72a40512013-12-19 10:14:15 -08002309 /* there is a race condition that exists between this callback
2310 function and the caller since the caller could time out either
2311 before or while this code is executing. we use a spinlock to
2312 serialize these actions */
2313 spin_lock(&hdd_context_lock);
2314
2315 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 {
2317 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002318 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002320 "%s: Invalid context, magic [%08x]",
2321 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
2323 if (ioctl_debug)
2324 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002325 pr_info("%s: Invalid context, magic [%08x]\n",
2326 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 }
2328 return;
2329 }
2330
Jeff Johnson72a40512013-12-19 10:14:15 -08002331 /* context is valid so caller is still waiting */
2332
2333 /* paranoia: invalidate the magic */
2334 pStatsContext->magic = 0;
2335
2336 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002338
2339 /* serialization is complete */
2340 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002341}
2342
2343/* Callback function for tx per hit */
2344void hdd_tx_per_hit_cb (void *pCallbackContext)
2345{
2346 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2347 unsigned char tx_fail[16];
2348 union iwreq_data wrqu;
2349
2350 if (NULL == pAdapter)
2351 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002352 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 return;
2354 }
2355 memset(&wrqu, 0, sizeof(wrqu));
2356 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2357 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2358}
2359
2360void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2361{
2362 struct statsContext *pStatsContext;
2363 tCsrGlobalClassAStatsInfo *pClassAStats;
2364 hdd_adapter_t *pAdapter;
2365
2366 if (ioctl_debug)
2367 {
2368 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002369 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 }
2371
2372 if ((NULL == pStats) || (NULL == pContext))
2373 {
2374 hddLog(VOS_TRACE_LEVEL_ERROR,
2375 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002376 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 return;
2378 }
2379
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 pClassAStats = pStats;
2381 pStatsContext = pContext;
2382 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002383
2384 /* there is a race condition that exists between this callback
2385 function and the caller since the caller could time out either
2386 before or while this code is executing. we use a spinlock to
2387 serialize these actions */
2388 spin_lock(&hdd_context_lock);
2389
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2391 {
2392 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002393 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 hddLog(VOS_TRACE_LEVEL_WARN,
2395 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002396 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 if (ioctl_debug)
2398 {
2399 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002400 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 }
2402 return;
2403 }
2404
Jeff Johnson72a40512013-12-19 10:14:15 -08002405 /* context is valid so caller is still waiting */
2406
2407 /* paranoia: invalidate the magic */
2408 pStatsContext->magic = 0;
2409
2410 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2412
Jeff Johnson72a40512013-12-19 10:14:15 -08002413 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002415
2416 /* serialization is complete */
2417 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002418}
2419
2420VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2421{
2422 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2423 eHalStatus hstatus;
2424 long lrc;
2425 struct statsContext context;
2426
2427 if (NULL == pAdapter)
2428 {
2429 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2430 return VOS_STATUS_E_FAULT;
2431 }
2432 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2433 {
2434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2435 return VOS_STATUS_SUCCESS;
2436 }
2437
2438 /* we are connected
2439 prepare our callback context */
2440 init_completion(&context.completion);
2441 context.pAdapter = pAdapter;
2442 context.magic = STATS_CONTEXT_MAGIC;
2443 /* query only for Class A statistics (which include link speed) */
2444 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2445 eCSR_HDD,
2446 SME_GLOBAL_CLASSA_STATS,
2447 hdd_GetClassA_statisticsCB,
2448 0, // not periodic
2449 FALSE, //non-cached results
2450 pHddStaCtx->conn_info.staId[0],
2451 &context);
2452 if (eHAL_STATUS_SUCCESS != hstatus)
2453 {
2454 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002455 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002456 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 /* we'll returned a cached value below */
2458 }
2459 else
2460 {
2461 /* request was sent -- wait for the response */
2462 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2463 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 if (lrc <= 0)
2465 {
2466 hddLog(VOS_TRACE_LEVEL_ERROR,
2467 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002468 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 }
2470 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002471
2472 /* either we never sent a request, we sent a request and received a
2473 response or we sent a request and timed out. if we never sent a
2474 request or if we sent a request and got a response, we want to
2475 clear the magic out of paranoia. if we timed out there is a
2476 race condition such that the callback function could be
2477 executing at the same time we are. of primary concern is if the
2478 callback function had already verified the "magic" but had not
2479 yet set the completion variable when a timeout occurred. we
2480 serialize these activities by invalidating the magic while
2481 holding a shared spinlock which will cause us to block if the
2482 callback is currently executing */
2483 spin_lock(&hdd_context_lock);
2484 context.magic = 0;
2485 spin_unlock(&hdd_context_lock);
2486
2487 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 return VOS_STATUS_SUCCESS;
2489}
2490
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002491static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2492{
2493 struct statsContext *pStatsContext;
2494 tCsrSummaryStatsInfo *pSummaryStats;
2495 tCsrGlobalClassAStatsInfo *pClassAStats;
2496 hdd_adapter_t *pAdapter;
2497
2498 if (ioctl_debug)
2499 {
2500 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002501 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002502 }
2503
2504 if ((NULL == pStats) || (NULL == pContext))
2505 {
2506 hddLog(VOS_TRACE_LEVEL_ERROR,
2507 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002508 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002509 return;
2510 }
2511
Jeff Johnson72a40512013-12-19 10:14:15 -08002512 /* there is a race condition that exists between this callback
2513 function and the caller since the caller could time out either
2514 before or while this code is executing. we use a spinlock to
2515 serialize these actions */
2516 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002517
2518 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2519 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2520 pStatsContext = pContext;
2521 pAdapter = pStatsContext->pAdapter;
2522 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2523 {
2524 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002525 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002526 hddLog(VOS_TRACE_LEVEL_WARN,
2527 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002528 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002529 if (ioctl_debug)
2530 {
2531 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002532 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002533 }
2534 return;
2535 }
2536
Jeff Johnson72a40512013-12-19 10:14:15 -08002537 /* context is valid so caller is still waiting */
2538
2539 /* paranoia: invalidate the magic */
2540 pStatsContext->magic = 0;
2541
2542 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002543 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2544 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2545
Jeff Johnson72a40512013-12-19 10:14:15 -08002546 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002547 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002548
2549 /* serialization is complete */
2550 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002551}
2552
2553VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2554{
2555 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2556 eHalStatus hstatus;
2557 long lrc;
2558 struct statsContext context;
2559
2560 if (NULL == pAdapter)
2561 {
2562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2563 return VOS_STATUS_SUCCESS;
2564 }
2565
2566 /* we are connected
2567 prepare our callback context */
2568 init_completion(&context.completion);
2569 context.pAdapter = pAdapter;
2570 context.magic = STATS_CONTEXT_MAGIC;
2571
2572 /* query only for Summary & Class A statistics */
2573 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2574 eCSR_HDD,
2575 SME_SUMMARY_STATS |
2576 SME_GLOBAL_CLASSA_STATS,
2577 hdd_get_station_statisticsCB,
2578 0, // not periodic
2579 FALSE, //non-cached results
2580 pHddStaCtx->conn_info.staId[0],
2581 &context);
2582 if (eHAL_STATUS_SUCCESS != hstatus)
2583 {
2584 hddLog(VOS_TRACE_LEVEL_ERROR,
2585 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002586 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002587 /* we'll return with cached values */
2588 }
2589 else
2590 {
2591 /* request was sent -- wait for the response */
2592 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2593 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002594
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002595 if (lrc <= 0)
2596 {
2597 hddLog(VOS_TRACE_LEVEL_ERROR,
2598 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002599 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002600 }
2601 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002602
2603 /* either we never sent a request, we sent a request and received a
2604 response or we sent a request and timed out. if we never sent a
2605 request or if we sent a request and got a response, we want to
2606 clear the magic out of paranoia. if we timed out there is a
2607 race condition such that the callback function could be
2608 executing at the same time we are. of primary concern is if the
2609 callback function had already verified the "magic" but had not
2610 yet set the completion variable when a timeout occurred. we
2611 serialize these activities by invalidating the magic while
2612 holding a shared spinlock which will cause us to block if the
2613 callback is currently executing */
2614 spin_lock(&hdd_context_lock);
2615 context.magic = 0;
2616 spin_unlock(&hdd_context_lock);
2617
2618 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002619 return VOS_STATUS_SUCCESS;
2620}
2621
2622
Jeff Johnson295189b2012-06-20 16:38:30 -07002623/*
2624 * Support for the LINKSPEED private command
2625 * Per the WiFi framework the response must be of the form
2626 * "LinkSpeed xx"
2627 */
2628static int iw_get_linkspeed(struct net_device *dev,
2629 struct iw_request_info *info,
2630 union iwreq_data *wrqu, char *extra)
2631{
2632 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302633 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302635 int len = sizeof(v_U32_t) + 1;
2636 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302638 VOS_STATUS status;
2639 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002640
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302641 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2642
2643 valid = wlan_hdd_validate_context(pHddCtx);
2644
2645 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002646 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302647 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2648 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002649 }
2650
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2652 {
2653 /* we are not connected so we don't have a classAstats */
2654 link_speed = 0;
2655 }
2656 else
2657 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302658 status = wlan_hdd_get_classAstats(pAdapter);
2659
2660 if (!VOS_IS_STATUS_SUCCESS(status ))
2661 {
2662 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2663 return -EINVAL;
2664 }
2665
2666 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2667 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2668 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2669 &link_speed);
2670
2671 link_speed = link_speed / 10;
2672
2673 if (0 == link_speed)
2674 {
2675 /* The linkspeed returned by HAL is in units of 500kbps.
2676 * converting it to mbps.
2677 * This is required to support legacy firmware which does
2678 * not return link capacity.
2679 */
2680 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2681 }
2682
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 }
2684
2685 wrqu->data.length = len;
2686 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002687 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 if ((rc < 0) || (rc >= len))
2689 {
2690 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302691 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 return -EIO;
2693 }
2694
2695 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002696 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002697}
2698
2699
2700/*
2701 * Support for the RSSI & RSSI-APPROX private commands
2702 * Per the WiFi framework the response must be of the form
2703 * "<ssid> rssi <xx>"
2704 * unless we are not associated, in which case the response is
2705 * "OK"
2706 */
2707static int iw_get_rssi(struct net_device *dev,
2708 struct iw_request_info *info,
2709 union iwreq_data *wrqu, char *extra)
2710{
2711 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002712 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 int len = wrqu->data.length;
2714 v_S7_t s7Rssi = 0;
2715 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2716 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2717 VOS_STATUS vosStatus;
2718 int rc;
2719
2720 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2721 (0 == ssidlen) || (ssidlen >= len))
2722 {
2723 /* we are not connected or our SSID is too long
2724 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002725 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 }
2727 else
2728 {
2729 /* we are connected with a valid SSID
2730 so we can write the SSID into the return buffer
2731 (note that it is not NUL-terminated) */
2732 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2733
2734 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2735
2736 if (VOS_STATUS_SUCCESS == vosStatus)
2737 {
2738 /* append the rssi to the ssid in the format required by
2739 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002740 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302741 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 }
2743 else
2744 {
2745 rc = -1;
2746 }
2747 }
2748
2749 /* verify that we wrote a valid response */
2750 if ((rc < 0) || (rc >= len))
2751 {
2752 // encoding or length error?
2753 hddLog(VOS_TRACE_LEVEL_ERROR,
2754 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002755 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 return -EIO;
2757 }
2758
2759 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002760 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002761}
2762
2763/*
2764 * Support for SoftAP channel range private command
2765 */
2766static int iw_softap_set_channel_range( struct net_device *dev,
2767 int startChannel,
2768 int endChannel,
2769 int band)
2770{
Jeff Johnson43971f52012-07-17 12:26:56 -07002771 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 int ret = 0;
2773 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2774 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002775 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2776
Jeff Johnson295189b2012-06-20 16:38:30 -07002777
2778 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2779 if (VOS_STATUS_SUCCESS != status)
2780 {
2781 ret = -EINVAL;
2782 }
Yathish9f22e662012-12-10 14:21:35 -08002783 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 return ret;
2785}
2786
2787VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2788{
2789 struct statsContext context;
2790 eHalStatus status;
2791 hdd_context_t *pHddCtx;
2792
2793 if (NULL == pAdapter)
2794 {
2795 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2796 return VOS_STATUS_E_FAULT;
2797 }
2798
2799 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2800 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2801 init_completion(&context.completion);
2802
2803 context.pAdapter = pAdapter;
2804 context.magic = POWER_CONTEXT_MAGIC;
2805
2806 if (DRIVER_POWER_MODE_ACTIVE == mode)
2807 {
2808 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2809 "Full Power", __func__);
2810 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2811 iw_power_callback_fn, &context,
2812 eSME_FULL_PWR_NEEDED_BY_HDD);
2813 // Enter Full power command received from GUI this means we are disconnected
2814 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2815 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2816 if (eHAL_STATUS_PMC_PENDING == status)
2817 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002818 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 int lrc = wait_for_completion_interruptible_timeout(
2820 &context.completion,
2821 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002822
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 if (lrc <= 0)
2824 {
2825 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002826 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 }
2828 }
2829 }
2830 else if (DRIVER_POWER_MODE_AUTO == mode)
2831 {
2832 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2833 {
2834 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2835 __func__);
2836 // Enter BMPS command received from GUI this means DHCP is completed
2837 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2838 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2839 FALSE);
2840 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2841 iw_power_callback_fn, &context);
2842 if (eHAL_STATUS_PMC_PENDING == status)
2843 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002844 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 int lrc = wait_for_completion_interruptible_timeout(
2846 &context.completion,
2847 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 if (lrc <= 0)
2849 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002850 hddLog(VOS_TRACE_LEVEL_ERROR,
2851 "%s: SME %s while requesting BMPS",
2852 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 }
2854 }
2855 }
2856 else
2857 {
2858 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2859 "enabled in the cfg");
2860 }
2861 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002862
2863 /* either we never sent a request, we sent a request and received a
2864 response or we sent a request and timed out. if we never sent a
2865 request or if we sent a request and got a response, we want to
2866 clear the magic out of paranoia. if we timed out there is a
2867 race condition such that the callback function could be
2868 executing at the same time we are. of primary concern is if the
2869 callback function had already verified the "magic" but had not
2870 yet set the completion variable when a timeout occurred. we
2871 serialize these activities by invalidating the magic while
2872 holding a shared spinlock which will cause us to block if the
2873 callback is currently executing */
2874 spin_lock(&hdd_context_lock);
2875 context.magic = 0;
2876 spin_unlock(&hdd_context_lock);
2877
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 return VOS_STATUS_SUCCESS;
2879}
2880
2881VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2882 hdd_adapter_t *pAdapter)
2883{
2884 VOS_STATUS vos_Status;
2885
2886 if ((NULL == pAdapter) || (NULL == pHddCtx))
2887 {
2888 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2889 return VOS_STATUS_E_FAULT;
2890 }
2891
2892 /**Exit from Deep sleep or standby if we get the driver
2893 START cmd from android GUI
2894 */
2895 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2896 {
2897 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2898 "from Stand by",__func__);
2899 vos_Status = hdd_exit_standby(pHddCtx);
2900 }
2901 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2902 {
2903 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2904 "from deep sleep",__func__);
2905 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2906 }
2907 else
2908 {
2909 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2910 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2911 vos_Status = VOS_STATUS_SUCCESS;
2912 }
2913
2914 return vos_Status;
2915}
2916
2917VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2918{
2919 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2920
2921 if (NULL == pHddCtx)
2922 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302923 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 return VOS_STATUS_E_FAULT;
2925 }
2926
2927 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2928 {
2929 //Execute standby procedure.
2930 //Executing standby procedure will cause the STA to
2931 //disassociate first and then the chip will be put into standby.
2932 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2933 vos_Status = hdd_enter_standby(pHddCtx);
2934 }
2935 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2936 pHddCtx->cfg_ini->nEnableDriverStop)
2937 {
2938 //Execute deep sleep procedure
2939 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002940 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 //Deep sleep not supported
2942 vos_Status = hdd_enter_standby(pHddCtx);
2943 }
2944 else
2945 {
2946 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2947 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2948 vos_Status = VOS_STATUS_SUCCESS;
2949 }
2950
2951 return vos_Status;
2952}
2953
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002954
2955void* wlan_hdd_change_country_code_callback(void *pAdapter)
2956{
2957
2958 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002959 complete(&call_back_pAdapter->change_country_code);
2960
2961 return NULL;
2962}
2963
Jeff Johnson295189b2012-06-20 16:38:30 -07002964static int iw_set_priv(struct net_device *dev,
2965 struct iw_request_info *info,
2966 union iwreq_data *wrqu, char *extra)
2967{
2968 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08002969 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 int cmd_len = wrqu->data.length;
2971 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08002972 int rc = 0;
2973 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2974
Jeff Johnson295189b2012-06-20 16:38:30 -07002975 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2976
2977 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08002978 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2979 wrqu->data.length);
2980 if (NULL == cmd)
2981 {
2982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2983 "mem_alloc_copy_from_user_helper fail");
2984 return -ENOMEM;
2985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002986
2987 if (ioctl_debug)
2988 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002989 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 }
2991
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002992 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2993 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002994
2995 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08002996 if (ioctl_debug)
2997 {
2998 pr_info("%s: RESTART in progress\n", __func__);
2999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003000
Arif Hussain24bfa702014-01-22 13:51:30 -08003001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003003 kfree(cmd);
3004 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 }
3006
Arif Hussain24bfa702014-01-22 13:51:30 -08003007 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003009 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3011 "%s: Error in iw_set_scan!", __func__);
3012 rc = -EINVAL;
3013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 }
3015 else if( strcasecmp(cmd, "start") == 0 ) {
3016
Arif Hussain6d2a3322013-11-17 19:50:10 -08003017 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003019
Arif Hussain24bfa702014-01-22 13:51:30 -08003020 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3021 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 {
3023 union iwreq_data wrqu;
3024 char buf[10];
3025
3026 memset(&wrqu, 0, sizeof(wrqu));
3027 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3028 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3029 }
3030 else
3031 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003032 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3033 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 }
3035 goto done;
3036 }
3037 else if( strcasecmp(cmd, "stop") == 0 )
3038 {
3039 union iwreq_data wrqu;
3040 char buf[10];
3041
Arif Hussain6d2a3322013-11-17 19:50:10 -08003042 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003043
3044 wlan_hdd_enter_lowpower(pHddCtx);
3045 memset(&wrqu, 0, sizeof(wrqu));
3046 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3047 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 goto done;
3049 }
3050 else if (strcasecmp(cmd, "macaddr") == 0)
3051 {
3052 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3053 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3054 }
3055 else if (strcasecmp(cmd, "scan-active") == 0)
3056 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003057 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 ret = snprintf(cmd, cmd_len, "OK");
3059 }
3060 else if (strcasecmp(cmd, "scan-passive") == 0)
3061 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003062 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 ret = snprintf(cmd, cmd_len, "OK");
3064 }
3065 else if( strcasecmp(cmd, "scan-mode") == 0 )
3066 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003067 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 }
3069 else if( strcasecmp(cmd, "linkspeed") == 0 )
3070 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003071 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 }
3073 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3074 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003075 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003076 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003077
3078 country_code = cmd + 8;
3079
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003080 init_completion(&pAdapter->change_country_code);
3081
Arif Hussain24bfa702014-01-22 13:51:30 -08003082 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003083 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 country_code,
3085 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303086 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303087 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303088 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003089
3090 /* Wait for completion */
3091 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3092 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3093
3094 if (lrc <= 0)
3095 {
3096 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003097 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003098 }
3099
Arif Hussain24bfa702014-01-22 13:51:30 -08003100 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003102 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003103 "%s: SME Change Country code fail", __func__);
3104 kfree(cmd);
3105 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 }
3107 }
3108 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3109 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003110 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 }
3112 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3113 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003114 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003115
Wilson Yang1be3e652013-10-09 15:18:31 -07003116 if (9 < cmd_len)
3117 {
3118 ptr = (char*)(cmd + 9);
3119
3120 }else{
3121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3122 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003123 kfree(cmd);
3124 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003125 }
3126
3127 if (1 != sscanf(ptr,"%d",&mode))
3128 {
3129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3130 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003131 kfree(cmd);
3132 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003133 }
3134
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 wlan_hdd_enter_bmps(pAdapter, mode);
3136 /*TODO:Set the power mode*/
3137 }
3138 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3139 v_U32_t pmc_state;
3140 v_U16_t value;
3141
3142 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3143 if(pmc_state == BMPS) {
3144 value = DRIVER_POWER_MODE_AUTO;
3145 }
3146 else {
3147 value = DRIVER_POWER_MODE_ACTIVE;
3148 }
3149 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3150 }
3151 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003152 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 /*TODO: set the btcoexmode*/
3154 }
3155 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3156
Arif Hussain6d2a3322013-11-17 19:50:10 -08003157 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 /*TODO: Return the btcoex status*/
3159 }
3160 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3161
Arif Hussain6d2a3322013-11-17 19:50:10 -08003162 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003163
3164 /*TODO: Enable Rx data Filter*/
3165 }
3166 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3167
Arif Hussain6d2a3322013-11-17 19:50:10 -08003168 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003169
3170 /*TODO: Disable Rx data Filter*/
3171 }
3172 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3173
Arif Hussain6d2a3322013-11-17 19:50:10 -08003174 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 /*TODO: rxfilter-statistics*/
3176 }
3177 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3178
Arif Hussain6d2a3322013-11-17 19:50:10 -08003179 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 /*TODO: rxfilter-add*/
3181 }
3182 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3183
Arif Hussain6d2a3322013-11-17 19:50:10 -08003184 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 /*TODO: rxfilter-remove*/
3186 }
3187#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003188 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3189 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3190 /*TODO: support pnosetup*/
3191 }
3192 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3193 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3194 /*TODO: support pnoforce*/
3195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3197
Arif Hussain6d2a3322013-11-17 19:50:10 -08003198 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003199 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3200 kfree(cmd);
3201 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 }
3203 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003204 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003205 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3206 kfree(cmd);
3207 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 }
3209#endif /*FEATURE_WLAN_SCAN_PNO*/
3210 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003211 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003212 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3213 kfree(cmd);
3214 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 }
3216 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3217 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003218 char *ptr;
3219
3220 if (18 < cmd_len)
3221 {
3222 ptr = (char*)(cmd + 18);
3223 }else{
3224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3225 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003226 kfree(cmd);
3227 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003228 }
3229
Jeff Johnson02797792013-10-26 19:17:13 -07003230 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003231 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3232 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3233 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3234 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3235 {
3236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3237 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003238 kfree(cmd);
3239 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003241
3242 // parameters checking
3243 // period has to be larger than 0
3244 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3245 {
3246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003247 kfree(cmd);
3248 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 }
3250
3251 // use default value 5 is the input is not reasonable. in unit of 10%
3252 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3253 {
3254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3255 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3256 }
3257
3258 // default is 5
3259 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3260 {
3261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3262 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3263 }
3264
Arif Hussain24bfa702014-01-22 13:51:30 -08003265 if (eHAL_STATUS_SUCCESS !=
3266 sme_SetTxPerTracking(pHddCtx->hHal,
3267 hdd_tx_per_hit_cb,
3268 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003270 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 }
3272 }
3273 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003274 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3275 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 }
3277done:
3278 /* many of the commands write information back into the command
3279 string using snprintf(). check the return value here in one
3280 place */
3281 if ((ret < 0) || (ret >= cmd_len))
3282 {
3283 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003284 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003286 else if (ret > 0)
3287 {
3288 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3289 {
3290 hddLog(VOS_TRACE_LEVEL_ERROR,
3291 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003292 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003293 return -EFAULT;
3294 }
3295 wrqu->data.length = ret;
3296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003297
3298 if (ioctl_debug)
3299 {
3300 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003301 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003303 kfree(cmd);
3304 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003305}
3306
3307static int iw_set_nick(struct net_device *dev,
3308 struct iw_request_info *info,
3309 union iwreq_data *wrqu, char *extra)
3310{
3311 ENTER();
3312 return 0;
3313}
3314
3315static int iw_get_nick(struct net_device *dev,
3316 struct iw_request_info *info,
3317 union iwreq_data *wrqu, char *extra)
3318{
3319 ENTER();
3320 return 0;
3321}
3322
3323static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3324{
3325 ENTER();
3326 return NULL;
3327}
3328
3329static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3330 union iwreq_data *wrqu,char *extra)
3331
3332{
3333 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3334 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3335 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3336 struct iw_point *encoderq = &(wrqu->encoding);
3337 v_U32_t keyId;
3338 v_U8_t key_length;
3339 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3340 v_BOOL_t fKeyPresent = 0;
3341 int i;
3342 eHalStatus status = eHAL_STATUS_SUCCESS;
3343
3344
3345 ENTER();
3346
3347 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3348 {
3349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3350 "%s:LOGP in Progress. Ignore!!!",__func__);
3351 return 0;
3352 }
3353
3354
3355 keyId = encoderq->flags & IW_ENCODE_INDEX;
3356
3357 if(keyId)
3358 {
3359 if(keyId > MAX_WEP_KEYS)
3360 {
3361 return -EINVAL;
3362 }
3363
3364 fKeyPresent = 1;
3365 keyId--;
3366 }
3367 else
3368 {
3369 fKeyPresent = 0;
3370 }
3371
3372
3373 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3374 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 if(!fKeyPresent) {
3377
3378 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3379
3380 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3381 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3382 }
3383 }
3384 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3385 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3386 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3387 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3388
3389 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3390 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3391
3392 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3393 {
3394 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3395 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003396 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303397 {
3398 long ret;
3399 ret = wait_for_completion_interruptible_timeout(
3400 &pAdapter->disconnect_comp_var,
3401 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3402 if (ret <= 0)
3403 hddLog(VOS_TRACE_LEVEL_ERROR,
3404 FL("failed wait on disconnect_comp_var %ld"), ret);
3405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 }
3407
3408 return status;
3409
3410 }
3411
3412 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3413 {
3414 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3415
3416 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3417
3418 }
3419
3420
3421 if(wrqu->data.length > 0)
3422 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003423 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003424
3425 key_length = wrqu->data.length;
3426
3427 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3428
3429 if(5 == key_length)
3430 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003431 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003432
3433 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3434 {
3435 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3436 }
3437 else
3438 {
3439 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3440 }
3441 }
3442 else if(13 == key_length)
3443 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003444 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003445
3446 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3447 {
3448 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3449 }
3450 else
3451 {
3452 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3453 }
3454 }
3455 else
3456 {
3457 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003458 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 return -EINVAL;
3460 }
3461
3462 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3463 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3464 pWextState->roamProfile.EncryptionType.numEntries = 1;
3465 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3466 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3467 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3468
3469 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3470 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3471 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3472 {
3473
3474 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3475
3476 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3477 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3478
3479 return status;
3480 }
3481 }
3482
3483 return 0;
3484}
3485
3486static int iw_get_encodeext(struct net_device *dev,
3487 struct iw_request_info *info,
3488 struct iw_point *dwrq,
3489 char *extra)
3490{
3491 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3492 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3493 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3494 int keyId;
3495 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3496 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3497 int i;
3498
3499 ENTER();
3500
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003501 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3502 {
3503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3504 "%s:LOGP in Progress. Ignore!!!", __func__);
3505 return -EBUSY;
3506 }
3507
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 keyId = pRoamProfile->Keys.defaultIndex;
3509
3510 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3511 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003512 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 return -EINVAL;
3514 }
3515
3516 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3517 {
3518 dwrq->flags |= IW_ENCODE_ENABLED;
3519 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303520 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3521 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 }
3523 else
3524 {
3525 dwrq->flags |= IW_ENCODE_DISABLED;
3526 }
3527
3528 for(i=0; i < MAX_WEP_KEYS; i++)
3529 {
3530 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3531 {
3532 continue;
3533 }
3534 else
3535 {
3536 break;
3537 }
3538 }
3539
3540 if(MAX_WEP_KEYS == i)
3541 {
3542 dwrq->flags |= IW_ENCODE_NOKEY;
3543 }
3544 else
3545 {
3546 dwrq->flags |= IW_ENCODE_ENABLED;
3547 }
3548
3549 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3550
3551 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3552 {
3553 dwrq->flags |= IW_ENCODE_DISABLED;
3554 }
3555
3556 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3557
3558 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3559 {
3560 dwrq->flags |= IW_ENCODE_OPEN;
3561 }
3562 else
3563 {
3564 dwrq->flags |= IW_ENCODE_RESTRICTED;
3565 }
3566 EXIT();
3567 return 0;
3568
3569}
3570
3571static int iw_set_encodeext(struct net_device *dev,
3572 struct iw_request_info *info,
3573 union iwreq_data *wrqu, char *extra)
3574{
3575 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3576 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3577 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3578 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3579
3580 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3581 v_U32_t status = 0;
3582
3583 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3584
3585 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3586
3587 int key_index;
3588 struct iw_point *encoding = &wrqu->encoding;
3589 tCsrRoamSetKey setKey;
3590 v_U32_t roamId= 0xFF;
3591 VOS_STATUS vos_status;
3592
3593 ENTER();
3594
3595 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3596 {
3597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3598 "%s:LOGP in Progress. Ignore!!!",__func__);
3599 return 0;
3600 }
3601
3602 key_index = encoding->flags & IW_ENCODE_INDEX;
3603
3604 if(key_index > 0) {
3605
3606 /*Convert from 1-based to 0-based keying*/
3607 key_index--;
3608 }
3609 if(!ext->key_len) {
3610
3611 /*Set the encrytion type to NONE*/
3612 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3613 return status;
3614 }
3615
3616 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3617 (IW_ENCODE_ALG_WEP == ext->alg))
3618 {
3619 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3620
Agarwal Ashish971c2882013-10-30 20:11:12 +05303621 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3622 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 return -EINVAL;
3624 }
3625 else {
3626 /*Static wep, update the roam profile with the keys */
3627 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3628 key_index < CSR_MAX_NUM_KEY) {
3629 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3630 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3631
3632 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3633 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3634
3635 }
3636 }
3637 return status;
3638 }
3639
3640 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3641
3642 setKey.keyId = key_index;
3643 setKey.keyLength = ext->key_len;
3644
3645 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3646 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3647 }
3648
3649 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3650 /*Key direction for group is RX only*/
3651 setKey.keyDirection = eSIR_RX_ONLY;
3652 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3653 }
3654 else {
3655
3656 setKey.keyDirection = eSIR_TX_RX;
3657 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3658 }
3659
3660 /*For supplicant pae role is zero*/
3661 setKey.paeRole = 0;
3662
3663 switch(ext->alg)
3664 {
3665 case IW_ENCODE_ALG_NONE:
3666 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3667 break;
3668
3669 case IW_ENCODE_ALG_WEP:
3670 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3671 break;
3672
3673 case IW_ENCODE_ALG_TKIP:
3674 {
3675 v_U8_t *pKey = &setKey.Key[0];
3676
3677 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3678
3679 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3680
3681 /*Supplicant sends the 32bytes key in this order
3682
3683 |--------------|----------|----------|
3684 | Tk1 |TX-MIC | RX Mic |
3685 |--------------|----------|----------|
3686 <---16bytes---><--8bytes--><--8bytes-->
3687
3688 */
3689 /*Sme expects the 32 bytes key to be in the below order
3690
3691 |--------------|----------|----------|
3692 | Tk1 |RX-MIC | TX Mic |
3693 |--------------|----------|----------|
3694 <---16bytes---><--8bytes--><--8bytes-->
3695 */
3696 /* Copy the Temporal Key 1 (TK1) */
3697 vos_mem_copy(pKey,ext->key,16);
3698
3699 /*Copy the rx mic first*/
3700 vos_mem_copy(&pKey[16],&ext->key[24],8);
3701
3702 /*Copy the tx mic */
3703 vos_mem_copy(&pKey[24],&ext->key[16],8);
3704
3705 }
3706 break;
3707
3708 case IW_ENCODE_ALG_CCMP:
3709 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3710 break;
3711
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003712#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003713#define IW_ENCODE_ALG_KRK 6
3714 case IW_ENCODE_ALG_KRK:
3715 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3716 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003717#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003718
3719 default:
3720 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3721 break;
3722 }
3723
3724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003725 ("%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 -07003726
3727#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303728 /* The supplicant may attempt to set the PTK once pre-authentication
3729 is done. Save the key in the UMAC and include it in the ADD
3730 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303732 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303734 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3735 "%s: Update PreAuth Key success", __func__);
3736 return 0;
3737 }
3738 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3739 {
3740 hddLog(VOS_TRACE_LEVEL_ERROR,
3741 "%s: Update PreAuth Key failed", __func__);
3742 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 }
3744#endif /* WLAN_FEATURE_VOWIFI_11R */
3745
3746 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3747
3748 vos_status = wlan_hdd_check_ula_done(pAdapter);
3749 if ( vos_status != VOS_STATUS_SUCCESS )
3750 {
3751 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3752 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3753 __LINE__, vos_status );
3754
3755 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3756 }
3757
3758 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3759
3760 if ( halStatus != eHAL_STATUS_SUCCESS )
3761 {
3762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3763 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3764 __LINE__, halStatus );
3765
3766 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3767 }
3768
3769 return halStatus;
3770}
3771
3772static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3773 union iwreq_data *wrqu, char *extra)
3774{
3775 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3776 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3777
3778 ENTER();
3779
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003780 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3781 {
3782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3783 "%s:LOGP in Progress. Ignore!!!", __func__);
3784 return -EBUSY;
3785 }
3786
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3788 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3789
Arif Hussain6d2a3322013-11-17 19:50:10 -08003790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003791
3792 return -EINVAL;
3793 }
3794
3795 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3796
3797 if((wrqu->retry.flags & IW_RETRY_LONG))
3798 {
3799 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3800 {
c_hpothub8245442013-11-20 23:41:09 +05303801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3802 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 return -EIO;
3804 }
3805 }
3806 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3807 {
3808 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3809 {
c_hpothub8245442013-11-20 23:41:09 +05303810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3811 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 return -EIO;
3813 }
3814 }
3815 }
3816 else
3817 {
3818 return -EOPNOTSUPP;
3819 }
3820
Arif Hussain6d2a3322013-11-17 19:50:10 -08003821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003822
3823 EXIT();
3824
3825 return 0;
3826
3827}
3828
3829static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3830 union iwreq_data *wrqu, char *extra)
3831{
3832 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3833 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3834 v_U32_t retry = 0;
3835
3836 ENTER();
3837
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003838 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3839 {
3840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3841 "%s:LOGP in Progress. Ignore!!!", __func__);
3842 return -EBUSY;
3843 }
3844
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 if((wrqu->retry.flags & IW_RETRY_LONG))
3846 {
3847 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3848
3849 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3850 {
c_hpothub8245442013-11-20 23:41:09 +05303851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3852 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 return -EIO;
3854 }
3855
3856 wrqu->retry.value = retry;
3857 }
3858 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3859 {
3860 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3861
3862 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3863 {
c_hpothub8245442013-11-20 23:41:09 +05303864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3865 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 return -EIO;
3867 }
3868
3869 wrqu->retry.value = retry;
3870 }
3871 else {
3872 return -EOPNOTSUPP;
3873 }
3874
Arif Hussain6d2a3322013-11-17 19:50:10 -08003875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003876
3877 EXIT();
3878
3879 return 0;
3880}
3881
3882static int iw_set_mlme(struct net_device *dev,
3883 struct iw_request_info *info,
3884 union iwreq_data *wrqu,
3885 char *extra)
3886{
3887 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3888 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3889 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3890 eHalStatus status = eHAL_STATUS_SUCCESS;
3891
3892 ENTER();
3893
3894 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3895 {
3896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3897 "%s:LOGP in Progress. Ignore!!!",__func__);
3898 return 0;
3899 }
3900
3901 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3902 switch (mlme->cmd) {
3903 case IW_MLME_DISASSOC:
3904 case IW_MLME_DEAUTH:
3905
3906 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3907 {
3908 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3909
3910 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3911 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3912
3913 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3914 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3915
Jeff Johnson43971f52012-07-17 12:26:56 -07003916 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303917 {
3918 long ret;
3919 ret = wait_for_completion_interruptible_timeout(
3920 &pAdapter->disconnect_comp_var,
3921 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3922 if (ret <= 0)
3923 hddLog(VOS_TRACE_LEVEL_ERROR,
3924 FL("failed wait on disconnect_comp_var %ld"), ret);
3925 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003927 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003928 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003929
3930 /* Resetting authKeyMgmt */
3931 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3932
3933 netif_tx_disable(dev);
3934 netif_carrier_off(dev);
3935
3936 }
3937 else
3938 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003939 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 -07003940 }
3941 break;
3942 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003943 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 return -EINVAL;
3945 }//end of switch
3946
3947 EXIT();
3948
3949 return status;
3950
3951}
3952
3953/* set param sub-ioctls */
3954static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3955 union iwreq_data *wrqu, char *extra)
3956{
3957 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3958 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3959 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3960 int *value = (int *)extra;
3961 int sub_cmd = value[0];
3962 int set_value = value[1];
3963 int ret = 0; /* success */
3964 int enable_pbm, enable_mp;
3965#ifdef CONFIG_HAS_EARLYSUSPEND
3966 v_U8_t nEnableSuspendOld;
3967#endif
3968 INIT_COMPLETION(pWextState->completion_var);
3969
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003970 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3971 {
3972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3973 "%s:LOGP in Progress. Ignore!!!", __func__);
3974 return -EBUSY;
3975 }
3976
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 switch(sub_cmd)
3978 {
3979 case WE_SET_11D_STATE:
3980 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003981 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07003982 memset(&smeConfig, 0x00, sizeof(smeConfig));
3983
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3985
3986 sme_GetConfigParam(hHal,&smeConfig);
3987 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3988
Arif Hussain6d2a3322013-11-17 19:50:10 -08003989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07003990
3991 sme_UpdateConfig(hHal,&smeConfig);
3992 }
3993 else {
3994 return -EINVAL;
3995 }
3996 break;
3997 }
3998
3999 case WE_WOWL:
4000 {
4001 switch (set_value)
4002 {
4003 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004004 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 break;
4006 case 0x01:
4007 case 0x02:
4008 case 0x03:
4009 enable_mp = (set_value & 0x01) ? 1 : 0;
4010 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004011 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4013 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4014 break;
4015 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004016 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 ret = -EINVAL;
4018 break;
4019 }
4020
4021 break;
4022 }
4023 case WE_SET_POWER:
4024 {
4025 switch (set_value)
4026 {
4027 case 0: //Full Power
4028 {
4029 struct statsContext context;
4030 eHalStatus status;
4031
4032 init_completion(&context.completion);
4033
4034 context.pAdapter = pAdapter;
4035 context.magic = POWER_CONTEXT_MAGIC;
4036
4037 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4038 iw_power_callback_fn, &context,
4039 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004040 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 {
4042 int lrc = wait_for_completion_interruptible_timeout(
4043 &context.completion,
4044 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004045
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 if (lrc <= 0)
4047 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004048 hddLog(VOS_TRACE_LEVEL_ERROR,
4049 "%s: SME %s while requesting fullpower",
4050 __func__, (0 == lrc) ?
4051 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 }
4053 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004054 /* either we have a response or we timed out. if we timed
4055 out there is a race condition such that the callback
4056 function could be executing at the same time we are. of
4057 primary concern is if the callback function had already
4058 verified the "magic" but had not yet set the completion
4059 variable when a timeout occurred. we serialize these
4060 activities by invalidating the magic while holding a
4061 shared spinlock which will cause us to block if the
4062 callback is currently executing */
4063 spin_lock(&hdd_context_lock);
4064 context.magic = 0;
4065 spin_unlock(&hdd_context_lock);
4066
Arif Hussain6d2a3322013-11-17 19:50:10 -08004067 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 break;
4069 }
4070 case 1: //Enable BMPS
4071 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4072 break;
4073 case 2: //Disable BMPS
4074 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4075 break;
4076 case 3: //Request Bmps
4077 {
4078 struct statsContext context;
4079 eHalStatus status;
4080
4081 init_completion(&context.completion);
4082
4083 context.pAdapter = pAdapter;
4084 context.magic = POWER_CONTEXT_MAGIC;
4085
4086 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4087 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004088 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 {
4090 int lrc = wait_for_completion_interruptible_timeout(
4091 &context.completion,
4092 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 if (lrc <= 0)
4094 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004095 hddLog(VOS_TRACE_LEVEL_ERROR,
4096 "%s: SME %s while requesting BMPS",
4097 __func__, (0 == lrc) ? "timeout" :
4098 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 }
4100 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004101 /* either we have a response or we timed out. if we
4102 timed out there is a race condition such that the
4103 callback function could be executing at the same
4104 time we are. of primary concern is if the callback
4105 function had already verified the "magic" but had
4106 not yet set the completion variable when a timeout
4107 occurred. we serialize these activities by
4108 invalidating the magic while holding a shared
4109 spinlock which will cause us to block if the
4110 callback is currently executing */
4111 spin_lock(&hdd_context_lock);
4112 context.magic = 0;
4113 spin_unlock(&hdd_context_lock);
4114
Arif Hussain6d2a3322013-11-17 19:50:10 -08004115 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 break;
4117 }
4118 case 4: //Enable IMPS
4119 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4120 break;
4121 case 5: //Disable IMPS
4122 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4123 break;
4124 case 6: //Enable Standby
4125 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4126 break;
4127 case 7: //Disable Standby
4128 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4129 break;
4130 case 8: //Request Standby
4131#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004132#endif
4133 break;
4134 case 9: //Start Auto Bmps Timer
4135 sme_StartAutoBmpsTimer(hHal);
4136 break;
4137 case 10://Stop Auto BMPS Timer
4138 sme_StopAutoBmpsTimer(hHal);
4139 break;
4140#ifdef CONFIG_HAS_EARLYSUSPEND
4141 case 11://suspend to standby
4142#ifdef CONFIG_HAS_EARLYSUSPEND
4143 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4144 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4146#endif
4147 break;
4148 case 12://suspend to deep sleep
4149#ifdef CONFIG_HAS_EARLYSUSPEND
4150 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4151 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4153#endif
4154 break;
4155 case 13://resume from suspend
4156#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004157#endif
4158 break;
4159#endif
4160 case 14://reset wlan (power down/power up)
4161 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4162 break;
4163 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004164 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 ret = -EINVAL;
4166 break;
4167 }
4168 break;
4169 }
4170
4171 case WE_SET_MAX_ASSOC:
4172 {
4173 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4174 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4175 {
4176 ret = -EINVAL;
4177 }
4178 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4179 set_value, NULL, eANI_BOOLEAN_FALSE)
4180 != eHAL_STATUS_SUCCESS )
4181 {
c_hpothub8245442013-11-20 23:41:09 +05304182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4183 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 ret = -EIO;
4185 }
4186 break;
4187 }
4188
4189 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4190 {
4191 if( 0 == set_value )
4192 {
4193 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4194 }
4195 else if ( 1 == set_value )
4196 {
4197 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4198 }
4199 else
4200 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004201 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 ret = -EINVAL;
4203 }
4204 break;
4205 }
4206
4207 case WE_SET_DATA_INACTIVITY_TO:
4208 {
4209 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4210 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4211 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4212 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4213 set_value,
4214 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4215 {
4216 hddLog(LOGE,"Failure: Could not pass on "
4217 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004218 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 ret = -EINVAL;
4220 }
4221 break;
4222 }
4223 case WE_SET_MAX_TX_POWER:
4224 {
4225 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4226 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4227
4228 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4229 __func__, set_value);
4230 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4231 eHAL_STATUS_SUCCESS )
4232 {
4233 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4234 __func__);
4235 return -EIO;
4236 }
4237
4238 break;
4239 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004240 case WE_SET_MAX_TX_POWER_2_4:
4241 {
4242 hddLog(VOS_TRACE_LEVEL_INFO,
4243 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4244 __func__, set_value);
4245 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4246 eHAL_STATUS_SUCCESS)
4247 {
4248 hddLog(VOS_TRACE_LEVEL_ERROR,
4249 "%s: Setting maximum tx power failed for 2.4 GHz band",
4250 __func__);
4251 return -EIO;
4252 }
4253
4254 break;
4255 }
4256 case WE_SET_MAX_TX_POWER_5_0:
4257 {
4258 hddLog(VOS_TRACE_LEVEL_INFO,
4259 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4260 __func__, set_value);
4261 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4262 eHAL_STATUS_SUCCESS)
4263 {
4264 hddLog(VOS_TRACE_LEVEL_ERROR,
4265 "%s: Setting maximum tx power failed for 5.0 GHz band",
4266 __func__);
4267 return -EIO;
4268 }
4269
4270 break;
4271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 case WE_SET_HIGHER_DTIM_TRANSITION:
4273 {
4274 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4275 (set_value == eANI_BOOLEAN_TRUE)))
4276 {
4277 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4278 ret = -EINVAL;
4279 }
4280 else
4281 {
4282 if(pAdapter->higherDtimTransition != set_value)
4283 {
4284 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004285 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 }
4287 }
4288
4289 break;
4290 }
4291
4292 case WE_SET_TM_LEVEL:
4293 {
4294 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004295 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4297
4298 break;
4299 }
4300
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304301 case WE_ENABLE_STRICT_FCC_REG:
4302 {
4303 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4304 struct wiphy *wiphy = NULL;
4305 long lrc;
4306 int status;
4307
4308 wiphy = hddCtxt->wiphy;
4309 if(wiphy == NULL)
4310 {
4311 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4312 break;
4313 }
4314 init_completion(&hddCtxt->wiphy_channel_update_event);
4315
4316 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4317
4318 status = regulatory_hint(wiphy, "00");
4319 if(status < 0)
4320 {
4321 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4322 break;
4323 }
4324
4325 /* Wait for completion */
4326 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4327 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4328 if (lrc <= 0)
4329 {
4330 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4331 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4332 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4333 }
4334 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4335
4336 break;
4337 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004338 case WE_SET_DEBUG_LOG:
4339 {
4340 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4341 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4342 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4343 break;
4344 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304345
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 default:
4347 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004348 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 sub_cmd, set_value);
4350 break;
4351 }
4352 }
4353
4354 return ret;
4355}
4356
4357/* set param sub-ioctls */
4358static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4359 union iwreq_data *wrqu, char *extra)
4360{
4361 VOS_STATUS vstatus;
4362 int sub_cmd = wrqu->data.flags;
4363 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004364 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4366 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4367#ifdef WLAN_FEATURE_VOWIFI
4368 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4369#endif /* WLAN_FEATURE_VOWIFI */
4370
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004371 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4372 {
4373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4374 "%s:LOGP in Progress. Ignore!!!", __func__);
4375 return -EBUSY;
4376 }
4377
Arif Hussain0273cba2014-01-07 20:58:29 -08004378 /* ODD number is used for set, copy data using copy_from_user */
4379 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4380 wrqu->data.length);
4381 if (NULL == pBuffer)
4382 {
4383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4384 "mem_alloc_copy_from_user_helper fail");
4385 return -ENOMEM;
4386 }
4387
4388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4389 "%s: Received length %d", __func__, wrqu->data.length);
4390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4391 "%s: Received data %s", __func__, pBuffer);
4392
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 switch(sub_cmd)
4394 {
4395 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004397 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 break;
4399 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004401 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 break;
4403#if defined WLAN_FEATURE_VOWIFI
4404 case WE_NEIGHBOR_REPORT_REQUEST:
4405 {
4406 tRrmNeighborReq neighborReq;
4407 tRrmNeighborRspCallbackInfo callbackInfo;
4408
4409 if (pConfig->fRrmEnable)
4410 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4413 if( !neighborReq.no_ssid )
4414 {
4415 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004416 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 }
4418
4419 callbackInfo.neighborRspCallback = NULL;
4420 callbackInfo.neighborRspCallbackContext = NULL;
4421 callbackInfo.timeout = 5000; //5 seconds
4422 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4423 }
4424 else
4425 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004426 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 ret = -EINVAL;
4428 }
4429 }
4430 break;
4431#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 case WE_SET_AP_WPS_IE:
4433 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004434 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004437 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 if (VOS_STATUS_SUCCESS != vstatus)
4439 {
4440 ret = -EINVAL;
4441 }
4442 break;
4443 default:
4444 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004445 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 ret = -EINVAL;
4447 break;
4448 }
4449 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004450 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 return ret;
4452}
4453
4454/* get param sub-ioctls */
4455static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4456 union iwreq_data *wrqu, char *extra)
4457{
4458 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4459 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4460 int *value = (int *)extra;
4461 int ret = 0; /* success */
4462
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004463 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4464 {
4465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4466 "%s:LOGP in Progress. Ignore!!!", __func__);
4467 return -EBUSY;
4468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004469
4470 switch (value[0])
4471 {
4472 case WE_GET_11D_STATE:
4473 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004474 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304476
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4478
Arif Hussain6d2a3322013-11-17 19:50:10 -08004479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004480
4481 break;
4482 }
4483
4484 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 break;
4487
4488 case WE_PMC_STATE:
4489 {
4490 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 break;
4493 }
4494 case WE_GET_WLAN_DBG:
4495 {
4496 vos_trace_display();
4497 *value = 0;
4498 break;
4499 }
4500 case WE_MODULE_DOWN_IND:
4501 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4504#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4507#endif
4508 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4509
4510 *value = 0;
4511 break;
4512 }
4513 case WE_GET_MAX_ASSOC:
4514 {
4515 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4516 {
c_hpothub8245442013-11-20 23:41:09 +05304517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4518 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 ret = -EIO;
4520 }
4521 break;
4522 }
4523
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 case WE_GET_WDI_DBG:
4525 {
4526 wpalTraceDisplay();
4527 *value = 0;
4528 break;
4529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004530
4531 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4532 {
4533 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4534 break;
4535 }
4536 case WE_GET_CONCURRENCY_MODE:
4537 {
4538 *value = hdd_get_concurrency_mode ( );
4539
Arif Hussain6d2a3322013-11-17 19:50:10 -08004540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 break;
4542 }
4543
4544 default:
4545 {
4546 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4547 break;
4548 }
4549 }
4550
4551 return ret;
4552}
4553
4554/* set param sub-ioctls */
4555int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4556 union iwreq_data *wrqu, char *extra)
4557{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004558 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 int *value = (int *)extra;
4560 int sub_cmd = value[0];
4561 int ret = 0;
4562
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004563 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4564 {
4565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4566 "%s:LOGP in Progress. Ignore!!!", __func__);
4567 return -EBUSY;
4568 }
4569
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 switch(sub_cmd)
4571 {
4572 case WE_SET_WLAN_DBG:
4573 {
4574 vos_trace_setValue( value[1], value[2], value[3]);
4575 break;
4576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 case WE_SET_WDI_DBG:
4578 {
4579 wpalTraceSetLevel( value[1], value[2], value[3]);
4580 break;
4581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 case WE_SET_SAP_CHANNELS:
4583 {
4584 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4585 break;
4586 }
4587
4588 default:
4589 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004590 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 break;
4592 }
4593 }
4594 return ret;
4595}
4596
4597static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4598 union iwreq_data *wrqu, char *extra)
4599{
4600 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4601 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004602#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004603 hdd_wext_state_t *pWextState;
4604#endif
4605
4606 if (pAdapter == NULL)
4607 {
4608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4609 "%s: pAdapter is NULL!", __func__);
4610 return -EINVAL;
4611 }
4612#ifdef WLAN_FEATURE_11W
4613 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004614#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004615
Yue Ma3ede6052013-08-29 00:33:26 -07004616 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4617 {
4618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4619 "%s: HDD Context is NULL!", __func__);
4620
4621 return -EINVAL;
4622 }
4623
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004624 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4625 {
4626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4627 "%s:LOGP in Progress. Ignore!!!", __func__);
4628 return -EBUSY;
4629 }
4630
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 switch(sub_cmd)
4632 {
4633 case WE_WLAN_VERSION:
4634 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004635 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 break;
4637 }
4638
4639 case WE_GET_STATS:
4640 {
4641 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4642 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4643 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4644
4645 snprintf(extra, WE_MAX_STR_LEN,
4646 "\nTransmit"
4647 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4648 "\n dropped BK %u, BE %u, VI %u, VO %u"
4649 "\n classified BK %u, BE %u, VI %u, VO %u"
4650 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4651 "\n queued BK %u, BE %u, VI %u, VO %u"
4652 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004653 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 "\n fetched BK %u, BE %u, VI %u, VO %u"
4655 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4656 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004657 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 "\n flushed BK %u, BE %u, VI %u, VO %u"
4659 "\n\nReceive"
4660 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4661 "\n\nResetsStats"
4662 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4663 "\n",
4664 pStats->txXmitCalled,
4665 pStats->txXmitDropped,
4666 pStats->txXmitBackPressured,
4667 pStats->txXmitQueued,
4668
4669 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4670 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4671 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4672 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4673
4674 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4675 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4676 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4677 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4678
4679 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4680 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4681 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4682 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4683
4684 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4685 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4686 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4687 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4688
4689 pStats->txFetched,
4690 pStats->txFetchEmpty,
4691 pStats->txFetchLowResources,
4692 pStats->txFetchDequeueError,
4693
4694 pStats->txFetchDequeued,
4695 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004696 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 pStats->txCompleted,
4698 pStats->txFlushed,
4699
4700 pStats->txFetchedAC[WLANTL_AC_BK],
4701 pStats->txFetchedAC[WLANTL_AC_BE],
4702 pStats->txFetchedAC[WLANTL_AC_VI],
4703 pStats->txFetchedAC[WLANTL_AC_VO],
4704
4705 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4706 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4707 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4708 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4709
4710 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4711 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4712 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4713 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4714
Ravi Joshi41914632013-10-21 23:02:21 -07004715 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4716 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4717 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4718 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4719
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 pStats->txFlushedAC[WLANTL_AC_BK],
4721 pStats->txFlushedAC[WLANTL_AC_BE],
4722 pStats->txFlushedAC[WLANTL_AC_VI],
4723 pStats->txFlushedAC[WLANTL_AC_VO],
4724
4725 pStats->rxChains,
4726 pStats->rxPackets,
4727 pStats->rxDropped,
4728 pStats->rxDelivered,
4729 pStats->rxRefused,
4730
4731 pResetStats->totalLogpResets,
4732 pResetStats->totalCMD53Failures,
4733 pResetStats->totalMutexReadFailures,
4734 pResetStats->totalMIFErrorFailures,
4735 pResetStats->totalFWHearbeatFailures,
4736 pResetStats->totalUnknownExceptions
4737 );
4738 wrqu->data.length = strlen(extra)+1;
4739 break;
4740 }
4741
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304742/* The case prints the current state of the HDD, SME, CSR, PE, TL
4743 *it can be extended for WDI Global State as well.
4744 *And currently it only checks P2P_CLIENT adapter.
4745 *P2P_DEVICE and P2P_GO have not been added as of now.
4746*/
4747 case WE_GET_STATES:
4748 {
4749 int buf = 0, len = 0;
4750 int adapter_num = 0;
4751 int count = 0, check = 1;
4752
4753 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004754 tHalHandle hHal = NULL;
4755 tpAniSirGlobal pMac = NULL;
4756 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304757
4758 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4759 hdd_adapter_t *useAdapter = NULL;
4760
4761 /* Print wlan0 or p2p0 states based on the adapter_num
4762 *by using the correct adapter
4763 */
4764 while ( adapter_num < 2 )
4765 {
4766 if ( WLAN_ADAPTER == adapter_num )
4767 {
4768 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004769 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304770 "\n\n wlan0 States:-");
4771 len += buf;
4772 }
4773 else if ( P2P_ADAPTER == adapter_num )
4774 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004775 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304776 "\n\n p2p0 States:-");
4777 len += buf;
4778
4779 if( !pHddCtx )
4780 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004781 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304782 "\n pHddCtx is NULL");
4783 len += buf;
4784 break;
4785 }
4786
4787 /*Printing p2p0 states only in the case when the device is
4788 configured as a p2p_client*/
4789 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4790 if ( !useAdapter )
4791 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004792 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304793 "\n Device not configured as P2P_CLIENT.");
4794 len += buf;
4795 break;
4796 }
4797 }
4798
4799 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004800 if (!hHal) {
4801 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4802 "\n pMac is NULL");
4803 len += buf;
4804 break;
4805 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304806 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004807 if (!pMac) {
4808 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4809 "\n pMac is NULL");
4810 len += buf;
4811 break;
4812 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304813 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4814 if( !pHddStaCtx )
4815 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004816 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304817 "\n pHddStaCtx is NULL");
4818 len += buf;
4819 break;
4820 }
4821
4822 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4823
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004824 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304825 "\n HDD Conn State - %s "
4826 "\n \n SME State:"
4827 "\n Neighbour Roam State - %s"
4828 "\n CSR State - %s"
4829 "\n CSR Substate - %s"
4830 "\n \n TL STA %d State: %s",
4831 macTraceGetHDDWlanConnState(
4832 pHddStaCtx->conn_info.connState),
4833 macTraceGetNeighbourRoamState(
4834 pMac->roam.neighborRoamInfo.neighborRoamState),
4835 macTraceGetcsrRoamState(
4836 pMac->roam.curState[useAdapter->sessionId]),
4837 macTraceGetcsrRoamSubState(
4838 pMac->roam.curSubState[useAdapter->sessionId]),
4839 pHddStaCtx->conn_info.staId[0],
4840 macTraceGetTLState(tlState)
4841 );
4842 len += buf;
4843 adapter_num++;
4844 }
4845
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004846 if (pMac) {
4847 /* Printing Lim State starting with global lim states */
4848 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4849 "\n \n LIM STATES:-"
4850 "\n Global Sme State - %s "\
4851 "\n Global mlm State - %s "\
4852 "\n",
4853 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4854 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4855 );
4856 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304857
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004858 /*printing the PE Sme and Mlm states for valid lim sessions*/
4859 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304860 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004861 if ( pMac->lim.gpSession[count].valid )
4862 {
4863 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4864 "\n Lim Valid Session %d:-"
4865 "\n PE Sme State - %s "
4866 "\n PE Mlm State - %s "
4867 "\n",
4868 check,
4869 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4870 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4871 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304872
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004873 len += buf;
4874 check++;
4875 }
4876 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304877 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304878 }
4879
4880 wrqu->data.length = strlen(extra)+1;
4881 break;
4882 }
4883
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 case WE_GET_CFG:
4885 {
4886 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4887 wrqu->data.length = strlen(extra)+1;
4888 break;
4889 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004890#ifdef WLAN_FEATURE_11AC
4891 case WE_GET_RSSI:
4892 {
4893 v_S7_t s7Rssi = 0;
4894 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4895 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4896 wrqu->data.length = strlen(extra)+1;
4897 break;
4898 }
4899#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304900
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004901#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004902 case WE_GET_ROAM_RSSI:
4903 {
4904 v_S7_t s7Rssi = 0;
4905 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4906 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4907 wrqu->data.length = strlen(extra)+1;
4908 break;
4909 }
4910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 case WE_GET_WMM_STATUS:
4912 {
4913 snprintf(extra, WE_MAX_STR_LEN,
4914 "\nDir: 0=up, 1=down, 3=both\n"
4915 "|------------------------|\n"
4916 "|AC | ACM |Admitted| Dir |\n"
4917 "|------------------------|\n"
4918 "|VO | %d | %3s | %d |\n"
4919 "|VI | %d | %3s | %d |\n"
4920 "|BE | %d | %3s | %d |\n"
4921 "|BK | %d | %3s | %d |\n"
4922 "|------------------------|\n",
4923 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4924 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4925 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4926 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4927 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4928 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4929 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4930 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4931 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4932 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4933 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4934 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4935
Jeff Johnsone7245742012-09-05 17:12:55 -07004936
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 wrqu->data.length = strlen(extra)+1;
4938 break;
4939 }
4940 case WE_GET_CHANNEL_LIST:
4941 {
4942 VOS_STATUS status;
4943 v_U8_t i, len;
4944 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004945
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 tChannelListInfo channel_list;
4947
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004948 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004950 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004952 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 return -EINVAL;
4954 }
4955 buf = extra;
4956
4957 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004958 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4959 * needed = 5 * number of channels. Check ifsufficient
4960 * buffer is available and then proceed to fill the buffer.
4961 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4963 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004964 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004965 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004966 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 return -EINVAL;
4968 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004969 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4970 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 for(i = 0 ; i < channel_list.num_channels; i++)
4972 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004973 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 }
4976 wrqu->data.length = strlen(extra)+1;
4977
4978 break;
4979 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004980#ifdef FEATURE_WLAN_TDLS
4981 case WE_GET_TDLS_PEERS:
4982 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004983 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004984 break;
4985 }
4986#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004987#ifdef WLAN_FEATURE_11W
4988 case WE_GET_11W_INFO:
4989 {
4990 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4991
4992 snprintf(extra, WE_MAX_STR_LEN,
4993 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4994 "\n Number of Unprotected Disassocs %d"
4995 "\n Number of Unprotected Deauths %d",
4996 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4997 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4998 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4999 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5000 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5001
5002 wrqu->data.length = strlen(extra)+1;
5003 break;
5004 }
5005#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305006 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005007 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005008 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 break;
5010 }
5011 }
5012
5013 return 0;
5014}
5015
5016/* action sub-ioctls */
5017static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5018 union iwreq_data *wrqu, char *extra)
5019{
5020 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5021 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005022 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07005023
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005024 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5025 {
5026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5027 "%s:LOGP in Progress. Ignore!!!", __func__);
5028 return -EBUSY;
5029 }
5030
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 switch (sub_cmd)
5032 {
5033 case WE_CLEAR_STATS:
5034 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5037 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5038 break;
5039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 case WE_INIT_AP:
5041 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305042 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5043
5044 /* As Soft AP mode might been changed to STA already with
5045 * killing of Hostapd, need to find the adpater by name
5046 * rather than mode */
5047 hdd_adapter_t* pAdapter_to_stop =
5048 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5049 if( pAdapter_to_stop )
5050 {
5051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5052 "Adapter with name softap.0 already "
5053 "exist, ignoring the request.\nRemove the "
5054 "adapter and try again\n");
5055 break;
5056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 pr_info("Init AP trigger\n");
5058 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5059 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5060 break;
5061 }
5062 case WE_STOP_AP:
5063 {
5064 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5065 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5066 * this is a dead code and need to find the adpater by name rather than mode */
5067 hdd_adapter_t* pAdapter_to_stop =
5068 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5069 if( pAdapter_to_stop )
5070 {
5071 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5072
5073 pr_info("Stopping AP mode\n");
5074
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305075 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5076 {
5077 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5078 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5079 }
5080
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 /*Make sure that pAdapter cleaned properly*/
5082 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5083 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5084 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5085
5086 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5087 pAdapter_to_stop->macAddressCurrent.bytes);
5088 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5089 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305090
5091 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5092 {
5093 /* put the device back into BMPS */
5094 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 }
5097 else
5098 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005099 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 }
5101
5102 break;
5103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005104#ifdef WLAN_BTAMP_FEATURE
5105 case WE_ENABLE_AMP:
5106 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 WLANBAP_RegisterWithHCI(pAdapter);
5109 break;
5110 }
5111 case WE_DISABLE_AMP:
5112 {
5113 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5114 VOS_STATUS status;
5115
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005117
5118 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5119 status = WLANBAP_StopAmp();
5120 if(VOS_STATUS_SUCCESS != status )
5121 {
5122 pHddCtx->isAmpAllowed = VOS_TRUE;
5123 hddLog(VOS_TRACE_LEVEL_FATAL,
5124 "%s: Failed to stop AMP", __func__);
5125 }
5126 else
5127 {
5128 //a state m/c implementation in PAL is TBD to avoid this delay
5129 msleep(500);
5130 pHddCtx->isAmpAllowed = VOS_FALSE;
5131 WLANBAP_DeregisterFromHCI();
5132 }
5133
5134 break;
5135 }
5136#endif
5137
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005138 case WE_ENABLE_DXE_STALL_DETECT:
5139 {
schang6295e542013-03-12 15:31:23 -07005140 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5141 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005142 break;
5143 }
5144 case WE_DISPLAY_DXE_SNAP_SHOT:
5145 {
schang6295e542013-03-12 15:31:23 -07005146 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5147 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005148 break;
5149 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305150 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5151 {
5152 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5153 hdd_wmm_tx_snapshot(pAdapter);
5154 WLANTL_TLDebugMessage(VOS_TRUE);
5155 break;
5156 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07005157 case WE_SET_REASSOC_TRIGGER:
5158 {
5159 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5160 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5161 v_U32_t roamId = 0;
5162 tCsrRoamModifyProfileFields modProfileFields;
5163 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5164 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5165 return 0;
5166 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305167
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305168 case WE_STOP_OBSS_SCAN:
5169 {
5170 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5171 2.OBSS scan is stopped by Firmware during the disassociation
5172 3.OBSS stop comamnd is added for debugging purpose*/
5173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5174 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005175
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305176 if (pAdapter == NULL)
5177 {
5178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5179 " pAdapter is NULL ");
5180 }
5181 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5182 if (pMac == NULL)
5183 {
5184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5185 " pMac is NULL ");
5186 }
5187 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5188 }
5189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 default:
5191 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005192 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 break;
5194 }
5195 }
5196
5197 return ret;
5198}
5199
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305200void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5201{
5202 /*
5203 * Function to display HDD WMM information
5204 * for Tx Queues.
5205 * Prints globala as well as per client depending
5206 * whether the clients are registered or not.
5207 */
5208 int i = 0, j = 0;
5209 for ( i=0; i< NUM_TX_QUEUES; i++)
5210 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305211 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005212 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305213 i, pAdapter->wmm_tx_queue[i].count,
5214 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305215 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305216 }
5217
5218 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5219 {
5220 if(pAdapter->aStaInfo[i].isUsed)
5221 {
5222 hddLog(LOGE, "******STAIndex: %d*********", i);
5223 for ( j=0; j< NUM_TX_QUEUES; j++)
5224 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305225 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005226 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305227 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5228 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5229 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305230 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305231 }
5232 }
5233 }
5234
5235}
Jeff Johnson295189b2012-06-20 16:38:30 -07005236int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5237 union iwreq_data *wrqu, char *extra)
5238{
5239 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5240 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5241 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005242 int apps_args[MAX_VAR_ARGS] = {0};
5243 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005244 hdd_station_ctx_t *pStaCtx = NULL ;
5245 hdd_ap_ctx_t *pAPCtx = NULL;
5246 int cmd = 0;
5247 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005248
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005249 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005250
5251 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5252 {
5253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5254 "%s:LOGP in Progress. Ignore!!!", __func__);
5255 return -EBUSY;
5256 }
5257
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 if (num_args > MAX_VAR_ARGS)
5259 {
5260 num_args = MAX_VAR_ARGS;
5261 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005262
5263 /* ODD number is used for set, copy data using copy_from_user */
5264 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5265 {
5266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5267 "%s: failed to copy data to user buffer", __func__);
5268 return -EFAULT;
5269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005270
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005271 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5272 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5273 {
5274 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5275 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5276 {
5277 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5278 staId = pStaCtx->conn_info.staId[0];
5279 }
5280 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5281 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5282 {
5283 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5284 staId = pAPCtx->uBCStaId;
5285 }
5286 else
5287 {
5288 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5289 return 0;
5290 }
5291 }
5292
Jeff Johnson295189b2012-06-20 16:38:30 -07005293 switch (sub_cmd)
5294 {
5295 case WE_LOG_DUMP_CMD:
5296 {
5297 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005298 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 apps_args[3], apps_args[4]);
5300
5301 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5302 apps_args[3], apps_args[4]);
5303
5304 }
5305 break;
5306
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 case WE_P2P_NOA_CMD:
5308 {
5309 p2p_app_setP2pPs_t p2pNoA;
5310
5311 p2pNoA.opp_ps = apps_args[0];
5312 p2pNoA.ctWindow = apps_args[1];
5313 p2pNoA.duration = apps_args[2];
5314 p2pNoA.interval = apps_args[3];
5315 p2pNoA.count = apps_args[4];
5316 p2pNoA.single_noa_duration = apps_args[5];
5317 p2pNoA.psSelection = apps_args[6];
5318
5319 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5320 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005321 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5323
5324 hdd_setP2pPs(dev, &p2pNoA);
5325
5326 }
5327 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005328
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305329 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5330 {
5331 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5332 __func__, apps_args[0], apps_args[1]);
5333 vosTraceEnable(apps_args[0], apps_args[1]);
5334 }
5335 break;
5336
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005337 case WE_MTRACE_DUMP_CMD:
5338 {
5339 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5340 "bitmask_of_module %d ",
5341 __func__, apps_args[0], apps_args[1], apps_args[2],
5342 apps_args[3]);
5343 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5344 apps_args[2], apps_args[3]);
5345
5346 }
5347 break;
5348
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005349 case WE_MCC_CONFIG_CREDENTIAL :
5350 {
5351 cmd = 287; //Command should be updated if there is any change
5352 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005353 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005354 {
5355 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5356 }
5357 else
5358 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005359 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005360 return 0;
5361 }
5362 }
5363 break;
5364
5365 case WE_MCC_CONFIG_PARAMS :
5366 {
5367 cmd = 288; //command Should be updated if there is any change
5368 // in the Riva dump command
5369 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5370 }
5371 break;
5372
Chilam NG571c65a2013-01-19 12:27:36 +05305373#ifdef FEATURE_WLAN_TDLS
5374 case WE_TDLS_CONFIG_PARAMS :
5375 {
5376 tdls_config_params_t tdlsParams;
5377
Chilam Ng01120412013-02-19 18:32:21 -08005378 tdlsParams.tdls = apps_args[0];
5379 tdlsParams.tx_period_t = apps_args[1];
5380 tdlsParams.tx_packet_n = apps_args[2];
5381 tdlsParams.discovery_period_t = apps_args[3];
5382 tdlsParams.discovery_tries_n = apps_args[4];
5383 tdlsParams.idle_timeout_t = apps_args[5];
5384 tdlsParams.idle_packet_n = apps_args[6];
5385 tdlsParams.rssi_hysteresis = apps_args[7];
5386 tdlsParams.rssi_trigger_threshold = apps_args[8];
5387 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305388
Chilam Ng01120412013-02-19 18:32:21 -08005389 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305390 }
5391 break;
5392#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 default:
5394 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005395 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5396 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 }
5398 break;
5399 }
5400
5401 return 0;
5402}
5403
5404
5405static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5406 union iwreq_data *wrqu, char *extra)
5407{
5408 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5409 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5410 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5411 int params[HDD_WLAN_WMM_PARAM_COUNT];
5412 sme_QosWmmTspecInfo tSpec;
5413 v_U32_t handle;
5414
5415 // make sure the application is sufficiently priviledged
5416 // note that the kernel will do this for "set" ioctls, but since
5417 // this ioctl wants to return status to user space it must be
5418 // defined as a "get" ioctl
5419 if (!capable(CAP_NET_ADMIN))
5420 {
5421 return -EPERM;
5422 }
5423
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005424 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5425 {
5426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5427 "%s:LOGP in Progress. Ignore!!!", __func__);
5428 return -EBUSY;
5429 }
5430
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 // we must be associated in order to add a tspec
5432 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5433 {
5434 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5435 return 0;
5436 }
5437
5438 // since we are defined to be a "get" ioctl, and since the number
5439 // of params exceeds the number of params that wireless extensions
5440 // will pass down in the iwreq_data, we must copy the "set" params
5441 // from user space ourselves
5442 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5443 {
5444 // hmmm, can't get them
5445 return -EIO;
5446 }
5447
5448 // clear the tspec
5449 memset(&tSpec, 0, sizeof(tSpec));
5450
5451 // validate the handle
5452 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5453 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5454 {
5455 // that one is reserved
5456 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5457 return 0;
5458 }
5459
5460 // validate the TID
5461 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5462 {
5463 // out of range
5464 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5465 return 0;
5466 }
5467 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5468
5469 // validate the direction
5470 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5471 {
5472 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5473 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5474 break;
5475
5476 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5477 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5478 break;
5479
5480 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5481 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5482 break;
5483
5484 default:
5485 // unknown
5486 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5487 return 0;
5488 }
5489
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305490 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5491
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 // validate the user priority
5493 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5494 {
5495 // out of range
5496 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5497 return 0;
5498 }
5499 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305500 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5501 {
5502 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5503 return 0;
5504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005505
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5507 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5508 tSpec.ts_info.psb, tSpec.ts_info.up);
5509
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5511 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5512 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5513 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5514 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5515 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5516 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5517 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5518 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5519 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5520 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5521 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5522
5523 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5524
5525 // validate the ts info ack policy
5526 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5527 {
5528 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5529 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5530 break;
5531
5532 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5533 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5534 break;
5535
5536 default:
5537 // unknown
5538 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5539 return 0;
5540 }
5541
5542 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5543 return 0;
5544}
5545
5546
5547static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5548 union iwreq_data *wrqu, char *extra)
5549{
5550 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5551 int *params = (int *)extra;
5552 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5553 v_U32_t handle;
5554
5555 // make sure the application is sufficiently priviledged
5556 // note that the kernel will do this for "set" ioctls, but since
5557 // this ioctl wants to return status to user space it must be
5558 // defined as a "get" ioctl
5559 if (!capable(CAP_NET_ADMIN))
5560 {
5561 return -EPERM;
5562 }
5563
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005564 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5565 {
5566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5567 "%s:LOGP in Progress. Ignore!!!", __func__);
5568 return -EBUSY;
5569 }
5570
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 // although we are defined to be a "get" ioctl, the params we require
5572 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5573 // is no need to copy the params from user space
5574
5575 // validate the handle
5576 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5577 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5578 {
5579 // that one is reserved
5580 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5581 return 0;
5582 }
5583
5584 *pStatus = hdd_wmm_delts(pAdapter, handle);
5585 return 0;
5586}
5587
5588
5589static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5590 union iwreq_data *wrqu, char *extra)
5591{
5592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5593 int *params = (int *)extra;
5594 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5595 v_U32_t handle;
5596
5597 // although we are defined to be a "get" ioctl, the params we require
5598 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5599 // is no need to copy the params from user space
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
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005610 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5611 {
5612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5613 "%s:LOGP in Progress. Ignore!!!", __func__);
5614 return -EBUSY;
5615 }
5616
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5618 return 0;
5619}
5620
5621
5622#ifdef FEATURE_WLAN_WAPI
5623static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5624 union iwreq_data *wrqu, char *extra)
5625{
5626 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5627 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5628 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5629 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5630
Arif Hussain7adce1b2013-11-11 22:59:34 -08005631 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005632
5633 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005634 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005635 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5636 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005637
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005638 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5639 {
5640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5641 "%s:LOGP in Progress. Ignore!!!", __func__);
5642 return -EBUSY;
5643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005644
5645 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005646 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5648 pRoamProfile->EncryptionType.numEntries = 1;
5649 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5650 pRoamProfile->mcEncryptionType.numEntries = 1;
5651 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5652
5653 pRoamProfile->AuthType.numEntries = 1;
5654 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5655 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5656 }
5657 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005658 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 }
5660 else
5661 return -EINVAL;
5662
5663 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5664
5665 return 0;
5666}
5667
5668static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5669 union iwreq_data *wrqu, char *extra)
5670{
5671 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5672 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5673
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005674 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5675 {
5676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5677 "%s:LOGP in Progress. Ignore!!!", __func__);
5678 return -EBUSY;
5679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5681
5682 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005683 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 return 0;
5685}
5686
5687static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5688 union iwreq_data *wrqu, char *extra)
5689{
5690 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5691// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5692 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5693 int i = 0, j = 0;
5694 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005695 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005696 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005697
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005698 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5699 {
5700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5701 "%s:LOGP in Progress. Ignore!!!", __func__);
5702 return -EBUSY;
5703 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005704
5705 if (NULL == pWapiAssocInfo)
5706 {
5707 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5708 "%s: WDA NULL context", __func__);
5709 VOS_ASSERT(0);
5710 return VOS_STATUS_E_FAILURE;
5711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005712
Arif Hussain6d2a3322013-11-17 19:50:10 -08005713 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 -07005714 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005716 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005717
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005718 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005720 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005721
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005722 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005723 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 for(i = 0 ; i < 16 ; i++) {
5725 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5726 for(j = 0 ; j < 16 ; j++)
5727 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5728 }
5729
5730 /* We are not using the entire IE as provided by the supplicant.
5731 * This is being calculated by SME. This is the same as in the
5732 * case of WPA. Only the auth mode information needs to be
5733 * extracted here*/
5734 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005735 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005736 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5737 }
5738
5739 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005740 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5742 }
5743 return 0;
5744}
5745
5746static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5747 union iwreq_data *wrqu, char *extra)
5748{
5749 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5750 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5751 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5752 tANI_U32 roamId = 0xFF;
5753 tANI_U8 *pKeyPtr = NULL;
5754 v_BOOL_t isConnected = TRUE;
5755 tCsrRoamSetKey setKey;
5756 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5758
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005759 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5760 {
5761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5762 "%s:LOGP in Progress. Ignore!!!", __func__);
5763 return -EBUSY;
5764 }
5765
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005767 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005768 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005769
Arif Hussain6d2a3322013-11-17 19:50:10 -08005770 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 -07005771 hddLog(LOG1,"Add Index:0x");
5772 for(i =0 ; i < 12 ; i++)
5773 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5774
Arif Hussain6d2a3322013-11-17 19:50:10 -08005775 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5777 for(i =0 ; i < 16 ; i++)
5778 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5779
Arif Hussain6d2a3322013-11-17 19:50:10 -08005780 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5782 for(i =0 ; i < 16 ; i++)
5783 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5784
Arif Hussain6d2a3322013-11-17 19:50:10 -08005785 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 for(i = 0 ; i < 16 ; i++)
5787 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5788
5789 // Clear the setkey memory
5790 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5791 // Store Key ID
5792 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5793 // SET WAPI Encryption
5794 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5795 // Key Directionn both TX and RX
5796 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5797 // the PAE role
5798 setKey.paeRole = 0 ;
5799
5800 switch ( pWapiKey->keyType )
5801 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005802 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005803 {
5804 isConnected = hdd_connIsConnected(pHddStaCtx);
5805 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5806 break;
5807 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005808 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 {
5810 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5811 break;
5812 }
5813 default:
5814 {
5815 //Any other option is invalid.
5816 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005817 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005818
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005819 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5821 break; // NEED RETURN FROM HERE ????
5822 }
5823 }
5824
5825 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5826 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5827 pKeyPtr = setKey.Key;
5828 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5829 pKeyPtr += pWapiKey->wpiekLen;
5830 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5831
5832 // Set the new key with SME.
5833 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5834
5835 if ( isConnected ) {
5836 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5837 if ( halStatus != eHAL_STATUS_SUCCESS )
5838 {
5839 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5840 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5841
5842 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5843 }
5844 }
5845#if 0 /// NEED TO CHECK ON THIS
5846 else
5847 {
5848 // Store the keys in the adapter to be moved to the profile & passed to
5849 // SME in the ConnectRequest if we are not yet in connected state.
5850 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5851 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5852
5853 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5854 " Saving key [idx= %d] to apply when moving to connected state ",
5855 setKey.keyId );
5856
5857 }
5858#endif
5859 return halStatus;
5860}
5861
5862static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5863 union iwreq_data *wrqu, char *extra)
5864{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005866#ifdef WLAN_DEBUG
5867 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005868 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005869#endif
5870
5871 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005872 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005873 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005874
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005875 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5876 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005877
5878 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005879
5880 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5881 {
5882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5883 "%s:LOGP in Progress. Ignore!!!", __func__);
5884 return -EBUSY;
5885 }
5886
Jeff Johnson295189b2012-06-20 16:38:30 -07005887#ifdef WLAN_DEBUG
5888 for(i =0 ; i < 16 ; i++)
5889 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5890#endif
5891
5892 return 0;
5893}
5894
5895static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5896 union iwreq_data *wrqu, char *extra)
5897{
5898 /* Yet to implement this function, 19th April 2010 */
5899 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5900
5901 return 0;
5902}
5903#endif /* FEATURE_WLAN_WAPI */
5904
5905#ifdef WLAN_FEATURE_VOWIFI_11R
5906//
5907//
5908// Each time the supplicant has the auth_request or reassoc request
5909// IEs ready. This is pushed to the driver. The driver will inturn use
5910// it to send out the auth req and reassoc req for 11r FT Assoc.
5911//
5912static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5913 union iwreq_data *wrqu, char *extra)
5914{
5915 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5916 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5917 //v_CONTEXT_t pVosContext;
5918
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005919 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5920 {
5921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5922 "%s:LOGP in Progress. Ignore!!!", __func__);
5923 return -EBUSY;
5924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 if (!wrqu->data.length)
5926 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005927 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 return -EINVAL;
5929 }
5930 if (wrqu->data.pointer == NULL)
5931 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005932 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 return -EINVAL;
5934 }
5935
5936 // Added for debug on reception of Re-assoc Req.
5937 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5938 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005939 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005941 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 }
5943
5944#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005945 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005946#endif
5947
5948 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005949 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 wrqu->data.length);
5951
5952 return 0;
5953}
5954#endif
5955
Amar Singhalf3a6e762013-02-19 15:06:50 -08005956static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005957 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005959{
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005961 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005963 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005964 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005965 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5966 int idx;
5967 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005969 if (pHddCtx->isLogpInProgress)
5970 {
5971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5972 "%s:LOGP in Progress. Ignore!!!", __func__);
5973 return -EBUSY;
5974 }
5975
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305976 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5977 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305978#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005979
Amar Singhalf3a6e762013-02-19 15:06:50 -08005980 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5981 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005982 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005983 hddLog(VOS_TRACE_LEVEL_ERROR,
5984 "%s: vos_mem_alloc failed", __func__);
5985 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005986 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005987
5988 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5989
5990 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5991 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5992
5993 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5994 mc_addr_list_ptr->ulMulticastAddrCnt);
5995
5996 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005997 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005998 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5999 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6000
6001 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6002 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006003 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006004
Amar Singhalf3a6e762013-02-19 15:06:50 -08006005 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6006 vos_mem_free(mc_addr_list_ptr);
6007 if (eHAL_STATUS_SUCCESS != ret_val)
6008 {
6009 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6010 __func__);
6011 return -EINVAL;
6012 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306013#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306014 }
6015 else
6016 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006017
Amar Singhalf3a6e762013-02-19 15:06:50 -08006018 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6019 "%s: Set MC BC Filter Config request: %d suspend %d",
6020 __func__, pRequest->mcastBcastFilterSetting,
6021 pHddCtx->hdd_wlan_suspended);
6022
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306023 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006024
6025 if (pHddCtx->hdd_wlan_suspended)
6026 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006027 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6028 if (NULL == wlanRxpFilterParam)
6029 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306030 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006031 "%s: vos_mem_alloc failed", __func__);
6032 return -EINVAL;
6033 }
6034
Amar Singhalf3a6e762013-02-19 15:06:50 -08006035 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6036 pRequest->mcastBcastFilterSetting;
6037 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6038
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306039 hdd_conf_hostoffload(pAdapter, TRUE);
6040 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6041 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006042
6043 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6044 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306045 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006046 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6047 wlanRxpFilterParam->setMcstBcstFilter);
6048
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306049 if (eHAL_STATUS_SUCCESS !=
6050 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6051 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006052 {
6053 hddLog(VOS_TRACE_LEVEL_ERROR,
6054 "%s: Failure to execute set HW MC/BC Filter request",
6055 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006056 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006057 return -EINVAL;
6058 }
6059
Amar Singhalf3a6e762013-02-19 15:06:50 -08006060 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006062
6063 return 0;
6064}
6065
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006066static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006067 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 union iwreq_data *wrqu, char *extra)
6069{
6070 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6071 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306072 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006073 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006074
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306075 //Reset the filter to INI value as we have to clear the dynamic filter
6076 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006077
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306078 //Configure FW with new setting
6079 if (pHddCtx->hdd_wlan_suspended)
6080 {
6081 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6082 if (NULL == wlanRxpFilterParam)
6083 {
6084 hddLog(VOS_TRACE_LEVEL_ERROR,
6085 "%s: vos_mem_alloc failed", __func__);
6086 return -EINVAL;
6087 }
6088
6089 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6090 pHddCtx->configuredMcastBcastFilter;
6091 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6092
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306093 hdd_conf_hostoffload(pAdapter, TRUE);
6094 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6095 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306096
6097 if (eHAL_STATUS_SUCCESS !=
6098 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6099 wlanRxpFilterParam))
6100 {
6101 hddLog(VOS_TRACE_LEVEL_ERROR,
6102 "%s: Failure to execute set HW MC/BC Filter request",
6103 __func__);
6104 vos_mem_free(wlanRxpFilterParam);
6105 return -EINVAL;
6106 }
6107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 return 0;
6109}
6110
6111static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6112 union iwreq_data *wrqu, char *extra)
6113{
6114 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006115 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 tSirHostOffloadReq offloadRequest;
6117
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006118 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6119 {
6120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6121 "%s:LOGP in Progress. Ignore!!!", __func__);
6122 return -EBUSY;
6123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 /* Debug display of request components. */
6125 switch (pRequest->offloadType)
6126 {
6127 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006128 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 switch (pRequest->enableOrDisable)
6130 {
6131 case WLAN_OFFLOAD_DISABLE:
6132 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6133 break;
6134 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6135 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6136 case WLAN_OFFLOAD_ENABLE:
6137 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6138 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6139 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6140 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6141 }
6142 break;
6143
6144 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006145 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006146 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 switch (pRequest->enableOrDisable)
6148 {
6149 case WLAN_OFFLOAD_DISABLE:
6150 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6151 break;
6152 case WLAN_OFFLOAD_ENABLE:
6153 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6154 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6155 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6156 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6157 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6158 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6159 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6160 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6161 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6162 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6163 }
6164 }
6165
6166 /* Execute offload request. The reason that we can copy the request information
6167 from the ioctl structure to the SME structure is that they are laid out
6168 exactly the same. Otherwise, each piece of information would have to be
6169 copied individually. */
6170 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006171 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6172 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 __func__);
6176 return -EINVAL;
6177 }
6178
6179 return 0;
6180}
6181
6182static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6183 union iwreq_data *wrqu, char *extra)
6184{
6185 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006186 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 tSirKeepAliveReq keepaliveRequest;
6188
6189 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6190 {
6191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006192 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 return 0;
6194 }
6195
6196 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006197 hddLog(VOS_TRACE_LEVEL_INFO,
6198 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6199 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006200
6201 switch (pRequest->packetType)
6202 {
6203 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006204 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 break;
6206
6207 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6208
Arif Hussain6d2a3322013-11-17 19:50:10 -08006209 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006210 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006211
6212 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6213 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6214 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6215
6216 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6217 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6218 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6219
6220 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6221 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6222 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6223 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6224 break;
6225
6226 }
6227
6228 /* Execute keep alive request. The reason that we can copy the request information
6229 from the ioctl structure to the SME structure is that they are laid out
6230 exactly the same. Otherwise, each piece of information would have to be
6231 copied individually. */
6232 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6233
Arif Hussain6d2a3322013-11-17 19:50:10 -08006234 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006235
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006236 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006237 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006239 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 __func__);
6241 return -EINVAL;
6242 }
6243
6244 return 0;
6245}
6246
6247#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006248int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006249 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006250{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006251 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6252 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 int i=0;
6254
6255 if (pHddCtx->cfg_ini->disablePacketFilter)
6256 {
6257 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006258 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 return 0;
6260 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006261 if (pHddCtx->isLogpInProgress)
6262 {
6263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6264 "%s:LOGP in Progress. Ignore!!!", __func__);
6265 return -EBUSY;
6266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 /* Debug display of request components. */
6268 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006269 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006270
6271 switch (pRequest->filterAction)
6272 {
6273 case HDD_RCV_FILTER_SET:
6274 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006275 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006276
6277 packetFilterSetReq.filterId = pRequest->filterId;
6278 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6279 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006280 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 __func__, pRequest->numParams);
6282 return -EINVAL;
6283 }
6284 packetFilterSetReq.numFieldParams = pRequest->numParams;
6285 packetFilterSetReq.coalesceTime = 0;
6286 packetFilterSetReq.filterType = 1;
6287 for (i=0; i < pRequest->numParams; i++)
6288 {
6289 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6290 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6291 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6292 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6293 packetFilterSetReq.paramsData[i].reserved = 0;
6294
Arif Hussain6d2a3322013-11-17 19:50:10 -08006295 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6297 packetFilterSetReq.filterType);
6298
Arif Hussain6d2a3322013-11-17 19:50:10 -08006299 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6301
6302 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6303 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6304 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6305 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6306
Arif Hussain6d2a3322013-11-17 19:50:10 -08006307 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6309 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6310 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6311
Arif Hussain6d2a3322013-11-17 19:50:10 -08006312 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6314 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6315 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6316 }
6317
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006318 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006320 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 __func__);
6322 return -EINVAL;
6323 }
6324
6325 break;
6326
6327 case HDD_RCV_FILTER_CLEAR:
6328
Arif Hussain6d2a3322013-11-17 19:50:10 -08006329 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006330 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006332 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006334 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 __func__);
6336 return -EINVAL;
6337 }
6338 break;
6339
6340 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006341 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006342 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 return -EINVAL;
6344 }
6345 return 0;
6346}
6347
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306348int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6349 tANI_U8 sessionId)
6350{
6351 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6352 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6353
6354 if (NULL == pHddCtx)
6355 {
6356 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6357 return -EINVAL;
6358 }
6359
6360 if (pHddCtx->isLogpInProgress)
6361 {
6362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6363 "%s:LOGP in Progress. Ignore!!!", __func__);
6364 return -EBUSY;
6365 }
6366
6367 if (pHddCtx->cfg_ini->disablePacketFilter)
6368 {
6369 hddLog(VOS_TRACE_LEVEL_ERROR,
6370 "%s: Packet Filtering Disabled. Returning ",
6371 __func__ );
6372 return -EINVAL;
6373 }
6374
6375 switch (filterType)
6376 {
6377 /* For setting IPV6 MC and UC Filter we need to configure
6378 * 2 filters, one for MC and one for UC.
6379 * The Filter ID shouldn't be swapped, which results in making
6380 * UC Filter ineffective.
6381 * We have Hardcode all the values
6382 *
6383 * Reason for a seperate UC filter is because, driver need to
6384 * specify the FW that the specific filter is for unicast
6385 * otherwise FW will not pass the unicast frames by default
6386 * through the filter. This is required to avoid any performance
6387 * hits when no unicast filter is set and only MC/BC are set.
6388 * The way driver informs host is by using the MAC protocol
6389 * layer, CMP flag set to MAX, CMP Data set to 1.
6390 */
6391
6392 case HDD_FILTER_IPV6_MC_UC:
6393 /* Setting IPV6 MC Filter below
6394 */
6395 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6396 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6397 packetFilterSetReq.numFieldParams = 2;
6398 packetFilterSetReq.paramsData[0].protocolLayer =
6399 HDD_FILTER_PROTO_TYPE_MAC;
6400 packetFilterSetReq.paramsData[0].cmpFlag =
6401 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6402 packetFilterSetReq.paramsData[0].dataOffset =
6403 WLAN_HDD_80211_FRM_DA_OFFSET;
6404 packetFilterSetReq.paramsData[0].dataLength = 1;
6405 packetFilterSetReq.paramsData[0].compareData[0] =
6406 HDD_IPV6_MC_CMP_DATA;
6407
6408 packetFilterSetReq.paramsData[1].protocolLayer =
6409 HDD_FILTER_PROTO_TYPE_ARP;
6410 packetFilterSetReq.paramsData[1].cmpFlag =
6411 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6412 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6413 packetFilterSetReq.paramsData[1].dataLength = 2;
6414 packetFilterSetReq.paramsData[1].compareData[0] =
6415 HDD_IPV6_CMP_DATA_0;
6416 packetFilterSetReq.paramsData[1].compareData[1] =
6417 HDD_IPV6_CMP_DATA_1;
6418
6419
6420 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6421 &packetFilterSetReq, sessionId))
6422 {
6423 hddLog(VOS_TRACE_LEVEL_ERROR,
6424 "%s: Failure to execute Set IPv6 Mulicast Filter",
6425 __func__);
6426 return -EINVAL;
6427 }
6428
6429 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6430
6431 /*
6432 * Setting IPV6 UC Filter below
6433 */
6434 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6435 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6436 packetFilterSetReq.numFieldParams = 2;
6437 packetFilterSetReq.paramsData[0].protocolLayer =
6438 HDD_FILTER_PROTO_TYPE_MAC;
6439 packetFilterSetReq.paramsData[0].cmpFlag =
6440 HDD_FILTER_CMP_TYPE_MAX;
6441 packetFilterSetReq.paramsData[0].dataOffset = 0;
6442 packetFilterSetReq.paramsData[0].dataLength = 1;
6443 packetFilterSetReq.paramsData[0].compareData[0] =
6444 HDD_IPV6_UC_CMP_DATA;
6445
6446 packetFilterSetReq.paramsData[1].protocolLayer =
6447 HDD_FILTER_PROTO_TYPE_ARP;
6448 packetFilterSetReq.paramsData[1].cmpFlag =
6449 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6450 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6451 packetFilterSetReq.paramsData[1].dataLength = 2;
6452 packetFilterSetReq.paramsData[1].compareData[0] =
6453 HDD_IPV6_CMP_DATA_0;
6454 packetFilterSetReq.paramsData[1].compareData[1] =
6455 HDD_IPV6_CMP_DATA_1;
6456
6457 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6458 &packetFilterSetReq, sessionId))
6459 {
6460 hddLog(VOS_TRACE_LEVEL_ERROR,
6461 "%s: Failure to execute Set IPv6 Unicast Filter",
6462 __func__);
6463 return -EINVAL;
6464 }
6465
6466 break;
6467
6468 case HDD_FILTER_IPV6_MC:
6469 /*
6470 * IPV6 UC Filter might be already set,
6471 * clear the UC Filter. As the Filter
6472 * IDs are static, we can directly clear it.
6473 */
6474 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6475 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6476 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6477 &packetFilterClrReq, sessionId))
6478 {
6479 hddLog(VOS_TRACE_LEVEL_ERROR,
6480 "%s: Failure to execute Clear IPv6 Unicast Filter",
6481 __func__);
6482 return -EINVAL;
6483 }
6484
6485 /*
6486 * Setting IPV6 MC Filter below
6487 */
6488 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6489 packetFilterSetReq.numFieldParams = 2;
6490 packetFilterSetReq.paramsData[0].protocolLayer =
6491 HDD_FILTER_PROTO_TYPE_MAC;
6492 packetFilterSetReq.paramsData[0].cmpFlag =
6493 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6494 packetFilterSetReq.paramsData[0].dataOffset =
6495 WLAN_HDD_80211_FRM_DA_OFFSET;
6496 packetFilterSetReq.paramsData[0].dataLength = 1;
6497 packetFilterSetReq.paramsData[0].compareData[0] =
6498 HDD_IPV6_MC_CMP_DATA;
6499
6500 packetFilterSetReq.paramsData[1].protocolLayer =
6501 HDD_FILTER_PROTO_TYPE_ARP;
6502 packetFilterSetReq.paramsData[1].cmpFlag =
6503 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6504 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6505 packetFilterSetReq.paramsData[1].dataLength = 2;
6506 packetFilterSetReq.paramsData[1].compareData[0] =
6507 HDD_IPV6_CMP_DATA_0;
6508 packetFilterSetReq.paramsData[1].compareData[1] =
6509 HDD_IPV6_CMP_DATA_1;
6510
6511
6512 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6513 &packetFilterSetReq, sessionId))
6514 {
6515 hddLog(VOS_TRACE_LEVEL_ERROR,
6516 "%s: Failure to execute Set IPv6 Multicast Filter",
6517 __func__);
6518 return -EINVAL;
6519 }
6520 break;
6521
6522 default :
6523 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6524 "%s: Packet Filter Request: Invalid",
6525 __func__);
6526 return -EINVAL;
6527 }
6528 return 0;
6529}
6530
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306531void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006532{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306533 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306534 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006535 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306536 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006537
Yue Ma3ede6052013-08-29 00:33:26 -07006538 if (NULL == pHddCtx)
6539 {
6540 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6541 return;
6542 }
6543
6544 hHal = pHddCtx->hHal;
6545
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306546 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306548 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6549 return;
6550 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306551
6552 /* Check if INI is enabled or not, other wise just return
6553 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306554 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306555 {
6556 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6557 if (NULL == pMulticastAddrs)
6558 {
6559 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6560 return;
6561 }
6562
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 if (set)
6564 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306565 /* Following pre-conditions should be satisfied before wei
6566 * configure the MC address list.
6567 */
6568 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6569 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6570 && pAdapter->mc_addr_list.mc_cnt
6571 && (eConnectionState_Associated ==
6572 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6573 {
6574 pMulticastAddrs->ulMulticastAddrCnt =
6575 pAdapter->mc_addr_list.mc_cnt;
6576 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6577 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006578 memcpy(pMulticastAddrs->multicastAddr[i],
6579 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306580 sizeof(pAdapter->mc_addr_list.addr[i]));
6581 hddLog(VOS_TRACE_LEVEL_INFO,
6582 "%s: %s multicast filter: addr ="
6583 MAC_ADDRESS_STR,
6584 __func__, set ? "setting" : "clearing",
6585 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6586 }
6587 /* Set multicast filter */
6588 sme_8023MulticastList(hHal, pAdapter->sessionId,
6589 pMulticastAddrs);
6590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306592 else
6593 {
6594 /* Need to clear only if it was previously configured
6595 */
6596 if (pAdapter->mc_addr_list.isFilterApplied)
6597 {
6598 pMulticastAddrs->ulMulticastAddrCnt = 0;
6599 sme_8023MulticastList(hHal, pAdapter->sessionId,
6600 pMulticastAddrs);
6601 }
6602
6603 }
6604 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006605 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306607 else
6608 {
6609 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306610 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306611 }
6612 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006613}
6614
6615static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6616 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306617{
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006619 tpPacketFilterCfg pRequest = NULL;
6620 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006621
Arif Hussain0273cba2014-01-07 20:58:29 -08006622 /* ODD number is used for set, copy data using copy_from_user */
6623 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6624 wrqu->data.length);
6625 if (NULL == pRequest)
6626 {
6627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6628 "mem_alloc_copy_from_user_helper fail");
6629 return -ENOMEM;
6630 }
6631
6632 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6633 kfree(pRequest);
6634
6635 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006636}
6637#endif
6638static int iw_get_statistics(struct net_device *dev,
6639 struct iw_request_info *info,
6640 union iwreq_data *wrqu, char *extra)
6641{
6642
6643 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6644 eHalStatus status = eHAL_STATUS_SUCCESS;
6645 hdd_wext_state_t *pWextState;
6646 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6647 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6648 char *p = extra;
6649 int tlen = 0;
6650 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6651
6652 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6653 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6654
6655 ENTER();
6656
6657 if (pHddCtx->isLogpInProgress) {
6658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6659 return -EINVAL;
6660 }
6661
6662 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6663
6664 wrqu->txpower.value = 0;
6665 }
6666 else {
6667 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6668 SME_SUMMARY_STATS |
6669 SME_GLOBAL_CLASSA_STATS |
6670 SME_GLOBAL_CLASSB_STATS |
6671 SME_GLOBAL_CLASSC_STATS |
6672 SME_GLOBAL_CLASSD_STATS |
6673 SME_PER_STA_STATS,
6674 hdd_StatisticsCB, 0, FALSE,
6675 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6676
6677 if (eHAL_STATUS_SUCCESS != status)
6678 {
6679 hddLog(VOS_TRACE_LEVEL_ERROR,
6680 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006681 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 return -EINVAL;
6683 }
6684
6685 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6686
6687 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6688 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6689 {
6690 hddLog(VOS_TRACE_LEVEL_ERROR,
6691 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006692 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 /*Remove the SME statistics list by passing NULL in callback argument*/
6694 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6695 SME_SUMMARY_STATS |
6696 SME_GLOBAL_CLASSA_STATS |
6697 SME_GLOBAL_CLASSB_STATS |
6698 SME_GLOBAL_CLASSC_STATS |
6699 SME_GLOBAL_CLASSD_STATS |
6700 SME_PER_STA_STATS,
6701 NULL, 0, FALSE,
6702 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6703
6704 return -EINVAL;
6705 }
6706 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6707 (tANI_U8) sizeof (pStats->retry_cnt),
6708 (char*) &(pStats->retry_cnt[0]),
6709 tlen);
6710
6711 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6712 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6713 (char*) &(pStats->multiple_retry_cnt[0]),
6714 tlen);
6715
6716 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6717 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6718 (char*) &(pStats->tx_frm_cnt[0]),
6719 tlen);
6720
6721 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6722 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6723 (char*) &(pStats->rx_frm_cnt),
6724 tlen);
6725
6726 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6727 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6728 (char*) &(pStats->frm_dup_cnt),
6729 tlen);
6730
6731 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6732 (tANI_U8) sizeof (pStats->fail_cnt),
6733 (char*) &(pStats->fail_cnt[0]),
6734 tlen);
6735
6736 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6737 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6738 (char*) &(pStats->rts_fail_cnt),
6739 tlen);
6740
6741 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6742 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6743 (char*) &(pStats->ack_fail_cnt),
6744 tlen);
6745
6746 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6747 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6748 (char*) &(pStats->rts_succ_cnt),
6749 tlen);
6750
6751 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6752 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6753 (char*) &(pStats->rx_discard_cnt),
6754 tlen);
6755
6756 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6757 (tANI_U8) sizeof (pStats->rx_error_cnt),
6758 (char*) &(pStats->rx_error_cnt),
6759 tlen);
6760
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006761 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006762 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006763 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 tlen);
6765
6766 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6767 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6768 (char*) &(dStats->rx_byte_cnt),
6769 tlen);
6770
6771 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6772 (tANI_U8) sizeof (dStats->rx_rate),
6773 (char*) &(dStats->rx_rate),
6774 tlen);
6775
6776 /* Transmit rate, in units of 500 kbit/sec */
6777 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6778 (tANI_U8) sizeof (aStats->tx_rate),
6779 (char*) &(aStats->tx_rate),
6780 tlen);
6781
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006782 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6783 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6784 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006785 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006786 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6787 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6788 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006789 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006790 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6791 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6792 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006793 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006794 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6795 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6796 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006797 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006798 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6799 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6800 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006801 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006802 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6803 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6804 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006805 tlen);
6806
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 wrqu->data.length = tlen;
6808
6809 }
6810
6811 EXIT();
6812
6813 return 0;
6814}
6815
6816
6817#ifdef FEATURE_WLAN_SCAN_PNO
6818
6819/*Max Len for PNO notification*/
6820#define MAX_PNO_NOTIFY_LEN 100
6821void found_pref_network_cb (void *callbackContext,
6822 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6823{
6824 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6825 union iwreq_data wrqu;
6826 char buf[MAX_PNO_NOTIFY_LEN+1];
6827
6828 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6829 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6830
6831 // create the event
6832 memset(&wrqu, 0, sizeof(wrqu));
6833 memset(buf, 0, sizeof(buf));
6834
6835 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6836 pPrefNetworkFoundInd->ssId.ssId,
6837 (unsigned int)pPrefNetworkFoundInd->rssi);
6838
6839 wrqu.data.pointer = buf;
6840 wrqu.data.length = strlen(buf);
6841
6842 // send the event
6843
6844 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6845
6846}
6847
6848
6849/*string based input*/
6850VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6851 union iwreq_data *wrqu, char *extra, int nOffset)
6852{
6853 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006854 /* pnoRequest is a large struct, so we make it static to avoid stack
6855 overflow. This API is only invoked via ioctl, so it is
6856 serialized by the kernel rtnl_lock and hence does not need to be
6857 reentrant */
6858 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 char *ptr;
6860 v_U8_t i,j, ucParams, ucMode;
6861 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6862
6863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6864 "PNO data len %d data %s",
6865 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006866 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006867
6868 if (wrqu->data.length <= nOffset )
6869 {
6870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6871 return VOS_STATUS_E_FAILURE;
6872 }
6873
6874 pnoRequest.enable = 0;
6875 pnoRequest.ucNetworksCount = 0;
6876 /*-----------------------------------------------------------------------
6877 Input is string based and expected to be like this:
6878
6879 <enabled> <netw_count>
6880 for each network:
6881 <ssid_len> <ssid> <authentication> <encryption>
6882 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6883 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6884
6885 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006886 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 -07006887
6888 this translates into:
6889 -----------------------------
6890 enable PNO
6891 look for 2 networks:
6892 test - with authentication type 0 and encryption type 0,
6893 that can be found on 3 channels: 1 6 and 11 ,
6894 SSID bcast type is unknown (directed probe will be sent if AP not found)
6895 and must meet -40dBm RSSI
6896
6897 test2 - with auth and enrytption type 4/4
6898 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6899 bcast type is non-bcast (directed probe will be sent)
6900 and must not meet any RSSI threshold
6901
Jeff Johnson8301aa12013-03-28 14:27:29 -07006902 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006904 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905
Wilson Yang623f6592013-10-08 16:33:37 -07006906 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6907 {
6908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6909 "PNO enable input is not valid %s",ptr);
6910 return VOS_STATUS_E_FAILURE;
6911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006912
6913 if ( 0 == pnoRequest.enable )
6914 {
6915 /*Disable PNO*/
6916 memset(&pnoRequest, 0, sizeof(pnoRequest));
6917 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6918 pAdapter->sessionId,
6919 found_pref_network_cb, pAdapter);
6920 return VOS_STATUS_SUCCESS;
6921 }
6922
6923 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006924
6925 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6926 {
6927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6928 "PNO count input not valid %s",ptr);
6929 return VOS_STATUS_E_FAILURE;
6930
6931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006932
6933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6934 "PNO enable %d networks count %d offset %d",
6935 pnoRequest.enable,
6936 pnoRequest.ucNetworksCount,
6937 nOffset);
6938
6939 /* Parameters checking:
6940 ucNetworksCount has to be larger than 0*/
6941 if (( 0 == pnoRequest.ucNetworksCount ) ||
6942 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6943 {
6944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6945 return VOS_STATUS_E_FAILURE;
6946 }
6947
6948 ptr += nOffset;
6949
6950 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6951 {
6952
6953 pnoRequest.aNetworks[i].ssId.length = 0;
6954
Wilson Yang623f6592013-10-08 16:33:37 -07006955 ucParams = sscanf(ptr,"%hhu %n",
6956 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6957
6958 if (1 != ucParams)
6959 {
6960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6961 "PNO ssid length input is not valid %s",ptr);
6962 return VOS_STATUS_E_FAILURE;
6963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006964
6965 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6966 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6967 {
6968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6969 "SSID Len %d is not correct for network %d",
6970 pnoRequest.aNetworks[i].ssId.length, i);
6971 return VOS_STATUS_E_FAILURE;
6972 }
6973
6974 /*Advance to SSID*/
6975 ptr += nOffset;
6976
Jeff Johnson8301aa12013-03-28 14:27:29 -07006977 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006978 pnoRequest.aNetworks[i].ssId.length);
6979 ptr += pnoRequest.aNetworks[i].ssId.length;
6980
Jeff Johnson02797792013-10-26 19:17:13 -07006981 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006982 &(pnoRequest.aNetworks[i].authentication),
6983 &(pnoRequest.aNetworks[i].encryption),
6984 &(pnoRequest.aNetworks[i].ucChannelCount),
6985 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006986
Wilson Yang623f6592013-10-08 16:33:37 -07006987 if ( 3 != ucParams )
6988 {
6989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6990 "Incorrect cmd %s",ptr);
6991 return VOS_STATUS_E_FAILURE;
6992 }
6993
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006995 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006996 "auth %d encry %d channel count %d offset %d",
6997 pnoRequest.aNetworks[i].ssId.length,
6998 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6999 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7000 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7001 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7002 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7003 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7004 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7005 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7006 pnoRequest.aNetworks[i].authentication,
7007 pnoRequest.aNetworks[i].encryption,
7008 pnoRequest.aNetworks[i].ucChannelCount,
7009 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007010
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 /*Advance to channel list*/
7012 ptr += nOffset;
7013
Wilson Yang623f6592013-10-08 16:33:37 -07007014 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 {
7016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7017 "Incorrect number of channels");
7018 return VOS_STATUS_E_FAILURE;
7019 }
7020
7021 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7022 {
7023 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7024 {
Wilson Yang623f6592013-10-08 16:33:37 -07007025 if (1 != sscanf(ptr,"%hhu %n",
7026 &(pnoRequest.aNetworks[i].aChannels[j]),
7027 &nOffset))
7028 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7029 "PNO network channel input is not valid %s",ptr);
7030 return VOS_STATUS_E_FAILURE;
7031 }
7032 /*Advance to next channel number*/
7033 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 }
7035 }
7036
Jeff Johnson02797792013-10-26 19:17:13 -07007037 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007038 &(pnoRequest.aNetworks[i].bcastNetwType),
7039 &nOffset))
7040 {
7041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7042 "PNO broadcast network type input is not valid %s",ptr);
7043 return VOS_STATUS_E_FAILURE;
7044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007045
7046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7047 "PNO bcastNetwType %d offset %d",
7048 pnoRequest.aNetworks[i].bcastNetwType,
7049 nOffset );
7050
7051 /*Advance to rssi Threshold*/
7052 ptr += nOffset;
7053
Wilson Yang623f6592013-10-08 16:33:37 -07007054 if (1 != sscanf(ptr,"%hhu %n",
7055 &(pnoRequest.aNetworks[i].rssiThreshold),
7056 &nOffset))
7057 {
7058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7059 "PNO rssi threshold input is not valid %s",ptr);
7060 return VOS_STATUS_E_FAILURE;
7061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007062
7063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7064 "PNO rssi %d offset %d",
7065 pnoRequest.aNetworks[i].rssiThreshold,
7066 nOffset );
7067 /*Advance to next network*/
7068 ptr += nOffset;
7069 }/*For ucNetworkCount*/
7070
7071 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007072 &(pnoRequest.scanTimers.ucScanTimersCount),
7073 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007074
7075 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007076 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 {
7078 ptr += nOffset;
7079
Jeff Johnson8301aa12013-03-28 14:27:29 -07007080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7081 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 pnoRequest.scanTimers.ucScanTimersCount,
7083 nOffset );
7084
7085 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7086 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007088 "Incorrect cmd - too many scan timers");
7089 return VOS_STATUS_E_FAILURE;
7090 }
7091
7092 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7093 {
Jeff Johnson02797792013-10-26 19:17:13 -07007094 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7096 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7097 &nOffset);
7098
Wilson Yang623f6592013-10-08 16:33:37 -07007099 if (2 != ucParams)
7100 {
7101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7102 "Incorrect cmd - diff params then expected %d", ucParams);
7103 return VOS_STATUS_E_FAILURE;
7104 }
7105
Jeff Johnson8301aa12013-03-28 14:27:29 -07007106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7107 "PNO Timer value %d Timer repeat %d offset %d",
7108 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7110 nOffset );
7111
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 ptr += nOffset;
7113 }
7114
7115 }
7116 else
7117 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7119 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7121
7122 /*Scan timers defaults to 5 minutes*/
7123 pnoRequest.scanTimers.ucScanTimersCount = 1;
7124 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7125 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7126 }
7127
Wilson Yang623f6592013-10-08 16:33:37 -07007128 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007129
7130 pnoRequest.modePNO = ucMode;
7131 /*for LA we just expose suspend option*/
7132 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7133 {
7134 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7135 }
7136
7137 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
7138 pAdapter->sessionId,
7139 found_pref_network_cb, pAdapter);
7140
7141 return VOS_STATUS_SUCCESS;
7142}/*iw_set_pno*/
7143
7144VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7145 union iwreq_data *wrqu, char *extra, int nOffset)
7146{
7147 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7148 v_U8_t rssiThreshold = 0;
7149 v_U8_t nRead;
7150
Arif Hussain7adce1b2013-11-11 22:59:34 -08007151 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007152 &rssiThreshold);
7153
7154 if ( 1 != nRead )
7155 {
7156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7157 "Incorrect format");
7158 return VOS_STATUS_E_FAILURE;
7159 }
7160
7161 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7162 return VOS_STATUS_SUCCESS;
7163}
7164
7165
7166static int iw_set_pno_priv(struct net_device *dev,
7167 struct iw_request_info *info,
7168 union iwreq_data *wrqu, char *extra)
7169{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007170 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7171
7172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007174
7175 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7176 {
7177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7178 "%s:LOGP in Progress. Ignore!!!", __func__);
7179 return -EBUSY;
7180 }
7181 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007182}
7183#endif /*FEATURE_WLAN_SCAN_PNO*/
7184
7185//Common function to SetBand
7186int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
7187{
7188 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7189 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7190 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7191 tANI_U8 band = 0;
7192 eCsrBand currBand = eCSR_BAND_MAX;
7193
7194 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
7195
7196 switch(band)
7197 {
7198 case WLAN_HDD_UI_BAND_AUTO:
7199 band = eCSR_BAND_ALL;
7200 break;
7201 case WLAN_HDD_UI_BAND_5_GHZ:
7202 band = eCSR_BAND_5G;
7203 break;
7204 case WLAN_HDD_UI_BAND_2_4_GHZ:
7205 band = eCSR_BAND_24;
7206 break;
7207 default:
7208 band = eCSR_BAND_MAX;
7209 }
7210
7211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007212 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007213
7214 if (band == eCSR_BAND_MAX)
7215 {
7216 /* Received change band request with invalid band value */
7217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007218 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 return -EIO;
7220 }
7221
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307222 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7223 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7224 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7225 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007227 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007228 band, pHddCtx->cfg_ini->nBandCapability);
7229 return -EIO;
7230 }
7231
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7233 {
7234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7235 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007236 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 return -EIO;
7238 }
7239
7240 if (currBand != band)
7241 {
7242 /* Change band request received.
7243 * Abort pending scan requests, flush the existing scan results,
7244 * and change the band capability
7245 */
7246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7247 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007248 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007249
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307250 /* We need to change the band and flush the scan results here itself
7251 * as we may get timeout for disconnection in which we will return
7252 * with out doing any of these
7253 */
7254 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7255 {
7256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7257 "%s: failed to set the band value to %u ",
7258 __func__, band);
7259 return -EINVAL;
7260 }
7261 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7262 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7263 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7264 sme_FilterScanResults(hHal, pAdapter->sessionId);
7265
7266 if (band != eCSR_BAND_ALL &&
7267 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 {
7269 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7270 eHalStatus status = eHAL_STATUS_SUCCESS;
7271 long lrc;
7272
7273 /* STA already connected on current band, So issue disconnect first,
7274 * then change the band*/
7275
7276 hddLog(VOS_TRACE_LEVEL_INFO,
7277 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7278 __func__, csrGetCurrentBand(hHal), band);
7279
7280 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7281 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7282
7283 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7284 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7285
Jeff Johnson43971f52012-07-17 12:26:56 -07007286 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 {
7288 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007289 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 __func__, (int)status );
7291 return -EINVAL;
7292 }
7293
7294 lrc = wait_for_completion_interruptible_timeout(
7295 &pAdapter->disconnect_comp_var,
7296 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7297
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307298 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007299
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007300 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007301 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007302
7303 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7304 }
7305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007306 }
7307 return 0;
7308}
7309
7310static int iw_set_band_config(struct net_device *dev,
7311 struct iw_request_info *info,
7312 union iwreq_data *wrqu, char *extra)
7313{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007314 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007315 tANI_U8 *ptr = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007316 int ret = 0;
7317
Arif Hussain0273cba2014-01-07 20:58:29 -08007318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007319
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007320 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7321 {
7322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7323 "%s:LOGP in Progress. Ignore!!!", __func__);
7324 return -EBUSY;
7325 }
7326
Arif Hussain0273cba2014-01-07 20:58:29 -08007327 /* ODD number is used for set, copy data using copy_from_user */
7328 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7329 wrqu->data.length);
7330 if (NULL == ptr)
7331 {
7332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7333 "mem_alloc_copy_from_user_helper fail");
7334 return -ENOMEM;
7335 }
7336
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 if (memcmp(ptr, "SETBAND ", 8) == 0)
7338 {
7339 /* Change band request received */
7340 ret = hdd_setBand_helper(dev, ptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 }
Arif Hussain0273cba2014-01-07 20:58:29 -08007342 kfree(ptr);
7343
7344 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007345}
7346
7347static int iw_set_power_params_priv(struct net_device *dev,
7348 struct iw_request_info *info,
7349 union iwreq_data *wrqu, char *extra)
7350{
Arif Hussain0273cba2014-01-07 20:58:29 -08007351 int ret;
7352 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7354 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007355 /* ODD number is used for set, copy data using copy_from_user */
7356 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7357 wrqu->data.length);
7358 if (NULL == ptr)
7359 {
7360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7361 "mem_alloc_copy_from_user_helper fail");
7362 return -ENOMEM;
7363 }
7364
7365 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7366 kfree(ptr);
7367 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007368}
7369
7370
7371
7372/*string based input*/
7373VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7374 union iwreq_data *wrqu, char *extra, int nOffset)
7375{
7376 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7377 tSirSetPowerParamsReq powerRequest;
7378 char *ptr;
7379 v_U8_t ucType;
7380 v_U32_t uTotalSize, uValue;
7381 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7382
7383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7384 "Power Params data len %d data %s",
7385 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007386 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007387
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007388 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7389 {
7390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7391 "%s:LOGP in Progress. Ignore!!!", __func__);
7392 return -EBUSY;
7393 }
7394
Jeff Johnson295189b2012-06-20 16:38:30 -07007395 if (wrqu->data.length <= nOffset )
7396 {
7397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7398 return VOS_STATUS_E_FAILURE;
7399 }
7400
7401 uTotalSize = wrqu->data.length - nOffset;
7402
7403 /*-----------------------------------------------------------------------
7404 Input is string based and expected to be like this:
7405
7406 <param_type> <param_value> <param_type> <param_value> ...
7407
7408 e.g:
7409 1 2 2 3 3 0 4 1 5 1
7410
7411 e.g. setting just a few:
7412 1 2 4 1
7413
7414 parameter types:
7415 -----------------------------
7416 1 - Ignore DTIM
7417 2 - Listen Interval
7418 3 - Broadcast Multicas Filter
7419 4 - Beacon Early Termination
7420 5 - Beacon Early Termination Interval
7421 -----------------------------------------------------------------------*/
7422 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7423 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7424 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7425 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7426 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7427
Arif Hussain7adce1b2013-11-11 22:59:34 -08007428 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007429
7430 while ( uTotalSize )
7431 {
Wilson Yang6f971452013-10-08 15:00:00 -07007432 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7433 {
7434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7435 "Invalid input parameter type %s",ptr);
7436 return VOS_STATUS_E_FAILURE;
7437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007438
7439 uTotalSize -= nOffset;
7440
7441 if (!uTotalSize)
7442 {
7443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007444 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 ucType, nOffset);
7446 return VOS_STATUS_E_FAILURE;
7447 }
7448
7449 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007450
Jeff Johnson02797792013-10-26 19:17:13 -07007451 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007452 {
7453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7454 "Invalid input parameter value %s",ptr);
7455 return VOS_STATUS_E_FAILURE;
7456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007457
7458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7459 "Power request parameter %d value %d offset %d",
7460 ucType, uValue, nOffset);
7461
7462 switch (ucType)
7463 {
7464 case eSIR_IGNORE_DTIM:
7465 powerRequest.uIgnoreDTIM = uValue;
7466 break;
7467 case eSIR_LISTEN_INTERVAL:
7468 powerRequest.uListenInterval = uValue;
7469 break;
7470 case eSIR_MCAST_BCAST_FILTER:
7471 powerRequest.uBcastMcastFilter = uValue;
7472 break;
7473 case eSIR_ENABLE_BET:
7474 powerRequest.uEnableBET = uValue;
7475 break;
7476 case eSIR_BET_INTERVAL:
7477 powerRequest.uBETInterval = uValue;
7478 break;
7479 default:
7480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007481 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 ucType, uValue, nOffset);
7483 return VOS_STATUS_E_FAILURE;
7484 }
7485
7486 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7488 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007489 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007491 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007492 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007493 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7494 {
7495 uTotalSize = 0;
7496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007497
7498 }/*Go for as long as we have a valid string*/
7499
7500 /* put the device into full power*/
7501 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7502
7503 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007504 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007505
7506 /* put the device back to power save*/
7507 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7508
7509 return VOS_STATUS_SUCCESS;
7510}/*iw_set_power_params*/
7511
7512
7513// Define the Wireless Extensions to the Linux Network Device structure
7514// A number of these routines are NULL (meaning they are not implemented.)
7515
7516static const iw_handler we_handler[] =
7517{
7518 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7519 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7520 (iw_handler) NULL, /* SIOCSIWNWID */
7521 (iw_handler) NULL, /* SIOCGIWNWID */
7522 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7523 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7524 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7525 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7526 (iw_handler) NULL, /* SIOCSIWSENS */
7527 (iw_handler) NULL, /* SIOCGIWSENS */
7528 (iw_handler) NULL, /* SIOCSIWRANGE */
7529 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7530 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7531 (iw_handler) NULL, /* SIOCGIWPRIV */
7532 (iw_handler) NULL, /* SIOCSIWSTATS */
7533 (iw_handler) NULL, /* SIOCGIWSTATS */
7534 iw_handler_set_spy, /* SIOCSIWSPY */
7535 iw_handler_get_spy, /* SIOCGIWSPY */
7536 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7537 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7538 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7539 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7540 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7541 (iw_handler) NULL, /* SIOCGIWAPLIST */
7542 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7543 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7544 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7545 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7546 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7547 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7548 (iw_handler) NULL, /* -- hole -- */
7549 (iw_handler) NULL, /* -- hole -- */
7550 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7551 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7552 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7553 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7554 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7555 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7556 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7557 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7558 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7559 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7560 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7561 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7562 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7563 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7564 (iw_handler) NULL, /* -- hole -- */
7565 (iw_handler) NULL, /* -- hole -- */
7566 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7567 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7568 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7569 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7570 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7571 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7572 (iw_handler) NULL, /* SIOCSIWPMKSA */
7573};
7574
7575static const iw_handler we_private[] = {
7576
7577 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7578 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7579 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7580 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7581 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7582 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7583 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7584 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7585 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7586 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007587#ifdef FEATURE_OEM_DATA_SUPPORT
7588 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7589 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7590#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007591
7592#ifdef FEATURE_WLAN_WAPI
7593 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7594 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7595 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7596 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7597 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7598 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7599#endif /* FEATURE_WLAN_WAPI */
7600#ifdef WLAN_FEATURE_VOWIFI_11R
7601 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7602#endif
7603 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7604 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7605 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7606#ifdef WLAN_FEATURE_PACKET_FILTERING
7607 ,
7608 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7609#endif
7610#ifdef FEATURE_WLAN_SCAN_PNO
7611 ,
7612 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7613#endif
7614 ,
7615 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7616 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7617 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7618 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007619 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007620};
7621
7622/*Maximum command length can be only 15 */
7623static const struct iw_priv_args we_private_args[] = {
7624
7625 /* handlers for main ioctl */
7626 { WLAN_PRIV_SET_INT_GET_NONE,
7627 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7628 0,
7629 "" },
7630
7631 /* handlers for sub-ioctl */
7632 { WE_SET_11D_STATE,
7633 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7634 0,
7635 "set11Dstate" },
7636
7637 { WE_WOWL,
7638 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7639 0,
7640 "wowl" },
7641
7642 { WE_SET_POWER,
7643 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7644 0,
7645 "setPower" },
7646
7647 { WE_SET_MAX_ASSOC,
7648 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7649 0,
7650 "setMaxAssoc" },
7651
7652 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7653 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7654 0,
7655 "setAutoChannel" },
7656
7657 { WE_SET_DATA_INACTIVITY_TO,
7658 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7659 0,
7660 "inactivityTO" },
7661
7662 { WE_SET_MAX_TX_POWER,
7663 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7664 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007665 "setMaxTxPower" },
7666
7667 { WE_SET_MAX_TX_POWER_2_4,
7668 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7669 0,
7670 "setTxMaxPower2G" },
7671
7672 { WE_SET_MAX_TX_POWER_5_0,
7673 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7674 0,
7675 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007676
7677 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7678 * as well to keep same syntax as in SAP. Now onwards, STA
7679 * will support both */
7680 { WE_SET_MAX_TX_POWER,
7681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7682 0,
7683 "setTxMaxPower" },
7684
Jeff Johnson295189b2012-06-20 16:38:30 -07007685 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7686 * 1 = enable and 0 = disable */
7687 {
7688 WE_SET_HIGHER_DTIM_TRANSITION,
7689 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7690 0,
7691 "setHDtimTransn" },
7692
7693 { WE_SET_TM_LEVEL,
7694 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007695 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 "setTmLevel" },
7697
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307698 { WE_ENABLE_STRICT_FCC_REG,
7699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7700 0,
7701 "setStrictFCCreg" },
7702
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007703 { WE_SET_DEBUG_LOG,
7704 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7705 0, "setDbgLvl" },
7706
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 /* handlers for main ioctl */
7708 { WLAN_PRIV_SET_NONE_GET_INT,
7709 0,
7710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7711 "" },
7712
7713 /* handlers for sub-ioctl */
7714 { WE_GET_11D_STATE,
7715 0,
7716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7717 "get11Dstate" },
7718
7719 { WE_IBSS_STATUS,
7720 0,
7721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7722 "getAdhocStatus" },
7723
7724 { WE_PMC_STATE,
7725 0,
7726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7727 "pmcState" },
7728
7729 { WE_GET_WLAN_DBG,
7730 0,
7731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7732 "getwlandbg" },
7733
7734 { WE_MODULE_DOWN_IND,
7735 0,
7736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7737 "moduleDownInd" },
7738
7739 { WE_GET_MAX_ASSOC,
7740 0,
7741 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7742 "getMaxAssoc" },
7743
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 { WE_GET_WDI_DBG,
7745 0,
7746 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7747 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007748
7749 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7750 0,
7751 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7752 "getAutoChannel" },
7753
7754 { WE_GET_CONCURRENCY_MODE,
7755 0,
7756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7757 "getconcurrency" },
7758
7759 /* handlers for main ioctl */
7760 { WLAN_PRIV_SET_CHAR_GET_NONE,
7761 IW_PRIV_TYPE_CHAR| 512,
7762 0,
7763 "" },
7764
7765 /* handlers for sub-ioctl */
7766 { WE_WOWL_ADD_PTRN,
7767 IW_PRIV_TYPE_CHAR| 512,
7768 0,
7769 "wowlAddPtrn" },
7770
7771 { WE_WOWL_DEL_PTRN,
7772 IW_PRIV_TYPE_CHAR| 512,
7773 0,
7774 "wowlDelPtrn" },
7775
7776#if defined WLAN_FEATURE_VOWIFI
7777 /* handlers for sub-ioctl */
7778 { WE_NEIGHBOR_REPORT_REQUEST,
7779 IW_PRIV_TYPE_CHAR | 512,
7780 0,
7781 "neighbor" },
7782#endif
7783 { WE_SET_AP_WPS_IE,
7784 IW_PRIV_TYPE_CHAR| 512,
7785 0,
7786 "set_ap_wps_ie" },
7787
7788 { WE_SET_CONFIG,
7789 IW_PRIV_TYPE_CHAR| 512,
7790 0,
7791 "setConfig" },
7792
7793 /* handlers for main ioctl */
7794 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7796 0,
7797 "" },
7798
7799 /* handlers for sub-ioctl */
7800 { WE_SET_WLAN_DBG,
7801 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7802 0,
7803 "setwlandbg" },
7804
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 { WE_SET_WDI_DBG,
7806 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7807 0,
7808 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007809
7810 { WE_SET_SAP_CHANNELS,
7811 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7812 0,
7813 "setsapchannels" },
7814
7815 /* handlers for main ioctl */
7816 { WLAN_PRIV_GET_CHAR_SET_NONE,
7817 0,
7818 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7819 "" },
7820
7821 /* handlers for sub-ioctl */
7822 { WE_WLAN_VERSION,
7823 0,
7824 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7825 "version" },
7826 { WE_GET_STATS,
7827 0,
7828 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7829 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307830 { WE_GET_STATES,
7831 0,
7832 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7833 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 { WE_GET_CFG,
7835 0,
7836 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7837 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007838#ifdef WLAN_FEATURE_11AC
7839 { WE_GET_RSSI,
7840 0,
7841 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7842 "getRSSI" },
7843#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007844#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007845 { WE_GET_ROAM_RSSI,
7846 0,
7847 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7848 "getRoamRSSI" },
7849#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 { WE_GET_WMM_STATUS,
7851 0,
7852 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7853 "getWmmStatus" },
7854 {
7855 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307856 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7858 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007859#ifdef FEATURE_WLAN_TDLS
7860 {
7861 WE_GET_TDLS_PEERS,
7862 0,
7863 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7864 "getTdlsPeers" },
7865#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007866#ifdef WLAN_FEATURE_11W
7867 {
7868 WE_GET_11W_INFO,
7869 0,
7870 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7871 "getPMFInfo" },
7872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 /* handlers for main ioctl */
7874 { WLAN_PRIV_SET_NONE_GET_NONE,
7875 0,
7876 0,
7877 "" },
7878
7879 /* handlers for sub-ioctl */
7880 { WE_CLEAR_STATS,
7881 0,
7882 0,
7883 "clearStats" },
7884 { WE_INIT_AP,
7885 0,
7886 0,
7887 "initAP" },
7888 { WE_STOP_AP,
7889 0,
7890 0,
7891 "exitAP" },
7892 { WE_ENABLE_AMP,
7893 0,
7894 0,
7895 "enableAMP" },
7896 { WE_DISABLE_AMP,
7897 0,
7898 0,
7899 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007900 { WE_ENABLE_DXE_STALL_DETECT,
7901 0,
7902 0,
7903 "dxeStallDetect" },
7904 { WE_DISPLAY_DXE_SNAP_SHOT,
7905 0,
7906 0,
7907 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307908 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7909 0,
7910 0,
7911 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007912 {
7913 WE_SET_REASSOC_TRIGGER,
7914 0,
7915 0,
7916 "reassoc" },
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307917 {
7918 WE_STOP_OBSS_SCAN,
7919 0,
7920 0,
7921 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007922
7923 /* handlers for main ioctl */
7924 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7925 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7926 0,
7927 "" },
7928
7929 /* handlers for sub-ioctl */
7930 { WE_LOG_DUMP_CMD,
7931 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7932 0,
7933 "dump" },
7934
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007935 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307936 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
7937 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7938 0,
7939 "setdumplog" },
7940
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007941 { WE_MTRACE_DUMP_CMD,
7942 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7943 0,
7944 "dumplog" },
7945
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007946 /* handlers for sub ioctl */
7947 {
7948 WE_MCC_CONFIG_CREDENTIAL,
7949 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7950 0,
7951 "setMccCrdnl" },
7952
7953 /* handlers for sub ioctl */
7954 {
7955 WE_MCC_CONFIG_PARAMS,
7956 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7957 0,
7958 "setMccConfig" },
7959
Chilam NG571c65a2013-01-19 12:27:36 +05307960#ifdef FEATURE_WLAN_TDLS
7961 /* handlers for sub ioctl */
7962 {
7963 WE_TDLS_CONFIG_PARAMS,
7964 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7965 0,
7966 "setTdlsConfig" },
7967#endif
7968
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 /* handlers for main ioctl */
7970 { WLAN_PRIV_ADD_TSPEC,
7971 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7972 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7973 "addTspec" },
7974
7975 /* handlers for main ioctl */
7976 { WLAN_PRIV_DEL_TSPEC,
7977 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7978 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7979 "delTspec" },
7980
7981 /* handlers for main ioctl */
7982 { WLAN_PRIV_GET_TSPEC,
7983 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7985 "getTspec" },
7986
Jeff Johnsone7245742012-09-05 17:12:55 -07007987#ifdef FEATURE_OEM_DATA_SUPPORT
7988 /* handlers for main ioctl - OEM DATA */
7989 {
7990 WLAN_PRIV_SET_OEM_DATA_REQ,
7991 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7992 0,
7993 "set_oem_data_req" },
7994
7995 /* handlers for main ioctl - OEM DATA */
7996 {
7997 WLAN_PRIV_GET_OEM_DATA_RSP,
7998 0,
7999 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8000 "get_oem_data_rsp" },
8001#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008002
8003#ifdef FEATURE_WLAN_WAPI
8004 /* handlers for main ioctl SET_WAPI_MODE */
8005 { WLAN_PRIV_SET_WAPI_MODE,
8006 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8007 0,
8008 "SET_WAPI_MODE" },
8009
8010 /* handlers for main ioctl GET_WAPI_MODE */
8011 { WLAN_PRIV_GET_WAPI_MODE,
8012 0,
8013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8014 "GET_WAPI_MODE" },
8015
8016 /* handlers for main ioctl SET_ASSOC_INFO */
8017 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
8018 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
8019 0,
8020 "SET_WAPI_ASSOC" },
8021
8022 /* handlers for main ioctl SET_WAPI_KEY */
8023 { WLAN_PRIV_SET_WAPI_KEY,
8024 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8025 0,
8026 "SET_WAPI_KEY" },
8027
8028 /* handlers for main ioctl SET_WAPI_BKID */
8029 { WLAN_PRIV_SET_WAPI_BKID,
8030 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8031 0,
8032 "SET_WAPI_BKID" },
8033
8034 /* handlers for main ioctl GET_WAPI_BKID */
8035 { WLAN_PRIV_GET_WAPI_BKID,
8036 0,
8037 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8038 "GET_WAPI_BKID" },
8039#endif /* FEATURE_WLAN_WAPI */
8040
8041 /* handlers for main ioctl - host offload */
8042 {
8043 WLAN_PRIV_SET_HOST_OFFLOAD,
8044 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8045 0,
8046 "setHostOffload" },
8047
8048 {
8049 WLAN_GET_WLAN_STATISTICS,
8050 0,
8051 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8052 "getWlanStats" },
8053
8054 {
8055 WLAN_SET_KEEPALIVE_PARAMS,
8056 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8057 0,
8058 "setKeepAlive" },
8059#ifdef WLAN_FEATURE_PACKET_FILTERING
8060 {
8061 WLAN_SET_PACKET_FILTER_PARAMS,
8062 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8063 0,
8064 "setPktFilter" },
8065#endif
8066#ifdef FEATURE_WLAN_SCAN_PNO
8067 {
8068 WLAN_SET_PNO,
8069 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8070 0,
8071 "setpno" },
8072#endif
8073 {
8074 WLAN_SET_BAND_CONFIG,
8075 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8076 0,
8077 "SETBAND" },
8078 /* handlers for dynamic MC BC ioctl */
8079 {
8080 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008081 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 0,
8083 "setMCBCFilter" },
8084 {
8085 WLAN_PRIV_CLEAR_MCBC_FILTER,
8086 0,
8087 0,
8088 "clearMCBCFilter" },
8089 {
8090 WLAN_SET_POWER_PARAMS,
8091 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8092 0,
8093 "setpowerparams" },
8094 {
8095 WLAN_GET_LINK_SPEED,
8096 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308097 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008098};
8099
8100
8101
8102const struct iw_handler_def we_handler_def = {
8103 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8104 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8105 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8106
8107 .standard = (iw_handler *)we_handler,
8108 .private = (iw_handler *)we_private,
8109 .private_args = we_private_args,
8110 .get_wireless_stats = get_wireless_stats,
8111};
8112
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008113int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8114{
8115 v_U32_t cmd = 288; //Command to RIVA
8116 hdd_context_t *pHddCtx = NULL;
8117 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8118 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8119 /*
8120 *configMccParam : specify the bit which needs to be modified
8121 *allowed to update based on wlan_qcom_cfg.ini
8122 * configuration
8123 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8124 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8125 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8126 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8127 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8128 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8129 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8130 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8131 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8132 * Bit 9 : Reserved
8133 */
8134 switch (arg1)
8135 {
8136 //Update MCC SCHEDULE_TIME_SLICE parameter
8137 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8138 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8139 {
8140 if((arg2 >= 5) && (arg2 <= 20))
8141 {
8142 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8143 }
8144 else
8145 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008146 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008147 return 0;
8148 }
8149 }
8150 break;
8151
8152 //Update MCC MAX_NULL_SEND_TIME parameter
8153 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8154 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8155 {
8156 if((arg2 >= 1) && (arg2 <= 10))
8157 {
8158 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8159 }
8160 else
8161 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008162 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008163 return 0;
8164 }
8165 }
8166 break;
8167
8168 //Update MCC TX_EARLY_STOP_TIME parameter
8169 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8170 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8171 {
8172 if((arg2 >= 1) && (arg2 <= 10))
8173 {
8174 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8175 }
8176 else
8177 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008178 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008179 return 0;
8180 }
8181 }
8182 break;
8183
8184 //Update MCC RX_DRAIN_TIME parameter
8185 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8186 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8187 {
8188 if((arg2 >= 1) && (arg2 <= 10))
8189 {
8190 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8191 }
8192 else
8193 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008194 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008195 return 0;
8196 }
8197 }
8198 break;
8199
8200 //Update MCC CHANNEL_SWITCH_TIME parameter
8201 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8202 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8203 {
8204 if((arg2 >= 1) && (arg2 <= 20))
8205 {
8206 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8207 }
8208 else
8209 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008210 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008211 return 0;
8212 }
8213 }
8214 break;
8215
8216 //Update MCC MIN_CHANNEL_TIME parameter
8217 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8218 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8219 {
8220 if((arg2 >= 5) && (arg2 <= 20))
8221 {
8222 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8223 }
8224 else
8225 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008226 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008227 return 0;
8228 }
8229 }
8230 break;
8231
8232 //Update MCC PARK_BEFORE_TBTT parameter
8233 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8234 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8235 {
8236 if((arg2 >= 1) && (arg2 <= 5))
8237 {
8238 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8239 }
8240 else
8241 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008242 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008243 return 0;
8244 }
8245 }
8246 break;
8247
8248 //Update MCC MIN_AFTER_DTIM parameter
8249 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8250 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8251 {
8252 if((arg2 >= 5) && (arg2 <= 15))
8253 {
8254 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8255 }
8256 else
8257 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008258 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008259 return 0;
8260 }
8261 }
8262 break;
8263
8264 //Update MCC TOO_CLOSE_MARGIN parameter
8265 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8266 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8267 {
8268 if((arg2 >= 1) && (arg2 <= 3))
8269 {
8270 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8271 }
8272 else
8273 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008274 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008275 return 0;
8276 }
8277 }
8278 break;
8279
8280 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008281 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008282 __FUNCTION__,arg1);
8283 break;
8284 }
8285 return 0;
8286}
8287
Jeff Johnson295189b2012-06-20 16:38:30 -07008288int hdd_set_wext(hdd_adapter_t *pAdapter)
8289{
8290 hdd_wext_state_t *pwextBuf;
8291 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008292 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008293
8294 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8295
8296 // Now configure the roaming profile links. To SSID and bssid.
8297 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8298 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8299
8300 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8301 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8302
8303 /*Set the numOfChannels to zero to scan all the channels*/
8304 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8305 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8306
8307 /* Default is no encryption */
8308 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8309 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8310
8311 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8312 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8313
8314 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8315
8316 /* Default is no authentication */
8317 pwextBuf->roamProfile.AuthType.numEntries = 1;
8318 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8319
8320 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8321 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8322
8323 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008324 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008325
8326 hdd_clearRoamProfileIe(pAdapter);
8327
8328 return VOS_STATUS_SUCCESS;
8329
8330 }
8331
8332int hdd_register_wext(struct net_device *dev)
8333 {
8334 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8335 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8336 VOS_STATUS status;
8337
8338 ENTER();
8339
8340 // Zero the memory. This zeros the profile structure.
8341 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8342
8343 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8344
8345
8346 status = hdd_set_wext(pAdapter);
8347
8348 if(!VOS_IS_STATUS_SUCCESS(status)) {
8349
Arif Hussain6d2a3322013-11-17 19:50:10 -08008350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008351 return eHAL_STATUS_FAILURE;
8352 }
8353
8354 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8355 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 return eHAL_STATUS_FAILURE;
8358 }
8359
8360 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8361 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008363 return eHAL_STATUS_FAILURE;
8364 }
8365
8366 // Register as a wireless device
8367 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8368
8369 EXIT();
8370 return 0;
8371}
8372
8373int hdd_UnregisterWext(struct net_device *dev)
8374{
8375#if 0
8376 hdd_wext_state_t *wextBuf;
8377 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8378
8379 ENTER();
8380 // Set up the pointer to the Wireless Extensions state structure
8381 wextBuf = pAdapter->pWextState;
8382
8383 // De-allocate the Wireless Extensions state structure
8384 kfree(wextBuf);
8385
8386 // Clear out the pointer to the Wireless Extensions state structure
8387 pAdapter->pWextState = NULL;
8388
8389 EXIT();
8390#endif
8391 dev->wireless_handlers = NULL;
8392 return 0;
8393}
8394
8395