blob: 544dc7e0303b4a46da2cf7244907428401b14f9e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/** ------------------------------------------------------------------------ *
31 ------------------------------------------------------------------------ *
32
33
34 \file wlan_hdd_wext.c
35
36 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
37 interfaces.
38
39 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041 This file defines all of the types that are utilized by the CCP module
42 of the "Portable" HDD. This file also includes the underlying Linux
43 Wireless Extensions Data types referred to by CCP.
44
45 ======================================================================== */
46
47#include <linux/version.h>
48#include <linux/module.h>
49#include <linux/kernel.h>
50#include <linux/init.h>
51#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053052#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include <wlan_hdd_includes.h>
54#include <wlan_btc_svc.h>
55#include <wlan_nlink_common.h>
56#ifdef WLAN_BTAMP_FEATURE
57#include <bap_hdd_main.h>
58#endif
59#include <vos_api.h>
60#include <net/arp.h>
61#include "ccmApi.h"
62#include "sirParams.h"
63#include "csrApi.h"
64#include "csrInsideApi.h"
65#if defined WLAN_FEATURE_VOWIFI
66#include "smeRrmInternal.h"
67#endif
68#include <aniGlobal.h>
69#include "dot11f.h"
70#include <wlan_hdd_wowl.h>
71#include <wlan_hdd_cfg.h>
72#include <wlan_hdd_wmm.h>
73#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053075#ifdef FEATURE_WLAN_TDLS
76#include "wlan_hdd_tdls.h"
77#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070078
79#ifdef CONFIG_HAS_EARLYSUSPEND
80#include <linux/earlysuspend.h>
81#endif
82#include "wlan_hdd_power.h"
83#include "qwlan_version.h"
84#include <vos_power.h>
85#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
104#ifdef CONFIG_HAS_EARLYSUSPEND
105extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
106extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
107#endif
108
Jeff Johnsone7245742012-09-05 17:12:55 -0700109#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800110#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700111#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
113#define HDD_FINISH_ULA_TIME_OUT 800
114
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
117int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
118
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700119static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122/* To Validate Channel against the Frequency and Vice-Versa */
123static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
124 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
125 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
126 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
127 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
128 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
129 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
130 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
131 {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} };
132
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800133#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700134
135/* Private ioctls and their sub-ioctls */
136#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
137#define WE_SET_11D_STATE 1
138#define WE_WOWL 2
139#define WE_SET_POWER 3
140#define WE_SET_MAX_ASSOC 4
141#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
142#define WE_SET_DATA_INACTIVITY_TO 6
143#define WE_SET_MAX_TX_POWER 7
144#define WE_SET_HIGHER_DTIM_TRANSITION 8
145#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530146#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700147#define WE_SET_MAX_TX_POWER_2_4 11
148#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800149/* Private IOCTL for debug connection issues */
150#define WE_SET_DEBUG_LOG 13
Jeff Johnson295189b2012-06-20 16:38:30 -0700151
152/* Private ioctls and their sub-ioctls */
153#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
154#define WE_GET_11D_STATE 1
155#define WE_IBSS_STATUS 2
156#define WE_PMC_STATE 3
157#define WE_GET_WLAN_DBG 4
158#define WE_MODULE_DOWN_IND 5
159#define WE_GET_MAX_ASSOC 6
160#define WE_GET_WDI_DBG 7
161#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
162#define WE_GET_CONCURRENCY_MODE 9
163/* Private ioctls and their sub-ioctls */
164#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
165
166/* Private ioctls and their sub-ioctls */
167#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
168#define WE_WOWL_ADD_PTRN 1
169#define WE_WOWL_DEL_PTRN 2
170#if defined WLAN_FEATURE_VOWIFI
171#define WE_NEIGHBOR_REPORT_REQUEST 3
172#endif
173#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
174#define WE_SET_CONFIG 5
175
176/* Private ioctls and their sub-ioctls */
177#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
178#define WE_SET_WLAN_DBG 1
179#define WE_SET_WDI_DBG 2
180#define WE_SET_SAP_CHANNELS 3
181
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
184#define WE_WLAN_VERSION 1
185#define WE_GET_STATS 2
186#define WE_GET_CFG 3
187#define WE_GET_WMM_STATUS 4
188#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700189#ifdef WLAN_FEATURE_11AC
190#define WE_GET_RSSI 6
191#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800192#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800193#ifdef FEATURE_WLAN_TDLS
194#define WE_GET_TDLS_PEERS 8
195#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700196#ifdef WLAN_FEATURE_11W
197#define WE_GET_11W_INFO 9
198#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530199#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700200
201/* Private ioctls and their sub-ioctls */
202#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
203#define WE_CLEAR_STATS 1
204#define WE_INIT_AP 2
205#define WE_STOP_AP 3
206#define WE_ENABLE_AMP 4
207#define WE_DISABLE_AMP 5
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700208#define WE_ENABLE_DXE_STALL_DETECT 6
209#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +0530210#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700211#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530212#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700213
214/* Private ioctls and their sub-ioctls */
215#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
216#define WE_LOG_DUMP_CMD 1
217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800219//IOCTL to configure MCC params
220#define WE_MCC_CONFIG_CREDENTIAL 3
221#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700222
Chilam NG571c65a2013-01-19 12:27:36 +0530223#ifdef FEATURE_WLAN_TDLS
224#define WE_TDLS_CONFIG_PARAMS 5
225#endif
226
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700227#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530228#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700229
Chilam Ng01120412013-02-19 18:32:21 -0800230#ifdef FEATURE_WLAN_TDLS
231#undef MAX_VAR_ARGS
232#define MAX_VAR_ARGS 10
233#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700234#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800235#endif
236
Jeff Johnson295189b2012-06-20 16:38:30 -0700237
238/* Private ioctls (with no sub-ioctls) */
239/* note that they must be odd so that they have "get" semantics */
240#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
241#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
242#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
243
244#ifdef FEATURE_WLAN_WAPI
245/* Private ioctls EVEN NO: SET, ODD NO:GET */
246#define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8)
247#define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16)
248#define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10)
249#define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12)
250#define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14)
251#define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15)
252#define WAPI_PSK_AKM_SUITE 0x02721400
253#define WAPI_CERT_AKM_SUITE 0x01721400
254#endif
255
Jeff Johnsone7245742012-09-05 17:12:55 -0700256#ifdef FEATURE_OEM_DATA_SUPPORT
257/* Private ioctls for setting the measurement configuration */
258#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
259#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
260#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700261
262#ifdef WLAN_FEATURE_VOWIFI_11R
263#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
264#endif
265
266/* Private ioctl for setting the host offload feature */
267#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
268
269/* Private ioctl to get the statistics */
270#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
271
272/* Private ioctl to set the Keep Alive Params */
273#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
274#ifdef WLAN_FEATURE_PACKET_FILTERING
275/* Private ioctl to set the Packet Filtering Params */
276#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
277#endif
278
279#ifdef FEATURE_WLAN_SCAN_PNO
280/* Private ioctl to get the statistics */
281#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
282#endif
283
284#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
285
286#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
287#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700288/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700289
Jeff Johnson295189b2012-06-20 16:38:30 -0700290#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
291#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
292
293#define WLAN_STATS_INVALID 0
294#define WLAN_STATS_RETRY_CNT 1
295#define WLAN_STATS_MUL_RETRY_CNT 2
296#define WLAN_STATS_TX_FRM_CNT 3
297#define WLAN_STATS_RX_FRM_CNT 4
298#define WLAN_STATS_FRM_DUP_CNT 5
299#define WLAN_STATS_FAIL_CNT 6
300#define WLAN_STATS_RTS_FAIL_CNT 7
301#define WLAN_STATS_ACK_FAIL_CNT 8
302#define WLAN_STATS_RTS_SUC_CNT 9
303#define WLAN_STATS_RX_DISCARD_CNT 10
304#define WLAN_STATS_RX_ERROR_CNT 11
305#define WLAN_STATS_TX_BYTE_CNT 12
306
307#define WLAN_STATS_RX_BYTE_CNT 13
308#define WLAN_STATS_RX_RATE 14
309#define WLAN_STATS_TX_RATE 15
310
Jeff Johnsone7245742012-09-05 17:12:55 -0700311#define WLAN_STATS_RX_UC_BYTE_CNT 16
312#define WLAN_STATS_RX_MC_BYTE_CNT 17
313#define WLAN_STATS_RX_BC_BYTE_CNT 18
314#define WLAN_STATS_TX_UC_BYTE_CNT 19
315#define WLAN_STATS_TX_MC_BYTE_CNT 20
316#define WLAN_STATS_TX_BC_BYTE_CNT 21
317
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800318#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
319 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
320 { \
321 *__p++ = __type; \
322 *__p++ = __size; \
323 memcpy(__p, __val, __size); \
324 __p += __size; \
325 __tlen += __size + 2; \
326 } \
327 else \
328 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800329 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800330 } \
331 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700332
333#define VERSION_VALUE_MAX_LEN 32
334
335#define TX_PER_TRACKING_DEFAULT_RATIO 5
336#define TX_PER_TRACKING_MAX_RATIO 10
337#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
338
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530339#define WLAN_ADAPTER 0
340#define P2P_ADAPTER 1
341
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800342/*MCC Configuration parameters */
343enum {
344 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
345 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
346 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
347 MCC_RX_DRAIN_TIME_CFG_PARAM,
348 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
349 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
350 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
351 MCC_MIN_AFTER_DTIM_CFG_PARAM,
352 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
353};
354
355int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
356 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
357
Jeff Johnson295189b2012-06-20 16:38:30 -0700358#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800359int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700360 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361#endif
362
Jeff Johnson295189b2012-06-20 16:38:30 -0700363/**---------------------------------------------------------------------------
364
Arif Hussain0273cba2014-01-07 20:58:29 -0800365 \brief mem_alloc_copy_from_user_helper -
366
367 Helper function to allocate buffer and copy user data.
368
369 \param - wrqu - Pointer to IOCTL Data.
370 len - size
371
372 \return - On Success pointer to buffer, On failure NULL
373
374 --------------------------------------------------------------------------*/
375static void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
376{
377 u8 *ptr = NULL;
378
379 /* in order to protect the code, an extra byte is post appended to the buffer
380 * and the null termination is added. However, when allocating (len+1) byte
381 * of memory, we need to make sure that there is no uint overflow when doing
382 * addition. In theory check len < UINT_MAX protects the uint overflow. For
383 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
384 * guess, now, it is assumed that the private command buffer size is no
385 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
386 */
387 if (len > MAX_USER_COMMAND_SIZE)
388 {
389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
390 "Invalid length");
391 return NULL;
392 }
393
394 ptr = kmalloc(len + 1, GFP_KERNEL);
395 if (NULL == ptr)
396 {
397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
398 "unable to allocate memory");
399 return NULL;
400 }
401
402 if (copy_from_user(ptr, wrqu_data, len))
403 {
404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
405 "%s: failed to copy data to user buffer", __func__);
406 kfree(ptr);
407 return NULL;
408 }
409 ptr[len] = '\0';
410 return ptr;
411}
412
413/**---------------------------------------------------------------------------
414
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 \brief hdd_wlan_get_version() -
416
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800417 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700418
419 \param - pAdapter Pointer to the adapter.
420 wrqu - Pointer to IOCTL REQUEST Data.
421 extra - Pointer to char
422
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800423 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700424
425 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800426void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
427 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700428{
429 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800430 tSirVersionString wcnss_SW_version;
431 tSirVersionString wcnss_HW_version;
432 char *pSWversion;
433 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700435
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800436 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
437 sizeof(wcnss_SW_version));
438 if (VOS_IS_STATUS_SUCCESS(status))
439 {
440 pSWversion = wcnss_SW_version;
441 }
442 else
443 {
444 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 }
446
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800447 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
448 sizeof(wcnss_HW_version));
449 if (VOS_IS_STATUS_SUCCESS(status))
450 {
451 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800453 else
454 {
455 pHWversion = "Unknown";
456 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700457
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700458 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800459 "Host SW:%s, FW:%s, HW:%s",
460 QWLAN_VERSIONSTR,
461 pSWversion,
462 pHWversion);
463
464 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700465}
466
Jeff Johnson295189b2012-06-20 16:38:30 -0700467int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
468{
469 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
470 v_U32_t threshold = 0,status = 0;
471
472 ENTER();
473
Agarwal Ashish971c2882013-10-30 20:11:12 +0530474 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
475 {
476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 "%s:LOGP in Progress. Ignore!!!",__func__);
478 return status;
479 }
480
481 if ( eHAL_STATUS_SUCCESS !=
482 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
483 {
c_hpothub8245442013-11-20 23:41:09 +0530484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
485 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 return -EIO;
487 }
488 wrqu->rts.value = threshold;
489
490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800491 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700492
493 EXIT();
494
495 return 0;
496}
497
498int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
499{
500 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
501 v_U32_t threshold = 0,status = 0;
502
503 ENTER();
504
Agarwal Ashish971c2882013-10-30 20:11:12 +0530505 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
506 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
508 "%s:LOGP in Progress. Ignore!!!",__func__);
509 return status;
510 }
511
512 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
513 != eHAL_STATUS_SUCCESS )
514 {
c_hpothub8245442013-11-20 23:41:09 +0530515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
516 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 return -EIO;
518 }
519 wrqu->frag.value = threshold;
520
521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800522 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700523
524 EXIT();
525
526 return 0;
527}
528
529int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
530{
Jeff Johnsone7245742012-09-05 17:12:55 -0700531 int i;
532 if (channel > 0)
533 {
534 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
535 {
536 if (channel == freq_chan_map[i].chan)
537 {
538 *pfreq = freq_chan_map[i].freq;
539 return 1;
540 }
541 }
542 }
543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800544 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700545 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700546}
547
548static v_BOOL_t
549hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
550{
551 v_BOOL_t rsnType = VOS_FALSE;
552 // is the authType supported?
553 switch (authType)
554 {
555 case eCSR_AUTH_TYPE_NONE: //never used
556 rsnType = eANI_BOOLEAN_FALSE;
557 break;
558 // MAC layer authentication types
559 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
560 rsnType = eANI_BOOLEAN_FALSE;
561 break;
562 case eCSR_AUTH_TYPE_SHARED_KEY:
563 rsnType = eANI_BOOLEAN_FALSE;
564 break;
565 case eCSR_AUTH_TYPE_AUTOSWITCH:
566 rsnType = eANI_BOOLEAN_FALSE;
567 break;
568
569 // Upper layer authentication types
570 case eCSR_AUTH_TYPE_WPA:
571 rsnType = eANI_BOOLEAN_TRUE;
572 break;
573 case eCSR_AUTH_TYPE_WPA_PSK:
574 rsnType = eANI_BOOLEAN_TRUE;
575 break;
576 case eCSR_AUTH_TYPE_WPA_NONE:
577 rsnType = eANI_BOOLEAN_TRUE;
578 break;
579#ifdef WLAN_FEATURE_VOWIFI_11R
580 case eCSR_AUTH_TYPE_FT_RSN:
581#endif
582 case eCSR_AUTH_TYPE_RSN:
583 rsnType = eANI_BOOLEAN_TRUE;
584 break;
585#ifdef WLAN_FEATURE_VOWIFI_11R
586 case eCSR_AUTH_TYPE_FT_RSN_PSK:
587#endif
588 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700589#ifdef WLAN_FEATURE_11W
590 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
591#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 rsnType = eANI_BOOLEAN_TRUE;
593 break;
594 //case eCSR_AUTH_TYPE_FAILED:
595 case eCSR_AUTH_TYPE_UNKNOWN:
596 rsnType = eANI_BOOLEAN_FALSE;
597 break;
598 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800599 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
600 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 rsnType = eANI_BOOLEAN_FALSE;
602 break;
603 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800604 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700605 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700606 return rsnType;
607}
608
609static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
610{
611 struct statsContext *pStatsContext;
612 hdd_adapter_t *pAdapter;
613
614 if (ioctl_debug)
615 {
616 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700617 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 }
619
620 if (NULL == pContext)
621 {
622 hddLog(VOS_TRACE_LEVEL_ERROR,
623 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700624 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 return;
626 }
627
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 pStatsContext = pContext;
629 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800630
631 /* there is a race condition that exists between this callback
632 function and the caller since the caller could time out either
633 before or while this code is executing. we use a spinlock to
634 serialize these actions */
635 spin_lock(&hdd_context_lock);
636
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
638 {
639 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800640 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 hddLog(VOS_TRACE_LEVEL_WARN,
642 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700643 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 if (ioctl_debug)
645 {
646 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700647 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700648 }
649 return;
650 }
651
Jeff Johnson72a40512013-12-19 10:14:15 -0800652 /* context is valid so caller is still waiting */
653
654 /* paranoia: invalidate the magic */
655 pStatsContext->magic = 0;
656
657 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 pAdapter->rssi = rssi;
659
Jeff Johnson72a40512013-12-19 10:14:15 -0800660 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800662
663 /* serialization is complete */
664 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700665}
666
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530667static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
668{
669 struct statsContext *pStatsContext;
670 hdd_adapter_t *pAdapter;
671
672 if (ioctl_debug)
673 {
674 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
675 __func__, (int)snr, (int)staId, pContext);
676 }
677
678 if (NULL == pContext)
679 {
680 hddLog(VOS_TRACE_LEVEL_ERROR,
681 "%s: Bad param, pContext [%p]",
682 __func__, pContext);
683 return;
684 }
685
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530686 pStatsContext = pContext;
687 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800688
689 /* there is a race condition that exists between this callback
690 function and the caller since the caller could time out either
691 before or while this code is executing. we use a spinlock to
692 serialize these actions */
693 spin_lock(&hdd_context_lock);
694
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530695 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
696 {
697 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800698 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530699 hddLog(VOS_TRACE_LEVEL_WARN,
700 "%s: Invalid context, pAdapter [%p] magic [%08x]",
701 __func__, pAdapter, pStatsContext->magic);
702 if (ioctl_debug)
703 {
704 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
705 __func__, pAdapter, pStatsContext->magic);
706 }
707 return;
708 }
709
Jeff Johnson72a40512013-12-19 10:14:15 -0800710 /* context is valid so caller is still waiting */
711
712 /* paranoia: invalidate the magic */
713 pStatsContext->magic = 0;
714
715 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530716 pAdapter->snr = snr;
717
Jeff Johnson72a40512013-12-19 10:14:15 -0800718 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530719 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800720
721 /* serialization is complete */
722 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530723}
724
Jeff Johnson295189b2012-06-20 16:38:30 -0700725VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
726{
727 struct statsContext context;
728 hdd_context_t *pHddCtx;
729 hdd_station_ctx_t *pHddStaCtx;
730 eHalStatus hstatus;
731 long lrc;
732
733 if (NULL == pAdapter)
734 {
735 hddLog(VOS_TRACE_LEVEL_WARN,
736 "%s: Invalid context, pAdapter", __func__);
737 return VOS_STATUS_E_FAULT;
738 }
739 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
740 {
741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
742 /* return a cached value */
743 *rssi_value = pAdapter->rssi;
744 return VOS_STATUS_SUCCESS;
745 }
746
747 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
748 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
749
750 init_completion(&context.completion);
751 context.pAdapter = pAdapter;
752 context.magic = RSSI_CONTEXT_MAGIC;
753
754 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
755 pHddStaCtx->conn_info.staId[ 0 ],
756 pHddStaCtx->conn_info.bssId,
757 &context, pHddCtx->pvosContext);
758 if (eHAL_STATUS_SUCCESS != hstatus)
759 {
760 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700761 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 /* we'll returned a cached value below */
763 }
764 else
765 {
766 /* request was sent -- wait for the response */
767 lrc = wait_for_completion_interruptible_timeout(&context.completion,
768 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 if (lrc <= 0)
770 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800771 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700772 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 /* we'll now returned a cached value below */
774 }
775 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800776
777 /* either we never sent a request, we sent a request and received a
778 response or we sent a request and timed out. if we never sent a
779 request or if we sent a request and got a response, we want to
780 clear the magic out of paranoia. if we timed out there is a
781 race condition such that the callback function could be
782 executing at the same time we are. of primary concern is if the
783 callback function had already verified the "magic" but had not
784 yet set the completion variable when a timeout occurred. we
785 serialize these activities by invalidating the magic while
786 holding a shared spinlock which will cause us to block if the
787 callback is currently executing */
788 spin_lock(&hdd_context_lock);
789 context.magic = 0;
790 spin_unlock(&hdd_context_lock);
791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 *rssi_value = pAdapter->rssi;
793
794 return VOS_STATUS_SUCCESS;
795}
796
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530797VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
798{
799 struct statsContext context;
800 hdd_context_t *pHddCtx;
801 hdd_station_ctx_t *pHddStaCtx;
802 eHalStatus hstatus;
803 long lrc;
804 int valid;
805
806 if (NULL == pAdapter)
807 {
808 hddLog(VOS_TRACE_LEVEL_ERROR,
809 "%s: Invalid context, pAdapter", __func__);
810 return VOS_STATUS_E_FAULT;
811 }
812
813 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
814
815 valid = wlan_hdd_validate_context(pHddCtx);
816 if (0 != valid)
817 {
818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
819 return VOS_STATUS_E_FAULT;
820 }
821
822 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
823 if (NULL == pHddStaCtx)
824 {
825 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
826 return VOS_STATUS_E_FAULT;
827 }
828
829 init_completion(&context.completion);
830 context.pAdapter = pAdapter;
831 context.magic = SNR_CONTEXT_MAGIC;
832
833 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
834 pHddStaCtx->conn_info.staId[ 0 ],
835 pHddStaCtx->conn_info.bssId,
836 &context);
837 if (eHAL_STATUS_SUCCESS != hstatus)
838 {
839 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
840 __func__);
841 /* we'll returned a cached value below */
842 }
843 else
844 {
845 /* request was sent -- wait for the response */
846 lrc = wait_for_completion_interruptible_timeout(&context.completion,
847 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530848 if (lrc <= 0)
849 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800850 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530851 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530852 /* we'll now returned a cached value below */
853 }
854 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800855
856 /* either we never sent a request, we sent a request and received a
857 response or we sent a request and timed out. if we never sent a
858 request or if we sent a request and got a response, we want to
859 clear the magic out of paranoia. if we timed out there is a
860 race condition such that the callback function could be
861 executing at the same time we are. of primary concern is if the
862 callback function had already verified the "magic" but had not
863 yet set the completion variable when a timeout occurred. we
864 serialize these activities by invalidating the magic while
865 holding a shared spinlock which will cause us to block if the
866 callback is currently executing */
867 spin_lock(&hdd_context_lock);
868 context.magic = 0;
869 spin_unlock(&hdd_context_lock);
870
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530871 *snr = pAdapter->snr;
872
873 return VOS_STATUS_SUCCESS;
874}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800875#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800876
877static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
878{
879 struct statsContext *pStatsContext;
880 hdd_adapter_t *pAdapter;
881 if (ioctl_debug)
882 {
883 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
884 __func__, (int)rssi, (int)staId, pContext);
885 }
886
887 if (NULL == pContext)
888 {
889 hddLog(VOS_TRACE_LEVEL_ERROR,
890 "%s: Bad param, pContext [%p]",
891 __func__, pContext);
892 return;
893 }
894
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800895 pStatsContext = pContext;
896 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800897
898 /* there is a race condition that exists between this callback
899 function and the caller since the caller could time out either
900 before or while this code is executing. we use a spinlock to
901 serialize these actions */
902 spin_lock(&hdd_context_lock);
903
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800904 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
905 {
906 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800907 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800908 hddLog(VOS_TRACE_LEVEL_WARN,
909 "%s: Invalid context, pAdapter [%p] magic [%08x]",
910 __func__, pAdapter, pStatsContext->magic);
911 if (ioctl_debug)
912 {
913 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
914 __func__, pAdapter, pStatsContext->magic);
915 }
916 return;
917 }
918
Jeff Johnson72a40512013-12-19 10:14:15 -0800919 /* context is valid so caller is still waiting */
920
921 /* paranoia: invalidate the magic */
922 pStatsContext->magic = 0;
923
924 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800925 pAdapter->rssi = rssi;
926
Jeff Johnson72a40512013-12-19 10:14:15 -0800927 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800928 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800929
930 /* serialization is complete */
931 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800932}
933
934
935
936VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
937{
938 struct statsContext context;
939 hdd_context_t *pHddCtx = NULL;
940 hdd_station_ctx_t *pHddStaCtx = NULL;
941 eHalStatus hstatus;
942 long lrc;
943
944 if (NULL == pAdapter)
945 {
946 hddLog(VOS_TRACE_LEVEL_WARN,
947 "%s: Invalid context, pAdapter", __func__);
948 return VOS_STATUS_E_FAULT;
949 }
950 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
951 {
952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
953 /* return a cached value */
954 *rssi_value = pAdapter->rssi;
955 return VOS_STATUS_SUCCESS;
956 }
957
958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
959 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
960
961 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
962 {
963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
964 /* return a cached value */
965 *rssi_value = 0;
966 return VOS_STATUS_SUCCESS;
967 }
968 init_completion(&context.completion);
969 context.pAdapter = pAdapter;
970 context.magic = RSSI_CONTEXT_MAGIC;
971
972 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
973 pHddStaCtx->conn_info.staId[ 0 ],
974 pHddStaCtx->conn_info.bssId,
975 &context, pHddCtx->pvosContext);
976 if (eHAL_STATUS_SUCCESS != hstatus)
977 {
978 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
979 __func__);
980 /* we'll returned a cached value below */
981 }
982 else
983 {
984 /* request was sent -- wait for the response */
985 lrc = wait_for_completion_interruptible_timeout(&context.completion,
986 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800987 if (lrc <= 0)
988 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800989 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800990 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800991 /* we'll now returned a cached value below */
992 }
993 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800994
995 /* either we never sent a request, we sent a request and received a
996 response or we sent a request and timed out. if we never sent a
997 request or if we sent a request and got a response, we want to
998 clear the magic out of paranoia. if we timed out there is a
999 race condition such that the callback function could be
1000 executing at the same time we are. of primary concern is if the
1001 callback function had already verified the "magic" but had not
1002 yet set the completion variable when a timeout occurred. we
1003 serialize these activities by invalidating the magic while
1004 holding a shared spinlock which will cause us to block if the
1005 callback is currently executing */
1006 spin_lock(&hdd_context_lock);
1007 context.magic = 0;
1008 spin_unlock(&hdd_context_lock);
1009
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001010 *rssi_value = pAdapter->rssi;
1011
1012 return VOS_STATUS_SUCCESS;
1013}
1014#endif
1015
1016
Jeff Johnson295189b2012-06-20 16:38:30 -07001017void hdd_StatisticsCB( void *pStats, void *pContext )
1018{
1019 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1020 hdd_stats_t *pStatsCache = NULL;
1021 hdd_wext_state_t *pWextState;
1022 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1023
1024 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1025 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1026 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1027 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1028 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1029 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1030
1031 if (pAdapter!= NULL)
1032 pStatsCache = &pAdapter->hdd_stats;
1033
1034
1035 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1036 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1037 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1038 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1039 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1040 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1041
1042 if (pStatsCache!=NULL)
1043 {
1044 // and copy the stats into the cache we keep in the adapter instance structure
1045 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1046 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1047 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1048 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1049 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1050 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1051 }
1052
1053 if(pAdapter)
1054 {
1055 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1056 if(pWextState)
1057 {
1058 vos_status = vos_event_set(&pWextState->vosevent);
1059 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1060 {
1061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001062 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 return;
1064 }
1065 }
1066 }
1067}
1068
1069void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1070{
1071 v_CONTEXT_t pVosContext;
1072 hdd_context_t *pHddCtx;
1073 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1074#if 0
1075 hdd_wext_state_t *pWextState;
1076 v_U32_t roamId;
1077#endif
1078
1079 ENTER();
1080
1081 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1082
1083 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1084 if (NULL == pHddCtx)
1085 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001086 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 return;
1088 }
1089#if 0
1090 pWextState = pAdapter->pWextState;
1091#endif
1092
1093 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1094 {
1095 //TODO Verify is this is really used. If yes need to fix it.
1096 hdd_reconnect_all_adapters( pHddCtx );
1097#if 0
1098 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1099 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1100 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1101
1102 if(VOS_STATUS_SUCCESS == vosStatus)
1103 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1104 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1105
1106 sme_RoamConnect(halHandle,
1107 pAdapter->sessionId, &(pWextState->roamProfile),
1108 &roamId);
1109#endif
1110 }
1111
1112 EXIT();
1113
1114}
1115
1116void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1117{
1118 int i = 0;
1119 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1120
1121 /* clear WPA/RSN/WSC IE information in the profile */
1122 pWextState->roamProfile.nWPAReqIELength = 0;
1123 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1124 pWextState->roamProfile.nRSNReqIELength = 0;
1125 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1126
Chet Lanctot186b5732013-03-18 10:26:30 -07001127#ifdef FEATURE_WLAN_WAPI
1128 pWextState->roamProfile.nWAPIReqIELength = 0;
1129 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1130#endif
1131
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301134 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1136 pWextState->roamProfile.nAddIEAssocLength = 0;
1137
1138 pWextState->roamProfile.EncryptionType.numEntries = 1;
1139 pWextState->roamProfile.EncryptionType.encryptionType[0]
1140 = eCSR_ENCRYPT_TYPE_NONE;
1141
1142 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1143 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1144 = eCSR_ENCRYPT_TYPE_NONE;
1145
1146 pWextState->roamProfile.AuthType.numEntries = 1;
1147 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1148
Chet Lanctot186b5732013-03-18 10:26:30 -07001149#ifdef WLAN_FEATURE_11W
1150 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1151 pWextState->roamProfile.MFPRequired = 0;
1152 pWextState->roamProfile.MFPCapable = 0;
1153#endif
1154
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 pWextState->authKeyMgmt = 0;
1156
1157 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1158 {
1159 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1160 {
1161 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1162 }
1163 }
1164#ifdef FEATURE_WLAN_WAPI
1165 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1166 pAdapter->wapi_info.nWapiMode = 0;
1167#endif
1168
1169 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1170
1171}
1172
1173void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1174{
1175 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001176
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001177 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1178 {
1179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1180 "%s: Invalid pAdapter magic", __func__);
1181 }
1182 else
1183 {
1184 complete(&pAdapter->ula_complete);
1185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001186}
1187
1188VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1189{
1190 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001192 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001193
1194 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1195 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001196 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001197
1198 /*To avoid race condition between the set key and the last EAPOL
1199 packet, notify TL to finish upper layer authentication incase if the
1200 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001201 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001202
1203 if ( vos_status != VOS_STATUS_SUCCESS )
1204 {
1205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1206 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1207 __LINE__, vos_status );
1208 return vos_status;
1209
1210 }
1211
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001212 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301214 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001215 {
1216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301217 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001218 /* we'll still fall through and return success since the
1219 * connection may still get established but is just taking
1220 * too long for us to wait */
1221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 }
1223 return VOS_STATUS_SUCCESS;
1224}
1225
1226v_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)
1227{
1228
1229 int left = ie_len;
1230 v_U8_t *ptr = ie;
1231 v_U8_t elem_id,elem_len;
1232 v_U8_t eid = 0xDD;
1233
1234 if ( NULL == ie || 0 == ie_len )
1235 return NULL;
1236
1237 while(left >= 2)
1238 {
1239 elem_id = ptr[0];
1240 elem_len = ptr[1];
1241 left -= 2;
1242 if(elem_len > left)
1243 {
1244 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001245 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 eid,elem_len,left);
1247 return NULL;
1248 }
1249 if (elem_id == eid)
1250 {
1251 if(memcmp( &ptr[2], oui, oui_size)==0)
1252 return ptr;
1253 }
1254
1255 left -= elem_len;
1256 ptr += (elem_len + 2);
1257 }
1258 return NULL;
1259}
1260
1261static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1262 union iwreq_data *wrqu, char *extra)
1263{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001264 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 /* Do nothing for now */
1266 return 0;
1267}
1268
1269static int iw_get_name(struct net_device *dev,
1270 struct iw_request_info *info,
1271 char *wrqu, char *extra)
1272{
1273
1274 ENTER();
1275 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1276 EXIT();
1277 return 0;
1278}
1279
1280static int iw_set_mode(struct net_device *dev,
1281 struct iw_request_info *info,
1282 union iwreq_data *wrqu, char *extra)
1283{
1284 hdd_wext_state_t *pWextState;
1285 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1286 tCsrRoamProfile *pRoamProfile;
1287 eCsrRoamBssType LastBSSType;
1288 eMib_dot11DesiredBssType connectedBssType;
1289 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001291
1292 ENTER();
1293
1294 if (NULL == pAdapter)
1295 {
1296 hddLog(VOS_TRACE_LEVEL_WARN,
1297 "%s: Invalid context, pAdapter", __func__);
1298 return 0;
1299 }
1300
1301 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1303 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 return 0;
1305 }
1306
1307 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1308 if (pWextState == NULL)
1309 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301310 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 return -EINVAL;
1312 }
1313
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 pRoamProfile = &pWextState->roamProfile;
1316 LastBSSType = pRoamProfile->BSSType;
1317
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301318 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001319
1320 switch (wrqu->mode)
1321 {
1322 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301323 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1325 // Set the phymode correctly for IBSS.
1326 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1327 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001328 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 break;
1331 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301332 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 break;
1336 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301337 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1339 break;
1340 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301341 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 return -EOPNOTSUPP;
1343 }
1344
1345 if ( LastBSSType != pRoamProfile->BSSType )
1346 {
1347 //the BSS mode changed
1348 // We need to issue disconnect if connected or in IBSS disconnect state
1349 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1350 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1351 {
1352 VOS_STATUS vosStatus;
1353 // need to issue a disconnect to CSR.
1354 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1355 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1356 pAdapter->sessionId,
1357 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1358 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301359 {
1360 long ret;
1361 ret = wait_for_completion_interruptible_timeout(
1362 &pAdapter->disconnect_comp_var,
1363 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1364 if (ret <= 0)
1365 hddLog(VOS_TRACE_LEVEL_ERROR,
1366 FL("failed wait on disconnect_comp_var %ld"), ret);
1367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 }
1369 }
1370
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 EXIT();
1372 return 0;
1373}
1374
1375
1376static int iw_get_mode(struct net_device *dev,
1377 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301378 union iwreq_data *wrqu,
1379 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001380{
1381
1382 hdd_wext_state_t *pWextState;
1383 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1384
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301385 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001386
1387 if (NULL == pAdapter)
1388 {
1389 hddLog(VOS_TRACE_LEVEL_WARN,
1390 "%s: Invalid context, pAdapter", __func__);
1391 return 0;
1392 }
1393
1394 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1396 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 return 0;
1398 }
1399
1400 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1401 if (pWextState == NULL)
1402 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301403 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 return -EINVAL;
1405 }
1406
1407 switch (pWextState->roamProfile.BSSType)
1408 {
1409 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001410 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301411 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 break;
1413 case eCSR_BSS_TYPE_IBSS:
1414 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001415 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301416 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 break;
1418 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001419 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301420 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 break;
1422 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001423 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 break;
1425 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301426
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 return 0;
1428}
1429
1430static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1431 union iwreq_data *wrqu, char *extra)
1432{
1433 v_U32_t numChans = 0;
1434 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1435 v_U32_t indx = 0;
1436 v_U32_t status = 0;
1437
1438 hdd_wext_state_t *pWextState;
1439 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1440 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1441 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1442 tCsrRoamProfile * pRoamProfile;
1443 ENTER();
1444
1445 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1447 return status;
1448 }
1449
1450 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1451
1452 pRoamProfile = &pWextState->roamProfile;
1453
Arif Hussain6d2a3322013-11-17 19:50:10 -08001454 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001455
1456 /* Link is up then return cant set channel*/
1457 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1458 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1459 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001460 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 return -EOPNOTSUPP;
1462 }
1463
1464 /* Settings by Frequency as input */
1465 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1466 (wrqu->freq.m <= (tANI_U32)5.825e8))
1467 {
1468 tANI_U32 freq = wrqu->freq.m / 100000;
1469
1470 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1471 indx++;
1472 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1473 {
1474 return -EINVAL;
1475 }
1476 wrqu->freq.e = 0;
1477 wrqu->freq.m = freq_chan_map[indx].chan;
1478
1479 }
1480
1481 if (wrqu->freq.e == 0)
1482 {
1483 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1484 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1485 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001486 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001487 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1489 return -EINVAL;
1490 }
1491
1492 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1493
1494 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1495 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1497 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 return -EIO;
1499 }
1500
1501 for (indx = 0; indx < numChans; indx++) {
1502 if (wrqu->freq.m == validChan[indx]){
1503 break;
1504 }
1505 }
1506 }
1507 else{
1508
1509 return -EINVAL;
1510 }
1511
1512 if(indx >= numChans)
1513 {
1514 return -EINVAL;
1515 }
1516
1517 /* Set the Operational Channel */
1518 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1519 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1520 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1521
Arif Hussain6d2a3322013-11-17 19:50:10 -08001522 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001523
1524 EXIT();
1525
1526 return status;
1527}
1528
1529static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1530 struct iw_freq *fwrq, char *extra)
1531{
Jeff Johnsone7245742012-09-05 17:12:55 -07001532 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1534 tHalHandle hHal;
1535 hdd_wext_state_t *pWextState;
1536 tCsrRoamProfile * pRoamProfile;
1537 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1538
1539 ENTER();
1540
1541 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1543 return status;
1544 }
1545
1546 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1547 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1548
1549 pRoamProfile = &pWextState->roamProfile;
1550
1551 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1552 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001553 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 {
c_hpothub8245442013-11-20 23:41:09 +05301555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1556 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 return -EIO;
1558 }
1559 else
1560 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001561 status = hdd_wlan_get_freq(channel, &freq);
1562 if( TRUE == status )
1563 {
1564 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1565 * iwlist & iwconfig command shows frequency into proper
1566 * format (2.412 GHz instead of 246.2 MHz)*/
1567 fwrq->m = freq;
1568 fwrq->e = MHZ;
1569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 }
1571 }
1572 else
1573 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001574 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1575 * iwlist & iwconfig command shows frequency into proper
1576 * format (2.412 GHz instead of 246.2 MHz)*/
1577 fwrq->m = 0;
1578 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001580 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581}
1582
1583static int iw_get_tx_power(struct net_device *dev,
1584 struct iw_request_info *info,
1585 union iwreq_data *wrqu, char *extra)
1586{
1587
1588 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1589 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1590 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1591
1592 if (pHddCtx->isLogpInProgress)
1593 {
1594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1595 "%s:LOGP in Progress. Ignore!!!",__func__);
1596 return -EBUSY;
1597 }
1598
1599 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1600 {
1601 wrqu->txpower.value = 0;
1602 return 0;
1603 }
1604 wlan_hdd_get_classAstats(pAdapter);
1605 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1606
1607 return 0;
1608}
1609
1610static int iw_set_tx_power(struct net_device *dev,
1611 struct iw_request_info *info,
1612 union iwreq_data *wrqu, char *extra)
1613{
1614 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1615 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1616
1617 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1618 {
1619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1620 return 0;
1621 }
1622
1623 ENTER();
1624
1625 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1626 {
c_hpothub8245442013-11-20 23:41:09 +05301627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1628 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 return -EIO;
1630 }
1631
1632 EXIT();
1633
1634 return 0;
1635}
1636
1637static int iw_get_bitrate(struct net_device *dev,
1638 struct iw_request_info *info,
1639 union iwreq_data *wrqu, char *extra)
1640{
1641 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1642 eHalStatus status = eHAL_STATUS_SUCCESS;
1643 hdd_wext_state_t *pWextState;
1644 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1645 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1646
1647 ENTER();
1648
1649 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1651 return status;
1652 }
1653
1654 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1655 wrqu->bitrate.value = 0;
1656 }
1657 else {
1658 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1659 SME_SUMMARY_STATS |
1660 SME_GLOBAL_CLASSA_STATS |
1661 SME_GLOBAL_CLASSB_STATS |
1662 SME_GLOBAL_CLASSC_STATS |
1663 SME_GLOBAL_CLASSD_STATS |
1664 SME_PER_STA_STATS,
1665 hdd_StatisticsCB, 0, FALSE,
1666 pHddStaCtx->conn_info.staId[0], pAdapter );
1667
1668 if(eHAL_STATUS_SUCCESS != status)
1669 {
1670 hddLog(VOS_TRACE_LEVEL_ERROR,
1671 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001672 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 return status;
1674 }
1675
1676 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1677
1678 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1679
1680 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1681 {
1682 hddLog(VOS_TRACE_LEVEL_ERROR,
1683 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001684 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 return VOS_STATUS_E_FAILURE;
1686 }
1687
1688 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1689 }
1690
1691 EXIT();
1692
1693 return vos_status;
1694}
1695/* ccm call back function */
1696
1697static int iw_set_bitrate(struct net_device *dev,
1698 struct iw_request_info *info,
1699 union iwreq_data *wrqu,
1700 char *extra)
1701{
1702 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1703 hdd_wext_state_t *pWextState;
1704 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1705 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1706 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1707 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1708 v_U32_t i, rate;
1709 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1710
1711 ENTER();
1712
1713 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1715 return 0;
1716 }
1717
1718 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1719
1720 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1721 {
1722 return -ENXIO ;
1723 }
1724
1725 rate = wrqu->bitrate.value;
1726
1727 if (rate == -1)
1728 {
1729 rate = WNI_CFG_FIXED_RATE_AUTO;
1730 valid_rate = TRUE;
1731 }
1732 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1733 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1734 {
1735 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1736 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1737 {
1738 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1739 WNI_CFG_SUPPORTED_RATES_11A,
1740 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1741 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1742 WNI_CFG_SUPPORTED_RATES_11B,
1743 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1744 {
1745 for (i = 0; i < (b_len + a_len); ++i)
1746 {
1747 /* supported rates returned is double the actual rate so we divide it by 2 */
1748 if ((supp_rates[i]&0x7F)/2 == rate)
1749 {
1750 valid_rate = TRUE;
1751 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1752 break;
1753 }
1754 }
1755 }
1756 }
1757 }
1758 if (valid_rate != TRUE)
1759 {
1760 return -EINVAL;
1761 }
1762 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1763 WNI_CFG_FIXED_RATE, rate,
1764 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1765 {
c_hpothub8245442013-11-20 23:41:09 +05301766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1767 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 return -EIO;
1769 }
1770 return 0;
1771}
1772
1773
1774static int iw_set_genie(struct net_device *dev,
1775 struct iw_request_info *info,
1776 union iwreq_data *wrqu,
1777 char *extra)
1778{
1779 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1780 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001781 u_int8_t *genie = NULL;
1782 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 v_U16_t remLen;
1784
1785 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001786
1787 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1789 "%s:LOGP in Progress. Ignore!!!", __func__);
1790 return 0;
1791 }
1792
1793 if (!wrqu->data.length) {
1794 hdd_clearRoamProfileIe(pAdapter);
1795 EXIT();
1796 return 0;
1797 }
1798
1799 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1800 wrqu->data.length);
1801 if (NULL == base_genie)
1802 {
1803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1804 "mem_alloc_copy_from_user_helper fail");
1805 return -ENOMEM;
1806 }
1807
1808 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001809
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 remLen = wrqu->data.length;
1811
Arif Hussain6d2a3322013-11-17 19:50:10 -08001812 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001813
1814 /* clear any previous genIE before this call */
1815 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1816
1817 while (remLen >= 2)
1818 {
1819 v_U16_t eLen = 0;
1820 v_U8_t elementId;
1821 elementId = *genie++;
1822 eLen = *genie++;
1823 remLen -= 2;
1824
Arif Hussain6d2a3322013-11-17 19:50:10 -08001825 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 __func__, elementId, eLen);
1827
1828 switch ( elementId )
1829 {
1830 case IE_EID_VENDOR:
1831 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001832 {
1833 kfree(base_genie);
1834 return -EINVAL;
1835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001836
1837 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1838 {
1839 v_U16_t curGenIELen = pWextState->genIE.length;
1840 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1841 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1842
1843 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1844 {
1845 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001846 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001848 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 return -ENOMEM;
1850 }
1851 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1852 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1853 pWextState->genIE.length += eLen + 2;
1854 }
1855 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1856 {
1857 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1858 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1859 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1860 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1861 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1862 }
1863 else /* any vendorId except WPA IE should be accumulated to genIE */
1864 {
1865 v_U16_t curGenIELen = pWextState->genIE.length;
1866 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1867 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1868
1869 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1870 {
1871 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001872 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001874 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 return -ENOMEM;
1876 }
1877 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1878 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1879 pWextState->genIE.length += eLen + 2;
1880 }
1881 break;
1882 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001883 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1885 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1886 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1887 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1888 break;
1889
1890 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001891 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001892 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 return 0;
1894 }
1895 genie += eLen;
1896 remLen -= eLen;
1897 }
1898 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001899 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 return 0;
1901}
1902
1903static int iw_get_genie(struct net_device *dev,
1904 struct iw_request_info *info,
1905 union iwreq_data *wrqu,
1906 char *extra)
1907{
1908 hdd_wext_state_t *pWextState;
1909 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1910 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1911 eHalStatus status;
1912 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1913 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1914
1915 ENTER();
1916
1917 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1919 return 0;
1920 }
1921
1922
Arif Hussain6d2a3322013-11-17 19:50:10 -08001923 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001924
1925 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1926
1927 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1928 {
1929 return -ENXIO;
1930 }
1931
1932 // Return something ONLY if we are associated with an RSN or WPA network
1933 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1934 pWextState->roamProfile.negotiatedAuthType))
1935 {
1936 return -ENXIO;
1937 }
1938
1939 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1940 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1941 pAdapter->sessionId,
1942 &length,
1943 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001944 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1945 if (wrqu->data.length < length)
1946 {
1947 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1948 return -EFAULT;
1949 }
Arif Hussain9f05be02014-02-05 12:06:53 -08001950 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001951 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001952
Arif Hussain6d2a3322013-11-17 19:50:10 -08001953 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001954
1955 EXIT();
1956
1957 return 0;
1958}
1959
1960static int iw_get_encode(struct net_device *dev,
1961 struct iw_request_info *info,
1962 struct iw_point *dwrq, char *extra)
1963{
1964 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1965 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1966 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
1967 int keyId;
1968 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
1969 int i;
1970
1971 ENTER();
1972
1973 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1975 return 0;
1976 }
1977
1978 keyId = pRoamProfile->Keys.defaultIndex;
1979
1980 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
1981 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001982 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 return -EINVAL;
1984 }
1985
1986 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
1987 {
1988 dwrq->flags |= IW_ENCODE_ENABLED;
1989 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
1990 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
1991
1992 dwrq->flags |= (keyId + 1);
1993
1994 }
1995 else
1996 {
1997 dwrq->flags |= IW_ENCODE_DISABLED;
1998 }
1999
2000 for(i=0; i < MAX_WEP_KEYS; i++)
2001 {
2002 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2003 {
2004 continue;
2005 }
2006 else
2007 {
2008 break;
2009 }
2010 }
2011
2012 if(MAX_WEP_KEYS == i)
2013 {
2014 dwrq->flags |= IW_ENCODE_NOKEY;
2015 }
2016
2017 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2018
2019 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2020 {
2021 dwrq->flags |= IW_ENCODE_OPEN;
2022 }
2023 else
2024 {
2025 dwrq->flags |= IW_ENCODE_RESTRICTED;
2026 }
2027 EXIT();
2028 return 0;
2029}
2030
2031#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2032#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2033
2034
2035/*
2036 * This function sends a single 'key' to LIM at all time.
2037 */
2038
2039static int iw_get_rts_threshold(struct net_device *dev,
2040 struct iw_request_info *info,
2041 union iwreq_data *wrqu, char *extra)
2042{
2043 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2044 v_U32_t status = 0;
2045
2046 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2047
2048 return status;
2049}
2050
2051static int iw_set_rts_threshold(struct net_device *dev,
2052 struct iw_request_info *info,
2053 union iwreq_data *wrqu, char *extra)
2054{
2055 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2056 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2057
2058 ENTER();
2059
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002060 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2061 {
2062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2063 "%s:LOGP in Progress. Ignore!!!", __func__);
2064 return -EAGAIN;
2065 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2067 {
2068 return -EINVAL;
2069 }
2070
2071 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2072 {
c_hpothub8245442013-11-20 23:41:09 +05302073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2074 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 return -EIO;
2076 }
2077
2078 EXIT();
2079
2080 return 0;
2081}
2082
2083static int iw_get_frag_threshold(struct net_device *dev,
2084 struct iw_request_info *info,
2085 union iwreq_data *wrqu, char *extra)
2086{
2087 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2088 v_U32_t status = 0;
2089
2090 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2091
2092 return status;
2093}
2094
2095static int iw_set_frag_threshold(struct net_device *dev,
2096 struct iw_request_info *info,
2097 union iwreq_data *wrqu, char *extra)
2098{
2099 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2100 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2101
2102 ENTER();
2103
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002104 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2105 {
2106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2107 "%s:LOGP in Progress. Ignore!!!", __func__);
2108 return -EBUSY;
2109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2111 {
2112 return -EINVAL;
2113 }
2114
2115 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2116 {
c_hpothub8245442013-11-20 23:41:09 +05302117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2118 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 return -EIO;
2120 }
2121
2122 EXIT();
2123
2124 return 0;
2125}
2126
2127static int iw_get_power_mode(struct net_device *dev,
2128 struct iw_request_info *info,
2129 union iwreq_data *wrqu, char *extra)
2130{
2131 ENTER();
2132 return -EOPNOTSUPP;
2133}
2134
2135static int iw_set_power_mode(struct net_device *dev,
2136 struct iw_request_info *info,
2137 union iwreq_data *wrqu, char *extra)
2138{
2139 ENTER();
2140 return -EOPNOTSUPP;
2141}
2142
2143static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2144 union iwreq_data *wrqu, char *extra)
2145{
2146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2147 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2148 struct iw_range *range = (struct iw_range *) extra;
2149
2150 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2151
2152 v_U32_t num_channels = sizeof(channels);
2153 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2154 v_U32_t a_len;
2155 v_U32_t b_len;
2156 v_U32_t active_phy_mode = 0;
2157 v_U8_t index = 0, i;
2158
2159 ENTER();
2160
2161 wrqu->data.length = sizeof(struct iw_range);
2162 memset(range, 0, sizeof(struct iw_range));
2163
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002164 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2165 {
2166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2167 "%s:LOGP in Progress. Ignore!!!", __func__);
2168 return -EBUSY;
2169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002170
2171 /*Get the phy mode*/
2172 if (ccmCfgGetInt(hHal,
2173 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2174 {
2175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002176 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002177
2178 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2179 {
2180 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002181 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 if (ccmCfgGetStr(hHal,
2183 WNI_CFG_SUPPORTED_RATES_11A,
2184 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2185 {
2186 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2187 {
2188 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2189 }
2190 for (i = 0; i < a_len; i++)
2191 {
2192 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2193 }
2194 range->num_bitrates = a_len;
2195 }
2196 else
2197 {
2198 return -EIO;
2199 }
2200 }
2201 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2202 {
2203 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002204 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 if (ccmCfgGetStr(hHal,
2206 WNI_CFG_SUPPORTED_RATES_11B,
2207 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2208 {
2209 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2210 {
2211 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2212 }
2213 for (i = 0; i < b_len; i++)
2214 {
2215 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2216 }
2217 range->num_bitrates = b_len;
2218 }
2219 else
2220 {
2221 return -EIO;
2222 }
2223 }
2224 }
2225
2226 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2227 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2228 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2229
2230 range->encoding_size[0] = 5;
2231 range->encoding_size[1] = 13;
2232 range->num_encoding_sizes = 2;
2233 range->max_encoding_tokens = MAX_WEP_KEYS;
2234
2235 // we support through Wireless Extensions 22
2236 range->we_version_compiled = WIRELESS_EXT;
2237 range->we_version_source = 22;
2238
2239 /*Supported Channels and Frequencies*/
2240 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2241 {
c_hpothub8245442013-11-20 23:41:09 +05302242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2243 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 return -EIO;
2245 }
2246 if (num_channels > IW_MAX_FREQUENCIES)
2247 {
2248 num_channels = IW_MAX_FREQUENCIES;
2249 }
2250
2251 range->num_channels = num_channels;
2252 range->num_frequency = num_channels;
2253
2254 for (index=0; index < num_channels; index++)
2255 {
2256 v_U32_t frq_indx = 0;
2257
2258 range->freq[index].i = channels[index];
2259 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2260 {
2261 if(channels[index] == freq_chan_map[frq_indx].chan)
2262 {
2263 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2264 range->freq[index].e = 1;
2265 break;
2266 }
2267 frq_indx++;
2268 }
2269 }
2270
2271 /* Event capability (kernel + driver) */
2272 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2273 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2274 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2275 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2276
2277 /*Encryption capability*/
2278 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2279 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2280
2281 /* Txpower capability */
2282 range->txpower_capa = IW_TXPOW_MWATT;
2283
2284 /*Scanning capability*/
2285 #if WIRELESS_EXT >= 22
2286 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2287 #endif
2288
2289 EXIT();
2290 return 0;
2291}
2292
2293/* Callback function registered with PMC to know status of PMC request */
2294static void iw_power_callback_fn (void *pContext, eHalStatus status)
2295{
2296 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002297
2298 if (NULL == pContext)
2299 {
2300 hddLog(VOS_TRACE_LEVEL_ERROR,
2301 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002302 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 return;
2304 }
2305
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002307
Jeff Johnson72a40512013-12-19 10:14:15 -08002308 /* there is a race condition that exists between this callback
2309 function and the caller since the caller could time out either
2310 before or while this code is executing. we use a spinlock to
2311 serialize these actions */
2312 spin_lock(&hdd_context_lock);
2313
2314 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 {
2316 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002317 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002319 "%s: Invalid context, magic [%08x]",
2320 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002321
2322 if (ioctl_debug)
2323 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002324 pr_info("%s: Invalid context, magic [%08x]\n",
2325 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 }
2327 return;
2328 }
2329
Jeff Johnson72a40512013-12-19 10:14:15 -08002330 /* context is valid so caller is still waiting */
2331
2332 /* paranoia: invalidate the magic */
2333 pStatsContext->magic = 0;
2334
2335 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002337
2338 /* serialization is complete */
2339 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002340}
2341
2342/* Callback function for tx per hit */
2343void hdd_tx_per_hit_cb (void *pCallbackContext)
2344{
2345 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2346 unsigned char tx_fail[16];
2347 union iwreq_data wrqu;
2348
2349 if (NULL == pAdapter)
2350 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002351 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 return;
2353 }
2354 memset(&wrqu, 0, sizeof(wrqu));
2355 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2356 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2357}
2358
2359void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2360{
2361 struct statsContext *pStatsContext;
2362 tCsrGlobalClassAStatsInfo *pClassAStats;
2363 hdd_adapter_t *pAdapter;
2364
2365 if (ioctl_debug)
2366 {
2367 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002368 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 }
2370
2371 if ((NULL == pStats) || (NULL == pContext))
2372 {
2373 hddLog(VOS_TRACE_LEVEL_ERROR,
2374 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002375 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 return;
2377 }
2378
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 pClassAStats = pStats;
2380 pStatsContext = pContext;
2381 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002382
2383 /* there is a race condition that exists between this callback
2384 function and the caller since the caller could time out either
2385 before or while this code is executing. we use a spinlock to
2386 serialize these actions */
2387 spin_lock(&hdd_context_lock);
2388
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2390 {
2391 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002392 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 hddLog(VOS_TRACE_LEVEL_WARN,
2394 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002395 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 if (ioctl_debug)
2397 {
2398 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002399 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 }
2401 return;
2402 }
2403
Jeff Johnson72a40512013-12-19 10:14:15 -08002404 /* context is valid so caller is still waiting */
2405
2406 /* paranoia: invalidate the magic */
2407 pStatsContext->magic = 0;
2408
2409 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2411
Jeff Johnson72a40512013-12-19 10:14:15 -08002412 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002414
2415 /* serialization is complete */
2416 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002417}
2418
2419VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2420{
2421 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2422 eHalStatus hstatus;
2423 long lrc;
2424 struct statsContext context;
2425
2426 if (NULL == pAdapter)
2427 {
2428 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2429 return VOS_STATUS_E_FAULT;
2430 }
2431 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2432 {
2433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2434 return VOS_STATUS_SUCCESS;
2435 }
2436
2437 /* we are connected
2438 prepare our callback context */
2439 init_completion(&context.completion);
2440 context.pAdapter = pAdapter;
2441 context.magic = STATS_CONTEXT_MAGIC;
2442 /* query only for Class A statistics (which include link speed) */
2443 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2444 eCSR_HDD,
2445 SME_GLOBAL_CLASSA_STATS,
2446 hdd_GetClassA_statisticsCB,
2447 0, // not periodic
2448 FALSE, //non-cached results
2449 pHddStaCtx->conn_info.staId[0],
2450 &context);
2451 if (eHAL_STATUS_SUCCESS != hstatus)
2452 {
2453 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002454 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002455 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 /* we'll returned a cached value below */
2457 }
2458 else
2459 {
2460 /* request was sent -- wait for the response */
2461 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2462 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 if (lrc <= 0)
2464 {
2465 hddLog(VOS_TRACE_LEVEL_ERROR,
2466 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002467 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 }
2469 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002470
2471 /* either we never sent a request, we sent a request and received a
2472 response or we sent a request and timed out. if we never sent a
2473 request or if we sent a request and got a response, we want to
2474 clear the magic out of paranoia. if we timed out there is a
2475 race condition such that the callback function could be
2476 executing at the same time we are. of primary concern is if the
2477 callback function had already verified the "magic" but had not
2478 yet set the completion variable when a timeout occurred. we
2479 serialize these activities by invalidating the magic while
2480 holding a shared spinlock which will cause us to block if the
2481 callback is currently executing */
2482 spin_lock(&hdd_context_lock);
2483 context.magic = 0;
2484 spin_unlock(&hdd_context_lock);
2485
2486 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 return VOS_STATUS_SUCCESS;
2488}
2489
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002490static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2491{
2492 struct statsContext *pStatsContext;
2493 tCsrSummaryStatsInfo *pSummaryStats;
2494 tCsrGlobalClassAStatsInfo *pClassAStats;
2495 hdd_adapter_t *pAdapter;
2496
2497 if (ioctl_debug)
2498 {
2499 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002500 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002501 }
2502
2503 if ((NULL == pStats) || (NULL == pContext))
2504 {
2505 hddLog(VOS_TRACE_LEVEL_ERROR,
2506 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002507 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002508 return;
2509 }
2510
Jeff Johnson72a40512013-12-19 10:14:15 -08002511 /* there is a race condition that exists between this callback
2512 function and the caller since the caller could time out either
2513 before or while this code is executing. we use a spinlock to
2514 serialize these actions */
2515 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002516
2517 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2518 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2519 pStatsContext = pContext;
2520 pAdapter = pStatsContext->pAdapter;
2521 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2522 {
2523 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002524 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002525 hddLog(VOS_TRACE_LEVEL_WARN,
2526 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002527 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002528 if (ioctl_debug)
2529 {
2530 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002531 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002532 }
2533 return;
2534 }
2535
Jeff Johnson72a40512013-12-19 10:14:15 -08002536 /* context is valid so caller is still waiting */
2537
2538 /* paranoia: invalidate the magic */
2539 pStatsContext->magic = 0;
2540
2541 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002542 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2543 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2544
Jeff Johnson72a40512013-12-19 10:14:15 -08002545 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002546 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002547
2548 /* serialization is complete */
2549 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002550}
2551
2552VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2553{
2554 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2555 eHalStatus hstatus;
2556 long lrc;
2557 struct statsContext context;
2558
2559 if (NULL == pAdapter)
2560 {
2561 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2562 return VOS_STATUS_SUCCESS;
2563 }
2564
2565 /* we are connected
2566 prepare our callback context */
2567 init_completion(&context.completion);
2568 context.pAdapter = pAdapter;
2569 context.magic = STATS_CONTEXT_MAGIC;
2570
2571 /* query only for Summary & Class A statistics */
2572 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2573 eCSR_HDD,
2574 SME_SUMMARY_STATS |
2575 SME_GLOBAL_CLASSA_STATS,
2576 hdd_get_station_statisticsCB,
2577 0, // not periodic
2578 FALSE, //non-cached results
2579 pHddStaCtx->conn_info.staId[0],
2580 &context);
2581 if (eHAL_STATUS_SUCCESS != hstatus)
2582 {
2583 hddLog(VOS_TRACE_LEVEL_ERROR,
2584 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002585 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002586 /* we'll return with cached values */
2587 }
2588 else
2589 {
2590 /* request was sent -- wait for the response */
2591 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2592 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002593
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002594 if (lrc <= 0)
2595 {
2596 hddLog(VOS_TRACE_LEVEL_ERROR,
2597 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002598 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002599 }
2600 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002601
2602 /* either we never sent a request, we sent a request and received a
2603 response or we sent a request and timed out. if we never sent a
2604 request or if we sent a request and got a response, we want to
2605 clear the magic out of paranoia. if we timed out there is a
2606 race condition such that the callback function could be
2607 executing at the same time we are. of primary concern is if the
2608 callback function had already verified the "magic" but had not
2609 yet set the completion variable when a timeout occurred. we
2610 serialize these activities by invalidating the magic while
2611 holding a shared spinlock which will cause us to block if the
2612 callback is currently executing */
2613 spin_lock(&hdd_context_lock);
2614 context.magic = 0;
2615 spin_unlock(&hdd_context_lock);
2616
2617 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002618 return VOS_STATUS_SUCCESS;
2619}
2620
2621
Jeff Johnson295189b2012-06-20 16:38:30 -07002622/*
2623 * Support for the LINKSPEED private command
2624 * Per the WiFi framework the response must be of the form
2625 * "LinkSpeed xx"
2626 */
2627static int iw_get_linkspeed(struct net_device *dev,
2628 struct iw_request_info *info,
2629 union iwreq_data *wrqu, char *extra)
2630{
2631 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302632 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302634 int len = sizeof(v_U32_t) + 1;
2635 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302637 VOS_STATUS status;
2638 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002639
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302640 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2641
2642 valid = wlan_hdd_validate_context(pHddCtx);
2643
2644 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002645 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302646 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2647 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002648 }
2649
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2651 {
2652 /* we are not connected so we don't have a classAstats */
2653 link_speed = 0;
2654 }
2655 else
2656 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302657 status = wlan_hdd_get_classAstats(pAdapter);
2658
2659 if (!VOS_IS_STATUS_SUCCESS(status ))
2660 {
2661 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2662 return -EINVAL;
2663 }
2664
2665 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2666 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2667 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2668 &link_speed);
2669
2670 link_speed = link_speed / 10;
2671
2672 if (0 == link_speed)
2673 {
2674 /* The linkspeed returned by HAL is in units of 500kbps.
2675 * converting it to mbps.
2676 * This is required to support legacy firmware which does
2677 * not return link capacity.
2678 */
2679 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2680 }
2681
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 }
2683
2684 wrqu->data.length = len;
2685 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002686 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 if ((rc < 0) || (rc >= len))
2688 {
2689 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302690 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 return -EIO;
2692 }
2693
2694 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002695 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002696}
2697
2698
2699/*
2700 * Support for the RSSI & RSSI-APPROX private commands
2701 * Per the WiFi framework the response must be of the form
2702 * "<ssid> rssi <xx>"
2703 * unless we are not associated, in which case the response is
2704 * "OK"
2705 */
2706static int iw_get_rssi(struct net_device *dev,
2707 struct iw_request_info *info,
2708 union iwreq_data *wrqu, char *extra)
2709{
2710 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002711 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 int len = wrqu->data.length;
2713 v_S7_t s7Rssi = 0;
2714 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2715 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2716 VOS_STATUS vosStatus;
2717 int rc;
2718
2719 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2720 (0 == ssidlen) || (ssidlen >= len))
2721 {
2722 /* we are not connected or our SSID is too long
2723 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002724 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 }
2726 else
2727 {
2728 /* we are connected with a valid SSID
2729 so we can write the SSID into the return buffer
2730 (note that it is not NUL-terminated) */
2731 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2732
2733 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2734
2735 if (VOS_STATUS_SUCCESS == vosStatus)
2736 {
2737 /* append the rssi to the ssid in the format required by
2738 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002739 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302740 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 }
2742 else
2743 {
2744 rc = -1;
2745 }
2746 }
2747
2748 /* verify that we wrote a valid response */
2749 if ((rc < 0) || (rc >= len))
2750 {
2751 // encoding or length error?
2752 hddLog(VOS_TRACE_LEVEL_ERROR,
2753 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002754 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 return -EIO;
2756 }
2757
2758 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002759 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002760}
2761
2762/*
2763 * Support for SoftAP channel range private command
2764 */
2765static int iw_softap_set_channel_range( struct net_device *dev,
2766 int startChannel,
2767 int endChannel,
2768 int band)
2769{
Jeff Johnson43971f52012-07-17 12:26:56 -07002770 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 int ret = 0;
2772 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2773 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002774 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2775
Jeff Johnson295189b2012-06-20 16:38:30 -07002776
2777 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2778 if (VOS_STATUS_SUCCESS != status)
2779 {
2780 ret = -EINVAL;
2781 }
Yathish9f22e662012-12-10 14:21:35 -08002782 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 return ret;
2784}
2785
2786VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2787{
2788 struct statsContext context;
2789 eHalStatus status;
2790 hdd_context_t *pHddCtx;
2791
2792 if (NULL == pAdapter)
2793 {
2794 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2795 return VOS_STATUS_E_FAULT;
2796 }
2797
2798 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2799 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2800 init_completion(&context.completion);
2801
2802 context.pAdapter = pAdapter;
2803 context.magic = POWER_CONTEXT_MAGIC;
2804
2805 if (DRIVER_POWER_MODE_ACTIVE == mode)
2806 {
2807 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2808 "Full Power", __func__);
2809 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2810 iw_power_callback_fn, &context,
2811 eSME_FULL_PWR_NEEDED_BY_HDD);
2812 // Enter Full power command received from GUI this means we are disconnected
2813 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2814 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2815 if (eHAL_STATUS_PMC_PENDING == status)
2816 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002817 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 int lrc = wait_for_completion_interruptible_timeout(
2819 &context.completion,
2820 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002821
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 if (lrc <= 0)
2823 {
2824 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002825 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 }
2827 }
2828 }
2829 else if (DRIVER_POWER_MODE_AUTO == mode)
2830 {
2831 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2832 {
2833 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2834 __func__);
2835 // Enter BMPS command received from GUI this means DHCP is completed
2836 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2837 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2838 FALSE);
2839 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2840 iw_power_callback_fn, &context);
2841 if (eHAL_STATUS_PMC_PENDING == status)
2842 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002843 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 int lrc = wait_for_completion_interruptible_timeout(
2845 &context.completion,
2846 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 if (lrc <= 0)
2848 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002849 hddLog(VOS_TRACE_LEVEL_ERROR,
2850 "%s: SME %s while requesting BMPS",
2851 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 }
2853 }
2854 }
2855 else
2856 {
2857 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2858 "enabled in the cfg");
2859 }
2860 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002861
2862 /* either we never sent a request, we sent a request and received a
2863 response or we sent a request and timed out. if we never sent a
2864 request or if we sent a request and got a response, we want to
2865 clear the magic out of paranoia. if we timed out there is a
2866 race condition such that the callback function could be
2867 executing at the same time we are. of primary concern is if the
2868 callback function had already verified the "magic" but had not
2869 yet set the completion variable when a timeout occurred. we
2870 serialize these activities by invalidating the magic while
2871 holding a shared spinlock which will cause us to block if the
2872 callback is currently executing */
2873 spin_lock(&hdd_context_lock);
2874 context.magic = 0;
2875 spin_unlock(&hdd_context_lock);
2876
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 return VOS_STATUS_SUCCESS;
2878}
2879
2880VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2881 hdd_adapter_t *pAdapter)
2882{
2883 VOS_STATUS vos_Status;
2884
2885 if ((NULL == pAdapter) || (NULL == pHddCtx))
2886 {
2887 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2888 return VOS_STATUS_E_FAULT;
2889 }
2890
2891 /**Exit from Deep sleep or standby if we get the driver
2892 START cmd from android GUI
2893 */
2894 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2895 {
2896 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2897 "from Stand by",__func__);
2898 vos_Status = hdd_exit_standby(pHddCtx);
2899 }
2900 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2901 {
2902 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2903 "from deep sleep",__func__);
2904 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2905 }
2906 else
2907 {
2908 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2909 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2910 vos_Status = VOS_STATUS_SUCCESS;
2911 }
2912
2913 return vos_Status;
2914}
2915
2916VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2917{
2918 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2919
2920 if (NULL == pHddCtx)
2921 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302922 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 return VOS_STATUS_E_FAULT;
2924 }
2925
2926 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2927 {
2928 //Execute standby procedure.
2929 //Executing standby procedure will cause the STA to
2930 //disassociate first and then the chip will be put into standby.
2931 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2932 vos_Status = hdd_enter_standby(pHddCtx);
2933 }
2934 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
2935 pHddCtx->cfg_ini->nEnableDriverStop)
2936 {
2937 //Execute deep sleep procedure
2938 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002939 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 //Deep sleep not supported
2941 vos_Status = hdd_enter_standby(pHddCtx);
2942 }
2943 else
2944 {
2945 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
2946 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
2947 vos_Status = VOS_STATUS_SUCCESS;
2948 }
2949
2950 return vos_Status;
2951}
2952
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002953
2954void* wlan_hdd_change_country_code_callback(void *pAdapter)
2955{
2956
2957 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002958 complete(&call_back_pAdapter->change_country_code);
2959
2960 return NULL;
2961}
2962
Jeff Johnson295189b2012-06-20 16:38:30 -07002963static int iw_set_priv(struct net_device *dev,
2964 struct iw_request_info *info,
2965 union iwreq_data *wrqu, char *extra)
2966{
2967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08002968 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 int cmd_len = wrqu->data.length;
2970 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08002971 int rc = 0;
2972 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2973
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2975
2976 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08002977 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2978 wrqu->data.length);
2979 if (NULL == cmd)
2980 {
2981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2982 "mem_alloc_copy_from_user_helper fail");
2983 return -ENOMEM;
2984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002985
2986 if (ioctl_debug)
2987 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002988 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 }
2990
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002991 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2992 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002993
2994 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08002995 if (ioctl_debug)
2996 {
2997 pr_info("%s: RESTART in progress\n", __func__);
2998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002999
Arif Hussain24bfa702014-01-22 13:51:30 -08003000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003002 kfree(cmd);
3003 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 }
3005
Arif Hussain24bfa702014-01-22 13:51:30 -08003006 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003008 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3010 "%s: Error in iw_set_scan!", __func__);
3011 rc = -EINVAL;
3012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003013 }
3014 else if( strcasecmp(cmd, "start") == 0 ) {
3015
Arif Hussain6d2a3322013-11-17 19:50:10 -08003016 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003018
Arif Hussain24bfa702014-01-22 13:51:30 -08003019 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3020 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 {
3022 union iwreq_data wrqu;
3023 char buf[10];
3024
3025 memset(&wrqu, 0, sizeof(wrqu));
3026 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3027 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3028 }
3029 else
3030 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003031 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3032 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 }
3034 goto done;
3035 }
3036 else if( strcasecmp(cmd, "stop") == 0 )
3037 {
3038 union iwreq_data wrqu;
3039 char buf[10];
3040
Arif Hussain6d2a3322013-11-17 19:50:10 -08003041 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003042
3043 wlan_hdd_enter_lowpower(pHddCtx);
3044 memset(&wrqu, 0, sizeof(wrqu));
3045 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3046 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 goto done;
3048 }
3049 else if (strcasecmp(cmd, "macaddr") == 0)
3050 {
3051 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3052 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3053 }
3054 else if (strcasecmp(cmd, "scan-active") == 0)
3055 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003056 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 ret = snprintf(cmd, cmd_len, "OK");
3058 }
3059 else if (strcasecmp(cmd, "scan-passive") == 0)
3060 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003061 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 ret = snprintf(cmd, cmd_len, "OK");
3063 }
3064 else if( strcasecmp(cmd, "scan-mode") == 0 )
3065 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003066 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 }
3068 else if( strcasecmp(cmd, "linkspeed") == 0 )
3069 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003070 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 }
3072 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3073 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003074 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003075 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003076
3077 country_code = cmd + 8;
3078
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003079 init_completion(&pAdapter->change_country_code);
3080
Arif Hussain24bfa702014-01-22 13:51:30 -08003081 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003082 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 country_code,
3084 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303085 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303086 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303087 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003088
3089 /* Wait for completion */
3090 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3091 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3092
3093 if (lrc <= 0)
3094 {
3095 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003096 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003097 }
3098
Arif Hussain24bfa702014-01-22 13:51:30 -08003099 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003101 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003102 "%s: SME Change Country code fail", __func__);
3103 kfree(cmd);
3104 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 }
3106 }
3107 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3108 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003109 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 }
3111 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3112 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003113 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003114
Wilson Yang1be3e652013-10-09 15:18:31 -07003115 if (9 < cmd_len)
3116 {
3117 ptr = (char*)(cmd + 9);
3118
3119 }else{
3120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3121 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003122 kfree(cmd);
3123 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003124 }
3125
3126 if (1 != sscanf(ptr,"%d",&mode))
3127 {
3128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3129 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003130 kfree(cmd);
3131 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003132 }
3133
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 wlan_hdd_enter_bmps(pAdapter, mode);
3135 /*TODO:Set the power mode*/
3136 }
3137 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3138 v_U32_t pmc_state;
3139 v_U16_t value;
3140
3141 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3142 if(pmc_state == BMPS) {
3143 value = DRIVER_POWER_MODE_AUTO;
3144 }
3145 else {
3146 value = DRIVER_POWER_MODE_ACTIVE;
3147 }
3148 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3149 }
3150 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003151 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 /*TODO: set the btcoexmode*/
3153 }
3154 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3155
Arif Hussain6d2a3322013-11-17 19:50:10 -08003156 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 /*TODO: Return the btcoex status*/
3158 }
3159 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3160
Arif Hussain6d2a3322013-11-17 19:50:10 -08003161 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003162
3163 /*TODO: Enable Rx data Filter*/
3164 }
3165 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3166
Arif Hussain6d2a3322013-11-17 19:50:10 -08003167 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003168
3169 /*TODO: Disable Rx data Filter*/
3170 }
3171 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3172
Arif Hussain6d2a3322013-11-17 19:50:10 -08003173 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 /*TODO: rxfilter-statistics*/
3175 }
3176 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3177
Arif Hussain6d2a3322013-11-17 19:50:10 -08003178 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 /*TODO: rxfilter-add*/
3180 }
3181 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3182
Arif Hussain6d2a3322013-11-17 19:50:10 -08003183 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 /*TODO: rxfilter-remove*/
3185 }
3186#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003187 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3188 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3189 /*TODO: support pnosetup*/
3190 }
3191 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3192 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3193 /*TODO: support pnoforce*/
3194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3196
Arif Hussain6d2a3322013-11-17 19:50:10 -08003197 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003198 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3199 kfree(cmd);
3200 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 }
3202 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003203 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003204 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3205 kfree(cmd);
3206 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 }
3208#endif /*FEATURE_WLAN_SCAN_PNO*/
3209 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003210 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003211 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3212 kfree(cmd);
3213 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 }
3215 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3216 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003217 char *ptr;
3218
3219 if (18 < cmd_len)
3220 {
3221 ptr = (char*)(cmd + 18);
3222 }else{
3223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3224 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003225 kfree(cmd);
3226 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003227 }
3228
Jeff Johnson02797792013-10-26 19:17:13 -07003229 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003230 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3231 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3232 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3233 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3234 {
3235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3236 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003237 kfree(cmd);
3238 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003240
3241 // parameters checking
3242 // period has to be larger than 0
3243 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3244 {
3245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003246 kfree(cmd);
3247 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 }
3249
3250 // use default value 5 is the input is not reasonable. in unit of 10%
3251 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3252 {
3253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3254 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3255 }
3256
3257 // default is 5
3258 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3259 {
3260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3261 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3262 }
3263
Arif Hussain24bfa702014-01-22 13:51:30 -08003264 if (eHAL_STATUS_SUCCESS !=
3265 sme_SetTxPerTracking(pHddCtx->hHal,
3266 hdd_tx_per_hit_cb,
3267 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003269 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 }
3271 }
3272 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003273 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3274 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 }
3276done:
3277 /* many of the commands write information back into the command
3278 string using snprintf(). check the return value here in one
3279 place */
3280 if ((ret < 0) || (ret >= cmd_len))
3281 {
3282 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003283 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003285 else if (ret > 0)
3286 {
3287 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3288 {
3289 hddLog(VOS_TRACE_LEVEL_ERROR,
3290 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003291 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003292 return -EFAULT;
3293 }
3294 wrqu->data.length = ret;
3295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003296
3297 if (ioctl_debug)
3298 {
3299 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003300 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003302 kfree(cmd);
3303 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003304}
3305
3306static int iw_set_nick(struct net_device *dev,
3307 struct iw_request_info *info,
3308 union iwreq_data *wrqu, char *extra)
3309{
3310 ENTER();
3311 return 0;
3312}
3313
3314static int iw_get_nick(struct net_device *dev,
3315 struct iw_request_info *info,
3316 union iwreq_data *wrqu, char *extra)
3317{
3318 ENTER();
3319 return 0;
3320}
3321
3322static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3323{
3324 ENTER();
3325 return NULL;
3326}
3327
3328static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3329 union iwreq_data *wrqu,char *extra)
3330
3331{
3332 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3333 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3334 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3335 struct iw_point *encoderq = &(wrqu->encoding);
3336 v_U32_t keyId;
3337 v_U8_t key_length;
3338 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3339 v_BOOL_t fKeyPresent = 0;
3340 int i;
3341 eHalStatus status = eHAL_STATUS_SUCCESS;
3342
3343
3344 ENTER();
3345
3346 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3347 {
3348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3349 "%s:LOGP in Progress. Ignore!!!",__func__);
3350 return 0;
3351 }
3352
3353
3354 keyId = encoderq->flags & IW_ENCODE_INDEX;
3355
3356 if(keyId)
3357 {
3358 if(keyId > MAX_WEP_KEYS)
3359 {
3360 return -EINVAL;
3361 }
3362
3363 fKeyPresent = 1;
3364 keyId--;
3365 }
3366 else
3367 {
3368 fKeyPresent = 0;
3369 }
3370
3371
3372 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3373 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 if(!fKeyPresent) {
3376
3377 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3378
3379 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3380 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3381 }
3382 }
3383 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3384 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3385 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3386 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3387
3388 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3389 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3390
3391 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3392 {
3393 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3394 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003395 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303396 {
3397 long ret;
3398 ret = wait_for_completion_interruptible_timeout(
3399 &pAdapter->disconnect_comp_var,
3400 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3401 if (ret <= 0)
3402 hddLog(VOS_TRACE_LEVEL_ERROR,
3403 FL("failed wait on disconnect_comp_var %ld"), ret);
3404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 }
3406
3407 return status;
3408
3409 }
3410
3411 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3412 {
3413 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3414
3415 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3416
3417 }
3418
3419
3420 if(wrqu->data.length > 0)
3421 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003422 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003423
3424 key_length = wrqu->data.length;
3425
3426 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3427
3428 if(5 == key_length)
3429 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003430 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003431
3432 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3433 {
3434 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3435 }
3436 else
3437 {
3438 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3439 }
3440 }
3441 else if(13 == key_length)
3442 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003443 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003444
3445 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3446 {
3447 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3448 }
3449 else
3450 {
3451 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3452 }
3453 }
3454 else
3455 {
3456 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003457 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 return -EINVAL;
3459 }
3460
3461 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3462 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3463 pWextState->roamProfile.EncryptionType.numEntries = 1;
3464 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3465 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3466 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3467
3468 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3469 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3470 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3471 {
3472
3473 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3474
3475 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3476 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3477
3478 return status;
3479 }
3480 }
3481
3482 return 0;
3483}
3484
3485static int iw_get_encodeext(struct net_device *dev,
3486 struct iw_request_info *info,
3487 struct iw_point *dwrq,
3488 char *extra)
3489{
3490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3491 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3492 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3493 int keyId;
3494 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3495 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3496 int i;
3497
3498 ENTER();
3499
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003500 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3501 {
3502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3503 "%s:LOGP in Progress. Ignore!!!", __func__);
3504 return -EBUSY;
3505 }
3506
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 keyId = pRoamProfile->Keys.defaultIndex;
3508
3509 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3510 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003511 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 return -EINVAL;
3513 }
3514
3515 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3516 {
3517 dwrq->flags |= IW_ENCODE_ENABLED;
3518 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303519 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3520 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522 else
3523 {
3524 dwrq->flags |= IW_ENCODE_DISABLED;
3525 }
3526
3527 for(i=0; i < MAX_WEP_KEYS; i++)
3528 {
3529 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3530 {
3531 continue;
3532 }
3533 else
3534 {
3535 break;
3536 }
3537 }
3538
3539 if(MAX_WEP_KEYS == i)
3540 {
3541 dwrq->flags |= IW_ENCODE_NOKEY;
3542 }
3543 else
3544 {
3545 dwrq->flags |= IW_ENCODE_ENABLED;
3546 }
3547
3548 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3549
3550 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3551 {
3552 dwrq->flags |= IW_ENCODE_DISABLED;
3553 }
3554
3555 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3556
3557 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3558 {
3559 dwrq->flags |= IW_ENCODE_OPEN;
3560 }
3561 else
3562 {
3563 dwrq->flags |= IW_ENCODE_RESTRICTED;
3564 }
3565 EXIT();
3566 return 0;
3567
3568}
3569
3570static int iw_set_encodeext(struct net_device *dev,
3571 struct iw_request_info *info,
3572 union iwreq_data *wrqu, char *extra)
3573{
3574 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3575 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3576 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3577 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3578
3579 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3580 v_U32_t status = 0;
3581
3582 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3583
3584 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3585
3586 int key_index;
3587 struct iw_point *encoding = &wrqu->encoding;
3588 tCsrRoamSetKey setKey;
3589 v_U32_t roamId= 0xFF;
3590 VOS_STATUS vos_status;
3591
3592 ENTER();
3593
3594 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3595 {
3596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3597 "%s:LOGP in Progress. Ignore!!!",__func__);
3598 return 0;
3599 }
3600
3601 key_index = encoding->flags & IW_ENCODE_INDEX;
3602
3603 if(key_index > 0) {
3604
3605 /*Convert from 1-based to 0-based keying*/
3606 key_index--;
3607 }
3608 if(!ext->key_len) {
3609
3610 /*Set the encrytion type to NONE*/
3611 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3612 return status;
3613 }
3614
3615 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3616 (IW_ENCODE_ALG_WEP == ext->alg))
3617 {
3618 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3619
Agarwal Ashish971c2882013-10-30 20:11:12 +05303620 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3621 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 return -EINVAL;
3623 }
3624 else {
3625 /*Static wep, update the roam profile with the keys */
3626 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3627 key_index < CSR_MAX_NUM_KEY) {
3628 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3629 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3630
3631 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3632 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3633
3634 }
3635 }
3636 return status;
3637 }
3638
3639 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3640
3641 setKey.keyId = key_index;
3642 setKey.keyLength = ext->key_len;
3643
3644 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3645 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3646 }
3647
3648 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3649 /*Key direction for group is RX only*/
3650 setKey.keyDirection = eSIR_RX_ONLY;
3651 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3652 }
3653 else {
3654
3655 setKey.keyDirection = eSIR_TX_RX;
3656 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3657 }
3658
3659 /*For supplicant pae role is zero*/
3660 setKey.paeRole = 0;
3661
3662 switch(ext->alg)
3663 {
3664 case IW_ENCODE_ALG_NONE:
3665 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3666 break;
3667
3668 case IW_ENCODE_ALG_WEP:
3669 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3670 break;
3671
3672 case IW_ENCODE_ALG_TKIP:
3673 {
3674 v_U8_t *pKey = &setKey.Key[0];
3675
3676 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3677
3678 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3679
3680 /*Supplicant sends the 32bytes key in this order
3681
3682 |--------------|----------|----------|
3683 | Tk1 |TX-MIC | RX Mic |
3684 |--------------|----------|----------|
3685 <---16bytes---><--8bytes--><--8bytes-->
3686
3687 */
3688 /*Sme expects the 32 bytes key to be in the below order
3689
3690 |--------------|----------|----------|
3691 | Tk1 |RX-MIC | TX Mic |
3692 |--------------|----------|----------|
3693 <---16bytes---><--8bytes--><--8bytes-->
3694 */
3695 /* Copy the Temporal Key 1 (TK1) */
3696 vos_mem_copy(pKey,ext->key,16);
3697
3698 /*Copy the rx mic first*/
3699 vos_mem_copy(&pKey[16],&ext->key[24],8);
3700
3701 /*Copy the tx mic */
3702 vos_mem_copy(&pKey[24],&ext->key[16],8);
3703
3704 }
3705 break;
3706
3707 case IW_ENCODE_ALG_CCMP:
3708 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3709 break;
3710
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003711#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003712#define IW_ENCODE_ALG_KRK 6
3713 case IW_ENCODE_ALG_KRK:
3714 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3715 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003716#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003717
3718 default:
3719 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3720 break;
3721 }
3722
3723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003724 ("%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 -07003725
3726#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303727 /* The supplicant may attempt to set the PTK once pre-authentication
3728 is done. Save the key in the UMAC and include it in the ADD
3729 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303731 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303733 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3734 "%s: Update PreAuth Key success", __func__);
3735 return 0;
3736 }
3737 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3738 {
3739 hddLog(VOS_TRACE_LEVEL_ERROR,
3740 "%s: Update PreAuth Key failed", __func__);
3741 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 }
3743#endif /* WLAN_FEATURE_VOWIFI_11R */
3744
3745 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3746
3747 vos_status = wlan_hdd_check_ula_done(pAdapter);
3748 if ( vos_status != VOS_STATUS_SUCCESS )
3749 {
3750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3751 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3752 __LINE__, vos_status );
3753
3754 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3755 }
3756
3757 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3758
3759 if ( halStatus != eHAL_STATUS_SUCCESS )
3760 {
3761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3762 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3763 __LINE__, halStatus );
3764
3765 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3766 }
3767
3768 return halStatus;
3769}
3770
3771static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3772 union iwreq_data *wrqu, char *extra)
3773{
3774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3775 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3776
3777 ENTER();
3778
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003779 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3780 {
3781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3782 "%s:LOGP in Progress. Ignore!!!", __func__);
3783 return -EBUSY;
3784 }
3785
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3787 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3788
Arif Hussain6d2a3322013-11-17 19:50:10 -08003789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003790
3791 return -EINVAL;
3792 }
3793
3794 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3795
3796 if((wrqu->retry.flags & IW_RETRY_LONG))
3797 {
3798 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3799 {
c_hpothub8245442013-11-20 23:41:09 +05303800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3801 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 return -EIO;
3803 }
3804 }
3805 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3806 {
3807 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3808 {
c_hpothub8245442013-11-20 23:41:09 +05303809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3810 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 return -EIO;
3812 }
3813 }
3814 }
3815 else
3816 {
3817 return -EOPNOTSUPP;
3818 }
3819
Arif Hussain6d2a3322013-11-17 19:50:10 -08003820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003821
3822 EXIT();
3823
3824 return 0;
3825
3826}
3827
3828static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3829 union iwreq_data *wrqu, char *extra)
3830{
3831 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3832 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3833 v_U32_t retry = 0;
3834
3835 ENTER();
3836
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003837 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3838 {
3839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3840 "%s:LOGP in Progress. Ignore!!!", __func__);
3841 return -EBUSY;
3842 }
3843
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 if((wrqu->retry.flags & IW_RETRY_LONG))
3845 {
3846 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3847
3848 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3849 {
c_hpothub8245442013-11-20 23:41:09 +05303850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3851 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 return -EIO;
3853 }
3854
3855 wrqu->retry.value = retry;
3856 }
3857 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3858 {
3859 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3860
3861 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3862 {
c_hpothub8245442013-11-20 23:41:09 +05303863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3864 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 return -EIO;
3866 }
3867
3868 wrqu->retry.value = retry;
3869 }
3870 else {
3871 return -EOPNOTSUPP;
3872 }
3873
Arif Hussain6d2a3322013-11-17 19:50:10 -08003874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003875
3876 EXIT();
3877
3878 return 0;
3879}
3880
3881static int iw_set_mlme(struct net_device *dev,
3882 struct iw_request_info *info,
3883 union iwreq_data *wrqu,
3884 char *extra)
3885{
3886 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3887 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3888 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3889 eHalStatus status = eHAL_STATUS_SUCCESS;
3890
3891 ENTER();
3892
3893 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3894 {
3895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3896 "%s:LOGP in Progress. Ignore!!!",__func__);
3897 return 0;
3898 }
3899
3900 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3901 switch (mlme->cmd) {
3902 case IW_MLME_DISASSOC:
3903 case IW_MLME_DEAUTH:
3904
3905 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3906 {
3907 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3908
3909 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3910 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3911
3912 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3913 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3914
Jeff Johnson43971f52012-07-17 12:26:56 -07003915 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303916 {
3917 long ret;
3918 ret = wait_for_completion_interruptible_timeout(
3919 &pAdapter->disconnect_comp_var,
3920 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3921 if (ret <= 0)
3922 hddLog(VOS_TRACE_LEVEL_ERROR,
3923 FL("failed wait on disconnect_comp_var %ld"), ret);
3924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003926 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003927 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003928
3929 /* Resetting authKeyMgmt */
3930 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
3931
3932 netif_tx_disable(dev);
3933 netif_carrier_off(dev);
3934
3935 }
3936 else
3937 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003938 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 -07003939 }
3940 break;
3941 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003942 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 return -EINVAL;
3944 }//end of switch
3945
3946 EXIT();
3947
3948 return status;
3949
3950}
3951
3952/* set param sub-ioctls */
3953static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
3954 union iwreq_data *wrqu, char *extra)
3955{
3956 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3957 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3958 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3959 int *value = (int *)extra;
3960 int sub_cmd = value[0];
3961 int set_value = value[1];
3962 int ret = 0; /* success */
3963 int enable_pbm, enable_mp;
3964#ifdef CONFIG_HAS_EARLYSUSPEND
3965 v_U8_t nEnableSuspendOld;
3966#endif
3967 INIT_COMPLETION(pWextState->completion_var);
3968
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003969 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3970 {
3971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3972 "%s:LOGP in Progress. Ignore!!!", __func__);
3973 return -EBUSY;
3974 }
3975
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 switch(sub_cmd)
3977 {
3978 case WE_SET_11D_STATE:
3979 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003980 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07003981 memset(&smeConfig, 0x00, sizeof(smeConfig));
3982
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
3984
3985 sme_GetConfigParam(hHal,&smeConfig);
3986 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
3987
Arif Hussain6d2a3322013-11-17 19:50:10 -08003988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07003989
3990 sme_UpdateConfig(hHal,&smeConfig);
3991 }
3992 else {
3993 return -EINVAL;
3994 }
3995 break;
3996 }
3997
3998 case WE_WOWL:
3999 {
4000 switch (set_value)
4001 {
4002 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004003 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 break;
4005 case 0x01:
4006 case 0x02:
4007 case 0x03:
4008 enable_mp = (set_value & 0x01) ? 1 : 0;
4009 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004010 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4012 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4013 break;
4014 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004015 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 ret = -EINVAL;
4017 break;
4018 }
4019
4020 break;
4021 }
4022 case WE_SET_POWER:
4023 {
4024 switch (set_value)
4025 {
4026 case 0: //Full Power
4027 {
4028 struct statsContext context;
4029 eHalStatus status;
4030
4031 init_completion(&context.completion);
4032
4033 context.pAdapter = pAdapter;
4034 context.magic = POWER_CONTEXT_MAGIC;
4035
4036 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4037 iw_power_callback_fn, &context,
4038 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004039 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 {
4041 int lrc = wait_for_completion_interruptible_timeout(
4042 &context.completion,
4043 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004044
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 if (lrc <= 0)
4046 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004047 hddLog(VOS_TRACE_LEVEL_ERROR,
4048 "%s: SME %s while requesting fullpower",
4049 __func__, (0 == lrc) ?
4050 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 }
4052 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004053 /* either we have a response or we timed out. if we timed
4054 out there is a race condition such that the callback
4055 function could be executing at the same time we are. of
4056 primary concern is if the callback function had already
4057 verified the "magic" but had not yet set the completion
4058 variable when a timeout occurred. we serialize these
4059 activities by invalidating the magic while holding a
4060 shared spinlock which will cause us to block if the
4061 callback is currently executing */
4062 spin_lock(&hdd_context_lock);
4063 context.magic = 0;
4064 spin_unlock(&hdd_context_lock);
4065
Arif Hussain6d2a3322013-11-17 19:50:10 -08004066 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 break;
4068 }
4069 case 1: //Enable BMPS
4070 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4071 break;
4072 case 2: //Disable BMPS
4073 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4074 break;
4075 case 3: //Request Bmps
4076 {
4077 struct statsContext context;
4078 eHalStatus status;
4079
4080 init_completion(&context.completion);
4081
4082 context.pAdapter = pAdapter;
4083 context.magic = POWER_CONTEXT_MAGIC;
4084
4085 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4086 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004087 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 {
4089 int lrc = wait_for_completion_interruptible_timeout(
4090 &context.completion,
4091 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 if (lrc <= 0)
4093 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004094 hddLog(VOS_TRACE_LEVEL_ERROR,
4095 "%s: SME %s while requesting BMPS",
4096 __func__, (0 == lrc) ? "timeout" :
4097 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 }
4099 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004100 /* either we have a response or we timed out. if we
4101 timed out there is a race condition such that the
4102 callback function could be executing at the same
4103 time we are. of primary concern is if the callback
4104 function had already verified the "magic" but had
4105 not yet set the completion variable when a timeout
4106 occurred. we serialize these activities by
4107 invalidating the magic while holding a shared
4108 spinlock which will cause us to block if the
4109 callback is currently executing */
4110 spin_lock(&hdd_context_lock);
4111 context.magic = 0;
4112 spin_unlock(&hdd_context_lock);
4113
Arif Hussain6d2a3322013-11-17 19:50:10 -08004114 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 break;
4116 }
4117 case 4: //Enable IMPS
4118 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4119 break;
4120 case 5: //Disable IMPS
4121 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4122 break;
4123 case 6: //Enable Standby
4124 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4125 break;
4126 case 7: //Disable Standby
4127 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4128 break;
4129 case 8: //Request Standby
4130#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004131#endif
4132 break;
4133 case 9: //Start Auto Bmps Timer
4134 sme_StartAutoBmpsTimer(hHal);
4135 break;
4136 case 10://Stop Auto BMPS Timer
4137 sme_StopAutoBmpsTimer(hHal);
4138 break;
4139#ifdef CONFIG_HAS_EARLYSUSPEND
4140 case 11://suspend to standby
4141#ifdef CONFIG_HAS_EARLYSUSPEND
4142 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4143 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4145#endif
4146 break;
4147 case 12://suspend to deep sleep
4148#ifdef CONFIG_HAS_EARLYSUSPEND
4149 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4150 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4152#endif
4153 break;
4154 case 13://resume from suspend
4155#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004156#endif
4157 break;
4158#endif
4159 case 14://reset wlan (power down/power up)
4160 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4161 break;
4162 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004163 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 ret = -EINVAL;
4165 break;
4166 }
4167 break;
4168 }
4169
4170 case WE_SET_MAX_ASSOC:
4171 {
4172 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4173 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4174 {
4175 ret = -EINVAL;
4176 }
4177 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4178 set_value, NULL, eANI_BOOLEAN_FALSE)
4179 != eHAL_STATUS_SUCCESS )
4180 {
c_hpothub8245442013-11-20 23:41:09 +05304181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4182 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 ret = -EIO;
4184 }
4185 break;
4186 }
4187
4188 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4189 {
4190 if( 0 == set_value )
4191 {
4192 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4193 }
4194 else if ( 1 == set_value )
4195 {
4196 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4197 }
4198 else
4199 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004200 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 ret = -EINVAL;
4202 }
4203 break;
4204 }
4205
4206 case WE_SET_DATA_INACTIVITY_TO:
4207 {
4208 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4209 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4210 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4211 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4212 set_value,
4213 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4214 {
4215 hddLog(LOGE,"Failure: Could not pass on "
4216 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004217 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 ret = -EINVAL;
4219 }
4220 break;
4221 }
4222 case WE_SET_MAX_TX_POWER:
4223 {
4224 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4225 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4226
4227 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4228 __func__, set_value);
4229 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4230 eHAL_STATUS_SUCCESS )
4231 {
4232 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4233 __func__);
4234 return -EIO;
4235 }
4236
4237 break;
4238 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004239 case WE_SET_MAX_TX_POWER_2_4:
4240 {
4241 hddLog(VOS_TRACE_LEVEL_INFO,
4242 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4243 __func__, set_value);
4244 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4245 eHAL_STATUS_SUCCESS)
4246 {
4247 hddLog(VOS_TRACE_LEVEL_ERROR,
4248 "%s: Setting maximum tx power failed for 2.4 GHz band",
4249 __func__);
4250 return -EIO;
4251 }
4252
4253 break;
4254 }
4255 case WE_SET_MAX_TX_POWER_5_0:
4256 {
4257 hddLog(VOS_TRACE_LEVEL_INFO,
4258 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4259 __func__, set_value);
4260 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4261 eHAL_STATUS_SUCCESS)
4262 {
4263 hddLog(VOS_TRACE_LEVEL_ERROR,
4264 "%s: Setting maximum tx power failed for 5.0 GHz band",
4265 __func__);
4266 return -EIO;
4267 }
4268
4269 break;
4270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 case WE_SET_HIGHER_DTIM_TRANSITION:
4272 {
4273 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4274 (set_value == eANI_BOOLEAN_TRUE)))
4275 {
4276 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4277 ret = -EINVAL;
4278 }
4279 else
4280 {
4281 if(pAdapter->higherDtimTransition != set_value)
4282 {
4283 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004284 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 }
4286 }
4287
4288 break;
4289 }
4290
4291 case WE_SET_TM_LEVEL:
4292 {
4293 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004294 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4296
4297 break;
4298 }
4299
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304300 case WE_ENABLE_STRICT_FCC_REG:
4301 {
4302 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4303 struct wiphy *wiphy = NULL;
4304 long lrc;
4305 int status;
4306
4307 wiphy = hddCtxt->wiphy;
4308 if(wiphy == NULL)
4309 {
4310 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4311 break;
4312 }
4313 init_completion(&hddCtxt->wiphy_channel_update_event);
4314
4315 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4316
4317 status = regulatory_hint(wiphy, "00");
4318 if(status < 0)
4319 {
4320 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4321 break;
4322 }
4323
4324 /* Wait for completion */
4325 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4326 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4327 if (lrc <= 0)
4328 {
4329 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4330 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4331 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4332 }
4333 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4334
4335 break;
4336 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004337 case WE_SET_DEBUG_LOG:
4338 {
4339 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4340 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4341 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4342 break;
4343 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304344
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 default:
4346 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004347 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 sub_cmd, set_value);
4349 break;
4350 }
4351 }
4352
4353 return ret;
4354}
4355
4356/* set param sub-ioctls */
4357static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4358 union iwreq_data *wrqu, char *extra)
4359{
4360 VOS_STATUS vstatus;
4361 int sub_cmd = wrqu->data.flags;
4362 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004363 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4365 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4366#ifdef WLAN_FEATURE_VOWIFI
4367 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4368#endif /* WLAN_FEATURE_VOWIFI */
4369
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004370 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4371 {
4372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4373 "%s:LOGP in Progress. Ignore!!!", __func__);
4374 return -EBUSY;
4375 }
4376
Arif Hussain0273cba2014-01-07 20:58:29 -08004377 /* ODD number is used for set, copy data using copy_from_user */
4378 pBuffer = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4379 wrqu->data.length);
4380 if (NULL == pBuffer)
4381 {
4382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4383 "mem_alloc_copy_from_user_helper fail");
4384 return -ENOMEM;
4385 }
4386
4387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4388 "%s: Received length %d", __func__, wrqu->data.length);
4389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4390 "%s: Received data %s", __func__, pBuffer);
4391
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 switch(sub_cmd)
4393 {
4394 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004396 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 break;
4398 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004400 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 break;
4402#if defined WLAN_FEATURE_VOWIFI
4403 case WE_NEIGHBOR_REPORT_REQUEST:
4404 {
4405 tRrmNeighborReq neighborReq;
4406 tRrmNeighborRspCallbackInfo callbackInfo;
4407
4408 if (pConfig->fRrmEnable)
4409 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ;
4412 if( !neighborReq.no_ssid )
4413 {
4414 neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004415 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 }
4417
4418 callbackInfo.neighborRspCallback = NULL;
4419 callbackInfo.neighborRspCallbackContext = NULL;
4420 callbackInfo.timeout = 5000; //5 seconds
4421 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4422 }
4423 else
4424 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004425 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 ret = -EINVAL;
4427 }
4428 }
4429 break;
4430#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 case WE_SET_AP_WPS_IE:
4432 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Arif Hussain0273cba2014-01-07 20:58:29 -08004433 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004436 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 if (VOS_STATUS_SUCCESS != vstatus)
4438 {
4439 ret = -EINVAL;
4440 }
4441 break;
4442 default:
4443 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004444 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 ret = -EINVAL;
4446 break;
4447 }
4448 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004449 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 return ret;
4451}
4452
4453/* get param sub-ioctls */
4454static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4455 union iwreq_data *wrqu, char *extra)
4456{
4457 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4458 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4459 int *value = (int *)extra;
4460 int ret = 0; /* success */
4461
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004462 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4463 {
4464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4465 "%s:LOGP in Progress. Ignore!!!", __func__);
4466 return -EBUSY;
4467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004468
4469 switch (value[0])
4470 {
4471 case WE_GET_11D_STATE:
4472 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004473 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304475
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4477
Arif Hussain6d2a3322013-11-17 19:50:10 -08004478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004479
4480 break;
4481 }
4482
4483 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 break;
4486
4487 case WE_PMC_STATE:
4488 {
4489 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 break;
4492 }
4493 case WE_GET_WLAN_DBG:
4494 {
4495 vos_trace_display();
4496 *value = 0;
4497 break;
4498 }
4499 case WE_MODULE_DOWN_IND:
4500 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4503#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4506#endif
4507 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4508
4509 *value = 0;
4510 break;
4511 }
4512 case WE_GET_MAX_ASSOC:
4513 {
4514 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4515 {
c_hpothub8245442013-11-20 23:41:09 +05304516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4517 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 ret = -EIO;
4519 }
4520 break;
4521 }
4522
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 case WE_GET_WDI_DBG:
4524 {
4525 wpalTraceDisplay();
4526 *value = 0;
4527 break;
4528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004529
4530 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4531 {
4532 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4533 break;
4534 }
4535 case WE_GET_CONCURRENCY_MODE:
4536 {
4537 *value = hdd_get_concurrency_mode ( );
4538
Arif Hussain6d2a3322013-11-17 19:50:10 -08004539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 break;
4541 }
4542
4543 default:
4544 {
4545 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4546 break;
4547 }
4548 }
4549
4550 return ret;
4551}
4552
4553/* set param sub-ioctls */
4554int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4555 union iwreq_data *wrqu, char *extra)
4556{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004557 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 int *value = (int *)extra;
4559 int sub_cmd = value[0];
4560 int ret = 0;
4561
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004562 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4563 {
4564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4565 "%s:LOGP in Progress. Ignore!!!", __func__);
4566 return -EBUSY;
4567 }
4568
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 switch(sub_cmd)
4570 {
4571 case WE_SET_WLAN_DBG:
4572 {
4573 vos_trace_setValue( value[1], value[2], value[3]);
4574 break;
4575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 case WE_SET_WDI_DBG:
4577 {
4578 wpalTraceSetLevel( value[1], value[2], value[3]);
4579 break;
4580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 case WE_SET_SAP_CHANNELS:
4582 {
4583 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4584 break;
4585 }
4586
4587 default:
4588 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004589 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 break;
4591 }
4592 }
4593 return ret;
4594}
4595
4596static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4597 union iwreq_data *wrqu, char *extra)
4598{
4599 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4600 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004601#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004602 hdd_wext_state_t *pWextState;
4603#endif
4604
4605 if (pAdapter == NULL)
4606 {
4607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4608 "%s: pAdapter is NULL!", __func__);
4609 return -EINVAL;
4610 }
4611#ifdef WLAN_FEATURE_11W
4612 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004613#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004614
Yue Ma3ede6052013-08-29 00:33:26 -07004615 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4616 {
4617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4618 "%s: HDD Context is NULL!", __func__);
4619
4620 return -EINVAL;
4621 }
4622
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004623 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4624 {
4625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4626 "%s:LOGP in Progress. Ignore!!!", __func__);
4627 return -EBUSY;
4628 }
4629
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 switch(sub_cmd)
4631 {
4632 case WE_WLAN_VERSION:
4633 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004634 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 break;
4636 }
4637
4638 case WE_GET_STATS:
4639 {
4640 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4641 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4642 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4643
4644 snprintf(extra, WE_MAX_STR_LEN,
4645 "\nTransmit"
4646 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4647 "\n dropped BK %u, BE %u, VI %u, VO %u"
4648 "\n classified BK %u, BE %u, VI %u, VO %u"
4649 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4650 "\n queued BK %u, BE %u, VI %u, VO %u"
4651 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004652 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 "\n fetched BK %u, BE %u, VI %u, VO %u"
4654 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4655 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004656 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 "\n flushed BK %u, BE %u, VI %u, VO %u"
4658 "\n\nReceive"
4659 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4660 "\n\nResetsStats"
4661 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4662 "\n",
4663 pStats->txXmitCalled,
4664 pStats->txXmitDropped,
4665 pStats->txXmitBackPressured,
4666 pStats->txXmitQueued,
4667
4668 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4669 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4670 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4671 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4672
4673 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4674 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4675 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4676 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4677
4678 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4679 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4680 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4681 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4682
4683 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4684 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4685 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4686 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4687
4688 pStats->txFetched,
4689 pStats->txFetchEmpty,
4690 pStats->txFetchLowResources,
4691 pStats->txFetchDequeueError,
4692
4693 pStats->txFetchDequeued,
4694 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004695 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 pStats->txCompleted,
4697 pStats->txFlushed,
4698
4699 pStats->txFetchedAC[WLANTL_AC_BK],
4700 pStats->txFetchedAC[WLANTL_AC_BE],
4701 pStats->txFetchedAC[WLANTL_AC_VI],
4702 pStats->txFetchedAC[WLANTL_AC_VO],
4703
4704 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4705 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4706 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4707 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4708
4709 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4710 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4711 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4712 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4713
Ravi Joshi41914632013-10-21 23:02:21 -07004714 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4715 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4716 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4717 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4718
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 pStats->txFlushedAC[WLANTL_AC_BK],
4720 pStats->txFlushedAC[WLANTL_AC_BE],
4721 pStats->txFlushedAC[WLANTL_AC_VI],
4722 pStats->txFlushedAC[WLANTL_AC_VO],
4723
4724 pStats->rxChains,
4725 pStats->rxPackets,
4726 pStats->rxDropped,
4727 pStats->rxDelivered,
4728 pStats->rxRefused,
4729
4730 pResetStats->totalLogpResets,
4731 pResetStats->totalCMD53Failures,
4732 pResetStats->totalMutexReadFailures,
4733 pResetStats->totalMIFErrorFailures,
4734 pResetStats->totalFWHearbeatFailures,
4735 pResetStats->totalUnknownExceptions
4736 );
4737 wrqu->data.length = strlen(extra)+1;
4738 break;
4739 }
4740
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304741/* The case prints the current state of the HDD, SME, CSR, PE, TL
4742 *it can be extended for WDI Global State as well.
4743 *And currently it only checks P2P_CLIENT adapter.
4744 *P2P_DEVICE and P2P_GO have not been added as of now.
4745*/
4746 case WE_GET_STATES:
4747 {
4748 int buf = 0, len = 0;
4749 int adapter_num = 0;
4750 int count = 0, check = 1;
4751
4752 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004753 tHalHandle hHal = NULL;
4754 tpAniSirGlobal pMac = NULL;
4755 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304756
4757 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4758 hdd_adapter_t *useAdapter = NULL;
4759
4760 /* Print wlan0 or p2p0 states based on the adapter_num
4761 *by using the correct adapter
4762 */
4763 while ( adapter_num < 2 )
4764 {
4765 if ( WLAN_ADAPTER == adapter_num )
4766 {
4767 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004768 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304769 "\n\n wlan0 States:-");
4770 len += buf;
4771 }
4772 else if ( P2P_ADAPTER == adapter_num )
4773 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004774 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304775 "\n\n p2p0 States:-");
4776 len += buf;
4777
4778 if( !pHddCtx )
4779 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004780 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304781 "\n pHddCtx is NULL");
4782 len += buf;
4783 break;
4784 }
4785
4786 /*Printing p2p0 states only in the case when the device is
4787 configured as a p2p_client*/
4788 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4789 if ( !useAdapter )
4790 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004791 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304792 "\n Device not configured as P2P_CLIENT.");
4793 len += buf;
4794 break;
4795 }
4796 }
4797
4798 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004799 if (!hHal) {
4800 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4801 "\n pMac is NULL");
4802 len += buf;
4803 break;
4804 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304805 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004806 if (!pMac) {
4807 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4808 "\n pMac is NULL");
4809 len += buf;
4810 break;
4811 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304812 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4813 if( !pHddStaCtx )
4814 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004815 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304816 "\n pHddStaCtx is NULL");
4817 len += buf;
4818 break;
4819 }
4820
4821 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4822
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004823 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304824 "\n HDD Conn State - %s "
4825 "\n \n SME State:"
4826 "\n Neighbour Roam State - %s"
4827 "\n CSR State - %s"
4828 "\n CSR Substate - %s"
4829 "\n \n TL STA %d State: %s",
4830 macTraceGetHDDWlanConnState(
4831 pHddStaCtx->conn_info.connState),
4832 macTraceGetNeighbourRoamState(
4833 pMac->roam.neighborRoamInfo.neighborRoamState),
4834 macTraceGetcsrRoamState(
4835 pMac->roam.curState[useAdapter->sessionId]),
4836 macTraceGetcsrRoamSubState(
4837 pMac->roam.curSubState[useAdapter->sessionId]),
4838 pHddStaCtx->conn_info.staId[0],
4839 macTraceGetTLState(tlState)
4840 );
4841 len += buf;
4842 adapter_num++;
4843 }
4844
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004845 if (pMac) {
4846 /* Printing Lim State starting with global lim states */
4847 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4848 "\n \n LIM STATES:-"
4849 "\n Global Sme State - %s "\
4850 "\n Global mlm State - %s "\
4851 "\n",
4852 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4853 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4854 );
4855 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304856
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004857 /*printing the PE Sme and Mlm states for valid lim sessions*/
4858 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304859 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004860 if ( pMac->lim.gpSession[count].valid )
4861 {
4862 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4863 "\n Lim Valid Session %d:-"
4864 "\n PE Sme State - %s "
4865 "\n PE Mlm State - %s "
4866 "\n",
4867 check,
4868 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4869 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4870 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304871
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004872 len += buf;
4873 check++;
4874 }
4875 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304876 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304877 }
4878
4879 wrqu->data.length = strlen(extra)+1;
4880 break;
4881 }
4882
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 case WE_GET_CFG:
4884 {
4885 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
4886 wrqu->data.length = strlen(extra)+1;
4887 break;
4888 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004889#ifdef WLAN_FEATURE_11AC
4890 case WE_GET_RSSI:
4891 {
4892 v_S7_t s7Rssi = 0;
4893 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
4894 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
4895 wrqu->data.length = strlen(extra)+1;
4896 break;
4897 }
4898#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304899
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004900#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004901 case WE_GET_ROAM_RSSI:
4902 {
4903 v_S7_t s7Rssi = 0;
4904 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
4905 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
4906 wrqu->data.length = strlen(extra)+1;
4907 break;
4908 }
4909#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 case WE_GET_WMM_STATUS:
4911 {
4912 snprintf(extra, WE_MAX_STR_LEN,
4913 "\nDir: 0=up, 1=down, 3=both\n"
4914 "|------------------------|\n"
4915 "|AC | ACM |Admitted| Dir |\n"
4916 "|------------------------|\n"
4917 "|VO | %d | %3s | %d |\n"
4918 "|VI | %d | %3s | %d |\n"
4919 "|BE | %d | %3s | %d |\n"
4920 "|BK | %d | %3s | %d |\n"
4921 "|------------------------|\n",
4922 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
4923 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
4924 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
4925 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
4926 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
4927 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
4928 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
4929 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
4930 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
4931 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
4932 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
4933 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
4934
Jeff Johnsone7245742012-09-05 17:12:55 -07004935
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 wrqu->data.length = strlen(extra)+1;
4937 break;
4938 }
4939 case WE_GET_CHANNEL_LIST:
4940 {
4941 VOS_STATUS status;
4942 v_U8_t i, len;
4943 char* buf ;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004944
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 tChannelListInfo channel_list;
4946
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004947 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004949 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004951 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 return -EINVAL;
4953 }
4954 buf = extra;
4955
4956 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004957 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
4958 * needed = 5 * number of channels. Check ifsufficient
4959 * buffer is available and then proceed to fill the buffer.
4960 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
4962 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004963 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004964 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004965 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 return -EINVAL;
4967 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004968 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
4969 channel_list.num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 for(i = 0 ; i < channel_list.num_channels; i++)
4971 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004972 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 }
4975 wrqu->data.length = strlen(extra)+1;
4976
4977 break;
4978 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004979#ifdef FEATURE_WLAN_TDLS
4980 case WE_GET_TDLS_PEERS:
4981 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08004982 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08004983 break;
4984 }
4985#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004986#ifdef WLAN_FEATURE_11W
4987 case WE_GET_11W_INFO:
4988 {
4989 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
4990
4991 snprintf(extra, WE_MAX_STR_LEN,
4992 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
4993 "\n Number of Unprotected Disassocs %d"
4994 "\n Number of Unprotected Deauths %d",
4995 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
4996 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
4997 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
4998 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
4999 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5000
5001 wrqu->data.length = strlen(extra)+1;
5002 break;
5003 }
5004#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305005 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005007 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 break;
5009 }
5010 }
5011
5012 return 0;
5013}
5014
5015/* action sub-ioctls */
5016static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5017 union iwreq_data *wrqu, char *extra)
5018{
5019 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5020 int sub_cmd = wrqu->data.flags;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005021 int ret = 0; /* success */
Jeff Johnson295189b2012-06-20 16:38:30 -07005022
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005023 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5024 {
5025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5026 "%s:LOGP in Progress. Ignore!!!", __func__);
5027 return -EBUSY;
5028 }
5029
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 switch (sub_cmd)
5031 {
5032 case WE_CLEAR_STATS:
5033 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5036 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5037 break;
5038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 case WE_INIT_AP:
5040 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305041 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5042
5043 /* As Soft AP mode might been changed to STA already with
5044 * killing of Hostapd, need to find the adpater by name
5045 * rather than mode */
5046 hdd_adapter_t* pAdapter_to_stop =
5047 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5048 if( pAdapter_to_stop )
5049 {
5050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5051 "Adapter with name softap.0 already "
5052 "exist, ignoring the request.\nRemove the "
5053 "adapter and try again\n");
5054 break;
5055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 pr_info("Init AP trigger\n");
5057 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5058 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5059 break;
5060 }
5061 case WE_STOP_AP:
5062 {
5063 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5064 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5065 * this is a dead code and need to find the adpater by name rather than mode */
5066 hdd_adapter_t* pAdapter_to_stop =
5067 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5068 if( pAdapter_to_stop )
5069 {
5070 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5071
5072 pr_info("Stopping AP mode\n");
5073
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305074 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5075 {
5076 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5077 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5078 }
5079
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 /*Make sure that pAdapter cleaned properly*/
5081 hdd_stop_adapter( pHddCtx, pAdapter_to_stop );
5082 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5083 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5084
5085 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5086 pAdapter_to_stop->macAddressCurrent.bytes);
5087 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5088 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305089
5090 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5091 {
5092 /* put the device back into BMPS */
5093 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 }
5096 else
5097 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005098 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 }
5100
5101 break;
5102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005103#ifdef WLAN_BTAMP_FEATURE
5104 case WE_ENABLE_AMP:
5105 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 WLANBAP_RegisterWithHCI(pAdapter);
5108 break;
5109 }
5110 case WE_DISABLE_AMP:
5111 {
5112 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5113 VOS_STATUS status;
5114
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005116
5117 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5118 status = WLANBAP_StopAmp();
5119 if(VOS_STATUS_SUCCESS != status )
5120 {
5121 pHddCtx->isAmpAllowed = VOS_TRUE;
5122 hddLog(VOS_TRACE_LEVEL_FATAL,
5123 "%s: Failed to stop AMP", __func__);
5124 }
5125 else
5126 {
5127 //a state m/c implementation in PAL is TBD to avoid this delay
5128 msleep(500);
5129 pHddCtx->isAmpAllowed = VOS_FALSE;
5130 WLANBAP_DeregisterFromHCI();
5131 }
5132
5133 break;
5134 }
5135#endif
5136
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005137 case WE_ENABLE_DXE_STALL_DETECT:
5138 {
schang6295e542013-03-12 15:31:23 -07005139 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5140 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005141 break;
5142 }
5143 case WE_DISPLAY_DXE_SNAP_SHOT:
5144 {
schang6295e542013-03-12 15:31:23 -07005145 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5146 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005147 break;
5148 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305149 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5150 {
5151 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5152 hdd_wmm_tx_snapshot(pAdapter);
5153 WLANTL_TLDebugMessage(VOS_TRUE);
5154 break;
5155 }
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07005156 case WE_SET_REASSOC_TRIGGER:
5157 {
5158 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5159 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5160 v_U32_t roamId = 0;
5161 tCsrRoamModifyProfileFields modProfileFields;
5162 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5163 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5164 return 0;
5165 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305166
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305167 case WE_STOP_OBSS_SCAN:
5168 {
5169 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5170 2.OBSS scan is stopped by Firmware during the disassociation
5171 3.OBSS stop comamnd is added for debugging purpose*/
5172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5173 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005174
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305175 if (pAdapter == NULL)
5176 {
5177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5178 " pAdapter is NULL ");
5179 }
5180 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5181 if (pMac == NULL)
5182 {
5183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5184 " pMac is NULL ");
5185 }
5186 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5187 }
5188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 default:
5190 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005191 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 break;
5193 }
5194 }
5195
5196 return ret;
5197}
5198
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305199void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5200{
5201 /*
5202 * Function to display HDD WMM information
5203 * for Tx Queues.
5204 * Prints globala as well as per client depending
5205 * whether the clients are registered or not.
5206 */
5207 int i = 0, j = 0;
5208 for ( i=0; i< NUM_TX_QUEUES; i++)
5209 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305210 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005211 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305212 i, pAdapter->wmm_tx_queue[i].count,
5213 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305214 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305215 }
5216
5217 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5218 {
5219 if(pAdapter->aStaInfo[i].isUsed)
5220 {
5221 hddLog(LOGE, "******STAIndex: %d*********", i);
5222 for ( j=0; j< NUM_TX_QUEUES; j++)
5223 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305224 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005225 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305226 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5227 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5228 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305229 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305230 }
5231 }
5232 }
5233
5234}
Jeff Johnson295189b2012-06-20 16:38:30 -07005235int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5236 union iwreq_data *wrqu, char *extra)
5237{
5238 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5239 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5240 int sub_cmd = wrqu->data.flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 int apps_args[MAX_VAR_ARGS] = {0};
5242 int num_args = wrqu->data.length;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005243 hdd_station_ctx_t *pStaCtx = NULL ;
5244 hdd_ap_ctx_t *pAPCtx = NULL;
5245 int cmd = 0;
5246 int staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005247
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005248 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005249
5250 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5251 {
5252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5253 "%s:LOGP in Progress. Ignore!!!", __func__);
5254 return -EBUSY;
5255 }
5256
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 if (num_args > MAX_VAR_ARGS)
5258 {
5259 num_args = MAX_VAR_ARGS;
5260 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005261
5262 /* ODD number is used for set, copy data using copy_from_user */
5263 if (copy_from_user(apps_args, wrqu->data.pointer, (sizeof(int)) * num_args))
5264 {
5265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5266 "%s: failed to copy data to user buffer", __func__);
5267 return -EFAULT;
5268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005269
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005270 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5271 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5272 {
5273 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5274 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5275 {
5276 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5277 staId = pStaCtx->conn_info.staId[0];
5278 }
5279 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5280 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5281 {
5282 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5283 staId = pAPCtx->uBCStaId;
5284 }
5285 else
5286 {
5287 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5288 return 0;
5289 }
5290 }
5291
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 switch (sub_cmd)
5293 {
5294 case WE_LOG_DUMP_CMD:
5295 {
5296 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005297 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 apps_args[3], apps_args[4]);
5299
5300 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5301 apps_args[3], apps_args[4]);
5302
5303 }
5304 break;
5305
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 case WE_P2P_NOA_CMD:
5307 {
5308 p2p_app_setP2pPs_t p2pNoA;
5309
5310 p2pNoA.opp_ps = apps_args[0];
5311 p2pNoA.ctWindow = apps_args[1];
5312 p2pNoA.duration = apps_args[2];
5313 p2pNoA.interval = apps_args[3];
5314 p2pNoA.count = apps_args[4];
5315 p2pNoA.single_noa_duration = apps_args[5];
5316 p2pNoA.psSelection = apps_args[6];
5317
5318 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5319 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005320 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5322
5323 hdd_setP2pPs(dev, &p2pNoA);
5324
5325 }
5326 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005327
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305328 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5329 {
5330 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5331 __func__, apps_args[0], apps_args[1]);
5332 vosTraceEnable(apps_args[0], apps_args[1]);
5333 }
5334 break;
5335
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005336 case WE_MTRACE_DUMP_CMD:
5337 {
5338 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5339 "bitmask_of_module %d ",
5340 __func__, apps_args[0], apps_args[1], apps_args[2],
5341 apps_args[3]);
5342 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5343 apps_args[2], apps_args[3]);
5344
5345 }
5346 break;
5347
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005348 case WE_MCC_CONFIG_CREDENTIAL :
5349 {
5350 cmd = 287; //Command should be updated if there is any change
5351 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005352 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005353 {
5354 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5355 }
5356 else
5357 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005358 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005359 return 0;
5360 }
5361 }
5362 break;
5363
5364 case WE_MCC_CONFIG_PARAMS :
5365 {
5366 cmd = 288; //command Should be updated if there is any change
5367 // in the Riva dump command
5368 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5369 }
5370 break;
5371
Chilam NG571c65a2013-01-19 12:27:36 +05305372#ifdef FEATURE_WLAN_TDLS
5373 case WE_TDLS_CONFIG_PARAMS :
5374 {
5375 tdls_config_params_t tdlsParams;
5376
Chilam Ng01120412013-02-19 18:32:21 -08005377 tdlsParams.tdls = apps_args[0];
5378 tdlsParams.tx_period_t = apps_args[1];
5379 tdlsParams.tx_packet_n = apps_args[2];
5380 tdlsParams.discovery_period_t = apps_args[3];
5381 tdlsParams.discovery_tries_n = apps_args[4];
5382 tdlsParams.idle_timeout_t = apps_args[5];
5383 tdlsParams.idle_packet_n = apps_args[6];
5384 tdlsParams.rssi_hysteresis = apps_args[7];
5385 tdlsParams.rssi_trigger_threshold = apps_args[8];
5386 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305387
Chilam Ng01120412013-02-19 18:32:21 -08005388 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305389 }
5390 break;
5391#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 default:
5393 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005394 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5395 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 }
5397 break;
5398 }
5399
5400 return 0;
5401}
5402
5403
5404static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5405 union iwreq_data *wrqu, char *extra)
5406{
5407 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5408 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5409 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5410 int params[HDD_WLAN_WMM_PARAM_COUNT];
5411 sme_QosWmmTspecInfo tSpec;
5412 v_U32_t handle;
5413
5414 // make sure the application is sufficiently priviledged
5415 // note that the kernel will do this for "set" ioctls, but since
5416 // this ioctl wants to return status to user space it must be
5417 // defined as a "get" ioctl
5418 if (!capable(CAP_NET_ADMIN))
5419 {
5420 return -EPERM;
5421 }
5422
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005423 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5424 {
5425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5426 "%s:LOGP in Progress. Ignore!!!", __func__);
5427 return -EBUSY;
5428 }
5429
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 // we must be associated in order to add a tspec
5431 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5432 {
5433 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5434 return 0;
5435 }
5436
5437 // since we are defined to be a "get" ioctl, and since the number
5438 // of params exceeds the number of params that wireless extensions
5439 // will pass down in the iwreq_data, we must copy the "set" params
5440 // from user space ourselves
5441 if (copy_from_user(&params, wrqu->data.pointer, sizeof(params)))
5442 {
5443 // hmmm, can't get them
5444 return -EIO;
5445 }
5446
5447 // clear the tspec
5448 memset(&tSpec, 0, sizeof(tSpec));
5449
5450 // validate the handle
5451 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5452 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5453 {
5454 // that one is reserved
5455 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5456 return 0;
5457 }
5458
5459 // validate the TID
5460 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5461 {
5462 // out of range
5463 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5464 return 0;
5465 }
5466 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5467
5468 // validate the direction
5469 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5470 {
5471 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5472 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5473 break;
5474
5475 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5476 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5477 break;
5478
5479 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5480 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5481 break;
5482
5483 default:
5484 // unknown
5485 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5486 return 0;
5487 }
5488
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305489 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5490
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 // validate the user priority
5492 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5493 {
5494 // out of range
5495 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5496 return 0;
5497 }
5498 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305499 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5500 {
5501 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5502 return 0;
5503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005504
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5506 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5507 tSpec.ts_info.psb, tSpec.ts_info.up);
5508
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5510 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5511 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5512 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5513 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5514 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5515 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5516 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5517 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5518 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5519 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5520 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5521
5522 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5523
5524 // validate the ts info ack policy
5525 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5526 {
5527 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5528 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5529 break;
5530
5531 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5532 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5533 break;
5534
5535 default:
5536 // unknown
5537 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5538 return 0;
5539 }
5540
5541 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5542 return 0;
5543}
5544
5545
5546static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5547 union iwreq_data *wrqu, char *extra)
5548{
5549 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5550 int *params = (int *)extra;
5551 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5552 v_U32_t handle;
5553
5554 // make sure the application is sufficiently priviledged
5555 // note that the kernel will do this for "set" ioctls, but since
5556 // this ioctl wants to return status to user space it must be
5557 // defined as a "get" ioctl
5558 if (!capable(CAP_NET_ADMIN))
5559 {
5560 return -EPERM;
5561 }
5562
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005563 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5564 {
5565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5566 "%s:LOGP in Progress. Ignore!!!", __func__);
5567 return -EBUSY;
5568 }
5569
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 // although we are defined to be a "get" ioctl, the params we require
5571 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5572 // is no need to copy the params from user space
5573
5574 // validate the handle
5575 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5576 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5577 {
5578 // that one is reserved
5579 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5580 return 0;
5581 }
5582
5583 *pStatus = hdd_wmm_delts(pAdapter, handle);
5584 return 0;
5585}
5586
5587
5588static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5589 union iwreq_data *wrqu, char *extra)
5590{
5591 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5592 int *params = (int *)extra;
5593 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5594 v_U32_t handle;
5595
5596 // although we are defined to be a "get" ioctl, the params we require
5597 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5598 // is no need to copy the params from user space
5599
5600 // validate the handle
5601 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5602 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5603 {
5604 // that one is reserved
5605 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5606 return 0;
5607 }
5608
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005609 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5610 {
5611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5612 "%s:LOGP in Progress. Ignore!!!", __func__);
5613 return -EBUSY;
5614 }
5615
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5617 return 0;
5618}
5619
5620
5621#ifdef FEATURE_WLAN_WAPI
5622static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5623 union iwreq_data *wrqu, char *extra)
5624{
5625 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5626 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5627 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5628 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5629
Arif Hussain7adce1b2013-11-11 22:59:34 -08005630 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005631
5632 hddLog(LOG1, "The function iw_qcom_set_wapi_mode called");
Arif Hussain7adce1b2013-11-11 22:59:34 -08005633 hddLog(LOG1, "%s: Received data %s", __func__, extra);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005634 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
5635 hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005636
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005637 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5638 {
5639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5640 "%s:LOGP in Progress. Ignore!!!", __func__);
5641 return -EBUSY;
5642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005643
5644 if(WZC_ORIGINAL == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005645 hddLog(LOG1, "%s: WAPI Mode Set to OFF", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */
5647 pRoamProfile->EncryptionType.numEntries = 1;
5648 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5649 pRoamProfile->mcEncryptionType.numEntries = 1;
5650 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5651
5652 pRoamProfile->AuthType.numEntries = 1;
5653 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5654 pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5655 }
5656 else if(WAPI_EXTENTION == pWapiMode->wapiMode) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005657 hddLog(LOG1, "%s: WAPI Mode Set to ON", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 }
5659 else
5660 return -EINVAL;
5661
5662 pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode;
5663
5664 return 0;
5665}
5666
5667static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info,
5668 union iwreq_data *wrqu, char *extra)
5669{
5670 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5671 WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra);
5672
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005673 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5674 {
5675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5676 "%s:LOGP in Progress. Ignore!!!", __func__);
5677 return -EBUSY;
5678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 hddLog(LOG1, "The function iw_qcom_get_wapi_mode called");
5680
5681 pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005682 hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __func__, pWapiMode->wapiMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 return 0;
5684}
5685
5686static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info,
5687 union iwreq_data *wrqu, char *extra)
5688{
5689 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5690// WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer);
5691 WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra);
5692 int i = 0, j = 0;
5693 hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005694 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005695 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005696
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005697 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5698 {
5699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5700 "%s:LOGP in Progress. Ignore!!!", __func__);
5701 return -EBUSY;
5702 }
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005703
5704 if (NULL == pWapiAssocInfo)
5705 {
5706 VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
5707 "%s: WDA NULL context", __func__);
5708 VOS_ASSERT(0);
5709 return VOS_STATUS_E_FAILURE;
5710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005711
Arif Hussain6d2a3322013-11-17 19:50:10 -08005712 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 -07005713 hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__func__,pWapiAssocInfo->akmSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005715 hddLog(LOG1,"akm suite[%02d]:0x%08x",i,pWapiAssocInfo->akmSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005716
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005717 hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__func__,pWapiAssocInfo->unicastSuiteCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 for(i =0 ; i < 16 ; i++)
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005719 hddLog(LOG1, "Unicast suite[%02d]:0x%08x",i,pWapiAssocInfo->unicastSuite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005720
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005721 hddLog(LOG1,"%s: Multicast suite:0x%08x Wapi capa:0x%04x",__func__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005722 hddLog(LOG1, "%s: BKID Cnt:0x%04x",__func__,pWapiAssocInfo->bkidCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 for(i = 0 ; i < 16 ; i++) {
5724 hddLog(LOG1, "BKID List[%02d].bkid:0x",i);
5725 for(j = 0 ; j < 16 ; j++)
5726 hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]);
5727 }
5728
5729 /* We are not using the entire IE as provided by the supplicant.
5730 * This is being calculated by SME. This is the same as in the
5731 * case of WPA. Only the auth mode information needs to be
5732 * extracted here*/
5733 if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005734 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
5736 }
5737
5738 if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005739 hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5741 }
5742 return 0;
5743}
5744
5745static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info,
5746 union iwreq_data *wrqu, char *extra)
5747{
5748 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5749 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5750 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5751 tANI_U32 roamId = 0xFF;
5752 tANI_U8 *pKeyPtr = NULL;
5753 v_BOOL_t isConnected = TRUE;
5754 tCsrRoamSetKey setKey;
5755 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra);
5757
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005758 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5759 {
5760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5761 "%s:LOGP in Progress. Ignore!!!", __func__);
5762 return -EBUSY;
5763 }
5764
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 hddLog(LOG1, "The function iw_qcom_set_wapi_key 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
Arif Hussain6d2a3322013-11-17 19:50:10 -08005769 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 -07005770 hddLog(LOG1,"Add Index:0x");
5771 for(i =0 ; i < 12 ; i++)
5772 hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]);
5773
Arif Hussain6d2a3322013-11-17 19:50:10 -08005774 hddLog(LOG1,"%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __func__,pWapiKey->wpiekLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 hddLog(LOG1, "WAPI ENCRYPTION KEY:0x");
5776 for(i =0 ; i < 16 ; i++)
5777 hddLog(LOG1,"%02x",pWapiKey->wpiek[i]);
5778
Arif Hussain6d2a3322013-11-17 19:50:10 -08005779 hddLog(LOG1,"%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __func__,pWapiKey->wpickLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x");
5781 for(i =0 ; i < 16 ; i++)
5782 hddLog(LOG1,"%02x",pWapiKey->wpick[i]);
5783
Arif Hussain6d2a3322013-11-17 19:50:10 -08005784 hddLog(LOG1,"WAPI PN NUMBER:0x");
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 for(i = 0 ; i < 16 ; i++)
5786 hddLog(LOG1,"%02x",pWapiKey->pn[i]);
5787
5788 // Clear the setkey memory
5789 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5790 // Store Key ID
5791 setKey.keyId = (unsigned char)( pWapiKey->keyId );
5792 // SET WAPI Encryption
5793 setKey.encType = eCSR_ENCRYPT_TYPE_WPI;
5794 // Key Directionn both TX and RX
5795 setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST??
5796 // the PAE role
5797 setKey.paeRole = 0 ;
5798
5799 switch ( pWapiKey->keyType )
5800 {
Chilam Ngc4244af2013-04-01 15:37:32 -07005801 case PAIRWISE_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 {
5803 isConnected = hdd_connIsConnected(pHddStaCtx);
5804 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
5805 break;
5806 }
Chilam Ngc4244af2013-04-01 15:37:32 -07005807 case GROUP_KEY:
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 {
5809 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
5810 break;
5811 }
5812 default:
5813 {
5814 //Any other option is invalid.
5815 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005816 "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__func__ , -1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005817
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005818 hddLog(LOGE," %s: Error WAPI Key Add Type",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE
5820 break; // NEED RETURN FROM HERE ????
5821 }
5822 }
5823
5824 // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK
5825 setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen));
5826 pKeyPtr = setKey.Key;
5827 memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen );
5828 pKeyPtr += pWapiKey->wpiekLen;
5829 memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen );
5830
5831 // Set the new key with SME.
5832 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5833
5834 if ( isConnected ) {
5835 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId );
5836 if ( halStatus != eHAL_STATUS_SUCCESS )
5837 {
5838 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5839 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
5840
5841 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5842 }
5843 }
5844#if 0 /// NEED TO CHECK ON THIS
5845 else
5846 {
5847 // Store the keys in the adapter to be moved to the profile & passed to
5848 // SME in the ConnectRequest if we are not yet in connected state.
5849 memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) );
5850 pAdapter->fKeySet[ setKey.keyId ] = TRUE;
5851
5852 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
5853 " Saving key [idx= %d] to apply when moving to connected state ",
5854 setKey.keyId );
5855
5856 }
5857#endif
5858 return halStatus;
5859}
5860
5861static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5862 union iwreq_data *wrqu, char *extra)
5863{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005864 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005865#ifdef WLAN_DEBUG
5866 int i = 0;
Arif Hussain7adce1b2013-11-11 22:59:34 -08005867 WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005868#endif
5869
5870 hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005871 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005872 hddLog(LOG1, "%s: Received data %s", __func__, (char*)extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005873
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005874 hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08x", __func__,pBkid->length);
5875 hddLog(LOG1,"%s: BKID Cnt:0x%04x", __func__, pBkid->BKIDCount);
Jeff Johnson295189b2012-06-20 16:38:30 -07005876
5877 hddLog(LOG1,"BKID KEY LIST[0]:0x");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005878
5879 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5880 {
5881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5882 "%s:LOGP in Progress. Ignore!!!", __func__);
5883 return -EBUSY;
5884 }
5885
Jeff Johnson295189b2012-06-20 16:38:30 -07005886#ifdef WLAN_DEBUG
5887 for(i =0 ; i < 16 ; i++)
5888 hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]);
5889#endif
5890
5891 return 0;
5892}
5893
5894static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info,
5895 union iwreq_data *wrqu, char *extra)
5896{
5897 /* Yet to implement this function, 19th April 2010 */
5898 hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called ");
5899
5900 return 0;
5901}
5902#endif /* FEATURE_WLAN_WAPI */
5903
5904#ifdef WLAN_FEATURE_VOWIFI_11R
5905//
5906//
5907// Each time the supplicant has the auth_request or reassoc request
5908// IEs ready. This is pushed to the driver. The driver will inturn use
5909// it to send out the auth req and reassoc req for 11r FT Assoc.
5910//
5911static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5912 union iwreq_data *wrqu, char *extra)
5913{
5914 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5915 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5916 //v_CONTEXT_t pVosContext;
5917
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005918 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5919 {
5920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5921 "%s:LOGP in Progress. Ignore!!!", __func__);
5922 return -EBUSY;
5923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 if (!wrqu->data.length)
5925 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005926 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 return -EINVAL;
5928 }
5929 if (wrqu->data.pointer == NULL)
5930 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005931 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 return -EINVAL;
5933 }
5934
5935 // Added for debug on reception of Re-assoc Req.
5936 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5937 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005938 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005940 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 }
5942
5943#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005944 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005945#endif
5946
5947 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005948 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 wrqu->data.length);
5950
5951 return 0;
5952}
5953#endif
5954
Amar Singhalf3a6e762013-02-19 15:06:50 -08005955static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005956 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005958{
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005960 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005962 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005963 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005964 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5965 int idx;
5966 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005967
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005968 if (pHddCtx->isLogpInProgress)
5969 {
5970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5971 "%s:LOGP in Progress. Ignore!!!", __func__);
5972 return -EBUSY;
5973 }
5974
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305975 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5976 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305977#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005978
Amar Singhalf3a6e762013-02-19 15:06:50 -08005979 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5980 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005981 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005982 hddLog(VOS_TRACE_LEVEL_ERROR,
5983 "%s: vos_mem_alloc failed", __func__);
5984 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005985 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005986
5987 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5988
5989 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5990 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5991
5992 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5993 mc_addr_list_ptr->ulMulticastAddrCnt);
5994
5995 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005996 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005997 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5998 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5999
6000 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6001 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006002 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006003
Amar Singhalf3a6e762013-02-19 15:06:50 -08006004 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6005 vos_mem_free(mc_addr_list_ptr);
6006 if (eHAL_STATUS_SUCCESS != ret_val)
6007 {
6008 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6009 __func__);
6010 return -EINVAL;
6011 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306012#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306013 }
6014 else
6015 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006016
Amar Singhalf3a6e762013-02-19 15:06:50 -08006017 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6018 "%s: Set MC BC Filter Config request: %d suspend %d",
6019 __func__, pRequest->mcastBcastFilterSetting,
6020 pHddCtx->hdd_wlan_suspended);
6021
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306022 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006023
6024 if (pHddCtx->hdd_wlan_suspended)
6025 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006026 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6027 if (NULL == wlanRxpFilterParam)
6028 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306029 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006030 "%s: vos_mem_alloc failed", __func__);
6031 return -EINVAL;
6032 }
6033
Amar Singhalf3a6e762013-02-19 15:06:50 -08006034 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6035 pRequest->mcastBcastFilterSetting;
6036 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6037
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306038 hdd_conf_hostoffload(pAdapter, TRUE);
6039 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6040 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006041
6042 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6043 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306044 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006045 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6046 wlanRxpFilterParam->setMcstBcstFilter);
6047
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306048 if (eHAL_STATUS_SUCCESS !=
6049 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6050 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006051 {
6052 hddLog(VOS_TRACE_LEVEL_ERROR,
6053 "%s: Failure to execute set HW MC/BC Filter request",
6054 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006055 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006056 return -EINVAL;
6057 }
6058
Amar Singhalf3a6e762013-02-19 15:06:50 -08006059 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006061
6062 return 0;
6063}
6064
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006065static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006066 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 union iwreq_data *wrqu, char *extra)
6068{
6069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6070 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306071 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006072 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006073
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306074 //Reset the filter to INI value as we have to clear the dynamic filter
6075 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006076
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306077 //Configure FW with new setting
6078 if (pHddCtx->hdd_wlan_suspended)
6079 {
6080 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6081 if (NULL == wlanRxpFilterParam)
6082 {
6083 hddLog(VOS_TRACE_LEVEL_ERROR,
6084 "%s: vos_mem_alloc failed", __func__);
6085 return -EINVAL;
6086 }
6087
6088 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6089 pHddCtx->configuredMcastBcastFilter;
6090 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6091
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306092 hdd_conf_hostoffload(pAdapter, TRUE);
6093 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6094 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306095
6096 if (eHAL_STATUS_SUCCESS !=
6097 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6098 wlanRxpFilterParam))
6099 {
6100 hddLog(VOS_TRACE_LEVEL_ERROR,
6101 "%s: Failure to execute set HW MC/BC Filter request",
6102 __func__);
6103 vos_mem_free(wlanRxpFilterParam);
6104 return -EINVAL;
6105 }
6106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 return 0;
6108}
6109
6110static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6111 union iwreq_data *wrqu, char *extra)
6112{
6113 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006114 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 tSirHostOffloadReq offloadRequest;
6116
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006117 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6118 {
6119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6120 "%s:LOGP in Progress. Ignore!!!", __func__);
6121 return -EBUSY;
6122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 /* Debug display of request components. */
6124 switch (pRequest->offloadType)
6125 {
6126 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006127 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 switch (pRequest->enableOrDisable)
6129 {
6130 case WLAN_OFFLOAD_DISABLE:
6131 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6132 break;
6133 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6134 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6135 case WLAN_OFFLOAD_ENABLE:
6136 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6137 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6138 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6139 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6140 }
6141 break;
6142
6143 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006144 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006145 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 switch (pRequest->enableOrDisable)
6147 {
6148 case WLAN_OFFLOAD_DISABLE:
6149 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6150 break;
6151 case WLAN_OFFLOAD_ENABLE:
6152 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6153 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6154 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6155 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6156 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6157 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6158 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6159 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6160 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6161 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6162 }
6163 }
6164
6165 /* Execute offload request. The reason that we can copy the request information
6166 from the ioctl structure to the SME structure is that they are laid out
6167 exactly the same. Otherwise, each piece of information would have to be
6168 copied individually. */
6169 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006170 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6171 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006173 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 __func__);
6175 return -EINVAL;
6176 }
6177
6178 return 0;
6179}
6180
6181static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6182 union iwreq_data *wrqu, char *extra)
6183{
6184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006185 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 tSirKeepAliveReq keepaliveRequest;
6187
6188 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6189 {
6190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006191 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 return 0;
6193 }
6194
6195 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006196 hddLog(VOS_TRACE_LEVEL_INFO,
6197 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6198 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006199
6200 switch (pRequest->packetType)
6201 {
6202 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006203 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 break;
6205
6206 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6207
Arif Hussain6d2a3322013-11-17 19:50:10 -08006208 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006209 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006210
6211 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6212 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6213 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6214
6215 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6216 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6217 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6218
6219 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6220 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6221 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6222 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6223 break;
6224
6225 }
6226
6227 /* Execute keep alive request. The reason that we can copy the request information
6228 from the ioctl structure to the SME structure is that they are laid out
6229 exactly the same. Otherwise, each piece of information would have to be
6230 copied individually. */
6231 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6232
Arif Hussain6d2a3322013-11-17 19:50:10 -08006233 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006234
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006235 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006236 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006238 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 __func__);
6240 return -EINVAL;
6241 }
6242
6243 return 0;
6244}
6245
6246#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006247int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006248 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006249{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006250 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6251 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 int i=0;
6253
6254 if (pHddCtx->cfg_ini->disablePacketFilter)
6255 {
6256 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006257 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 return 0;
6259 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006260 if (pHddCtx->isLogpInProgress)
6261 {
6262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6263 "%s:LOGP in Progress. Ignore!!!", __func__);
6264 return -EBUSY;
6265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 /* Debug display of request components. */
6267 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006268 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006269
6270 switch (pRequest->filterAction)
6271 {
6272 case HDD_RCV_FILTER_SET:
6273 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006274 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006275
6276 packetFilterSetReq.filterId = pRequest->filterId;
6277 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6278 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006279 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 __func__, pRequest->numParams);
6281 return -EINVAL;
6282 }
6283 packetFilterSetReq.numFieldParams = pRequest->numParams;
6284 packetFilterSetReq.coalesceTime = 0;
6285 packetFilterSetReq.filterType = 1;
6286 for (i=0; i < pRequest->numParams; i++)
6287 {
6288 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6289 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6290 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6291 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6292 packetFilterSetReq.paramsData[i].reserved = 0;
6293
Arif Hussain6d2a3322013-11-17 19:50:10 -08006294 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6296 packetFilterSetReq.filterType);
6297
Arif Hussain6d2a3322013-11-17 19:50:10 -08006298 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6300
6301 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6302 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6303 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6304 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6305
Arif Hussain6d2a3322013-11-17 19:50:10 -08006306 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6308 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6309 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6310
Arif Hussain6d2a3322013-11-17 19:50:10 -08006311 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6313 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6314 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6315 }
6316
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006317 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006319 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 __func__);
6321 return -EINVAL;
6322 }
6323
6324 break;
6325
6326 case HDD_RCV_FILTER_CLEAR:
6327
Arif Hussain6d2a3322013-11-17 19:50:10 -08006328 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006329 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006331 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006333 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 __func__);
6335 return -EINVAL;
6336 }
6337 break;
6338
6339 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006340 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006341 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 return -EINVAL;
6343 }
6344 return 0;
6345}
6346
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306347int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6348 tANI_U8 sessionId)
6349{
6350 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6351 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6352
6353 if (NULL == pHddCtx)
6354 {
6355 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6356 return -EINVAL;
6357 }
6358
6359 if (pHddCtx->isLogpInProgress)
6360 {
6361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6362 "%s:LOGP in Progress. Ignore!!!", __func__);
6363 return -EBUSY;
6364 }
6365
6366 if (pHddCtx->cfg_ini->disablePacketFilter)
6367 {
6368 hddLog(VOS_TRACE_LEVEL_ERROR,
6369 "%s: Packet Filtering Disabled. Returning ",
6370 __func__ );
6371 return -EINVAL;
6372 }
6373
6374 switch (filterType)
6375 {
6376 /* For setting IPV6 MC and UC Filter we need to configure
6377 * 2 filters, one for MC and one for UC.
6378 * The Filter ID shouldn't be swapped, which results in making
6379 * UC Filter ineffective.
6380 * We have Hardcode all the values
6381 *
6382 * Reason for a seperate UC filter is because, driver need to
6383 * specify the FW that the specific filter is for unicast
6384 * otherwise FW will not pass the unicast frames by default
6385 * through the filter. This is required to avoid any performance
6386 * hits when no unicast filter is set and only MC/BC are set.
6387 * The way driver informs host is by using the MAC protocol
6388 * layer, CMP flag set to MAX, CMP Data set to 1.
6389 */
6390
6391 case HDD_FILTER_IPV6_MC_UC:
6392 /* Setting IPV6 MC Filter below
6393 */
6394 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6395 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6396 packetFilterSetReq.numFieldParams = 2;
6397 packetFilterSetReq.paramsData[0].protocolLayer =
6398 HDD_FILTER_PROTO_TYPE_MAC;
6399 packetFilterSetReq.paramsData[0].cmpFlag =
6400 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6401 packetFilterSetReq.paramsData[0].dataOffset =
6402 WLAN_HDD_80211_FRM_DA_OFFSET;
6403 packetFilterSetReq.paramsData[0].dataLength = 1;
6404 packetFilterSetReq.paramsData[0].compareData[0] =
6405 HDD_IPV6_MC_CMP_DATA;
6406
6407 packetFilterSetReq.paramsData[1].protocolLayer =
6408 HDD_FILTER_PROTO_TYPE_ARP;
6409 packetFilterSetReq.paramsData[1].cmpFlag =
6410 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6411 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6412 packetFilterSetReq.paramsData[1].dataLength = 2;
6413 packetFilterSetReq.paramsData[1].compareData[0] =
6414 HDD_IPV6_CMP_DATA_0;
6415 packetFilterSetReq.paramsData[1].compareData[1] =
6416 HDD_IPV6_CMP_DATA_1;
6417
6418
6419 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6420 &packetFilterSetReq, sessionId))
6421 {
6422 hddLog(VOS_TRACE_LEVEL_ERROR,
6423 "%s: Failure to execute Set IPv6 Mulicast Filter",
6424 __func__);
6425 return -EINVAL;
6426 }
6427
6428 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6429
6430 /*
6431 * Setting IPV6 UC Filter below
6432 */
6433 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6434 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6435 packetFilterSetReq.numFieldParams = 2;
6436 packetFilterSetReq.paramsData[0].protocolLayer =
6437 HDD_FILTER_PROTO_TYPE_MAC;
6438 packetFilterSetReq.paramsData[0].cmpFlag =
6439 HDD_FILTER_CMP_TYPE_MAX;
6440 packetFilterSetReq.paramsData[0].dataOffset = 0;
6441 packetFilterSetReq.paramsData[0].dataLength = 1;
6442 packetFilterSetReq.paramsData[0].compareData[0] =
6443 HDD_IPV6_UC_CMP_DATA;
6444
6445 packetFilterSetReq.paramsData[1].protocolLayer =
6446 HDD_FILTER_PROTO_TYPE_ARP;
6447 packetFilterSetReq.paramsData[1].cmpFlag =
6448 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6449 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6450 packetFilterSetReq.paramsData[1].dataLength = 2;
6451 packetFilterSetReq.paramsData[1].compareData[0] =
6452 HDD_IPV6_CMP_DATA_0;
6453 packetFilterSetReq.paramsData[1].compareData[1] =
6454 HDD_IPV6_CMP_DATA_1;
6455
6456 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6457 &packetFilterSetReq, sessionId))
6458 {
6459 hddLog(VOS_TRACE_LEVEL_ERROR,
6460 "%s: Failure to execute Set IPv6 Unicast Filter",
6461 __func__);
6462 return -EINVAL;
6463 }
6464
6465 break;
6466
6467 case HDD_FILTER_IPV6_MC:
6468 /*
6469 * IPV6 UC Filter might be already set,
6470 * clear the UC Filter. As the Filter
6471 * IDs are static, we can directly clear it.
6472 */
6473 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6474 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6475 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6476 &packetFilterClrReq, sessionId))
6477 {
6478 hddLog(VOS_TRACE_LEVEL_ERROR,
6479 "%s: Failure to execute Clear IPv6 Unicast Filter",
6480 __func__);
6481 return -EINVAL;
6482 }
6483
6484 /*
6485 * Setting IPV6 MC Filter below
6486 */
6487 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6488 packetFilterSetReq.numFieldParams = 2;
6489 packetFilterSetReq.paramsData[0].protocolLayer =
6490 HDD_FILTER_PROTO_TYPE_MAC;
6491 packetFilterSetReq.paramsData[0].cmpFlag =
6492 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6493 packetFilterSetReq.paramsData[0].dataOffset =
6494 WLAN_HDD_80211_FRM_DA_OFFSET;
6495 packetFilterSetReq.paramsData[0].dataLength = 1;
6496 packetFilterSetReq.paramsData[0].compareData[0] =
6497 HDD_IPV6_MC_CMP_DATA;
6498
6499 packetFilterSetReq.paramsData[1].protocolLayer =
6500 HDD_FILTER_PROTO_TYPE_ARP;
6501 packetFilterSetReq.paramsData[1].cmpFlag =
6502 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6503 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6504 packetFilterSetReq.paramsData[1].dataLength = 2;
6505 packetFilterSetReq.paramsData[1].compareData[0] =
6506 HDD_IPV6_CMP_DATA_0;
6507 packetFilterSetReq.paramsData[1].compareData[1] =
6508 HDD_IPV6_CMP_DATA_1;
6509
6510
6511 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6512 &packetFilterSetReq, sessionId))
6513 {
6514 hddLog(VOS_TRACE_LEVEL_ERROR,
6515 "%s: Failure to execute Set IPv6 Multicast Filter",
6516 __func__);
6517 return -EINVAL;
6518 }
6519 break;
6520
6521 default :
6522 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6523 "%s: Packet Filter Request: Invalid",
6524 __func__);
6525 return -EINVAL;
6526 }
6527 return 0;
6528}
6529
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306530void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006531{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306532 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306533 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006534 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306535 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006536
Yue Ma3ede6052013-08-29 00:33:26 -07006537 if (NULL == pHddCtx)
6538 {
6539 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6540 return;
6541 }
6542
6543 hHal = pHddCtx->hHal;
6544
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306545 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006546 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306547 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6548 return;
6549 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306550
6551 /* Check if INI is enabled or not, other wise just return
6552 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306553 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306554 {
6555 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6556 if (NULL == pMulticastAddrs)
6557 {
6558 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6559 return;
6560 }
6561
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 if (set)
6563 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306564 /* Following pre-conditions should be satisfied before wei
6565 * configure the MC address list.
6566 */
6567 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6568 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6569 && pAdapter->mc_addr_list.mc_cnt
6570 && (eConnectionState_Associated ==
6571 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6572 {
6573 pMulticastAddrs->ulMulticastAddrCnt =
6574 pAdapter->mc_addr_list.mc_cnt;
6575 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6576 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006577 memcpy(pMulticastAddrs->multicastAddr[i],
6578 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306579 sizeof(pAdapter->mc_addr_list.addr[i]));
6580 hddLog(VOS_TRACE_LEVEL_INFO,
6581 "%s: %s multicast filter: addr ="
6582 MAC_ADDRESS_STR,
6583 __func__, set ? "setting" : "clearing",
6584 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6585 }
6586 /* Set multicast filter */
6587 sme_8023MulticastList(hHal, pAdapter->sessionId,
6588 pMulticastAddrs);
6589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306591 else
6592 {
6593 /* Need to clear only if it was previously configured
6594 */
6595 if (pAdapter->mc_addr_list.isFilterApplied)
6596 {
6597 pMulticastAddrs->ulMulticastAddrCnt = 0;
6598 sme_8023MulticastList(hHal, pAdapter->sessionId,
6599 pMulticastAddrs);
6600 }
6601
6602 }
6603 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006604 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306606 else
6607 {
6608 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306609 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306610 }
6611 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006612}
6613
6614static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6615 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306616{
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006618 tpPacketFilterCfg pRequest = NULL;
6619 int ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006620
Arif Hussain0273cba2014-01-07 20:58:29 -08006621 /* ODD number is used for set, copy data using copy_from_user */
6622 pRequest = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
6623 wrqu->data.length);
6624 if (NULL == pRequest)
6625 {
6626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6627 "mem_alloc_copy_from_user_helper fail");
6628 return -ENOMEM;
6629 }
6630
6631 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6632 kfree(pRequest);
6633
6634 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006635}
6636#endif
6637static int iw_get_statistics(struct net_device *dev,
6638 struct iw_request_info *info,
6639 union iwreq_data *wrqu, char *extra)
6640{
6641
6642 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6643 eHalStatus status = eHAL_STATUS_SUCCESS;
6644 hdd_wext_state_t *pWextState;
6645 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6646 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6647 char *p = extra;
6648 int tlen = 0;
6649 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6650
6651 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6652 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6653
6654 ENTER();
6655
6656 if (pHddCtx->isLogpInProgress) {
6657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6658 return -EINVAL;
6659 }
6660
6661 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6662
6663 wrqu->txpower.value = 0;
6664 }
6665 else {
6666 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6667 SME_SUMMARY_STATS |
6668 SME_GLOBAL_CLASSA_STATS |
6669 SME_GLOBAL_CLASSB_STATS |
6670 SME_GLOBAL_CLASSC_STATS |
6671 SME_GLOBAL_CLASSD_STATS |
6672 SME_PER_STA_STATS,
6673 hdd_StatisticsCB, 0, FALSE,
6674 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6675
6676 if (eHAL_STATUS_SUCCESS != status)
6677 {
6678 hddLog(VOS_TRACE_LEVEL_ERROR,
6679 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006680 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 return -EINVAL;
6682 }
6683
6684 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6685
6686 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6687 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6688 {
6689 hddLog(VOS_TRACE_LEVEL_ERROR,
6690 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006691 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 /*Remove the SME statistics list by passing NULL in callback argument*/
6693 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6694 SME_SUMMARY_STATS |
6695 SME_GLOBAL_CLASSA_STATS |
6696 SME_GLOBAL_CLASSB_STATS |
6697 SME_GLOBAL_CLASSC_STATS |
6698 SME_GLOBAL_CLASSD_STATS |
6699 SME_PER_STA_STATS,
6700 NULL, 0, FALSE,
6701 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6702
6703 return -EINVAL;
6704 }
6705 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6706 (tANI_U8) sizeof (pStats->retry_cnt),
6707 (char*) &(pStats->retry_cnt[0]),
6708 tlen);
6709
6710 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6711 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6712 (char*) &(pStats->multiple_retry_cnt[0]),
6713 tlen);
6714
6715 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6716 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6717 (char*) &(pStats->tx_frm_cnt[0]),
6718 tlen);
6719
6720 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6721 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6722 (char*) &(pStats->rx_frm_cnt),
6723 tlen);
6724
6725 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6726 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6727 (char*) &(pStats->frm_dup_cnt),
6728 tlen);
6729
6730 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6731 (tANI_U8) sizeof (pStats->fail_cnt),
6732 (char*) &(pStats->fail_cnt[0]),
6733 tlen);
6734
6735 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6736 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6737 (char*) &(pStats->rts_fail_cnt),
6738 tlen);
6739
6740 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6741 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6742 (char*) &(pStats->ack_fail_cnt),
6743 tlen);
6744
6745 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6746 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6747 (char*) &(pStats->rts_succ_cnt),
6748 tlen);
6749
6750 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6751 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6752 (char*) &(pStats->rx_discard_cnt),
6753 tlen);
6754
6755 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6756 (tANI_U8) sizeof (pStats->rx_error_cnt),
6757 (char*) &(pStats->rx_error_cnt),
6758 tlen);
6759
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006760 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006761 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006762 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 tlen);
6764
6765 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6766 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6767 (char*) &(dStats->rx_byte_cnt),
6768 tlen);
6769
6770 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6771 (tANI_U8) sizeof (dStats->rx_rate),
6772 (char*) &(dStats->rx_rate),
6773 tlen);
6774
6775 /* Transmit rate, in units of 500 kbit/sec */
6776 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6777 (tANI_U8) sizeof (aStats->tx_rate),
6778 (char*) &(aStats->tx_rate),
6779 tlen);
6780
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006781 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6782 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6783 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006784 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006785 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6786 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6787 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006788 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006789 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6790 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6791 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006792 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006793 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6794 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6795 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006796 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006797 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6798 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6799 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006800 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006801 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6802 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6803 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006804 tlen);
6805
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 wrqu->data.length = tlen;
6807
6808 }
6809
6810 EXIT();
6811
6812 return 0;
6813}
6814
6815
6816#ifdef FEATURE_WLAN_SCAN_PNO
6817
6818/*Max Len for PNO notification*/
6819#define MAX_PNO_NOTIFY_LEN 100
6820void found_pref_network_cb (void *callbackContext,
6821 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6822{
6823 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6824 union iwreq_data wrqu;
6825 char buf[MAX_PNO_NOTIFY_LEN+1];
6826
6827 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6828 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6829
6830 // create the event
6831 memset(&wrqu, 0, sizeof(wrqu));
6832 memset(buf, 0, sizeof(buf));
6833
6834 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6835 pPrefNetworkFoundInd->ssId.ssId,
6836 (unsigned int)pPrefNetworkFoundInd->rssi);
6837
6838 wrqu.data.pointer = buf;
6839 wrqu.data.length = strlen(buf);
6840
6841 // send the event
6842
6843 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6844
6845}
6846
6847
6848/*string based input*/
6849VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6850 union iwreq_data *wrqu, char *extra, int nOffset)
6851{
6852 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006853 /* pnoRequest is a large struct, so we make it static to avoid stack
6854 overflow. This API is only invoked via ioctl, so it is
6855 serialized by the kernel rtnl_lock and hence does not need to be
6856 reentrant */
6857 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 char *ptr;
6859 v_U8_t i,j, ucParams, ucMode;
6860 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6861
6862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6863 "PNO data len %d data %s",
6864 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006865 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006866
6867 if (wrqu->data.length <= nOffset )
6868 {
6869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6870 return VOS_STATUS_E_FAILURE;
6871 }
6872
6873 pnoRequest.enable = 0;
6874 pnoRequest.ucNetworksCount = 0;
6875 /*-----------------------------------------------------------------------
6876 Input is string based and expected to be like this:
6877
6878 <enabled> <netw_count>
6879 for each network:
6880 <ssid_len> <ssid> <authentication> <encryption>
6881 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6882 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6883
6884 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006885 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 -07006886
6887 this translates into:
6888 -----------------------------
6889 enable PNO
6890 look for 2 networks:
6891 test - with authentication type 0 and encryption type 0,
6892 that can be found on 3 channels: 1 6 and 11 ,
6893 SSID bcast type is unknown (directed probe will be sent if AP not found)
6894 and must meet -40dBm RSSI
6895
6896 test2 - with auth and enrytption type 4/4
6897 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6898 bcast type is non-bcast (directed probe will be sent)
6899 and must not meet any RSSI threshold
6900
Jeff Johnson8301aa12013-03-28 14:27:29 -07006901 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006903 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006904
Wilson Yang623f6592013-10-08 16:33:37 -07006905 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6906 {
6907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6908 "PNO enable input is not valid %s",ptr);
6909 return VOS_STATUS_E_FAILURE;
6910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006911
6912 if ( 0 == pnoRequest.enable )
6913 {
6914 /*Disable PNO*/
6915 memset(&pnoRequest, 0, sizeof(pnoRequest));
6916 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
6917 pAdapter->sessionId,
6918 found_pref_network_cb, pAdapter);
6919 return VOS_STATUS_SUCCESS;
6920 }
6921
6922 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006923
6924 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6925 {
6926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6927 "PNO count input not valid %s",ptr);
6928 return VOS_STATUS_E_FAILURE;
6929
6930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006931
6932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6933 "PNO enable %d networks count %d offset %d",
6934 pnoRequest.enable,
6935 pnoRequest.ucNetworksCount,
6936 nOffset);
6937
6938 /* Parameters checking:
6939 ucNetworksCount has to be larger than 0*/
6940 if (( 0 == pnoRequest.ucNetworksCount ) ||
6941 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6942 {
6943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
6944 return VOS_STATUS_E_FAILURE;
6945 }
6946
6947 ptr += nOffset;
6948
6949 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6950 {
6951
6952 pnoRequest.aNetworks[i].ssId.length = 0;
6953
Wilson Yang623f6592013-10-08 16:33:37 -07006954 ucParams = sscanf(ptr,"%hhu %n",
6955 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6956
6957 if (1 != ucParams)
6958 {
6959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6960 "PNO ssid length input is not valid %s",ptr);
6961 return VOS_STATUS_E_FAILURE;
6962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006963
6964 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6965 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6966 {
6967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6968 "SSID Len %d is not correct for network %d",
6969 pnoRequest.aNetworks[i].ssId.length, i);
6970 return VOS_STATUS_E_FAILURE;
6971 }
6972
6973 /*Advance to SSID*/
6974 ptr += nOffset;
6975
Jeff Johnson8301aa12013-03-28 14:27:29 -07006976 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006977 pnoRequest.aNetworks[i].ssId.length);
6978 ptr += pnoRequest.aNetworks[i].ssId.length;
6979
Jeff Johnson02797792013-10-26 19:17:13 -07006980 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006981 &(pnoRequest.aNetworks[i].authentication),
6982 &(pnoRequest.aNetworks[i].encryption),
6983 &(pnoRequest.aNetworks[i].ucChannelCount),
6984 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006985
Wilson Yang623f6592013-10-08 16:33:37 -07006986 if ( 3 != ucParams )
6987 {
6988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6989 "Incorrect cmd %s",ptr);
6990 return VOS_STATUS_E_FAILURE;
6991 }
6992
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006994 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006995 "auth %d encry %d channel count %d offset %d",
6996 pnoRequest.aNetworks[i].ssId.length,
6997 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6998 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6999 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7000 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7001 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7002 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7003 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7004 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7005 pnoRequest.aNetworks[i].authentication,
7006 pnoRequest.aNetworks[i].encryption,
7007 pnoRequest.aNetworks[i].ucChannelCount,
7008 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007009
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 /*Advance to channel list*/
7011 ptr += nOffset;
7012
Wilson Yang623f6592013-10-08 16:33:37 -07007013 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 {
7015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7016 "Incorrect number of channels");
7017 return VOS_STATUS_E_FAILURE;
7018 }
7019
7020 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7021 {
7022 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7023 {
Wilson Yang623f6592013-10-08 16:33:37 -07007024 if (1 != sscanf(ptr,"%hhu %n",
7025 &(pnoRequest.aNetworks[i].aChannels[j]),
7026 &nOffset))
7027 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7028 "PNO network channel input is not valid %s",ptr);
7029 return VOS_STATUS_E_FAILURE;
7030 }
7031 /*Advance to next channel number*/
7032 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 }
7034 }
7035
Jeff Johnson02797792013-10-26 19:17:13 -07007036 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007037 &(pnoRequest.aNetworks[i].bcastNetwType),
7038 &nOffset))
7039 {
7040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7041 "PNO broadcast network type input is not valid %s",ptr);
7042 return VOS_STATUS_E_FAILURE;
7043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007044
7045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7046 "PNO bcastNetwType %d offset %d",
7047 pnoRequest.aNetworks[i].bcastNetwType,
7048 nOffset );
7049
7050 /*Advance to rssi Threshold*/
7051 ptr += nOffset;
7052
Wilson Yang623f6592013-10-08 16:33:37 -07007053 if (1 != sscanf(ptr,"%hhu %n",
7054 &(pnoRequest.aNetworks[i].rssiThreshold),
7055 &nOffset))
7056 {
7057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7058 "PNO rssi threshold input is not valid %s",ptr);
7059 return VOS_STATUS_E_FAILURE;
7060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007061
7062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7063 "PNO rssi %d offset %d",
7064 pnoRequest.aNetworks[i].rssiThreshold,
7065 nOffset );
7066 /*Advance to next network*/
7067 ptr += nOffset;
7068 }/*For ucNetworkCount*/
7069
7070 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007071 &(pnoRequest.scanTimers.ucScanTimersCount),
7072 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007073
7074 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007075 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 {
7077 ptr += nOffset;
7078
Jeff Johnson8301aa12013-03-28 14:27:29 -07007079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7080 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 pnoRequest.scanTimers.ucScanTimersCount,
7082 nOffset );
7083
7084 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7085 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 "Incorrect cmd - too many scan timers");
7088 return VOS_STATUS_E_FAILURE;
7089 }
7090
7091 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7092 {
Jeff Johnson02797792013-10-26 19:17:13 -07007093 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7095 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7096 &nOffset);
7097
Wilson Yang623f6592013-10-08 16:33:37 -07007098 if (2 != ucParams)
7099 {
7100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7101 "Incorrect cmd - diff params then expected %d", ucParams);
7102 return VOS_STATUS_E_FAILURE;
7103 }
7104
Jeff Johnson8301aa12013-03-28 14:27:29 -07007105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7106 "PNO Timer value %d Timer repeat %d offset %d",
7107 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7109 nOffset );
7110
Jeff Johnson295189b2012-06-20 16:38:30 -07007111 ptr += nOffset;
7112 }
7113
7114 }
7115 else
7116 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7118 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7120
7121 /*Scan timers defaults to 5 minutes*/
7122 pnoRequest.scanTimers.ucScanTimersCount = 1;
7123 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7124 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7125 }
7126
Wilson Yang623f6592013-10-08 16:33:37 -07007127 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007128
7129 pnoRequest.modePNO = ucMode;
7130 /*for LA we just expose suspend option*/
7131 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7132 {
7133 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7134 }
7135
7136 sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
7137 pAdapter->sessionId,
7138 found_pref_network_cb, pAdapter);
7139
7140 return VOS_STATUS_SUCCESS;
7141}/*iw_set_pno*/
7142
7143VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7144 union iwreq_data *wrqu, char *extra, int nOffset)
7145{
7146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7147 v_U8_t rssiThreshold = 0;
7148 v_U8_t nRead;
7149
Arif Hussain7adce1b2013-11-11 22:59:34 -08007150 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 &rssiThreshold);
7152
7153 if ( 1 != nRead )
7154 {
7155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7156 "Incorrect format");
7157 return VOS_STATUS_E_FAILURE;
7158 }
7159
7160 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7161 return VOS_STATUS_SUCCESS;
7162}
7163
7164
7165static int iw_set_pno_priv(struct net_device *dev,
7166 struct iw_request_info *info,
7167 union iwreq_data *wrqu, char *extra)
7168{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7170
7171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007173
7174 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7175 {
7176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7177 "%s:LOGP in Progress. Ignore!!!", __func__);
7178 return -EBUSY;
7179 }
7180 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007181}
7182#endif /*FEATURE_WLAN_SCAN_PNO*/
7183
7184//Common function to SetBand
7185int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
7186{
7187 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7188 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7189 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7190 tANI_U8 band = 0;
7191 eCsrBand currBand = eCSR_BAND_MAX;
7192
7193 band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
7194
7195 switch(band)
7196 {
7197 case WLAN_HDD_UI_BAND_AUTO:
7198 band = eCSR_BAND_ALL;
7199 break;
7200 case WLAN_HDD_UI_BAND_5_GHZ:
7201 band = eCSR_BAND_5G;
7202 break;
7203 case WLAN_HDD_UI_BAND_2_4_GHZ:
7204 band = eCSR_BAND_24;
7205 break;
7206 default:
7207 band = eCSR_BAND_MAX;
7208 }
7209
7210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007211 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007212
7213 if (band == eCSR_BAND_MAX)
7214 {
7215 /* Received change band request with invalid band value */
7216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007217 "%s: Invalid band value %u", __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 return -EIO;
7219 }
7220
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307221 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7222 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7223 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7224 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007226 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007227 band, pHddCtx->cfg_ini->nBandCapability);
7228 return -EIO;
7229 }
7230
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7232 {
7233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7234 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007235 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 return -EIO;
7237 }
7238
7239 if (currBand != band)
7240 {
7241 /* Change band request received.
7242 * Abort pending scan requests, flush the existing scan results,
7243 * and change the band capability
7244 */
7245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7246 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007247 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007248
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307249 /* We need to change the band and flush the scan results here itself
7250 * as we may get timeout for disconnection in which we will return
7251 * with out doing any of these
7252 */
7253 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7254 {
7255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7256 "%s: failed to set the band value to %u ",
7257 __func__, band);
7258 return -EINVAL;
7259 }
7260 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7261 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7262 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7263 sme_FilterScanResults(hHal, pAdapter->sessionId);
7264
7265 if (band != eCSR_BAND_ALL &&
7266 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 {
7268 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7269 eHalStatus status = eHAL_STATUS_SUCCESS;
7270 long lrc;
7271
7272 /* STA already connected on current band, So issue disconnect first,
7273 * then change the band*/
7274
7275 hddLog(VOS_TRACE_LEVEL_INFO,
7276 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect",
7277 __func__, csrGetCurrentBand(hHal), band);
7278
7279 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7280 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7281
7282 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7283 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7284
Jeff Johnson43971f52012-07-17 12:26:56 -07007285 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 {
7287 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007288 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 __func__, (int)status );
7290 return -EINVAL;
7291 }
7292
7293 lrc = wait_for_completion_interruptible_timeout(
7294 &pAdapter->disconnect_comp_var,
7295 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7296
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307297 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007298
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007299 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007300 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007301
7302 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7303 }
7304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 }
7306 return 0;
7307}
7308
7309static int iw_set_band_config(struct net_device *dev,
7310 struct iw_request_info *info,
7311 union iwreq_data *wrqu, char *extra)
7312{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007313 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007314 tANI_U8 *ptr = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 int ret = 0;
7316
Arif Hussain0273cba2014-01-07 20:58:29 -08007317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007318
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007319 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7320 {
7321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7322 "%s:LOGP in Progress. Ignore!!!", __func__);
7323 return -EBUSY;
7324 }
7325
Arif Hussain0273cba2014-01-07 20:58:29 -08007326 /* ODD number is used for set, copy data using copy_from_user */
7327 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7328 wrqu->data.length);
7329 if (NULL == ptr)
7330 {
7331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7332 "mem_alloc_copy_from_user_helper fail");
7333 return -ENOMEM;
7334 }
7335
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 if (memcmp(ptr, "SETBAND ", 8) == 0)
7337 {
7338 /* Change band request received */
7339 ret = hdd_setBand_helper(dev, ptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 }
Arif Hussain0273cba2014-01-07 20:58:29 -08007341 kfree(ptr);
7342
7343 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007344}
7345
7346static int iw_set_power_params_priv(struct net_device *dev,
7347 struct iw_request_info *info,
7348 union iwreq_data *wrqu, char *extra)
7349{
Arif Hussain0273cba2014-01-07 20:58:29 -08007350 int ret;
7351 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7353 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007354 /* ODD number is used for set, copy data using copy_from_user */
7355 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7356 wrqu->data.length);
7357 if (NULL == ptr)
7358 {
7359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7360 "mem_alloc_copy_from_user_helper fail");
7361 return -ENOMEM;
7362 }
7363
7364 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7365 kfree(ptr);
7366 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007367}
7368
7369
7370
7371/*string based input*/
7372VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7373 union iwreq_data *wrqu, char *extra, int nOffset)
7374{
7375 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7376 tSirSetPowerParamsReq powerRequest;
7377 char *ptr;
7378 v_U8_t ucType;
7379 v_U32_t uTotalSize, uValue;
7380 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7381
7382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7383 "Power Params data len %d data %s",
7384 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007385 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007386
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007387 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7388 {
7389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7390 "%s:LOGP in Progress. Ignore!!!", __func__);
7391 return -EBUSY;
7392 }
7393
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 if (wrqu->data.length <= nOffset )
7395 {
7396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7397 return VOS_STATUS_E_FAILURE;
7398 }
7399
7400 uTotalSize = wrqu->data.length - nOffset;
7401
7402 /*-----------------------------------------------------------------------
7403 Input is string based and expected to be like this:
7404
7405 <param_type> <param_value> <param_type> <param_value> ...
7406
7407 e.g:
7408 1 2 2 3 3 0 4 1 5 1
7409
7410 e.g. setting just a few:
7411 1 2 4 1
7412
7413 parameter types:
7414 -----------------------------
7415 1 - Ignore DTIM
7416 2 - Listen Interval
7417 3 - Broadcast Multicas Filter
7418 4 - Beacon Early Termination
7419 5 - Beacon Early Termination Interval
7420 -----------------------------------------------------------------------*/
7421 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7422 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7423 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7424 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7425 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7426
Arif Hussain7adce1b2013-11-11 22:59:34 -08007427 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
7429 while ( uTotalSize )
7430 {
Wilson Yang6f971452013-10-08 15:00:00 -07007431 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7432 {
7433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7434 "Invalid input parameter type %s",ptr);
7435 return VOS_STATUS_E_FAILURE;
7436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007437
7438 uTotalSize -= nOffset;
7439
7440 if (!uTotalSize)
7441 {
7442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007443 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 ucType, nOffset);
7445 return VOS_STATUS_E_FAILURE;
7446 }
7447
7448 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007449
Jeff Johnson02797792013-10-26 19:17:13 -07007450 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007451 {
7452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7453 "Invalid input parameter value %s",ptr);
7454 return VOS_STATUS_E_FAILURE;
7455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007456
7457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7458 "Power request parameter %d value %d offset %d",
7459 ucType, uValue, nOffset);
7460
7461 switch (ucType)
7462 {
7463 case eSIR_IGNORE_DTIM:
7464 powerRequest.uIgnoreDTIM = uValue;
7465 break;
7466 case eSIR_LISTEN_INTERVAL:
7467 powerRequest.uListenInterval = uValue;
7468 break;
7469 case eSIR_MCAST_BCAST_FILTER:
7470 powerRequest.uBcastMcastFilter = uValue;
7471 break;
7472 case eSIR_ENABLE_BET:
7473 powerRequest.uEnableBET = uValue;
7474 break;
7475 case eSIR_BET_INTERVAL:
7476 powerRequest.uBETInterval = uValue;
7477 break;
7478 default:
7479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007480 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 ucType, uValue, nOffset);
7482 return VOS_STATUS_E_FAILURE;
7483 }
7484
7485 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7487 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007488 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007490 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007491 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007492 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7493 {
7494 uTotalSize = 0;
7495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007496
7497 }/*Go for as long as we have a valid string*/
7498
7499 /* put the device into full power*/
7500 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7501
7502 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007503 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007504
7505 /* put the device back to power save*/
7506 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7507
7508 return VOS_STATUS_SUCCESS;
7509}/*iw_set_power_params*/
7510
7511
7512// Define the Wireless Extensions to the Linux Network Device structure
7513// A number of these routines are NULL (meaning they are not implemented.)
7514
7515static const iw_handler we_handler[] =
7516{
7517 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7518 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7519 (iw_handler) NULL, /* SIOCSIWNWID */
7520 (iw_handler) NULL, /* SIOCGIWNWID */
7521 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7522 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7523 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7524 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7525 (iw_handler) NULL, /* SIOCSIWSENS */
7526 (iw_handler) NULL, /* SIOCGIWSENS */
7527 (iw_handler) NULL, /* SIOCSIWRANGE */
7528 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7529 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7530 (iw_handler) NULL, /* SIOCGIWPRIV */
7531 (iw_handler) NULL, /* SIOCSIWSTATS */
7532 (iw_handler) NULL, /* SIOCGIWSTATS */
7533 iw_handler_set_spy, /* SIOCSIWSPY */
7534 iw_handler_get_spy, /* SIOCGIWSPY */
7535 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7536 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7537 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7538 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7539 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7540 (iw_handler) NULL, /* SIOCGIWAPLIST */
7541 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7542 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7543 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7544 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7545 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7546 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7547 (iw_handler) NULL, /* -- hole -- */
7548 (iw_handler) NULL, /* -- hole -- */
7549 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7550 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7551 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7552 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7553 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7554 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7555 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7556 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7557 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7558 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7559 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7560 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7561 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7562 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7563 (iw_handler) NULL, /* -- hole -- */
7564 (iw_handler) NULL, /* -- hole -- */
7565 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7566 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7567 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7568 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7569 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7570 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7571 (iw_handler) NULL, /* SIOCSIWPMKSA */
7572};
7573
7574static const iw_handler we_private[] = {
7575
7576 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7577 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7578 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7579 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7580 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7581 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7582 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7583 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7584 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7585 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007586#ifdef FEATURE_OEM_DATA_SUPPORT
7587 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7588 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007590
7591#ifdef FEATURE_WLAN_WAPI
7592 [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode,
7593 [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode,
7594 [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info,
7595 [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key,
7596 [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid,
7597 [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid,
7598#endif /* FEATURE_WLAN_WAPI */
7599#ifdef WLAN_FEATURE_VOWIFI_11R
7600 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7601#endif
7602 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7603 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7604 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7605#ifdef WLAN_FEATURE_PACKET_FILTERING
7606 ,
7607 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7608#endif
7609#ifdef FEATURE_WLAN_SCAN_PNO
7610 ,
7611 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7612#endif
7613 ,
7614 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7615 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7616 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7617 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007618 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
Jeff Johnson295189b2012-06-20 16:38:30 -07007619};
7620
7621/*Maximum command length can be only 15 */
7622static const struct iw_priv_args we_private_args[] = {
7623
7624 /* handlers for main ioctl */
7625 { WLAN_PRIV_SET_INT_GET_NONE,
7626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7627 0,
7628 "" },
7629
7630 /* handlers for sub-ioctl */
7631 { WE_SET_11D_STATE,
7632 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7633 0,
7634 "set11Dstate" },
7635
7636 { WE_WOWL,
7637 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7638 0,
7639 "wowl" },
7640
7641 { WE_SET_POWER,
7642 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7643 0,
7644 "setPower" },
7645
7646 { WE_SET_MAX_ASSOC,
7647 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7648 0,
7649 "setMaxAssoc" },
7650
7651 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7652 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7653 0,
7654 "setAutoChannel" },
7655
7656 { WE_SET_DATA_INACTIVITY_TO,
7657 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7658 0,
7659 "inactivityTO" },
7660
7661 { WE_SET_MAX_TX_POWER,
7662 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7663 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007664 "setMaxTxPower" },
7665
7666 { WE_SET_MAX_TX_POWER_2_4,
7667 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7668 0,
7669 "setTxMaxPower2G" },
7670
7671 { WE_SET_MAX_TX_POWER_5_0,
7672 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7673 0,
7674 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007675
7676 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7677 * as well to keep same syntax as in SAP. Now onwards, STA
7678 * will support both */
7679 { WE_SET_MAX_TX_POWER,
7680 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7681 0,
7682 "setTxMaxPower" },
7683
Jeff Johnson295189b2012-06-20 16:38:30 -07007684 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7685 * 1 = enable and 0 = disable */
7686 {
7687 WE_SET_HIGHER_DTIM_TRANSITION,
7688 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7689 0,
7690 "setHDtimTransn" },
7691
7692 { WE_SET_TM_LEVEL,
7693 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007694 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 "setTmLevel" },
7696
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307697 { WE_ENABLE_STRICT_FCC_REG,
7698 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7699 0,
7700 "setStrictFCCreg" },
7701
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007702 { WE_SET_DEBUG_LOG,
7703 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7704 0, "setDbgLvl" },
7705
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 /* handlers for main ioctl */
7707 { WLAN_PRIV_SET_NONE_GET_INT,
7708 0,
7709 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7710 "" },
7711
7712 /* handlers for sub-ioctl */
7713 { WE_GET_11D_STATE,
7714 0,
7715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7716 "get11Dstate" },
7717
7718 { WE_IBSS_STATUS,
7719 0,
7720 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7721 "getAdhocStatus" },
7722
7723 { WE_PMC_STATE,
7724 0,
7725 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7726 "pmcState" },
7727
7728 { WE_GET_WLAN_DBG,
7729 0,
7730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7731 "getwlandbg" },
7732
7733 { WE_MODULE_DOWN_IND,
7734 0,
7735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7736 "moduleDownInd" },
7737
7738 { WE_GET_MAX_ASSOC,
7739 0,
7740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7741 "getMaxAssoc" },
7742
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 { WE_GET_WDI_DBG,
7744 0,
7745 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7746 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007747
7748 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7749 0,
7750 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7751 "getAutoChannel" },
7752
7753 { WE_GET_CONCURRENCY_MODE,
7754 0,
7755 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7756 "getconcurrency" },
7757
7758 /* handlers for main ioctl */
7759 { WLAN_PRIV_SET_CHAR_GET_NONE,
7760 IW_PRIV_TYPE_CHAR| 512,
7761 0,
7762 "" },
7763
7764 /* handlers for sub-ioctl */
7765 { WE_WOWL_ADD_PTRN,
7766 IW_PRIV_TYPE_CHAR| 512,
7767 0,
7768 "wowlAddPtrn" },
7769
7770 { WE_WOWL_DEL_PTRN,
7771 IW_PRIV_TYPE_CHAR| 512,
7772 0,
7773 "wowlDelPtrn" },
7774
7775#if defined WLAN_FEATURE_VOWIFI
7776 /* handlers for sub-ioctl */
7777 { WE_NEIGHBOR_REPORT_REQUEST,
7778 IW_PRIV_TYPE_CHAR | 512,
7779 0,
7780 "neighbor" },
7781#endif
7782 { WE_SET_AP_WPS_IE,
7783 IW_PRIV_TYPE_CHAR| 512,
7784 0,
7785 "set_ap_wps_ie" },
7786
7787 { WE_SET_CONFIG,
7788 IW_PRIV_TYPE_CHAR| 512,
7789 0,
7790 "setConfig" },
7791
7792 /* handlers for main ioctl */
7793 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7794 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7795 0,
7796 "" },
7797
7798 /* handlers for sub-ioctl */
7799 { WE_SET_WLAN_DBG,
7800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7801 0,
7802 "setwlandbg" },
7803
Jeff Johnson295189b2012-06-20 16:38:30 -07007804 { WE_SET_WDI_DBG,
7805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7806 0,
7807 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007808
7809 { WE_SET_SAP_CHANNELS,
7810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7811 0,
7812 "setsapchannels" },
7813
7814 /* handlers for main ioctl */
7815 { WLAN_PRIV_GET_CHAR_SET_NONE,
7816 0,
7817 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7818 "" },
7819
7820 /* handlers for sub-ioctl */
7821 { WE_WLAN_VERSION,
7822 0,
7823 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7824 "version" },
7825 { WE_GET_STATS,
7826 0,
7827 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7828 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307829 { WE_GET_STATES,
7830 0,
7831 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7832 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 { WE_GET_CFG,
7834 0,
7835 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7836 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007837#ifdef WLAN_FEATURE_11AC
7838 { WE_GET_RSSI,
7839 0,
7840 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7841 "getRSSI" },
7842#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007843#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007844 { WE_GET_ROAM_RSSI,
7845 0,
7846 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7847 "getRoamRSSI" },
7848#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 { WE_GET_WMM_STATUS,
7850 0,
7851 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7852 "getWmmStatus" },
7853 {
7854 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307855 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007856 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7857 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007858#ifdef FEATURE_WLAN_TDLS
7859 {
7860 WE_GET_TDLS_PEERS,
7861 0,
7862 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7863 "getTdlsPeers" },
7864#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007865#ifdef WLAN_FEATURE_11W
7866 {
7867 WE_GET_11W_INFO,
7868 0,
7869 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7870 "getPMFInfo" },
7871#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 /* handlers for main ioctl */
7873 { WLAN_PRIV_SET_NONE_GET_NONE,
7874 0,
7875 0,
7876 "" },
7877
7878 /* handlers for sub-ioctl */
7879 { WE_CLEAR_STATS,
7880 0,
7881 0,
7882 "clearStats" },
7883 { WE_INIT_AP,
7884 0,
7885 0,
7886 "initAP" },
7887 { WE_STOP_AP,
7888 0,
7889 0,
7890 "exitAP" },
7891 { WE_ENABLE_AMP,
7892 0,
7893 0,
7894 "enableAMP" },
7895 { WE_DISABLE_AMP,
7896 0,
7897 0,
7898 "disableAMP" },
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007899 { WE_ENABLE_DXE_STALL_DETECT,
7900 0,
7901 0,
7902 "dxeStallDetect" },
7903 { WE_DISPLAY_DXE_SNAP_SHOT,
7904 0,
7905 0,
7906 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307907 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7908 0,
7909 0,
7910 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007911 {
7912 WE_SET_REASSOC_TRIGGER,
7913 0,
7914 0,
7915 "reassoc" },
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307916 {
7917 WE_STOP_OBSS_SCAN,
7918 0,
7919 0,
7920 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007921
7922 /* handlers for main ioctl */
7923 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7924 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7925 0,
7926 "" },
7927
7928 /* handlers for sub-ioctl */
7929 { WE_LOG_DUMP_CMD,
7930 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7931 0,
7932 "dump" },
7933
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007934 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307935 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
7936 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7937 0,
7938 "setdumplog" },
7939
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007940 { WE_MTRACE_DUMP_CMD,
7941 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7942 0,
7943 "dumplog" },
7944
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007945 /* handlers for sub ioctl */
7946 {
7947 WE_MCC_CONFIG_CREDENTIAL,
7948 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7949 0,
7950 "setMccCrdnl" },
7951
7952 /* handlers for sub ioctl */
7953 {
7954 WE_MCC_CONFIG_PARAMS,
7955 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7956 0,
7957 "setMccConfig" },
7958
Chilam NG571c65a2013-01-19 12:27:36 +05307959#ifdef FEATURE_WLAN_TDLS
7960 /* handlers for sub ioctl */
7961 {
7962 WE_TDLS_CONFIG_PARAMS,
7963 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7964 0,
7965 "setTdlsConfig" },
7966#endif
7967
Jeff Johnson295189b2012-06-20 16:38:30 -07007968 /* handlers for main ioctl */
7969 { WLAN_PRIV_ADD_TSPEC,
7970 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7971 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7972 "addTspec" },
7973
7974 /* handlers for main ioctl */
7975 { WLAN_PRIV_DEL_TSPEC,
7976 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7977 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7978 "delTspec" },
7979
7980 /* handlers for main ioctl */
7981 { WLAN_PRIV_GET_TSPEC,
7982 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7983 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7984 "getTspec" },
7985
Jeff Johnsone7245742012-09-05 17:12:55 -07007986#ifdef FEATURE_OEM_DATA_SUPPORT
7987 /* handlers for main ioctl - OEM DATA */
7988 {
7989 WLAN_PRIV_SET_OEM_DATA_REQ,
7990 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7991 0,
7992 "set_oem_data_req" },
7993
7994 /* handlers for main ioctl - OEM DATA */
7995 {
7996 WLAN_PRIV_GET_OEM_DATA_RSP,
7997 0,
7998 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7999 "get_oem_data_rsp" },
8000#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008001
8002#ifdef FEATURE_WLAN_WAPI
8003 /* handlers for main ioctl SET_WAPI_MODE */
8004 { WLAN_PRIV_SET_WAPI_MODE,
8005 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8006 0,
8007 "SET_WAPI_MODE" },
8008
8009 /* handlers for main ioctl GET_WAPI_MODE */
8010 { WLAN_PRIV_GET_WAPI_MODE,
8011 0,
8012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8013 "GET_WAPI_MODE" },
8014
8015 /* handlers for main ioctl SET_ASSOC_INFO */
8016 { WLAN_PRIV_SET_WAPI_ASSOC_INFO,
8017 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400,
8018 0,
8019 "SET_WAPI_ASSOC" },
8020
8021 /* handlers for main ioctl SET_WAPI_KEY */
8022 { WLAN_PRIV_SET_WAPI_KEY,
8023 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71,
8024 0,
8025 "SET_WAPI_KEY" },
8026
8027 /* handlers for main ioctl SET_WAPI_BKID */
8028 { WLAN_PRIV_SET_WAPI_BKID,
8029 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8030 0,
8031 "SET_WAPI_BKID" },
8032
8033 /* handlers for main ioctl GET_WAPI_BKID */
8034 { WLAN_PRIV_GET_WAPI_BKID,
8035 0,
8036 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24,
8037 "GET_WAPI_BKID" },
8038#endif /* FEATURE_WLAN_WAPI */
8039
8040 /* handlers for main ioctl - host offload */
8041 {
8042 WLAN_PRIV_SET_HOST_OFFLOAD,
8043 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8044 0,
8045 "setHostOffload" },
8046
8047 {
8048 WLAN_GET_WLAN_STATISTICS,
8049 0,
8050 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8051 "getWlanStats" },
8052
8053 {
8054 WLAN_SET_KEEPALIVE_PARAMS,
8055 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8056 0,
8057 "setKeepAlive" },
8058#ifdef WLAN_FEATURE_PACKET_FILTERING
8059 {
8060 WLAN_SET_PACKET_FILTER_PARAMS,
8061 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8062 0,
8063 "setPktFilter" },
8064#endif
8065#ifdef FEATURE_WLAN_SCAN_PNO
8066 {
8067 WLAN_SET_PNO,
8068 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8069 0,
8070 "setpno" },
8071#endif
8072 {
8073 WLAN_SET_BAND_CONFIG,
8074 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8075 0,
8076 "SETBAND" },
8077 /* handlers for dynamic MC BC ioctl */
8078 {
8079 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008080 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 0,
8082 "setMCBCFilter" },
8083 {
8084 WLAN_PRIV_CLEAR_MCBC_FILTER,
8085 0,
8086 0,
8087 "clearMCBCFilter" },
8088 {
8089 WLAN_SET_POWER_PARAMS,
8090 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8091 0,
8092 "setpowerparams" },
8093 {
8094 WLAN_GET_LINK_SPEED,
8095 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308096 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008097};
8098
8099
8100
8101const struct iw_handler_def we_handler_def = {
8102 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8103 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8104 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8105
8106 .standard = (iw_handler *)we_handler,
8107 .private = (iw_handler *)we_private,
8108 .private_args = we_private_args,
8109 .get_wireless_stats = get_wireless_stats,
8110};
8111
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008112int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8113{
8114 v_U32_t cmd = 288; //Command to RIVA
8115 hdd_context_t *pHddCtx = NULL;
8116 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8117 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8118 /*
8119 *configMccParam : specify the bit which needs to be modified
8120 *allowed to update based on wlan_qcom_cfg.ini
8121 * configuration
8122 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8123 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8124 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8125 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8126 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8127 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8128 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8129 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8130 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8131 * Bit 9 : Reserved
8132 */
8133 switch (arg1)
8134 {
8135 //Update MCC SCHEDULE_TIME_SLICE parameter
8136 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8137 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8138 {
8139 if((arg2 >= 5) && (arg2 <= 20))
8140 {
8141 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8142 }
8143 else
8144 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008145 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008146 return 0;
8147 }
8148 }
8149 break;
8150
8151 //Update MCC MAX_NULL_SEND_TIME parameter
8152 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8153 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8154 {
8155 if((arg2 >= 1) && (arg2 <= 10))
8156 {
8157 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8158 }
8159 else
8160 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008161 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008162 return 0;
8163 }
8164 }
8165 break;
8166
8167 //Update MCC TX_EARLY_STOP_TIME parameter
8168 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8169 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8170 {
8171 if((arg2 >= 1) && (arg2 <= 10))
8172 {
8173 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8174 }
8175 else
8176 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008177 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008178 return 0;
8179 }
8180 }
8181 break;
8182
8183 //Update MCC RX_DRAIN_TIME parameter
8184 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8185 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8186 {
8187 if((arg2 >= 1) && (arg2 <= 10))
8188 {
8189 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8190 }
8191 else
8192 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008193 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008194 return 0;
8195 }
8196 }
8197 break;
8198
8199 //Update MCC CHANNEL_SWITCH_TIME parameter
8200 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8201 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8202 {
8203 if((arg2 >= 1) && (arg2 <= 20))
8204 {
8205 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8206 }
8207 else
8208 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008209 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008210 return 0;
8211 }
8212 }
8213 break;
8214
8215 //Update MCC MIN_CHANNEL_TIME parameter
8216 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8217 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8218 {
8219 if((arg2 >= 5) && (arg2 <= 20))
8220 {
8221 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8222 }
8223 else
8224 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008225 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008226 return 0;
8227 }
8228 }
8229 break;
8230
8231 //Update MCC PARK_BEFORE_TBTT parameter
8232 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8233 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8234 {
8235 if((arg2 >= 1) && (arg2 <= 5))
8236 {
8237 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8238 }
8239 else
8240 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008241 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008242 return 0;
8243 }
8244 }
8245 break;
8246
8247 //Update MCC MIN_AFTER_DTIM parameter
8248 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8249 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8250 {
8251 if((arg2 >= 5) && (arg2 <= 15))
8252 {
8253 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8254 }
8255 else
8256 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008257 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008258 return 0;
8259 }
8260 }
8261 break;
8262
8263 //Update MCC TOO_CLOSE_MARGIN parameter
8264 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8265 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8266 {
8267 if((arg2 >= 1) && (arg2 <= 3))
8268 {
8269 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8270 }
8271 else
8272 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008273 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008274 return 0;
8275 }
8276 }
8277 break;
8278
8279 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008280 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008281 __FUNCTION__,arg1);
8282 break;
8283 }
8284 return 0;
8285}
8286
Jeff Johnson295189b2012-06-20 16:38:30 -07008287int hdd_set_wext(hdd_adapter_t *pAdapter)
8288{
8289 hdd_wext_state_t *pwextBuf;
8290 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008291 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008292
8293 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8294
8295 // Now configure the roaming profile links. To SSID and bssid.
8296 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8297 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8298
8299 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8300 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8301
8302 /*Set the numOfChannels to zero to scan all the channels*/
8303 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8304 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8305
8306 /* Default is no encryption */
8307 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8308 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8309
8310 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8311 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8312
8313 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8314
8315 /* Default is no authentication */
8316 pwextBuf->roamProfile.AuthType.numEntries = 1;
8317 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8318
8319 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8320 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8321
8322 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008323 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008324
8325 hdd_clearRoamProfileIe(pAdapter);
8326
8327 return VOS_STATUS_SUCCESS;
8328
8329 }
8330
8331int hdd_register_wext(struct net_device *dev)
8332 {
8333 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8334 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8335 VOS_STATUS status;
8336
8337 ENTER();
8338
8339 // Zero the memory. This zeros the profile structure.
8340 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8341
8342 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8343
8344
8345 status = hdd_set_wext(pAdapter);
8346
8347 if(!VOS_IS_STATUS_SUCCESS(status)) {
8348
Arif Hussain6d2a3322013-11-17 19:50:10 -08008349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 return eHAL_STATUS_FAILURE;
8351 }
8352
8353 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8354 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 return eHAL_STATUS_FAILURE;
8357 }
8358
8359 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8360 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 return eHAL_STATUS_FAILURE;
8363 }
8364
8365 // Register as a wireless device
8366 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8367
8368 EXIT();
8369 return 0;
8370}
8371
8372int hdd_UnregisterWext(struct net_device *dev)
8373{
8374#if 0
8375 hdd_wext_state_t *wextBuf;
8376 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8377
8378 ENTER();
8379 // Set up the pointer to the Wireless Extensions state structure
8380 wextBuf = pAdapter->pWextState;
8381
8382 // De-allocate the Wireless Extensions state structure
8383 kfree(wextBuf);
8384
8385 // Clear out the pointer to the Wireless Extensions state structure
8386 pAdapter->pWextState = NULL;
8387
8388 EXIT();
8389#endif
8390 dev->wireless_handlers = NULL;
8391 return 0;
8392}
8393
8394