blob: 851eea2eba76f22515baf262e39a83ba20f49854 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/** ------------------------------------------------------------------------ *
31 ------------------------------------------------------------------------ *
32
33
34 \file wlan_hdd_wext.c
35
36 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
37 interfaces.
38
39 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041 This file defines all of the types that are utilized by the CCP module
42 of the "Portable" HDD. This file also includes the underlying Linux
43 Wireless Extensions Data types referred to by CCP.
44
45 ======================================================================== */
46
47#include <linux/version.h>
48#include <linux/module.h>
49#include <linux/kernel.h>
50#include <linux/init.h>
51#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053052#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include <wlan_hdd_includes.h>
54#include <wlan_btc_svc.h>
55#include <wlan_nlink_common.h>
56#ifdef WLAN_BTAMP_FEATURE
57#include <bap_hdd_main.h>
58#endif
59#include <vos_api.h>
60#include <net/arp.h>
61#include "ccmApi.h"
62#include "sirParams.h"
63#include "csrApi.h"
64#include "csrInsideApi.h"
65#if defined WLAN_FEATURE_VOWIFI
66#include "smeRrmInternal.h"
67#endif
68#include <aniGlobal.h>
69#include "dot11f.h"
70#include <wlan_hdd_wowl.h>
71#include <wlan_hdd_cfg.h>
72#include <wlan_hdd_wmm.h>
73#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053075#ifdef FEATURE_WLAN_TDLS
76#include "wlan_hdd_tdls.h"
77#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070078
79#ifdef CONFIG_HAS_EARLYSUSPEND
80#include <linux/earlysuspend.h>
81#endif
82#include "wlan_hdd_power.h"
83#include "qwlan_version.h"
84#include <vos_power.h>
85#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
105#ifdef CONFIG_HAS_EARLYSUSPEND
106extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
107extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
108#endif
109
Jeff Johnsone7245742012-09-05 17:12:55 -0700110#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800111#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700112#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700113
114#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530115#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700119static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122/* To Validate Channel against the Frequency and Vice-Versa */
123static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
124 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
125 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
126 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
127 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
128 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
129 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
130 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800131 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
132 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800134#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136/* Private ioctls and their sub-ioctls */
137#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
138#define WE_SET_11D_STATE 1
139#define WE_WOWL 2
140#define WE_SET_POWER 3
141#define WE_SET_MAX_ASSOC 4
142#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
143#define WE_SET_DATA_INACTIVITY_TO 6
144#define WE_SET_MAX_TX_POWER 7
145#define WE_SET_HIGHER_DTIM_TRANSITION 8
146#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530147#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700148#define WE_SET_MAX_TX_POWER_2_4 11
149#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800150/* Private IOCTL for debug connection issues */
151#define WE_SET_DEBUG_LOG 13
Jeff Johnson295189b2012-06-20 16:38:30 -0700152
153/* Private ioctls and their sub-ioctls */
154#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
155#define WE_GET_11D_STATE 1
156#define WE_IBSS_STATUS 2
157#define WE_PMC_STATE 3
158#define WE_GET_WLAN_DBG 4
159#define WE_MODULE_DOWN_IND 5
160#define WE_GET_MAX_ASSOC 6
161#define WE_GET_WDI_DBG 7
162#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
163#define WE_GET_CONCURRENCY_MODE 9
164/* Private ioctls and their sub-ioctls */
165#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
166
167/* Private ioctls and their sub-ioctls */
168#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
169#define WE_WOWL_ADD_PTRN 1
170#define WE_WOWL_DEL_PTRN 2
171#if defined WLAN_FEATURE_VOWIFI
172#define WE_NEIGHBOR_REPORT_REQUEST 3
173#endif
174#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
175#define WE_SET_CONFIG 5
176
177/* Private ioctls and their sub-ioctls */
178#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
179#define WE_SET_WLAN_DBG 1
180#define WE_SET_WDI_DBG 2
181#define WE_SET_SAP_CHANNELS 3
182
183/* Private ioctls and their sub-ioctls */
184#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
185#define WE_WLAN_VERSION 1
186#define WE_GET_STATS 2
187#define WE_GET_CFG 3
188#define WE_GET_WMM_STATUS 4
189#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700190#ifdef WLAN_FEATURE_11AC
191#define WE_GET_RSSI 6
192#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800193#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800194#ifdef FEATURE_WLAN_TDLS
195#define WE_GET_TDLS_PEERS 8
196#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700197#ifdef WLAN_FEATURE_11W
198#define WE_GET_11W_INFO 9
199#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530200#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202/* Private ioctls and their sub-ioctls */
203#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
204#define WE_CLEAR_STATS 1
205#define WE_INIT_AP 2
206#define WE_STOP_AP 3
207#define WE_ENABLE_AMP 4
208#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700209#define WE_ENABLE_DXE_STALL_DETECT 6
210#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530211#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700212#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530213#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700214
215/* Private ioctls and their sub-ioctls */
216#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
217#define WE_LOG_DUMP_CMD 1
218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800220//IOCTL to configure MCC params
221#define WE_MCC_CONFIG_CREDENTIAL 3
222#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
Chilam NG571c65a2013-01-19 12:27:36 +0530224#ifdef FEATURE_WLAN_TDLS
225#define WE_TDLS_CONFIG_PARAMS 5
226#endif
227
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700228#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530229#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700230
Chilam Ng01120412013-02-19 18:32:21 -0800231#ifdef FEATURE_WLAN_TDLS
232#undef MAX_VAR_ARGS
233#define MAX_VAR_ARGS 10
234#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700235#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800236#endif
237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
239/* Private ioctls (with no sub-ioctls) */
240/* note that they must be odd so that they have "get" semantics */
241#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
242#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
243#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
244
245#ifdef FEATURE_WLAN_WAPI
246/* Private ioctls EVEN NO: SET, ODD NO:GET */
247#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
248#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
249#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
250#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
251#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
252#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
253#define WAPI_PSK_AKM_SUITE 0x02721400
254#define WAPI_CERT_AKM_SUITE 0x01721400
255#endif
256
Jeff Johnsone7245742012-09-05 17:12:55 -0700257#ifdef FEATURE_OEM_DATA_SUPPORT
258/* Private ioctls for setting the measurement configuration */
259#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
260#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
261#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700262
263#ifdef WLAN_FEATURE_VOWIFI_11R
264#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
265#endif
266
267/* Private ioctl for setting the host offload feature */
268#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
269
270/* Private ioctl to get the statistics */
271#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
272
273/* Private ioctl to set the Keep Alive Params */
274#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
275#ifdef WLAN_FEATURE_PACKET_FILTERING
276/* Private ioctl to set the Packet Filtering Params */
277#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
278#endif
279
280#ifdef FEATURE_WLAN_SCAN_PNO
281/* Private ioctl to get the statistics */
282#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
283#endif
284
285#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
286
287#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
288#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700289/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700290
Jeff Johnson295189b2012-06-20 16:38:30 -0700291#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
292#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
293
294#define WLAN_STATS_INVALID 0
295#define WLAN_STATS_RETRY_CNT 1
296#define WLAN_STATS_MUL_RETRY_CNT 2
297#define WLAN_STATS_TX_FRM_CNT 3
298#define WLAN_STATS_RX_FRM_CNT 4
299#define WLAN_STATS_FRM_DUP_CNT 5
300#define WLAN_STATS_FAIL_CNT 6
301#define WLAN_STATS_RTS_FAIL_CNT 7
302#define WLAN_STATS_ACK_FAIL_CNT 8
303#define WLAN_STATS_RTS_SUC_CNT 9
304#define WLAN_STATS_RX_DISCARD_CNT 10
305#define WLAN_STATS_RX_ERROR_CNT 11
306#define WLAN_STATS_TX_BYTE_CNT 12
307
308#define WLAN_STATS_RX_BYTE_CNT 13
309#define WLAN_STATS_RX_RATE 14
310#define WLAN_STATS_TX_RATE 15
311
Jeff Johnsone7245742012-09-05 17:12:55 -0700312#define WLAN_STATS_RX_UC_BYTE_CNT 16
313#define WLAN_STATS_RX_MC_BYTE_CNT 17
314#define WLAN_STATS_RX_BC_BYTE_CNT 18
315#define WLAN_STATS_TX_UC_BYTE_CNT 19
316#define WLAN_STATS_TX_MC_BYTE_CNT 20
317#define WLAN_STATS_TX_BC_BYTE_CNT 21
318
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800319#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
320 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
321 { \
322 *__p++ = __type; \
323 *__p++ = __size; \
324 memcpy(__p, __val, __size); \
325 __p += __size; \
326 __tlen += __size + 2; \
327 } \
328 else \
329 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800330 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800331 } \
332 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700333
334#define VERSION_VALUE_MAX_LEN 32
335
336#define TX_PER_TRACKING_DEFAULT_RATIO 5
337#define TX_PER_TRACKING_MAX_RATIO 10
338#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
339
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530340#define WLAN_ADAPTER 0
341#define P2P_ADAPTER 1
342
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800343/*MCC Configuration parameters */
344enum {
345 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
346 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
347 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
348 MCC_RX_DRAIN_TIME_CFG_PARAM,
349 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
350 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
351 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
352 MCC_MIN_AFTER_DTIM_CFG_PARAM,
353 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
354};
355
356int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
357 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800360int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700361 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700362#endif
363
Jeff Johnson295189b2012-06-20 16:38:30 -0700364/**---------------------------------------------------------------------------
365
Arif Hussain0273cba2014-01-07 20:58:29 -0800366 \brief mem_alloc_copy_from_user_helper -
367
368 Helper function to allocate buffer and copy user data.
369
370 \param - wrqu - Pointer to IOCTL Data.
371 len - size
372
373 \return - On Success pointer to buffer, On failure NULL
374
375 --------------------------------------------------------------------------*/
376static void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
377{
378 u8 *ptr = NULL;
379
380 /* in order to protect the code, an extra byte is post appended to the buffer
381 * and the null termination is added. However, when allocating (len+1) byte
382 * of memory, we need to make sure that there is no uint overflow when doing
383 * addition. In theory check len < UINT_MAX protects the uint overflow. For
384 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
385 * guess, now, it is assumed that the private command buffer size is no
386 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
387 */
388 if (len > MAX_USER_COMMAND_SIZE)
389 {
390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
391 "Invalid length");
392 return NULL;
393 }
394
395 ptr = kmalloc(len + 1, GFP_KERNEL);
396 if (NULL == ptr)
397 {
398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
399 "unable to allocate memory");
400 return NULL;
401 }
402
403 if (copy_from_user(ptr, wrqu_data, len))
404 {
405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
406 "%s: failed to copy data to user buffer", __func__);
407 kfree(ptr);
408 return NULL;
409 }
410 ptr[len] = '\0';
411 return ptr;
412}
413
414/**---------------------------------------------------------------------------
415
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 \brief hdd_wlan_get_version() -
417
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800418 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700419
420 \param - pAdapter Pointer to the adapter.
421 wrqu - Pointer to IOCTL REQUEST Data.
422 extra - Pointer to char
423
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800424 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700425
426 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800427void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
428 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700429{
430 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800431 tSirVersionString wcnss_SW_version;
432 tSirVersionString wcnss_HW_version;
433 char *pSWversion;
434 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700436
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800437 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
438 sizeof(wcnss_SW_version));
439 if (VOS_IS_STATUS_SUCCESS(status))
440 {
441 pSWversion = wcnss_SW_version;
442 }
443 else
444 {
445 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 }
447
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800448 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
449 sizeof(wcnss_HW_version));
450 if (VOS_IS_STATUS_SUCCESS(status))
451 {
452 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800454 else
455 {
456 pHWversion = "Unknown";
457 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700458
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700459 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800460 "Host SW:%s, FW:%s, HW:%s",
461 QWLAN_VERSIONSTR,
462 pSWversion,
463 pHWversion);
464
465 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466}
467
Jeff Johnson295189b2012-06-20 16:38:30 -0700468int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
469{
470 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
471 v_U32_t threshold = 0,status = 0;
472
473 ENTER();
474
Agarwal Ashish971c2882013-10-30 20:11:12 +0530475 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
476 {
477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 "%s:LOGP in Progress. Ignore!!!",__func__);
479 return status;
480 }
481
482 if ( eHAL_STATUS_SUCCESS !=
483 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
484 {
c_hpothub8245442013-11-20 23:41:09 +0530485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
486 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 return -EIO;
488 }
489 wrqu->rts.value = threshold;
490
491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800492 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
494 EXIT();
495
496 return 0;
497}
498
499int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
500{
501 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
502 v_U32_t threshold = 0,status = 0;
503
504 ENTER();
505
Agarwal Ashish971c2882013-10-30 20:11:12 +0530506 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
507 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
509 "%s:LOGP in Progress. Ignore!!!",__func__);
510 return status;
511 }
512
513 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
514 != eHAL_STATUS_SUCCESS )
515 {
c_hpothub8245442013-11-20 23:41:09 +0530516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
517 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 return -EIO;
519 }
520 wrqu->frag.value = threshold;
521
522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800523 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700524
525 EXIT();
526
527 return 0;
528}
529
530int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
531{
Jeff Johnsone7245742012-09-05 17:12:55 -0700532 int i;
533 if (channel > 0)
534 {
535 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
536 {
537 if (channel == freq_chan_map[i].chan)
538 {
539 *pfreq = freq_chan_map[i].freq;
540 return 1;
541 }
542 }
543 }
544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800545 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700546 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700547}
548
549static v_BOOL_t
550hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
551{
552 v_BOOL_t rsnType = VOS_FALSE;
553 // is the authType supported?
554 switch (authType)
555 {
556 case eCSR_AUTH_TYPE_NONE: //never used
557 rsnType = eANI_BOOLEAN_FALSE;
558 break;
559 // MAC layer authentication types
560 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
561 rsnType = eANI_BOOLEAN_FALSE;
562 break;
563 case eCSR_AUTH_TYPE_SHARED_KEY:
564 rsnType = eANI_BOOLEAN_FALSE;
565 break;
566 case eCSR_AUTH_TYPE_AUTOSWITCH:
567 rsnType = eANI_BOOLEAN_FALSE;
568 break;
569
570 // Upper layer authentication types
571 case eCSR_AUTH_TYPE_WPA:
572 rsnType = eANI_BOOLEAN_TRUE;
573 break;
574 case eCSR_AUTH_TYPE_WPA_PSK:
575 rsnType = eANI_BOOLEAN_TRUE;
576 break;
577 case eCSR_AUTH_TYPE_WPA_NONE:
578 rsnType = eANI_BOOLEAN_TRUE;
579 break;
580#ifdef WLAN_FEATURE_VOWIFI_11R
581 case eCSR_AUTH_TYPE_FT_RSN:
582#endif
583 case eCSR_AUTH_TYPE_RSN:
584 rsnType = eANI_BOOLEAN_TRUE;
585 break;
586#ifdef WLAN_FEATURE_VOWIFI_11R
587 case eCSR_AUTH_TYPE_FT_RSN_PSK:
588#endif
589 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700590#ifdef WLAN_FEATURE_11W
591 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
592#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 rsnType = eANI_BOOLEAN_TRUE;
594 break;
595 //case eCSR_AUTH_TYPE_FAILED:
596 case eCSR_AUTH_TYPE_UNKNOWN:
597 rsnType = eANI_BOOLEAN_FALSE;
598 break;
599 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800600 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
601 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 rsnType = eANI_BOOLEAN_FALSE;
603 break;
604 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800605 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700606 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 return rsnType;
608}
609
610static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
611{
612 struct statsContext *pStatsContext;
613 hdd_adapter_t *pAdapter;
614
615 if (ioctl_debug)
616 {
617 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700618 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 }
620
621 if (NULL == pContext)
622 {
623 hddLog(VOS_TRACE_LEVEL_ERROR,
624 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700625 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 return;
627 }
628
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 pStatsContext = pContext;
630 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800631
632 /* there is a race condition that exists between this callback
633 function and the caller since the caller could time out either
634 before or while this code is executing. we use a spinlock to
635 serialize these actions */
636 spin_lock(&hdd_context_lock);
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
639 {
640 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800641 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 hddLog(VOS_TRACE_LEVEL_WARN,
643 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700644 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 if (ioctl_debug)
646 {
647 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700648 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 }
650 return;
651 }
652
Jeff Johnson72a40512013-12-19 10:14:15 -0800653 /* context is valid so caller is still waiting */
654
655 /* paranoia: invalidate the magic */
656 pStatsContext->magic = 0;
657
658 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 pAdapter->rssi = rssi;
660
Jeff Johnson72a40512013-12-19 10:14:15 -0800661 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800663
664 /* serialization is complete */
665 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700666}
667
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530668static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
669{
670 struct statsContext *pStatsContext;
671 hdd_adapter_t *pAdapter;
672
673 if (ioctl_debug)
674 {
675 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
676 __func__, (int)snr, (int)staId, pContext);
677 }
678
679 if (NULL == pContext)
680 {
681 hddLog(VOS_TRACE_LEVEL_ERROR,
682 "%s: Bad param, pContext [%p]",
683 __func__, pContext);
684 return;
685 }
686
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530687 pStatsContext = pContext;
688 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800689
690 /* there is a race condition that exists between this callback
691 function and the caller since the caller could time out either
692 before or while this code is executing. we use a spinlock to
693 serialize these actions */
694 spin_lock(&hdd_context_lock);
695
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530696 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
697 {
698 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800699 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530700 hddLog(VOS_TRACE_LEVEL_WARN,
701 "%s: Invalid context, pAdapter [%p] magic [%08x]",
702 __func__, pAdapter, pStatsContext->magic);
703 if (ioctl_debug)
704 {
705 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
706 __func__, pAdapter, pStatsContext->magic);
707 }
708 return;
709 }
710
Jeff Johnson72a40512013-12-19 10:14:15 -0800711 /* context is valid so caller is still waiting */
712
713 /* paranoia: invalidate the magic */
714 pStatsContext->magic = 0;
715
716 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530717 pAdapter->snr = snr;
718
Jeff Johnson72a40512013-12-19 10:14:15 -0800719 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530720 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800721
722 /* serialization is complete */
723 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530724}
725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
727{
728 struct statsContext context;
729 hdd_context_t *pHddCtx;
730 hdd_station_ctx_t *pHddStaCtx;
731 eHalStatus hstatus;
732 long lrc;
733
734 if (NULL == pAdapter)
735 {
736 hddLog(VOS_TRACE_LEVEL_WARN,
737 "%s: Invalid context, pAdapter", __func__);
738 return VOS_STATUS_E_FAULT;
739 }
740 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
741 {
742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
743 /* return a cached value */
744 *rssi_value = pAdapter->rssi;
745 return VOS_STATUS_SUCCESS;
746 }
747
748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
749 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
750
751 init_completion(&context.completion);
752 context.pAdapter = pAdapter;
753 context.magic = RSSI_CONTEXT_MAGIC;
754
755 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
756 pHddStaCtx->conn_info.staId[ 0 ],
757 pHddStaCtx->conn_info.bssId,
758 &context, pHddCtx->pvosContext);
759 if (eHAL_STATUS_SUCCESS != hstatus)
760 {
761 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700762 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 /* we'll returned a cached value below */
764 }
765 else
766 {
767 /* request was sent -- wait for the response */
768 lrc = wait_for_completion_interruptible_timeout(&context.completion,
769 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 if (lrc <= 0)
771 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800772 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700773 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 /* we'll now returned a cached value below */
775 }
776 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800777
778 /* either we never sent a request, we sent a request and received a
779 response or we sent a request and timed out. if we never sent a
780 request or if we sent a request and got a response, we want to
781 clear the magic out of paranoia. if we timed out there is a
782 race condition such that the callback function could be
783 executing at the same time we are. of primary concern is if the
784 callback function had already verified the "magic" but had not
785 yet set the completion variable when a timeout occurred. we
786 serialize these activities by invalidating the magic while
787 holding a shared spinlock which will cause us to block if the
788 callback is currently executing */
789 spin_lock(&hdd_context_lock);
790 context.magic = 0;
791 spin_unlock(&hdd_context_lock);
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 *rssi_value = pAdapter->rssi;
794
795 return VOS_STATUS_SUCCESS;
796}
797
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530798VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
799{
800 struct statsContext context;
801 hdd_context_t *pHddCtx;
802 hdd_station_ctx_t *pHddStaCtx;
803 eHalStatus hstatus;
804 long lrc;
805 int valid;
806
807 if (NULL == pAdapter)
808 {
809 hddLog(VOS_TRACE_LEVEL_ERROR,
810 "%s: Invalid context, pAdapter", __func__);
811 return VOS_STATUS_E_FAULT;
812 }
813
814 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
815
816 valid = wlan_hdd_validate_context(pHddCtx);
817 if (0 != valid)
818 {
819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
820 return VOS_STATUS_E_FAULT;
821 }
822
823 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
824 if (NULL == pHddStaCtx)
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
827 return VOS_STATUS_E_FAULT;
828 }
829
830 init_completion(&context.completion);
831 context.pAdapter = pAdapter;
832 context.magic = SNR_CONTEXT_MAGIC;
833
834 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
835 pHddStaCtx->conn_info.staId[ 0 ],
836 pHddStaCtx->conn_info.bssId,
837 &context);
838 if (eHAL_STATUS_SUCCESS != hstatus)
839 {
840 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
841 __func__);
842 /* we'll returned a cached value below */
843 }
844 else
845 {
846 /* request was sent -- wait for the response */
847 lrc = wait_for_completion_interruptible_timeout(&context.completion,
848 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530849 if (lrc <= 0)
850 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530852 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530853 /* we'll now returned a cached value below */
854 }
855 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800856
857 /* either we never sent a request, we sent a request and received a
858 response or we sent a request and timed out. if we never sent a
859 request or if we sent a request and got a response, we want to
860 clear the magic out of paranoia. if we timed out there is a
861 race condition such that the callback function could be
862 executing at the same time we are. of primary concern is if the
863 callback function had already verified the "magic" but had not
864 yet set the completion variable when a timeout occurred. we
865 serialize these activities by invalidating the magic while
866 holding a shared spinlock which will cause us to block if the
867 callback is currently executing */
868 spin_lock(&hdd_context_lock);
869 context.magic = 0;
870 spin_unlock(&hdd_context_lock);
871
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530872 *snr = pAdapter->snr;
873
874 return VOS_STATUS_SUCCESS;
875}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800876#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800877
878static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
879{
880 struct statsContext *pStatsContext;
881 hdd_adapter_t *pAdapter;
882 if (ioctl_debug)
883 {
884 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
885 __func__, (int)rssi, (int)staId, pContext);
886 }
887
888 if (NULL == pContext)
889 {
890 hddLog(VOS_TRACE_LEVEL_ERROR,
891 "%s: Bad param, pContext [%p]",
892 __func__, pContext);
893 return;
894 }
895
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800896 pStatsContext = pContext;
897 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800898
899 /* there is a race condition that exists between this callback
900 function and the caller since the caller could time out either
901 before or while this code is executing. we use a spinlock to
902 serialize these actions */
903 spin_lock(&hdd_context_lock);
904
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800905 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
906 {
907 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800908 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800909 hddLog(VOS_TRACE_LEVEL_WARN,
910 "%s: Invalid context, pAdapter [%p] magic [%08x]",
911 __func__, pAdapter, pStatsContext->magic);
912 if (ioctl_debug)
913 {
914 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
915 __func__, pAdapter, pStatsContext->magic);
916 }
917 return;
918 }
919
Jeff Johnson72a40512013-12-19 10:14:15 -0800920 /* context is valid so caller is still waiting */
921
922 /* paranoia: invalidate the magic */
923 pStatsContext->magic = 0;
924
925 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800926 pAdapter->rssi = rssi;
927
Jeff Johnson72a40512013-12-19 10:14:15 -0800928 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800929 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800930
931 /* serialization is complete */
932 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800933}
934
935
936
937VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
938{
939 struct statsContext context;
940 hdd_context_t *pHddCtx = NULL;
941 hdd_station_ctx_t *pHddStaCtx = NULL;
942 eHalStatus hstatus;
943 long lrc;
944
945 if (NULL == pAdapter)
946 {
947 hddLog(VOS_TRACE_LEVEL_WARN,
948 "%s: Invalid context, pAdapter", __func__);
949 return VOS_STATUS_E_FAULT;
950 }
951 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
952 {
953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
954 /* return a cached value */
955 *rssi_value = pAdapter->rssi;
956 return VOS_STATUS_SUCCESS;
957 }
958
959 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
960 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
961
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +0530962 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800963 {
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 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +0530969
970 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
971 {
972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
973 "%s: Roaming in progress, hence return last cached RSSI", __func__);
974 *rssi_value = pAdapter->rssi;
975 return VOS_STATUS_SUCCESS;
976 }
977
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800978 init_completion(&context.completion);
979 context.pAdapter = pAdapter;
980 context.magic = RSSI_CONTEXT_MAGIC;
981
982 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
983 pHddStaCtx->conn_info.staId[ 0 ],
984 pHddStaCtx->conn_info.bssId,
985 &context, pHddCtx->pvosContext);
986 if (eHAL_STATUS_SUCCESS != hstatus)
987 {
988 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
989 __func__);
990 /* we'll returned a cached value below */
991 }
992 else
993 {
994 /* request was sent -- wait for the response */
995 lrc = wait_for_completion_interruptible_timeout(&context.completion,
996 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800997 if (lrc <= 0)
998 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800999 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001000 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001001 /* we'll now returned a cached value below */
1002 }
1003 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001004
1005 /* either we never sent a request, we sent a request and received a
1006 response or we sent a request and timed out. if we never sent a
1007 request or if we sent a request and got a response, we want to
1008 clear the magic out of paranoia. if we timed out there is a
1009 race condition such that the callback function could be
1010 executing at the same time we are. of primary concern is if the
1011 callback function had already verified the "magic" but had not
1012 yet set the completion variable when a timeout occurred. we
1013 serialize these activities by invalidating the magic while
1014 holding a shared spinlock which will cause us to block if the
1015 callback is currently executing */
1016 spin_lock(&hdd_context_lock);
1017 context.magic = 0;
1018 spin_unlock(&hdd_context_lock);
1019
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001020 *rssi_value = pAdapter->rssi;
1021
1022 return VOS_STATUS_SUCCESS;
1023}
1024#endif
1025
1026
Jeff Johnson295189b2012-06-20 16:38:30 -07001027void hdd_StatisticsCB( void *pStats, void *pContext )
1028{
1029 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1030 hdd_stats_t *pStatsCache = NULL;
1031 hdd_wext_state_t *pWextState;
1032 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1033
1034 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1035 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1036 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1037 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1038 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1039 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1040
1041 if (pAdapter!= NULL)
1042 pStatsCache = &pAdapter->hdd_stats;
1043
1044
1045 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1046 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1047 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1048 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1049 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1050 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1051
1052 if (pStatsCache!=NULL)
1053 {
1054 // and copy the stats into the cache we keep in the adapter instance structure
1055 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1056 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1057 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1058 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1059 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1060 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1061 }
1062
1063 if(pAdapter)
1064 {
1065 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1066 if(pWextState)
1067 {
1068 vos_status = vos_event_set(&pWextState->vosevent);
1069 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1070 {
1071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001072 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 return;
1074 }
1075 }
1076 }
1077}
1078
1079void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1080{
1081 v_CONTEXT_t pVosContext;
1082 hdd_context_t *pHddCtx;
1083 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1084#if 0
1085 hdd_wext_state_t *pWextState;
1086 v_U32_t roamId;
1087#endif
1088
1089 ENTER();
1090
1091 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1092
1093 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1094 if (NULL == pHddCtx)
1095 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001096 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 return;
1098 }
1099#if 0
1100 pWextState = pAdapter->pWextState;
1101#endif
1102
1103 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1104 {
1105 //TODO Verify is this is really used. If yes need to fix it.
1106 hdd_reconnect_all_adapters( pHddCtx );
1107#if 0
1108 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1109 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1110 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1111
1112 if(VOS_STATUS_SUCCESS == vosStatus)
1113 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1114 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1115
1116 sme_RoamConnect(halHandle,
1117 pAdapter->sessionId, &(pWextState->roamProfile),
1118 &roamId);
1119#endif
1120 }
1121
1122 EXIT();
1123
1124}
1125
1126void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1127{
1128 int i = 0;
1129 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1130
1131 /* clear WPA/RSN/WSC IE information in the profile */
1132 pWextState->roamProfile.nWPAReqIELength = 0;
1133 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1134 pWextState->roamProfile.nRSNReqIELength = 0;
1135 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1136
Chet Lanctot186b5732013-03-18 10:26:30 -07001137#ifdef FEATURE_WLAN_WAPI
1138 pWextState->roamProfile.nWAPIReqIELength = 0;
1139 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1140#endif
1141
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001143 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301145 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1147 pWextState->roamProfile.nAddIEAssocLength = 0;
1148
1149 pWextState->roamProfile.EncryptionType.numEntries = 1;
1150 pWextState->roamProfile.EncryptionType.encryptionType[0]
1151 = eCSR_ENCRYPT_TYPE_NONE;
1152
1153 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1154 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1155 = eCSR_ENCRYPT_TYPE_NONE;
1156
1157 pWextState->roamProfile.AuthType.numEntries = 1;
1158 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1159
Chet Lanctot186b5732013-03-18 10:26:30 -07001160#ifdef WLAN_FEATURE_11W
1161 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1162 pWextState->roamProfile.MFPRequired = 0;
1163 pWextState->roamProfile.MFPCapable = 0;
1164#endif
1165
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 pWextState->authKeyMgmt = 0;
1167
1168 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1169 {
1170 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1171 {
1172 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1173 }
1174 }
1175#ifdef FEATURE_WLAN_WAPI
1176 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1177 pAdapter->wapi_info.nWapiMode = 0;
1178#endif
1179
1180 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1181
1182}
1183
1184void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1185{
1186 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001187
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001188 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1189 {
1190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1191 "%s: Invalid pAdapter magic", __func__);
1192 }
1193 else
1194 {
1195 complete(&pAdapter->ula_complete);
1196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001197}
1198
1199VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1200{
1201 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001203 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001204
1205 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1206 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001207 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001208
1209 /*To avoid race condition between the set key and the last EAPOL
1210 packet, notify TL to finish upper layer authentication incase if the
1211 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001212 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001213
1214 if ( vos_status != VOS_STATUS_SUCCESS )
1215 {
1216 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1217 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1218 __LINE__, vos_status );
1219 return vos_status;
1220
1221 }
1222
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001223 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301225 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001226 {
1227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301228 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001229 /* we'll still fall through and return success since the
1230 * connection may still get established but is just taking
1231 * too long for us to wait */
1232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 }
1234 return VOS_STATUS_SUCCESS;
1235}
1236
1237v_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)
1238{
1239
1240 int left = ie_len;
1241 v_U8_t *ptr = ie;
1242 v_U8_t elem_id,elem_len;
1243 v_U8_t eid = 0xDD;
1244
1245 if ( NULL == ie || 0 == ie_len )
1246 return NULL;
1247
1248 while(left >= 2)
1249 {
1250 elem_id = ptr[0];
1251 elem_len = ptr[1];
1252 left -= 2;
1253 if(elem_len > left)
1254 {
1255 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001256 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 eid,elem_len,left);
1258 return NULL;
1259 }
1260 if (elem_id == eid)
1261 {
1262 if(memcmp( &ptr[2], oui, oui_size)==0)
1263 return ptr;
1264 }
1265
1266 left -= elem_len;
1267 ptr += (elem_len + 2);
1268 }
1269 return NULL;
1270}
1271
1272static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1273 union iwreq_data *wrqu, char *extra)
1274{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001275 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 /* Do nothing for now */
1277 return 0;
1278}
1279
1280static int iw_get_name(struct net_device *dev,
1281 struct iw_request_info *info,
1282 char *wrqu, char *extra)
1283{
1284
1285 ENTER();
1286 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1287 EXIT();
1288 return 0;
1289}
1290
1291static int iw_set_mode(struct net_device *dev,
1292 struct iw_request_info *info,
1293 union iwreq_data *wrqu, char *extra)
1294{
1295 hdd_wext_state_t *pWextState;
1296 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1297 tCsrRoamProfile *pRoamProfile;
1298 eCsrRoamBssType LastBSSType;
1299 eMib_dot11DesiredBssType connectedBssType;
1300 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001301 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001302
1303 ENTER();
1304
1305 if (NULL == pAdapter)
1306 {
1307 hddLog(VOS_TRACE_LEVEL_WARN,
1308 "%s: Invalid context, pAdapter", __func__);
1309 return 0;
1310 }
1311
1312 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1314 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 return 0;
1316 }
1317
1318 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1319 if (pWextState == NULL)
1320 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301321 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 return -EINVAL;
1323 }
1324
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 pRoamProfile = &pWextState->roamProfile;
1327 LastBSSType = pRoamProfile->BSSType;
1328
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301329 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001330
1331 switch (wrqu->mode)
1332 {
1333 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301334 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1336 // Set the phymode correctly for IBSS.
1337 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1338 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001339 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 break;
1342 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301343 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 break;
1347 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301348 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1350 break;
1351 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301352 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001353 return -EOPNOTSUPP;
1354 }
1355
1356 if ( LastBSSType != pRoamProfile->BSSType )
1357 {
1358 //the BSS mode changed
1359 // We need to issue disconnect if connected or in IBSS disconnect state
1360 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1361 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1362 {
1363 VOS_STATUS vosStatus;
1364 // need to issue a disconnect to CSR.
1365 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1366 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1367 pAdapter->sessionId,
1368 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1369 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301370 {
1371 long ret;
1372 ret = wait_for_completion_interruptible_timeout(
1373 &pAdapter->disconnect_comp_var,
1374 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1375 if (ret <= 0)
1376 hddLog(VOS_TRACE_LEVEL_ERROR,
1377 FL("failed wait on disconnect_comp_var %ld"), ret);
1378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 }
1380 }
1381
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 EXIT();
1383 return 0;
1384}
1385
1386
1387static int iw_get_mode(struct net_device *dev,
1388 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301389 union iwreq_data *wrqu,
1390 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001391{
1392
1393 hdd_wext_state_t *pWextState;
1394 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1395
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301396 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 if (NULL == pAdapter)
1399 {
1400 hddLog(VOS_TRACE_LEVEL_WARN,
1401 "%s: Invalid context, pAdapter", __func__);
1402 return 0;
1403 }
1404
1405 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1407 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 return 0;
1409 }
1410
1411 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1412 if (pWextState == NULL)
1413 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301414 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 return -EINVAL;
1416 }
1417
1418 switch (pWextState->roamProfile.BSSType)
1419 {
1420 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001421 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301422 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 break;
1424 case eCSR_BSS_TYPE_IBSS:
1425 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001426 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301427 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 break;
1429 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001430 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301431 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 break;
1433 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001434 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 break;
1436 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301437
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 return 0;
1439}
1440
1441static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1442 union iwreq_data *wrqu, char *extra)
1443{
1444 v_U32_t numChans = 0;
1445 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1446 v_U32_t indx = 0;
1447 v_U32_t status = 0;
1448
1449 hdd_wext_state_t *pWextState;
1450 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1451 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1452 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1453 tCsrRoamProfile * pRoamProfile;
1454 ENTER();
1455
1456 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1458 return status;
1459 }
1460
1461 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1462
1463 pRoamProfile = &pWextState->roamProfile;
1464
Arif Hussain6d2a3322013-11-17 19:50:10 -08001465 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001466
1467 /* Link is up then return cant set channel*/
1468 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1469 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1470 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001471 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 return -EOPNOTSUPP;
1473 }
1474
1475 /* Settings by Frequency as input */
1476 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1477 (wrqu->freq.m <= (tANI_U32)5.825e8))
1478 {
1479 tANI_U32 freq = wrqu->freq.m / 100000;
1480
1481 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1482 indx++;
1483 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1484 {
1485 return -EINVAL;
1486 }
1487 wrqu->freq.e = 0;
1488 wrqu->freq.m = freq_chan_map[indx].chan;
1489
1490 }
1491
1492 if (wrqu->freq.e == 0)
1493 {
1494 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1495 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1496 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001497 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001498 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1500 return -EINVAL;
1501 }
1502
1503 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1504
1505 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1506 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1508 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 return -EIO;
1510 }
1511
1512 for (indx = 0; indx < numChans; indx++) {
1513 if (wrqu->freq.m == validChan[indx]){
1514 break;
1515 }
1516 }
1517 }
1518 else{
1519
1520 return -EINVAL;
1521 }
1522
1523 if(indx >= numChans)
1524 {
1525 return -EINVAL;
1526 }
1527
1528 /* Set the Operational Channel */
1529 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1530 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1531 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1532
Arif Hussain6d2a3322013-11-17 19:50:10 -08001533 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001534
1535 EXIT();
1536
1537 return status;
1538}
1539
1540static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1541 struct iw_freq *fwrq, char *extra)
1542{
Jeff Johnsone7245742012-09-05 17:12:55 -07001543 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1545 tHalHandle hHal;
1546 hdd_wext_state_t *pWextState;
1547 tCsrRoamProfile * pRoamProfile;
1548 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1549
1550 ENTER();
1551
1552 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1554 return status;
1555 }
1556
1557 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1558 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1559
1560 pRoamProfile = &pWextState->roamProfile;
1561
1562 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1563 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001564 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 {
c_hpothub8245442013-11-20 23:41:09 +05301566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1567 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 return -EIO;
1569 }
1570 else
1571 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001572 status = hdd_wlan_get_freq(channel, &freq);
1573 if( TRUE == status )
1574 {
1575 /* 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 = freq;
1579 fwrq->e = MHZ;
1580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 }
1582 }
1583 else
1584 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001585 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1586 * iwlist & iwconfig command shows frequency into proper
1587 * format (2.412 GHz instead of 246.2 MHz)*/
1588 fwrq->m = 0;
1589 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001591 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001592}
1593
1594static int iw_get_tx_power(struct net_device *dev,
1595 struct iw_request_info *info,
1596 union iwreq_data *wrqu, char *extra)
1597{
1598
1599 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1600 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1601 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1602
1603 if (pHddCtx->isLogpInProgress)
1604 {
1605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1606 "%s:LOGP in Progress. Ignore!!!",__func__);
1607 return -EBUSY;
1608 }
1609
1610 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1611 {
1612 wrqu->txpower.value = 0;
1613 return 0;
1614 }
1615 wlan_hdd_get_classAstats(pAdapter);
1616 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1617
1618 return 0;
1619}
1620
1621static int iw_set_tx_power(struct net_device *dev,
1622 struct iw_request_info *info,
1623 union iwreq_data *wrqu, char *extra)
1624{
1625 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1626 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1627
1628 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1629 {
1630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1631 return 0;
1632 }
1633
1634 ENTER();
1635
1636 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1637 {
c_hpothub8245442013-11-20 23:41:09 +05301638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1639 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 return -EIO;
1641 }
1642
1643 EXIT();
1644
1645 return 0;
1646}
1647
1648static int iw_get_bitrate(struct net_device *dev,
1649 struct iw_request_info *info,
1650 union iwreq_data *wrqu, char *extra)
1651{
1652 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1653 eHalStatus status = eHAL_STATUS_SUCCESS;
1654 hdd_wext_state_t *pWextState;
1655 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1656 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1657
1658 ENTER();
1659
1660 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1662 return status;
1663 }
1664
1665 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1666 wrqu->bitrate.value = 0;
1667 }
1668 else {
1669 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1670 SME_SUMMARY_STATS |
1671 SME_GLOBAL_CLASSA_STATS |
1672 SME_GLOBAL_CLASSB_STATS |
1673 SME_GLOBAL_CLASSC_STATS |
1674 SME_GLOBAL_CLASSD_STATS |
1675 SME_PER_STA_STATS,
1676 hdd_StatisticsCB, 0, FALSE,
1677 pHddStaCtx->conn_info.staId[0], pAdapter );
1678
1679 if(eHAL_STATUS_SUCCESS != status)
1680 {
1681 hddLog(VOS_TRACE_LEVEL_ERROR,
1682 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001683 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 return status;
1685 }
1686
1687 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1688
1689 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1690
1691 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1692 {
1693 hddLog(VOS_TRACE_LEVEL_ERROR,
1694 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001695 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 return VOS_STATUS_E_FAILURE;
1697 }
1698
1699 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1700 }
1701
1702 EXIT();
1703
1704 return vos_status;
1705}
1706/* ccm call back function */
1707
1708static int iw_set_bitrate(struct net_device *dev,
1709 struct iw_request_info *info,
1710 union iwreq_data *wrqu,
1711 char *extra)
1712{
1713 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1714 hdd_wext_state_t *pWextState;
1715 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1716 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1717 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1718 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1719 v_U32_t i, rate;
1720 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1721
1722 ENTER();
1723
1724 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1726 return 0;
1727 }
1728
1729 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1730
1731 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1732 {
1733 return -ENXIO ;
1734 }
1735
1736 rate = wrqu->bitrate.value;
1737
1738 if (rate == -1)
1739 {
1740 rate = WNI_CFG_FIXED_RATE_AUTO;
1741 valid_rate = TRUE;
1742 }
1743 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1744 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1745 {
1746 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1747 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1748 {
1749 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1750 WNI_CFG_SUPPORTED_RATES_11A,
1751 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1752 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1753 WNI_CFG_SUPPORTED_RATES_11B,
1754 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1755 {
1756 for (i = 0; i < (b_len + a_len); ++i)
1757 {
1758 /* supported rates returned is double the actual rate so we divide it by 2 */
1759 if ((supp_rates[i]&0x7F)/2 == rate)
1760 {
1761 valid_rate = TRUE;
1762 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1763 break;
1764 }
1765 }
1766 }
1767 }
1768 }
1769 if (valid_rate != TRUE)
1770 {
1771 return -EINVAL;
1772 }
1773 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1774 WNI_CFG_FIXED_RATE, rate,
1775 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1776 {
c_hpothub8245442013-11-20 23:41:09 +05301777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1778 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 return -EIO;
1780 }
1781 return 0;
1782}
1783
1784
1785static int iw_set_genie(struct net_device *dev,
1786 struct iw_request_info *info,
1787 union iwreq_data *wrqu,
1788 char *extra)
1789{
1790 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1791 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001792 u_int8_t *genie = NULL;
1793 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 v_U16_t remLen;
1795
1796 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001797
1798 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1800 "%s:LOGP in Progress. Ignore!!!", __func__);
1801 return 0;
1802 }
1803
1804 if (!wrqu->data.length) {
1805 hdd_clearRoamProfileIe(pAdapter);
1806 EXIT();
1807 return 0;
1808 }
1809
1810 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1811 wrqu->data.length);
1812 if (NULL == base_genie)
1813 {
1814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1815 "mem_alloc_copy_from_user_helper fail");
1816 return -ENOMEM;
1817 }
1818
1819 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001820
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 remLen = wrqu->data.length;
1822
Arif Hussain6d2a3322013-11-17 19:50:10 -08001823 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001824
1825 /* clear any previous genIE before this call */
1826 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1827
1828 while (remLen >= 2)
1829 {
1830 v_U16_t eLen = 0;
1831 v_U8_t elementId;
1832 elementId = *genie++;
1833 eLen = *genie++;
1834 remLen -= 2;
1835
Arif Hussain6d2a3322013-11-17 19:50:10 -08001836 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 __func__, elementId, eLen);
1838
1839 switch ( elementId )
1840 {
1841 case IE_EID_VENDOR:
1842 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001843 {
1844 kfree(base_genie);
1845 return -EINVAL;
1846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001847
1848 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1849 {
1850 v_U16_t curGenIELen = pWextState->genIE.length;
1851 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1852 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1853
1854 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1855 {
1856 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001857 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001859 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001860 return -ENOMEM;
1861 }
1862 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1863 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1864 pWextState->genIE.length += eLen + 2;
1865 }
1866 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1867 {
1868 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1869 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1870 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1871 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1872 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1873 }
1874 else /* any vendorId except WPA IE should be accumulated to genIE */
1875 {
1876 v_U16_t curGenIELen = pWextState->genIE.length;
1877 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1878 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1879
1880 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1881 {
1882 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001883 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001885 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 return -ENOMEM;
1887 }
1888 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1889 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1890 pWextState->genIE.length += eLen + 2;
1891 }
1892 break;
1893 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001894 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1896 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1897 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1898 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1899 break;
1900
1901 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001902 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001903 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 return 0;
1905 }
1906 genie += eLen;
1907 remLen -= eLen;
1908 }
1909 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001910 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 return 0;
1912}
1913
1914static int iw_get_genie(struct net_device *dev,
1915 struct iw_request_info *info,
1916 union iwreq_data *wrqu,
1917 char *extra)
1918{
1919 hdd_wext_state_t *pWextState;
1920 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1921 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1922 eHalStatus status;
1923 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1924 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1925
1926 ENTER();
1927
1928 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1930 return 0;
1931 }
1932
1933
Arif Hussain6d2a3322013-11-17 19:50:10 -08001934 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001935
1936 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1937
1938 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1939 {
1940 return -ENXIO;
1941 }
1942
1943 // Return something ONLY if we are associated with an RSN or WPA network
1944 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1945 pWextState->roamProfile.negotiatedAuthType))
1946 {
1947 return -ENXIO;
1948 }
1949
1950 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1951 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1952 pAdapter->sessionId,
1953 &length,
1954 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001955 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1956 if (wrqu->data.length < length)
1957 {
1958 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1959 return -EFAULT;
1960 }
Arif Hussain9f05be02014-02-05 12:06:53 -08001961 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001962 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001963
Arif Hussain6d2a3322013-11-17 19:50:10 -08001964 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001965
1966 EXIT();
1967
1968 return 0;
1969}
1970
1971static int iw_get_encode(struct net_device *dev,
1972 struct iw_request_info *info,
1973 struct iw_point *dwrq, char *extra)
1974{
1975 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1976 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1977 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1978 int keyId;
1979 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1980 int i;
1981
1982 ENTER();
1983
1984 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1986 return 0;
1987 }
1988
1989 keyId = pRoamProfile->Keys.defaultIndex;
1990
1991 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1992 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001993 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001994 return -EINVAL;
1995 }
1996
1997 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1998 {
1999 dwrq->flags |= IW_ENCODE_ENABLED;
2000 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2001 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2002
2003 dwrq->flags |= (keyId + 1);
2004
2005 }
2006 else
2007 {
2008 dwrq->flags |= IW_ENCODE_DISABLED;
2009 }
2010
2011 for(i=0; i < MAX_WEP_KEYS; i++)
2012 {
2013 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2014 {
2015 continue;
2016 }
2017 else
2018 {
2019 break;
2020 }
2021 }
2022
2023 if(MAX_WEP_KEYS == i)
2024 {
2025 dwrq->flags |= IW_ENCODE_NOKEY;
2026 }
2027
2028 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2029
2030 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2031 {
2032 dwrq->flags |= IW_ENCODE_OPEN;
2033 }
2034 else
2035 {
2036 dwrq->flags |= IW_ENCODE_RESTRICTED;
2037 }
2038 EXIT();
2039 return 0;
2040}
2041
2042#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2043#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2044
2045
2046/*
2047 * This function sends a single 'key' to LIM at all time.
2048 */
2049
2050static int iw_get_rts_threshold(struct net_device *dev,
2051 struct iw_request_info *info,
2052 union iwreq_data *wrqu, char *extra)
2053{
2054 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2055 v_U32_t status = 0;
2056
2057 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2058
2059 return status;
2060}
2061
2062static int iw_set_rts_threshold(struct net_device *dev,
2063 struct iw_request_info *info,
2064 union iwreq_data *wrqu, char *extra)
2065{
2066 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2067 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2068
2069 ENTER();
2070
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002071 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2072 {
2073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2074 "%s:LOGP in Progress. Ignore!!!", __func__);
2075 return -EAGAIN;
2076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2078 {
2079 return -EINVAL;
2080 }
2081
2082 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2083 {
c_hpothub8245442013-11-20 23:41:09 +05302084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2085 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002086 return -EIO;
2087 }
2088
2089 EXIT();
2090
2091 return 0;
2092}
2093
2094static int iw_get_frag_threshold(struct net_device *dev,
2095 struct iw_request_info *info,
2096 union iwreq_data *wrqu, char *extra)
2097{
2098 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2099 v_U32_t status = 0;
2100
2101 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2102
2103 return status;
2104}
2105
2106static int iw_set_frag_threshold(struct net_device *dev,
2107 struct iw_request_info *info,
2108 union iwreq_data *wrqu, char *extra)
2109{
2110 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2111 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2112
2113 ENTER();
2114
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002115 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2116 {
2117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2118 "%s:LOGP in Progress. Ignore!!!", __func__);
2119 return -EBUSY;
2120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2122 {
2123 return -EINVAL;
2124 }
2125
2126 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2127 {
c_hpothub8245442013-11-20 23:41:09 +05302128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2129 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 return -EIO;
2131 }
2132
2133 EXIT();
2134
2135 return 0;
2136}
2137
2138static int iw_get_power_mode(struct net_device *dev,
2139 struct iw_request_info *info,
2140 union iwreq_data *wrqu, char *extra)
2141{
2142 ENTER();
2143 return -EOPNOTSUPP;
2144}
2145
2146static int iw_set_power_mode(struct net_device *dev,
2147 struct iw_request_info *info,
2148 union iwreq_data *wrqu, char *extra)
2149{
2150 ENTER();
2151 return -EOPNOTSUPP;
2152}
2153
2154static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2155 union iwreq_data *wrqu, char *extra)
2156{
2157 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2158 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2159 struct iw_range *range = (struct iw_range *) extra;
2160
2161 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2162
2163 v_U32_t num_channels = sizeof(channels);
2164 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2165 v_U32_t a_len;
2166 v_U32_t b_len;
2167 v_U32_t active_phy_mode = 0;
2168 v_U8_t index = 0, i;
2169
2170 ENTER();
2171
2172 wrqu->data.length = sizeof(struct iw_range);
2173 memset(range, 0, sizeof(struct iw_range));
2174
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002175 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2176 {
2177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2178 "%s:LOGP in Progress. Ignore!!!", __func__);
2179 return -EBUSY;
2180 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002181
2182 /*Get the phy mode*/
2183 if (ccmCfgGetInt(hHal,
2184 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2185 {
2186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002187 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002188
2189 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2190 {
2191 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002192 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 if (ccmCfgGetStr(hHal,
2194 WNI_CFG_SUPPORTED_RATES_11A,
2195 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2196 {
2197 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2198 {
2199 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2200 }
2201 for (i = 0; i < a_len; i++)
2202 {
2203 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2204 }
2205 range->num_bitrates = a_len;
2206 }
2207 else
2208 {
2209 return -EIO;
2210 }
2211 }
2212 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2213 {
2214 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002215 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 if (ccmCfgGetStr(hHal,
2217 WNI_CFG_SUPPORTED_RATES_11B,
2218 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2219 {
2220 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2221 {
2222 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2223 }
2224 for (i = 0; i < b_len; i++)
2225 {
2226 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2227 }
2228 range->num_bitrates = b_len;
2229 }
2230 else
2231 {
2232 return -EIO;
2233 }
2234 }
2235 }
2236
2237 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2238 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2239 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2240
2241 range->encoding_size[0] = 5;
2242 range->encoding_size[1] = 13;
2243 range->num_encoding_sizes = 2;
2244 range->max_encoding_tokens = MAX_WEP_KEYS;
2245
2246 // we support through Wireless Extensions 22
2247 range->we_version_compiled = WIRELESS_EXT;
2248 range->we_version_source = 22;
2249
2250 /*Supported Channels and Frequencies*/
2251 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2252 {
c_hpothub8245442013-11-20 23:41:09 +05302253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2254 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 return -EIO;
2256 }
2257 if (num_channels > IW_MAX_FREQUENCIES)
2258 {
2259 num_channels = IW_MAX_FREQUENCIES;
2260 }
2261
2262 range->num_channels = num_channels;
2263 range->num_frequency = num_channels;
2264
2265 for (index=0; index < num_channels; index++)
2266 {
2267 v_U32_t frq_indx = 0;
2268
2269 range->freq[index].i = channels[index];
2270 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2271 {
2272 if(channels[index] == freq_chan_map[frq_indx].chan)
2273 {
2274 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2275 range->freq[index].e = 1;
2276 break;
2277 }
2278 frq_indx++;
2279 }
2280 }
2281
2282 /* Event capability (kernel + driver) */
2283 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2284 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2285 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2286 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2287
2288 /*Encryption capability*/
2289 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2290 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2291
2292 /* Txpower capability */
2293 range->txpower_capa = IW_TXPOW_MWATT;
2294
2295 /*Scanning capability*/
2296 #if WIRELESS_EXT >= 22
2297 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2298 #endif
2299
2300 EXIT();
2301 return 0;
2302}
2303
2304/* Callback function registered with PMC to know status of PMC request */
2305static void iw_power_callback_fn (void *pContext, eHalStatus status)
2306{
2307 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002308
2309 if (NULL == pContext)
2310 {
2311 hddLog(VOS_TRACE_LEVEL_ERROR,
2312 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002313 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 return;
2315 }
2316
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002318
Jeff Johnson72a40512013-12-19 10:14:15 -08002319 /* there is a race condition that exists between this callback
2320 function and the caller since the caller could time out either
2321 before or while this code is executing. we use a spinlock to
2322 serialize these actions */
2323 spin_lock(&hdd_context_lock);
2324
2325 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 {
2327 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002328 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002330 "%s: Invalid context, magic [%08x]",
2331 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002332
2333 if (ioctl_debug)
2334 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002335 pr_info("%s: Invalid context, magic [%08x]\n",
2336 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 }
2338 return;
2339 }
2340
Jeff Johnson72a40512013-12-19 10:14:15 -08002341 /* context is valid so caller is still waiting */
2342
2343 /* paranoia: invalidate the magic */
2344 pStatsContext->magic = 0;
2345
2346 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002348
2349 /* serialization is complete */
2350 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351}
2352
2353/* Callback function for tx per hit */
2354void hdd_tx_per_hit_cb (void *pCallbackContext)
2355{
2356 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2357 unsigned char tx_fail[16];
2358 union iwreq_data wrqu;
2359
2360 if (NULL == pAdapter)
2361 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002362 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 return;
2364 }
2365 memset(&wrqu, 0, sizeof(wrqu));
2366 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2367 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2368}
2369
2370void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2371{
2372 struct statsContext *pStatsContext;
2373 tCsrGlobalClassAStatsInfo *pClassAStats;
2374 hdd_adapter_t *pAdapter;
2375
2376 if (ioctl_debug)
2377 {
2378 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002379 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 }
2381
2382 if ((NULL == pStats) || (NULL == pContext))
2383 {
2384 hddLog(VOS_TRACE_LEVEL_ERROR,
2385 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002386 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 return;
2388 }
2389
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 pClassAStats = pStats;
2391 pStatsContext = pContext;
2392 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002393
2394 /* there is a race condition that exists between this callback
2395 function and the caller since the caller could time out either
2396 before or while this code is executing. we use a spinlock to
2397 serialize these actions */
2398 spin_lock(&hdd_context_lock);
2399
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2401 {
2402 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002403 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 hddLog(VOS_TRACE_LEVEL_WARN,
2405 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002406 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 if (ioctl_debug)
2408 {
2409 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002410 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 }
2412 return;
2413 }
2414
Jeff Johnson72a40512013-12-19 10:14:15 -08002415 /* context is valid so caller is still waiting */
2416
2417 /* paranoia: invalidate the magic */
2418 pStatsContext->magic = 0;
2419
2420 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2422
Jeff Johnson72a40512013-12-19 10:14:15 -08002423 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002425
2426 /* serialization is complete */
2427 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002428}
2429
2430VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2431{
2432 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2433 eHalStatus hstatus;
2434 long lrc;
2435 struct statsContext context;
2436
2437 if (NULL == pAdapter)
2438 {
2439 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2440 return VOS_STATUS_E_FAULT;
2441 }
2442 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2443 {
2444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2445 return VOS_STATUS_SUCCESS;
2446 }
2447
2448 /* we are connected
2449 prepare our callback context */
2450 init_completion(&context.completion);
2451 context.pAdapter = pAdapter;
2452 context.magic = STATS_CONTEXT_MAGIC;
2453 /* query only for Class A statistics (which include link speed) */
2454 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2455 eCSR_HDD,
2456 SME_GLOBAL_CLASSA_STATS,
2457 hdd_GetClassA_statisticsCB,
2458 0, // not periodic
2459 FALSE, //non-cached results
2460 pHddStaCtx->conn_info.staId[0],
2461 &context);
2462 if (eHAL_STATUS_SUCCESS != hstatus)
2463 {
2464 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002465 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002466 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 /* we'll returned a cached value below */
2468 }
2469 else
2470 {
2471 /* request was sent -- wait for the response */
2472 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2473 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 if (lrc <= 0)
2475 {
2476 hddLog(VOS_TRACE_LEVEL_ERROR,
2477 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002478 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 }
2480 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002481
2482 /* either we never sent a request, we sent a request and received a
2483 response or we sent a request and timed out. if we never sent a
2484 request or if we sent a request and got a response, we want to
2485 clear the magic out of paranoia. if we timed out there is a
2486 race condition such that the callback function could be
2487 executing at the same time we are. of primary concern is if the
2488 callback function had already verified the "magic" but had not
2489 yet set the completion variable when a timeout occurred. we
2490 serialize these activities by invalidating the magic while
2491 holding a shared spinlock which will cause us to block if the
2492 callback is currently executing */
2493 spin_lock(&hdd_context_lock);
2494 context.magic = 0;
2495 spin_unlock(&hdd_context_lock);
2496
2497 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 return VOS_STATUS_SUCCESS;
2499}
2500
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002501static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2502{
2503 struct statsContext *pStatsContext;
2504 tCsrSummaryStatsInfo *pSummaryStats;
2505 tCsrGlobalClassAStatsInfo *pClassAStats;
2506 hdd_adapter_t *pAdapter;
2507
2508 if (ioctl_debug)
2509 {
2510 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002511 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002512 }
2513
2514 if ((NULL == pStats) || (NULL == pContext))
2515 {
2516 hddLog(VOS_TRACE_LEVEL_ERROR,
2517 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002518 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002519 return;
2520 }
2521
Jeff Johnson72a40512013-12-19 10:14:15 -08002522 /* there is a race condition that exists between this callback
2523 function and the caller since the caller could time out either
2524 before or while this code is executing. we use a spinlock to
2525 serialize these actions */
2526 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002527
2528 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2529 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2530 pStatsContext = pContext;
2531 pAdapter = pStatsContext->pAdapter;
2532 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2533 {
2534 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002535 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002536 hddLog(VOS_TRACE_LEVEL_WARN,
2537 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002538 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002539 if (ioctl_debug)
2540 {
2541 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002542 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002543 }
2544 return;
2545 }
2546
Jeff Johnson72a40512013-12-19 10:14:15 -08002547 /* context is valid so caller is still waiting */
2548
2549 /* paranoia: invalidate the magic */
2550 pStatsContext->magic = 0;
2551
2552 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002553 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2554 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2555
Jeff Johnson72a40512013-12-19 10:14:15 -08002556 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002557 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002558
2559 /* serialization is complete */
2560 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002561}
2562
2563VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2564{
2565 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2566 eHalStatus hstatus;
2567 long lrc;
2568 struct statsContext context;
2569
2570 if (NULL == pAdapter)
2571 {
2572 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2573 return VOS_STATUS_SUCCESS;
2574 }
2575
2576 /* we are connected
2577 prepare our callback context */
2578 init_completion(&context.completion);
2579 context.pAdapter = pAdapter;
2580 context.magic = STATS_CONTEXT_MAGIC;
2581
2582 /* query only for Summary & Class A statistics */
2583 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2584 eCSR_HDD,
2585 SME_SUMMARY_STATS |
2586 SME_GLOBAL_CLASSA_STATS,
2587 hdd_get_station_statisticsCB,
2588 0, // not periodic
2589 FALSE, //non-cached results
2590 pHddStaCtx->conn_info.staId[0],
2591 &context);
2592 if (eHAL_STATUS_SUCCESS != hstatus)
2593 {
2594 hddLog(VOS_TRACE_LEVEL_ERROR,
2595 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002596 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002597 /* we'll return with cached values */
2598 }
2599 else
2600 {
2601 /* request was sent -- wait for the response */
2602 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2603 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002604
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002605 if (lrc <= 0)
2606 {
2607 hddLog(VOS_TRACE_LEVEL_ERROR,
2608 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002609 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002610 }
2611 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002612
2613 /* either we never sent a request, we sent a request and received a
2614 response or we sent a request and timed out. if we never sent a
2615 request or if we sent a request and got a response, we want to
2616 clear the magic out of paranoia. if we timed out there is a
2617 race condition such that the callback function could be
2618 executing at the same time we are. of primary concern is if the
2619 callback function had already verified the "magic" but had not
2620 yet set the completion variable when a timeout occurred. we
2621 serialize these activities by invalidating the magic while
2622 holding a shared spinlock which will cause us to block if the
2623 callback is currently executing */
2624 spin_lock(&hdd_context_lock);
2625 context.magic = 0;
2626 spin_unlock(&hdd_context_lock);
2627
2628 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002629 return VOS_STATUS_SUCCESS;
2630}
2631
2632
Jeff Johnson295189b2012-06-20 16:38:30 -07002633/*
2634 * Support for the LINKSPEED private command
2635 * Per the WiFi framework the response must be of the form
2636 * "LinkSpeed xx"
2637 */
2638static int iw_get_linkspeed(struct net_device *dev,
2639 struct iw_request_info *info,
2640 union iwreq_data *wrqu, char *extra)
2641{
2642 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302643 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302645 int len = sizeof(v_U32_t) + 1;
2646 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302648 VOS_STATUS status;
2649 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002650
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302651 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2652
2653 valid = wlan_hdd_validate_context(pHddCtx);
2654
2655 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002656 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302657 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2658 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002659 }
2660
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2662 {
2663 /* we are not connected so we don't have a classAstats */
2664 link_speed = 0;
2665 }
2666 else
2667 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302668 status = wlan_hdd_get_classAstats(pAdapter);
2669
2670 if (!VOS_IS_STATUS_SUCCESS(status ))
2671 {
2672 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2673 return -EINVAL;
2674 }
2675
2676 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2677 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2678 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2679 &link_speed);
2680
2681 link_speed = link_speed / 10;
2682
2683 if (0 == link_speed)
2684 {
2685 /* The linkspeed returned by HAL is in units of 500kbps.
2686 * converting it to mbps.
2687 * This is required to support legacy firmware which does
2688 * not return link capacity.
2689 */
2690 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2691 }
2692
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 }
2694
2695 wrqu->data.length = len;
2696 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002697 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 if ((rc < 0) || (rc >= len))
2699 {
2700 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302701 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 return -EIO;
2703 }
2704
2705 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002706 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002707}
2708
Arif Hussain695279c2014-03-24 14:06:07 -07002709/*
2710 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2711 *
2712 */
2713static int iw_get_linkspeed_priv(struct net_device *dev,
2714 struct iw_request_info *info,
2715 union iwreq_data *wrqu, char *extra)
2716{
2717 int rc;
2718
2719 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2720
2721 if (rc < 0)
2722 return rc;
2723
2724 /* a value is being successfully returned */
2725 return 0;
2726}
Jeff Johnson295189b2012-06-20 16:38:30 -07002727
2728/*
2729 * Support for the RSSI & RSSI-APPROX private commands
2730 * Per the WiFi framework the response must be of the form
2731 * "<ssid> rssi <xx>"
2732 * unless we are not associated, in which case the response is
2733 * "OK"
2734 */
2735static int iw_get_rssi(struct net_device *dev,
2736 struct iw_request_info *info,
2737 union iwreq_data *wrqu, char *extra)
2738{
2739 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002740 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 int len = wrqu->data.length;
2742 v_S7_t s7Rssi = 0;
2743 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2744 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2745 VOS_STATUS vosStatus;
2746 int rc;
2747
2748 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2749 (0 == ssidlen) || (ssidlen >= len))
2750 {
2751 /* we are not connected or our SSID is too long
2752 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002753 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 }
2755 else
2756 {
2757 /* we are connected with a valid SSID
2758 so we can write the SSID into the return buffer
2759 (note that it is not NUL-terminated) */
2760 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2761
2762 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2763
2764 if (VOS_STATUS_SUCCESS == vosStatus)
2765 {
2766 /* append the rssi to the ssid in the format required by
2767 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002768 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302769 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 }
2771 else
2772 {
2773 rc = -1;
2774 }
2775 }
2776
2777 /* verify that we wrote a valid response */
2778 if ((rc < 0) || (rc >= len))
2779 {
2780 // encoding or length error?
2781 hddLog(VOS_TRACE_LEVEL_ERROR,
2782 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002783 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 return -EIO;
2785 }
2786
2787 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002788 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002789}
2790
2791/*
2792 * Support for SoftAP channel range private command
2793 */
2794static int iw_softap_set_channel_range( struct net_device *dev,
2795 int startChannel,
2796 int endChannel,
2797 int band)
2798{
Jeff Johnson43971f52012-07-17 12:26:56 -07002799 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 int ret = 0;
2801 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2802 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002803 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2804
Jeff Johnson295189b2012-06-20 16:38:30 -07002805
2806 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2807 if (VOS_STATUS_SUCCESS != status)
2808 {
2809 ret = -EINVAL;
2810 }
Yathish9f22e662012-12-10 14:21:35 -08002811 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 return ret;
2813}
2814
2815VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2816{
2817 struct statsContext context;
2818 eHalStatus status;
2819 hdd_context_t *pHddCtx;
2820
2821 if (NULL == pAdapter)
2822 {
2823 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2824 return VOS_STATUS_E_FAULT;
2825 }
2826
2827 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2828 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05302829 if (pHddCtx->isLogpInProgress) {
2830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2831 "%s:LOGP in Progress. Ignore!!!", __func__);
2832 return VOS_STATUS_E_FAILURE;
2833 }
2834
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 init_completion(&context.completion);
2836
2837 context.pAdapter = pAdapter;
2838 context.magic = POWER_CONTEXT_MAGIC;
2839
2840 if (DRIVER_POWER_MODE_ACTIVE == mode)
2841 {
2842 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2843 "Full Power", __func__);
2844 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2845 iw_power_callback_fn, &context,
2846 eSME_FULL_PWR_NEEDED_BY_HDD);
2847 // Enter Full power command received from GUI this means we are disconnected
2848 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2849 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2850 if (eHAL_STATUS_PMC_PENDING == status)
2851 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002852 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 int lrc = wait_for_completion_interruptible_timeout(
2854 &context.completion,
2855 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002856
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 if (lrc <= 0)
2858 {
2859 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002860 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 }
2862 }
2863 }
2864 else if (DRIVER_POWER_MODE_AUTO == mode)
2865 {
2866 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2867 {
2868 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2869 __func__);
2870 // Enter BMPS command received from GUI this means DHCP is completed
2871 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2872 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2873 FALSE);
2874 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2875 iw_power_callback_fn, &context);
2876 if (eHAL_STATUS_PMC_PENDING == status)
2877 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002878 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 int lrc = wait_for_completion_interruptible_timeout(
2880 &context.completion,
2881 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 if (lrc <= 0)
2883 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002884 hddLog(VOS_TRACE_LEVEL_ERROR,
2885 "%s: SME %s while requesting BMPS",
2886 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 }
2888 }
2889 }
2890 else
2891 {
2892 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2893 "enabled in the cfg");
2894 }
2895 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002896
2897 /* either we never sent a request, we sent a request and received a
2898 response or we sent a request and timed out. if we never sent a
2899 request or if we sent a request and got a response, we want to
2900 clear the magic out of paranoia. if we timed out there is a
2901 race condition such that the callback function could be
2902 executing at the same time we are. of primary concern is if the
2903 callback function had already verified the "magic" but had not
2904 yet set the completion variable when a timeout occurred. we
2905 serialize these activities by invalidating the magic while
2906 holding a shared spinlock which will cause us to block if the
2907 callback is currently executing */
2908 spin_lock(&hdd_context_lock);
2909 context.magic = 0;
2910 spin_unlock(&hdd_context_lock);
2911
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 return VOS_STATUS_SUCCESS;
2913}
2914
2915VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2916 hdd_adapter_t *pAdapter)
2917{
2918 VOS_STATUS vos_Status;
2919
2920 if ((NULL == pAdapter) || (NULL == pHddCtx))
2921 {
2922 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2923 return VOS_STATUS_E_FAULT;
2924 }
2925
2926 /**Exit from Deep sleep or standby if we get the driver
2927 START cmd from android GUI
2928 */
2929 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2930 {
2931 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2932 "from Stand by",__func__);
2933 vos_Status = hdd_exit_standby(pHddCtx);
2934 }
2935 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2936 {
2937 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2938 "from deep sleep",__func__);
2939 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2940 }
2941 else
2942 {
2943 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2944 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2945 vos_Status = VOS_STATUS_SUCCESS;
2946 }
2947
2948 return vos_Status;
2949}
2950
2951VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2952{
2953 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2954
2955 if (NULL == pHddCtx)
2956 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302957 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 return VOS_STATUS_E_FAULT;
2959 }
2960
2961 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2962 {
2963 //Execute standby procedure.
2964 //Executing standby procedure will cause the STA to
2965 //disassociate first and then the chip will be put into standby.
2966 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2967 vos_Status = hdd_enter_standby(pHddCtx);
2968 }
2969 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2970 pHddCtx->cfg_ini->nEnableDriverStop)
2971 {
2972 //Execute deep sleep procedure
2973 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002974 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002975 //Deep sleep not supported
2976 vos_Status = hdd_enter_standby(pHddCtx);
2977 }
2978 else
2979 {
2980 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2981 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2982 vos_Status = VOS_STATUS_SUCCESS;
2983 }
2984
2985 return vos_Status;
2986}
2987
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002988
2989void* wlan_hdd_change_country_code_callback(void *pAdapter)
2990{
2991
2992 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002993 complete(&call_back_pAdapter->change_country_code);
2994
2995 return NULL;
2996}
2997
Jeff Johnson295189b2012-06-20 16:38:30 -07002998static int iw_set_priv(struct net_device *dev,
2999 struct iw_request_info *info,
3000 union iwreq_data *wrqu, char *extra)
3001{
3002 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003003 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 int cmd_len = wrqu->data.length;
3005 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003006 int rc = 0;
3007 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3008
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3010
3011 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003012 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3013 wrqu->data.length);
3014 if (NULL == cmd)
3015 {
3016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3017 "mem_alloc_copy_from_user_helper fail");
3018 return -ENOMEM;
3019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003020
3021 if (ioctl_debug)
3022 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003023 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 }
3025
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003026 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3027 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003028
3029 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003030 if (ioctl_debug)
3031 {
3032 pr_info("%s: RESTART in progress\n", __func__);
3033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003034
Arif Hussain24bfa702014-01-22 13:51:30 -08003035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003037 kfree(cmd);
3038 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 }
3040
Arif Hussain24bfa702014-01-22 13:51:30 -08003041 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003043 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3045 "%s: Error in iw_set_scan!", __func__);
3046 rc = -EINVAL;
3047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 }
3049 else if( strcasecmp(cmd, "start") == 0 ) {
3050
Arif Hussain6d2a3322013-11-17 19:50:10 -08003051 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003053
Arif Hussain24bfa702014-01-22 13:51:30 -08003054 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3055 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 {
3057 union iwreq_data wrqu;
3058 char buf[10];
3059
3060 memset(&wrqu, 0, sizeof(wrqu));
3061 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3062 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3063 }
3064 else
3065 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003066 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3067 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 }
3069 goto done;
3070 }
3071 else if( strcasecmp(cmd, "stop") == 0 )
3072 {
3073 union iwreq_data wrqu;
3074 char buf[10];
3075
Arif Hussain6d2a3322013-11-17 19:50:10 -08003076 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003077
3078 wlan_hdd_enter_lowpower(pHddCtx);
3079 memset(&wrqu, 0, sizeof(wrqu));
3080 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3081 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 goto done;
3083 }
3084 else if (strcasecmp(cmd, "macaddr") == 0)
3085 {
3086 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3087 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3088 }
3089 else if (strcasecmp(cmd, "scan-active") == 0)
3090 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303091 hddLog(VOS_TRACE_LEVEL_ERROR,
3092 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003093 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 ret = snprintf(cmd, cmd_len, "OK");
3095 }
3096 else if (strcasecmp(cmd, "scan-passive") == 0)
3097 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303098 hddLog(VOS_TRACE_LEVEL_ERROR,
3099 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003100 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 ret = snprintf(cmd, cmd_len, "OK");
3102 }
3103 else if( strcasecmp(cmd, "scan-mode") == 0 )
3104 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003105 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 }
3107 else if( strcasecmp(cmd, "linkspeed") == 0 )
3108 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003109 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 }
3111 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3112 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003113 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003114 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003115
3116 country_code = cmd + 8;
3117
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003118 init_completion(&pAdapter->change_country_code);
3119
Arif Hussain24bfa702014-01-22 13:51:30 -08003120 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003121 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 country_code,
3123 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303124 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303125 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303126 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003127
3128 /* Wait for completion */
3129 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3130 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3131
3132 if (lrc <= 0)
3133 {
3134 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003135 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003136 }
3137
Arif Hussain24bfa702014-01-22 13:51:30 -08003138 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003140 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003141 "%s: SME Change Country code fail", __func__);
3142 kfree(cmd);
3143 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 }
3145 }
3146 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3147 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003148 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 }
3150 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3151 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003152 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003153
Wilson Yang1be3e652013-10-09 15:18:31 -07003154 if (9 < cmd_len)
3155 {
3156 ptr = (char*)(cmd + 9);
3157
3158 }else{
3159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3160 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003161 kfree(cmd);
3162 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003163 }
3164
3165 if (1 != sscanf(ptr,"%d",&mode))
3166 {
3167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3168 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003169 kfree(cmd);
3170 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003171 }
3172
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 wlan_hdd_enter_bmps(pAdapter, mode);
3174 /*TODO:Set the power mode*/
3175 }
3176 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3177 v_U32_t pmc_state;
3178 v_U16_t value;
3179
3180 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3181 if(pmc_state == BMPS) {
3182 value = DRIVER_POWER_MODE_AUTO;
3183 }
3184 else {
3185 value = DRIVER_POWER_MODE_ACTIVE;
3186 }
3187 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3188 }
3189 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003190 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 /*TODO: set the btcoexmode*/
3192 }
3193 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3194
Arif Hussain6d2a3322013-11-17 19:50:10 -08003195 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 /*TODO: Return the btcoex status*/
3197 }
3198 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3199
Arif Hussain6d2a3322013-11-17 19:50:10 -08003200 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003201
3202 /*TODO: Enable Rx data Filter*/
3203 }
3204 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3205
Arif Hussain6d2a3322013-11-17 19:50:10 -08003206 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003207
3208 /*TODO: Disable Rx data Filter*/
3209 }
3210 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3211
Arif Hussain6d2a3322013-11-17 19:50:10 -08003212 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 /*TODO: rxfilter-statistics*/
3214 }
3215 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3216
Arif Hussain6d2a3322013-11-17 19:50:10 -08003217 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 /*TODO: rxfilter-add*/
3219 }
3220 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3221
Arif Hussain6d2a3322013-11-17 19:50:10 -08003222 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 /*TODO: rxfilter-remove*/
3224 }
3225#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003226 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3227 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3228 /*TODO: support pnosetup*/
3229 }
3230 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3231 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3232 /*TODO: support pnoforce*/
3233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3235
Arif Hussain6d2a3322013-11-17 19:50:10 -08003236 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003237 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3238 kfree(cmd);
3239 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 }
3241 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003242 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003243 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3244 kfree(cmd);
3245 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 }
3247#endif /*FEATURE_WLAN_SCAN_PNO*/
3248 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003249 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003250 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3251 kfree(cmd);
3252 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 }
3254 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3255 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003256 char *ptr;
3257
3258 if (18 < cmd_len)
3259 {
3260 ptr = (char*)(cmd + 18);
3261 }else{
3262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3263 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003264 kfree(cmd);
3265 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003266 }
3267
Jeff Johnson02797792013-10-26 19:17:13 -07003268 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003269 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3270 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3271 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3272 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3273 {
3274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3275 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003276 kfree(cmd);
3277 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003279
3280 // parameters checking
3281 // period has to be larger than 0
3282 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3283 {
3284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003285 kfree(cmd);
3286 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 }
3288
3289 // use default value 5 is the input is not reasonable. in unit of 10%
3290 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3291 {
3292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3293 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3294 }
3295
3296 // default is 5
3297 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3298 {
3299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3300 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3301 }
3302
Arif Hussain24bfa702014-01-22 13:51:30 -08003303 if (eHAL_STATUS_SUCCESS !=
3304 sme_SetTxPerTracking(pHddCtx->hHal,
3305 hdd_tx_per_hit_cb,
3306 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003308 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 }
3310 }
3311 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003312 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3313 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 }
3315done:
3316 /* many of the commands write information back into the command
3317 string using snprintf(). check the return value here in one
3318 place */
3319 if ((ret < 0) || (ret >= cmd_len))
3320 {
3321 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003322 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003324 else if (ret > 0)
3325 {
3326 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3327 {
3328 hddLog(VOS_TRACE_LEVEL_ERROR,
3329 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003330 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003331 return -EFAULT;
3332 }
3333 wrqu->data.length = ret;
3334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003335
3336 if (ioctl_debug)
3337 {
3338 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003339 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003341 kfree(cmd);
3342 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003343}
3344
3345static int iw_set_nick(struct net_device *dev,
3346 struct iw_request_info *info,
3347 union iwreq_data *wrqu, char *extra)
3348{
3349 ENTER();
3350 return 0;
3351}
3352
3353static int iw_get_nick(struct net_device *dev,
3354 struct iw_request_info *info,
3355 union iwreq_data *wrqu, char *extra)
3356{
3357 ENTER();
3358 return 0;
3359}
3360
3361static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3362{
3363 ENTER();
3364 return NULL;
3365}
3366
3367static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3368 union iwreq_data *wrqu,char *extra)
3369
3370{
3371 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3372 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3373 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3374 struct iw_point *encoderq = &(wrqu->encoding);
3375 v_U32_t keyId;
3376 v_U8_t key_length;
3377 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3378 v_BOOL_t fKeyPresent = 0;
3379 int i;
3380 eHalStatus status = eHAL_STATUS_SUCCESS;
3381
3382
3383 ENTER();
3384
3385 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3386 {
3387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3388 "%s:LOGP in Progress. Ignore!!!",__func__);
3389 return 0;
3390 }
3391
3392
3393 keyId = encoderq->flags & IW_ENCODE_INDEX;
3394
3395 if(keyId)
3396 {
3397 if(keyId > MAX_WEP_KEYS)
3398 {
3399 return -EINVAL;
3400 }
3401
3402 fKeyPresent = 1;
3403 keyId--;
3404 }
3405 else
3406 {
3407 fKeyPresent = 0;
3408 }
3409
3410
3411 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3412 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 if(!fKeyPresent) {
3415
3416 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3417
3418 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3419 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3420 }
3421 }
3422 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3423 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3424 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3425 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3426
3427 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3428 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3429
3430 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3431 {
3432 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3433 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003434 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303435 {
3436 long ret;
3437 ret = wait_for_completion_interruptible_timeout(
3438 &pAdapter->disconnect_comp_var,
3439 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3440 if (ret <= 0)
3441 hddLog(VOS_TRACE_LEVEL_ERROR,
3442 FL("failed wait on disconnect_comp_var %ld"), ret);
3443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 }
3445
3446 return status;
3447
3448 }
3449
3450 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3451 {
3452 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3453
3454 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3455
3456 }
3457
3458
3459 if(wrqu->data.length > 0)
3460 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003461 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003462
3463 key_length = wrqu->data.length;
3464
3465 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3466
3467 if(5 == key_length)
3468 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003469 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003470
3471 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3472 {
3473 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3474 }
3475 else
3476 {
3477 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3478 }
3479 }
3480 else if(13 == key_length)
3481 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003482 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003483
3484 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3485 {
3486 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3487 }
3488 else
3489 {
3490 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3491 }
3492 }
3493 else
3494 {
3495 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003496 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 return -EINVAL;
3498 }
3499
3500 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3501 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3502 pWextState->roamProfile.EncryptionType.numEntries = 1;
3503 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3504 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3505 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3506
3507 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3508 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3509 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3510 {
3511
3512 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3513
3514 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3515 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3516
3517 return status;
3518 }
3519 }
3520
3521 return 0;
3522}
3523
3524static int iw_get_encodeext(struct net_device *dev,
3525 struct iw_request_info *info,
3526 struct iw_point *dwrq,
3527 char *extra)
3528{
3529 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3530 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3531 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3532 int keyId;
3533 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3534 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3535 int i;
3536
3537 ENTER();
3538
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003539 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3540 {
3541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3542 "%s:LOGP in Progress. Ignore!!!", __func__);
3543 return -EBUSY;
3544 }
3545
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 keyId = pRoamProfile->Keys.defaultIndex;
3547
3548 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3549 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003550 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 return -EINVAL;
3552 }
3553
3554 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3555 {
3556 dwrq->flags |= IW_ENCODE_ENABLED;
3557 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303558 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3559 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 }
3561 else
3562 {
3563 dwrq->flags |= IW_ENCODE_DISABLED;
3564 }
3565
3566 for(i=0; i < MAX_WEP_KEYS; i++)
3567 {
3568 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3569 {
3570 continue;
3571 }
3572 else
3573 {
3574 break;
3575 }
3576 }
3577
3578 if(MAX_WEP_KEYS == i)
3579 {
3580 dwrq->flags |= IW_ENCODE_NOKEY;
3581 }
3582 else
3583 {
3584 dwrq->flags |= IW_ENCODE_ENABLED;
3585 }
3586
3587 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3588
3589 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3590 {
3591 dwrq->flags |= IW_ENCODE_DISABLED;
3592 }
3593
3594 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3595
3596 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3597 {
3598 dwrq->flags |= IW_ENCODE_OPEN;
3599 }
3600 else
3601 {
3602 dwrq->flags |= IW_ENCODE_RESTRICTED;
3603 }
3604 EXIT();
3605 return 0;
3606
3607}
3608
3609static int iw_set_encodeext(struct net_device *dev,
3610 struct iw_request_info *info,
3611 union iwreq_data *wrqu, char *extra)
3612{
3613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3614 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3615 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3616 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3617
3618 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3619 v_U32_t status = 0;
3620
3621 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3622
3623 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3624
3625 int key_index;
3626 struct iw_point *encoding = &wrqu->encoding;
3627 tCsrRoamSetKey setKey;
3628 v_U32_t roamId= 0xFF;
3629 VOS_STATUS vos_status;
3630
3631 ENTER();
3632
3633 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3634 {
3635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3636 "%s:LOGP in Progress. Ignore!!!",__func__);
3637 return 0;
3638 }
3639
3640 key_index = encoding->flags & IW_ENCODE_INDEX;
3641
3642 if(key_index > 0) {
3643
3644 /*Convert from 1-based to 0-based keying*/
3645 key_index--;
3646 }
3647 if(!ext->key_len) {
3648
3649 /*Set the encrytion type to NONE*/
3650 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3651 return status;
3652 }
3653
3654 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3655 (IW_ENCODE_ALG_WEP == ext->alg))
3656 {
3657 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3658
Agarwal Ashish971c2882013-10-30 20:11:12 +05303659 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3660 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 return -EINVAL;
3662 }
3663 else {
3664 /*Static wep, update the roam profile with the keys */
3665 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3666 key_index < CSR_MAX_NUM_KEY) {
3667 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3668 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3669
3670 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3671 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3672
3673 }
3674 }
3675 return status;
3676 }
3677
3678 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3679
3680 setKey.keyId = key_index;
3681 setKey.keyLength = ext->key_len;
3682
3683 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3684 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3685 }
3686
3687 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3688 /*Key direction for group is RX only*/
3689 setKey.keyDirection = eSIR_RX_ONLY;
3690 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3691 }
3692 else {
3693
3694 setKey.keyDirection = eSIR_TX_RX;
3695 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3696 }
3697
3698 /*For supplicant pae role is zero*/
3699 setKey.paeRole = 0;
3700
3701 switch(ext->alg)
3702 {
3703 case IW_ENCODE_ALG_NONE:
3704 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3705 break;
3706
3707 case IW_ENCODE_ALG_WEP:
3708 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3709 break;
3710
3711 case IW_ENCODE_ALG_TKIP:
3712 {
3713 v_U8_t *pKey = &setKey.Key[0];
3714
3715 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3716
3717 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3718
3719 /*Supplicant sends the 32bytes key in this order
3720
3721 |--------------|----------|----------|
3722 | Tk1 |TX-MIC | RX Mic |
3723 |--------------|----------|----------|
3724 <---16bytes---><--8bytes--><--8bytes-->
3725
3726 */
3727 /*Sme expects the 32 bytes key to be in the below order
3728
3729 |--------------|----------|----------|
3730 | Tk1 |RX-MIC | TX Mic |
3731 |--------------|----------|----------|
3732 <---16bytes---><--8bytes--><--8bytes-->
3733 */
3734 /* Copy the Temporal Key 1 (TK1) */
3735 vos_mem_copy(pKey,ext->key,16);
3736
3737 /*Copy the rx mic first*/
3738 vos_mem_copy(&pKey[16],&ext->key[24],8);
3739
3740 /*Copy the tx mic */
3741 vos_mem_copy(&pKey[24],&ext->key[16],8);
3742
3743 }
3744 break;
3745
3746 case IW_ENCODE_ALG_CCMP:
3747 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3748 break;
3749
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003750#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003751#define IW_ENCODE_ALG_KRK 6
3752 case IW_ENCODE_ALG_KRK:
3753 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3754 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003755#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003756
3757 default:
3758 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3759 break;
3760 }
3761
3762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003763 ("%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 -07003764
3765#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303766 /* The supplicant may attempt to set the PTK once pre-authentication
3767 is done. Save the key in the UMAC and include it in the ADD
3768 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303770 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303772 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3773 "%s: Update PreAuth Key success", __func__);
3774 return 0;
3775 }
3776 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3777 {
3778 hddLog(VOS_TRACE_LEVEL_ERROR,
3779 "%s: Update PreAuth Key failed", __func__);
3780 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 }
3782#endif /* WLAN_FEATURE_VOWIFI_11R */
3783
3784 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3785
3786 vos_status = wlan_hdd_check_ula_done(pAdapter);
3787 if ( vos_status != VOS_STATUS_SUCCESS )
3788 {
3789 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3790 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3791 __LINE__, vos_status );
3792
3793 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3794 }
3795
3796 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3797
3798 if ( halStatus != eHAL_STATUS_SUCCESS )
3799 {
3800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3801 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3802 __LINE__, halStatus );
3803
3804 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3805 }
3806
3807 return halStatus;
3808}
3809
3810static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3811 union iwreq_data *wrqu, char *extra)
3812{
3813 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3814 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3815
3816 ENTER();
3817
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003818 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3819 {
3820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3821 "%s:LOGP in Progress. Ignore!!!", __func__);
3822 return -EBUSY;
3823 }
3824
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3826 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3827
Arif Hussain6d2a3322013-11-17 19:50:10 -08003828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003829
3830 return -EINVAL;
3831 }
3832
3833 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3834
3835 if((wrqu->retry.flags & IW_RETRY_LONG))
3836 {
3837 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3838 {
c_hpothub8245442013-11-20 23:41:09 +05303839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3840 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 return -EIO;
3842 }
3843 }
3844 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3845 {
3846 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3847 {
c_hpothub8245442013-11-20 23:41:09 +05303848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3849 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 return -EIO;
3851 }
3852 }
3853 }
3854 else
3855 {
3856 return -EOPNOTSUPP;
3857 }
3858
Arif Hussain6d2a3322013-11-17 19:50:10 -08003859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003860
3861 EXIT();
3862
3863 return 0;
3864
3865}
3866
3867static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3868 union iwreq_data *wrqu, char *extra)
3869{
3870 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3871 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3872 v_U32_t retry = 0;
3873
3874 ENTER();
3875
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003876 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3877 {
3878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3879 "%s:LOGP in Progress. Ignore!!!", __func__);
3880 return -EBUSY;
3881 }
3882
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 if((wrqu->retry.flags & IW_RETRY_LONG))
3884 {
3885 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3886
3887 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3888 {
c_hpothub8245442013-11-20 23:41:09 +05303889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3890 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 return -EIO;
3892 }
3893
3894 wrqu->retry.value = retry;
3895 }
3896 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3897 {
3898 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3899
3900 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3901 {
c_hpothub8245442013-11-20 23:41:09 +05303902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3903 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 return -EIO;
3905 }
3906
3907 wrqu->retry.value = retry;
3908 }
3909 else {
3910 return -EOPNOTSUPP;
3911 }
3912
Arif Hussain6d2a3322013-11-17 19:50:10 -08003913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003914
3915 EXIT();
3916
3917 return 0;
3918}
3919
3920static int iw_set_mlme(struct net_device *dev,
3921 struct iw_request_info *info,
3922 union iwreq_data *wrqu,
3923 char *extra)
3924{
3925 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3926 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3927 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3928 eHalStatus status = eHAL_STATUS_SUCCESS;
3929
3930 ENTER();
3931
3932 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3933 {
3934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3935 "%s:LOGP in Progress. Ignore!!!",__func__);
3936 return 0;
3937 }
3938
3939 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3940 switch (mlme->cmd) {
3941 case IW_MLME_DISASSOC:
3942 case IW_MLME_DEAUTH:
3943
3944 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3945 {
3946 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3947
3948 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3949 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3950
3951 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3952 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3953
Jeff Johnson43971f52012-07-17 12:26:56 -07003954 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303955 {
3956 long ret;
3957 ret = wait_for_completion_interruptible_timeout(
3958 &pAdapter->disconnect_comp_var,
3959 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3960 if (ret <= 0)
3961 hddLog(VOS_TRACE_LEVEL_ERROR,
3962 FL("failed wait on disconnect_comp_var %ld"), ret);
3963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003965 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003966 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003967
3968 /* Resetting authKeyMgmt */
3969 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3970
3971 netif_tx_disable(dev);
3972 netif_carrier_off(dev);
3973
3974 }
3975 else
3976 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003977 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 -07003978 }
3979 break;
3980 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003981 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 return -EINVAL;
3983 }//end of switch
3984
3985 EXIT();
3986
3987 return status;
3988
3989}
3990
3991/* set param sub-ioctls */
3992static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3993 union iwreq_data *wrqu, char *extra)
3994{
3995 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3996 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3997 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3998 int *value = (int *)extra;
3999 int sub_cmd = value[0];
4000 int set_value = value[1];
4001 int ret = 0; /* success */
4002 int enable_pbm, enable_mp;
4003#ifdef CONFIG_HAS_EARLYSUSPEND
4004 v_U8_t nEnableSuspendOld;
4005#endif
4006 INIT_COMPLETION(pWextState->completion_var);
4007
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004008 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4009 {
4010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4011 "%s:LOGP in Progress. Ignore!!!", __func__);
4012 return -EBUSY;
4013 }
4014
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 switch(sub_cmd)
4016 {
4017 case WE_SET_11D_STATE:
4018 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004019 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004020 memset(&smeConfig, 0x00, sizeof(smeConfig));
4021
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4023
4024 sme_GetConfigParam(hHal,&smeConfig);
4025 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4026
Arif Hussain6d2a3322013-11-17 19:50:10 -08004027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004028
4029 sme_UpdateConfig(hHal,&smeConfig);
4030 }
4031 else {
4032 return -EINVAL;
4033 }
4034 break;
4035 }
4036
4037 case WE_WOWL:
4038 {
4039 switch (set_value)
4040 {
4041 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004042 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 break;
4044 case 0x01:
4045 case 0x02:
4046 case 0x03:
4047 enable_mp = (set_value & 0x01) ? 1 : 0;
4048 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004049 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4051 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4052 break;
4053 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004054 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 ret = -EINVAL;
4056 break;
4057 }
4058
4059 break;
4060 }
4061 case WE_SET_POWER:
4062 {
4063 switch (set_value)
4064 {
4065 case 0: //Full Power
4066 {
4067 struct statsContext context;
4068 eHalStatus status;
4069
4070 init_completion(&context.completion);
4071
4072 context.pAdapter = pAdapter;
4073 context.magic = POWER_CONTEXT_MAGIC;
4074
4075 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4076 iw_power_callback_fn, &context,
4077 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004078 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 {
4080 int lrc = wait_for_completion_interruptible_timeout(
4081 &context.completion,
4082 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004083
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 if (lrc <= 0)
4085 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004086 hddLog(VOS_TRACE_LEVEL_ERROR,
4087 "%s: SME %s while requesting fullpower",
4088 __func__, (0 == lrc) ?
4089 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 }
4091 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004092 /* either we have a response or we timed out. if we timed
4093 out there is a race condition such that the callback
4094 function could be executing at the same time we are. of
4095 primary concern is if the callback function had already
4096 verified the "magic" but had not yet set the completion
4097 variable when a timeout occurred. we serialize these
4098 activities by invalidating the magic while holding a
4099 shared spinlock which will cause us to block if the
4100 callback is currently executing */
4101 spin_lock(&hdd_context_lock);
4102 context.magic = 0;
4103 spin_unlock(&hdd_context_lock);
4104
Arif Hussain6d2a3322013-11-17 19:50:10 -08004105 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 break;
4107 }
4108 case 1: //Enable BMPS
4109 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4110 break;
4111 case 2: //Disable BMPS
4112 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4113 break;
4114 case 3: //Request Bmps
4115 {
4116 struct statsContext context;
4117 eHalStatus status;
4118
4119 init_completion(&context.completion);
4120
4121 context.pAdapter = pAdapter;
4122 context.magic = POWER_CONTEXT_MAGIC;
4123
4124 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4125 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004126 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 {
4128 int lrc = wait_for_completion_interruptible_timeout(
4129 &context.completion,
4130 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 if (lrc <= 0)
4132 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004133 hddLog(VOS_TRACE_LEVEL_ERROR,
4134 "%s: SME %s while requesting BMPS",
4135 __func__, (0 == lrc) ? "timeout" :
4136 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 }
4138 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004139 /* either we have a response or we timed out. if we
4140 timed out there is a race condition such that the
4141 callback function could be executing at the same
4142 time we are. of primary concern is if the callback
4143 function had already verified the "magic" but had
4144 not yet set the completion variable when a timeout
4145 occurred. we serialize these activities by
4146 invalidating the magic while holding a shared
4147 spinlock which will cause us to block if the
4148 callback is currently executing */
4149 spin_lock(&hdd_context_lock);
4150 context.magic = 0;
4151 spin_unlock(&hdd_context_lock);
4152
Arif Hussain6d2a3322013-11-17 19:50:10 -08004153 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 break;
4155 }
4156 case 4: //Enable IMPS
4157 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4158 break;
4159 case 5: //Disable IMPS
4160 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4161 break;
4162 case 6: //Enable Standby
4163 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4164 break;
4165 case 7: //Disable Standby
4166 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4167 break;
4168 case 8: //Request Standby
4169#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004170#endif
4171 break;
4172 case 9: //Start Auto Bmps Timer
4173 sme_StartAutoBmpsTimer(hHal);
4174 break;
4175 case 10://Stop Auto BMPS Timer
4176 sme_StopAutoBmpsTimer(hHal);
4177 break;
4178#ifdef CONFIG_HAS_EARLYSUSPEND
4179 case 11://suspend to standby
4180#ifdef CONFIG_HAS_EARLYSUSPEND
4181 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4182 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4184#endif
4185 break;
4186 case 12://suspend to deep sleep
4187#ifdef CONFIG_HAS_EARLYSUSPEND
4188 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4189 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4191#endif
4192 break;
4193 case 13://resume from suspend
4194#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004195#endif
4196 break;
4197#endif
4198 case 14://reset wlan (power down/power up)
4199 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4200 break;
4201 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004202 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 ret = -EINVAL;
4204 break;
4205 }
4206 break;
4207 }
4208
4209 case WE_SET_MAX_ASSOC:
4210 {
4211 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4212 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4213 {
4214 ret = -EINVAL;
4215 }
4216 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4217 set_value, NULL, eANI_BOOLEAN_FALSE)
4218 != eHAL_STATUS_SUCCESS )
4219 {
c_hpothub8245442013-11-20 23:41:09 +05304220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4221 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 ret = -EIO;
4223 }
4224 break;
4225 }
4226
4227 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4228 {
4229 if( 0 == set_value )
4230 {
4231 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4232 }
4233 else if ( 1 == set_value )
4234 {
4235 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4236 }
4237 else
4238 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004239 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 ret = -EINVAL;
4241 }
4242 break;
4243 }
4244
4245 case WE_SET_DATA_INACTIVITY_TO:
4246 {
4247 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4248 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4249 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4250 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4251 set_value,
4252 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4253 {
4254 hddLog(LOGE,"Failure: Could not pass on "
4255 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004256 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 ret = -EINVAL;
4258 }
4259 break;
4260 }
4261 case WE_SET_MAX_TX_POWER:
4262 {
4263 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4264 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4265
4266 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4267 __func__, set_value);
4268 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4269 eHAL_STATUS_SUCCESS )
4270 {
4271 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4272 __func__);
4273 return -EIO;
4274 }
4275
4276 break;
4277 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004278 case WE_SET_MAX_TX_POWER_2_4:
4279 {
4280 hddLog(VOS_TRACE_LEVEL_INFO,
4281 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4282 __func__, set_value);
4283 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4284 eHAL_STATUS_SUCCESS)
4285 {
4286 hddLog(VOS_TRACE_LEVEL_ERROR,
4287 "%s: Setting maximum tx power failed for 2.4 GHz band",
4288 __func__);
4289 return -EIO;
4290 }
4291
4292 break;
4293 }
4294 case WE_SET_MAX_TX_POWER_5_0:
4295 {
4296 hddLog(VOS_TRACE_LEVEL_INFO,
4297 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4298 __func__, set_value);
4299 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4300 eHAL_STATUS_SUCCESS)
4301 {
4302 hddLog(VOS_TRACE_LEVEL_ERROR,
4303 "%s: Setting maximum tx power failed for 5.0 GHz band",
4304 __func__);
4305 return -EIO;
4306 }
4307
4308 break;
4309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 case WE_SET_HIGHER_DTIM_TRANSITION:
4311 {
4312 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4313 (set_value == eANI_BOOLEAN_TRUE)))
4314 {
4315 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4316 ret = -EINVAL;
4317 }
4318 else
4319 {
4320 if(pAdapter->higherDtimTransition != set_value)
4321 {
4322 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004323 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 }
4325 }
4326
4327 break;
4328 }
4329
4330 case WE_SET_TM_LEVEL:
4331 {
4332 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004333 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4335
4336 break;
4337 }
4338
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304339 case WE_ENABLE_STRICT_FCC_REG:
4340 {
4341 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4342 struct wiphy *wiphy = NULL;
4343 long lrc;
4344 int status;
4345
4346 wiphy = hddCtxt->wiphy;
4347 if(wiphy == NULL)
4348 {
4349 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4350 break;
4351 }
4352 init_completion(&hddCtxt->wiphy_channel_update_event);
4353
4354 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4355
4356 status = regulatory_hint(wiphy, "00");
4357 if(status < 0)
4358 {
4359 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4360 break;
4361 }
4362
4363 /* Wait for completion */
4364 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4365 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4366 if (lrc <= 0)
4367 {
4368 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4369 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4370 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4371 }
4372 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4373
4374 break;
4375 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004376 case WE_SET_DEBUG_LOG:
4377 {
4378 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4379 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4380 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4381 break;
4382 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304383
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 default:
4385 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004386 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 sub_cmd, set_value);
4388 break;
4389 }
4390 }
4391
4392 return ret;
4393}
4394
4395/* set param sub-ioctls */
4396static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4397 union iwreq_data *wrqu, char *extra)
4398{
4399 VOS_STATUS vstatus;
4400 int sub_cmd = wrqu->data.flags;
4401 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004402 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4404 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4405#ifdef WLAN_FEATURE_VOWIFI
4406 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4407#endif /* WLAN_FEATURE_VOWIFI */
4408
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004409 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4410 {
4411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4412 "%s:LOGP in Progress. Ignore!!!", __func__);
4413 return -EBUSY;
4414 }
4415
Arif Hussain0273cba2014-01-07 20:58:29 -08004416 /* ODD number is used for set, copy data using copy_from_user */
4417 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4418 wrqu->data.length);
4419 if (NULL == pBuffer)
4420 {
4421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4422 "mem_alloc_copy_from_user_helper fail");
4423 return -ENOMEM;
4424 }
4425
4426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4427 "%s: Received length %d", __func__, wrqu->data.length);
4428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4429 "%s: Received data %s", __func__, pBuffer);
4430
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 switch(sub_cmd)
4432 {
4433 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004435 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 break;
4437 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004439 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 break;
4441#if defined WLAN_FEATURE_VOWIFI
4442 case WE_NEIGHBOR_REPORT_REQUEST:
4443 {
4444 tRrmNeighborReq neighborReq;
4445 tRrmNeighborRspCallbackInfo callbackInfo;
4446
4447 if (pConfig->fRrmEnable)
4448 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4451 if( !neighborReq.no_ssid )
4452 {
4453 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004454 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 }
4456
4457 callbackInfo.neighborRspCallback = NULL;
4458 callbackInfo.neighborRspCallbackContext = NULL;
4459 callbackInfo.timeout = 5000; //5 seconds
4460 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4461 }
4462 else
4463 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004464 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 ret = -EINVAL;
4466 }
4467 }
4468 break;
4469#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 case WE_SET_AP_WPS_IE:
4471 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004472 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004475 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 if (VOS_STATUS_SUCCESS != vstatus)
4477 {
4478 ret = -EINVAL;
4479 }
4480 break;
4481 default:
4482 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004483 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 ret = -EINVAL;
4485 break;
4486 }
4487 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004488 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 return ret;
4490}
4491
4492/* get param sub-ioctls */
4493static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4494 union iwreq_data *wrqu, char *extra)
4495{
4496 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4497 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4498 int *value = (int *)extra;
4499 int ret = 0; /* success */
4500
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004501 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4502 {
4503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4504 "%s:LOGP in Progress. Ignore!!!", __func__);
4505 return -EBUSY;
4506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004507
4508 switch (value[0])
4509 {
4510 case WE_GET_11D_STATE:
4511 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004512 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304514
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4516
Arif Hussain6d2a3322013-11-17 19:50:10 -08004517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004518
4519 break;
4520 }
4521
4522 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 break;
4525
4526 case WE_PMC_STATE:
4527 {
4528 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 break;
4531 }
4532 case WE_GET_WLAN_DBG:
4533 {
4534 vos_trace_display();
4535 *value = 0;
4536 break;
4537 }
4538 case WE_MODULE_DOWN_IND:
4539 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4542#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4545#endif
4546 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4547
4548 *value = 0;
4549 break;
4550 }
4551 case WE_GET_MAX_ASSOC:
4552 {
4553 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4554 {
c_hpothub8245442013-11-20 23:41:09 +05304555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4556 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 ret = -EIO;
4558 }
4559 break;
4560 }
4561
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 case WE_GET_WDI_DBG:
4563 {
4564 wpalTraceDisplay();
4565 *value = 0;
4566 break;
4567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004568
4569 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4570 {
4571 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4572 break;
4573 }
4574 case WE_GET_CONCURRENCY_MODE:
4575 {
4576 *value = hdd_get_concurrency_mode ( );
4577
Arif Hussain6d2a3322013-11-17 19:50:10 -08004578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 break;
4580 }
4581
4582 default:
4583 {
4584 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4585 break;
4586 }
4587 }
4588
4589 return ret;
4590}
4591
4592/* set param sub-ioctls */
4593int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4594 union iwreq_data *wrqu, char *extra)
4595{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004596 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 int *value = (int *)extra;
4598 int sub_cmd = value[0];
4599 int ret = 0;
4600
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004601 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4602 {
4603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4604 "%s:LOGP in Progress. Ignore!!!", __func__);
4605 return -EBUSY;
4606 }
4607
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 switch(sub_cmd)
4609 {
4610 case WE_SET_WLAN_DBG:
4611 {
4612 vos_trace_setValue( value[1], value[2], value[3]);
4613 break;
4614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 case WE_SET_WDI_DBG:
4616 {
4617 wpalTraceSetLevel( value[1], value[2], value[3]);
4618 break;
4619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 case WE_SET_SAP_CHANNELS:
4621 {
4622 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4623 break;
4624 }
4625
4626 default:
4627 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004628 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 break;
4630 }
4631 }
4632 return ret;
4633}
4634
4635static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4636 union iwreq_data *wrqu, char *extra)
4637{
4638 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4639 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004640#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004641 hdd_wext_state_t *pWextState;
4642#endif
4643
4644 if (pAdapter == NULL)
4645 {
4646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4647 "%s: pAdapter is NULL!", __func__);
4648 return -EINVAL;
4649 }
4650#ifdef WLAN_FEATURE_11W
4651 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004652#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004653
Yue Ma3ede6052013-08-29 00:33:26 -07004654 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4655 {
4656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4657 "%s: HDD Context is NULL!", __func__);
4658
4659 return -EINVAL;
4660 }
4661
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004662 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4663 {
4664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4665 "%s:LOGP in Progress. Ignore!!!", __func__);
4666 return -EBUSY;
4667 }
4668
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 switch(sub_cmd)
4670 {
4671 case WE_WLAN_VERSION:
4672 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004673 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 break;
4675 }
4676
4677 case WE_GET_STATS:
4678 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304679 tHalHandle hHal = NULL;
4680 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4682 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4683 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4684
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304685
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 snprintf(extra, WE_MAX_STR_LEN,
4687 "\nTransmit"
4688 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4689 "\n dropped BK %u, BE %u, VI %u, VO %u"
4690 "\n classified BK %u, BE %u, VI %u, VO %u"
4691 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4692 "\n queued BK %u, BE %u, VI %u, VO %u"
4693 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004694 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 "\n fetched BK %u, BE %u, VI %u, VO %u"
4696 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4697 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004698 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 "\n flushed BK %u, BE %u, VI %u, VO %u"
4700 "\n\nReceive"
4701 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4702 "\n\nResetsStats"
4703 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4704 "\n",
4705 pStats->txXmitCalled,
4706 pStats->txXmitDropped,
4707 pStats->txXmitBackPressured,
4708 pStats->txXmitQueued,
4709
4710 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4711 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4712 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4713 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4714
4715 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4716 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4717 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4718 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4719
4720 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4721 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4722 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4723 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4724
4725 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4726 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4727 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4728 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4729
4730 pStats->txFetched,
4731 pStats->txFetchEmpty,
4732 pStats->txFetchLowResources,
4733 pStats->txFetchDequeueError,
4734
4735 pStats->txFetchDequeued,
4736 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004737 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 pStats->txCompleted,
4739 pStats->txFlushed,
4740
4741 pStats->txFetchedAC[WLANTL_AC_BK],
4742 pStats->txFetchedAC[WLANTL_AC_BE],
4743 pStats->txFetchedAC[WLANTL_AC_VI],
4744 pStats->txFetchedAC[WLANTL_AC_VO],
4745
4746 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4747 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4748 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4749 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4750
4751 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4752 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4753 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4754 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4755
Ravi Joshi41914632013-10-21 23:02:21 -07004756 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4757 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4758 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4759 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4760
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 pStats->txFlushedAC[WLANTL_AC_BK],
4762 pStats->txFlushedAC[WLANTL_AC_BE],
4763 pStats->txFlushedAC[WLANTL_AC_VI],
4764 pStats->txFlushedAC[WLANTL_AC_VO],
4765
4766 pStats->rxChains,
4767 pStats->rxPackets,
4768 pStats->rxDropped,
4769 pStats->rxDelivered,
4770 pStats->rxRefused,
4771
4772 pResetStats->totalLogpResets,
4773 pResetStats->totalCMD53Failures,
4774 pResetStats->totalMutexReadFailures,
4775 pResetStats->totalMIFErrorFailures,
4776 pResetStats->totalFWHearbeatFailures,
4777 pResetStats->totalUnknownExceptions
4778 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304779 wrqu->data.length = strlen(extra);
4780
4781 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
4782
4783 if (hHal)
4784 pMac = PMAC_STRUCT( hHal );
4785
4786 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
4787 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
4788 snprintf(extra+wrqu->data.length, pmmStatsLength,
4789 "\n BMPS sleepcnt %llx, BMPS awakecnt %llx"
4790 "\n BMPS sleepreqfailcnt %llx, BMPS wakeupreqfailcnt %llx"
4791 "\n IMPS sleepcnt %llx, IMPS awakecnt %llx"
4792 "\n IMPS sleeperrcnt %llx, IMPS wakeuperrcnt %llx, IMPS lasterr %llx"
4793 "\n",
4794 pMac->pmm.BmpscntSleep,
4795 pMac->pmm.BmpscntAwake,
4796 pMac->pmm.BmpsSleeReqFailCnt,
4797 pMac->pmm.BmpsWakeupReqFailCnt,
4798 pMac->pmm.ImpsCntSleep,
4799 pMac->pmm.ImpsCntAwake,
4800 pMac->pmm.ImpsSleepErrCnt,
4801 pMac->pmm.ImpsWakeupErrCnt,
4802 pMac->pmm.ImpsLastErr
4803 );
4804 }
4805
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 wrqu->data.length = strlen(extra)+1;
4807 break;
4808 }
4809
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304810/* The case prints the current state of the HDD, SME, CSR, PE, TL
4811 *it can be extended for WDI Global State as well.
4812 *And currently it only checks P2P_CLIENT adapter.
4813 *P2P_DEVICE and P2P_GO have not been added as of now.
4814*/
4815 case WE_GET_STATES:
4816 {
4817 int buf = 0, len = 0;
4818 int adapter_num = 0;
4819 int count = 0, check = 1;
4820
4821 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004822 tHalHandle hHal = NULL;
4823 tpAniSirGlobal pMac = NULL;
4824 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304825
4826 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4827 hdd_adapter_t *useAdapter = NULL;
4828
4829 /* Print wlan0 or p2p0 states based on the adapter_num
4830 *by using the correct adapter
4831 */
4832 while ( adapter_num < 2 )
4833 {
4834 if ( WLAN_ADAPTER == adapter_num )
4835 {
4836 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004837 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304838 "\n\n wlan0 States:-");
4839 len += buf;
4840 }
4841 else if ( P2P_ADAPTER == adapter_num )
4842 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004843 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304844 "\n\n p2p0 States:-");
4845 len += buf;
4846
4847 if( !pHddCtx )
4848 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004849 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304850 "\n pHddCtx is NULL");
4851 len += buf;
4852 break;
4853 }
4854
4855 /*Printing p2p0 states only in the case when the device is
4856 configured as a p2p_client*/
4857 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4858 if ( !useAdapter )
4859 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004860 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304861 "\n Device not configured as P2P_CLIENT.");
4862 len += buf;
4863 break;
4864 }
4865 }
4866
4867 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004868 if (!hHal) {
4869 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4870 "\n pMac is NULL");
4871 len += buf;
4872 break;
4873 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304874 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004875 if (!pMac) {
4876 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4877 "\n pMac is NULL");
4878 len += buf;
4879 break;
4880 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304881 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4882 if( !pHddStaCtx )
4883 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004884 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304885 "\n pHddStaCtx is NULL");
4886 len += buf;
4887 break;
4888 }
4889
4890 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4891
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004892 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304893 "\n HDD Conn State - %s "
4894 "\n \n SME State:"
4895 "\n Neighbour Roam State - %s"
4896 "\n CSR State - %s"
4897 "\n CSR Substate - %s"
4898 "\n \n TL STA %d State: %s",
4899 macTraceGetHDDWlanConnState(
4900 pHddStaCtx->conn_info.connState),
4901 macTraceGetNeighbourRoamState(
4902 pMac->roam.neighborRoamInfo.neighborRoamState),
4903 macTraceGetcsrRoamState(
4904 pMac->roam.curState[useAdapter->sessionId]),
4905 macTraceGetcsrRoamSubState(
4906 pMac->roam.curSubState[useAdapter->sessionId]),
4907 pHddStaCtx->conn_info.staId[0],
4908 macTraceGetTLState(tlState)
4909 );
4910 len += buf;
4911 adapter_num++;
4912 }
4913
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004914 if (pMac) {
4915 /* Printing Lim State starting with global lim states */
4916 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4917 "\n \n LIM STATES:-"
4918 "\n Global Sme State - %s "\
4919 "\n Global mlm State - %s "\
4920 "\n",
4921 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4922 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4923 );
4924 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304925
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004926 /*printing the PE Sme and Mlm states for valid lim sessions*/
4927 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304928 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004929 if ( pMac->lim.gpSession[count].valid )
4930 {
4931 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4932 "\n Lim Valid Session %d:-"
4933 "\n PE Sme State - %s "
4934 "\n PE Mlm State - %s "
4935 "\n",
4936 check,
4937 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4938 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4939 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304940
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004941 len += buf;
4942 check++;
4943 }
4944 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304945 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304946 }
4947
4948 wrqu->data.length = strlen(extra)+1;
4949 break;
4950 }
4951
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 case WE_GET_CFG:
4953 {
4954 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4955 wrqu->data.length = strlen(extra)+1;
4956 break;
4957 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004958#ifdef WLAN_FEATURE_11AC
4959 case WE_GET_RSSI:
4960 {
4961 v_S7_t s7Rssi = 0;
4962 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4963 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4964 wrqu->data.length = strlen(extra)+1;
4965 break;
4966 }
4967#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304968
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004969#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004970 case WE_GET_ROAM_RSSI:
4971 {
4972 v_S7_t s7Rssi = 0;
4973 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4974 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4975 wrqu->data.length = strlen(extra)+1;
4976 break;
4977 }
4978#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 case WE_GET_WMM_STATUS:
4980 {
4981 snprintf(extra, WE_MAX_STR_LEN,
4982 "\nDir: 0=up, 1=down, 3=both\n"
4983 "|------------------------|\n"
4984 "|AC | ACM |Admitted| Dir |\n"
4985 "|------------------------|\n"
4986 "|VO | %d | %3s | %d |\n"
4987 "|VI | %d | %3s | %d |\n"
4988 "|BE | %d | %3s | %d |\n"
4989 "|BK | %d | %3s | %d |\n"
4990 "|------------------------|\n",
4991 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4992 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4993 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4994 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4995 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4996 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4997 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4998 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4999 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5000 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5001 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5002 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5003
Jeff Johnsone7245742012-09-05 17:12:55 -07005004
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 wrqu->data.length = strlen(extra)+1;
5006 break;
5007 }
5008 case WE_GET_CHANNEL_LIST:
5009 {
5010 VOS_STATUS status;
5011 v_U8_t i, len;
5012 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305013 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5014 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5015 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 tChannelListInfo channel_list;
5017
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005018 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005020 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005022 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 return -EINVAL;
5024 }
5025 buf = extra;
5026
5027 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005028 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5029 * needed = 5 * number of channels. Check ifsufficient
5030 * buffer is available and then proceed to fill the buffer.
5031 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5033 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005034 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005035 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005036 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 return -EINVAL;
5038 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005039 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5040 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305041 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5042 {
5043 //Printing Country code in getChannelList
5044 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5045 {
5046 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5047 "%c ", pBuf[i]);
5048 }
5049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 for(i = 0 ; i < channel_list.num_channels; i++)
5051 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005052 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 }
5055 wrqu->data.length = strlen(extra)+1;
5056
5057 break;
5058 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005059#ifdef FEATURE_WLAN_TDLS
5060 case WE_GET_TDLS_PEERS:
5061 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005062 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005063 break;
5064 }
5065#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005066#ifdef WLAN_FEATURE_11W
5067 case WE_GET_11W_INFO:
5068 {
5069 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5070
5071 snprintf(extra, WE_MAX_STR_LEN,
5072 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5073 "\n Number of Unprotected Disassocs %d"
5074 "\n Number of Unprotected Deauths %d",
5075 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5076 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5077 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5078 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5079 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5080
5081 wrqu->data.length = strlen(extra)+1;
5082 break;
5083 }
5084#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305085 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005087 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 break;
5089 }
5090 }
5091
5092 return 0;
5093}
5094
5095/* action sub-ioctls */
5096static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5097 union iwreq_data *wrqu, char *extra)
5098{
5099 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5100 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005101 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07005102
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005103 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5104 {
5105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5106 "%s:LOGP in Progress. Ignore!!!", __func__);
5107 return -EBUSY;
5108 }
5109
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 switch (sub_cmd)
5111 {
5112 case WE_CLEAR_STATS:
5113 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5116 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5117 break;
5118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 case WE_INIT_AP:
5120 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305121 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5122
5123 /* As Soft AP mode might been changed to STA already with
5124 * killing of Hostapd, need to find the adpater by name
5125 * rather than mode */
5126 hdd_adapter_t* pAdapter_to_stop =
5127 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5128 if( pAdapter_to_stop )
5129 {
5130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5131 "Adapter with name softap.0 already "
5132 "exist, ignoring the request.\nRemove the "
5133 "adapter and try again\n");
5134 break;
5135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 pr_info("Init AP trigger\n");
5137 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5138 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5139 break;
5140 }
5141 case WE_STOP_AP:
5142 {
5143 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5144 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5145 * this is a dead code and need to find the adpater by name rather than mode */
5146 hdd_adapter_t* pAdapter_to_stop =
5147 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5148 if( pAdapter_to_stop )
5149 {
5150 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5151
5152 pr_info("Stopping AP mode\n");
5153
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305154 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5155 {
5156 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5157 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5158 }
5159
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 /*Make sure that pAdapter cleaned properly*/
5161 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5162 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5163 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5164
5165 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5166 pAdapter_to_stop->macAddressCurrent.bytes);
5167 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5168 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305169
5170 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5171 {
5172 /* put the device back into BMPS */
5173 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005175 }
5176 else
5177 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005178 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 }
5180
5181 break;
5182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005183#ifdef WLAN_BTAMP_FEATURE
5184 case WE_ENABLE_AMP:
5185 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 WLANBAP_RegisterWithHCI(pAdapter);
5188 break;
5189 }
5190 case WE_DISABLE_AMP:
5191 {
5192 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5193 VOS_STATUS status;
5194
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005196
5197 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5198 status = WLANBAP_StopAmp();
5199 if(VOS_STATUS_SUCCESS != status )
5200 {
5201 pHddCtx->isAmpAllowed = VOS_TRUE;
5202 hddLog(VOS_TRACE_LEVEL_FATAL,
5203 "%s: Failed to stop AMP", __func__);
5204 }
5205 else
5206 {
5207 //a state m/c implementation in PAL is TBD to avoid this delay
5208 msleep(500);
5209 pHddCtx->isAmpAllowed = VOS_FALSE;
5210 WLANBAP_DeregisterFromHCI();
5211 }
5212
5213 break;
5214 }
5215#endif
5216
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005217 case WE_ENABLE_DXE_STALL_DETECT:
5218 {
schang6295e542013-03-12 15:31:23 -07005219 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5220 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005221 break;
5222 }
5223 case WE_DISPLAY_DXE_SNAP_SHOT:
5224 {
schang6295e542013-03-12 15:31:23 -07005225 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5226 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005227 break;
5228 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305229 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5230 {
5231 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5232 hdd_wmm_tx_snapshot(pAdapter);
5233 WLANTL_TLDebugMessage(VOS_TRUE);
5234 break;
5235 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305236
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305237 case WE_STOP_OBSS_SCAN:
5238 {
5239 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5240 2.OBSS scan is stopped by Firmware during the disassociation
5241 3.OBSS stop comamnd is added for debugging purpose*/
5242 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5243 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005244
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305245 if (pAdapter == NULL)
5246 {
5247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5248 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305249 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305250 }
5251 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5252 if (pMac == NULL)
5253 {
5254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5255 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305256 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305257 }
5258 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5259 }
5260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 default:
5262 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005263 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005264 break;
5265 }
5266 }
5267
5268 return ret;
5269}
5270
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305271void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5272{
5273 /*
5274 * Function to display HDD WMM information
5275 * for Tx Queues.
5276 * Prints globala as well as per client depending
5277 * whether the clients are registered or not.
5278 */
5279 int i = 0, j = 0;
5280 for ( i=0; i< NUM_TX_QUEUES; i++)
5281 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305282 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005283 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305284 i, pAdapter->wmm_tx_queue[i].count,
5285 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305286 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305287 }
5288
5289 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5290 {
5291 if(pAdapter->aStaInfo[i].isUsed)
5292 {
5293 hddLog(LOGE, "******STAIndex: %d*********", i);
5294 for ( j=0; j< NUM_TX_QUEUES; j++)
5295 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305296 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005297 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305298 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5299 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5300 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305301 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305302 }
5303 }
5304 }
5305
5306}
Jeff Johnson295189b2012-06-20 16:38:30 -07005307int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5308 union iwreq_data *wrqu, char *extra)
5309{
5310 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5311 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5312 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 int apps_args[MAX_VAR_ARGS] = {0};
5314 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005315 hdd_station_ctx_t *pStaCtx = NULL ;
5316 hdd_ap_ctx_t *pAPCtx = NULL;
5317 int cmd = 0;
5318 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005319
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005320 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005321
5322 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5323 {
5324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5325 "%s:LOGP in Progress. Ignore!!!", __func__);
5326 return -EBUSY;
5327 }
5328
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 if (num_args > MAX_VAR_ARGS)
5330 {
5331 num_args = MAX_VAR_ARGS;
5332 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005333
5334 /* ODD number is used for set, copy data using copy_from_user */
5335 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5336 {
5337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5338 "%s: failed to copy data to user buffer", __func__);
5339 return -EFAULT;
5340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005341
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005342 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5343 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5344 {
5345 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5346 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5347 {
5348 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5349 staId = pStaCtx->conn_info.staId[0];
5350 }
5351 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5352 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5353 {
5354 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5355 staId = pAPCtx->uBCStaId;
5356 }
5357 else
5358 {
5359 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5360 return 0;
5361 }
5362 }
5363
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 switch (sub_cmd)
5365 {
5366 case WE_LOG_DUMP_CMD:
5367 {
5368 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005369 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 apps_args[3], apps_args[4]);
5371
5372 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5373 apps_args[3], apps_args[4]);
5374
5375 }
5376 break;
5377
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 case WE_P2P_NOA_CMD:
5379 {
5380 p2p_app_setP2pPs_t p2pNoA;
5381
5382 p2pNoA.opp_ps = apps_args[0];
5383 p2pNoA.ctWindow = apps_args[1];
5384 p2pNoA.duration = apps_args[2];
5385 p2pNoA.interval = apps_args[3];
5386 p2pNoA.count = apps_args[4];
5387 p2pNoA.single_noa_duration = apps_args[5];
5388 p2pNoA.psSelection = apps_args[6];
5389
5390 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5391 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005392 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5394
5395 hdd_setP2pPs(dev, &p2pNoA);
5396
5397 }
5398 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005399
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305400 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5401 {
5402 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5403 __func__, apps_args[0], apps_args[1]);
5404 vosTraceEnable(apps_args[0], apps_args[1]);
5405 }
5406 break;
5407
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005408 case WE_MTRACE_DUMP_CMD:
5409 {
5410 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5411 "bitmask_of_module %d ",
5412 __func__, apps_args[0], apps_args[1], apps_args[2],
5413 apps_args[3]);
5414 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5415 apps_args[2], apps_args[3]);
5416
5417 }
5418 break;
5419
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005420 case WE_MCC_CONFIG_CREDENTIAL :
5421 {
5422 cmd = 287; //Command should be updated if there is any change
5423 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005424 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005425 {
5426 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5427 }
5428 else
5429 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005430 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005431 return 0;
5432 }
5433 }
5434 break;
5435
5436 case WE_MCC_CONFIG_PARAMS :
5437 {
5438 cmd = 288; //command Should be updated if there is any change
5439 // in the Riva dump command
5440 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5441 }
5442 break;
5443
Chilam NG571c65a2013-01-19 12:27:36 +05305444#ifdef FEATURE_WLAN_TDLS
5445 case WE_TDLS_CONFIG_PARAMS :
5446 {
5447 tdls_config_params_t tdlsParams;
5448
Chilam Ng01120412013-02-19 18:32:21 -08005449 tdlsParams.tdls = apps_args[0];
5450 tdlsParams.tx_period_t = apps_args[1];
5451 tdlsParams.tx_packet_n = apps_args[2];
5452 tdlsParams.discovery_period_t = apps_args[3];
5453 tdlsParams.discovery_tries_n = apps_args[4];
5454 tdlsParams.idle_timeout_t = apps_args[5];
5455 tdlsParams.idle_packet_n = apps_args[6];
5456 tdlsParams.rssi_hysteresis = apps_args[7];
5457 tdlsParams.rssi_trigger_threshold = apps_args[8];
5458 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305459
Chilam Ng01120412013-02-19 18:32:21 -08005460 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305461 }
5462 break;
5463#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 default:
5465 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005466 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5467 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 }
5469 break;
5470 }
5471
5472 return 0;
5473}
5474
5475
5476static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5477 union iwreq_data *wrqu, char *extra)
5478{
5479 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5480 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5481 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5482 int params[HDD_WLAN_WMM_PARAM_COUNT];
5483 sme_QosWmmTspecInfo tSpec;
5484 v_U32_t handle;
5485
5486 // make sure the application is sufficiently priviledged
5487 // note that the kernel will do this for "set" ioctls, but since
5488 // this ioctl wants to return status to user space it must be
5489 // defined as a "get" ioctl
5490 if (!capable(CAP_NET_ADMIN))
5491 {
5492 return -EPERM;
5493 }
5494
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005495 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5496 {
5497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5498 "%s:LOGP in Progress. Ignore!!!", __func__);
5499 return -EBUSY;
5500 }
5501
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 // we must be associated in order to add a tspec
5503 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5504 {
5505 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5506 return 0;
5507 }
5508
5509 // since we are defined to be a "get" ioctl, and since the number
5510 // of params exceeds the number of params that wireless extensions
5511 // will pass down in the iwreq_data, we must copy the "set" params
5512 // from user space ourselves
5513 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5514 {
5515 // hmmm, can't get them
5516 return -EIO;
5517 }
5518
5519 // clear the tspec
5520 memset(&tSpec, 0, sizeof(tSpec));
5521
5522 // validate the handle
5523 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5524 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5525 {
5526 // that one is reserved
5527 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5528 return 0;
5529 }
5530
5531 // validate the TID
5532 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5533 {
5534 // out of range
5535 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5536 return 0;
5537 }
5538 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5539
5540 // validate the direction
5541 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5542 {
5543 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5544 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5545 break;
5546
5547 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5548 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5549 break;
5550
5551 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5552 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5553 break;
5554
5555 default:
5556 // unknown
5557 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5558 return 0;
5559 }
5560
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305561 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5562
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 // validate the user priority
5564 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5565 {
5566 // out of range
5567 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5568 return 0;
5569 }
5570 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305571 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5572 {
5573 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5574 return 0;
5575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005576
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5578 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5579 tSpec.ts_info.psb, tSpec.ts_info.up);
5580
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5582 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5583 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5584 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5585 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5586 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5587 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5588 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5589 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5590 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5591 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5592 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5593
5594 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5595
5596 // validate the ts info ack policy
5597 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5598 {
5599 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5600 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5601 break;
5602
5603 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5604 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5605 break;
5606
5607 default:
5608 // unknown
5609 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5610 return 0;
5611 }
5612
5613 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5614 return 0;
5615}
5616
5617
5618static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5619 union iwreq_data *wrqu, char *extra)
5620{
5621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5622 int *params = (int *)extra;
5623 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5624 v_U32_t handle;
5625
5626 // make sure the application is sufficiently priviledged
5627 // note that the kernel will do this for "set" ioctls, but since
5628 // this ioctl wants to return status to user space it must be
5629 // defined as a "get" ioctl
5630 if (!capable(CAP_NET_ADMIN))
5631 {
5632 return -EPERM;
5633 }
5634
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005635 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5636 {
5637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5638 "%s:LOGP in Progress. Ignore!!!", __func__);
5639 return -EBUSY;
5640 }
5641
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 // although we are defined to be a "get" ioctl, the params we require
5643 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5644 // is no need to copy the params from user space
5645
5646 // validate the handle
5647 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5648 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5649 {
5650 // that one is reserved
5651 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5652 return 0;
5653 }
5654
5655 *pStatus = hdd_wmm_delts(pAdapter, handle);
5656 return 0;
5657}
5658
5659
5660static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5661 union iwreq_data *wrqu, char *extra)
5662{
5663 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5664 int *params = (int *)extra;
5665 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5666 v_U32_t handle;
5667
5668 // although we are defined to be a "get" ioctl, the params we require
5669 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5670 // is no need to copy the params from user space
5671
5672 // validate the handle
5673 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5674 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5675 {
5676 // that one is reserved
5677 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5678 return 0;
5679 }
5680
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005681 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5682 {
5683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5684 "%s:LOGP in Progress. Ignore!!!", __func__);
5685 return -EBUSY;
5686 }
5687
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5689 return 0;
5690}
5691
5692
5693#ifdef FEATURE_WLAN_WAPI
5694static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5695 union iwreq_data *wrqu, char *extra)
5696{
5697 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5698 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5699 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5700 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5701
Arif Hussain7adce1b2013-11-11 22:59:34 -08005702 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005703
5704 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005705 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005706 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5707 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005708
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005709 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5710 {
5711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5712 "%s:LOGP in Progress. Ignore!!!", __func__);
5713 return -EBUSY;
5714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005715
5716 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005717 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5719 pRoamProfile->EncryptionType.numEntries = 1;
5720 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5721 pRoamProfile->mcEncryptionType.numEntries = 1;
5722 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5723
5724 pRoamProfile->AuthType.numEntries = 1;
5725 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5726 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5727 }
5728 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005729 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 }
5731 else
5732 return -EINVAL;
5733
5734 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5735
5736 return 0;
5737}
5738
5739static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5740 union iwreq_data *wrqu, char *extra)
5741{
5742 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5743 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5744
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005745 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5746 {
5747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5748 "%s:LOGP in Progress. Ignore!!!", __func__);
5749 return -EBUSY;
5750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5752
5753 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005754 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005755 return 0;
5756}
5757
5758static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5759 union iwreq_data *wrqu, char *extra)
5760{
5761 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5762// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5763 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5764 int i = 0, j = 0;
5765 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005766 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005767 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005768
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005769 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5770 {
5771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5772 "%s:LOGP in Progress. Ignore!!!", __func__);
5773 return -EBUSY;
5774 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005775
5776 if (NULL == pWapiAssocInfo)
5777 {
5778 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5779 "%s: WDA NULL context", __func__);
5780 VOS_ASSERT(0);
5781 return VOS_STATUS_E_FAILURE;
5782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005783
Arif Hussain6d2a3322013-11-17 19:50:10 -08005784 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 -07005785 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005787 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005788
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005789 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005791 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005792
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005793 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005794 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 for(i = 0 ; i < 16 ; i++) {
5796 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5797 for(j = 0 ; j < 16 ; j++)
5798 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5799 }
5800
5801 /* We are not using the entire IE as provided by the supplicant.
5802 * This is being calculated by SME. This is the same as in the
5803 * case of WPA. Only the auth mode information needs to be
5804 * extracted here*/
5805 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005806 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5808 }
5809
5810 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005811 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5813 }
5814 return 0;
5815}
5816
5817static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5818 union iwreq_data *wrqu, char *extra)
5819{
5820 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5821 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5822 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5823 tANI_U32 roamId = 0xFF;
5824 tANI_U8 *pKeyPtr = NULL;
5825 v_BOOL_t isConnected = TRUE;
5826 tCsrRoamSetKey setKey;
5827 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5829
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005830 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5831 {
5832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5833 "%s:LOGP in Progress. Ignore!!!", __func__);
5834 return -EBUSY;
5835 }
5836
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 hddLog(LOG1, "The function iw_qcom_set_wapi_key called ");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005838 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005839 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005840
Arif Hussain6d2a3322013-11-17 19:50:10 -08005841 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 -07005842 hddLog(LOG1,"Add Index:0x");
5843 for(i =0 ; i < 12 ; i++)
5844 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5845
Arif Hussain6d2a3322013-11-17 19:50:10 -08005846 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5848 for(i =0 ; i < 16 ; i++)
5849 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5850
Arif Hussain6d2a3322013-11-17 19:50:10 -08005851 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5853 for(i =0 ; i < 16 ; i++)
5854 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5855
Arif Hussain6d2a3322013-11-17 19:50:10 -08005856 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 for(i = 0 ; i < 16 ; i++)
5858 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5859
5860 // Clear the setkey memory
5861 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5862 // Store Key ID
5863 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5864 // SET WAPI Encryption
5865 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5866 // Key Directionn both TX and RX
5867 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5868 // the PAE role
5869 setKey.paeRole = 0 ;
5870
5871 switch ( pWapiKey->keyType )
5872 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005873 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 {
5875 isConnected = hdd_connIsConnected(pHddStaCtx);
5876 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5877 break;
5878 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005879 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 {
5881 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5882 break;
5883 }
5884 default:
5885 {
5886 //Any other option is invalid.
5887 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005888 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005889
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005890 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5892 break; // NEED RETURN FROM HERE ????
5893 }
5894 }
5895
5896 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5897 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5898 pKeyPtr = setKey.Key;
5899 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5900 pKeyPtr += pWapiKey->wpiekLen;
5901 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5902
5903 // Set the new key with SME.
5904 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5905
5906 if ( isConnected ) {
5907 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5908 if ( halStatus != eHAL_STATUS_SUCCESS )
5909 {
5910 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5911 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5912
5913 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5914 }
5915 }
5916#if 0 /// NEED TO CHECK ON THIS
5917 else
5918 {
5919 // Store the keys in the adapter to be moved to the profile & passed to
5920 // SME in the ConnectRequest if we are not yet in connected state.
5921 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5922 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5923
5924 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5925 " Saving key [idx= %d] to apply when moving to connected state ",
5926 setKey.keyId );
5927
5928 }
5929#endif
5930 return halStatus;
5931}
5932
5933static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5934 union iwreq_data *wrqu, char *extra)
5935{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005936 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005937#ifdef WLAN_DEBUG
5938 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005939 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005940#endif
5941
5942 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005943 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005944 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005945
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005946 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5947 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005948
5949 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005950
5951 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5952 {
5953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5954 "%s:LOGP in Progress. Ignore!!!", __func__);
5955 return -EBUSY;
5956 }
5957
Jeff Johnson295189b2012-06-20 16:38:30 -07005958#ifdef WLAN_DEBUG
5959 for(i =0 ; i < 16 ; i++)
5960 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5961#endif
5962
5963 return 0;
5964}
5965
5966static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5967 union iwreq_data *wrqu, char *extra)
5968{
5969 /* Yet to implement this function, 19th April 2010 */
5970 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5971
5972 return 0;
5973}
5974#endif /* FEATURE_WLAN_WAPI */
5975
5976#ifdef WLAN_FEATURE_VOWIFI_11R
5977//
5978//
5979// Each time the supplicant has the auth_request or reassoc request
5980// IEs ready. This is pushed to the driver. The driver will inturn use
5981// it to send out the auth req and reassoc req for 11r FT Assoc.
5982//
5983static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5984 union iwreq_data *wrqu, char *extra)
5985{
5986 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5987 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5988 //v_CONTEXT_t pVosContext;
5989
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005990 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5991 {
5992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5993 "%s:LOGP in Progress. Ignore!!!", __func__);
5994 return -EBUSY;
5995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 if (!wrqu->data.length)
5997 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005998 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 return -EINVAL;
6000 }
6001 if (wrqu->data.pointer == NULL)
6002 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006003 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 return -EINVAL;
6005 }
6006
6007 // Added for debug on reception of Re-assoc Req.
6008 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6009 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006010 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006012 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 }
6014
6015#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08006016 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07006017#endif
6018
6019 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08006020 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 wrqu->data.length);
6022
6023 return 0;
6024}
6025#endif
6026
Amar Singhalf3a6e762013-02-19 15:06:50 -08006027static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006028 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08006030{
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006032 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006034 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006035 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006036 tpSirRcvFltMcAddrList mc_addr_list_ptr;
6037 int idx;
6038 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07006039
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006040 if (pHddCtx->isLogpInProgress)
6041 {
6042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6043 "%s:LOGP in Progress. Ignore!!!", __func__);
6044 return -EBUSY;
6045 }
6046
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306047 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
6048 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306049#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07006050
Amar Singhalf3a6e762013-02-19 15:06:50 -08006051 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6052 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006053 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006054 hddLog(VOS_TRACE_LEVEL_ERROR,
6055 "%s: vos_mem_alloc failed", __func__);
6056 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006057 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006058
6059 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6060
6061 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6062 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6063
6064 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6065 mc_addr_list_ptr->ulMulticastAddrCnt);
6066
6067 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006068 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006069 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6070 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6071
6072 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6073 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006074 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006075
Amar Singhalf3a6e762013-02-19 15:06:50 -08006076 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6077 vos_mem_free(mc_addr_list_ptr);
6078 if (eHAL_STATUS_SUCCESS != ret_val)
6079 {
6080 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6081 __func__);
6082 return -EINVAL;
6083 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306084#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306085 }
6086 else
6087 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006088
Amar Singhalf3a6e762013-02-19 15:06:50 -08006089 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6090 "%s: Set MC BC Filter Config request: %d suspend %d",
6091 __func__, pRequest->mcastBcastFilterSetting,
6092 pHddCtx->hdd_wlan_suspended);
6093
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306094 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006095
6096 if (pHddCtx->hdd_wlan_suspended)
6097 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006098 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6099 if (NULL == wlanRxpFilterParam)
6100 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306101 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006102 "%s: vos_mem_alloc failed", __func__);
6103 return -EINVAL;
6104 }
6105
Amar Singhalf3a6e762013-02-19 15:06:50 -08006106 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6107 pRequest->mcastBcastFilterSetting;
6108 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6109
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306110 hdd_conf_hostoffload(pAdapter, TRUE);
6111 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6112 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006113
6114 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6115 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306116 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006117 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6118 wlanRxpFilterParam->setMcstBcstFilter);
6119
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306120 if (eHAL_STATUS_SUCCESS !=
6121 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6122 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006123 {
6124 hddLog(VOS_TRACE_LEVEL_ERROR,
6125 "%s: Failure to execute set HW MC/BC Filter request",
6126 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006127 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006128 return -EINVAL;
6129 }
6130
Amar Singhalf3a6e762013-02-19 15:06:50 -08006131 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006133
6134 return 0;
6135}
6136
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006137static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006138 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 union iwreq_data *wrqu, char *extra)
6140{
6141 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6142 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306143 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006144 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006145
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306146 //Reset the filter to INI value as we have to clear the dynamic filter
6147 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006148
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306149 //Configure FW with new setting
6150 if (pHddCtx->hdd_wlan_suspended)
6151 {
6152 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6153 if (NULL == wlanRxpFilterParam)
6154 {
6155 hddLog(VOS_TRACE_LEVEL_ERROR,
6156 "%s: vos_mem_alloc failed", __func__);
6157 return -EINVAL;
6158 }
6159
6160 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6161 pHddCtx->configuredMcastBcastFilter;
6162 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6163
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306164 hdd_conf_hostoffload(pAdapter, TRUE);
6165 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6166 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306167
6168 if (eHAL_STATUS_SUCCESS !=
6169 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6170 wlanRxpFilterParam))
6171 {
6172 hddLog(VOS_TRACE_LEVEL_ERROR,
6173 "%s: Failure to execute set HW MC/BC Filter request",
6174 __func__);
6175 vos_mem_free(wlanRxpFilterParam);
6176 return -EINVAL;
6177 }
6178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 return 0;
6180}
6181
6182static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6183 union iwreq_data *wrqu, char *extra)
6184{
6185 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006186 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 tSirHostOffloadReq offloadRequest;
6188
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006189 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6190 {
6191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6192 "%s:LOGP in Progress. Ignore!!!", __func__);
6193 return -EBUSY;
6194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 /* Debug display of request components. */
6196 switch (pRequest->offloadType)
6197 {
6198 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006199 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 switch (pRequest->enableOrDisable)
6201 {
6202 case WLAN_OFFLOAD_DISABLE:
6203 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6204 break;
6205 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6206 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6207 case WLAN_OFFLOAD_ENABLE:
6208 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6209 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6210 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6211 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6212 }
6213 break;
6214
6215 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006216 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006217 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 switch (pRequest->enableOrDisable)
6219 {
6220 case WLAN_OFFLOAD_DISABLE:
6221 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6222 break;
6223 case WLAN_OFFLOAD_ENABLE:
6224 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6225 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6226 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6227 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6228 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6229 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6230 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6231 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6232 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6233 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6234 }
6235 }
6236
6237 /* Execute offload request. The reason that we can copy the request information
6238 from the ioctl structure to the SME structure is that they are laid out
6239 exactly the same. Otherwise, each piece of information would have to be
6240 copied individually. */
6241 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006242 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6243 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 __func__);
6247 return -EINVAL;
6248 }
6249
6250 return 0;
6251}
6252
6253static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6254 union iwreq_data *wrqu, char *extra)
6255{
6256 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006257 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 tSirKeepAliveReq keepaliveRequest;
6259
6260 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6261 {
6262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006263 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 return 0;
6265 }
6266
6267 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006268 hddLog(VOS_TRACE_LEVEL_INFO,
6269 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6270 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006271
6272 switch (pRequest->packetType)
6273 {
6274 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006275 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 break;
6277
6278 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6279
Arif Hussain6d2a3322013-11-17 19:50:10 -08006280 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006281 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006282
6283 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6284 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6285 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6286
6287 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6288 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6289 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6290
6291 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6292 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6293 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6294 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6295 break;
6296
6297 }
6298
6299 /* Execute keep alive request. The reason that we can copy the request information
6300 from the ioctl structure to the SME structure is that they are laid out
6301 exactly the same. Otherwise, each piece of information would have to be
6302 copied individually. */
6303 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6304
Arif Hussain6d2a3322013-11-17 19:50:10 -08006305 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006306
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006307 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006308 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 __func__);
6312 return -EINVAL;
6313 }
6314
6315 return 0;
6316}
6317
6318#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006319int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006320 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006321{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006322 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6323 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 int i=0;
6325
6326 if (pHddCtx->cfg_ini->disablePacketFilter)
6327 {
6328 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006329 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 return 0;
6331 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006332 if (pHddCtx->isLogpInProgress)
6333 {
6334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6335 "%s:LOGP in Progress. Ignore!!!", __func__);
6336 return -EBUSY;
6337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 /* Debug display of request components. */
6339 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006340 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006341
6342 switch (pRequest->filterAction)
6343 {
6344 case HDD_RCV_FILTER_SET:
6345 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006346 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006347
6348 packetFilterSetReq.filterId = pRequest->filterId;
6349 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6350 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006351 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 __func__, pRequest->numParams);
6353 return -EINVAL;
6354 }
6355 packetFilterSetReq.numFieldParams = pRequest->numParams;
6356 packetFilterSetReq.coalesceTime = 0;
6357 packetFilterSetReq.filterType = 1;
6358 for (i=0; i < pRequest->numParams; i++)
6359 {
6360 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6361 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6362 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6363 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6364 packetFilterSetReq.paramsData[i].reserved = 0;
6365
Arif Hussain6d2a3322013-11-17 19:50:10 -08006366 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6368 packetFilterSetReq.filterType);
6369
Arif Hussain6d2a3322013-11-17 19:50:10 -08006370 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6372
6373 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6374 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6375 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6376 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6377
Arif Hussain6d2a3322013-11-17 19:50:10 -08006378 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6380 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6381 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6382
Arif Hussain6d2a3322013-11-17 19:50:10 -08006383 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6385 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6386 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6387 }
6388
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006389 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006391 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 __func__);
6393 return -EINVAL;
6394 }
6395
6396 break;
6397
6398 case HDD_RCV_FILTER_CLEAR:
6399
Arif Hussain6d2a3322013-11-17 19:50:10 -08006400 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006401 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006403 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006405 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 __func__);
6407 return -EINVAL;
6408 }
6409 break;
6410
6411 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006412 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006413 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 return -EINVAL;
6415 }
6416 return 0;
6417}
6418
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306419int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6420 tANI_U8 sessionId)
6421{
6422 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6423 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6424
6425 if (NULL == pHddCtx)
6426 {
6427 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6428 return -EINVAL;
6429 }
6430
6431 if (pHddCtx->isLogpInProgress)
6432 {
6433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6434 "%s:LOGP in Progress. Ignore!!!", __func__);
6435 return -EBUSY;
6436 }
6437
6438 if (pHddCtx->cfg_ini->disablePacketFilter)
6439 {
6440 hddLog(VOS_TRACE_LEVEL_ERROR,
6441 "%s: Packet Filtering Disabled. Returning ",
6442 __func__ );
6443 return -EINVAL;
6444 }
6445
6446 switch (filterType)
6447 {
6448 /* For setting IPV6 MC and UC Filter we need to configure
6449 * 2 filters, one for MC and one for UC.
6450 * The Filter ID shouldn't be swapped, which results in making
6451 * UC Filter ineffective.
6452 * We have Hardcode all the values
6453 *
6454 * Reason for a seperate UC filter is because, driver need to
6455 * specify the FW that the specific filter is for unicast
6456 * otherwise FW will not pass the unicast frames by default
6457 * through the filter. This is required to avoid any performance
6458 * hits when no unicast filter is set and only MC/BC are set.
6459 * The way driver informs host is by using the MAC protocol
6460 * layer, CMP flag set to MAX, CMP Data set to 1.
6461 */
6462
6463 case HDD_FILTER_IPV6_MC_UC:
6464 /* Setting IPV6 MC Filter below
6465 */
6466 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6467 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6468 packetFilterSetReq.numFieldParams = 2;
6469 packetFilterSetReq.paramsData[0].protocolLayer =
6470 HDD_FILTER_PROTO_TYPE_MAC;
6471 packetFilterSetReq.paramsData[0].cmpFlag =
6472 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6473 packetFilterSetReq.paramsData[0].dataOffset =
6474 WLAN_HDD_80211_FRM_DA_OFFSET;
6475 packetFilterSetReq.paramsData[0].dataLength = 1;
6476 packetFilterSetReq.paramsData[0].compareData[0] =
6477 HDD_IPV6_MC_CMP_DATA;
6478
6479 packetFilterSetReq.paramsData[1].protocolLayer =
6480 HDD_FILTER_PROTO_TYPE_ARP;
6481 packetFilterSetReq.paramsData[1].cmpFlag =
6482 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6483 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6484 packetFilterSetReq.paramsData[1].dataLength = 2;
6485 packetFilterSetReq.paramsData[1].compareData[0] =
6486 HDD_IPV6_CMP_DATA_0;
6487 packetFilterSetReq.paramsData[1].compareData[1] =
6488 HDD_IPV6_CMP_DATA_1;
6489
6490
6491 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6492 &packetFilterSetReq, sessionId))
6493 {
6494 hddLog(VOS_TRACE_LEVEL_ERROR,
6495 "%s: Failure to execute Set IPv6 Mulicast Filter",
6496 __func__);
6497 return -EINVAL;
6498 }
6499
6500 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6501
6502 /*
6503 * Setting IPV6 UC Filter below
6504 */
6505 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6506 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
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_MAX;
6512 packetFilterSetReq.paramsData[0].dataOffset = 0;
6513 packetFilterSetReq.paramsData[0].dataLength = 1;
6514 packetFilterSetReq.paramsData[0].compareData[0] =
6515 HDD_IPV6_UC_CMP_DATA;
6516
6517 packetFilterSetReq.paramsData[1].protocolLayer =
6518 HDD_FILTER_PROTO_TYPE_ARP;
6519 packetFilterSetReq.paramsData[1].cmpFlag =
6520 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6521 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6522 packetFilterSetReq.paramsData[1].dataLength = 2;
6523 packetFilterSetReq.paramsData[1].compareData[0] =
6524 HDD_IPV6_CMP_DATA_0;
6525 packetFilterSetReq.paramsData[1].compareData[1] =
6526 HDD_IPV6_CMP_DATA_1;
6527
6528 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6529 &packetFilterSetReq, sessionId))
6530 {
6531 hddLog(VOS_TRACE_LEVEL_ERROR,
6532 "%s: Failure to execute Set IPv6 Unicast Filter",
6533 __func__);
6534 return -EINVAL;
6535 }
6536
6537 break;
6538
6539 case HDD_FILTER_IPV6_MC:
6540 /*
6541 * IPV6 UC Filter might be already set,
6542 * clear the UC Filter. As the Filter
6543 * IDs are static, we can directly clear it.
6544 */
6545 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6546 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6547 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6548 &packetFilterClrReq, sessionId))
6549 {
6550 hddLog(VOS_TRACE_LEVEL_ERROR,
6551 "%s: Failure to execute Clear IPv6 Unicast Filter",
6552 __func__);
6553 return -EINVAL;
6554 }
6555
6556 /*
6557 * Setting IPV6 MC Filter below
6558 */
6559 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6560 packetFilterSetReq.numFieldParams = 2;
6561 packetFilterSetReq.paramsData[0].protocolLayer =
6562 HDD_FILTER_PROTO_TYPE_MAC;
6563 packetFilterSetReq.paramsData[0].cmpFlag =
6564 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6565 packetFilterSetReq.paramsData[0].dataOffset =
6566 WLAN_HDD_80211_FRM_DA_OFFSET;
6567 packetFilterSetReq.paramsData[0].dataLength = 1;
6568 packetFilterSetReq.paramsData[0].compareData[0] =
6569 HDD_IPV6_MC_CMP_DATA;
6570
6571 packetFilterSetReq.paramsData[1].protocolLayer =
6572 HDD_FILTER_PROTO_TYPE_ARP;
6573 packetFilterSetReq.paramsData[1].cmpFlag =
6574 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6575 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6576 packetFilterSetReq.paramsData[1].dataLength = 2;
6577 packetFilterSetReq.paramsData[1].compareData[0] =
6578 HDD_IPV6_CMP_DATA_0;
6579 packetFilterSetReq.paramsData[1].compareData[1] =
6580 HDD_IPV6_CMP_DATA_1;
6581
6582
6583 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6584 &packetFilterSetReq, sessionId))
6585 {
6586 hddLog(VOS_TRACE_LEVEL_ERROR,
6587 "%s: Failure to execute Set IPv6 Multicast Filter",
6588 __func__);
6589 return -EINVAL;
6590 }
6591 break;
6592
6593 default :
6594 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6595 "%s: Packet Filter Request: Invalid",
6596 __func__);
6597 return -EINVAL;
6598 }
6599 return 0;
6600}
6601
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306602void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006603{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306604 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306605 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006606 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306607 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006608
Yue Ma3ede6052013-08-29 00:33:26 -07006609 if (NULL == pHddCtx)
6610 {
6611 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6612 return;
6613 }
6614
6615 hHal = pHddCtx->hHal;
6616
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306617 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306619 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6620 return;
6621 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306622
6623 /* Check if INI is enabled or not, other wise just return
6624 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306625 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306626 {
6627 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6628 if (NULL == pMulticastAddrs)
6629 {
6630 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6631 return;
6632 }
6633
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 if (set)
6635 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306636 /* Following pre-conditions should be satisfied before wei
6637 * configure the MC address list.
6638 */
6639 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6640 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6641 && pAdapter->mc_addr_list.mc_cnt
6642 && (eConnectionState_Associated ==
6643 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6644 {
6645 pMulticastAddrs->ulMulticastAddrCnt =
6646 pAdapter->mc_addr_list.mc_cnt;
6647 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6648 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006649 memcpy(pMulticastAddrs->multicastAddr[i],
6650 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306651 sizeof(pAdapter->mc_addr_list.addr[i]));
6652 hddLog(VOS_TRACE_LEVEL_INFO,
6653 "%s: %s multicast filter: addr ="
6654 MAC_ADDRESS_STR,
6655 __func__, set ? "setting" : "clearing",
6656 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6657 }
6658 /* Set multicast filter */
6659 sme_8023MulticastList(hHal, pAdapter->sessionId,
6660 pMulticastAddrs);
6661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306663 else
6664 {
6665 /* Need to clear only if it was previously configured
6666 */
6667 if (pAdapter->mc_addr_list.isFilterApplied)
6668 {
6669 pMulticastAddrs->ulMulticastAddrCnt = 0;
6670 sme_8023MulticastList(hHal, pAdapter->sessionId,
6671 pMulticastAddrs);
6672 }
6673
6674 }
6675 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006676 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306678 else
6679 {
6680 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306681 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306682 }
6683 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006684}
6685
6686static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6687 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306688{
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006690 tpPacketFilterCfg pRequest = NULL;
6691 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006692
Arif Hussain0273cba2014-01-07 20:58:29 -08006693 /* ODD number is used for set, copy data using copy_from_user */
6694 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6695 wrqu->data.length);
6696 if (NULL == pRequest)
6697 {
6698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6699 "mem_alloc_copy_from_user_helper fail");
6700 return -ENOMEM;
6701 }
6702
6703 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6704 kfree(pRequest);
6705
6706 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006707}
6708#endif
6709static int iw_get_statistics(struct net_device *dev,
6710 struct iw_request_info *info,
6711 union iwreq_data *wrqu, char *extra)
6712{
6713
6714 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6715 eHalStatus status = eHAL_STATUS_SUCCESS;
6716 hdd_wext_state_t *pWextState;
6717 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6718 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6719 char *p = extra;
6720 int tlen = 0;
6721 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6722
6723 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6724 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6725
6726 ENTER();
6727
6728 if (pHddCtx->isLogpInProgress) {
6729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6730 return -EINVAL;
6731 }
6732
6733 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6734
6735 wrqu->txpower.value = 0;
6736 }
6737 else {
6738 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6739 SME_SUMMARY_STATS |
6740 SME_GLOBAL_CLASSA_STATS |
6741 SME_GLOBAL_CLASSB_STATS |
6742 SME_GLOBAL_CLASSC_STATS |
6743 SME_GLOBAL_CLASSD_STATS |
6744 SME_PER_STA_STATS,
6745 hdd_StatisticsCB, 0, FALSE,
6746 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6747
6748 if (eHAL_STATUS_SUCCESS != status)
6749 {
6750 hddLog(VOS_TRACE_LEVEL_ERROR,
6751 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006752 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 return -EINVAL;
6754 }
6755
6756 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6757
6758 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6759 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6760 {
6761 hddLog(VOS_TRACE_LEVEL_ERROR,
6762 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006763 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 /*Remove the SME statistics list by passing NULL in callback argument*/
6765 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6766 SME_SUMMARY_STATS |
6767 SME_GLOBAL_CLASSA_STATS |
6768 SME_GLOBAL_CLASSB_STATS |
6769 SME_GLOBAL_CLASSC_STATS |
6770 SME_GLOBAL_CLASSD_STATS |
6771 SME_PER_STA_STATS,
6772 NULL, 0, FALSE,
6773 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6774
6775 return -EINVAL;
6776 }
6777 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6778 (tANI_U8) sizeof (pStats->retry_cnt),
6779 (char*) &(pStats->retry_cnt[0]),
6780 tlen);
6781
6782 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6783 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6784 (char*) &(pStats->multiple_retry_cnt[0]),
6785 tlen);
6786
6787 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6788 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6789 (char*) &(pStats->tx_frm_cnt[0]),
6790 tlen);
6791
6792 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6793 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6794 (char*) &(pStats->rx_frm_cnt),
6795 tlen);
6796
6797 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6798 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6799 (char*) &(pStats->frm_dup_cnt),
6800 tlen);
6801
6802 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6803 (tANI_U8) sizeof (pStats->fail_cnt),
6804 (char*) &(pStats->fail_cnt[0]),
6805 tlen);
6806
6807 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6808 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6809 (char*) &(pStats->rts_fail_cnt),
6810 tlen);
6811
6812 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6813 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6814 (char*) &(pStats->ack_fail_cnt),
6815 tlen);
6816
6817 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6818 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6819 (char*) &(pStats->rts_succ_cnt),
6820 tlen);
6821
6822 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6823 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6824 (char*) &(pStats->rx_discard_cnt),
6825 tlen);
6826
6827 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6828 (tANI_U8) sizeof (pStats->rx_error_cnt),
6829 (char*) &(pStats->rx_error_cnt),
6830 tlen);
6831
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006832 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006833 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006834 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 tlen);
6836
6837 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6838 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6839 (char*) &(dStats->rx_byte_cnt),
6840 tlen);
6841
6842 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6843 (tANI_U8) sizeof (dStats->rx_rate),
6844 (char*) &(dStats->rx_rate),
6845 tlen);
6846
6847 /* Transmit rate, in units of 500 kbit/sec */
6848 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6849 (tANI_U8) sizeof (aStats->tx_rate),
6850 (char*) &(aStats->tx_rate),
6851 tlen);
6852
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006853 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6854 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6855 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006856 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006857 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6858 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6859 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006860 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006861 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6862 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6863 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006864 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006865 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6866 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6867 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006868 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006869 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6870 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6871 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006872 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006873 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6874 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6875 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006876 tlen);
6877
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 wrqu->data.length = tlen;
6879
6880 }
6881
6882 EXIT();
6883
6884 return 0;
6885}
6886
6887
6888#ifdef FEATURE_WLAN_SCAN_PNO
6889
6890/*Max Len for PNO notification*/
6891#define MAX_PNO_NOTIFY_LEN 100
6892void found_pref_network_cb (void *callbackContext,
6893 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6894{
6895 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6896 union iwreq_data wrqu;
6897 char buf[MAX_PNO_NOTIFY_LEN+1];
6898
6899 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6900 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6901
6902 // create the event
6903 memset(&wrqu, 0, sizeof(wrqu));
6904 memset(buf, 0, sizeof(buf));
6905
6906 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6907 pPrefNetworkFoundInd->ssId.ssId,
6908 (unsigned int)pPrefNetworkFoundInd->rssi);
6909
6910 wrqu.data.pointer = buf;
6911 wrqu.data.length = strlen(buf);
6912
6913 // send the event
6914
6915 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6916
6917}
6918
6919
6920/*string based input*/
6921VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6922 union iwreq_data *wrqu, char *extra, int nOffset)
6923{
6924 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05306925 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006926 /* pnoRequest is a large struct, so we make it static to avoid stack
6927 overflow. This API is only invoked via ioctl, so it is
6928 serialized by the kernel rtnl_lock and hence does not need to be
6929 reentrant */
6930 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 char *ptr;
6932 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05306933 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6935
6936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6937 "PNO data len %d data %s",
6938 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006939 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006940
6941 if (wrqu->data.length <= nOffset )
6942 {
6943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6944 return VOS_STATUS_E_FAILURE;
6945 }
6946
6947 pnoRequest.enable = 0;
6948 pnoRequest.ucNetworksCount = 0;
6949 /*-----------------------------------------------------------------------
6950 Input is string based and expected to be like this:
6951
6952 <enabled> <netw_count>
6953 for each network:
6954 <ssid_len> <ssid> <authentication> <encryption>
6955 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6956 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6957
6958 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006959 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 -07006960
6961 this translates into:
6962 -----------------------------
6963 enable PNO
6964 look for 2 networks:
6965 test - with authentication type 0 and encryption type 0,
6966 that can be found on 3 channels: 1 6 and 11 ,
6967 SSID bcast type is unknown (directed probe will be sent if AP not found)
6968 and must meet -40dBm RSSI
6969
6970 test2 - with auth and enrytption type 4/4
6971 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6972 bcast type is non-bcast (directed probe will be sent)
6973 and must not meet any RSSI threshold
6974
Jeff Johnson8301aa12013-03-28 14:27:29 -07006975 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006976 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006977 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006978
Wilson Yang623f6592013-10-08 16:33:37 -07006979 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6980 {
6981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6982 "PNO enable input is not valid %s",ptr);
6983 return VOS_STATUS_E_FAILURE;
6984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006985
6986 if ( 0 == pnoRequest.enable )
6987 {
6988 /*Disable PNO*/
6989 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05306990 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
6991 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07006992 pAdapter->sessionId,
6993 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05306994 if (eHAL_STATUS_SUCCESS != status)
6995 {
6996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6997 "%s: failed to disable PNO", __func__);
6998 return VOS_STATUS_E_FAILURE;
6999 }
7000 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 return VOS_STATUS_SUCCESS;
7002 }
7003
c_hpothu37f21312014-04-09 21:49:54 +05307004 if (TRUE == pHddCtx->isPnoEnable)
7005 {
7006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7007 FL("already PNO is enabled"));
7008 return -EBUSY;
7009 }
7010 pHddCtx->isPnoEnable = TRUE;
7011
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07007013
7014 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
7015 {
7016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7017 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307018 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007020
7021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7022 "PNO enable %d networks count %d offset %d",
7023 pnoRequest.enable,
7024 pnoRequest.ucNetworksCount,
7025 nOffset);
7026
7027 /* Parameters checking:
7028 ucNetworksCount has to be larger than 0*/
7029 if (( 0 == pnoRequest.ucNetworksCount ) ||
7030 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7031 {
7032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05307033 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 }
7035
7036 ptr += nOffset;
7037
7038 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
7039 {
7040
7041 pnoRequest.aNetworks[i].ssId.length = 0;
7042
Wilson Yang623f6592013-10-08 16:33:37 -07007043 ucParams = sscanf(ptr,"%hhu %n",
7044 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
7045
7046 if (1 != ucParams)
7047 {
7048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7049 "PNO ssid length input is not valid %s",ptr);
7050 return VOS_STATUS_E_FAILURE;
7051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007052
7053 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
7054 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
7055 {
7056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7057 "SSID Len %d is not correct for network %d",
7058 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05307059 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 }
7061
7062 /*Advance to SSID*/
7063 ptr += nOffset;
7064
Jeff Johnson8301aa12013-03-28 14:27:29 -07007065 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08007066 pnoRequest.aNetworks[i].ssId.length);
7067 ptr += pnoRequest.aNetworks[i].ssId.length;
7068
Jeff Johnson02797792013-10-26 19:17:13 -07007069 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007070 &(pnoRequest.aNetworks[i].authentication),
7071 &(pnoRequest.aNetworks[i].encryption),
7072 &(pnoRequest.aNetworks[i].ucChannelCount),
7073 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007074
Wilson Yang623f6592013-10-08 16:33:37 -07007075 if ( 3 != ucParams )
7076 {
7077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7078 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307079 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007080 }
7081
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007083 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08007084 "auth %d encry %d channel count %d offset %d",
7085 pnoRequest.aNetworks[i].ssId.length,
7086 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
7087 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7088 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7089 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7090 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7091 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7092 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7093 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7094 pnoRequest.aNetworks[i].authentication,
7095 pnoRequest.aNetworks[i].encryption,
7096 pnoRequest.aNetworks[i].ucChannelCount,
7097 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007098
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 /*Advance to channel list*/
7100 ptr += nOffset;
7101
Wilson Yang623f6592013-10-08 16:33:37 -07007102 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 {
7104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7105 "Incorrect number of channels");
7106 return VOS_STATUS_E_FAILURE;
7107 }
7108
7109 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7110 {
7111 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7112 {
Wilson Yang623f6592013-10-08 16:33:37 -07007113 if (1 != sscanf(ptr,"%hhu %n",
7114 &(pnoRequest.aNetworks[i].aChannels[j]),
7115 &nOffset))
7116 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7117 "PNO network channel input is not valid %s",ptr);
7118 return VOS_STATUS_E_FAILURE;
7119 }
7120 /*Advance to next channel number*/
7121 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 }
7123 }
7124
Jeff Johnson02797792013-10-26 19:17:13 -07007125 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007126 &(pnoRequest.aNetworks[i].bcastNetwType),
7127 &nOffset))
7128 {
7129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7130 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307131 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007133
7134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7135 "PNO bcastNetwType %d offset %d",
7136 pnoRequest.aNetworks[i].bcastNetwType,
7137 nOffset );
7138
7139 /*Advance to rssi Threshold*/
7140 ptr += nOffset;
7141
Wilson Yang623f6592013-10-08 16:33:37 -07007142 if (1 != sscanf(ptr,"%hhu %n",
7143 &(pnoRequest.aNetworks[i].rssiThreshold),
7144 &nOffset))
7145 {
7146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7147 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307148 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007150
7151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7152 "PNO rssi %d offset %d",
7153 pnoRequest.aNetworks[i].rssiThreshold,
7154 nOffset );
7155 /*Advance to next network*/
7156 ptr += nOffset;
7157 }/*For ucNetworkCount*/
7158
7159 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007160 &(pnoRequest.scanTimers.ucScanTimersCount),
7161 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007162
7163 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007164 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 {
7166 ptr += nOffset;
7167
Jeff Johnson8301aa12013-03-28 14:27:29 -07007168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7169 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 pnoRequest.scanTimers.ucScanTimersCount,
7171 nOffset );
7172
7173 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7174 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307177 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 }
7179
7180 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7181 {
Jeff Johnson02797792013-10-26 19:17:13 -07007182 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7184 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7185 &nOffset);
7186
Wilson Yang623f6592013-10-08 16:33:37 -07007187 if (2 != ucParams)
7188 {
7189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7190 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307191 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007192 }
7193
Jeff Johnson8301aa12013-03-28 14:27:29 -07007194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7195 "PNO Timer value %d Timer repeat %d offset %d",
7196 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7198 nOffset );
7199
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 ptr += nOffset;
7201 }
7202
7203 }
7204 else
7205 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7207 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7209
7210 /*Scan timers defaults to 5 minutes*/
7211 pnoRequest.scanTimers.ucScanTimersCount = 1;
7212 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7213 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7214 }
7215
Wilson Yang623f6592013-10-08 16:33:37 -07007216 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007217
7218 pnoRequest.modePNO = ucMode;
7219 /*for LA we just expose suspend option*/
7220 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7221 {
7222 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7223 }
7224
c_hpothu37f21312014-04-09 21:49:54 +05307225 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 pAdapter->sessionId,
7227 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307228 if (eHAL_STATUS_SUCCESS == status)
7229 {
7230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7231 "%s: PNO enabled", __func__);
7232 return VOS_STATUS_SUCCESS;
7233 }
7234error:
7235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7236 "%s: Failed to enable PNO", __func__);
7237 pHddCtx->isPnoEnable = FALSE;
7238 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007239}/*iw_set_pno*/
7240
7241VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7242 union iwreq_data *wrqu, char *extra, int nOffset)
7243{
7244 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7245 v_U8_t rssiThreshold = 0;
7246 v_U8_t nRead;
7247
Arif Hussain7adce1b2013-11-11 22:59:34 -08007248 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 &rssiThreshold);
7250
7251 if ( 1 != nRead )
7252 {
7253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7254 "Incorrect format");
7255 return VOS_STATUS_E_FAILURE;
7256 }
7257
7258 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7259 return VOS_STATUS_SUCCESS;
7260}
7261
7262
7263static int iw_set_pno_priv(struct net_device *dev,
7264 struct iw_request_info *info,
7265 union iwreq_data *wrqu, char *extra)
7266{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007267 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7268
7269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007271
7272 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7273 {
7274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7275 "%s:LOGP in Progress. Ignore!!!", __func__);
7276 return -EBUSY;
7277 }
7278 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007279}
7280#endif /*FEATURE_WLAN_SCAN_PNO*/
7281
7282//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307283int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007284{
7285 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7286 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7287 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307288 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307290 eCsrBand connectedBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007291
Atul Mittal54378cb2014-04-02 16:51:50 +05307292 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 {
7294 case WLAN_HDD_UI_BAND_AUTO:
7295 band = eCSR_BAND_ALL;
7296 break;
7297 case WLAN_HDD_UI_BAND_5_GHZ:
7298 band = eCSR_BAND_5G;
7299 break;
7300 case WLAN_HDD_UI_BAND_2_4_GHZ:
7301 band = eCSR_BAND_24;
7302 break;
7303 default:
7304 band = eCSR_BAND_MAX;
7305 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307306 connectedBand =
7307 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007308
Atul Mittal54378cb2014-04-02 16:51:50 +05307309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007310 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007311
7312 if (band == eCSR_BAND_MAX)
7313 {
7314 /* Received change band request with invalid band value */
7315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307316 "%s: Invalid band value %u", __func__, ui_band);
7317 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 }
7319
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307320 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7321 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7322 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7323 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007325 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007326 band, pHddCtx->cfg_ini->nBandCapability);
7327 return -EIO;
7328 }
7329
Jeff Johnson295189b2012-06-20 16:38:30 -07007330 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7331 {
7332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7333 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007334 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 return -EIO;
7336 }
7337
7338 if (currBand != band)
7339 {
7340 /* Change band request received.
7341 * Abort pending scan requests, flush the existing scan results,
7342 * and change the band capability
7343 */
7344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7345 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007346 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007347
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307348 /* We need to change the band and flush the scan results here itself
7349 * as we may get timeout for disconnection in which we will return
7350 * with out doing any of these
7351 */
7352 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7353 {
7354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7355 "%s: failed to set the band value to %u ",
7356 __func__, band);
7357 return -EINVAL;
7358 }
7359 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7360 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7361 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7362 sme_FilterScanResults(hHal, pAdapter->sessionId);
7363
7364 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307365 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7366 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 {
7368 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7369 eHalStatus status = eHAL_STATUS_SUCCESS;
7370 long lrc;
7371
7372 /* STA already connected on current band, So issue disconnect first,
7373 * then change the band*/
7374
7375 hddLog(VOS_TRACE_LEVEL_INFO,
7376 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7377 __func__, csrGetCurrentBand(hHal), band);
7378
7379 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7380 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7381
7382 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7383 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7384
Jeff Johnson43971f52012-07-17 12:26:56 -07007385 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 {
7387 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007388 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 __func__, (int)status );
7390 return -EINVAL;
7391 }
7392
7393 lrc = wait_for_completion_interruptible_timeout(
7394 &pAdapter->disconnect_comp_var,
7395 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7396
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307397 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007398
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007399 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007400 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007401
7402 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7403 }
7404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 }
7406 return 0;
7407}
7408
Atul Mittal54378cb2014-04-02 16:51:50 +05307409int hdd_setBand_helper(struct net_device *dev, const char *command)
7410{
7411 u8 band;
7412
7413 /*convert the band value from ascii to integer*/
7414 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7415
7416 return hdd_setBand(dev, band);
7417
7418}
7419
Jeff Johnson295189b2012-06-20 16:38:30 -07007420static int iw_set_band_config(struct net_device *dev,
7421 struct iw_request_info *info,
7422 union iwreq_data *wrqu, char *extra)
7423{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007424 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307425 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007426
Arif Hussain0273cba2014-01-07 20:58:29 -08007427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007429 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7430 {
7431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7432 "%s:LOGP in Progress. Ignore!!!", __func__);
7433 return -EBUSY;
7434 }
7435
Atul Mittal54378cb2014-04-02 16:51:50 +05307436 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007437}
7438
7439static int iw_set_power_params_priv(struct net_device *dev,
7440 struct iw_request_info *info,
7441 union iwreq_data *wrqu, char *extra)
7442{
Arif Hussain0273cba2014-01-07 20:58:29 -08007443 int ret;
7444 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7446 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007447 /* ODD number is used for set, copy data using copy_from_user */
7448 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7449 wrqu->data.length);
7450 if (NULL == ptr)
7451 {
7452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7453 "mem_alloc_copy_from_user_helper fail");
7454 return -ENOMEM;
7455 }
7456
7457 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7458 kfree(ptr);
7459 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007460}
7461
7462
7463
7464/*string based input*/
7465VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7466 union iwreq_data *wrqu, char *extra, int nOffset)
7467{
7468 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7469 tSirSetPowerParamsReq powerRequest;
7470 char *ptr;
7471 v_U8_t ucType;
7472 v_U32_t uTotalSize, uValue;
7473 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7474
7475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7476 "Power Params data len %d data %s",
7477 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007478 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007479
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007480 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7481 {
7482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7483 "%s:LOGP in Progress. Ignore!!!", __func__);
7484 return -EBUSY;
7485 }
7486
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 if (wrqu->data.length <= nOffset )
7488 {
7489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7490 return VOS_STATUS_E_FAILURE;
7491 }
7492
7493 uTotalSize = wrqu->data.length - nOffset;
7494
7495 /*-----------------------------------------------------------------------
7496 Input is string based and expected to be like this:
7497
7498 <param_type> <param_value> <param_type> <param_value> ...
7499
7500 e.g:
7501 1 2 2 3 3 0 4 1 5 1
7502
7503 e.g. setting just a few:
7504 1 2 4 1
7505
7506 parameter types:
7507 -----------------------------
7508 1 - Ignore DTIM
7509 2 - Listen Interval
7510 3 - Broadcast Multicas Filter
7511 4 - Beacon Early Termination
7512 5 - Beacon Early Termination Interval
7513 -----------------------------------------------------------------------*/
7514 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7515 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7516 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7517 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7518 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7519
Arif Hussain7adce1b2013-11-11 22:59:34 -08007520 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007521
7522 while ( uTotalSize )
7523 {
Wilson Yang6f971452013-10-08 15:00:00 -07007524 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7525 {
7526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7527 "Invalid input parameter type %s",ptr);
7528 return VOS_STATUS_E_FAILURE;
7529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007530
7531 uTotalSize -= nOffset;
7532
7533 if (!uTotalSize)
7534 {
7535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007536 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 ucType, nOffset);
7538 return VOS_STATUS_E_FAILURE;
7539 }
7540
7541 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007542
Jeff Johnson02797792013-10-26 19:17:13 -07007543 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007544 {
7545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7546 "Invalid input parameter value %s",ptr);
7547 return VOS_STATUS_E_FAILURE;
7548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007549
7550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7551 "Power request parameter %d value %d offset %d",
7552 ucType, uValue, nOffset);
7553
7554 switch (ucType)
7555 {
7556 case eSIR_IGNORE_DTIM:
7557 powerRequest.uIgnoreDTIM = uValue;
7558 break;
7559 case eSIR_LISTEN_INTERVAL:
7560 powerRequest.uListenInterval = uValue;
7561 break;
7562 case eSIR_MCAST_BCAST_FILTER:
7563 powerRequest.uBcastMcastFilter = uValue;
7564 break;
7565 case eSIR_ENABLE_BET:
7566 powerRequest.uEnableBET = uValue;
7567 break;
7568 case eSIR_BET_INTERVAL:
7569 powerRequest.uBETInterval = uValue;
7570 break;
7571 default:
7572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007573 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 ucType, uValue, nOffset);
7575 return VOS_STATUS_E_FAILURE;
7576 }
7577
7578 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7580 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007581 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007583 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007584 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007585 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7586 {
7587 uTotalSize = 0;
7588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007589
7590 }/*Go for as long as we have a valid string*/
7591
7592 /* put the device into full power*/
7593 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7594
7595 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007596 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007597
7598 /* put the device back to power save*/
7599 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7600
7601 return VOS_STATUS_SUCCESS;
7602}/*iw_set_power_params*/
7603
7604
7605// Define the Wireless Extensions to the Linux Network Device structure
7606// A number of these routines are NULL (meaning they are not implemented.)
7607
7608static const iw_handler we_handler[] =
7609{
7610 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7611 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7612 (iw_handler) NULL, /* SIOCSIWNWID */
7613 (iw_handler) NULL, /* SIOCGIWNWID */
7614 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7615 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7616 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7617 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7618 (iw_handler) NULL, /* SIOCSIWSENS */
7619 (iw_handler) NULL, /* SIOCGIWSENS */
7620 (iw_handler) NULL, /* SIOCSIWRANGE */
7621 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7622 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7623 (iw_handler) NULL, /* SIOCGIWPRIV */
7624 (iw_handler) NULL, /* SIOCSIWSTATS */
7625 (iw_handler) NULL, /* SIOCGIWSTATS */
7626 iw_handler_set_spy, /* SIOCSIWSPY */
7627 iw_handler_get_spy, /* SIOCGIWSPY */
7628 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7629 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7630 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7631 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7632 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7633 (iw_handler) NULL, /* SIOCGIWAPLIST */
7634 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7635 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7636 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7637 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7638 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7639 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7640 (iw_handler) NULL, /* -- hole -- */
7641 (iw_handler) NULL, /* -- hole -- */
7642 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7643 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7644 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7645 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7646 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7647 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7648 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7649 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7650 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7651 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7652 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7653 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7654 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7655 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7656 (iw_handler) NULL, /* -- hole -- */
7657 (iw_handler) NULL, /* -- hole -- */
7658 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7659 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7660 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7661 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7662 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7663 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7664 (iw_handler) NULL, /* SIOCSIWPMKSA */
7665};
7666
7667static const iw_handler we_private[] = {
7668
7669 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7670 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7671 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7672 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7673 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7674 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7675 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7676 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7677 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7678 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007679#ifdef FEATURE_OEM_DATA_SUPPORT
7680 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7681 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7682#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007683
7684#ifdef FEATURE_WLAN_WAPI
7685 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7686 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7687 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7688 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7689 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7690 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7691#endif /* FEATURE_WLAN_WAPI */
7692#ifdef WLAN_FEATURE_VOWIFI_11R
7693 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7694#endif
7695 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7696 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7697 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7698#ifdef WLAN_FEATURE_PACKET_FILTERING
7699 ,
7700 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7701#endif
7702#ifdef FEATURE_WLAN_SCAN_PNO
7703 ,
7704 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7705#endif
7706 ,
7707 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7708 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7709 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7710 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007711 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007712};
7713
7714/*Maximum command length can be only 15 */
7715static const struct iw_priv_args we_private_args[] = {
7716
7717 /* handlers for main ioctl */
7718 { WLAN_PRIV_SET_INT_GET_NONE,
7719 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7720 0,
7721 "" },
7722
7723 /* handlers for sub-ioctl */
7724 { WE_SET_11D_STATE,
7725 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7726 0,
7727 "set11Dstate" },
7728
7729 { WE_WOWL,
7730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7731 0,
7732 "wowl" },
7733
7734 { WE_SET_POWER,
7735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7736 0,
7737 "setPower" },
7738
7739 { WE_SET_MAX_ASSOC,
7740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7741 0,
7742 "setMaxAssoc" },
7743
7744 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7745 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7746 0,
7747 "setAutoChannel" },
7748
7749 { WE_SET_DATA_INACTIVITY_TO,
7750 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7751 0,
7752 "inactivityTO" },
7753
7754 { WE_SET_MAX_TX_POWER,
7755 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7756 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007757 "setMaxTxPower" },
7758
7759 { WE_SET_MAX_TX_POWER_2_4,
7760 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7761 0,
7762 "setTxMaxPower2G" },
7763
7764 { WE_SET_MAX_TX_POWER_5_0,
7765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7766 0,
7767 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007768
7769 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7770 * as well to keep same syntax as in SAP. Now onwards, STA
7771 * will support both */
7772 { WE_SET_MAX_TX_POWER,
7773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7774 0,
7775 "setTxMaxPower" },
7776
Jeff Johnson295189b2012-06-20 16:38:30 -07007777 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7778 * 1 = enable and 0 = disable */
7779 {
7780 WE_SET_HIGHER_DTIM_TRANSITION,
7781 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7782 0,
7783 "setHDtimTransn" },
7784
7785 { WE_SET_TM_LEVEL,
7786 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007787 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007788 "setTmLevel" },
7789
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307790 { WE_ENABLE_STRICT_FCC_REG,
7791 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7792 0,
7793 "setStrictFCCreg" },
7794
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007795 { WE_SET_DEBUG_LOG,
7796 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7797 0, "setDbgLvl" },
7798
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 /* handlers for main ioctl */
7800 { WLAN_PRIV_SET_NONE_GET_INT,
7801 0,
7802 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7803 "" },
7804
7805 /* handlers for sub-ioctl */
7806 { WE_GET_11D_STATE,
7807 0,
7808 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7809 "get11Dstate" },
7810
7811 { WE_IBSS_STATUS,
7812 0,
7813 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7814 "getAdhocStatus" },
7815
7816 { WE_PMC_STATE,
7817 0,
7818 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7819 "pmcState" },
7820
7821 { WE_GET_WLAN_DBG,
7822 0,
7823 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7824 "getwlandbg" },
7825
7826 { WE_MODULE_DOWN_IND,
7827 0,
7828 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7829 "moduleDownInd" },
7830
7831 { WE_GET_MAX_ASSOC,
7832 0,
7833 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7834 "getMaxAssoc" },
7835
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 { WE_GET_WDI_DBG,
7837 0,
7838 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7839 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007840
7841 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7842 0,
7843 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7844 "getAutoChannel" },
7845
7846 { WE_GET_CONCURRENCY_MODE,
7847 0,
7848 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7849 "getconcurrency" },
7850
7851 /* handlers for main ioctl */
7852 { WLAN_PRIV_SET_CHAR_GET_NONE,
7853 IW_PRIV_TYPE_CHAR| 512,
7854 0,
7855 "" },
7856
7857 /* handlers for sub-ioctl */
7858 { WE_WOWL_ADD_PTRN,
7859 IW_PRIV_TYPE_CHAR| 512,
7860 0,
7861 "wowlAddPtrn" },
7862
7863 { WE_WOWL_DEL_PTRN,
7864 IW_PRIV_TYPE_CHAR| 512,
7865 0,
7866 "wowlDelPtrn" },
7867
7868#if defined WLAN_FEATURE_VOWIFI
7869 /* handlers for sub-ioctl */
7870 { WE_NEIGHBOR_REPORT_REQUEST,
7871 IW_PRIV_TYPE_CHAR | 512,
7872 0,
7873 "neighbor" },
7874#endif
7875 { WE_SET_AP_WPS_IE,
7876 IW_PRIV_TYPE_CHAR| 512,
7877 0,
7878 "set_ap_wps_ie" },
7879
7880 { WE_SET_CONFIG,
7881 IW_PRIV_TYPE_CHAR| 512,
7882 0,
7883 "setConfig" },
7884
7885 /* handlers for main ioctl */
7886 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7887 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7888 0,
7889 "" },
7890
7891 /* handlers for sub-ioctl */
7892 { WE_SET_WLAN_DBG,
7893 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7894 0,
7895 "setwlandbg" },
7896
Jeff Johnson295189b2012-06-20 16:38:30 -07007897 { WE_SET_WDI_DBG,
7898 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7899 0,
7900 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007901
7902 { WE_SET_SAP_CHANNELS,
7903 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7904 0,
7905 "setsapchannels" },
7906
7907 /* handlers for main ioctl */
7908 { WLAN_PRIV_GET_CHAR_SET_NONE,
7909 0,
7910 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7911 "" },
7912
7913 /* handlers for sub-ioctl */
7914 { WE_WLAN_VERSION,
7915 0,
7916 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7917 "version" },
7918 { WE_GET_STATS,
7919 0,
7920 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7921 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307922 { WE_GET_STATES,
7923 0,
7924 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7925 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 { WE_GET_CFG,
7927 0,
7928 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7929 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007930#ifdef WLAN_FEATURE_11AC
7931 { WE_GET_RSSI,
7932 0,
7933 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7934 "getRSSI" },
7935#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007936#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007937 { WE_GET_ROAM_RSSI,
7938 0,
7939 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7940 "getRoamRSSI" },
7941#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007942 { WE_GET_WMM_STATUS,
7943 0,
7944 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7945 "getWmmStatus" },
7946 {
7947 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307948 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7950 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007951#ifdef FEATURE_WLAN_TDLS
7952 {
7953 WE_GET_TDLS_PEERS,
7954 0,
7955 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7956 "getTdlsPeers" },
7957#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007958#ifdef WLAN_FEATURE_11W
7959 {
7960 WE_GET_11W_INFO,
7961 0,
7962 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7963 "getPMFInfo" },
7964#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007965 /* handlers for main ioctl */
7966 { WLAN_PRIV_SET_NONE_GET_NONE,
7967 0,
7968 0,
7969 "" },
7970
7971 /* handlers for sub-ioctl */
7972 { WE_CLEAR_STATS,
7973 0,
7974 0,
7975 "clearStats" },
7976 { WE_INIT_AP,
7977 0,
7978 0,
7979 "initAP" },
7980 { WE_STOP_AP,
7981 0,
7982 0,
7983 "exitAP" },
7984 { WE_ENABLE_AMP,
7985 0,
7986 0,
7987 "enableAMP" },
7988 { WE_DISABLE_AMP,
7989 0,
7990 0,
7991 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007992 { WE_ENABLE_DXE_STALL_DETECT,
7993 0,
7994 0,
7995 "dxeStallDetect" },
7996 { WE_DISPLAY_DXE_SNAP_SHOT,
7997 0,
7998 0,
7999 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308000 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
8001 0,
8002 0,
8003 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07008004 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05308005 WE_STOP_OBSS_SCAN,
8006 0,
8007 0,
8008 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008009
8010 /* handlers for main ioctl */
8011 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
8012 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8013 0,
8014 "" },
8015
8016 /* handlers for sub-ioctl */
8017 { WE_LOG_DUMP_CMD,
8018 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8019 0,
8020 "dump" },
8021
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008022 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308023 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8024 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8025 0,
8026 "setdumplog" },
8027
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008028 { WE_MTRACE_DUMP_CMD,
8029 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8030 0,
8031 "dumplog" },
8032
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008033 /* handlers for sub ioctl */
8034 {
8035 WE_MCC_CONFIG_CREDENTIAL,
8036 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8037 0,
8038 "setMccCrdnl" },
8039
8040 /* handlers for sub ioctl */
8041 {
8042 WE_MCC_CONFIG_PARAMS,
8043 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8044 0,
8045 "setMccConfig" },
8046
Chilam NG571c65a2013-01-19 12:27:36 +05308047#ifdef FEATURE_WLAN_TDLS
8048 /* handlers for sub ioctl */
8049 {
8050 WE_TDLS_CONFIG_PARAMS,
8051 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8052 0,
8053 "setTdlsConfig" },
8054#endif
8055
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 /* handlers for main ioctl */
8057 { WLAN_PRIV_ADD_TSPEC,
8058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8060 "addTspec" },
8061
8062 /* handlers for main ioctl */
8063 { WLAN_PRIV_DEL_TSPEC,
8064 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8065 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8066 "delTspec" },
8067
8068 /* handlers for main ioctl */
8069 { WLAN_PRIV_GET_TSPEC,
8070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8071 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8072 "getTspec" },
8073
Jeff Johnsone7245742012-09-05 17:12:55 -07008074#ifdef FEATURE_OEM_DATA_SUPPORT
8075 /* handlers for main ioctl - OEM DATA */
8076 {
8077 WLAN_PRIV_SET_OEM_DATA_REQ,
8078 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8079 0,
8080 "set_oem_data_req" },
8081
8082 /* handlers for main ioctl - OEM DATA */
8083 {
8084 WLAN_PRIV_GET_OEM_DATA_RSP,
8085 0,
8086 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8087 "get_oem_data_rsp" },
8088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008089
8090#ifdef FEATURE_WLAN_WAPI
8091 /* handlers for main ioctl SET_WAPI_MODE */
8092 { WLAN_PRIV_SET_WAPI_MODE,
8093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8094 0,
8095 "SET_WAPI_MODE" },
8096
8097 /* handlers for main ioctl GET_WAPI_MODE */
8098 { WLAN_PRIV_GET_WAPI_MODE,
8099 0,
8100 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8101 "GET_WAPI_MODE" },
8102
8103 /* handlers for main ioctl SET_ASSOC_INFO */
8104 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
8105 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
8106 0,
8107 "SET_WAPI_ASSOC" },
8108
8109 /* handlers for main ioctl SET_WAPI_KEY */
8110 { WLAN_PRIV_SET_WAPI_KEY,
8111 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8112 0,
8113 "SET_WAPI_KEY" },
8114
8115 /* handlers for main ioctl SET_WAPI_BKID */
8116 { WLAN_PRIV_SET_WAPI_BKID,
8117 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8118 0,
8119 "SET_WAPI_BKID" },
8120
8121 /* handlers for main ioctl GET_WAPI_BKID */
8122 { WLAN_PRIV_GET_WAPI_BKID,
8123 0,
8124 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8125 "GET_WAPI_BKID" },
8126#endif /* FEATURE_WLAN_WAPI */
8127
8128 /* handlers for main ioctl - host offload */
8129 {
8130 WLAN_PRIV_SET_HOST_OFFLOAD,
8131 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8132 0,
8133 "setHostOffload" },
8134
8135 {
8136 WLAN_GET_WLAN_STATISTICS,
8137 0,
8138 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8139 "getWlanStats" },
8140
8141 {
8142 WLAN_SET_KEEPALIVE_PARAMS,
8143 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8144 0,
8145 "setKeepAlive" },
8146#ifdef WLAN_FEATURE_PACKET_FILTERING
8147 {
8148 WLAN_SET_PACKET_FILTER_PARAMS,
8149 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8150 0,
8151 "setPktFilter" },
8152#endif
8153#ifdef FEATURE_WLAN_SCAN_PNO
8154 {
8155 WLAN_SET_PNO,
8156 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8157 0,
8158 "setpno" },
8159#endif
8160 {
8161 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008163 0,
8164 "SETBAND" },
8165 /* handlers for dynamic MC BC ioctl */
8166 {
8167 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008168 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 0,
8170 "setMCBCFilter" },
8171 {
8172 WLAN_PRIV_CLEAR_MCBC_FILTER,
8173 0,
8174 0,
8175 "clearMCBCFilter" },
8176 {
8177 WLAN_SET_POWER_PARAMS,
8178 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8179 0,
8180 "setpowerparams" },
8181 {
8182 WLAN_GET_LINK_SPEED,
8183 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308184 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008185};
8186
8187
8188
8189const struct iw_handler_def we_handler_def = {
8190 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8191 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8192 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8193
8194 .standard = (iw_handler *)we_handler,
8195 .private = (iw_handler *)we_private,
8196 .private_args = we_private_args,
8197 .get_wireless_stats = get_wireless_stats,
8198};
8199
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008200int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8201{
8202 v_U32_t cmd = 288; //Command to RIVA
8203 hdd_context_t *pHddCtx = NULL;
8204 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8205 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8206 /*
8207 *configMccParam : specify the bit which needs to be modified
8208 *allowed to update based on wlan_qcom_cfg.ini
8209 * configuration
8210 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8211 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8212 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8213 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8214 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8215 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8216 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8217 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8218 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8219 * Bit 9 : Reserved
8220 */
8221 switch (arg1)
8222 {
8223 //Update MCC SCHEDULE_TIME_SLICE parameter
8224 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8225 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8226 {
8227 if((arg2 >= 5) && (arg2 <= 20))
8228 {
8229 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8230 }
8231 else
8232 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008233 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008234 return 0;
8235 }
8236 }
8237 break;
8238
8239 //Update MCC MAX_NULL_SEND_TIME parameter
8240 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8241 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8242 {
8243 if((arg2 >= 1) && (arg2 <= 10))
8244 {
8245 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8246 }
8247 else
8248 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008249 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008250 return 0;
8251 }
8252 }
8253 break;
8254
8255 //Update MCC TX_EARLY_STOP_TIME parameter
8256 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8257 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8258 {
8259 if((arg2 >= 1) && (arg2 <= 10))
8260 {
8261 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8262 }
8263 else
8264 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008265 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008266 return 0;
8267 }
8268 }
8269 break;
8270
8271 //Update MCC RX_DRAIN_TIME parameter
8272 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8273 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8274 {
8275 if((arg2 >= 1) && (arg2 <= 10))
8276 {
8277 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8278 }
8279 else
8280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008281 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008282 return 0;
8283 }
8284 }
8285 break;
8286
8287 //Update MCC CHANNEL_SWITCH_TIME parameter
8288 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8289 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8290 {
8291 if((arg2 >= 1) && (arg2 <= 20))
8292 {
8293 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8294 }
8295 else
8296 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008297 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008298 return 0;
8299 }
8300 }
8301 break;
8302
8303 //Update MCC MIN_CHANNEL_TIME parameter
8304 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8305 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8306 {
8307 if((arg2 >= 5) && (arg2 <= 20))
8308 {
8309 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8310 }
8311 else
8312 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008313 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008314 return 0;
8315 }
8316 }
8317 break;
8318
8319 //Update MCC PARK_BEFORE_TBTT parameter
8320 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8321 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8322 {
8323 if((arg2 >= 1) && (arg2 <= 5))
8324 {
8325 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8326 }
8327 else
8328 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008329 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008330 return 0;
8331 }
8332 }
8333 break;
8334
8335 //Update MCC MIN_AFTER_DTIM parameter
8336 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8337 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8338 {
8339 if((arg2 >= 5) && (arg2 <= 15))
8340 {
8341 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8342 }
8343 else
8344 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008345 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008346 return 0;
8347 }
8348 }
8349 break;
8350
8351 //Update MCC TOO_CLOSE_MARGIN parameter
8352 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8353 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8354 {
8355 if((arg2 >= 1) && (arg2 <= 3))
8356 {
8357 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8358 }
8359 else
8360 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008361 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008362 return 0;
8363 }
8364 }
8365 break;
8366
8367 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008368 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008369 __FUNCTION__,arg1);
8370 break;
8371 }
8372 return 0;
8373}
8374
Jeff Johnson295189b2012-06-20 16:38:30 -07008375int hdd_set_wext(hdd_adapter_t *pAdapter)
8376{
8377 hdd_wext_state_t *pwextBuf;
8378 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008379 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008380
8381 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8382
8383 // Now configure the roaming profile links. To SSID and bssid.
8384 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8385 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8386
8387 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8388 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8389
8390 /*Set the numOfChannels to zero to scan all the channels*/
8391 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8392 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8393
8394 /* Default is no encryption */
8395 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8396 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8397
8398 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8399 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8400
8401 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8402
8403 /* Default is no authentication */
8404 pwextBuf->roamProfile.AuthType.numEntries = 1;
8405 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8406
8407 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8408 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8409
8410 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008411 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008412
8413 hdd_clearRoamProfileIe(pAdapter);
8414
8415 return VOS_STATUS_SUCCESS;
8416
8417 }
8418
8419int hdd_register_wext(struct net_device *dev)
8420 {
8421 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8422 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8423 VOS_STATUS status;
8424
8425 ENTER();
8426
8427 // Zero the memory. This zeros the profile structure.
8428 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8429
8430 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8431
8432
8433 status = hdd_set_wext(pAdapter);
8434
8435 if(!VOS_IS_STATUS_SUCCESS(status)) {
8436
Arif Hussain6d2a3322013-11-17 19:50:10 -08008437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 return eHAL_STATUS_FAILURE;
8439 }
8440
8441 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8442 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 return eHAL_STATUS_FAILURE;
8445 }
8446
8447 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8448 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008450 return eHAL_STATUS_FAILURE;
8451 }
8452
8453 // Register as a wireless device
8454 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8455
8456 EXIT();
8457 return 0;
8458}
8459
8460int hdd_UnregisterWext(struct net_device *dev)
8461{
8462#if 0
8463 hdd_wext_state_t *wextBuf;
8464 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8465
8466 ENTER();
8467 // Set up the pointer to the Wireless Extensions state structure
8468 wextBuf = pAdapter->pWextState;
8469
8470 // De-allocate the Wireless Extensions state structure
8471 kfree(wextBuf);
8472
8473 // Clear out the pointer to the Wireless Extensions state structure
8474 pAdapter->pWextState = NULL;
8475
8476 EXIT();
8477#endif
8478 dev->wireless_handlers = NULL;
8479 return 0;
8480}
8481
8482