blob: 33f9465dd3258a9fa7b3e4af3df3a71b38695eba [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
Arif Hussain695279c2014-03-24 14:06:07 -07002699/*
2700 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2701 *
2702 */
2703static int iw_get_linkspeed_priv(struct net_device *dev,
2704 struct iw_request_info *info,
2705 union iwreq_data *wrqu, char *extra)
2706{
2707 int rc;
2708
2709 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2710
2711 if (rc < 0)
2712 return rc;
2713
2714 /* a value is being successfully returned */
2715 return 0;
2716}
Jeff Johnson295189b2012-06-20 16:38:30 -07002717
2718/*
2719 * Support for the RSSI & RSSI-APPROX private commands
2720 * Per the WiFi framework the response must be of the form
2721 * "<ssid> rssi <xx>"
2722 * unless we are not associated, in which case the response is
2723 * "OK"
2724 */
2725static int iw_get_rssi(struct net_device *dev,
2726 struct iw_request_info *info,
2727 union iwreq_data *wrqu, char *extra)
2728{
2729 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002730 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 int len = wrqu->data.length;
2732 v_S7_t s7Rssi = 0;
2733 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2734 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2735 VOS_STATUS vosStatus;
2736 int rc;
2737
2738 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2739 (0 == ssidlen) || (ssidlen >= len))
2740 {
2741 /* we are not connected or our SSID is too long
2742 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002743 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 }
2745 else
2746 {
2747 /* we are connected with a valid SSID
2748 so we can write the SSID into the return buffer
2749 (note that it is not NUL-terminated) */
2750 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2751
2752 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2753
2754 if (VOS_STATUS_SUCCESS == vosStatus)
2755 {
2756 /* append the rssi to the ssid in the format required by
2757 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002758 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302759 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 }
2761 else
2762 {
2763 rc = -1;
2764 }
2765 }
2766
2767 /* verify that we wrote a valid response */
2768 if ((rc < 0) || (rc >= len))
2769 {
2770 // encoding or length error?
2771 hddLog(VOS_TRACE_LEVEL_ERROR,
2772 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002773 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 return -EIO;
2775 }
2776
2777 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002778 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002779}
2780
2781/*
2782 * Support for SoftAP channel range private command
2783 */
2784static int iw_softap_set_channel_range( struct net_device *dev,
2785 int startChannel,
2786 int endChannel,
2787 int band)
2788{
Jeff Johnson43971f52012-07-17 12:26:56 -07002789 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 int ret = 0;
2791 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2792 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002793 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2794
Jeff Johnson295189b2012-06-20 16:38:30 -07002795
2796 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2797 if (VOS_STATUS_SUCCESS != status)
2798 {
2799 ret = -EINVAL;
2800 }
Yathish9f22e662012-12-10 14:21:35 -08002801 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 return ret;
2803}
2804
2805VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2806{
2807 struct statsContext context;
2808 eHalStatus status;
2809 hdd_context_t *pHddCtx;
2810
2811 if (NULL == pAdapter)
2812 {
2813 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2814 return VOS_STATUS_E_FAULT;
2815 }
2816
2817 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2818 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2819 init_completion(&context.completion);
2820
2821 context.pAdapter = pAdapter;
2822 context.magic = POWER_CONTEXT_MAGIC;
2823
2824 if (DRIVER_POWER_MODE_ACTIVE == mode)
2825 {
2826 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2827 "Full Power", __func__);
2828 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2829 iw_power_callback_fn, &context,
2830 eSME_FULL_PWR_NEEDED_BY_HDD);
2831 // Enter Full power command received from GUI this means we are disconnected
2832 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2833 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2834 if (eHAL_STATUS_PMC_PENDING == status)
2835 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002836 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 int lrc = wait_for_completion_interruptible_timeout(
2838 &context.completion,
2839 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002840
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 if (lrc <= 0)
2842 {
2843 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002844 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 }
2846 }
2847 }
2848 else if (DRIVER_POWER_MODE_AUTO == mode)
2849 {
2850 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2851 {
2852 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2853 __func__);
2854 // Enter BMPS command received from GUI this means DHCP is completed
2855 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2856 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2857 FALSE);
2858 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2859 iw_power_callback_fn, &context);
2860 if (eHAL_STATUS_PMC_PENDING == status)
2861 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002862 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 int lrc = wait_for_completion_interruptible_timeout(
2864 &context.completion,
2865 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 if (lrc <= 0)
2867 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002868 hddLog(VOS_TRACE_LEVEL_ERROR,
2869 "%s: SME %s while requesting BMPS",
2870 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 }
2872 }
2873 }
2874 else
2875 {
2876 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2877 "enabled in the cfg");
2878 }
2879 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002880
2881 /* either we never sent a request, we sent a request and received a
2882 response or we sent a request and timed out. if we never sent a
2883 request or if we sent a request and got a response, we want to
2884 clear the magic out of paranoia. if we timed out there is a
2885 race condition such that the callback function could be
2886 executing at the same time we are. of primary concern is if the
2887 callback function had already verified the "magic" but had not
2888 yet set the completion variable when a timeout occurred. we
2889 serialize these activities by invalidating the magic while
2890 holding a shared spinlock which will cause us to block if the
2891 callback is currently executing */
2892 spin_lock(&hdd_context_lock);
2893 context.magic = 0;
2894 spin_unlock(&hdd_context_lock);
2895
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 return VOS_STATUS_SUCCESS;
2897}
2898
2899VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2900 hdd_adapter_t *pAdapter)
2901{
2902 VOS_STATUS vos_Status;
2903
2904 if ((NULL == pAdapter) || (NULL == pHddCtx))
2905 {
2906 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2907 return VOS_STATUS_E_FAULT;
2908 }
2909
2910 /**Exit from Deep sleep or standby if we get the driver
2911 START cmd from android GUI
2912 */
2913 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2914 {
2915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2916 "from Stand by",__func__);
2917 vos_Status = hdd_exit_standby(pHddCtx);
2918 }
2919 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2920 {
2921 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2922 "from deep sleep",__func__);
2923 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2924 }
2925 else
2926 {
2927 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2928 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2929 vos_Status = VOS_STATUS_SUCCESS;
2930 }
2931
2932 return vos_Status;
2933}
2934
2935VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2936{
2937 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2938
2939 if (NULL == pHddCtx)
2940 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302941 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 return VOS_STATUS_E_FAULT;
2943 }
2944
2945 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2946 {
2947 //Execute standby procedure.
2948 //Executing standby procedure will cause the STA to
2949 //disassociate first and then the chip will be put into standby.
2950 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2951 vos_Status = hdd_enter_standby(pHddCtx);
2952 }
2953 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2954 pHddCtx->cfg_ini->nEnableDriverStop)
2955 {
2956 //Execute deep sleep procedure
2957 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002958 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 //Deep sleep not supported
2960 vos_Status = hdd_enter_standby(pHddCtx);
2961 }
2962 else
2963 {
2964 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2965 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2966 vos_Status = VOS_STATUS_SUCCESS;
2967 }
2968
2969 return vos_Status;
2970}
2971
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002972
2973void* wlan_hdd_change_country_code_callback(void *pAdapter)
2974{
2975
2976 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002977 complete(&call_back_pAdapter->change_country_code);
2978
2979 return NULL;
2980}
2981
Jeff Johnson295189b2012-06-20 16:38:30 -07002982static int iw_set_priv(struct net_device *dev,
2983 struct iw_request_info *info,
2984 union iwreq_data *wrqu, char *extra)
2985{
2986 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08002987 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 int cmd_len = wrqu->data.length;
2989 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08002990 int rc = 0;
2991 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2992
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2994
2995 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08002996 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2997 wrqu->data.length);
2998 if (NULL == cmd)
2999 {
3000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3001 "mem_alloc_copy_from_user_helper fail");
3002 return -ENOMEM;
3003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003004
3005 if (ioctl_debug)
3006 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003007 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 }
3009
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003010 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3011 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003012
3013 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003014 if (ioctl_debug)
3015 {
3016 pr_info("%s: RESTART in progress\n", __func__);
3017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003018
Arif Hussain24bfa702014-01-22 13:51:30 -08003019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003021 kfree(cmd);
3022 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 }
3024
Arif Hussain24bfa702014-01-22 13:51:30 -08003025 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003027 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3029 "%s: Error in iw_set_scan!", __func__);
3030 rc = -EINVAL;
3031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 }
3033 else if( strcasecmp(cmd, "start") == 0 ) {
3034
Arif Hussain6d2a3322013-11-17 19:50:10 -08003035 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003037
Arif Hussain24bfa702014-01-22 13:51:30 -08003038 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3039 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 {
3041 union iwreq_data wrqu;
3042 char buf[10];
3043
3044 memset(&wrqu, 0, sizeof(wrqu));
3045 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3046 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3047 }
3048 else
3049 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3051 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 }
3053 goto done;
3054 }
3055 else if( strcasecmp(cmd, "stop") == 0 )
3056 {
3057 union iwreq_data wrqu;
3058 char buf[10];
3059
Arif Hussain6d2a3322013-11-17 19:50:10 -08003060 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003061
3062 wlan_hdd_enter_lowpower(pHddCtx);
3063 memset(&wrqu, 0, sizeof(wrqu));
3064 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3065 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 goto done;
3067 }
3068 else if (strcasecmp(cmd, "macaddr") == 0)
3069 {
3070 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3071 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3072 }
3073 else if (strcasecmp(cmd, "scan-active") == 0)
3074 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003075 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 ret = snprintf(cmd, cmd_len, "OK");
3077 }
3078 else if (strcasecmp(cmd, "scan-passive") == 0)
3079 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003080 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 ret = snprintf(cmd, cmd_len, "OK");
3082 }
3083 else if( strcasecmp(cmd, "scan-mode") == 0 )
3084 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003085 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 }
3087 else if( strcasecmp(cmd, "linkspeed") == 0 )
3088 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003089 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 }
3091 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3092 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003093 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003094 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003095
3096 country_code = cmd + 8;
3097
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003098 init_completion(&pAdapter->change_country_code);
3099
Arif Hussain24bfa702014-01-22 13:51:30 -08003100 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003101 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 country_code,
3103 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303104 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303105 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303106 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003107
3108 /* Wait for completion */
3109 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3110 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3111
3112 if (lrc <= 0)
3113 {
3114 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003115 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003116 }
3117
Arif Hussain24bfa702014-01-22 13:51:30 -08003118 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003120 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003121 "%s: SME Change Country code fail", __func__);
3122 kfree(cmd);
3123 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 }
3125 }
3126 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3127 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003128 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 }
3130 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3131 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003132 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133
Wilson Yang1be3e652013-10-09 15:18:31 -07003134 if (9 < cmd_len)
3135 {
3136 ptr = (char*)(cmd + 9);
3137
3138 }else{
3139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3140 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003141 kfree(cmd);
3142 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003143 }
3144
3145 if (1 != sscanf(ptr,"%d",&mode))
3146 {
3147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3148 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003149 kfree(cmd);
3150 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003151 }
3152
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 wlan_hdd_enter_bmps(pAdapter, mode);
3154 /*TODO:Set the power mode*/
3155 }
3156 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3157 v_U32_t pmc_state;
3158 v_U16_t value;
3159
3160 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3161 if(pmc_state == BMPS) {
3162 value = DRIVER_POWER_MODE_AUTO;
3163 }
3164 else {
3165 value = DRIVER_POWER_MODE_ACTIVE;
3166 }
3167 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3168 }
3169 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003170 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 /*TODO: set the btcoexmode*/
3172 }
3173 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3174
Arif Hussain6d2a3322013-11-17 19:50:10 -08003175 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 /*TODO: Return the btcoex status*/
3177 }
3178 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3179
Arif Hussain6d2a3322013-11-17 19:50:10 -08003180 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003181
3182 /*TODO: Enable Rx data Filter*/
3183 }
3184 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3185
Arif Hussain6d2a3322013-11-17 19:50:10 -08003186 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003187
3188 /*TODO: Disable Rx data Filter*/
3189 }
3190 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3191
Arif Hussain6d2a3322013-11-17 19:50:10 -08003192 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 /*TODO: rxfilter-statistics*/
3194 }
3195 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3196
Arif Hussain6d2a3322013-11-17 19:50:10 -08003197 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 /*TODO: rxfilter-add*/
3199 }
3200 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3201
Arif Hussain6d2a3322013-11-17 19:50:10 -08003202 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 /*TODO: rxfilter-remove*/
3204 }
3205#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003206 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3207 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3208 /*TODO: support pnosetup*/
3209 }
3210 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3211 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3212 /*TODO: support pnoforce*/
3213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3215
Arif Hussain6d2a3322013-11-17 19:50:10 -08003216 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003217 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3218 kfree(cmd);
3219 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 }
3221 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003222 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003223 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3224 kfree(cmd);
3225 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 }
3227#endif /*FEATURE_WLAN_SCAN_PNO*/
3228 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003229 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003230 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3231 kfree(cmd);
3232 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 }
3234 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3235 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003236 char *ptr;
3237
3238 if (18 < cmd_len)
3239 {
3240 ptr = (char*)(cmd + 18);
3241 }else{
3242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3243 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003244 kfree(cmd);
3245 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003246 }
3247
Jeff Johnson02797792013-10-26 19:17:13 -07003248 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003249 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3250 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3251 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3252 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3253 {
3254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3255 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003256 kfree(cmd);
3257 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003259
3260 // parameters checking
3261 // period has to be larger than 0
3262 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3263 {
3264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003265 kfree(cmd);
3266 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 }
3268
3269 // use default value 5 is the input is not reasonable. in unit of 10%
3270 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3271 {
3272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3273 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3274 }
3275
3276 // default is 5
3277 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3278 {
3279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3280 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3281 }
3282
Arif Hussain24bfa702014-01-22 13:51:30 -08003283 if (eHAL_STATUS_SUCCESS !=
3284 sme_SetTxPerTracking(pHddCtx->hHal,
3285 hdd_tx_per_hit_cb,
3286 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003288 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 }
3290 }
3291 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003292 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3293 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 }
3295done:
3296 /* many of the commands write information back into the command
3297 string using snprintf(). check the return value here in one
3298 place */
3299 if ((ret < 0) || (ret >= cmd_len))
3300 {
3301 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003302 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003304 else if (ret > 0)
3305 {
3306 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3307 {
3308 hddLog(VOS_TRACE_LEVEL_ERROR,
3309 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003310 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003311 return -EFAULT;
3312 }
3313 wrqu->data.length = ret;
3314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003315
3316 if (ioctl_debug)
3317 {
3318 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003319 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003321 kfree(cmd);
3322 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003323}
3324
3325static int iw_set_nick(struct net_device *dev,
3326 struct iw_request_info *info,
3327 union iwreq_data *wrqu, char *extra)
3328{
3329 ENTER();
3330 return 0;
3331}
3332
3333static int iw_get_nick(struct net_device *dev,
3334 struct iw_request_info *info,
3335 union iwreq_data *wrqu, char *extra)
3336{
3337 ENTER();
3338 return 0;
3339}
3340
3341static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3342{
3343 ENTER();
3344 return NULL;
3345}
3346
3347static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3348 union iwreq_data *wrqu,char *extra)
3349
3350{
3351 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3352 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3353 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3354 struct iw_point *encoderq = &(wrqu->encoding);
3355 v_U32_t keyId;
3356 v_U8_t key_length;
3357 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3358 v_BOOL_t fKeyPresent = 0;
3359 int i;
3360 eHalStatus status = eHAL_STATUS_SUCCESS;
3361
3362
3363 ENTER();
3364
3365 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3366 {
3367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3368 "%s:LOGP in Progress. Ignore!!!",__func__);
3369 return 0;
3370 }
3371
3372
3373 keyId = encoderq->flags & IW_ENCODE_INDEX;
3374
3375 if(keyId)
3376 {
3377 if(keyId > MAX_WEP_KEYS)
3378 {
3379 return -EINVAL;
3380 }
3381
3382 fKeyPresent = 1;
3383 keyId--;
3384 }
3385 else
3386 {
3387 fKeyPresent = 0;
3388 }
3389
3390
3391 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3392 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 if(!fKeyPresent) {
3395
3396 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3397
3398 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3399 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3400 }
3401 }
3402 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3403 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3404 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3405 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3406
3407 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3408 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3409
3410 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3411 {
3412 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3413 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003414 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303415 {
3416 long ret;
3417 ret = wait_for_completion_interruptible_timeout(
3418 &pAdapter->disconnect_comp_var,
3419 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3420 if (ret <= 0)
3421 hddLog(VOS_TRACE_LEVEL_ERROR,
3422 FL("failed wait on disconnect_comp_var %ld"), ret);
3423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 }
3425
3426 return status;
3427
3428 }
3429
3430 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3431 {
3432 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3433
3434 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3435
3436 }
3437
3438
3439 if(wrqu->data.length > 0)
3440 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003441 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003442
3443 key_length = wrqu->data.length;
3444
3445 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3446
3447 if(5 == key_length)
3448 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003449 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003450
3451 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3452 {
3453 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3454 }
3455 else
3456 {
3457 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3458 }
3459 }
3460 else if(13 == key_length)
3461 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003462 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003463
3464 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3465 {
3466 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3467 }
3468 else
3469 {
3470 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3471 }
3472 }
3473 else
3474 {
3475 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003476 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 return -EINVAL;
3478 }
3479
3480 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3481 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3482 pWextState->roamProfile.EncryptionType.numEntries = 1;
3483 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3484 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3485 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3486
3487 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3488 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3489 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3490 {
3491
3492 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3493
3494 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3495 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3496
3497 return status;
3498 }
3499 }
3500
3501 return 0;
3502}
3503
3504static int iw_get_encodeext(struct net_device *dev,
3505 struct iw_request_info *info,
3506 struct iw_point *dwrq,
3507 char *extra)
3508{
3509 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3510 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3511 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3512 int keyId;
3513 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3514 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3515 int i;
3516
3517 ENTER();
3518
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003519 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3520 {
3521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3522 "%s:LOGP in Progress. Ignore!!!", __func__);
3523 return -EBUSY;
3524 }
3525
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 keyId = pRoamProfile->Keys.defaultIndex;
3527
3528 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3529 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003530 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 return -EINVAL;
3532 }
3533
3534 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3535 {
3536 dwrq->flags |= IW_ENCODE_ENABLED;
3537 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303538 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3539 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 }
3541 else
3542 {
3543 dwrq->flags |= IW_ENCODE_DISABLED;
3544 }
3545
3546 for(i=0; i < MAX_WEP_KEYS; i++)
3547 {
3548 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3549 {
3550 continue;
3551 }
3552 else
3553 {
3554 break;
3555 }
3556 }
3557
3558 if(MAX_WEP_KEYS == i)
3559 {
3560 dwrq->flags |= IW_ENCODE_NOKEY;
3561 }
3562 else
3563 {
3564 dwrq->flags |= IW_ENCODE_ENABLED;
3565 }
3566
3567 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3568
3569 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3570 {
3571 dwrq->flags |= IW_ENCODE_DISABLED;
3572 }
3573
3574 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3575
3576 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3577 {
3578 dwrq->flags |= IW_ENCODE_OPEN;
3579 }
3580 else
3581 {
3582 dwrq->flags |= IW_ENCODE_RESTRICTED;
3583 }
3584 EXIT();
3585 return 0;
3586
3587}
3588
3589static int iw_set_encodeext(struct net_device *dev,
3590 struct iw_request_info *info,
3591 union iwreq_data *wrqu, char *extra)
3592{
3593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3594 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3595 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3596 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3597
3598 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3599 v_U32_t status = 0;
3600
3601 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3602
3603 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3604
3605 int key_index;
3606 struct iw_point *encoding = &wrqu->encoding;
3607 tCsrRoamSetKey setKey;
3608 v_U32_t roamId= 0xFF;
3609 VOS_STATUS vos_status;
3610
3611 ENTER();
3612
3613 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3614 {
3615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3616 "%s:LOGP in Progress. Ignore!!!",__func__);
3617 return 0;
3618 }
3619
3620 key_index = encoding->flags & IW_ENCODE_INDEX;
3621
3622 if(key_index > 0) {
3623
3624 /*Convert from 1-based to 0-based keying*/
3625 key_index--;
3626 }
3627 if(!ext->key_len) {
3628
3629 /*Set the encrytion type to NONE*/
3630 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3631 return status;
3632 }
3633
3634 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3635 (IW_ENCODE_ALG_WEP == ext->alg))
3636 {
3637 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3638
Agarwal Ashish971c2882013-10-30 20:11:12 +05303639 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3640 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 return -EINVAL;
3642 }
3643 else {
3644 /*Static wep, update the roam profile with the keys */
3645 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3646 key_index < CSR_MAX_NUM_KEY) {
3647 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3648 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3649
3650 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3651 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3652
3653 }
3654 }
3655 return status;
3656 }
3657
3658 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3659
3660 setKey.keyId = key_index;
3661 setKey.keyLength = ext->key_len;
3662
3663 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3664 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3665 }
3666
3667 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3668 /*Key direction for group is RX only*/
3669 setKey.keyDirection = eSIR_RX_ONLY;
3670 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3671 }
3672 else {
3673
3674 setKey.keyDirection = eSIR_TX_RX;
3675 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3676 }
3677
3678 /*For supplicant pae role is zero*/
3679 setKey.paeRole = 0;
3680
3681 switch(ext->alg)
3682 {
3683 case IW_ENCODE_ALG_NONE:
3684 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3685 break;
3686
3687 case IW_ENCODE_ALG_WEP:
3688 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3689 break;
3690
3691 case IW_ENCODE_ALG_TKIP:
3692 {
3693 v_U8_t *pKey = &setKey.Key[0];
3694
3695 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3696
3697 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3698
3699 /*Supplicant sends the 32bytes key in this order
3700
3701 |--------------|----------|----------|
3702 | Tk1 |TX-MIC | RX Mic |
3703 |--------------|----------|----------|
3704 <---16bytes---><--8bytes--><--8bytes-->
3705
3706 */
3707 /*Sme expects the 32 bytes key to be in the below order
3708
3709 |--------------|----------|----------|
3710 | Tk1 |RX-MIC | TX Mic |
3711 |--------------|----------|----------|
3712 <---16bytes---><--8bytes--><--8bytes-->
3713 */
3714 /* Copy the Temporal Key 1 (TK1) */
3715 vos_mem_copy(pKey,ext->key,16);
3716
3717 /*Copy the rx mic first*/
3718 vos_mem_copy(&pKey[16],&ext->key[24],8);
3719
3720 /*Copy the tx mic */
3721 vos_mem_copy(&pKey[24],&ext->key[16],8);
3722
3723 }
3724 break;
3725
3726 case IW_ENCODE_ALG_CCMP:
3727 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3728 break;
3729
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003730#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003731#define IW_ENCODE_ALG_KRK 6
3732 case IW_ENCODE_ALG_KRK:
3733 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3734 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003735#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003736
3737 default:
3738 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3739 break;
3740 }
3741
3742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003743 ("%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 -07003744
3745#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303746 /* The supplicant may attempt to set the PTK once pre-authentication
3747 is done. Save the key in the UMAC and include it in the ADD
3748 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303750 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303752 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3753 "%s: Update PreAuth Key success", __func__);
3754 return 0;
3755 }
3756 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3757 {
3758 hddLog(VOS_TRACE_LEVEL_ERROR,
3759 "%s: Update PreAuth Key failed", __func__);
3760 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 }
3762#endif /* WLAN_FEATURE_VOWIFI_11R */
3763
3764 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3765
3766 vos_status = wlan_hdd_check_ula_done(pAdapter);
3767 if ( vos_status != VOS_STATUS_SUCCESS )
3768 {
3769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3770 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3771 __LINE__, vos_status );
3772
3773 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3774 }
3775
3776 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3777
3778 if ( halStatus != eHAL_STATUS_SUCCESS )
3779 {
3780 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3781 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3782 __LINE__, halStatus );
3783
3784 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3785 }
3786
3787 return halStatus;
3788}
3789
3790static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3791 union iwreq_data *wrqu, char *extra)
3792{
3793 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3794 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3795
3796 ENTER();
3797
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003798 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3799 {
3800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3801 "%s:LOGP in Progress. Ignore!!!", __func__);
3802 return -EBUSY;
3803 }
3804
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3806 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3807
Arif Hussain6d2a3322013-11-17 19:50:10 -08003808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003809
3810 return -EINVAL;
3811 }
3812
3813 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3814
3815 if((wrqu->retry.flags & IW_RETRY_LONG))
3816 {
3817 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3818 {
c_hpothub8245442013-11-20 23:41:09 +05303819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3820 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 return -EIO;
3822 }
3823 }
3824 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3825 {
3826 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3827 {
c_hpothub8245442013-11-20 23:41:09 +05303828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3829 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 return -EIO;
3831 }
3832 }
3833 }
3834 else
3835 {
3836 return -EOPNOTSUPP;
3837 }
3838
Arif Hussain6d2a3322013-11-17 19:50:10 -08003839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003840
3841 EXIT();
3842
3843 return 0;
3844
3845}
3846
3847static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3848 union iwreq_data *wrqu, char *extra)
3849{
3850 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3851 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3852 v_U32_t retry = 0;
3853
3854 ENTER();
3855
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003856 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3857 {
3858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3859 "%s:LOGP in Progress. Ignore!!!", __func__);
3860 return -EBUSY;
3861 }
3862
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 if((wrqu->retry.flags & IW_RETRY_LONG))
3864 {
3865 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3866
3867 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3868 {
c_hpothub8245442013-11-20 23:41:09 +05303869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3870 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 return -EIO;
3872 }
3873
3874 wrqu->retry.value = retry;
3875 }
3876 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3877 {
3878 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3879
3880 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3881 {
c_hpothub8245442013-11-20 23:41:09 +05303882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3883 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 return -EIO;
3885 }
3886
3887 wrqu->retry.value = retry;
3888 }
3889 else {
3890 return -EOPNOTSUPP;
3891 }
3892
Arif Hussain6d2a3322013-11-17 19:50:10 -08003893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003894
3895 EXIT();
3896
3897 return 0;
3898}
3899
3900static int iw_set_mlme(struct net_device *dev,
3901 struct iw_request_info *info,
3902 union iwreq_data *wrqu,
3903 char *extra)
3904{
3905 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3906 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3907 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3908 eHalStatus status = eHAL_STATUS_SUCCESS;
3909
3910 ENTER();
3911
3912 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3913 {
3914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3915 "%s:LOGP in Progress. Ignore!!!",__func__);
3916 return 0;
3917 }
3918
3919 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3920 switch (mlme->cmd) {
3921 case IW_MLME_DISASSOC:
3922 case IW_MLME_DEAUTH:
3923
3924 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3925 {
3926 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3927
3928 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3929 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3930
3931 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3932 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3933
Jeff Johnson43971f52012-07-17 12:26:56 -07003934 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303935 {
3936 long ret;
3937 ret = wait_for_completion_interruptible_timeout(
3938 &pAdapter->disconnect_comp_var,
3939 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3940 if (ret <= 0)
3941 hddLog(VOS_TRACE_LEVEL_ERROR,
3942 FL("failed wait on disconnect_comp_var %ld"), ret);
3943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003945 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003946 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003947
3948 /* Resetting authKeyMgmt */
3949 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3950
3951 netif_tx_disable(dev);
3952 netif_carrier_off(dev);
3953
3954 }
3955 else
3956 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003957 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 -07003958 }
3959 break;
3960 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003961 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 return -EINVAL;
3963 }//end of switch
3964
3965 EXIT();
3966
3967 return status;
3968
3969}
3970
3971/* set param sub-ioctls */
3972static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3973 union iwreq_data *wrqu, char *extra)
3974{
3975 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3976 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3977 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3978 int *value = (int *)extra;
3979 int sub_cmd = value[0];
3980 int set_value = value[1];
3981 int ret = 0; /* success */
3982 int enable_pbm, enable_mp;
3983#ifdef CONFIG_HAS_EARLYSUSPEND
3984 v_U8_t nEnableSuspendOld;
3985#endif
3986 INIT_COMPLETION(pWextState->completion_var);
3987
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003988 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3989 {
3990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3991 "%s:LOGP in Progress. Ignore!!!", __func__);
3992 return -EBUSY;
3993 }
3994
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 switch(sub_cmd)
3996 {
3997 case WE_SET_11D_STATE:
3998 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003999 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004000 memset(&smeConfig, 0x00, sizeof(smeConfig));
4001
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4003
4004 sme_GetConfigParam(hHal,&smeConfig);
4005 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4006
Arif Hussain6d2a3322013-11-17 19:50:10 -08004007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004008
4009 sme_UpdateConfig(hHal,&smeConfig);
4010 }
4011 else {
4012 return -EINVAL;
4013 }
4014 break;
4015 }
4016
4017 case WE_WOWL:
4018 {
4019 switch (set_value)
4020 {
4021 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004022 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 break;
4024 case 0x01:
4025 case 0x02:
4026 case 0x03:
4027 enable_mp = (set_value & 0x01) ? 1 : 0;
4028 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004029 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4031 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4032 break;
4033 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004034 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 ret = -EINVAL;
4036 break;
4037 }
4038
4039 break;
4040 }
4041 case WE_SET_POWER:
4042 {
4043 switch (set_value)
4044 {
4045 case 0: //Full Power
4046 {
4047 struct statsContext context;
4048 eHalStatus status;
4049
4050 init_completion(&context.completion);
4051
4052 context.pAdapter = pAdapter;
4053 context.magic = POWER_CONTEXT_MAGIC;
4054
4055 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4056 iw_power_callback_fn, &context,
4057 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004058 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 {
4060 int lrc = wait_for_completion_interruptible_timeout(
4061 &context.completion,
4062 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004063
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 if (lrc <= 0)
4065 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004066 hddLog(VOS_TRACE_LEVEL_ERROR,
4067 "%s: SME %s while requesting fullpower",
4068 __func__, (0 == lrc) ?
4069 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 }
4071 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004072 /* either we have a response or we timed out. if we timed
4073 out there is a race condition such that the callback
4074 function could be executing at the same time we are. of
4075 primary concern is if the callback function had already
4076 verified the "magic" but had not yet set the completion
4077 variable when a timeout occurred. we serialize these
4078 activities by invalidating the magic while holding a
4079 shared spinlock which will cause us to block if the
4080 callback is currently executing */
4081 spin_lock(&hdd_context_lock);
4082 context.magic = 0;
4083 spin_unlock(&hdd_context_lock);
4084
Arif Hussain6d2a3322013-11-17 19:50:10 -08004085 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 break;
4087 }
4088 case 1: //Enable BMPS
4089 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4090 break;
4091 case 2: //Disable BMPS
4092 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4093 break;
4094 case 3: //Request Bmps
4095 {
4096 struct statsContext context;
4097 eHalStatus status;
4098
4099 init_completion(&context.completion);
4100
4101 context.pAdapter = pAdapter;
4102 context.magic = POWER_CONTEXT_MAGIC;
4103
4104 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4105 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004106 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 {
4108 int lrc = wait_for_completion_interruptible_timeout(
4109 &context.completion,
4110 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 if (lrc <= 0)
4112 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004113 hddLog(VOS_TRACE_LEVEL_ERROR,
4114 "%s: SME %s while requesting BMPS",
4115 __func__, (0 == lrc) ? "timeout" :
4116 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 }
4118 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004119 /* either we have a response or we timed out. if we
4120 timed out there is a race condition such that the
4121 callback function could be executing at the same
4122 time we are. of primary concern is if the callback
4123 function had already verified the "magic" but had
4124 not yet set the completion variable when a timeout
4125 occurred. we serialize these activities by
4126 invalidating the magic while holding a shared
4127 spinlock which will cause us to block if the
4128 callback is currently executing */
4129 spin_lock(&hdd_context_lock);
4130 context.magic = 0;
4131 spin_unlock(&hdd_context_lock);
4132
Arif Hussain6d2a3322013-11-17 19:50:10 -08004133 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 break;
4135 }
4136 case 4: //Enable IMPS
4137 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4138 break;
4139 case 5: //Disable IMPS
4140 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4141 break;
4142 case 6: //Enable Standby
4143 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4144 break;
4145 case 7: //Disable Standby
4146 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4147 break;
4148 case 8: //Request Standby
4149#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004150#endif
4151 break;
4152 case 9: //Start Auto Bmps Timer
4153 sme_StartAutoBmpsTimer(hHal);
4154 break;
4155 case 10://Stop Auto BMPS Timer
4156 sme_StopAutoBmpsTimer(hHal);
4157 break;
4158#ifdef CONFIG_HAS_EARLYSUSPEND
4159 case 11://suspend to standby
4160#ifdef CONFIG_HAS_EARLYSUSPEND
4161 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4162 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4164#endif
4165 break;
4166 case 12://suspend to deep sleep
4167#ifdef CONFIG_HAS_EARLYSUSPEND
4168 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4169 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4171#endif
4172 break;
4173 case 13://resume from suspend
4174#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004175#endif
4176 break;
4177#endif
4178 case 14://reset wlan (power down/power up)
4179 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4180 break;
4181 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004182 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 ret = -EINVAL;
4184 break;
4185 }
4186 break;
4187 }
4188
4189 case WE_SET_MAX_ASSOC:
4190 {
4191 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4192 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4193 {
4194 ret = -EINVAL;
4195 }
4196 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4197 set_value, NULL, eANI_BOOLEAN_FALSE)
4198 != eHAL_STATUS_SUCCESS )
4199 {
c_hpothub8245442013-11-20 23:41:09 +05304200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4201 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 ret = -EIO;
4203 }
4204 break;
4205 }
4206
4207 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4208 {
4209 if( 0 == set_value )
4210 {
4211 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4212 }
4213 else if ( 1 == set_value )
4214 {
4215 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4216 }
4217 else
4218 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004219 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 ret = -EINVAL;
4221 }
4222 break;
4223 }
4224
4225 case WE_SET_DATA_INACTIVITY_TO:
4226 {
4227 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4228 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4229 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4230 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4231 set_value,
4232 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4233 {
4234 hddLog(LOGE,"Failure: Could not pass on "
4235 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004236 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 ret = -EINVAL;
4238 }
4239 break;
4240 }
4241 case WE_SET_MAX_TX_POWER:
4242 {
4243 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4244 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4245
4246 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4247 __func__, set_value);
4248 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4249 eHAL_STATUS_SUCCESS )
4250 {
4251 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4252 __func__);
4253 return -EIO;
4254 }
4255
4256 break;
4257 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004258 case WE_SET_MAX_TX_POWER_2_4:
4259 {
4260 hddLog(VOS_TRACE_LEVEL_INFO,
4261 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4262 __func__, set_value);
4263 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4264 eHAL_STATUS_SUCCESS)
4265 {
4266 hddLog(VOS_TRACE_LEVEL_ERROR,
4267 "%s: Setting maximum tx power failed for 2.4 GHz band",
4268 __func__);
4269 return -EIO;
4270 }
4271
4272 break;
4273 }
4274 case WE_SET_MAX_TX_POWER_5_0:
4275 {
4276 hddLog(VOS_TRACE_LEVEL_INFO,
4277 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4278 __func__, set_value);
4279 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4280 eHAL_STATUS_SUCCESS)
4281 {
4282 hddLog(VOS_TRACE_LEVEL_ERROR,
4283 "%s: Setting maximum tx power failed for 5.0 GHz band",
4284 __func__);
4285 return -EIO;
4286 }
4287
4288 break;
4289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 case WE_SET_HIGHER_DTIM_TRANSITION:
4291 {
4292 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4293 (set_value == eANI_BOOLEAN_TRUE)))
4294 {
4295 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4296 ret = -EINVAL;
4297 }
4298 else
4299 {
4300 if(pAdapter->higherDtimTransition != set_value)
4301 {
4302 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004303 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 }
4305 }
4306
4307 break;
4308 }
4309
4310 case WE_SET_TM_LEVEL:
4311 {
4312 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004313 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4315
4316 break;
4317 }
4318
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304319 case WE_ENABLE_STRICT_FCC_REG:
4320 {
4321 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4322 struct wiphy *wiphy = NULL;
4323 long lrc;
4324 int status;
4325
4326 wiphy = hddCtxt->wiphy;
4327 if(wiphy == NULL)
4328 {
4329 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4330 break;
4331 }
4332 init_completion(&hddCtxt->wiphy_channel_update_event);
4333
4334 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4335
4336 status = regulatory_hint(wiphy, "00");
4337 if(status < 0)
4338 {
4339 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4340 break;
4341 }
4342
4343 /* Wait for completion */
4344 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4345 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4346 if (lrc <= 0)
4347 {
4348 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4349 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4350 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4351 }
4352 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4353
4354 break;
4355 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004356 case WE_SET_DEBUG_LOG:
4357 {
4358 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4359 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4360 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4361 break;
4362 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304363
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 default:
4365 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004366 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 sub_cmd, set_value);
4368 break;
4369 }
4370 }
4371
4372 return ret;
4373}
4374
4375/* set param sub-ioctls */
4376static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4377 union iwreq_data *wrqu, char *extra)
4378{
4379 VOS_STATUS vstatus;
4380 int sub_cmd = wrqu->data.flags;
4381 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004382 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4384 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4385#ifdef WLAN_FEATURE_VOWIFI
4386 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4387#endif /* WLAN_FEATURE_VOWIFI */
4388
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004389 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4390 {
4391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4392 "%s:LOGP in Progress. Ignore!!!", __func__);
4393 return -EBUSY;
4394 }
4395
Arif Hussain0273cba2014-01-07 20:58:29 -08004396 /* ODD number is used for set, copy data using copy_from_user */
4397 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4398 wrqu->data.length);
4399 if (NULL == pBuffer)
4400 {
4401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4402 "mem_alloc_copy_from_user_helper fail");
4403 return -ENOMEM;
4404 }
4405
4406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4407 "%s: Received length %d", __func__, wrqu->data.length);
4408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4409 "%s: Received data %s", __func__, pBuffer);
4410
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 switch(sub_cmd)
4412 {
4413 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004415 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 break;
4417 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004419 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 break;
4421#if defined WLAN_FEATURE_VOWIFI
4422 case WE_NEIGHBOR_REPORT_REQUEST:
4423 {
4424 tRrmNeighborReq neighborReq;
4425 tRrmNeighborRspCallbackInfo callbackInfo;
4426
4427 if (pConfig->fRrmEnable)
4428 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4431 if( !neighborReq.no_ssid )
4432 {
4433 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004434 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 }
4436
4437 callbackInfo.neighborRspCallback = NULL;
4438 callbackInfo.neighborRspCallbackContext = NULL;
4439 callbackInfo.timeout = 5000; //5 seconds
4440 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4441 }
4442 else
4443 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004444 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 ret = -EINVAL;
4446 }
4447 }
4448 break;
4449#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 case WE_SET_AP_WPS_IE:
4451 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004452 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004455 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 if (VOS_STATUS_SUCCESS != vstatus)
4457 {
4458 ret = -EINVAL;
4459 }
4460 break;
4461 default:
4462 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004463 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 ret = -EINVAL;
4465 break;
4466 }
4467 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004468 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 return ret;
4470}
4471
4472/* get param sub-ioctls */
4473static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4474 union iwreq_data *wrqu, char *extra)
4475{
4476 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4477 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4478 int *value = (int *)extra;
4479 int ret = 0; /* success */
4480
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004481 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4482 {
4483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4484 "%s:LOGP in Progress. Ignore!!!", __func__);
4485 return -EBUSY;
4486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004487
4488 switch (value[0])
4489 {
4490 case WE_GET_11D_STATE:
4491 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004492 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4496
Arif Hussain6d2a3322013-11-17 19:50:10 -08004497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004498
4499 break;
4500 }
4501
4502 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 break;
4505
4506 case WE_PMC_STATE:
4507 {
4508 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 break;
4511 }
4512 case WE_GET_WLAN_DBG:
4513 {
4514 vos_trace_display();
4515 *value = 0;
4516 break;
4517 }
4518 case WE_MODULE_DOWN_IND:
4519 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4522#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4525#endif
4526 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4527
4528 *value = 0;
4529 break;
4530 }
4531 case WE_GET_MAX_ASSOC:
4532 {
4533 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4534 {
c_hpothub8245442013-11-20 23:41:09 +05304535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4536 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 ret = -EIO;
4538 }
4539 break;
4540 }
4541
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 case WE_GET_WDI_DBG:
4543 {
4544 wpalTraceDisplay();
4545 *value = 0;
4546 break;
4547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004548
4549 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4550 {
4551 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4552 break;
4553 }
4554 case WE_GET_CONCURRENCY_MODE:
4555 {
4556 *value = hdd_get_concurrency_mode ( );
4557
Arif Hussain6d2a3322013-11-17 19:50:10 -08004558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 break;
4560 }
4561
4562 default:
4563 {
4564 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4565 break;
4566 }
4567 }
4568
4569 return ret;
4570}
4571
4572/* set param sub-ioctls */
4573int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4574 union iwreq_data *wrqu, char *extra)
4575{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004576 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 int *value = (int *)extra;
4578 int sub_cmd = value[0];
4579 int ret = 0;
4580
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004581 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4582 {
4583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4584 "%s:LOGP in Progress. Ignore!!!", __func__);
4585 return -EBUSY;
4586 }
4587
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 switch(sub_cmd)
4589 {
4590 case WE_SET_WLAN_DBG:
4591 {
4592 vos_trace_setValue( value[1], value[2], value[3]);
4593 break;
4594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 case WE_SET_WDI_DBG:
4596 {
4597 wpalTraceSetLevel( value[1], value[2], value[3]);
4598 break;
4599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 case WE_SET_SAP_CHANNELS:
4601 {
4602 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4603 break;
4604 }
4605
4606 default:
4607 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004608 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 break;
4610 }
4611 }
4612 return ret;
4613}
4614
4615static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4616 union iwreq_data *wrqu, char *extra)
4617{
4618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4619 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004620#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004621 hdd_wext_state_t *pWextState;
4622#endif
4623
4624 if (pAdapter == NULL)
4625 {
4626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4627 "%s: pAdapter is NULL!", __func__);
4628 return -EINVAL;
4629 }
4630#ifdef WLAN_FEATURE_11W
4631 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004632#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004633
Yue Ma3ede6052013-08-29 00:33:26 -07004634 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4635 {
4636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4637 "%s: HDD Context is NULL!", __func__);
4638
4639 return -EINVAL;
4640 }
4641
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004642 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4643 {
4644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4645 "%s:LOGP in Progress. Ignore!!!", __func__);
4646 return -EBUSY;
4647 }
4648
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 switch(sub_cmd)
4650 {
4651 case WE_WLAN_VERSION:
4652 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004653 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 break;
4655 }
4656
4657 case WE_GET_STATS:
4658 {
4659 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4660 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4661 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4662
4663 snprintf(extra, WE_MAX_STR_LEN,
4664 "\nTransmit"
4665 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4666 "\n dropped BK %u, BE %u, VI %u, VO %u"
4667 "\n classified BK %u, BE %u, VI %u, VO %u"
4668 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4669 "\n queued BK %u, BE %u, VI %u, VO %u"
4670 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004671 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 "\n fetched BK %u, BE %u, VI %u, VO %u"
4673 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4674 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004675 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 "\n flushed BK %u, BE %u, VI %u, VO %u"
4677 "\n\nReceive"
4678 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4679 "\n\nResetsStats"
4680 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4681 "\n",
4682 pStats->txXmitCalled,
4683 pStats->txXmitDropped,
4684 pStats->txXmitBackPressured,
4685 pStats->txXmitQueued,
4686
4687 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4688 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4689 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4690 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4691
4692 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4693 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4694 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4695 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4696
4697 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4698 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4699 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4700 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4701
4702 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4703 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4704 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4705 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4706
4707 pStats->txFetched,
4708 pStats->txFetchEmpty,
4709 pStats->txFetchLowResources,
4710 pStats->txFetchDequeueError,
4711
4712 pStats->txFetchDequeued,
4713 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004714 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 pStats->txCompleted,
4716 pStats->txFlushed,
4717
4718 pStats->txFetchedAC[WLANTL_AC_BK],
4719 pStats->txFetchedAC[WLANTL_AC_BE],
4720 pStats->txFetchedAC[WLANTL_AC_VI],
4721 pStats->txFetchedAC[WLANTL_AC_VO],
4722
4723 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4724 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4725 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4726 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4727
4728 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4729 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4730 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4731 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4732
Ravi Joshi41914632013-10-21 23:02:21 -07004733 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4734 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4735 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4736 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4737
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 pStats->txFlushedAC[WLANTL_AC_BK],
4739 pStats->txFlushedAC[WLANTL_AC_BE],
4740 pStats->txFlushedAC[WLANTL_AC_VI],
4741 pStats->txFlushedAC[WLANTL_AC_VO],
4742
4743 pStats->rxChains,
4744 pStats->rxPackets,
4745 pStats->rxDropped,
4746 pStats->rxDelivered,
4747 pStats->rxRefused,
4748
4749 pResetStats->totalLogpResets,
4750 pResetStats->totalCMD53Failures,
4751 pResetStats->totalMutexReadFailures,
4752 pResetStats->totalMIFErrorFailures,
4753 pResetStats->totalFWHearbeatFailures,
4754 pResetStats->totalUnknownExceptions
4755 );
4756 wrqu->data.length = strlen(extra)+1;
4757 break;
4758 }
4759
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304760/* The case prints the current state of the HDD, SME, CSR, PE, TL
4761 *it can be extended for WDI Global State as well.
4762 *And currently it only checks P2P_CLIENT adapter.
4763 *P2P_DEVICE and P2P_GO have not been added as of now.
4764*/
4765 case WE_GET_STATES:
4766 {
4767 int buf = 0, len = 0;
4768 int adapter_num = 0;
4769 int count = 0, check = 1;
4770
4771 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004772 tHalHandle hHal = NULL;
4773 tpAniSirGlobal pMac = NULL;
4774 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304775
4776 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4777 hdd_adapter_t *useAdapter = NULL;
4778
4779 /* Print wlan0 or p2p0 states based on the adapter_num
4780 *by using the correct adapter
4781 */
4782 while ( adapter_num < 2 )
4783 {
4784 if ( WLAN_ADAPTER == adapter_num )
4785 {
4786 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004787 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304788 "\n\n wlan0 States:-");
4789 len += buf;
4790 }
4791 else if ( P2P_ADAPTER == adapter_num )
4792 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004793 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304794 "\n\n p2p0 States:-");
4795 len += buf;
4796
4797 if( !pHddCtx )
4798 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004799 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304800 "\n pHddCtx is NULL");
4801 len += buf;
4802 break;
4803 }
4804
4805 /*Printing p2p0 states only in the case when the device is
4806 configured as a p2p_client*/
4807 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4808 if ( !useAdapter )
4809 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004810 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304811 "\n Device not configured as P2P_CLIENT.");
4812 len += buf;
4813 break;
4814 }
4815 }
4816
4817 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004818 if (!hHal) {
4819 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4820 "\n pMac is NULL");
4821 len += buf;
4822 break;
4823 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304824 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004825 if (!pMac) {
4826 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4827 "\n pMac is NULL");
4828 len += buf;
4829 break;
4830 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304831 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4832 if( !pHddStaCtx )
4833 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004834 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304835 "\n pHddStaCtx is NULL");
4836 len += buf;
4837 break;
4838 }
4839
4840 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4841
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004842 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304843 "\n HDD Conn State - %s "
4844 "\n \n SME State:"
4845 "\n Neighbour Roam State - %s"
4846 "\n CSR State - %s"
4847 "\n CSR Substate - %s"
4848 "\n \n TL STA %d State: %s",
4849 macTraceGetHDDWlanConnState(
4850 pHddStaCtx->conn_info.connState),
4851 macTraceGetNeighbourRoamState(
4852 pMac->roam.neighborRoamInfo.neighborRoamState),
4853 macTraceGetcsrRoamState(
4854 pMac->roam.curState[useAdapter->sessionId]),
4855 macTraceGetcsrRoamSubState(
4856 pMac->roam.curSubState[useAdapter->sessionId]),
4857 pHddStaCtx->conn_info.staId[0],
4858 macTraceGetTLState(tlState)
4859 );
4860 len += buf;
4861 adapter_num++;
4862 }
4863
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004864 if (pMac) {
4865 /* Printing Lim State starting with global lim states */
4866 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4867 "\n \n LIM STATES:-"
4868 "\n Global Sme State - %s "\
4869 "\n Global mlm State - %s "\
4870 "\n",
4871 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4872 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4873 );
4874 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304875
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004876 /*printing the PE Sme and Mlm states for valid lim sessions*/
4877 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304878 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004879 if ( pMac->lim.gpSession[count].valid )
4880 {
4881 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4882 "\n Lim Valid Session %d:-"
4883 "\n PE Sme State - %s "
4884 "\n PE Mlm State - %s "
4885 "\n",
4886 check,
4887 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4888 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4889 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304890
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004891 len += buf;
4892 check++;
4893 }
4894 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304895 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304896 }
4897
4898 wrqu->data.length = strlen(extra)+1;
4899 break;
4900 }
4901
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 case WE_GET_CFG:
4903 {
4904 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4905 wrqu->data.length = strlen(extra)+1;
4906 break;
4907 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004908#ifdef WLAN_FEATURE_11AC
4909 case WE_GET_RSSI:
4910 {
4911 v_S7_t s7Rssi = 0;
4912 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4913 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4914 wrqu->data.length = strlen(extra)+1;
4915 break;
4916 }
4917#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304918
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004919#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004920 case WE_GET_ROAM_RSSI:
4921 {
4922 v_S7_t s7Rssi = 0;
4923 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4924 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4925 wrqu->data.length = strlen(extra)+1;
4926 break;
4927 }
4928#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 case WE_GET_WMM_STATUS:
4930 {
4931 snprintf(extra, WE_MAX_STR_LEN,
4932 "\nDir: 0=up, 1=down, 3=both\n"
4933 "|------------------------|\n"
4934 "|AC | ACM |Admitted| Dir |\n"
4935 "|------------------------|\n"
4936 "|VO | %d | %3s | %d |\n"
4937 "|VI | %d | %3s | %d |\n"
4938 "|BE | %d | %3s | %d |\n"
4939 "|BK | %d | %3s | %d |\n"
4940 "|------------------------|\n",
4941 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4942 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4943 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4944 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4945 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4946 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4947 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4948 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4949 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4950 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4951 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4952 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4953
Jeff Johnsone7245742012-09-05 17:12:55 -07004954
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 wrqu->data.length = strlen(extra)+1;
4956 break;
4957 }
4958 case WE_GET_CHANNEL_LIST:
4959 {
4960 VOS_STATUS status;
4961 v_U8_t i, len;
4962 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004963
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 tChannelListInfo channel_list;
4965
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004966 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004968 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004970 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 return -EINVAL;
4972 }
4973 buf = extra;
4974
4975 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004976 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4977 * needed = 5 * number of channels. Check ifsufficient
4978 * buffer is available and then proceed to fill the buffer.
4979 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4981 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004982 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004983 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004984 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 return -EINVAL;
4986 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004987 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4988 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 for(i = 0 ; i < channel_list.num_channels; i++)
4990 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004991 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 }
4994 wrqu->data.length = strlen(extra)+1;
4995
4996 break;
4997 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004998#ifdef FEATURE_WLAN_TDLS
4999 case WE_GET_TDLS_PEERS:
5000 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005001 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005002 break;
5003 }
5004#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005005#ifdef WLAN_FEATURE_11W
5006 case WE_GET_11W_INFO:
5007 {
5008 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5009
5010 snprintf(extra, WE_MAX_STR_LEN,
5011 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5012 "\n Number of Unprotected Disassocs %d"
5013 "\n Number of Unprotected Deauths %d",
5014 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5015 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5016 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5017 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5018 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5019
5020 wrqu->data.length = strlen(extra)+1;
5021 break;
5022 }
5023#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305024 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005026 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 break;
5028 }
5029 }
5030
5031 return 0;
5032}
5033
5034/* action sub-ioctls */
5035static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5036 union iwreq_data *wrqu, char *extra)
5037{
5038 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5039 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005040 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07005041
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005042 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5043 {
5044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5045 "%s:LOGP in Progress. Ignore!!!", __func__);
5046 return -EBUSY;
5047 }
5048
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 switch (sub_cmd)
5050 {
5051 case WE_CLEAR_STATS:
5052 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5055 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5056 break;
5057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 case WE_INIT_AP:
5059 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305060 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5061
5062 /* As Soft AP mode might been changed to STA already with
5063 * killing of Hostapd, need to find the adpater by name
5064 * rather than mode */
5065 hdd_adapter_t* pAdapter_to_stop =
5066 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5067 if( pAdapter_to_stop )
5068 {
5069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5070 "Adapter with name softap.0 already "
5071 "exist, ignoring the request.\nRemove the "
5072 "adapter and try again\n");
5073 break;
5074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 pr_info("Init AP trigger\n");
5076 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5077 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5078 break;
5079 }
5080 case WE_STOP_AP:
5081 {
5082 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5083 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5084 * this is a dead code and need to find the adpater by name rather than mode */
5085 hdd_adapter_t* pAdapter_to_stop =
5086 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5087 if( pAdapter_to_stop )
5088 {
5089 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5090
5091 pr_info("Stopping AP mode\n");
5092
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305093 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5094 {
5095 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5096 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5097 }
5098
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 /*Make sure that pAdapter cleaned properly*/
5100 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5101 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5102 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5103
5104 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5105 pAdapter_to_stop->macAddressCurrent.bytes);
5106 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5107 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305108
5109 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5110 {
5111 /* put the device back into BMPS */
5112 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 }
5115 else
5116 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005117 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 }
5119
5120 break;
5121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005122#ifdef WLAN_BTAMP_FEATURE
5123 case WE_ENABLE_AMP:
5124 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 WLANBAP_RegisterWithHCI(pAdapter);
5127 break;
5128 }
5129 case WE_DISABLE_AMP:
5130 {
5131 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5132 VOS_STATUS status;
5133
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005135
5136 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5137 status = WLANBAP_StopAmp();
5138 if(VOS_STATUS_SUCCESS != status )
5139 {
5140 pHddCtx->isAmpAllowed = VOS_TRUE;
5141 hddLog(VOS_TRACE_LEVEL_FATAL,
5142 "%s: Failed to stop AMP", __func__);
5143 }
5144 else
5145 {
5146 //a state m/c implementation in PAL is TBD to avoid this delay
5147 msleep(500);
5148 pHddCtx->isAmpAllowed = VOS_FALSE;
5149 WLANBAP_DeregisterFromHCI();
5150 }
5151
5152 break;
5153 }
5154#endif
5155
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005156 case WE_ENABLE_DXE_STALL_DETECT:
5157 {
schang6295e542013-03-12 15:31:23 -07005158 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5159 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005160 break;
5161 }
5162 case WE_DISPLAY_DXE_SNAP_SHOT:
5163 {
schang6295e542013-03-12 15:31:23 -07005164 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5165 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005166 break;
5167 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305168 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5169 {
5170 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5171 hdd_wmm_tx_snapshot(pAdapter);
5172 WLANTL_TLDebugMessage(VOS_TRUE);
5173 break;
5174 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07005175 case WE_SET_REASSOC_TRIGGER:
5176 {
5177 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5178 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5179 v_U32_t roamId = 0;
5180 tCsrRoamModifyProfileFields modProfileFields;
5181 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5182 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5183 return 0;
5184 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305185
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305186 case WE_STOP_OBSS_SCAN:
5187 {
5188 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5189 2.OBSS scan is stopped by Firmware during the disassociation
5190 3.OBSS stop comamnd is added for debugging purpose*/
5191 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5192 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005193
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305194 if (pAdapter == NULL)
5195 {
5196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5197 " pAdapter is NULL ");
5198 }
5199 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5200 if (pMac == NULL)
5201 {
5202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5203 " pMac is NULL ");
5204 }
5205 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5206 }
5207 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 default:
5209 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005210 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 break;
5212 }
5213 }
5214
5215 return ret;
5216}
5217
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305218void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5219{
5220 /*
5221 * Function to display HDD WMM information
5222 * for Tx Queues.
5223 * Prints globala as well as per client depending
5224 * whether the clients are registered or not.
5225 */
5226 int i = 0, j = 0;
5227 for ( i=0; i< NUM_TX_QUEUES; i++)
5228 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305229 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005230 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305231 i, pAdapter->wmm_tx_queue[i].count,
5232 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305233 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305234 }
5235
5236 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5237 {
5238 if(pAdapter->aStaInfo[i].isUsed)
5239 {
5240 hddLog(LOGE, "******STAIndex: %d*********", i);
5241 for ( j=0; j< NUM_TX_QUEUES; j++)
5242 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305243 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005244 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305245 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5246 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5247 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305248 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305249 }
5250 }
5251 }
5252
5253}
Jeff Johnson295189b2012-06-20 16:38:30 -07005254int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5255 union iwreq_data *wrqu, char *extra)
5256{
5257 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5258 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5259 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 int apps_args[MAX_VAR_ARGS] = {0};
5261 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005262 hdd_station_ctx_t *pStaCtx = NULL ;
5263 hdd_ap_ctx_t *pAPCtx = NULL;
5264 int cmd = 0;
5265 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005266
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005267 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005268
5269 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5270 {
5271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5272 "%s:LOGP in Progress. Ignore!!!", __func__);
5273 return -EBUSY;
5274 }
5275
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 if (num_args > MAX_VAR_ARGS)
5277 {
5278 num_args = MAX_VAR_ARGS;
5279 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005280
5281 /* ODD number is used for set, copy data using copy_from_user */
5282 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5283 {
5284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5285 "%s: failed to copy data to user buffer", __func__);
5286 return -EFAULT;
5287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005288
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005289 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5290 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5291 {
5292 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5293 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5294 {
5295 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5296 staId = pStaCtx->conn_info.staId[0];
5297 }
5298 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5299 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5300 {
5301 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5302 staId = pAPCtx->uBCStaId;
5303 }
5304 else
5305 {
5306 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5307 return 0;
5308 }
5309 }
5310
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 switch (sub_cmd)
5312 {
5313 case WE_LOG_DUMP_CMD:
5314 {
5315 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005316 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 apps_args[3], apps_args[4]);
5318
5319 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5320 apps_args[3], apps_args[4]);
5321
5322 }
5323 break;
5324
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 case WE_P2P_NOA_CMD:
5326 {
5327 p2p_app_setP2pPs_t p2pNoA;
5328
5329 p2pNoA.opp_ps = apps_args[0];
5330 p2pNoA.ctWindow = apps_args[1];
5331 p2pNoA.duration = apps_args[2];
5332 p2pNoA.interval = apps_args[3];
5333 p2pNoA.count = apps_args[4];
5334 p2pNoA.single_noa_duration = apps_args[5];
5335 p2pNoA.psSelection = apps_args[6];
5336
5337 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5338 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005339 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5341
5342 hdd_setP2pPs(dev, &p2pNoA);
5343
5344 }
5345 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005346
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305347 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5348 {
5349 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5350 __func__, apps_args[0], apps_args[1]);
5351 vosTraceEnable(apps_args[0], apps_args[1]);
5352 }
5353 break;
5354
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005355 case WE_MTRACE_DUMP_CMD:
5356 {
5357 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5358 "bitmask_of_module %d ",
5359 __func__, apps_args[0], apps_args[1], apps_args[2],
5360 apps_args[3]);
5361 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5362 apps_args[2], apps_args[3]);
5363
5364 }
5365 break;
5366
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005367 case WE_MCC_CONFIG_CREDENTIAL :
5368 {
5369 cmd = 287; //Command should be updated if there is any change
5370 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005371 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005372 {
5373 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5374 }
5375 else
5376 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005377 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005378 return 0;
5379 }
5380 }
5381 break;
5382
5383 case WE_MCC_CONFIG_PARAMS :
5384 {
5385 cmd = 288; //command Should be updated if there is any change
5386 // in the Riva dump command
5387 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5388 }
5389 break;
5390
Chilam NG571c65a2013-01-19 12:27:36 +05305391#ifdef FEATURE_WLAN_TDLS
5392 case WE_TDLS_CONFIG_PARAMS :
5393 {
5394 tdls_config_params_t tdlsParams;
5395
Chilam Ng01120412013-02-19 18:32:21 -08005396 tdlsParams.tdls = apps_args[0];
5397 tdlsParams.tx_period_t = apps_args[1];
5398 tdlsParams.tx_packet_n = apps_args[2];
5399 tdlsParams.discovery_period_t = apps_args[3];
5400 tdlsParams.discovery_tries_n = apps_args[4];
5401 tdlsParams.idle_timeout_t = apps_args[5];
5402 tdlsParams.idle_packet_n = apps_args[6];
5403 tdlsParams.rssi_hysteresis = apps_args[7];
5404 tdlsParams.rssi_trigger_threshold = apps_args[8];
5405 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305406
Chilam Ng01120412013-02-19 18:32:21 -08005407 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305408 }
5409 break;
5410#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 default:
5412 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005413 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5414 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 }
5416 break;
5417 }
5418
5419 return 0;
5420}
5421
5422
5423static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5424 union iwreq_data *wrqu, char *extra)
5425{
5426 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5427 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5428 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5429 int params[HDD_WLAN_WMM_PARAM_COUNT];
5430 sme_QosWmmTspecInfo tSpec;
5431 v_U32_t handle;
5432
5433 // make sure the application is sufficiently priviledged
5434 // note that the kernel will do this for "set" ioctls, but since
5435 // this ioctl wants to return status to user space it must be
5436 // defined as a "get" ioctl
5437 if (!capable(CAP_NET_ADMIN))
5438 {
5439 return -EPERM;
5440 }
5441
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005442 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5443 {
5444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5445 "%s:LOGP in Progress. Ignore!!!", __func__);
5446 return -EBUSY;
5447 }
5448
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 // we must be associated in order to add a tspec
5450 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5451 {
5452 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5453 return 0;
5454 }
5455
5456 // since we are defined to be a "get" ioctl, and since the number
5457 // of params exceeds the number of params that wireless extensions
5458 // will pass down in the iwreq_data, we must copy the "set" params
5459 // from user space ourselves
5460 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5461 {
5462 // hmmm, can't get them
5463 return -EIO;
5464 }
5465
5466 // clear the tspec
5467 memset(&tSpec, 0, sizeof(tSpec));
5468
5469 // validate the handle
5470 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5471 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5472 {
5473 // that one is reserved
5474 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5475 return 0;
5476 }
5477
5478 // validate the TID
5479 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5480 {
5481 // out of range
5482 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5483 return 0;
5484 }
5485 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5486
5487 // validate the direction
5488 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5489 {
5490 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5491 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5492 break;
5493
5494 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5495 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5496 break;
5497
5498 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5499 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5500 break;
5501
5502 default:
5503 // unknown
5504 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5505 return 0;
5506 }
5507
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305508 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5509
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 // validate the user priority
5511 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5512 {
5513 // out of range
5514 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5515 return 0;
5516 }
5517 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305518 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5519 {
5520 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5521 return 0;
5522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005523
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5525 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5526 tSpec.ts_info.psb, tSpec.ts_info.up);
5527
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5529 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5530 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5531 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5532 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5533 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5534 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5535 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5536 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5537 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5538 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5539 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5540
5541 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5542
5543 // validate the ts info ack policy
5544 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5545 {
5546 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5547 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5548 break;
5549
5550 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5551 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5552 break;
5553
5554 default:
5555 // unknown
5556 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5557 return 0;
5558 }
5559
5560 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5561 return 0;
5562}
5563
5564
5565static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5566 union iwreq_data *wrqu, char *extra)
5567{
5568 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5569 int *params = (int *)extra;
5570 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5571 v_U32_t handle;
5572
5573 // make sure the application is sufficiently priviledged
5574 // note that the kernel will do this for "set" ioctls, but since
5575 // this ioctl wants to return status to user space it must be
5576 // defined as a "get" ioctl
5577 if (!capable(CAP_NET_ADMIN))
5578 {
5579 return -EPERM;
5580 }
5581
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005582 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5583 {
5584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5585 "%s:LOGP in Progress. Ignore!!!", __func__);
5586 return -EBUSY;
5587 }
5588
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 // although we are defined to be a "get" ioctl, the params we require
5590 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5591 // is no need to copy the params from user space
5592
5593 // validate the handle
5594 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5595 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5596 {
5597 // that one is reserved
5598 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5599 return 0;
5600 }
5601
5602 *pStatus = hdd_wmm_delts(pAdapter, handle);
5603 return 0;
5604}
5605
5606
5607static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5608 union iwreq_data *wrqu, char *extra)
5609{
5610 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5611 int *params = (int *)extra;
5612 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5613 v_U32_t handle;
5614
5615 // although we are defined to be a "get" ioctl, the params we require
5616 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5617 // is no need to copy the params from user space
5618
5619 // validate the handle
5620 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5621 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5622 {
5623 // that one is reserved
5624 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5625 return 0;
5626 }
5627
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005628 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5629 {
5630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5631 "%s:LOGP in Progress. Ignore!!!", __func__);
5632 return -EBUSY;
5633 }
5634
Jeff Johnson295189b2012-06-20 16:38:30 -07005635 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5636 return 0;
5637}
5638
5639
5640#ifdef FEATURE_WLAN_WAPI
5641static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5642 union iwreq_data *wrqu, char *extra)
5643{
5644 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5645 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5646 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5647 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5648
Arif Hussain7adce1b2013-11-11 22:59:34 -08005649 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005650
5651 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005652 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005653 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5654 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005655
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005656 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5657 {
5658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5659 "%s:LOGP in Progress. Ignore!!!", __func__);
5660 return -EBUSY;
5661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005662
5663 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005664 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5666 pRoamProfile->EncryptionType.numEntries = 1;
5667 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5668 pRoamProfile->mcEncryptionType.numEntries = 1;
5669 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5670
5671 pRoamProfile->AuthType.numEntries = 1;
5672 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5673 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5674 }
5675 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005676 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 }
5678 else
5679 return -EINVAL;
5680
5681 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5682
5683 return 0;
5684}
5685
5686static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5687 union iwreq_data *wrqu, char *extra)
5688{
5689 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5690 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5691
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005692 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5693 {
5694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5695 "%s:LOGP in Progress. Ignore!!!", __func__);
5696 return -EBUSY;
5697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5699
5700 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005701 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 return 0;
5703}
5704
5705static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5706 union iwreq_data *wrqu, char *extra)
5707{
5708 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5709// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5710 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5711 int i = 0, j = 0;
5712 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005713 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005714 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005715
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005716 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5717 {
5718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5719 "%s:LOGP in Progress. Ignore!!!", __func__);
5720 return -EBUSY;
5721 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005722
5723 if (NULL == pWapiAssocInfo)
5724 {
5725 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5726 "%s: WDA NULL context", __func__);
5727 VOS_ASSERT(0);
5728 return VOS_STATUS_E_FAILURE;
5729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005730
Arif Hussain6d2a3322013-11-17 19:50:10 -08005731 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 -07005732 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005734 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005735
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005736 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005738 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005739
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005740 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005741 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 for(i = 0 ; i < 16 ; i++) {
5743 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5744 for(j = 0 ; j < 16 ; j++)
5745 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5746 }
5747
5748 /* We are not using the entire IE as provided by the supplicant.
5749 * This is being calculated by SME. This is the same as in the
5750 * case of WPA. Only the auth mode information needs to be
5751 * extracted here*/
5752 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005753 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5755 }
5756
5757 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005758 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5760 }
5761 return 0;
5762}
5763
5764static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5765 union iwreq_data *wrqu, char *extra)
5766{
5767 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5768 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5769 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5770 tANI_U32 roamId = 0xFF;
5771 tANI_U8 *pKeyPtr = NULL;
5772 v_BOOL_t isConnected = TRUE;
5773 tCsrRoamSetKey setKey;
5774 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5776
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005777 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5778 {
5779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5780 "%s:LOGP in Progress. Ignore!!!", __func__);
5781 return -EBUSY;
5782 }
5783
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005785 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005786 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005787
Arif Hussain6d2a3322013-11-17 19:50:10 -08005788 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 -07005789 hddLog(LOG1,"Add Index:0x");
5790 for(i =0 ; i < 12 ; i++)
5791 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5792
Arif Hussain6d2a3322013-11-17 19:50:10 -08005793 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5795 for(i =0 ; i < 16 ; i++)
5796 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5797
Arif Hussain6d2a3322013-11-17 19:50:10 -08005798 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5800 for(i =0 ; i < 16 ; i++)
5801 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5802
Arif Hussain6d2a3322013-11-17 19:50:10 -08005803 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 for(i = 0 ; i < 16 ; i++)
5805 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5806
5807 // Clear the setkey memory
5808 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5809 // Store Key ID
5810 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5811 // SET WAPI Encryption
5812 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5813 // Key Directionn both TX and RX
5814 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5815 // the PAE role
5816 setKey.paeRole = 0 ;
5817
5818 switch ( pWapiKey->keyType )
5819 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005820 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 {
5822 isConnected = hdd_connIsConnected(pHddStaCtx);
5823 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5824 break;
5825 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005826 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 {
5828 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5829 break;
5830 }
5831 default:
5832 {
5833 //Any other option is invalid.
5834 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005835 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005836
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005837 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5839 break; // NEED RETURN FROM HERE ????
5840 }
5841 }
5842
5843 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5844 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5845 pKeyPtr = setKey.Key;
5846 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5847 pKeyPtr += pWapiKey->wpiekLen;
5848 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5849
5850 // Set the new key with SME.
5851 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5852
5853 if ( isConnected ) {
5854 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5855 if ( halStatus != eHAL_STATUS_SUCCESS )
5856 {
5857 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5858 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5859
5860 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5861 }
5862 }
5863#if 0 /// NEED TO CHECK ON THIS
5864 else
5865 {
5866 // Store the keys in the adapter to be moved to the profile & passed to
5867 // SME in the ConnectRequest if we are not yet in connected state.
5868 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5869 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5870
5871 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5872 " Saving key [idx= %d] to apply when moving to connected state ",
5873 setKey.keyId );
5874
5875 }
5876#endif
5877 return halStatus;
5878}
5879
5880static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5881 union iwreq_data *wrqu, char *extra)
5882{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005883 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005884#ifdef WLAN_DEBUG
5885 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005886 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005887#endif
5888
5889 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005890 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005891 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005892
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005893 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5894 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005895
5896 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005897
5898 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5899 {
5900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5901 "%s:LOGP in Progress. Ignore!!!", __func__);
5902 return -EBUSY;
5903 }
5904
Jeff Johnson295189b2012-06-20 16:38:30 -07005905#ifdef WLAN_DEBUG
5906 for(i =0 ; i < 16 ; i++)
5907 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5908#endif
5909
5910 return 0;
5911}
5912
5913static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5914 union iwreq_data *wrqu, char *extra)
5915{
5916 /* Yet to implement this function, 19th April 2010 */
5917 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5918
5919 return 0;
5920}
5921#endif /* FEATURE_WLAN_WAPI */
5922
5923#ifdef WLAN_FEATURE_VOWIFI_11R
5924//
5925//
5926// Each time the supplicant has the auth_request or reassoc request
5927// IEs ready. This is pushed to the driver. The driver will inturn use
5928// it to send out the auth req and reassoc req for 11r FT Assoc.
5929//
5930static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5931 union iwreq_data *wrqu, char *extra)
5932{
5933 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5934 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5935 //v_CONTEXT_t pVosContext;
5936
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005937 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5938 {
5939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5940 "%s:LOGP in Progress. Ignore!!!", __func__);
5941 return -EBUSY;
5942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 if (!wrqu->data.length)
5944 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005945 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 return -EINVAL;
5947 }
5948 if (wrqu->data.pointer == NULL)
5949 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005950 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 return -EINVAL;
5952 }
5953
5954 // Added for debug on reception of Re-assoc Req.
5955 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5956 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005957 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005959 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 }
5961
5962#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005963 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005964#endif
5965
5966 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005967 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 wrqu->data.length);
5969
5970 return 0;
5971}
5972#endif
5973
Amar Singhalf3a6e762013-02-19 15:06:50 -08005974static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005975 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005977{
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005979 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005981 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005982 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005983 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5984 int idx;
5985 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005987 if (pHddCtx->isLogpInProgress)
5988 {
5989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5990 "%s:LOGP in Progress. Ignore!!!", __func__);
5991 return -EBUSY;
5992 }
5993
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305994 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5995 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305996#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005997
Amar Singhalf3a6e762013-02-19 15:06:50 -08005998 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5999 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006000 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006001 hddLog(VOS_TRACE_LEVEL_ERROR,
6002 "%s: vos_mem_alloc failed", __func__);
6003 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006004 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006005
6006 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6007
6008 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6009 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6010
6011 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6012 mc_addr_list_ptr->ulMulticastAddrCnt);
6013
6014 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006015 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006016 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6017 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6018
6019 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6020 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006021 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006022
Amar Singhalf3a6e762013-02-19 15:06:50 -08006023 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6024 vos_mem_free(mc_addr_list_ptr);
6025 if (eHAL_STATUS_SUCCESS != ret_val)
6026 {
6027 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6028 __func__);
6029 return -EINVAL;
6030 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306031#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306032 }
6033 else
6034 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006035
Amar Singhalf3a6e762013-02-19 15:06:50 -08006036 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6037 "%s: Set MC BC Filter Config request: %d suspend %d",
6038 __func__, pRequest->mcastBcastFilterSetting,
6039 pHddCtx->hdd_wlan_suspended);
6040
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306041 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006042
6043 if (pHddCtx->hdd_wlan_suspended)
6044 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006045 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6046 if (NULL == wlanRxpFilterParam)
6047 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306048 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006049 "%s: vos_mem_alloc failed", __func__);
6050 return -EINVAL;
6051 }
6052
Amar Singhalf3a6e762013-02-19 15:06:50 -08006053 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6054 pRequest->mcastBcastFilterSetting;
6055 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6056
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306057 hdd_conf_hostoffload(pAdapter, TRUE);
6058 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6059 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006060
6061 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6062 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306063 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006064 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6065 wlanRxpFilterParam->setMcstBcstFilter);
6066
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306067 if (eHAL_STATUS_SUCCESS !=
6068 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6069 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006070 {
6071 hddLog(VOS_TRACE_LEVEL_ERROR,
6072 "%s: Failure to execute set HW MC/BC Filter request",
6073 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006074 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006075 return -EINVAL;
6076 }
6077
Amar Singhalf3a6e762013-02-19 15:06:50 -08006078 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006080
6081 return 0;
6082}
6083
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006084static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006085 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 union iwreq_data *wrqu, char *extra)
6087{
6088 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6089 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306090 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006091 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006092
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306093 //Reset the filter to INI value as we have to clear the dynamic filter
6094 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006095
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306096 //Configure FW with new setting
6097 if (pHddCtx->hdd_wlan_suspended)
6098 {
6099 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6100 if (NULL == wlanRxpFilterParam)
6101 {
6102 hddLog(VOS_TRACE_LEVEL_ERROR,
6103 "%s: vos_mem_alloc failed", __func__);
6104 return -EINVAL;
6105 }
6106
6107 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6108 pHddCtx->configuredMcastBcastFilter;
6109 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6110
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306111 hdd_conf_hostoffload(pAdapter, TRUE);
6112 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6113 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306114
6115 if (eHAL_STATUS_SUCCESS !=
6116 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6117 wlanRxpFilterParam))
6118 {
6119 hddLog(VOS_TRACE_LEVEL_ERROR,
6120 "%s: Failure to execute set HW MC/BC Filter request",
6121 __func__);
6122 vos_mem_free(wlanRxpFilterParam);
6123 return -EINVAL;
6124 }
6125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 return 0;
6127}
6128
6129static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6130 union iwreq_data *wrqu, char *extra)
6131{
6132 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006133 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 tSirHostOffloadReq offloadRequest;
6135
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006136 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6137 {
6138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6139 "%s:LOGP in Progress. Ignore!!!", __func__);
6140 return -EBUSY;
6141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 /* Debug display of request components. */
6143 switch (pRequest->offloadType)
6144 {
6145 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006146 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 switch (pRequest->enableOrDisable)
6148 {
6149 case WLAN_OFFLOAD_DISABLE:
6150 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6151 break;
6152 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6153 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6154 case WLAN_OFFLOAD_ENABLE:
6155 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6156 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6157 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6158 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6159 }
6160 break;
6161
6162 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006163 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006164 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 switch (pRequest->enableOrDisable)
6166 {
6167 case WLAN_OFFLOAD_DISABLE:
6168 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6169 break;
6170 case WLAN_OFFLOAD_ENABLE:
6171 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6172 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6173 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6174 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6175 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6176 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6177 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6178 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6179 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6180 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6181 }
6182 }
6183
6184 /* Execute offload request. The reason that we can copy the request information
6185 from the ioctl structure to the SME structure is that they are laid out
6186 exactly the same. Otherwise, each piece of information would have to be
6187 copied individually. */
6188 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006189 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6190 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006192 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 __func__);
6194 return -EINVAL;
6195 }
6196
6197 return 0;
6198}
6199
6200static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6201 union iwreq_data *wrqu, char *extra)
6202{
6203 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006204 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 tSirKeepAliveReq keepaliveRequest;
6206
6207 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6208 {
6209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006210 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 return 0;
6212 }
6213
6214 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006215 hddLog(VOS_TRACE_LEVEL_INFO,
6216 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6217 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006218
6219 switch (pRequest->packetType)
6220 {
6221 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006222 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 break;
6224
6225 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6226
Arif Hussain6d2a3322013-11-17 19:50:10 -08006227 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006228 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006229
6230 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6231 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6232 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6233
6234 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6235 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6236 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6237
6238 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6239 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6240 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6241 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6242 break;
6243
6244 }
6245
6246 /* Execute keep alive request. The reason that we can copy the request information
6247 from the ioctl structure to the SME structure is that they are laid out
6248 exactly the same. Otherwise, each piece of information would have to be
6249 copied individually. */
6250 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6251
Arif Hussain6d2a3322013-11-17 19:50:10 -08006252 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006254 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006255 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006257 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 __func__);
6259 return -EINVAL;
6260 }
6261
6262 return 0;
6263}
6264
6265#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006266int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006267 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006268{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006269 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6270 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 int i=0;
6272
6273 if (pHddCtx->cfg_ini->disablePacketFilter)
6274 {
6275 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006276 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 return 0;
6278 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006279 if (pHddCtx->isLogpInProgress)
6280 {
6281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6282 "%s:LOGP in Progress. Ignore!!!", __func__);
6283 return -EBUSY;
6284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 /* Debug display of request components. */
6286 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006287 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006288
6289 switch (pRequest->filterAction)
6290 {
6291 case HDD_RCV_FILTER_SET:
6292 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006293 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006294
6295 packetFilterSetReq.filterId = pRequest->filterId;
6296 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6297 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006298 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 __func__, pRequest->numParams);
6300 return -EINVAL;
6301 }
6302 packetFilterSetReq.numFieldParams = pRequest->numParams;
6303 packetFilterSetReq.coalesceTime = 0;
6304 packetFilterSetReq.filterType = 1;
6305 for (i=0; i < pRequest->numParams; i++)
6306 {
6307 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6308 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6309 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6310 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6311 packetFilterSetReq.paramsData[i].reserved = 0;
6312
Arif Hussain6d2a3322013-11-17 19:50:10 -08006313 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6315 packetFilterSetReq.filterType);
6316
Arif Hussain6d2a3322013-11-17 19:50:10 -08006317 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6319
6320 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6321 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6322 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6323 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6324
Arif Hussain6d2a3322013-11-17 19:50:10 -08006325 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6327 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6328 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6329
Arif Hussain6d2a3322013-11-17 19:50:10 -08006330 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6332 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6333 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6334 }
6335
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006336 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006338 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 __func__);
6340 return -EINVAL;
6341 }
6342
6343 break;
6344
6345 case HDD_RCV_FILTER_CLEAR:
6346
Arif Hussain6d2a3322013-11-17 19:50:10 -08006347 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006348 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006349 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006350 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006352 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 __func__);
6354 return -EINVAL;
6355 }
6356 break;
6357
6358 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006359 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006360 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 return -EINVAL;
6362 }
6363 return 0;
6364}
6365
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306366int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6367 tANI_U8 sessionId)
6368{
6369 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6370 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6371
6372 if (NULL == pHddCtx)
6373 {
6374 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6375 return -EINVAL;
6376 }
6377
6378 if (pHddCtx->isLogpInProgress)
6379 {
6380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6381 "%s:LOGP in Progress. Ignore!!!", __func__);
6382 return -EBUSY;
6383 }
6384
6385 if (pHddCtx->cfg_ini->disablePacketFilter)
6386 {
6387 hddLog(VOS_TRACE_LEVEL_ERROR,
6388 "%s: Packet Filtering Disabled. Returning ",
6389 __func__ );
6390 return -EINVAL;
6391 }
6392
6393 switch (filterType)
6394 {
6395 /* For setting IPV6 MC and UC Filter we need to configure
6396 * 2 filters, one for MC and one for UC.
6397 * The Filter ID shouldn't be swapped, which results in making
6398 * UC Filter ineffective.
6399 * We have Hardcode all the values
6400 *
6401 * Reason for a seperate UC filter is because, driver need to
6402 * specify the FW that the specific filter is for unicast
6403 * otherwise FW will not pass the unicast frames by default
6404 * through the filter. This is required to avoid any performance
6405 * hits when no unicast filter is set and only MC/BC are set.
6406 * The way driver informs host is by using the MAC protocol
6407 * layer, CMP flag set to MAX, CMP Data set to 1.
6408 */
6409
6410 case HDD_FILTER_IPV6_MC_UC:
6411 /* Setting IPV6 MC Filter below
6412 */
6413 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6414 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6415 packetFilterSetReq.numFieldParams = 2;
6416 packetFilterSetReq.paramsData[0].protocolLayer =
6417 HDD_FILTER_PROTO_TYPE_MAC;
6418 packetFilterSetReq.paramsData[0].cmpFlag =
6419 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6420 packetFilterSetReq.paramsData[0].dataOffset =
6421 WLAN_HDD_80211_FRM_DA_OFFSET;
6422 packetFilterSetReq.paramsData[0].dataLength = 1;
6423 packetFilterSetReq.paramsData[0].compareData[0] =
6424 HDD_IPV6_MC_CMP_DATA;
6425
6426 packetFilterSetReq.paramsData[1].protocolLayer =
6427 HDD_FILTER_PROTO_TYPE_ARP;
6428 packetFilterSetReq.paramsData[1].cmpFlag =
6429 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6430 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6431 packetFilterSetReq.paramsData[1].dataLength = 2;
6432 packetFilterSetReq.paramsData[1].compareData[0] =
6433 HDD_IPV6_CMP_DATA_0;
6434 packetFilterSetReq.paramsData[1].compareData[1] =
6435 HDD_IPV6_CMP_DATA_1;
6436
6437
6438 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6439 &packetFilterSetReq, sessionId))
6440 {
6441 hddLog(VOS_TRACE_LEVEL_ERROR,
6442 "%s: Failure to execute Set IPv6 Mulicast Filter",
6443 __func__);
6444 return -EINVAL;
6445 }
6446
6447 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6448
6449 /*
6450 * Setting IPV6 UC Filter below
6451 */
6452 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6453 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6454 packetFilterSetReq.numFieldParams = 2;
6455 packetFilterSetReq.paramsData[0].protocolLayer =
6456 HDD_FILTER_PROTO_TYPE_MAC;
6457 packetFilterSetReq.paramsData[0].cmpFlag =
6458 HDD_FILTER_CMP_TYPE_MAX;
6459 packetFilterSetReq.paramsData[0].dataOffset = 0;
6460 packetFilterSetReq.paramsData[0].dataLength = 1;
6461 packetFilterSetReq.paramsData[0].compareData[0] =
6462 HDD_IPV6_UC_CMP_DATA;
6463
6464 packetFilterSetReq.paramsData[1].protocolLayer =
6465 HDD_FILTER_PROTO_TYPE_ARP;
6466 packetFilterSetReq.paramsData[1].cmpFlag =
6467 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6468 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6469 packetFilterSetReq.paramsData[1].dataLength = 2;
6470 packetFilterSetReq.paramsData[1].compareData[0] =
6471 HDD_IPV6_CMP_DATA_0;
6472 packetFilterSetReq.paramsData[1].compareData[1] =
6473 HDD_IPV6_CMP_DATA_1;
6474
6475 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6476 &packetFilterSetReq, sessionId))
6477 {
6478 hddLog(VOS_TRACE_LEVEL_ERROR,
6479 "%s: Failure to execute Set IPv6 Unicast Filter",
6480 __func__);
6481 return -EINVAL;
6482 }
6483
6484 break;
6485
6486 case HDD_FILTER_IPV6_MC:
6487 /*
6488 * IPV6 UC Filter might be already set,
6489 * clear the UC Filter. As the Filter
6490 * IDs are static, we can directly clear it.
6491 */
6492 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6493 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6494 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6495 &packetFilterClrReq, sessionId))
6496 {
6497 hddLog(VOS_TRACE_LEVEL_ERROR,
6498 "%s: Failure to execute Clear IPv6 Unicast Filter",
6499 __func__);
6500 return -EINVAL;
6501 }
6502
6503 /*
6504 * Setting IPV6 MC Filter below
6505 */
6506 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6507 packetFilterSetReq.numFieldParams = 2;
6508 packetFilterSetReq.paramsData[0].protocolLayer =
6509 HDD_FILTER_PROTO_TYPE_MAC;
6510 packetFilterSetReq.paramsData[0].cmpFlag =
6511 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6512 packetFilterSetReq.paramsData[0].dataOffset =
6513 WLAN_HDD_80211_FRM_DA_OFFSET;
6514 packetFilterSetReq.paramsData[0].dataLength = 1;
6515 packetFilterSetReq.paramsData[0].compareData[0] =
6516 HDD_IPV6_MC_CMP_DATA;
6517
6518 packetFilterSetReq.paramsData[1].protocolLayer =
6519 HDD_FILTER_PROTO_TYPE_ARP;
6520 packetFilterSetReq.paramsData[1].cmpFlag =
6521 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6522 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6523 packetFilterSetReq.paramsData[1].dataLength = 2;
6524 packetFilterSetReq.paramsData[1].compareData[0] =
6525 HDD_IPV6_CMP_DATA_0;
6526 packetFilterSetReq.paramsData[1].compareData[1] =
6527 HDD_IPV6_CMP_DATA_1;
6528
6529
6530 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6531 &packetFilterSetReq, sessionId))
6532 {
6533 hddLog(VOS_TRACE_LEVEL_ERROR,
6534 "%s: Failure to execute Set IPv6 Multicast Filter",
6535 __func__);
6536 return -EINVAL;
6537 }
6538 break;
6539
6540 default :
6541 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6542 "%s: Packet Filter Request: Invalid",
6543 __func__);
6544 return -EINVAL;
6545 }
6546 return 0;
6547}
6548
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306549void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006550{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306551 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306552 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006553 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306554 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006555
Yue Ma3ede6052013-08-29 00:33:26 -07006556 if (NULL == pHddCtx)
6557 {
6558 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6559 return;
6560 }
6561
6562 hHal = pHddCtx->hHal;
6563
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306564 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306566 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6567 return;
6568 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306569
6570 /* Check if INI is enabled or not, other wise just return
6571 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306572 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306573 {
6574 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6575 if (NULL == pMulticastAddrs)
6576 {
6577 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6578 return;
6579 }
6580
Jeff Johnson295189b2012-06-20 16:38:30 -07006581 if (set)
6582 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306583 /* Following pre-conditions should be satisfied before wei
6584 * configure the MC address list.
6585 */
6586 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6587 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6588 && pAdapter->mc_addr_list.mc_cnt
6589 && (eConnectionState_Associated ==
6590 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6591 {
6592 pMulticastAddrs->ulMulticastAddrCnt =
6593 pAdapter->mc_addr_list.mc_cnt;
6594 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6595 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006596 memcpy(pMulticastAddrs->multicastAddr[i],
6597 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306598 sizeof(pAdapter->mc_addr_list.addr[i]));
6599 hddLog(VOS_TRACE_LEVEL_INFO,
6600 "%s: %s multicast filter: addr ="
6601 MAC_ADDRESS_STR,
6602 __func__, set ? "setting" : "clearing",
6603 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6604 }
6605 /* Set multicast filter */
6606 sme_8023MulticastList(hHal, pAdapter->sessionId,
6607 pMulticastAddrs);
6608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306610 else
6611 {
6612 /* Need to clear only if it was previously configured
6613 */
6614 if (pAdapter->mc_addr_list.isFilterApplied)
6615 {
6616 pMulticastAddrs->ulMulticastAddrCnt = 0;
6617 sme_8023MulticastList(hHal, pAdapter->sessionId,
6618 pMulticastAddrs);
6619 }
6620
6621 }
6622 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006623 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306625 else
6626 {
6627 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306628 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306629 }
6630 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006631}
6632
6633static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6634 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306635{
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006637 tpPacketFilterCfg pRequest = NULL;
6638 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006639
Arif Hussain0273cba2014-01-07 20:58:29 -08006640 /* ODD number is used for set, copy data using copy_from_user */
6641 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6642 wrqu->data.length);
6643 if (NULL == pRequest)
6644 {
6645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6646 "mem_alloc_copy_from_user_helper fail");
6647 return -ENOMEM;
6648 }
6649
6650 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6651 kfree(pRequest);
6652
6653 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006654}
6655#endif
6656static int iw_get_statistics(struct net_device *dev,
6657 struct iw_request_info *info,
6658 union iwreq_data *wrqu, char *extra)
6659{
6660
6661 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6662 eHalStatus status = eHAL_STATUS_SUCCESS;
6663 hdd_wext_state_t *pWextState;
6664 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6665 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6666 char *p = extra;
6667 int tlen = 0;
6668 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6669
6670 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6671 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6672
6673 ENTER();
6674
6675 if (pHddCtx->isLogpInProgress) {
6676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6677 return -EINVAL;
6678 }
6679
6680 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6681
6682 wrqu->txpower.value = 0;
6683 }
6684 else {
6685 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6686 SME_SUMMARY_STATS |
6687 SME_GLOBAL_CLASSA_STATS |
6688 SME_GLOBAL_CLASSB_STATS |
6689 SME_GLOBAL_CLASSC_STATS |
6690 SME_GLOBAL_CLASSD_STATS |
6691 SME_PER_STA_STATS,
6692 hdd_StatisticsCB, 0, FALSE,
6693 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6694
6695 if (eHAL_STATUS_SUCCESS != status)
6696 {
6697 hddLog(VOS_TRACE_LEVEL_ERROR,
6698 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006699 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 return -EINVAL;
6701 }
6702
6703 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6704
6705 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6706 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6707 {
6708 hddLog(VOS_TRACE_LEVEL_ERROR,
6709 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006710 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 /*Remove the SME statistics list by passing NULL in callback argument*/
6712 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6713 SME_SUMMARY_STATS |
6714 SME_GLOBAL_CLASSA_STATS |
6715 SME_GLOBAL_CLASSB_STATS |
6716 SME_GLOBAL_CLASSC_STATS |
6717 SME_GLOBAL_CLASSD_STATS |
6718 SME_PER_STA_STATS,
6719 NULL, 0, FALSE,
6720 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6721
6722 return -EINVAL;
6723 }
6724 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6725 (tANI_U8) sizeof (pStats->retry_cnt),
6726 (char*) &(pStats->retry_cnt[0]),
6727 tlen);
6728
6729 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6730 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6731 (char*) &(pStats->multiple_retry_cnt[0]),
6732 tlen);
6733
6734 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6735 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6736 (char*) &(pStats->tx_frm_cnt[0]),
6737 tlen);
6738
6739 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6740 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6741 (char*) &(pStats->rx_frm_cnt),
6742 tlen);
6743
6744 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6745 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6746 (char*) &(pStats->frm_dup_cnt),
6747 tlen);
6748
6749 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6750 (tANI_U8) sizeof (pStats->fail_cnt),
6751 (char*) &(pStats->fail_cnt[0]),
6752 tlen);
6753
6754 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6755 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6756 (char*) &(pStats->rts_fail_cnt),
6757 tlen);
6758
6759 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6760 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6761 (char*) &(pStats->ack_fail_cnt),
6762 tlen);
6763
6764 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6765 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6766 (char*) &(pStats->rts_succ_cnt),
6767 tlen);
6768
6769 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6770 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6771 (char*) &(pStats->rx_discard_cnt),
6772 tlen);
6773
6774 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6775 (tANI_U8) sizeof (pStats->rx_error_cnt),
6776 (char*) &(pStats->rx_error_cnt),
6777 tlen);
6778
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006779 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006780 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006781 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 tlen);
6783
6784 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6785 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6786 (char*) &(dStats->rx_byte_cnt),
6787 tlen);
6788
6789 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6790 (tANI_U8) sizeof (dStats->rx_rate),
6791 (char*) &(dStats->rx_rate),
6792 tlen);
6793
6794 /* Transmit rate, in units of 500 kbit/sec */
6795 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6796 (tANI_U8) sizeof (aStats->tx_rate),
6797 (char*) &(aStats->tx_rate),
6798 tlen);
6799
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006800 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6801 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6802 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006803 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006804 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6805 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6806 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006807 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006808 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6809 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6810 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006811 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006812 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6813 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6814 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006815 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006816 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6817 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6818 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006819 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006820 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6821 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6822 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006823 tlen);
6824
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 wrqu->data.length = tlen;
6826
6827 }
6828
6829 EXIT();
6830
6831 return 0;
6832}
6833
6834
6835#ifdef FEATURE_WLAN_SCAN_PNO
6836
6837/*Max Len for PNO notification*/
6838#define MAX_PNO_NOTIFY_LEN 100
6839void found_pref_network_cb (void *callbackContext,
6840 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6841{
6842 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6843 union iwreq_data wrqu;
6844 char buf[MAX_PNO_NOTIFY_LEN+1];
6845
6846 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6847 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6848
6849 // create the event
6850 memset(&wrqu, 0, sizeof(wrqu));
6851 memset(buf, 0, sizeof(buf));
6852
6853 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6854 pPrefNetworkFoundInd->ssId.ssId,
6855 (unsigned int)pPrefNetworkFoundInd->rssi);
6856
6857 wrqu.data.pointer = buf;
6858 wrqu.data.length = strlen(buf);
6859
6860 // send the event
6861
6862 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6863
6864}
6865
6866
6867/*string based input*/
6868VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6869 union iwreq_data *wrqu, char *extra, int nOffset)
6870{
6871 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006872 /* pnoRequest is a large struct, so we make it static to avoid stack
6873 overflow. This API is only invoked via ioctl, so it is
6874 serialized by the kernel rtnl_lock and hence does not need to be
6875 reentrant */
6876 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 char *ptr;
6878 v_U8_t i,j, ucParams, ucMode;
6879 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6880
6881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6882 "PNO data len %d data %s",
6883 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006884 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006885
6886 if (wrqu->data.length <= nOffset )
6887 {
6888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6889 return VOS_STATUS_E_FAILURE;
6890 }
6891
6892 pnoRequest.enable = 0;
6893 pnoRequest.ucNetworksCount = 0;
6894 /*-----------------------------------------------------------------------
6895 Input is string based and expected to be like this:
6896
6897 <enabled> <netw_count>
6898 for each network:
6899 <ssid_len> <ssid> <authentication> <encryption>
6900 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6901 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6902
6903 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006904 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 -07006905
6906 this translates into:
6907 -----------------------------
6908 enable PNO
6909 look for 2 networks:
6910 test - with authentication type 0 and encryption type 0,
6911 that can be found on 3 channels: 1 6 and 11 ,
6912 SSID bcast type is unknown (directed probe will be sent if AP not found)
6913 and must meet -40dBm RSSI
6914
6915 test2 - with auth and enrytption type 4/4
6916 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6917 bcast type is non-bcast (directed probe will be sent)
6918 and must not meet any RSSI threshold
6919
Jeff Johnson8301aa12013-03-28 14:27:29 -07006920 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006922 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006923
Wilson Yang623f6592013-10-08 16:33:37 -07006924 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6925 {
6926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6927 "PNO enable input is not valid %s",ptr);
6928 return VOS_STATUS_E_FAILURE;
6929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006930
6931 if ( 0 == pnoRequest.enable )
6932 {
6933 /*Disable PNO*/
6934 memset(&pnoRequest, 0, sizeof(pnoRequest));
6935 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6936 pAdapter->sessionId,
6937 found_pref_network_cb, pAdapter);
6938 return VOS_STATUS_SUCCESS;
6939 }
6940
6941 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006942
6943 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6944 {
6945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6946 "PNO count input not valid %s",ptr);
6947 return VOS_STATUS_E_FAILURE;
6948
6949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006950
6951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6952 "PNO enable %d networks count %d offset %d",
6953 pnoRequest.enable,
6954 pnoRequest.ucNetworksCount,
6955 nOffset);
6956
6957 /* Parameters checking:
6958 ucNetworksCount has to be larger than 0*/
6959 if (( 0 == pnoRequest.ucNetworksCount ) ||
6960 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6961 {
6962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6963 return VOS_STATUS_E_FAILURE;
6964 }
6965
6966 ptr += nOffset;
6967
6968 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6969 {
6970
6971 pnoRequest.aNetworks[i].ssId.length = 0;
6972
Wilson Yang623f6592013-10-08 16:33:37 -07006973 ucParams = sscanf(ptr,"%hhu %n",
6974 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6975
6976 if (1 != ucParams)
6977 {
6978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6979 "PNO ssid length input is not valid %s",ptr);
6980 return VOS_STATUS_E_FAILURE;
6981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006982
6983 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6984 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6985 {
6986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6987 "SSID Len %d is not correct for network %d",
6988 pnoRequest.aNetworks[i].ssId.length, i);
6989 return VOS_STATUS_E_FAILURE;
6990 }
6991
6992 /*Advance to SSID*/
6993 ptr += nOffset;
6994
Jeff Johnson8301aa12013-03-28 14:27:29 -07006995 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006996 pnoRequest.aNetworks[i].ssId.length);
6997 ptr += pnoRequest.aNetworks[i].ssId.length;
6998
Jeff Johnson02797792013-10-26 19:17:13 -07006999 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007000 &(pnoRequest.aNetworks[i].authentication),
7001 &(pnoRequest.aNetworks[i].encryption),
7002 &(pnoRequest.aNetworks[i].ucChannelCount),
7003 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007004
Wilson Yang623f6592013-10-08 16:33:37 -07007005 if ( 3 != ucParams )
7006 {
7007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7008 "Incorrect cmd %s",ptr);
7009 return VOS_STATUS_E_FAILURE;
7010 }
7011
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007013 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08007014 "auth %d encry %d channel count %d offset %d",
7015 pnoRequest.aNetworks[i].ssId.length,
7016 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
7017 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7018 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7019 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7020 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7021 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7022 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7023 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7024 pnoRequest.aNetworks[i].authentication,
7025 pnoRequest.aNetworks[i].encryption,
7026 pnoRequest.aNetworks[i].ucChannelCount,
7027 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007028
Jeff Johnson295189b2012-06-20 16:38:30 -07007029 /*Advance to channel list*/
7030 ptr += nOffset;
7031
Wilson Yang623f6592013-10-08 16:33:37 -07007032 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 {
7034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7035 "Incorrect number of channels");
7036 return VOS_STATUS_E_FAILURE;
7037 }
7038
7039 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7040 {
7041 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7042 {
Wilson Yang623f6592013-10-08 16:33:37 -07007043 if (1 != sscanf(ptr,"%hhu %n",
7044 &(pnoRequest.aNetworks[i].aChannels[j]),
7045 &nOffset))
7046 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7047 "PNO network channel input is not valid %s",ptr);
7048 return VOS_STATUS_E_FAILURE;
7049 }
7050 /*Advance to next channel number*/
7051 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 }
7053 }
7054
Jeff Johnson02797792013-10-26 19:17:13 -07007055 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007056 &(pnoRequest.aNetworks[i].bcastNetwType),
7057 &nOffset))
7058 {
7059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7060 "PNO broadcast network type input is not valid %s",ptr);
7061 return VOS_STATUS_E_FAILURE;
7062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007063
7064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7065 "PNO bcastNetwType %d offset %d",
7066 pnoRequest.aNetworks[i].bcastNetwType,
7067 nOffset );
7068
7069 /*Advance to rssi Threshold*/
7070 ptr += nOffset;
7071
Wilson Yang623f6592013-10-08 16:33:37 -07007072 if (1 != sscanf(ptr,"%hhu %n",
7073 &(pnoRequest.aNetworks[i].rssiThreshold),
7074 &nOffset))
7075 {
7076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7077 "PNO rssi threshold input is not valid %s",ptr);
7078 return VOS_STATUS_E_FAILURE;
7079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007080
7081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7082 "PNO rssi %d offset %d",
7083 pnoRequest.aNetworks[i].rssiThreshold,
7084 nOffset );
7085 /*Advance to next network*/
7086 ptr += nOffset;
7087 }/*For ucNetworkCount*/
7088
7089 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007090 &(pnoRequest.scanTimers.ucScanTimersCount),
7091 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007092
7093 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007094 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 {
7096 ptr += nOffset;
7097
Jeff Johnson8301aa12013-03-28 14:27:29 -07007098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7099 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 pnoRequest.scanTimers.ucScanTimersCount,
7101 nOffset );
7102
7103 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7104 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 "Incorrect cmd - too many scan timers");
7107 return VOS_STATUS_E_FAILURE;
7108 }
7109
7110 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7111 {
Jeff Johnson02797792013-10-26 19:17:13 -07007112 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7114 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7115 &nOffset);
7116
Wilson Yang623f6592013-10-08 16:33:37 -07007117 if (2 != ucParams)
7118 {
7119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7120 "Incorrect cmd - diff params then expected %d", ucParams);
7121 return VOS_STATUS_E_FAILURE;
7122 }
7123
Jeff Johnson8301aa12013-03-28 14:27:29 -07007124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7125 "PNO Timer value %d Timer repeat %d offset %d",
7126 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7128 nOffset );
7129
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 ptr += nOffset;
7131 }
7132
7133 }
7134 else
7135 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7137 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7139
7140 /*Scan timers defaults to 5 minutes*/
7141 pnoRequest.scanTimers.ucScanTimersCount = 1;
7142 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7143 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7144 }
7145
Wilson Yang623f6592013-10-08 16:33:37 -07007146 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007147
7148 pnoRequest.modePNO = ucMode;
7149 /*for LA we just expose suspend option*/
7150 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7151 {
7152 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7153 }
7154
7155 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
7156 pAdapter->sessionId,
7157 found_pref_network_cb, pAdapter);
7158
7159 return VOS_STATUS_SUCCESS;
7160}/*iw_set_pno*/
7161
7162VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7163 union iwreq_data *wrqu, char *extra, int nOffset)
7164{
7165 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7166 v_U8_t rssiThreshold = 0;
7167 v_U8_t nRead;
7168
Arif Hussain7adce1b2013-11-11 22:59:34 -08007169 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 &rssiThreshold);
7171
7172 if ( 1 != nRead )
7173 {
7174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7175 "Incorrect format");
7176 return VOS_STATUS_E_FAILURE;
7177 }
7178
7179 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7180 return VOS_STATUS_SUCCESS;
7181}
7182
7183
7184static int iw_set_pno_priv(struct net_device *dev,
7185 struct iw_request_info *info,
7186 union iwreq_data *wrqu, char *extra)
7187{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007188 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7189
7190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007191 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007192
7193 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7194 {
7195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7196 "%s:LOGP in Progress. Ignore!!!", __func__);
7197 return -EBUSY;
7198 }
7199 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007200}
7201#endif /*FEATURE_WLAN_SCAN_PNO*/
7202
7203//Common function to SetBand
7204int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
7205{
7206 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7207 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7208 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7209 tANI_U8 band = 0;
7210 eCsrBand currBand = eCSR_BAND_MAX;
7211
7212 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
7213
7214 switch(band)
7215 {
7216 case WLAN_HDD_UI_BAND_AUTO:
7217 band = eCSR_BAND_ALL;
7218 break;
7219 case WLAN_HDD_UI_BAND_5_GHZ:
7220 band = eCSR_BAND_5G;
7221 break;
7222 case WLAN_HDD_UI_BAND_2_4_GHZ:
7223 band = eCSR_BAND_24;
7224 break;
7225 default:
7226 band = eCSR_BAND_MAX;
7227 }
7228
7229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007230 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007231
7232 if (band == eCSR_BAND_MAX)
7233 {
7234 /* Received change band request with invalid band value */
7235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007236 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 return -EIO;
7238 }
7239
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307240 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7241 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7242 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7243 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007245 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007246 band, pHddCtx->cfg_ini->nBandCapability);
7247 return -EIO;
7248 }
7249
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7251 {
7252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7253 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007254 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 return -EIO;
7256 }
7257
7258 if (currBand != band)
7259 {
7260 /* Change band request received.
7261 * Abort pending scan requests, flush the existing scan results,
7262 * and change the band capability
7263 */
7264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7265 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007266 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007267
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307268 /* We need to change the band and flush the scan results here itself
7269 * as we may get timeout for disconnection in which we will return
7270 * with out doing any of these
7271 */
7272 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7273 {
7274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7275 "%s: failed to set the band value to %u ",
7276 __func__, band);
7277 return -EINVAL;
7278 }
7279 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7280 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7281 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7282 sme_FilterScanResults(hHal, pAdapter->sessionId);
7283
7284 if (band != eCSR_BAND_ALL &&
7285 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 {
7287 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7288 eHalStatus status = eHAL_STATUS_SUCCESS;
7289 long lrc;
7290
7291 /* STA already connected on current band, So issue disconnect first,
7292 * then change the band*/
7293
7294 hddLog(VOS_TRACE_LEVEL_INFO,
7295 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7296 __func__, csrGetCurrentBand(hHal), band);
7297
7298 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7299 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7300
7301 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7302 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7303
Jeff Johnson43971f52012-07-17 12:26:56 -07007304 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 {
7306 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007307 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007308 __func__, (int)status );
7309 return -EINVAL;
7310 }
7311
7312 lrc = wait_for_completion_interruptible_timeout(
7313 &pAdapter->disconnect_comp_var,
7314 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7315
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307316 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007317
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007318 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007319 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007320
7321 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7322 }
7323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 }
7325 return 0;
7326}
7327
7328static int iw_set_band_config(struct net_device *dev,
7329 struct iw_request_info *info,
7330 union iwreq_data *wrqu, char *extra)
7331{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007332 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007333 tANI_U8 *ptr = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 int ret = 0;
7335
Arif Hussain0273cba2014-01-07 20:58:29 -08007336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007337
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007338 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7339 {
7340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7341 "%s:LOGP in Progress. Ignore!!!", __func__);
7342 return -EBUSY;
7343 }
7344
Arif Hussain0273cba2014-01-07 20:58:29 -08007345 /* ODD number is used for set, copy data using copy_from_user */
7346 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7347 wrqu->data.length);
7348 if (NULL == ptr)
7349 {
7350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7351 "mem_alloc_copy_from_user_helper fail");
7352 return -ENOMEM;
7353 }
7354
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 if (memcmp(ptr, "SETBAND ", 8) == 0)
7356 {
7357 /* Change band request received */
7358 ret = hdd_setBand_helper(dev, ptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 }
Arif Hussain0273cba2014-01-07 20:58:29 -08007360 kfree(ptr);
7361
7362 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007363}
7364
7365static int iw_set_power_params_priv(struct net_device *dev,
7366 struct iw_request_info *info,
7367 union iwreq_data *wrqu, char *extra)
7368{
Arif Hussain0273cba2014-01-07 20:58:29 -08007369 int ret;
7370 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7372 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007373 /* ODD number is used for set, copy data using copy_from_user */
7374 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7375 wrqu->data.length);
7376 if (NULL == ptr)
7377 {
7378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7379 "mem_alloc_copy_from_user_helper fail");
7380 return -ENOMEM;
7381 }
7382
7383 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7384 kfree(ptr);
7385 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007386}
7387
7388
7389
7390/*string based input*/
7391VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7392 union iwreq_data *wrqu, char *extra, int nOffset)
7393{
7394 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7395 tSirSetPowerParamsReq powerRequest;
7396 char *ptr;
7397 v_U8_t ucType;
7398 v_U32_t uTotalSize, uValue;
7399 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7400
7401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7402 "Power Params data len %d data %s",
7403 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007404 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007405
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007406 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7407 {
7408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7409 "%s:LOGP in Progress. Ignore!!!", __func__);
7410 return -EBUSY;
7411 }
7412
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 if (wrqu->data.length <= nOffset )
7414 {
7415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7416 return VOS_STATUS_E_FAILURE;
7417 }
7418
7419 uTotalSize = wrqu->data.length - nOffset;
7420
7421 /*-----------------------------------------------------------------------
7422 Input is string based and expected to be like this:
7423
7424 <param_type> <param_value> <param_type> <param_value> ...
7425
7426 e.g:
7427 1 2 2 3 3 0 4 1 5 1
7428
7429 e.g. setting just a few:
7430 1 2 4 1
7431
7432 parameter types:
7433 -----------------------------
7434 1 - Ignore DTIM
7435 2 - Listen Interval
7436 3 - Broadcast Multicas Filter
7437 4 - Beacon Early Termination
7438 5 - Beacon Early Termination Interval
7439 -----------------------------------------------------------------------*/
7440 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7441 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7442 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7443 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7444 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7445
Arif Hussain7adce1b2013-11-11 22:59:34 -08007446 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007447
7448 while ( uTotalSize )
7449 {
Wilson Yang6f971452013-10-08 15:00:00 -07007450 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7451 {
7452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7453 "Invalid input parameter type %s",ptr);
7454 return VOS_STATUS_E_FAILURE;
7455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007456
7457 uTotalSize -= nOffset;
7458
7459 if (!uTotalSize)
7460 {
7461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007462 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 ucType, nOffset);
7464 return VOS_STATUS_E_FAILURE;
7465 }
7466
7467 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007468
Jeff Johnson02797792013-10-26 19:17:13 -07007469 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007470 {
7471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7472 "Invalid input parameter value %s",ptr);
7473 return VOS_STATUS_E_FAILURE;
7474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007475
7476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7477 "Power request parameter %d value %d offset %d",
7478 ucType, uValue, nOffset);
7479
7480 switch (ucType)
7481 {
7482 case eSIR_IGNORE_DTIM:
7483 powerRequest.uIgnoreDTIM = uValue;
7484 break;
7485 case eSIR_LISTEN_INTERVAL:
7486 powerRequest.uListenInterval = uValue;
7487 break;
7488 case eSIR_MCAST_BCAST_FILTER:
7489 powerRequest.uBcastMcastFilter = uValue;
7490 break;
7491 case eSIR_ENABLE_BET:
7492 powerRequest.uEnableBET = uValue;
7493 break;
7494 case eSIR_BET_INTERVAL:
7495 powerRequest.uBETInterval = uValue;
7496 break;
7497 default:
7498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007499 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 ucType, uValue, nOffset);
7501 return VOS_STATUS_E_FAILURE;
7502 }
7503
7504 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7506 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007507 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007509 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007510 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007511 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7512 {
7513 uTotalSize = 0;
7514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007515
7516 }/*Go for as long as we have a valid string*/
7517
7518 /* put the device into full power*/
7519 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7520
7521 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007522 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007523
7524 /* put the device back to power save*/
7525 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7526
7527 return VOS_STATUS_SUCCESS;
7528}/*iw_set_power_params*/
7529
7530
7531// Define the Wireless Extensions to the Linux Network Device structure
7532// A number of these routines are NULL (meaning they are not implemented.)
7533
7534static const iw_handler we_handler[] =
7535{
7536 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7537 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7538 (iw_handler) NULL, /* SIOCSIWNWID */
7539 (iw_handler) NULL, /* SIOCGIWNWID */
7540 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7541 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7542 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7543 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7544 (iw_handler) NULL, /* SIOCSIWSENS */
7545 (iw_handler) NULL, /* SIOCGIWSENS */
7546 (iw_handler) NULL, /* SIOCSIWRANGE */
7547 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7548 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7549 (iw_handler) NULL, /* SIOCGIWPRIV */
7550 (iw_handler) NULL, /* SIOCSIWSTATS */
7551 (iw_handler) NULL, /* SIOCGIWSTATS */
7552 iw_handler_set_spy, /* SIOCSIWSPY */
7553 iw_handler_get_spy, /* SIOCGIWSPY */
7554 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7555 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7556 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7557 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7558 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7559 (iw_handler) NULL, /* SIOCGIWAPLIST */
7560 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7561 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7562 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7563 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7564 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7565 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7566 (iw_handler) NULL, /* -- hole -- */
7567 (iw_handler) NULL, /* -- hole -- */
7568 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7569 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7570 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7571 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7572 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7573 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7574 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7575 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7576 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7577 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7578 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7579 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7580 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7581 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7582 (iw_handler) NULL, /* -- hole -- */
7583 (iw_handler) NULL, /* -- hole -- */
7584 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7585 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7586 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7587 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7588 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7589 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7590 (iw_handler) NULL, /* SIOCSIWPMKSA */
7591};
7592
7593static const iw_handler we_private[] = {
7594
7595 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7596 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7597 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7598 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7599 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7600 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7601 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7602 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7603 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7604 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007605#ifdef FEATURE_OEM_DATA_SUPPORT
7606 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7607 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7608#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
7610#ifdef FEATURE_WLAN_WAPI
7611 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7612 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7613 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7614 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7615 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7616 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7617#endif /* FEATURE_WLAN_WAPI */
7618#ifdef WLAN_FEATURE_VOWIFI_11R
7619 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7620#endif
7621 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7622 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7623 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7624#ifdef WLAN_FEATURE_PACKET_FILTERING
7625 ,
7626 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7627#endif
7628#ifdef FEATURE_WLAN_SCAN_PNO
7629 ,
7630 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7631#endif
7632 ,
7633 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7634 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7635 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7636 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007637 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007638};
7639
7640/*Maximum command length can be only 15 */
7641static const struct iw_priv_args we_private_args[] = {
7642
7643 /* handlers for main ioctl */
7644 { WLAN_PRIV_SET_INT_GET_NONE,
7645 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7646 0,
7647 "" },
7648
7649 /* handlers for sub-ioctl */
7650 { WE_SET_11D_STATE,
7651 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7652 0,
7653 "set11Dstate" },
7654
7655 { WE_WOWL,
7656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7657 0,
7658 "wowl" },
7659
7660 { WE_SET_POWER,
7661 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7662 0,
7663 "setPower" },
7664
7665 { WE_SET_MAX_ASSOC,
7666 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7667 0,
7668 "setMaxAssoc" },
7669
7670 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7671 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7672 0,
7673 "setAutoChannel" },
7674
7675 { WE_SET_DATA_INACTIVITY_TO,
7676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7677 0,
7678 "inactivityTO" },
7679
7680 { WE_SET_MAX_TX_POWER,
7681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7682 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007683 "setMaxTxPower" },
7684
7685 { WE_SET_MAX_TX_POWER_2_4,
7686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7687 0,
7688 "setTxMaxPower2G" },
7689
7690 { WE_SET_MAX_TX_POWER_5_0,
7691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7692 0,
7693 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007694
7695 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7696 * as well to keep same syntax as in SAP. Now onwards, STA
7697 * will support both */
7698 { WE_SET_MAX_TX_POWER,
7699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7700 0,
7701 "setTxMaxPower" },
7702
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7704 * 1 = enable and 0 = disable */
7705 {
7706 WE_SET_HIGHER_DTIM_TRANSITION,
7707 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7708 0,
7709 "setHDtimTransn" },
7710
7711 { WE_SET_TM_LEVEL,
7712 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007713 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007714 "setTmLevel" },
7715
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307716 { WE_ENABLE_STRICT_FCC_REG,
7717 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7718 0,
7719 "setStrictFCCreg" },
7720
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007721 { WE_SET_DEBUG_LOG,
7722 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7723 0, "setDbgLvl" },
7724
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 /* handlers for main ioctl */
7726 { WLAN_PRIV_SET_NONE_GET_INT,
7727 0,
7728 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7729 "" },
7730
7731 /* handlers for sub-ioctl */
7732 { WE_GET_11D_STATE,
7733 0,
7734 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7735 "get11Dstate" },
7736
7737 { WE_IBSS_STATUS,
7738 0,
7739 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7740 "getAdhocStatus" },
7741
7742 { WE_PMC_STATE,
7743 0,
7744 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7745 "pmcState" },
7746
7747 { WE_GET_WLAN_DBG,
7748 0,
7749 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7750 "getwlandbg" },
7751
7752 { WE_MODULE_DOWN_IND,
7753 0,
7754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7755 "moduleDownInd" },
7756
7757 { WE_GET_MAX_ASSOC,
7758 0,
7759 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7760 "getMaxAssoc" },
7761
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 { WE_GET_WDI_DBG,
7763 0,
7764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7765 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007766
7767 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7768 0,
7769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7770 "getAutoChannel" },
7771
7772 { WE_GET_CONCURRENCY_MODE,
7773 0,
7774 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7775 "getconcurrency" },
7776
7777 /* handlers for main ioctl */
7778 { WLAN_PRIV_SET_CHAR_GET_NONE,
7779 IW_PRIV_TYPE_CHAR| 512,
7780 0,
7781 "" },
7782
7783 /* handlers for sub-ioctl */
7784 { WE_WOWL_ADD_PTRN,
7785 IW_PRIV_TYPE_CHAR| 512,
7786 0,
7787 "wowlAddPtrn" },
7788
7789 { WE_WOWL_DEL_PTRN,
7790 IW_PRIV_TYPE_CHAR| 512,
7791 0,
7792 "wowlDelPtrn" },
7793
7794#if defined WLAN_FEATURE_VOWIFI
7795 /* handlers for sub-ioctl */
7796 { WE_NEIGHBOR_REPORT_REQUEST,
7797 IW_PRIV_TYPE_CHAR | 512,
7798 0,
7799 "neighbor" },
7800#endif
7801 { WE_SET_AP_WPS_IE,
7802 IW_PRIV_TYPE_CHAR| 512,
7803 0,
7804 "set_ap_wps_ie" },
7805
7806 { WE_SET_CONFIG,
7807 IW_PRIV_TYPE_CHAR| 512,
7808 0,
7809 "setConfig" },
7810
7811 /* handlers for main ioctl */
7812 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7813 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7814 0,
7815 "" },
7816
7817 /* handlers for sub-ioctl */
7818 { WE_SET_WLAN_DBG,
7819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7820 0,
7821 "setwlandbg" },
7822
Jeff Johnson295189b2012-06-20 16:38:30 -07007823 { WE_SET_WDI_DBG,
7824 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7825 0,
7826 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007827
7828 { WE_SET_SAP_CHANNELS,
7829 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7830 0,
7831 "setsapchannels" },
7832
7833 /* handlers for main ioctl */
7834 { WLAN_PRIV_GET_CHAR_SET_NONE,
7835 0,
7836 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7837 "" },
7838
7839 /* handlers for sub-ioctl */
7840 { WE_WLAN_VERSION,
7841 0,
7842 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7843 "version" },
7844 { WE_GET_STATS,
7845 0,
7846 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7847 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307848 { WE_GET_STATES,
7849 0,
7850 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7851 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 { WE_GET_CFG,
7853 0,
7854 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7855 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007856#ifdef WLAN_FEATURE_11AC
7857 { WE_GET_RSSI,
7858 0,
7859 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7860 "getRSSI" },
7861#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007862#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007863 { WE_GET_ROAM_RSSI,
7864 0,
7865 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7866 "getRoamRSSI" },
7867#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 { WE_GET_WMM_STATUS,
7869 0,
7870 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7871 "getWmmStatus" },
7872 {
7873 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307874 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7876 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007877#ifdef FEATURE_WLAN_TDLS
7878 {
7879 WE_GET_TDLS_PEERS,
7880 0,
7881 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7882 "getTdlsPeers" },
7883#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007884#ifdef WLAN_FEATURE_11W
7885 {
7886 WE_GET_11W_INFO,
7887 0,
7888 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7889 "getPMFInfo" },
7890#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007891 /* handlers for main ioctl */
7892 { WLAN_PRIV_SET_NONE_GET_NONE,
7893 0,
7894 0,
7895 "" },
7896
7897 /* handlers for sub-ioctl */
7898 { WE_CLEAR_STATS,
7899 0,
7900 0,
7901 "clearStats" },
7902 { WE_INIT_AP,
7903 0,
7904 0,
7905 "initAP" },
7906 { WE_STOP_AP,
7907 0,
7908 0,
7909 "exitAP" },
7910 { WE_ENABLE_AMP,
7911 0,
7912 0,
7913 "enableAMP" },
7914 { WE_DISABLE_AMP,
7915 0,
7916 0,
7917 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007918 { WE_ENABLE_DXE_STALL_DETECT,
7919 0,
7920 0,
7921 "dxeStallDetect" },
7922 { WE_DISPLAY_DXE_SNAP_SHOT,
7923 0,
7924 0,
7925 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307926 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7927 0,
7928 0,
7929 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007930 {
7931 WE_SET_REASSOC_TRIGGER,
7932 0,
7933 0,
7934 "reassoc" },
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307935 {
7936 WE_STOP_OBSS_SCAN,
7937 0,
7938 0,
7939 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007940
7941 /* handlers for main ioctl */
7942 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7943 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7944 0,
7945 "" },
7946
7947 /* handlers for sub-ioctl */
7948 { WE_LOG_DUMP_CMD,
7949 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7950 0,
7951 "dump" },
7952
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007953 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307954 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
7955 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7956 0,
7957 "setdumplog" },
7958
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007959 { WE_MTRACE_DUMP_CMD,
7960 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7961 0,
7962 "dumplog" },
7963
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007964 /* handlers for sub ioctl */
7965 {
7966 WE_MCC_CONFIG_CREDENTIAL,
7967 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7968 0,
7969 "setMccCrdnl" },
7970
7971 /* handlers for sub ioctl */
7972 {
7973 WE_MCC_CONFIG_PARAMS,
7974 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7975 0,
7976 "setMccConfig" },
7977
Chilam NG571c65a2013-01-19 12:27:36 +05307978#ifdef FEATURE_WLAN_TDLS
7979 /* handlers for sub ioctl */
7980 {
7981 WE_TDLS_CONFIG_PARAMS,
7982 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7983 0,
7984 "setTdlsConfig" },
7985#endif
7986
Jeff Johnson295189b2012-06-20 16:38:30 -07007987 /* handlers for main ioctl */
7988 { WLAN_PRIV_ADD_TSPEC,
7989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7990 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7991 "addTspec" },
7992
7993 /* handlers for main ioctl */
7994 { WLAN_PRIV_DEL_TSPEC,
7995 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7996 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7997 "delTspec" },
7998
7999 /* handlers for main ioctl */
8000 { WLAN_PRIV_GET_TSPEC,
8001 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8003 "getTspec" },
8004
Jeff Johnsone7245742012-09-05 17:12:55 -07008005#ifdef FEATURE_OEM_DATA_SUPPORT
8006 /* handlers for main ioctl - OEM DATA */
8007 {
8008 WLAN_PRIV_SET_OEM_DATA_REQ,
8009 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8010 0,
8011 "set_oem_data_req" },
8012
8013 /* handlers for main ioctl - OEM DATA */
8014 {
8015 WLAN_PRIV_GET_OEM_DATA_RSP,
8016 0,
8017 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8018 "get_oem_data_rsp" },
8019#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008020
8021#ifdef FEATURE_WLAN_WAPI
8022 /* handlers for main ioctl SET_WAPI_MODE */
8023 { WLAN_PRIV_SET_WAPI_MODE,
8024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8025 0,
8026 "SET_WAPI_MODE" },
8027
8028 /* handlers for main ioctl GET_WAPI_MODE */
8029 { WLAN_PRIV_GET_WAPI_MODE,
8030 0,
8031 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8032 "GET_WAPI_MODE" },
8033
8034 /* handlers for main ioctl SET_ASSOC_INFO */
8035 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
8036 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
8037 0,
8038 "SET_WAPI_ASSOC" },
8039
8040 /* handlers for main ioctl SET_WAPI_KEY */
8041 { WLAN_PRIV_SET_WAPI_KEY,
8042 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8043 0,
8044 "SET_WAPI_KEY" },
8045
8046 /* handlers for main ioctl SET_WAPI_BKID */
8047 { WLAN_PRIV_SET_WAPI_BKID,
8048 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8049 0,
8050 "SET_WAPI_BKID" },
8051
8052 /* handlers for main ioctl GET_WAPI_BKID */
8053 { WLAN_PRIV_GET_WAPI_BKID,
8054 0,
8055 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8056 "GET_WAPI_BKID" },
8057#endif /* FEATURE_WLAN_WAPI */
8058
8059 /* handlers for main ioctl - host offload */
8060 {
8061 WLAN_PRIV_SET_HOST_OFFLOAD,
8062 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8063 0,
8064 "setHostOffload" },
8065
8066 {
8067 WLAN_GET_WLAN_STATISTICS,
8068 0,
8069 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8070 "getWlanStats" },
8071
8072 {
8073 WLAN_SET_KEEPALIVE_PARAMS,
8074 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8075 0,
8076 "setKeepAlive" },
8077#ifdef WLAN_FEATURE_PACKET_FILTERING
8078 {
8079 WLAN_SET_PACKET_FILTER_PARAMS,
8080 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8081 0,
8082 "setPktFilter" },
8083#endif
8084#ifdef FEATURE_WLAN_SCAN_PNO
8085 {
8086 WLAN_SET_PNO,
8087 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8088 0,
8089 "setpno" },
8090#endif
8091 {
8092 WLAN_SET_BAND_CONFIG,
8093 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8094 0,
8095 "SETBAND" },
8096 /* handlers for dynamic MC BC ioctl */
8097 {
8098 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008099 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 0,
8101 "setMCBCFilter" },
8102 {
8103 WLAN_PRIV_CLEAR_MCBC_FILTER,
8104 0,
8105 0,
8106 "clearMCBCFilter" },
8107 {
8108 WLAN_SET_POWER_PARAMS,
8109 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8110 0,
8111 "setpowerparams" },
8112 {
8113 WLAN_GET_LINK_SPEED,
8114 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308115 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008116};
8117
8118
8119
8120const struct iw_handler_def we_handler_def = {
8121 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8122 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8123 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8124
8125 .standard = (iw_handler *)we_handler,
8126 .private = (iw_handler *)we_private,
8127 .private_args = we_private_args,
8128 .get_wireless_stats = get_wireless_stats,
8129};
8130
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008131int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8132{
8133 v_U32_t cmd = 288; //Command to RIVA
8134 hdd_context_t *pHddCtx = NULL;
8135 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8136 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8137 /*
8138 *configMccParam : specify the bit which needs to be modified
8139 *allowed to update based on wlan_qcom_cfg.ini
8140 * configuration
8141 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8142 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8143 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8144 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8145 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8146 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8147 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8148 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8149 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8150 * Bit 9 : Reserved
8151 */
8152 switch (arg1)
8153 {
8154 //Update MCC SCHEDULE_TIME_SLICE parameter
8155 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8156 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8157 {
8158 if((arg2 >= 5) && (arg2 <= 20))
8159 {
8160 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8161 }
8162 else
8163 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008164 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008165 return 0;
8166 }
8167 }
8168 break;
8169
8170 //Update MCC MAX_NULL_SEND_TIME parameter
8171 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8172 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8173 {
8174 if((arg2 >= 1) && (arg2 <= 10))
8175 {
8176 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8177 }
8178 else
8179 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008180 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008181 return 0;
8182 }
8183 }
8184 break;
8185
8186 //Update MCC TX_EARLY_STOP_TIME parameter
8187 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8188 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8189 {
8190 if((arg2 >= 1) && (arg2 <= 10))
8191 {
8192 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8193 }
8194 else
8195 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008196 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008197 return 0;
8198 }
8199 }
8200 break;
8201
8202 //Update MCC RX_DRAIN_TIME parameter
8203 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8204 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8205 {
8206 if((arg2 >= 1) && (arg2 <= 10))
8207 {
8208 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8209 }
8210 else
8211 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008212 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008213 return 0;
8214 }
8215 }
8216 break;
8217
8218 //Update MCC CHANNEL_SWITCH_TIME parameter
8219 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8220 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8221 {
8222 if((arg2 >= 1) && (arg2 <= 20))
8223 {
8224 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8225 }
8226 else
8227 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008228 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008229 return 0;
8230 }
8231 }
8232 break;
8233
8234 //Update MCC MIN_CHANNEL_TIME parameter
8235 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8236 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8237 {
8238 if((arg2 >= 5) && (arg2 <= 20))
8239 {
8240 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8241 }
8242 else
8243 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008244 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008245 return 0;
8246 }
8247 }
8248 break;
8249
8250 //Update MCC PARK_BEFORE_TBTT parameter
8251 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8252 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8253 {
8254 if((arg2 >= 1) && (arg2 <= 5))
8255 {
8256 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8257 }
8258 else
8259 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008260 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008261 return 0;
8262 }
8263 }
8264 break;
8265
8266 //Update MCC MIN_AFTER_DTIM parameter
8267 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8268 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8269 {
8270 if((arg2 >= 5) && (arg2 <= 15))
8271 {
8272 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8273 }
8274 else
8275 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008276 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008277 return 0;
8278 }
8279 }
8280 break;
8281
8282 //Update MCC TOO_CLOSE_MARGIN parameter
8283 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8284 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8285 {
8286 if((arg2 >= 1) && (arg2 <= 3))
8287 {
8288 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8289 }
8290 else
8291 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008292 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008293 return 0;
8294 }
8295 }
8296 break;
8297
8298 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008299 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008300 __FUNCTION__,arg1);
8301 break;
8302 }
8303 return 0;
8304}
8305
Jeff Johnson295189b2012-06-20 16:38:30 -07008306int hdd_set_wext(hdd_adapter_t *pAdapter)
8307{
8308 hdd_wext_state_t *pwextBuf;
8309 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008310 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008311
8312 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8313
8314 // Now configure the roaming profile links. To SSID and bssid.
8315 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8316 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8317
8318 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8319 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8320
8321 /*Set the numOfChannels to zero to scan all the channels*/
8322 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8323 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8324
8325 /* Default is no encryption */
8326 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8327 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8328
8329 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8330 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8331
8332 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8333
8334 /* Default is no authentication */
8335 pwextBuf->roamProfile.AuthType.numEntries = 1;
8336 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8337
8338 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8339 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8340
8341 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008342 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008343
8344 hdd_clearRoamProfileIe(pAdapter);
8345
8346 return VOS_STATUS_SUCCESS;
8347
8348 }
8349
8350int hdd_register_wext(struct net_device *dev)
8351 {
8352 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8353 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8354 VOS_STATUS status;
8355
8356 ENTER();
8357
8358 // Zero the memory. This zeros the profile structure.
8359 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8360
8361 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8362
8363
8364 status = hdd_set_wext(pAdapter);
8365
8366 if(!VOS_IS_STATUS_SUCCESS(status)) {
8367
Arif Hussain6d2a3322013-11-17 19:50:10 -08008368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 return eHAL_STATUS_FAILURE;
8370 }
8371
8372 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8373 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 return eHAL_STATUS_FAILURE;
8376 }
8377
8378 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8379 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 return eHAL_STATUS_FAILURE;
8382 }
8383
8384 // Register as a wireless device
8385 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8386
8387 EXIT();
8388 return 0;
8389}
8390
8391int hdd_UnregisterWext(struct net_device *dev)
8392{
8393#if 0
8394 hdd_wext_state_t *wextBuf;
8395 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8396
8397 ENTER();
8398 // Set up the pointer to the Wireless Extensions state structure
8399 wextBuf = pAdapter->pWextState;
8400
8401 // De-allocate the Wireless Extensions state structure
8402 kfree(wextBuf);
8403
8404 // Clear out the pointer to the Wireless Extensions state structure
8405 pAdapter->pWextState = NULL;
8406
8407 EXIT();
8408#endif
8409 dev->wireless_handlers = NULL;
8410 return 0;
8411}
8412
8413