blob: e316ea31f918112c04f9db33069d6419791ef2c5 [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 Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053053#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include <wlan_hdd_includes.h>
55#include <wlan_btc_svc.h>
56#include <wlan_nlink_common.h>
57#ifdef WLAN_BTAMP_FEATURE
58#include <bap_hdd_main.h>
59#endif
60#include <vos_api.h>
61#include <net/arp.h>
62#include "ccmApi.h"
63#include "sirParams.h"
64#include "csrApi.h"
65#include "csrInsideApi.h"
66#if defined WLAN_FEATURE_VOWIFI
67#include "smeRrmInternal.h"
68#endif
69#include <aniGlobal.h>
70#include "dot11f.h"
71#include <wlan_hdd_wowl.h>
72#include <wlan_hdd_cfg.h>
73#include <wlan_hdd_wmm.h>
74#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053076#ifdef FEATURE_WLAN_TDLS
77#include "wlan_hdd_tdls.h"
78#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070079
80#ifdef CONFIG_HAS_EARLYSUSPEND
81#include <linux/earlysuspend.h>
82#endif
83#include "wlan_hdd_power.h"
84#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070085#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
Mukul Sharma84f27252014-07-14 18:11:42 +0530105#ifdef DEBUG_ROAM_DELAY
106#include "vos_utils.h"
107#endif
108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700127static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
129
Jeff Johnson295189b2012-06-20 16:38:30 -0700130/* To Validate Channel against the Frequency and Vice-Versa */
131static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
132 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
133 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
134 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
135 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
136 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
137 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
138 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800139 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
140 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700141
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800142#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
144/* Private ioctls and their sub-ioctls */
145#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
146#define WE_SET_11D_STATE 1
147#define WE_WOWL 2
148#define WE_SET_POWER 3
149#define WE_SET_MAX_ASSOC 4
150#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
151#define WE_SET_DATA_INACTIVITY_TO 6
152#define WE_SET_MAX_TX_POWER 7
153#define WE_SET_HIGHER_DTIM_TRANSITION 8
154#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530155#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700156#define WE_SET_MAX_TX_POWER_2_4 11
157#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800158/* Private IOCTL for debug connection issues */
159#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530160// tdlsoffchan
161#ifdef FEATURE_WLAN_TDLS
162#define WE_SET_TDLS_OFF_CHAN 14
163#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
164#define WE_SET_TDLS_OFF_CHAN_MODE 16
165#endif
Peng Xu2446a892014-09-05 17:21:18 +0530166#define WE_SET_SCAN_BAND_PREFERENCE 17
Jeff Johnson295189b2012-06-20 16:38:30 -0700167
168/* Private ioctls and their sub-ioctls */
169#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
170#define WE_GET_11D_STATE 1
171#define WE_IBSS_STATUS 2
172#define WE_PMC_STATE 3
173#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700174#define WE_GET_MAX_ASSOC 6
175#define WE_GET_WDI_DBG 7
176#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
177#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530178#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700179/* Private ioctls and their sub-ioctls */
180#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
181
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
184#define WE_WOWL_ADD_PTRN 1
185#define WE_WOWL_DEL_PTRN 2
186#if defined WLAN_FEATURE_VOWIFI
187#define WE_NEIGHBOR_REPORT_REQUEST 3
188#endif
189#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
190#define WE_SET_CONFIG 5
191
192/* Private ioctls and their sub-ioctls */
193#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
194#define WE_SET_WLAN_DBG 1
195#define WE_SET_WDI_DBG 2
196#define WE_SET_SAP_CHANNELS 3
197
198/* Private ioctls and their sub-ioctls */
199#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
200#define WE_WLAN_VERSION 1
201#define WE_GET_STATS 2
202#define WE_GET_CFG 3
203#define WE_GET_WMM_STATUS 4
204#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700205#ifdef WLAN_FEATURE_11AC
206#define WE_GET_RSSI 6
207#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800208#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800209#ifdef FEATURE_WLAN_TDLS
210#define WE_GET_TDLS_PEERS 8
211#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700212#ifdef WLAN_FEATURE_11W
213#define WE_GET_11W_INFO 9
214#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530215#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530216#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700217
218/* Private ioctls and their sub-ioctls */
219#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
220#define WE_CLEAR_STATS 1
221#define WE_INIT_AP 2
222#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530223#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700224#define WE_ENABLE_AMP 4
225#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530226#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700227#define WE_ENABLE_DXE_STALL_DETECT 6
228#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700229#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530230#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530231#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700232
Mukul Sharma84f27252014-07-14 18:11:42 +0530233#ifdef DEBUG_ROAM_DELAY
234#define WE_DUMP_ROAM_TIMER_LOG 12
235#define WE_RESET_ROAM_TIMER_LOG 13
236#endif
237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238/* Private ioctls and their sub-ioctls */
239#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
240#define WE_LOG_DUMP_CMD 1
241
Jeff Johnson295189b2012-06-20 16:38:30 -0700242#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800243//IOCTL to configure MCC params
244#define WE_MCC_CONFIG_CREDENTIAL 3
245#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700246
Chilam NG571c65a2013-01-19 12:27:36 +0530247#ifdef FEATURE_WLAN_TDLS
248#define WE_TDLS_CONFIG_PARAMS 5
249#endif
250
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700251#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530252#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700253
Chilam Ng01120412013-02-19 18:32:21 -0800254#ifdef FEATURE_WLAN_TDLS
255#undef MAX_VAR_ARGS
256#define MAX_VAR_ARGS 10
257#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700258#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800259#endif
260
Jeff Johnson295189b2012-06-20 16:38:30 -0700261/* Private ioctls (with no sub-ioctls) */
262/* note that they must be odd so that they have "get" semantics */
263#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
264#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
265#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
266
Girish Gowli464c9c82014-06-09 19:47:53 +0530267/* (SIOCIWFIRSTPRIV + 8) is currently unused */
268/* (SIOCIWFIRSTPRIV + 16) is currently unused */
269/* (SIOCIWFIRSTPRIV + 10) is currently unused */
270/* (SIOCIWFIRSTPRIV + 12) is currently unused */
271/* (SIOCIWFIRSTPRIV + 14) is currently unused */
272/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
Jeff Johnsone7245742012-09-05 17:12:55 -0700274#ifdef FEATURE_OEM_DATA_SUPPORT
275/* Private ioctls for setting the measurement configuration */
276#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
277#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
278#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280#ifdef WLAN_FEATURE_VOWIFI_11R
281#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
282#endif
283
284/* Private ioctl for setting the host offload feature */
285#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
286
287/* Private ioctl to get the statistics */
288#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
289
290/* Private ioctl to set the Keep Alive Params */
291#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
292#ifdef WLAN_FEATURE_PACKET_FILTERING
293/* Private ioctl to set the Packet Filtering Params */
294#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
295#endif
296
297#ifdef FEATURE_WLAN_SCAN_PNO
298/* Private ioctl to get the statistics */
299#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
300#endif
301
302#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
303
304#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
305#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700306/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700307
Jeff Johnson295189b2012-06-20 16:38:30 -0700308#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
309#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
310
311#define WLAN_STATS_INVALID 0
312#define WLAN_STATS_RETRY_CNT 1
313#define WLAN_STATS_MUL_RETRY_CNT 2
314#define WLAN_STATS_TX_FRM_CNT 3
315#define WLAN_STATS_RX_FRM_CNT 4
316#define WLAN_STATS_FRM_DUP_CNT 5
317#define WLAN_STATS_FAIL_CNT 6
318#define WLAN_STATS_RTS_FAIL_CNT 7
319#define WLAN_STATS_ACK_FAIL_CNT 8
320#define WLAN_STATS_RTS_SUC_CNT 9
321#define WLAN_STATS_RX_DISCARD_CNT 10
322#define WLAN_STATS_RX_ERROR_CNT 11
323#define WLAN_STATS_TX_BYTE_CNT 12
324
325#define WLAN_STATS_RX_BYTE_CNT 13
326#define WLAN_STATS_RX_RATE 14
327#define WLAN_STATS_TX_RATE 15
328
Jeff Johnsone7245742012-09-05 17:12:55 -0700329#define WLAN_STATS_RX_UC_BYTE_CNT 16
330#define WLAN_STATS_RX_MC_BYTE_CNT 17
331#define WLAN_STATS_RX_BC_BYTE_CNT 18
332#define WLAN_STATS_TX_UC_BYTE_CNT 19
333#define WLAN_STATS_TX_MC_BYTE_CNT 20
334#define WLAN_STATS_TX_BC_BYTE_CNT 21
335
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800336#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
337 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
338 { \
339 *__p++ = __type; \
340 *__p++ = __size; \
341 memcpy(__p, __val, __size); \
342 __p += __size; \
343 __tlen += __size + 2; \
344 } \
345 else \
346 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800347 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800348 } \
349 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350
351#define VERSION_VALUE_MAX_LEN 32
352
353#define TX_PER_TRACKING_DEFAULT_RATIO 5
354#define TX_PER_TRACKING_MAX_RATIO 10
355#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
356
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530357#define WLAN_ADAPTER 0
358#define P2P_ADAPTER 1
359
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530360/*
361 * When supplicant sends SETBAND ioctl it queries for channels from
362 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
363 * This is not required if the return type from ioctl is
364 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
365 * event as part of regulatory_hint.
366 */
367enum {
368 SEND_CHANNEL_CHANGE_EVENT = 0,
369 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
370};
371
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800372/*MCC Configuration parameters */
373enum {
374 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
375 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
376 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
377 MCC_RX_DRAIN_TIME_CFG_PARAM,
378 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
379 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
380 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
381 MCC_MIN_AFTER_DTIM_CFG_PARAM,
382 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
383};
384
385int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
386 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
387
Jeff Johnson295189b2012-06-20 16:38:30 -0700388#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800389int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700390 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700391#endif
392
Jeff Johnson295189b2012-06-20 16:38:30 -0700393/**---------------------------------------------------------------------------
394
Arif Hussain0273cba2014-01-07 20:58:29 -0800395 \brief mem_alloc_copy_from_user_helper -
396
397 Helper function to allocate buffer and copy user data.
398
399 \param - wrqu - Pointer to IOCTL Data.
400 len - size
401
402 \return - On Success pointer to buffer, On failure NULL
403
404 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530405void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800406{
407 u8 *ptr = NULL;
408
409 /* in order to protect the code, an extra byte is post appended to the buffer
410 * and the null termination is added. However, when allocating (len+1) byte
411 * of memory, we need to make sure that there is no uint overflow when doing
412 * addition. In theory check len < UINT_MAX protects the uint overflow. For
413 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
414 * guess, now, it is assumed that the private command buffer size is no
415 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
416 */
417 if (len > MAX_USER_COMMAND_SIZE)
418 {
419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
420 "Invalid length");
421 return NULL;
422 }
423
424 ptr = kmalloc(len + 1, GFP_KERNEL);
425 if (NULL == ptr)
426 {
427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
428 "unable to allocate memory");
429 return NULL;
430 }
431
432 if (copy_from_user(ptr, wrqu_data, len))
433 {
434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
435 "%s: failed to copy data to user buffer", __func__);
436 kfree(ptr);
437 return NULL;
438 }
439 ptr[len] = '\0';
440 return ptr;
441}
442
Girish Gowli488ef492014-06-12 18:44:33 +0530443// Function to handle and get compatible struct iw_point passed to ioctl.
444int hdd_priv_get_data(struct iw_point *p_priv_data,
445 union iwreq_data *wrqu)
446{
447 if ((NULL == p_priv_data) || (NULL == wrqu))
448 {
449 return -EINVAL;
450 }
451
452#ifdef CONFIG_COMPAT
453 if (is_compat_task())
454 {
455 struct compat_iw_point *p_compat_priv_data;
456
457 // Compat task: typecast to campat structure and copy the members.
458 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
459
460 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
461 p_priv_data->length = p_compat_priv_data->length;
462 p_priv_data->flags = p_compat_priv_data->flags;
463 }//if(is_compat_task())
464 else
465 {
466#endif //#ifdef CONFIG_COMPAT
467
468 // Non compat task: directly copy the structure.
469 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
470
471#ifdef CONFIG_COMPAT
472 }//else of - if(is_compat_task())
473#endif //#ifdef CONFIG_COMPAT
474
475 return 0;
476}
477
Arif Hussain0273cba2014-01-07 20:58:29 -0800478/**---------------------------------------------------------------------------
479
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 \brief hdd_wlan_get_version() -
481
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800482 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700483
484 \param - pAdapter Pointer to the adapter.
485 wrqu - Pointer to IOCTL REQUEST Data.
486 extra - Pointer to char
487
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800488 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700489
490 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800491void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
492 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700493{
494 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800495 tSirVersionString wcnss_SW_version;
496 tSirVersionString wcnss_HW_version;
497 char *pSWversion;
498 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700500
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800501 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
502 sizeof(wcnss_SW_version));
503 if (VOS_IS_STATUS_SUCCESS(status))
504 {
505 pSWversion = wcnss_SW_version;
506 }
507 else
508 {
509 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 }
511
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800512 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
513 sizeof(wcnss_HW_version));
514 if (VOS_IS_STATUS_SUCCESS(status))
515 {
516 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800518 else
519 {
520 pHWversion = "Unknown";
521 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700523 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800524 "Host SW:%s, FW:%s, HW:%s",
525 QWLAN_VERSIONSTR,
526 pSWversion,
527 pHWversion);
528
529 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700530}
531
Jeff Johnson295189b2012-06-20 16:38:30 -0700532int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
533{
534 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
535 v_U32_t threshold = 0,status = 0;
536
537 ENTER();
538
Agarwal Ashish971c2882013-10-30 20:11:12 +0530539 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
540 {
541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 "%s:LOGP in Progress. Ignore!!!",__func__);
543 return status;
544 }
545
546 if ( eHAL_STATUS_SUCCESS !=
547 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
548 {
c_hpothub8245442013-11-20 23:41:09 +0530549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
550 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 return -EIO;
552 }
553 wrqu->rts.value = threshold;
554
555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800556 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
558 EXIT();
559
560 return 0;
561}
562
563int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
564{
565 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
566 v_U32_t threshold = 0,status = 0;
567
568 ENTER();
569
Agarwal Ashish971c2882013-10-30 20:11:12 +0530570 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
571 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
573 "%s:LOGP in Progress. Ignore!!!",__func__);
574 return status;
575 }
576
577 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
578 != eHAL_STATUS_SUCCESS )
579 {
c_hpothub8245442013-11-20 23:41:09 +0530580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
581 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 return -EIO;
583 }
584 wrqu->frag.value = threshold;
585
586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800587 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
589 EXIT();
590
591 return 0;
592}
593
594int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
595{
Jeff Johnsone7245742012-09-05 17:12:55 -0700596 int i;
597 if (channel > 0)
598 {
599 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
600 {
601 if (channel == freq_chan_map[i].chan)
602 {
603 *pfreq = freq_chan_map[i].freq;
604 return 1;
605 }
606 }
607 }
608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800609 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700610 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700611}
612
613static v_BOOL_t
614hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
615{
616 v_BOOL_t rsnType = VOS_FALSE;
617 // is the authType supported?
618 switch (authType)
619 {
620 case eCSR_AUTH_TYPE_NONE: //never used
621 rsnType = eANI_BOOLEAN_FALSE;
622 break;
623 // MAC layer authentication types
624 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
625 rsnType = eANI_BOOLEAN_FALSE;
626 break;
627 case eCSR_AUTH_TYPE_SHARED_KEY:
628 rsnType = eANI_BOOLEAN_FALSE;
629 break;
630 case eCSR_AUTH_TYPE_AUTOSWITCH:
631 rsnType = eANI_BOOLEAN_FALSE;
632 break;
633
634 // Upper layer authentication types
635 case eCSR_AUTH_TYPE_WPA:
636 rsnType = eANI_BOOLEAN_TRUE;
637 break;
638 case eCSR_AUTH_TYPE_WPA_PSK:
639 rsnType = eANI_BOOLEAN_TRUE;
640 break;
641 case eCSR_AUTH_TYPE_WPA_NONE:
642 rsnType = eANI_BOOLEAN_TRUE;
643 break;
644#ifdef WLAN_FEATURE_VOWIFI_11R
645 case eCSR_AUTH_TYPE_FT_RSN:
646#endif
647 case eCSR_AUTH_TYPE_RSN:
648 rsnType = eANI_BOOLEAN_TRUE;
649 break;
650#ifdef WLAN_FEATURE_VOWIFI_11R
651 case eCSR_AUTH_TYPE_FT_RSN_PSK:
652#endif
653 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700654#ifdef WLAN_FEATURE_11W
655 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530656 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700657#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 rsnType = eANI_BOOLEAN_TRUE;
659 break;
660 //case eCSR_AUTH_TYPE_FAILED:
661 case eCSR_AUTH_TYPE_UNKNOWN:
662 rsnType = eANI_BOOLEAN_FALSE;
663 break;
664 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800665 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
666 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 rsnType = eANI_BOOLEAN_FALSE;
668 break;
669 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800670 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700671 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 return rsnType;
673}
674
675static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
676{
677 struct statsContext *pStatsContext;
678 hdd_adapter_t *pAdapter;
679
680 if (ioctl_debug)
681 {
682 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700683 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 }
685
686 if (NULL == pContext)
687 {
688 hddLog(VOS_TRACE_LEVEL_ERROR,
689 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700690 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 return;
692 }
693
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 pStatsContext = pContext;
695 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800696
697 /* there is a race condition that exists between this callback
698 function and the caller since the caller could time out either
699 before or while this code is executing. we use a spinlock to
700 serialize these actions */
701 spin_lock(&hdd_context_lock);
702
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
704 {
705 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800706 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 hddLog(VOS_TRACE_LEVEL_WARN,
708 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700709 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 if (ioctl_debug)
711 {
712 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700713 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 }
715 return;
716 }
717
Jeff Johnson72a40512013-12-19 10:14:15 -0800718 /* context is valid so caller is still waiting */
719
720 /* paranoia: invalidate the magic */
721 pStatsContext->magic = 0;
722
723 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 pAdapter->rssi = rssi;
725
Jeff Johnson72a40512013-12-19 10:14:15 -0800726 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800728
729 /* serialization is complete */
730 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731}
732
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530733static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
734{
735 struct statsContext *pStatsContext;
736 hdd_adapter_t *pAdapter;
737
738 if (ioctl_debug)
739 {
740 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
741 __func__, (int)snr, (int)staId, pContext);
742 }
743
744 if (NULL == pContext)
745 {
746 hddLog(VOS_TRACE_LEVEL_ERROR,
747 "%s: Bad param, pContext [%p]",
748 __func__, pContext);
749 return;
750 }
751
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530752 pStatsContext = pContext;
753 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800754
755 /* there is a race condition that exists between this callback
756 function and the caller since the caller could time out either
757 before or while this code is executing. we use a spinlock to
758 serialize these actions */
759 spin_lock(&hdd_context_lock);
760
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530761 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
762 {
763 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800764 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530765 hddLog(VOS_TRACE_LEVEL_WARN,
766 "%s: Invalid context, pAdapter [%p] magic [%08x]",
767 __func__, pAdapter, pStatsContext->magic);
768 if (ioctl_debug)
769 {
770 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
771 __func__, pAdapter, pStatsContext->magic);
772 }
773 return;
774 }
775
Jeff Johnson72a40512013-12-19 10:14:15 -0800776 /* context is valid so caller is still waiting */
777
778 /* paranoia: invalidate the magic */
779 pStatsContext->magic = 0;
780
781 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530782 pAdapter->snr = snr;
783
Jeff Johnson72a40512013-12-19 10:14:15 -0800784 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530785 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800786
787 /* serialization is complete */
788 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530789}
790
Jeff Johnson295189b2012-06-20 16:38:30 -0700791VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
792{
793 struct statsContext context;
794 hdd_context_t *pHddCtx;
795 hdd_station_ctx_t *pHddStaCtx;
796 eHalStatus hstatus;
797 long lrc;
798
799 if (NULL == pAdapter)
800 {
801 hddLog(VOS_TRACE_LEVEL_WARN,
802 "%s: Invalid context, pAdapter", __func__);
803 return VOS_STATUS_E_FAULT;
804 }
805 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
806 {
807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
808 /* return a cached value */
809 *rssi_value = pAdapter->rssi;
810 return VOS_STATUS_SUCCESS;
811 }
812
813 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
814 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
815
816 init_completion(&context.completion);
817 context.pAdapter = pAdapter;
818 context.magic = RSSI_CONTEXT_MAGIC;
819
820 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
821 pHddStaCtx->conn_info.staId[ 0 ],
822 pHddStaCtx->conn_info.bssId,
823 &context, pHddCtx->pvosContext);
824 if (eHAL_STATUS_SUCCESS != hstatus)
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700827 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 /* we'll returned a cached value below */
829 }
830 else
831 {
832 /* request was sent -- wait for the response */
833 lrc = wait_for_completion_interruptible_timeout(&context.completion,
834 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 if (lrc <= 0)
836 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800837 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700838 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 /* we'll now returned a cached value below */
840 }
841 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800842
843 /* either we never sent a request, we sent a request and received a
844 response or we sent a request and timed out. if we never sent a
845 request or if we sent a request and got a response, we want to
846 clear the magic out of paranoia. if we timed out there is a
847 race condition such that the callback function could be
848 executing at the same time we are. of primary concern is if the
849 callback function had already verified the "magic" but had not
850 yet set the completion variable when a timeout occurred. we
851 serialize these activities by invalidating the magic while
852 holding a shared spinlock which will cause us to block if the
853 callback is currently executing */
854 spin_lock(&hdd_context_lock);
855 context.magic = 0;
856 spin_unlock(&hdd_context_lock);
857
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 *rssi_value = pAdapter->rssi;
859
860 return VOS_STATUS_SUCCESS;
861}
862
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530863VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
864{
865 struct statsContext context;
866 hdd_context_t *pHddCtx;
867 hdd_station_ctx_t *pHddStaCtx;
868 eHalStatus hstatus;
869 long lrc;
870 int valid;
871
872 if (NULL == pAdapter)
873 {
874 hddLog(VOS_TRACE_LEVEL_ERROR,
875 "%s: Invalid context, pAdapter", __func__);
876 return VOS_STATUS_E_FAULT;
877 }
878
879 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
880
881 valid = wlan_hdd_validate_context(pHddCtx);
882 if (0 != valid)
883 {
884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
885 return VOS_STATUS_E_FAULT;
886 }
887
888 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
889 if (NULL == pHddStaCtx)
890 {
891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
892 return VOS_STATUS_E_FAULT;
893 }
894
895 init_completion(&context.completion);
896 context.pAdapter = pAdapter;
897 context.magic = SNR_CONTEXT_MAGIC;
898
899 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
900 pHddStaCtx->conn_info.staId[ 0 ],
901 pHddStaCtx->conn_info.bssId,
902 &context);
903 if (eHAL_STATUS_SUCCESS != hstatus)
904 {
905 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
906 __func__);
907 /* we'll returned a cached value below */
908 }
909 else
910 {
911 /* request was sent -- wait for the response */
912 lrc = wait_for_completion_interruptible_timeout(&context.completion,
913 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530914 if (lrc <= 0)
915 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530917 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530918 /* we'll now returned a cached value below */
919 }
920 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800921
922 /* either we never sent a request, we sent a request and received a
923 response or we sent a request and timed out. if we never sent a
924 request or if we sent a request and got a response, we want to
925 clear the magic out of paranoia. if we timed out there is a
926 race condition such that the callback function could be
927 executing at the same time we are. of primary concern is if the
928 callback function had already verified the "magic" but had not
929 yet set the completion variable when a timeout occurred. we
930 serialize these activities by invalidating the magic while
931 holding a shared spinlock which will cause us to block if the
932 callback is currently executing */
933 spin_lock(&hdd_context_lock);
934 context.magic = 0;
935 spin_unlock(&hdd_context_lock);
936
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530937 *snr = pAdapter->snr;
938
939 return VOS_STATUS_SUCCESS;
940}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800941#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800942
943static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
944{
945 struct statsContext *pStatsContext;
946 hdd_adapter_t *pAdapter;
947 if (ioctl_debug)
948 {
949 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
950 __func__, (int)rssi, (int)staId, pContext);
951 }
952
953 if (NULL == pContext)
954 {
955 hddLog(VOS_TRACE_LEVEL_ERROR,
956 "%s: Bad param, pContext [%p]",
957 __func__, pContext);
958 return;
959 }
960
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800961 pStatsContext = pContext;
962 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800963
964 /* there is a race condition that exists between this callback
965 function and the caller since the caller could time out either
966 before or while this code is executing. we use a spinlock to
967 serialize these actions */
968 spin_lock(&hdd_context_lock);
969
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800970 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
971 {
972 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800973 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800974 hddLog(VOS_TRACE_LEVEL_WARN,
975 "%s: Invalid context, pAdapter [%p] magic [%08x]",
976 __func__, pAdapter, pStatsContext->magic);
977 if (ioctl_debug)
978 {
979 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
980 __func__, pAdapter, pStatsContext->magic);
981 }
982 return;
983 }
984
Jeff Johnson72a40512013-12-19 10:14:15 -0800985 /* context is valid so caller is still waiting */
986
987 /* paranoia: invalidate the magic */
988 pStatsContext->magic = 0;
989
990 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800991 pAdapter->rssi = rssi;
992
Jeff Johnson72a40512013-12-19 10:14:15 -0800993 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800994 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800995
996 /* serialization is complete */
997 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800998}
999
1000
1001
1002VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1003{
1004 struct statsContext context;
1005 hdd_context_t *pHddCtx = NULL;
1006 hdd_station_ctx_t *pHddStaCtx = NULL;
1007 eHalStatus hstatus;
1008 long lrc;
1009
1010 if (NULL == pAdapter)
1011 {
1012 hddLog(VOS_TRACE_LEVEL_WARN,
1013 "%s: Invalid context, pAdapter", __func__);
1014 return VOS_STATUS_E_FAULT;
1015 }
1016 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1017 {
1018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1019 /* return a cached value */
1020 *rssi_value = pAdapter->rssi;
1021 return VOS_STATUS_SUCCESS;
1022 }
1023
1024 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1025 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1026
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301027 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001028 {
1029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1030 /* return a cached value */
1031 *rssi_value = 0;
1032 return VOS_STATUS_SUCCESS;
1033 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301034
1035 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1036 {
1037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1038 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1039 *rssi_value = pAdapter->rssi;
1040 return VOS_STATUS_SUCCESS;
1041 }
1042
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001043 init_completion(&context.completion);
1044 context.pAdapter = pAdapter;
1045 context.magic = RSSI_CONTEXT_MAGIC;
1046
1047 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1048 pHddStaCtx->conn_info.staId[ 0 ],
1049 pHddStaCtx->conn_info.bssId,
1050 &context, pHddCtx->pvosContext);
1051 if (eHAL_STATUS_SUCCESS != hstatus)
1052 {
1053 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1054 __func__);
1055 /* we'll returned a cached value below */
1056 }
1057 else
1058 {
1059 /* request was sent -- wait for the response */
1060 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1061 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001062 if (lrc <= 0)
1063 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001064 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001065 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001066 /* we'll now returned a cached value below */
1067 }
1068 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001069
1070 /* either we never sent a request, we sent a request and received a
1071 response or we sent a request and timed out. if we never sent a
1072 request or if we sent a request and got a response, we want to
1073 clear the magic out of paranoia. if we timed out there is a
1074 race condition such that the callback function could be
1075 executing at the same time we are. of primary concern is if the
1076 callback function had already verified the "magic" but had not
1077 yet set the completion variable when a timeout occurred. we
1078 serialize these activities by invalidating the magic while
1079 holding a shared spinlock which will cause us to block if the
1080 callback is currently executing */
1081 spin_lock(&hdd_context_lock);
1082 context.magic = 0;
1083 spin_unlock(&hdd_context_lock);
1084
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001085 *rssi_value = pAdapter->rssi;
1086
1087 return VOS_STATUS_SUCCESS;
1088}
1089#endif
1090
1091
Jeff Johnson295189b2012-06-20 16:38:30 -07001092void hdd_StatisticsCB( void *pStats, void *pContext )
1093{
1094 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1095 hdd_stats_t *pStatsCache = NULL;
1096 hdd_wext_state_t *pWextState;
1097 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1098
1099 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1100 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1101 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1102 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1103 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1104 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1105
1106 if (pAdapter!= NULL)
1107 pStatsCache = &pAdapter->hdd_stats;
1108
1109
1110 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1111 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1112 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1113 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1114 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1115 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1116
1117 if (pStatsCache!=NULL)
1118 {
1119 // and copy the stats into the cache we keep in the adapter instance structure
1120 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1121 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1122 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1123 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1124 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1125 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1126 }
1127
1128 if(pAdapter)
1129 {
1130 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1131 if(pWextState)
1132 {
1133 vos_status = vos_event_set(&pWextState->vosevent);
1134 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1135 {
1136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001137 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 return;
1139 }
1140 }
1141 }
1142}
1143
1144void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1145{
1146 v_CONTEXT_t pVosContext;
1147 hdd_context_t *pHddCtx;
1148 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1149#if 0
1150 hdd_wext_state_t *pWextState;
1151 v_U32_t roamId;
1152#endif
1153
1154 ENTER();
1155
1156 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1157
1158 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1159 if (NULL == pHddCtx)
1160 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001161 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 return;
1163 }
1164#if 0
1165 pWextState = pAdapter->pWextState;
1166#endif
1167
1168 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1169 {
1170 //TODO Verify is this is really used. If yes need to fix it.
1171 hdd_reconnect_all_adapters( pHddCtx );
1172#if 0
1173 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1174 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1175 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1176
1177 if(VOS_STATUS_SUCCESS == vosStatus)
1178 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1179 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1180
1181 sme_RoamConnect(halHandle,
1182 pAdapter->sessionId, &(pWextState->roamProfile),
1183 &roamId);
1184#endif
1185 }
1186
1187 EXIT();
1188
1189}
1190
1191void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1192{
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1194
1195 /* clear WPA/RSN/WSC IE information in the profile */
1196 pWextState->roamProfile.nWPAReqIELength = 0;
1197 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1198 pWextState->roamProfile.nRSNReqIELength = 0;
1199 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1200
Chet Lanctot186b5732013-03-18 10:26:30 -07001201#ifdef FEATURE_WLAN_WAPI
1202 pWextState->roamProfile.nWAPIReqIELength = 0;
1203 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1204#endif
1205
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001207 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301209 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1211 pWextState->roamProfile.nAddIEAssocLength = 0;
1212
1213 pWextState->roamProfile.EncryptionType.numEntries = 1;
1214 pWextState->roamProfile.EncryptionType.encryptionType[0]
1215 = eCSR_ENCRYPT_TYPE_NONE;
1216
1217 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1218 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1219 = eCSR_ENCRYPT_TYPE_NONE;
1220
1221 pWextState->roamProfile.AuthType.numEntries = 1;
1222 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1223
Chet Lanctot186b5732013-03-18 10:26:30 -07001224#ifdef WLAN_FEATURE_11W
1225 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1226 pWextState->roamProfile.MFPRequired = 0;
1227 pWextState->roamProfile.MFPCapable = 0;
1228#endif
1229
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 pWextState->authKeyMgmt = 0;
1231
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301232 vos_mem_zero(&pWextState->roamProfile.Keys,
1233 sizeof(pWextState->roamProfile.Keys));
1234
Jeff Johnson295189b2012-06-20 16:38:30 -07001235#ifdef FEATURE_WLAN_WAPI
1236 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1237 pAdapter->wapi_info.nWapiMode = 0;
1238#endif
1239
1240 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1241
1242}
1243
1244void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1245{
1246 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001248 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1249 {
1250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1251 "%s: Invalid pAdapter magic", __func__);
1252 }
1253 else
1254 {
1255 complete(&pAdapter->ula_complete);
1256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001257}
1258
1259VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1260{
1261 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001263 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001264
1265 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1266 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001267 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001268
1269 /*To avoid race condition between the set key and the last EAPOL
1270 packet, notify TL to finish upper layer authentication incase if the
1271 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001272 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001273
1274 if ( vos_status != VOS_STATUS_SUCCESS )
1275 {
1276 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1277 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1278 __LINE__, vos_status );
1279 return vos_status;
1280
1281 }
1282
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001283 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301285 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001286 {
1287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301288 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001289 /* we'll still fall through and return success since the
1290 * connection may still get established but is just taking
1291 * too long for us to wait */
1292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 }
1294 return VOS_STATUS_SUCCESS;
1295}
1296
1297v_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)
1298{
1299
1300 int left = ie_len;
1301 v_U8_t *ptr = ie;
1302 v_U8_t elem_id,elem_len;
1303 v_U8_t eid = 0xDD;
1304
1305 if ( NULL == ie || 0 == ie_len )
1306 return NULL;
1307
1308 while(left >= 2)
1309 {
1310 elem_id = ptr[0];
1311 elem_len = ptr[1];
1312 left -= 2;
1313 if(elem_len > left)
1314 {
1315 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001316 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 eid,elem_len,left);
1318 return NULL;
1319 }
1320 if (elem_id == eid)
1321 {
1322 if(memcmp( &ptr[2], oui, oui_size)==0)
1323 return ptr;
1324 }
1325
1326 left -= elem_len;
1327 ptr += (elem_len + 2);
1328 }
1329 return NULL;
1330}
1331
1332static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1333 union iwreq_data *wrqu, char *extra)
1334{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001335 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 /* Do nothing for now */
1337 return 0;
1338}
1339
1340static int iw_get_name(struct net_device *dev,
1341 struct iw_request_info *info,
1342 char *wrqu, char *extra)
1343{
1344
1345 ENTER();
1346 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1347 EXIT();
1348 return 0;
1349}
1350
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301351static int __iw_set_mode(struct net_device *dev,
1352 struct iw_request_info *info,
1353 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001354{
1355 hdd_wext_state_t *pWextState;
1356 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1357 tCsrRoamProfile *pRoamProfile;
1358 eCsrRoamBssType LastBSSType;
1359 eMib_dot11DesiredBssType connectedBssType;
1360 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001362
1363 ENTER();
1364
1365 if (NULL == pAdapter)
1366 {
1367 hddLog(VOS_TRACE_LEVEL_WARN,
1368 "%s: Invalid context, pAdapter", __func__);
1369 return 0;
1370 }
1371
1372 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1374 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 return 0;
1376 }
1377
1378 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1379 if (pWextState == NULL)
1380 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301381 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 return -EINVAL;
1383 }
1384
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 pRoamProfile = &pWextState->roamProfile;
1387 LastBSSType = pRoamProfile->BSSType;
1388
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301389 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001390
1391 switch (wrqu->mode)
1392 {
1393 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301394 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1396 // Set the phymode correctly for IBSS.
1397 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1398 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001399 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 break;
1402 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301403 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 break;
1407 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301408 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1410 break;
1411 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301412 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 return -EOPNOTSUPP;
1414 }
1415
1416 if ( LastBSSType != pRoamProfile->BSSType )
1417 {
1418 //the BSS mode changed
1419 // We need to issue disconnect if connected or in IBSS disconnect state
1420 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1421 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1422 {
1423 VOS_STATUS vosStatus;
1424 // need to issue a disconnect to CSR.
1425 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1426 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1427 pAdapter->sessionId,
1428 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1429 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301430 {
1431 long ret;
1432 ret = wait_for_completion_interruptible_timeout(
1433 &pAdapter->disconnect_comp_var,
1434 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1435 if (ret <= 0)
1436 hddLog(VOS_TRACE_LEVEL_ERROR,
1437 FL("failed wait on disconnect_comp_var %ld"), ret);
1438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 }
1440 }
1441
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 EXIT();
1443 return 0;
1444}
1445
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301446static int iw_set_mode(struct net_device *dev,
1447 struct iw_request_info *info,
1448 union iwreq_data *wrqu, char *extra)
1449{
1450 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001451
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301452 vos_ssr_protect(__func__);
1453 ret = __iw_set_mode(dev, info, wrqu, extra);
1454 vos_ssr_unprotect(__func__);
1455
1456 return ret;
1457}
1458
1459static int __iw_get_mode(struct net_device *dev,
1460 struct iw_request_info *info,
1461 union iwreq_data *wrqu,
1462 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001463{
1464
1465 hdd_wext_state_t *pWextState;
1466 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1467
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301468 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001469
1470 if (NULL == pAdapter)
1471 {
1472 hddLog(VOS_TRACE_LEVEL_WARN,
1473 "%s: Invalid context, pAdapter", __func__);
1474 return 0;
1475 }
1476
1477 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1479 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 return 0;
1481 }
1482
1483 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1484 if (pWextState == NULL)
1485 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301486 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 return -EINVAL;
1488 }
1489
1490 switch (pWextState->roamProfile.BSSType)
1491 {
1492 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001493 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301494 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 break;
1496 case eCSR_BSS_TYPE_IBSS:
1497 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001498 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301499 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 break;
1501 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001502 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301503 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 break;
1505 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001506 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 break;
1508 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301509
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 return 0;
1511}
1512
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301513static int iw_get_mode(struct net_device *dev,
1514 struct iw_request_info *info,
1515 union iwreq_data *wrqu,
1516 char *extra)
1517{
1518 int ret;
1519
1520 vos_ssr_protect(__func__);
1521 ret = __iw_get_mode(dev, info, wrqu, extra);
1522 vos_ssr_unprotect(__func__);
1523
1524 return ret;
1525}
1526
1527static int __iw_set_freq(struct net_device *dev,
1528 struct iw_request_info *info,
1529 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001530{
1531 v_U32_t numChans = 0;
1532 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1533 v_U32_t indx = 0;
1534 v_U32_t status = 0;
1535
1536 hdd_wext_state_t *pWextState;
1537 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1538 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1539 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1540 tCsrRoamProfile * pRoamProfile;
1541 ENTER();
1542
1543 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1545 return status;
1546 }
1547
1548 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1549
1550 pRoamProfile = &pWextState->roamProfile;
1551
Arif Hussain6d2a3322013-11-17 19:50:10 -08001552 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001553
1554 /* Link is up then return cant set channel*/
1555 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1556 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1557 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001558 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 return -EOPNOTSUPP;
1560 }
1561
1562 /* Settings by Frequency as input */
1563 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1564 (wrqu->freq.m <= (tANI_U32)5.825e8))
1565 {
1566 tANI_U32 freq = wrqu->freq.m / 100000;
1567
1568 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1569 indx++;
1570 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1571 {
1572 return -EINVAL;
1573 }
1574 wrqu->freq.e = 0;
1575 wrqu->freq.m = freq_chan_map[indx].chan;
1576
1577 }
1578
1579 if (wrqu->freq.e == 0)
1580 {
1581 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1582 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1583 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001584 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001585 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1587 return -EINVAL;
1588 }
1589
1590 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1591
1592 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1593 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1595 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 return -EIO;
1597 }
1598
1599 for (indx = 0; indx < numChans; indx++) {
1600 if (wrqu->freq.m == validChan[indx]){
1601 break;
1602 }
1603 }
1604 }
1605 else{
1606
1607 return -EINVAL;
1608 }
1609
1610 if(indx >= numChans)
1611 {
1612 return -EINVAL;
1613 }
1614
1615 /* Set the Operational Channel */
1616 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1617 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1618 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1619
Arif Hussain6d2a3322013-11-17 19:50:10 -08001620 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001621
1622 EXIT();
1623
1624 return status;
1625}
1626
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301627static int iw_set_freq(struct net_device *dev,
1628 struct iw_request_info *info,
1629 union iwreq_data *wrqu, char *extra)
1630{
1631 int ret;
1632
1633 vos_ssr_protect(__func__);
1634 ret = __iw_set_freq(dev, info, wrqu, extra);
1635 vos_ssr_unprotect(__func__);
1636
1637 return ret;
1638}
1639
1640static int __iw_get_freq(struct net_device *dev,
1641 struct iw_request_info *info,
1642 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001643{
Jeff Johnsone7245742012-09-05 17:12:55 -07001644 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001645 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1646 tHalHandle hHal;
1647 hdd_wext_state_t *pWextState;
1648 tCsrRoamProfile * pRoamProfile;
1649 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1650
1651 ENTER();
1652
1653 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1655 return status;
1656 }
1657
1658 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1659 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1660
1661 pRoamProfile = &pWextState->roamProfile;
1662
1663 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1664 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001665 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 {
c_hpothub8245442013-11-20 23:41:09 +05301667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1668 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 return -EIO;
1670 }
1671 else
1672 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001673 status = hdd_wlan_get_freq(channel, &freq);
1674 if( TRUE == status )
1675 {
1676 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1677 * iwlist & iwconfig command shows frequency into proper
1678 * format (2.412 GHz instead of 246.2 MHz)*/
1679 fwrq->m = freq;
1680 fwrq->e = MHZ;
1681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 }
1683 }
1684 else
1685 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001686 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1687 * iwlist & iwconfig command shows frequency into proper
1688 * format (2.412 GHz instead of 246.2 MHz)*/
1689 fwrq->m = 0;
1690 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001692 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693}
1694
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301695static int iw_get_freq(struct net_device *dev,
1696 struct iw_request_info *info,
1697 struct iw_freq *fwrq, char *extra)
1698{
1699 int ret;
1700
1701 vos_ssr_protect(__func__);
1702 ret = __iw_get_freq(dev, info, fwrq, extra);
1703 vos_ssr_unprotect(__func__);
1704
1705 return ret;
1706}
1707
1708static int __iw_get_tx_power(struct net_device *dev,
1709 struct iw_request_info *info,
1710 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001711{
1712
1713 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1714 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1715 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1716
1717 if (pHddCtx->isLogpInProgress)
1718 {
1719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1720 "%s:LOGP in Progress. Ignore!!!",__func__);
1721 return -EBUSY;
1722 }
1723
1724 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1725 {
1726 wrqu->txpower.value = 0;
1727 return 0;
1728 }
1729 wlan_hdd_get_classAstats(pAdapter);
1730 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1731
1732 return 0;
1733}
1734
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301735static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 struct iw_request_info *info,
1737 union iwreq_data *wrqu, char *extra)
1738{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301739 int ret;
1740
1741 vos_ssr_protect(__func__);
1742 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1743 vos_ssr_unprotect(__func__);
1744
1745 return ret;
1746}
1747
1748static int __iw_set_tx_power(struct net_device *dev,
1749 struct iw_request_info *info,
1750 union iwreq_data *wrqu, char *extra)
1751{
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1753 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1754
1755 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1756 {
1757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1758 return 0;
1759 }
1760
1761 ENTER();
1762
1763 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1764 {
c_hpothub8245442013-11-20 23:41:09 +05301765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1766 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 return -EIO;
1768 }
1769
1770 EXIT();
1771
1772 return 0;
1773}
1774
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301775static int iw_set_tx_power(struct net_device *dev,
1776 struct iw_request_info *info,
1777 union iwreq_data *wrqu, char *extra)
1778{
1779 int ret;
1780
1781 vos_ssr_protect(__func__);
1782 ret = __iw_set_tx_power(dev, info, wrqu, extra);
1783 vos_ssr_unprotect(__func__);
1784
1785 return ret;
1786}
1787
1788static int __iw_get_bitrate(struct net_device *dev,
1789 struct iw_request_info *info,
1790 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001791{
1792 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1793 eHalStatus status = eHAL_STATUS_SUCCESS;
1794 hdd_wext_state_t *pWextState;
1795 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1796 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1797
1798 ENTER();
1799
1800 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1802 return status;
1803 }
1804
1805 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1806 wrqu->bitrate.value = 0;
1807 }
1808 else {
1809 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1810 SME_SUMMARY_STATS |
1811 SME_GLOBAL_CLASSA_STATS |
1812 SME_GLOBAL_CLASSB_STATS |
1813 SME_GLOBAL_CLASSC_STATS |
1814 SME_GLOBAL_CLASSD_STATS |
1815 SME_PER_STA_STATS,
1816 hdd_StatisticsCB, 0, FALSE,
1817 pHddStaCtx->conn_info.staId[0], pAdapter );
1818
1819 if(eHAL_STATUS_SUCCESS != status)
1820 {
1821 hddLog(VOS_TRACE_LEVEL_ERROR,
1822 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001823 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 return status;
1825 }
1826
1827 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1828
1829 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1830
1831 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1832 {
1833 hddLog(VOS_TRACE_LEVEL_ERROR,
1834 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001835 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 return VOS_STATUS_E_FAILURE;
1837 }
1838
1839 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1840 }
1841
1842 EXIT();
1843
1844 return vos_status;
1845}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301846
1847static int iw_get_bitrate(struct net_device *dev,
1848 struct iw_request_info *info,
1849 union iwreq_data *wrqu, char *extra)
1850{
1851 int ret;
1852
1853 vos_ssr_protect(__func__);
1854 ret = __iw_get_bitrate(dev, info, wrqu, extra);
1855 vos_ssr_unprotect(__func__);
1856
1857 return ret;
1858}
1859
1860
Jeff Johnson295189b2012-06-20 16:38:30 -07001861/* ccm call back function */
1862
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301863static int __iw_set_bitrate(struct net_device *dev,
1864 struct iw_request_info *info,
1865 union iwreq_data *wrqu,
1866 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001867{
1868 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1869 hdd_wext_state_t *pWextState;
1870 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1871 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1872 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1873 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1874 v_U32_t i, rate;
1875 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1876
1877 ENTER();
1878
1879 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1881 return 0;
1882 }
1883
1884 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1885
1886 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1887 {
1888 return -ENXIO ;
1889 }
1890
1891 rate = wrqu->bitrate.value;
1892
1893 if (rate == -1)
1894 {
1895 rate = WNI_CFG_FIXED_RATE_AUTO;
1896 valid_rate = TRUE;
1897 }
1898 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1899 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1900 {
1901 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1902 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1903 {
1904 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1905 WNI_CFG_SUPPORTED_RATES_11A,
1906 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1907 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1908 WNI_CFG_SUPPORTED_RATES_11B,
1909 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1910 {
1911 for (i = 0; i < (b_len + a_len); ++i)
1912 {
1913 /* supported rates returned is double the actual rate so we divide it by 2 */
1914 if ((supp_rates[i]&0x7F)/2 == rate)
1915 {
1916 valid_rate = TRUE;
1917 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1918 break;
1919 }
1920 }
1921 }
1922 }
1923 }
1924 if (valid_rate != TRUE)
1925 {
1926 return -EINVAL;
1927 }
1928 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1929 WNI_CFG_FIXED_RATE, rate,
1930 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1931 {
c_hpothub8245442013-11-20 23:41:09 +05301932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1933 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 return -EIO;
1935 }
1936 return 0;
1937}
1938
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301939static int iw_set_bitrate(struct net_device *dev,
1940 struct iw_request_info *info,
1941 union iwreq_data *wrqu,
1942 char *extra)
1943{
1944 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001945
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301946 vos_ssr_protect(__func__);
1947 ret = __iw_set_bitrate(dev, info, wrqu, extra);
1948 vos_ssr_unprotect(__func__);
1949
1950 return ret;
1951}
1952
1953static int __iw_set_genie(struct net_device *dev,
1954 struct iw_request_info *info,
1955 union iwreq_data *wrqu,
1956 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001957{
1958 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1959 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001960 u_int8_t *genie = NULL;
1961 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 v_U16_t remLen;
1963
1964 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001965
1966 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1968 "%s:LOGP in Progress. Ignore!!!", __func__);
1969 return 0;
1970 }
1971
1972 if (!wrqu->data.length) {
1973 hdd_clearRoamProfileIe(pAdapter);
1974 EXIT();
1975 return 0;
1976 }
1977
1978 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1979 wrqu->data.length);
1980 if (NULL == base_genie)
1981 {
1982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1983 "mem_alloc_copy_from_user_helper fail");
1984 return -ENOMEM;
1985 }
1986
1987 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001988
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 remLen = wrqu->data.length;
1990
Arif Hussain6d2a3322013-11-17 19:50:10 -08001991 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001992
1993 /* clear any previous genIE before this call */
1994 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1995
1996 while (remLen >= 2)
1997 {
1998 v_U16_t eLen = 0;
1999 v_U8_t elementId;
2000 elementId = *genie++;
2001 eLen = *genie++;
2002 remLen -= 2;
2003
Arif Hussain6d2a3322013-11-17 19:50:10 -08002004 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 __func__, elementId, eLen);
2006
2007 switch ( elementId )
2008 {
2009 case IE_EID_VENDOR:
2010 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002011 {
2012 kfree(base_genie);
2013 return -EINVAL;
2014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002015
2016 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2017 {
2018 v_U16_t curGenIELen = pWextState->genIE.length;
2019 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2020 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2021
2022 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2023 {
2024 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002025 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002027 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 return -ENOMEM;
2029 }
2030 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2031 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2032 pWextState->genIE.length += eLen + 2;
2033 }
2034 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2035 {
2036 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2037 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2038 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2039 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2040 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2041 }
2042 else /* any vendorId except WPA IE should be accumulated to genIE */
2043 {
2044 v_U16_t curGenIELen = pWextState->genIE.length;
2045 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2046 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2047
2048 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2049 {
2050 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002051 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002053 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 return -ENOMEM;
2055 }
2056 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2057 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2058 pWextState->genIE.length += eLen + 2;
2059 }
2060 break;
2061 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002062 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2064 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2065 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2066 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2067 break;
2068
2069 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002070 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002071 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 return 0;
2073 }
2074 genie += eLen;
2075 remLen -= eLen;
2076 }
2077 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002078 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 return 0;
2080}
2081
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302082static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 struct iw_request_info *info,
2084 union iwreq_data *wrqu,
2085 char *extra)
2086{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302087 int ret;
2088
2089 vos_ssr_protect(__func__);
2090 ret = __iw_set_genie(dev, info, wrqu, extra);
2091 vos_ssr_unprotect(__func__);
2092
2093 return ret;
2094}
2095
2096static int __iw_get_genie(struct net_device *dev,
2097 struct iw_request_info *info,
2098 union iwreq_data *wrqu,
2099 char *extra)
2100{
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 hdd_wext_state_t *pWextState;
2102 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2103 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2104 eHalStatus status;
2105 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2106 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2107
2108 ENTER();
2109
2110 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2112 return 0;
2113 }
2114
2115
Arif Hussain6d2a3322013-11-17 19:50:10 -08002116 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07002117
2118 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2119
2120 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2121 {
2122 return -ENXIO;
2123 }
2124
2125 // Return something ONLY if we are associated with an RSN or WPA network
2126 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2127 pWextState->roamProfile.negotiatedAuthType))
2128 {
2129 return -ENXIO;
2130 }
2131
2132 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2133 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2134 pAdapter->sessionId,
2135 &length,
2136 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002137 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2138 if (wrqu->data.length < length)
2139 {
2140 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2141 return -EFAULT;
2142 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002143 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002144 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002145
Arif Hussain6d2a3322013-11-17 19:50:10 -08002146 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002147
2148 EXIT();
2149
2150 return 0;
2151}
2152
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302153static int iw_get_genie(struct net_device *dev,
2154 struct iw_request_info *info,
2155 union iwreq_data *wrqu,
2156 char *extra)
2157{
2158 int ret;
2159
2160 vos_ssr_protect(__func__);
2161 ret = __iw_get_genie(dev, info, wrqu, extra);
2162 vos_ssr_unprotect(__func__);
2163
2164 return ret;
2165}
2166
2167
2168static int __iw_get_encode(struct net_device *dev,
2169 struct iw_request_info *info,
2170 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002171{
2172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2173 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2174 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2175 int keyId;
2176 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2177 int i;
2178
2179 ENTER();
2180
2181 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2183 return 0;
2184 }
2185
2186 keyId = pRoamProfile->Keys.defaultIndex;
2187
2188 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2189 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002190 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 return -EINVAL;
2192 }
2193
2194 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2195 {
2196 dwrq->flags |= IW_ENCODE_ENABLED;
2197 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2198 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2199
2200 dwrq->flags |= (keyId + 1);
2201
2202 }
2203 else
2204 {
2205 dwrq->flags |= IW_ENCODE_DISABLED;
2206 }
2207
2208 for(i=0; i < MAX_WEP_KEYS; i++)
2209 {
2210 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2211 {
2212 continue;
2213 }
2214 else
2215 {
2216 break;
2217 }
2218 }
2219
2220 if(MAX_WEP_KEYS == i)
2221 {
2222 dwrq->flags |= IW_ENCODE_NOKEY;
2223 }
2224
2225 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2226
2227 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2228 {
2229 dwrq->flags |= IW_ENCODE_OPEN;
2230 }
2231 else
2232 {
2233 dwrq->flags |= IW_ENCODE_RESTRICTED;
2234 }
2235 EXIT();
2236 return 0;
2237}
2238
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302239static int iw_get_encode(struct net_device *dev,
2240 struct iw_request_info *info,
2241 struct iw_point *dwrq, char *extra)
2242{
2243 int ret;
2244
2245 vos_ssr_protect(__func__);
2246 ret = __iw_get_encode(dev, info, dwrq, extra);
2247 vos_ssr_unprotect(__func__);
2248
2249 return ret;
2250}
2251
Jeff Johnson295189b2012-06-20 16:38:30 -07002252#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2253#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2254
2255
2256/*
2257 * This function sends a single 'key' to LIM at all time.
2258 */
2259
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302260static int __iw_get_rts_threshold(struct net_device *dev,
2261 struct iw_request_info *info,
2262 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002263{
2264 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2265 v_U32_t status = 0;
2266
2267 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2268
2269 return status;
2270}
2271
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302272static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 struct iw_request_info *info,
2274 union iwreq_data *wrqu, char *extra)
2275{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302276 int ret;
2277
2278 vos_ssr_protect(__func__);
2279 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2280 vos_ssr_unprotect(__func__);
2281
2282 return ret;
2283}
2284
2285static int __iw_set_rts_threshold(struct net_device *dev,
2286 struct iw_request_info *info,
2287 union iwreq_data *wrqu, char *extra)
2288{
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2290 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2291
2292 ENTER();
2293
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002294 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2295 {
2296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2297 "%s:LOGP in Progress. Ignore!!!", __func__);
2298 return -EAGAIN;
2299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2301 {
2302 return -EINVAL;
2303 }
2304
2305 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2306 {
c_hpothub8245442013-11-20 23:41:09 +05302307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2308 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 return -EIO;
2310 }
2311
2312 EXIT();
2313
2314 return 0;
2315}
2316
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302317static int iw_set_rts_threshold(struct net_device *dev,
2318 struct iw_request_info *info,
2319 union iwreq_data *wrqu, char *extra)
2320{
2321 int ret;
2322
2323 vos_ssr_protect(__func__);
2324 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2325 vos_ssr_unprotect(__func__);
2326
2327 return ret;
2328}
2329
2330static int __iw_get_frag_threshold(struct net_device *dev,
2331 struct iw_request_info *info,
2332 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002333{
2334 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2335 v_U32_t status = 0;
2336
2337 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2338
2339 return status;
2340}
2341
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302342static int iw_get_frag_threshold(struct net_device *dev,
2343 struct iw_request_info *info,
2344 union iwreq_data *wrqu, char *extra)
2345{
2346 int ret;
2347
2348 vos_ssr_protect(__func__);
2349 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2350 vos_ssr_unprotect(__func__);
2351
2352 return ret;
2353}
2354
2355static int __iw_set_frag_threshold(struct net_device *dev,
2356 struct iw_request_info *info,
2357 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002358{
2359 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2360 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2361
2362 ENTER();
2363
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002364 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2365 {
2366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2367 "%s:LOGP in Progress. Ignore!!!", __func__);
2368 return -EBUSY;
2369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2371 {
2372 return -EINVAL;
2373 }
2374
2375 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2376 {
c_hpothub8245442013-11-20 23:41:09 +05302377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2378 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 return -EIO;
2380 }
2381
2382 EXIT();
2383
2384 return 0;
2385}
2386
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302387static int iw_set_frag_threshold(struct net_device *dev,
2388 struct iw_request_info *info,
2389 union iwreq_data *wrqu, char *extra)
2390{
2391 int ret;
2392
2393 vos_ssr_protect(__func__);
2394 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2395 vos_ssr_unprotect(__func__);
2396
2397 return ret;
2398}
2399
Jeff Johnson295189b2012-06-20 16:38:30 -07002400static int iw_get_power_mode(struct net_device *dev,
2401 struct iw_request_info *info,
2402 union iwreq_data *wrqu, char *extra)
2403{
2404 ENTER();
2405 return -EOPNOTSUPP;
2406}
2407
2408static int iw_set_power_mode(struct net_device *dev,
2409 struct iw_request_info *info,
2410 union iwreq_data *wrqu, char *extra)
2411{
2412 ENTER();
2413 return -EOPNOTSUPP;
2414}
2415
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302416static int __iw_get_range(struct net_device *dev,
2417 struct iw_request_info *info,
2418 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002419{
2420 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2421 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2422 struct iw_range *range = (struct iw_range *) extra;
2423
2424 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2425
2426 v_U32_t num_channels = sizeof(channels);
2427 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2428 v_U32_t a_len;
2429 v_U32_t b_len;
2430 v_U32_t active_phy_mode = 0;
2431 v_U8_t index = 0, i;
2432
2433 ENTER();
2434
2435 wrqu->data.length = sizeof(struct iw_range);
2436 memset(range, 0, sizeof(struct iw_range));
2437
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002438 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2439 {
2440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2441 "%s:LOGP in Progress. Ignore!!!", __func__);
2442 return -EBUSY;
2443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002444
2445 /*Get the phy mode*/
2446 if (ccmCfgGetInt(hHal,
2447 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2448 {
2449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002450 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002451
2452 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2453 {
2454 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002455 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 if (ccmCfgGetStr(hHal,
2457 WNI_CFG_SUPPORTED_RATES_11A,
2458 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2459 {
2460 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2461 {
2462 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2463 }
2464 for (i = 0; i < a_len; i++)
2465 {
2466 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2467 }
2468 range->num_bitrates = a_len;
2469 }
2470 else
2471 {
2472 return -EIO;
2473 }
2474 }
2475 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2476 {
2477 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002478 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 if (ccmCfgGetStr(hHal,
2480 WNI_CFG_SUPPORTED_RATES_11B,
2481 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2482 {
2483 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2484 {
2485 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2486 }
2487 for (i = 0; i < b_len; i++)
2488 {
2489 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2490 }
2491 range->num_bitrates = b_len;
2492 }
2493 else
2494 {
2495 return -EIO;
2496 }
2497 }
2498 }
2499
2500 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2501 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2502 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2503
2504 range->encoding_size[0] = 5;
2505 range->encoding_size[1] = 13;
2506 range->num_encoding_sizes = 2;
2507 range->max_encoding_tokens = MAX_WEP_KEYS;
2508
2509 // we support through Wireless Extensions 22
2510 range->we_version_compiled = WIRELESS_EXT;
2511 range->we_version_source = 22;
2512
2513 /*Supported Channels and Frequencies*/
2514 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2515 {
c_hpothub8245442013-11-20 23:41:09 +05302516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2517 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 return -EIO;
2519 }
2520 if (num_channels > IW_MAX_FREQUENCIES)
2521 {
2522 num_channels = IW_MAX_FREQUENCIES;
2523 }
2524
2525 range->num_channels = num_channels;
2526 range->num_frequency = num_channels;
2527
2528 for (index=0; index < num_channels; index++)
2529 {
2530 v_U32_t frq_indx = 0;
2531
2532 range->freq[index].i = channels[index];
2533 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2534 {
2535 if(channels[index] == freq_chan_map[frq_indx].chan)
2536 {
2537 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2538 range->freq[index].e = 1;
2539 break;
2540 }
2541 frq_indx++;
2542 }
2543 }
2544
2545 /* Event capability (kernel + driver) */
2546 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2547 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2548 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2549 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2550
2551 /*Encryption capability*/
2552 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2553 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2554
2555 /* Txpower capability */
2556 range->txpower_capa = IW_TXPOW_MWATT;
2557
2558 /*Scanning capability*/
2559 #if WIRELESS_EXT >= 22
2560 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2561 #endif
2562
2563 EXIT();
2564 return 0;
2565}
2566
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302567static int iw_get_range(struct net_device *dev,
2568 struct iw_request_info *info,
2569 union iwreq_data *wrqu, char *extra)
2570{
2571 int ret;
2572
2573 vos_ssr_protect(__func__);
2574 ret = __iw_get_range(dev, info, wrqu, extra);
2575 vos_ssr_unprotect(__func__);
2576
2577 return ret;
2578}
2579
Jeff Johnson295189b2012-06-20 16:38:30 -07002580/* Callback function registered with PMC to know status of PMC request */
2581static void iw_power_callback_fn (void *pContext, eHalStatus status)
2582{
2583 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584
2585 if (NULL == pContext)
2586 {
2587 hddLog(VOS_TRACE_LEVEL_ERROR,
2588 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002589 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 return;
2591 }
2592
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002594
Jeff Johnson72a40512013-12-19 10:14:15 -08002595 /* there is a race condition that exists between this callback
2596 function and the caller since the caller could time out either
2597 before or while this code is executing. we use a spinlock to
2598 serialize these actions */
2599 spin_lock(&hdd_context_lock);
2600
2601 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 {
2603 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002604 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002606 "%s: Invalid context, magic [%08x]",
2607 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002608
2609 if (ioctl_debug)
2610 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002611 pr_info("%s: Invalid context, magic [%08x]\n",
2612 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 }
2614 return;
2615 }
2616
Jeff Johnson72a40512013-12-19 10:14:15 -08002617 /* context is valid so caller is still waiting */
2618
2619 /* paranoia: invalidate the magic */
2620 pStatsContext->magic = 0;
2621
2622 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002624
2625 /* serialization is complete */
2626 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002627}
2628
2629/* Callback function for tx per hit */
2630void hdd_tx_per_hit_cb (void *pCallbackContext)
2631{
2632 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2633 unsigned char tx_fail[16];
2634 union iwreq_data wrqu;
2635
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05302636 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002638 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 return;
2640 }
2641 memset(&wrqu, 0, sizeof(wrqu));
2642 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2643 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2644}
2645
2646void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2647{
2648 struct statsContext *pStatsContext;
2649 tCsrGlobalClassAStatsInfo *pClassAStats;
2650 hdd_adapter_t *pAdapter;
2651
2652 if (ioctl_debug)
2653 {
2654 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002655 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 }
2657
2658 if ((NULL == pStats) || (NULL == pContext))
2659 {
2660 hddLog(VOS_TRACE_LEVEL_ERROR,
2661 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002662 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 return;
2664 }
2665
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 pClassAStats = pStats;
2667 pStatsContext = pContext;
2668 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002669
2670 /* there is a race condition that exists between this callback
2671 function and the caller since the caller could time out either
2672 before or while this code is executing. we use a spinlock to
2673 serialize these actions */
2674 spin_lock(&hdd_context_lock);
2675
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2677 {
2678 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002679 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 hddLog(VOS_TRACE_LEVEL_WARN,
2681 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002682 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 if (ioctl_debug)
2684 {
2685 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002686 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 }
2688 return;
2689 }
2690
Jeff Johnson72a40512013-12-19 10:14:15 -08002691 /* context is valid so caller is still waiting */
2692
2693 /* paranoia: invalidate the magic */
2694 pStatsContext->magic = 0;
2695
2696 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2698
Jeff Johnson72a40512013-12-19 10:14:15 -08002699 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002701
2702 /* serialization is complete */
2703 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002704}
2705
2706VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2707{
2708 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2709 eHalStatus hstatus;
2710 long lrc;
2711 struct statsContext context;
2712
2713 if (NULL == pAdapter)
2714 {
2715 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2716 return VOS_STATUS_E_FAULT;
2717 }
2718 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2719 {
2720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2721 return VOS_STATUS_SUCCESS;
2722 }
2723
2724 /* we are connected
2725 prepare our callback context */
2726 init_completion(&context.completion);
2727 context.pAdapter = pAdapter;
2728 context.magic = STATS_CONTEXT_MAGIC;
2729 /* query only for Class A statistics (which include link speed) */
2730 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2731 eCSR_HDD,
2732 SME_GLOBAL_CLASSA_STATS,
2733 hdd_GetClassA_statisticsCB,
2734 0, // not periodic
2735 FALSE, //non-cached results
2736 pHddStaCtx->conn_info.staId[0],
2737 &context);
2738 if (eHAL_STATUS_SUCCESS != hstatus)
2739 {
2740 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002741 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002742 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 /* we'll returned a cached value below */
2744 }
2745 else
2746 {
2747 /* request was sent -- wait for the response */
2748 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2749 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 if (lrc <= 0)
2751 {
2752 hddLog(VOS_TRACE_LEVEL_ERROR,
2753 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002754 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 }
2756 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002757
2758 /* either we never sent a request, we sent a request and received a
2759 response or we sent a request and timed out. if we never sent a
2760 request or if we sent a request and got a response, we want to
2761 clear the magic out of paranoia. if we timed out there is a
2762 race condition such that the callback function could be
2763 executing at the same time we are. of primary concern is if the
2764 callback function had already verified the "magic" but had not
2765 yet set the completion variable when a timeout occurred. we
2766 serialize these activities by invalidating the magic while
2767 holding a shared spinlock which will cause us to block if the
2768 callback is currently executing */
2769 spin_lock(&hdd_context_lock);
2770 context.magic = 0;
2771 spin_unlock(&hdd_context_lock);
2772
2773 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 return VOS_STATUS_SUCCESS;
2775}
2776
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002777static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2778{
2779 struct statsContext *pStatsContext;
2780 tCsrSummaryStatsInfo *pSummaryStats;
2781 tCsrGlobalClassAStatsInfo *pClassAStats;
2782 hdd_adapter_t *pAdapter;
2783
2784 if (ioctl_debug)
2785 {
2786 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002787 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002788 }
2789
2790 if ((NULL == pStats) || (NULL == pContext))
2791 {
2792 hddLog(VOS_TRACE_LEVEL_ERROR,
2793 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002794 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002795 return;
2796 }
2797
Jeff Johnson72a40512013-12-19 10:14:15 -08002798 /* there is a race condition that exists between this callback
2799 function and the caller since the caller could time out either
2800 before or while this code is executing. we use a spinlock to
2801 serialize these actions */
2802 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002803
2804 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2805 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2806 pStatsContext = pContext;
2807 pAdapter = pStatsContext->pAdapter;
2808 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2809 {
2810 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002811 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002812 hddLog(VOS_TRACE_LEVEL_WARN,
2813 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002814 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002815 if (ioctl_debug)
2816 {
2817 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002818 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002819 }
2820 return;
2821 }
2822
Jeff Johnson72a40512013-12-19 10:14:15 -08002823 /* context is valid so caller is still waiting */
2824
2825 /* paranoia: invalidate the magic */
2826 pStatsContext->magic = 0;
2827
2828 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002829 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2830 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2831
Jeff Johnson72a40512013-12-19 10:14:15 -08002832 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002833 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002834
2835 /* serialization is complete */
2836 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002837}
2838
2839VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2840{
2841 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2842 eHalStatus hstatus;
2843 long lrc;
2844 struct statsContext context;
2845
2846 if (NULL == pAdapter)
2847 {
2848 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2849 return VOS_STATUS_SUCCESS;
2850 }
2851
2852 /* we are connected
2853 prepare our callback context */
2854 init_completion(&context.completion);
2855 context.pAdapter = pAdapter;
2856 context.magic = STATS_CONTEXT_MAGIC;
2857
2858 /* query only for Summary & Class A statistics */
2859 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2860 eCSR_HDD,
2861 SME_SUMMARY_STATS |
2862 SME_GLOBAL_CLASSA_STATS,
2863 hdd_get_station_statisticsCB,
2864 0, // not periodic
2865 FALSE, //non-cached results
2866 pHddStaCtx->conn_info.staId[0],
2867 &context);
2868 if (eHAL_STATUS_SUCCESS != hstatus)
2869 {
2870 hddLog(VOS_TRACE_LEVEL_ERROR,
2871 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002872 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002873 /* we'll return with cached values */
2874 }
2875 else
2876 {
2877 /* request was sent -- wait for the response */
2878 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2879 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002880
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002881 if (lrc <= 0)
2882 {
2883 hddLog(VOS_TRACE_LEVEL_ERROR,
2884 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002885 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002886 }
2887 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002888
2889 /* either we never sent a request, we sent a request and received a
2890 response or we sent a request and timed out. if we never sent a
2891 request or if we sent a request and got a response, we want to
2892 clear the magic out of paranoia. if we timed out there is a
2893 race condition such that the callback function could be
2894 executing at the same time we are. of primary concern is if the
2895 callback function had already verified the "magic" but had not
2896 yet set the completion variable when a timeout occurred. we
2897 serialize these activities by invalidating the magic while
2898 holding a shared spinlock which will cause us to block if the
2899 callback is currently executing */
2900 spin_lock(&hdd_context_lock);
2901 context.magic = 0;
2902 spin_unlock(&hdd_context_lock);
2903
2904 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002905 return VOS_STATUS_SUCCESS;
2906}
2907
2908
Jeff Johnson295189b2012-06-20 16:38:30 -07002909/*
2910 * Support for the LINKSPEED private command
2911 * Per the WiFi framework the response must be of the form
2912 * "LinkSpeed xx"
2913 */
2914static int iw_get_linkspeed(struct net_device *dev,
2915 struct iw_request_info *info,
2916 union iwreq_data *wrqu, char *extra)
2917{
2918 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302919 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302921 int len = sizeof(v_U32_t) + 1;
2922 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302924 VOS_STATUS status;
2925 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002926
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302927 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2928
2929 valid = wlan_hdd_validate_context(pHddCtx);
2930
2931 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002932 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302933 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2934 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002935 }
2936
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2938 {
2939 /* we are not connected so we don't have a classAstats */
2940 link_speed = 0;
2941 }
2942 else
2943 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302944 status = wlan_hdd_get_classAstats(pAdapter);
2945
2946 if (!VOS_IS_STATUS_SUCCESS(status ))
2947 {
2948 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2949 return -EINVAL;
2950 }
2951
2952 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2953 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2954 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2955 &link_speed);
2956
2957 link_speed = link_speed / 10;
2958
2959 if (0 == link_speed)
2960 {
2961 /* The linkspeed returned by HAL is in units of 500kbps.
2962 * converting it to mbps.
2963 * This is required to support legacy firmware which does
2964 * not return link capacity.
2965 */
2966 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2967 }
2968
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 }
2970
2971 wrqu->data.length = len;
2972 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002973 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 if ((rc < 0) || (rc >= len))
2975 {
2976 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302977 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 return -EIO;
2979 }
2980
2981 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002982 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002983}
2984
Arif Hussain695279c2014-03-24 14:06:07 -07002985/*
2986 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2987 *
2988 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05302989static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07002990 struct iw_request_info *info,
2991 union iwreq_data *wrqu, char *extra)
2992{
2993 int rc;
2994
2995 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2996
2997 if (rc < 0)
2998 return rc;
2999
3000 /* a value is being successfully returned */
3001 return 0;
3002}
Jeff Johnson295189b2012-06-20 16:38:30 -07003003
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303004static int iw_get_linkspeed_priv(struct net_device *dev,
3005 struct iw_request_info *info,
3006 union iwreq_data *wrqu, char *extra)
3007{
3008 int ret;
3009
3010 vos_ssr_protect(__func__);
3011 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3012 vos_ssr_unprotect(__func__);
3013
3014 return ret;
3015}
3016
Jeff Johnson295189b2012-06-20 16:38:30 -07003017/*
3018 * Support for the RSSI & RSSI-APPROX private commands
3019 * Per the WiFi framework the response must be of the form
3020 * "<ssid> rssi <xx>"
3021 * unless we are not associated, in which case the response is
3022 * "OK"
3023 */
3024static int iw_get_rssi(struct net_device *dev,
3025 struct iw_request_info *info,
3026 union iwreq_data *wrqu, char *extra)
3027{
3028 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003029 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 int len = wrqu->data.length;
3031 v_S7_t s7Rssi = 0;
3032 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3033 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3034 VOS_STATUS vosStatus;
3035 int rc;
3036
3037 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3038 (0 == ssidlen) || (ssidlen >= len))
3039 {
3040 /* we are not connected or our SSID is too long
3041 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003042 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 }
3044 else
3045 {
3046 /* we are connected with a valid SSID
3047 so we can write the SSID into the return buffer
3048 (note that it is not NUL-terminated) */
3049 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3050
3051 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3052
3053 if (VOS_STATUS_SUCCESS == vosStatus)
3054 {
3055 /* append the rssi to the ssid in the format required by
3056 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003057 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303058 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 }
3060 else
3061 {
3062 rc = -1;
3063 }
3064 }
3065
3066 /* verify that we wrote a valid response */
3067 if ((rc < 0) || (rc >= len))
3068 {
3069 // encoding or length error?
3070 hddLog(VOS_TRACE_LEVEL_ERROR,
3071 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003072 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 return -EIO;
3074 }
3075
3076 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003077 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003078}
3079
3080/*
3081 * Support for SoftAP channel range private command
3082 */
3083static int iw_softap_set_channel_range( struct net_device *dev,
3084 int startChannel,
3085 int endChannel,
3086 int band)
3087{
Jeff Johnson43971f52012-07-17 12:26:56 -07003088 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 int ret = 0;
3090 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3091 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003092 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3093
Jeff Johnson295189b2012-06-20 16:38:30 -07003094
3095 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3096 if (VOS_STATUS_SUCCESS != status)
3097 {
3098 ret = -EINVAL;
3099 }
Yathish9f22e662012-12-10 14:21:35 -08003100 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 return ret;
3102}
3103
3104VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3105{
3106 struct statsContext context;
3107 eHalStatus status;
3108 hdd_context_t *pHddCtx;
3109
3110 if (NULL == pAdapter)
3111 {
3112 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3113 return VOS_STATUS_E_FAULT;
3114 }
3115
3116 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3117 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303118 if (pHddCtx->isLogpInProgress) {
3119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3120 "%s:LOGP in Progress. Ignore!!!", __func__);
3121 return VOS_STATUS_E_FAILURE;
3122 }
3123
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 init_completion(&context.completion);
3125
3126 context.pAdapter = pAdapter;
3127 context.magic = POWER_CONTEXT_MAGIC;
3128
3129 if (DRIVER_POWER_MODE_ACTIVE == mode)
3130 {
3131 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3132 "Full Power", __func__);
3133 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3134 iw_power_callback_fn, &context,
3135 eSME_FULL_PWR_NEEDED_BY_HDD);
3136 // Enter Full power command received from GUI this means we are disconnected
3137 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3138 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3139 if (eHAL_STATUS_PMC_PENDING == status)
3140 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003141 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 int lrc = wait_for_completion_interruptible_timeout(
3143 &context.completion,
3144 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003145
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 if (lrc <= 0)
3147 {
3148 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003149 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 }
3151 }
3152 }
3153 else if (DRIVER_POWER_MODE_AUTO == mode)
3154 {
3155 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3156 {
3157 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3158 __func__);
3159 // Enter BMPS command received from GUI this means DHCP is completed
3160 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3161 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3162 FALSE);
3163 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3164 iw_power_callback_fn, &context);
3165 if (eHAL_STATUS_PMC_PENDING == status)
3166 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003167 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 int lrc = wait_for_completion_interruptible_timeout(
3169 &context.completion,
3170 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 if (lrc <= 0)
3172 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003173 hddLog(VOS_TRACE_LEVEL_ERROR,
3174 "%s: SME %s while requesting BMPS",
3175 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 }
3177 }
3178 }
3179 else
3180 {
3181 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3182 "enabled in the cfg");
3183 }
3184 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003185
3186 /* either we never sent a request, we sent a request and received a
3187 response or we sent a request and timed out. if we never sent a
3188 request or if we sent a request and got a response, we want to
3189 clear the magic out of paranoia. if we timed out there is a
3190 race condition such that the callback function could be
3191 executing at the same time we are. of primary concern is if the
3192 callback function had already verified the "magic" but had not
3193 yet set the completion variable when a timeout occurred. we
3194 serialize these activities by invalidating the magic while
3195 holding a shared spinlock which will cause us to block if the
3196 callback is currently executing */
3197 spin_lock(&hdd_context_lock);
3198 context.magic = 0;
3199 spin_unlock(&hdd_context_lock);
3200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 return VOS_STATUS_SUCCESS;
3202}
3203
3204VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3205 hdd_adapter_t *pAdapter)
3206{
3207 VOS_STATUS vos_Status;
3208
3209 if ((NULL == pAdapter) || (NULL == pHddCtx))
3210 {
3211 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3212 return VOS_STATUS_E_FAULT;
3213 }
3214
3215 /**Exit from Deep sleep or standby if we get the driver
3216 START cmd from android GUI
3217 */
3218 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3219 {
3220 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3221 "from Stand by",__func__);
3222 vos_Status = hdd_exit_standby(pHddCtx);
3223 }
3224 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3225 {
3226 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3227 "from deep sleep",__func__);
3228 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3229 }
3230 else
3231 {
3232 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3233 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3234 vos_Status = VOS_STATUS_SUCCESS;
3235 }
3236
3237 return vos_Status;
3238}
3239
3240VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3241{
3242 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3243
3244 if (NULL == pHddCtx)
3245 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303246 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 return VOS_STATUS_E_FAULT;
3248 }
3249
3250 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3251 {
3252 //Execute standby procedure.
3253 //Executing standby procedure will cause the STA to
3254 //disassociate first and then the chip will be put into standby.
3255 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3256 vos_Status = hdd_enter_standby(pHddCtx);
3257 }
3258 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3259 pHddCtx->cfg_ini->nEnableDriverStop)
3260 {
3261 //Execute deep sleep procedure
3262 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003263 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 //Deep sleep not supported
3265 vos_Status = hdd_enter_standby(pHddCtx);
3266 }
3267 else
3268 {
3269 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3270 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3271 vos_Status = VOS_STATUS_SUCCESS;
3272 }
3273
3274 return vos_Status;
3275}
3276
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003277
3278void* wlan_hdd_change_country_code_callback(void *pAdapter)
3279{
3280
3281 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003282 complete(&call_back_pAdapter->change_country_code);
3283
3284 return NULL;
3285}
3286
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303287static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 struct iw_request_info *info,
3289 union iwreq_data *wrqu, char *extra)
3290{
3291 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003292 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 int cmd_len = wrqu->data.length;
3294 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003295 int rc = 0;
3296 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3297
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3299
3300 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003301 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3302 wrqu->data.length);
3303 if (NULL == cmd)
3304 {
3305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3306 "mem_alloc_copy_from_user_helper fail");
3307 return -ENOMEM;
3308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003309
3310 if (ioctl_debug)
3311 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003312 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 }
3314
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003315 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3316 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003317
3318 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003319 if (ioctl_debug)
3320 {
3321 pr_info("%s: RESTART in progress\n", __func__);
3322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003323
Arif Hussain24bfa702014-01-22 13:51:30 -08003324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003326 kfree(cmd);
3327 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 }
3329
Arif Hussain24bfa702014-01-22 13:51:30 -08003330 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003332 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3334 "%s: Error in iw_set_scan!", __func__);
3335 rc = -EINVAL;
3336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 }
3338 else if( strcasecmp(cmd, "start") == 0 ) {
3339
Arif Hussain6d2a3322013-11-17 19:50:10 -08003340 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003342
Arif Hussain24bfa702014-01-22 13:51:30 -08003343 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3344 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 {
3346 union iwreq_data wrqu;
3347 char buf[10];
3348
3349 memset(&wrqu, 0, sizeof(wrqu));
3350 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3351 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3352 }
3353 else
3354 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003355 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3356 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 }
3358 goto done;
3359 }
3360 else if( strcasecmp(cmd, "stop") == 0 )
3361 {
3362 union iwreq_data wrqu;
3363 char buf[10];
3364
Arif Hussain6d2a3322013-11-17 19:50:10 -08003365 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003366
3367 wlan_hdd_enter_lowpower(pHddCtx);
3368 memset(&wrqu, 0, sizeof(wrqu));
3369 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3370 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 goto done;
3372 }
3373 else if (strcasecmp(cmd, "macaddr") == 0)
3374 {
3375 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3376 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3377 }
3378 else if (strcasecmp(cmd, "scan-active") == 0)
3379 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303380 hddLog(VOS_TRACE_LEVEL_ERROR,
3381 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003382 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 ret = snprintf(cmd, cmd_len, "OK");
3384 }
3385 else if (strcasecmp(cmd, "scan-passive") == 0)
3386 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303387 hddLog(VOS_TRACE_LEVEL_ERROR,
3388 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003389 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 ret = snprintf(cmd, cmd_len, "OK");
3391 }
3392 else if( strcasecmp(cmd, "scan-mode") == 0 )
3393 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003394 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 }
3396 else if( strcasecmp(cmd, "linkspeed") == 0 )
3397 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003398 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 }
3400 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3401 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003402 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003403 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003404
3405 country_code = cmd + 8;
3406
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003407 init_completion(&pAdapter->change_country_code);
3408
Arif Hussain24bfa702014-01-22 13:51:30 -08003409 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003410 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 country_code,
3412 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303413 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303414 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303415 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003416
3417 /* Wait for completion */
3418 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3419 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3420
3421 if (lrc <= 0)
3422 {
3423 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003424 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003425 }
3426
Arif Hussain24bfa702014-01-22 13:51:30 -08003427 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003429 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003430 "%s: SME Change Country code fail", __func__);
3431 kfree(cmd);
3432 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 }
3434 }
3435 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3436 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003437 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 }
3439 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3440 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003441 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003442
Wilson Yang1be3e652013-10-09 15:18:31 -07003443 if (9 < cmd_len)
3444 {
3445 ptr = (char*)(cmd + 9);
3446
3447 }else{
3448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3449 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003450 kfree(cmd);
3451 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003452 }
3453
3454 if (1 != sscanf(ptr,"%d",&mode))
3455 {
3456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3457 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003458 kfree(cmd);
3459 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003460 }
3461
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 wlan_hdd_enter_bmps(pAdapter, mode);
3463 /*TODO:Set the power mode*/
3464 }
3465 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3466 v_U32_t pmc_state;
3467 v_U16_t value;
3468
3469 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3470 if(pmc_state == BMPS) {
3471 value = DRIVER_POWER_MODE_AUTO;
3472 }
3473 else {
3474 value = DRIVER_POWER_MODE_ACTIVE;
3475 }
3476 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3477 }
3478 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003479 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 /*TODO: set the btcoexmode*/
3481 }
3482 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3483
Arif Hussain6d2a3322013-11-17 19:50:10 -08003484 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 /*TODO: Return the btcoex status*/
3486 }
3487 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3488
Arif Hussain6d2a3322013-11-17 19:50:10 -08003489 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003490
3491 /*TODO: Enable Rx data Filter*/
3492 }
3493 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3494
Arif Hussain6d2a3322013-11-17 19:50:10 -08003495 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003496
3497 /*TODO: Disable Rx data Filter*/
3498 }
3499 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3500
Arif Hussain6d2a3322013-11-17 19:50:10 -08003501 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 /*TODO: rxfilter-statistics*/
3503 }
3504 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3505
Arif Hussain6d2a3322013-11-17 19:50:10 -08003506 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 /*TODO: rxfilter-add*/
3508 }
3509 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3510
Arif Hussain6d2a3322013-11-17 19:50:10 -08003511 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 /*TODO: rxfilter-remove*/
3513 }
3514#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003515 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3516 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3517 /*TODO: support pnosetup*/
3518 }
3519 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3520 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3521 /*TODO: support pnoforce*/
3522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3524
Arif Hussain6d2a3322013-11-17 19:50:10 -08003525 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003526 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3527 kfree(cmd);
3528 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 }
3530 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003531 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003532 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3533 kfree(cmd);
3534 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 }
3536#endif /*FEATURE_WLAN_SCAN_PNO*/
3537 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003538 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003539 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3540 kfree(cmd);
3541 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 }
3543 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3544 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003545 char *ptr;
3546
3547 if (18 < cmd_len)
3548 {
3549 ptr = (char*)(cmd + 18);
3550 }else{
3551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3552 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003553 kfree(cmd);
3554 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003555 }
3556
Jeff Johnson02797792013-10-26 19:17:13 -07003557 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003558 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3559 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3560 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3561 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3562 {
3563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3564 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003565 kfree(cmd);
3566 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003568
3569 // parameters checking
3570 // period has to be larger than 0
3571 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3572 {
3573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003574 kfree(cmd);
3575 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 }
3577
3578 // use default value 5 is the input is not reasonable. in unit of 10%
3579 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3580 {
3581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3582 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3583 }
3584
3585 // default is 5
3586 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3587 {
3588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3589 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3590 }
3591
Arif Hussain24bfa702014-01-22 13:51:30 -08003592 if (eHAL_STATUS_SUCCESS !=
3593 sme_SetTxPerTracking(pHddCtx->hHal,
3594 hdd_tx_per_hit_cb,
3595 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003597 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 }
3599 }
3600 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003601 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3602 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 }
3604done:
3605 /* many of the commands write information back into the command
3606 string using snprintf(). check the return value here in one
3607 place */
3608 if ((ret < 0) || (ret >= cmd_len))
3609 {
3610 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003611 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003613 else if (ret > 0)
3614 {
3615 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3616 {
3617 hddLog(VOS_TRACE_LEVEL_ERROR,
3618 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003619 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003620 return -EFAULT;
3621 }
3622 wrqu->data.length = ret;
3623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003624
3625 if (ioctl_debug)
3626 {
3627 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003628 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003630 kfree(cmd);
3631 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003632}
3633
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303634static int iw_set_priv(struct net_device *dev,
3635 struct iw_request_info *info,
3636 union iwreq_data *wrqu, char *extra)
3637{
3638 int ret;
3639 vos_ssr_protect(__func__);
3640 ret = __iw_set_priv(dev, info, wrqu, extra);
3641 vos_ssr_unprotect(__func__);
3642
3643 return ret;
3644}
3645
Jeff Johnson295189b2012-06-20 16:38:30 -07003646static int iw_set_nick(struct net_device *dev,
3647 struct iw_request_info *info,
3648 union iwreq_data *wrqu, char *extra)
3649{
3650 ENTER();
3651 return 0;
3652}
3653
3654static int iw_get_nick(struct net_device *dev,
3655 struct iw_request_info *info,
3656 union iwreq_data *wrqu, char *extra)
3657{
3658 ENTER();
3659 return 0;
3660}
3661
3662static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3663{
3664 ENTER();
3665 return NULL;
3666}
3667
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303668static int __iw_set_encode(struct net_device *dev,
3669 struct iw_request_info *info,
3670 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003671
3672{
3673 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3674 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3675 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3676 struct iw_point *encoderq = &(wrqu->encoding);
3677 v_U32_t keyId;
3678 v_U8_t key_length;
3679 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3680 v_BOOL_t fKeyPresent = 0;
3681 int i;
3682 eHalStatus status = eHAL_STATUS_SUCCESS;
3683
3684
3685 ENTER();
3686
3687 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3688 {
3689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3690 "%s:LOGP in Progress. Ignore!!!",__func__);
3691 return 0;
3692 }
3693
3694
3695 keyId = encoderq->flags & IW_ENCODE_INDEX;
3696
3697 if(keyId)
3698 {
3699 if(keyId > MAX_WEP_KEYS)
3700 {
3701 return -EINVAL;
3702 }
3703
3704 fKeyPresent = 1;
3705 keyId--;
3706 }
3707 else
3708 {
3709 fKeyPresent = 0;
3710 }
3711
3712
3713 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3714 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 if(!fKeyPresent) {
3717
3718 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3719
3720 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3721 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3722 }
3723 }
3724 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3725 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3726 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3727 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3728
3729 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3730 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3731
3732 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3733 {
3734 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3735 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003736 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303737 {
3738 long ret;
3739 ret = wait_for_completion_interruptible_timeout(
3740 &pAdapter->disconnect_comp_var,
3741 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3742 if (ret <= 0)
3743 hddLog(VOS_TRACE_LEVEL_ERROR,
3744 FL("failed wait on disconnect_comp_var %ld"), ret);
3745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 }
3747
3748 return status;
3749
3750 }
3751
3752 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3753 {
3754 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3755
3756 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3757
3758 }
3759
3760
3761 if(wrqu->data.length > 0)
3762 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003763 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003764
3765 key_length = wrqu->data.length;
3766
3767 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3768
3769 if(5 == key_length)
3770 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003771 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003772
3773 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3774 {
3775 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3776 }
3777 else
3778 {
3779 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3780 }
3781 }
3782 else if(13 == key_length)
3783 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003784 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003785
3786 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3787 {
3788 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3789 }
3790 else
3791 {
3792 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3793 }
3794 }
3795 else
3796 {
3797 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003798 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 return -EINVAL;
3800 }
3801
3802 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3803 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3804 pWextState->roamProfile.EncryptionType.numEntries = 1;
3805 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3806 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3807 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3808
3809 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3810 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3811 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3812 {
3813
3814 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3815
3816 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3817 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3818
3819 return status;
3820 }
3821 }
3822
3823 return 0;
3824}
3825
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303826static int iw_set_encode(struct net_device *dev,
3827 struct iw_request_info *info,
3828 union iwreq_data *wrqu,char *extra)
3829{
3830 int ret;
3831
3832 vos_ssr_protect(__func__);
3833 ret = __iw_set_encode(dev, info, wrqu, extra);
3834 vos_ssr_unprotect(__func__);
3835
3836 return ret;
3837}
3838
3839static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 struct iw_request_info *info,
3841 struct iw_point *dwrq,
3842 char *extra)
3843{
3844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3845 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3846 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3847 int keyId;
3848 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3849 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3850 int i;
3851
3852 ENTER();
3853
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003854 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3855 {
3856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3857 "%s:LOGP in Progress. Ignore!!!", __func__);
3858 return -EBUSY;
3859 }
3860
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 keyId = pRoamProfile->Keys.defaultIndex;
3862
3863 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3864 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003865 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 return -EINVAL;
3867 }
3868
3869 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3870 {
3871 dwrq->flags |= IW_ENCODE_ENABLED;
3872 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303873 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3874 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 }
3876 else
3877 {
3878 dwrq->flags |= IW_ENCODE_DISABLED;
3879 }
3880
3881 for(i=0; i < MAX_WEP_KEYS; i++)
3882 {
3883 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3884 {
3885 continue;
3886 }
3887 else
3888 {
3889 break;
3890 }
3891 }
3892
3893 if(MAX_WEP_KEYS == i)
3894 {
3895 dwrq->flags |= IW_ENCODE_NOKEY;
3896 }
3897 else
3898 {
3899 dwrq->flags |= IW_ENCODE_ENABLED;
3900 }
3901
3902 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3903
3904 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3905 {
3906 dwrq->flags |= IW_ENCODE_DISABLED;
3907 }
3908
3909 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3910
3911 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3912 {
3913 dwrq->flags |= IW_ENCODE_OPEN;
3914 }
3915 else
3916 {
3917 dwrq->flags |= IW_ENCODE_RESTRICTED;
3918 }
3919 EXIT();
3920 return 0;
3921
3922}
3923
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303924static int iw_get_encodeext(struct net_device *dev,
3925 struct iw_request_info *info,
3926 struct iw_point *dwrq,
3927 char *extra)
3928{
3929 int ret;
3930 vos_ssr_protect(__func__);
3931 ret = __iw_get_encodeext(dev, info, dwrq, extra);
3932 vos_ssr_unprotect(__func__);
3933
3934 return ret;
3935}
3936
3937static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 struct iw_request_info *info,
3939 union iwreq_data *wrqu, char *extra)
3940{
3941 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3942 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3943 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3944 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3945
3946 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3947 v_U32_t status = 0;
3948
3949 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3950
3951 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3952
3953 int key_index;
3954 struct iw_point *encoding = &wrqu->encoding;
3955 tCsrRoamSetKey setKey;
3956 v_U32_t roamId= 0xFF;
3957 VOS_STATUS vos_status;
3958
3959 ENTER();
3960
3961 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3962 {
3963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3964 "%s:LOGP in Progress. Ignore!!!",__func__);
3965 return 0;
3966 }
3967
3968 key_index = encoding->flags & IW_ENCODE_INDEX;
3969
3970 if(key_index > 0) {
3971
3972 /*Convert from 1-based to 0-based keying*/
3973 key_index--;
3974 }
3975 if(!ext->key_len) {
3976
3977 /*Set the encrytion type to NONE*/
3978 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3979 return status;
3980 }
3981
3982 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3983 (IW_ENCODE_ALG_WEP == ext->alg))
3984 {
3985 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3986
Agarwal Ashish971c2882013-10-30 20:11:12 +05303987 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3988 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 return -EINVAL;
3990 }
3991 else {
3992 /*Static wep, update the roam profile with the keys */
3993 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3994 key_index < CSR_MAX_NUM_KEY) {
3995 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3996 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3997
3998 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3999 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4000
4001 }
4002 }
4003 return status;
4004 }
4005
4006 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4007
4008 setKey.keyId = key_index;
4009 setKey.keyLength = ext->key_len;
4010
4011 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4012 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4013 }
4014
4015 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4016 /*Key direction for group is RX only*/
4017 setKey.keyDirection = eSIR_RX_ONLY;
4018 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4019 }
4020 else {
4021
4022 setKey.keyDirection = eSIR_TX_RX;
4023 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4024 }
4025
4026 /*For supplicant pae role is zero*/
4027 setKey.paeRole = 0;
4028
4029 switch(ext->alg)
4030 {
4031 case IW_ENCODE_ALG_NONE:
4032 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4033 break;
4034
4035 case IW_ENCODE_ALG_WEP:
4036 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4037 break;
4038
4039 case IW_ENCODE_ALG_TKIP:
4040 {
4041 v_U8_t *pKey = &setKey.Key[0];
4042
4043 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4044
4045 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4046
4047 /*Supplicant sends the 32bytes key in this order
4048
4049 |--------------|----------|----------|
4050 | Tk1 |TX-MIC | RX Mic |
4051 |--------------|----------|----------|
4052 <---16bytes---><--8bytes--><--8bytes-->
4053
4054 */
4055 /*Sme expects the 32 bytes key to be in the below order
4056
4057 |--------------|----------|----------|
4058 | Tk1 |RX-MIC | TX Mic |
4059 |--------------|----------|----------|
4060 <---16bytes---><--8bytes--><--8bytes-->
4061 */
4062 /* Copy the Temporal Key 1 (TK1) */
4063 vos_mem_copy(pKey,ext->key,16);
4064
4065 /*Copy the rx mic first*/
4066 vos_mem_copy(&pKey[16],&ext->key[24],8);
4067
4068 /*Copy the tx mic */
4069 vos_mem_copy(&pKey[24],&ext->key[16],8);
4070
4071 }
4072 break;
4073
4074 case IW_ENCODE_ALG_CCMP:
4075 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4076 break;
4077
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004078#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004079#define IW_ENCODE_ALG_KRK 6
4080 case IW_ENCODE_ALG_KRK:
4081 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4082 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004083#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004084
4085 default:
4086 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4087 break;
4088 }
4089
4090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004091 ("%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 -07004092
4093#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304094 /* The supplicant may attempt to set the PTK once pre-authentication
4095 is done. Save the key in the UMAC and include it in the ADD
4096 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304098 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304100 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4101 "%s: Update PreAuth Key success", __func__);
4102 return 0;
4103 }
4104 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4105 {
4106 hddLog(VOS_TRACE_LEVEL_ERROR,
4107 "%s: Update PreAuth Key failed", __func__);
4108 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 }
4110#endif /* WLAN_FEATURE_VOWIFI_11R */
4111
4112 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4113
4114 vos_status = wlan_hdd_check_ula_done(pAdapter);
4115 if ( vos_status != VOS_STATUS_SUCCESS )
4116 {
4117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4118 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4119 __LINE__, vos_status );
4120
4121 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4122 }
4123
4124 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4125
4126 if ( halStatus != eHAL_STATUS_SUCCESS )
4127 {
4128 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4129 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4130 __LINE__, halStatus );
4131
4132 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4133 }
4134
4135 return halStatus;
4136}
4137
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304138static int iw_set_encodeext(struct net_device *dev,
4139 struct iw_request_info *info,
4140 union iwreq_data *wrqu, char *extra)
4141{
4142 int ret;
4143
4144 vos_ssr_protect(__func__);
4145 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4146 vos_ssr_unprotect(__func__);
4147
4148 return ret;
4149}
4150
4151static int __iw_set_retry(struct net_device *dev,
4152 struct iw_request_info *info,
4153 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004154{
4155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4156 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4157
4158 ENTER();
4159
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004160 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4161 {
4162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4163 "%s:LOGP in Progress. Ignore!!!", __func__);
4164 return -EBUSY;
4165 }
4166
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4168 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4169
Arif Hussain6d2a3322013-11-17 19:50:10 -08004170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004171
4172 return -EINVAL;
4173 }
4174
4175 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
4176
4177 if((wrqu->retry.flags & IW_RETRY_LONG))
4178 {
4179 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != 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_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 return -EIO;
4184 }
4185 }
4186 else if((wrqu->retry.flags & IW_RETRY_SHORT))
4187 {
4188 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4189 {
c_hpothub8245442013-11-20 23:41:09 +05304190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4191 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 return -EIO;
4193 }
4194 }
4195 }
4196 else
4197 {
4198 return -EOPNOTSUPP;
4199 }
4200
Arif Hussain6d2a3322013-11-17 19:50:10 -08004201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004202
4203 EXIT();
4204
4205 return 0;
4206
4207}
4208
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304209static int iw_set_retry(struct net_device *dev,
4210 struct iw_request_info *info,
4211 union iwreq_data *wrqu, char *extra)
4212{
4213 int ret;
4214
4215 vos_ssr_protect(__func__);
4216 ret = __iw_set_retry(dev, info, wrqu, extra);
4217 vos_ssr_unprotect(__func__);
4218
4219 return ret;
4220}
4221
4222static int __iw_get_retry(struct net_device *dev,
4223 struct iw_request_info *info,
4224 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004225{
4226 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4227 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4228 v_U32_t retry = 0;
4229
4230 ENTER();
4231
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004232 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4233 {
4234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4235 "%s:LOGP in Progress. Ignore!!!", __func__);
4236 return -EBUSY;
4237 }
4238
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 if((wrqu->retry.flags & IW_RETRY_LONG))
4240 {
4241 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4242
4243 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
4244 {
c_hpothub8245442013-11-20 23:41:09 +05304245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4246 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 return -EIO;
4248 }
4249
4250 wrqu->retry.value = retry;
4251 }
4252 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
4253 {
4254 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4255
4256 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
4257 {
c_hpothub8245442013-11-20 23:41:09 +05304258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4259 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 return -EIO;
4261 }
4262
4263 wrqu->retry.value = retry;
4264 }
4265 else {
4266 return -EOPNOTSUPP;
4267 }
4268
Arif Hussain6d2a3322013-11-17 19:50:10 -08004269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004270
4271 EXIT();
4272
4273 return 0;
4274}
4275
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304276static int iw_get_retry(struct net_device *dev,
4277 struct iw_request_info *info,
4278 union iwreq_data *wrqu, char *extra)
4279{
4280 int ret;
4281
4282 vos_ssr_protect(__func__);
4283 ret = __iw_get_retry(dev, info, wrqu, extra);
4284 vos_ssr_unprotect(__func__);
4285
4286 return ret;
4287}
4288
4289static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 struct iw_request_info *info,
4291 union iwreq_data *wrqu,
4292 char *extra)
4293{
4294 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4295 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4296 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4297 eHalStatus status = eHAL_STATUS_SUCCESS;
4298
4299 ENTER();
4300
4301 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4302 {
4303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4304 "%s:LOGP in Progress. Ignore!!!",__func__);
4305 return 0;
4306 }
4307
4308 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4309 switch (mlme->cmd) {
4310 case IW_MLME_DISASSOC:
4311 case IW_MLME_DEAUTH:
4312
4313 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
4314 {
4315 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4316
4317 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4318 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4319
4320 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4321 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
4322
Jeff Johnson43971f52012-07-17 12:26:56 -07004323 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304324 {
4325 long ret;
4326 ret = wait_for_completion_interruptible_timeout(
4327 &pAdapter->disconnect_comp_var,
4328 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4329 if (ret <= 0)
4330 hddLog(VOS_TRACE_LEVEL_ERROR,
4331 FL("failed wait on disconnect_comp_var %ld"), ret);
4332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08004334 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004335 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07004336
4337 /* Resetting authKeyMgmt */
4338 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
4339
4340 netif_tx_disable(dev);
4341 netif_carrier_off(dev);
4342
4343 }
4344 else
4345 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004346 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 -07004347 }
4348 break;
4349 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004350 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 return -EINVAL;
4352 }//end of switch
4353
4354 EXIT();
4355
4356 return status;
4357
4358}
4359
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304360static int iw_set_mlme(struct net_device *dev,
4361 struct iw_request_info *info,
4362 union iwreq_data *wrqu,
4363 char *extra)
4364{
4365 int ret;
4366
4367 vos_ssr_protect(__func__);
4368 ret = __iw_set_mlme(dev, info, wrqu, extra);
4369 vos_ssr_unprotect(__func__);
4370
4371 return ret;
4372}
4373
Jeff Johnson295189b2012-06-20 16:38:30 -07004374/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304375static int __iw_setint_getnone(struct net_device *dev,
4376 struct iw_request_info *info,
4377 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004378{
4379 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4380 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4381 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4382 int *value = (int *)extra;
4383 int sub_cmd = value[0];
4384 int set_value = value[1];
4385 int ret = 0; /* success */
4386 int enable_pbm, enable_mp;
4387#ifdef CONFIG_HAS_EARLYSUSPEND
4388 v_U8_t nEnableSuspendOld;
4389#endif
4390 INIT_COMPLETION(pWextState->completion_var);
4391
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004392 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4393 {
4394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4395 "%s:LOGP in Progress. Ignore!!!", __func__);
4396 return -EBUSY;
4397 }
4398
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 switch(sub_cmd)
4400 {
4401 case WE_SET_11D_STATE:
4402 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004403 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004404 memset(&smeConfig, 0x00, sizeof(smeConfig));
4405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4407
4408 sme_GetConfigParam(hHal,&smeConfig);
4409 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4410
Arif Hussain6d2a3322013-11-17 19:50:10 -08004411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004412
4413 sme_UpdateConfig(hHal,&smeConfig);
4414 }
4415 else {
4416 return -EINVAL;
4417 }
4418 break;
4419 }
4420
4421 case WE_WOWL:
4422 {
4423 switch (set_value)
4424 {
4425 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05304426 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 break;
4428 case 0x01:
4429 case 0x02:
4430 case 0x03:
4431 enable_mp = (set_value & 0x01) ? 1 : 0;
4432 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004433 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4435 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4436 break;
4437 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004438 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 ret = -EINVAL;
4440 break;
4441 }
4442
4443 break;
4444 }
4445 case WE_SET_POWER:
4446 {
4447 switch (set_value)
4448 {
4449 case 0: //Full Power
4450 {
4451 struct statsContext context;
4452 eHalStatus status;
4453
4454 init_completion(&context.completion);
4455
4456 context.pAdapter = pAdapter;
4457 context.magic = POWER_CONTEXT_MAGIC;
4458
4459 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4460 iw_power_callback_fn, &context,
4461 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004462 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 {
4464 int lrc = wait_for_completion_interruptible_timeout(
4465 &context.completion,
4466 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004467
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 if (lrc <= 0)
4469 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004470 hddLog(VOS_TRACE_LEVEL_ERROR,
4471 "%s: SME %s while requesting fullpower",
4472 __func__, (0 == lrc) ?
4473 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 }
4475 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004476 /* either we have a response or we timed out. if we timed
4477 out there is a race condition such that the callback
4478 function could be executing at the same time we are. of
4479 primary concern is if the callback function had already
4480 verified the "magic" but had not yet set the completion
4481 variable when a timeout occurred. we serialize these
4482 activities by invalidating the magic while holding a
4483 shared spinlock which will cause us to block if the
4484 callback is currently executing */
4485 spin_lock(&hdd_context_lock);
4486 context.magic = 0;
4487 spin_unlock(&hdd_context_lock);
4488
Arif Hussain6d2a3322013-11-17 19:50:10 -08004489 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 break;
4491 }
4492 case 1: //Enable BMPS
4493 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4494 break;
4495 case 2: //Disable BMPS
4496 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4497 break;
4498 case 3: //Request Bmps
4499 {
4500 struct statsContext context;
4501 eHalStatus status;
4502
4503 init_completion(&context.completion);
4504
4505 context.pAdapter = pAdapter;
4506 context.magic = POWER_CONTEXT_MAGIC;
4507
4508 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4509 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004510 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 {
4512 int lrc = wait_for_completion_interruptible_timeout(
4513 &context.completion,
4514 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 if (lrc <= 0)
4516 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004517 hddLog(VOS_TRACE_LEVEL_ERROR,
4518 "%s: SME %s while requesting BMPS",
4519 __func__, (0 == lrc) ? "timeout" :
4520 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 }
4522 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004523 /* either we have a response or we timed out. if we
4524 timed out there is a race condition such that the
4525 callback function could be executing at the same
4526 time we are. of primary concern is if the callback
4527 function had already verified the "magic" but had
4528 not yet set the completion variable when a timeout
4529 occurred. we serialize these activities by
4530 invalidating the magic while holding a shared
4531 spinlock which will cause us to block if the
4532 callback is currently executing */
4533 spin_lock(&hdd_context_lock);
4534 context.magic = 0;
4535 spin_unlock(&hdd_context_lock);
4536
Arif Hussain6d2a3322013-11-17 19:50:10 -08004537 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 break;
4539 }
4540 case 4: //Enable IMPS
4541 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4542 break;
4543 case 5: //Disable IMPS
4544 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4545 break;
4546 case 6: //Enable Standby
4547 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4548 break;
4549 case 7: //Disable Standby
4550 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4551 break;
4552 case 8: //Request Standby
4553#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004554#endif
4555 break;
4556 case 9: //Start Auto Bmps Timer
4557 sme_StartAutoBmpsTimer(hHal);
4558 break;
4559 case 10://Stop Auto BMPS Timer
4560 sme_StopAutoBmpsTimer(hHal);
4561 break;
4562#ifdef CONFIG_HAS_EARLYSUSPEND
4563 case 11://suspend to standby
4564#ifdef CONFIG_HAS_EARLYSUSPEND
4565 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4566 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4568#endif
4569 break;
4570 case 12://suspend to deep sleep
4571#ifdef CONFIG_HAS_EARLYSUSPEND
4572 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4573 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4575#endif
4576 break;
4577 case 13://resume from suspend
4578#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004579#endif
4580 break;
4581#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004583 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 ret = -EINVAL;
4585 break;
4586 }
4587 break;
4588 }
4589
4590 case WE_SET_MAX_ASSOC:
4591 {
4592 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4593 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4594 {
4595 ret = -EINVAL;
4596 }
4597 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4598 set_value, NULL, eANI_BOOLEAN_FALSE)
4599 != eHAL_STATUS_SUCCESS )
4600 {
c_hpothub8245442013-11-20 23:41:09 +05304601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4602 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 ret = -EIO;
4604 }
4605 break;
4606 }
4607
4608 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4609 {
4610 if( 0 == set_value )
4611 {
4612 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4613 }
4614 else if ( 1 == set_value )
4615 {
4616 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4617 }
4618 else
4619 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004620 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 ret = -EINVAL;
4622 }
4623 break;
4624 }
4625
4626 case WE_SET_DATA_INACTIVITY_TO:
4627 {
4628 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4629 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4630 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4631 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4632 set_value,
4633 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4634 {
4635 hddLog(LOGE,"Failure: Could not pass on "
4636 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004637 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 ret = -EINVAL;
4639 }
4640 break;
4641 }
4642 case WE_SET_MAX_TX_POWER:
4643 {
4644 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4645 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4646
4647 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4648 __func__, set_value);
4649 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4650 eHAL_STATUS_SUCCESS )
4651 {
4652 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4653 __func__);
4654 return -EIO;
4655 }
4656
4657 break;
4658 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004659 case WE_SET_MAX_TX_POWER_2_4:
4660 {
4661 hddLog(VOS_TRACE_LEVEL_INFO,
4662 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4663 __func__, set_value);
4664 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4665 eHAL_STATUS_SUCCESS)
4666 {
4667 hddLog(VOS_TRACE_LEVEL_ERROR,
4668 "%s: Setting maximum tx power failed for 2.4 GHz band",
4669 __func__);
4670 return -EIO;
4671 }
4672
4673 break;
4674 }
4675 case WE_SET_MAX_TX_POWER_5_0:
4676 {
4677 hddLog(VOS_TRACE_LEVEL_INFO,
4678 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4679 __func__, set_value);
4680 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4681 eHAL_STATUS_SUCCESS)
4682 {
4683 hddLog(VOS_TRACE_LEVEL_ERROR,
4684 "%s: Setting maximum tx power failed for 5.0 GHz band",
4685 __func__);
4686 return -EIO;
4687 }
4688
4689 break;
4690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 case WE_SET_HIGHER_DTIM_TRANSITION:
4692 {
4693 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4694 (set_value == eANI_BOOLEAN_TRUE)))
4695 {
4696 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4697 ret = -EINVAL;
4698 }
4699 else
4700 {
4701 if(pAdapter->higherDtimTransition != set_value)
4702 {
4703 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004704 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 }
4706 }
4707
4708 break;
4709 }
4710
4711 case WE_SET_TM_LEVEL:
4712 {
4713 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004714 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4716
4717 break;
4718 }
4719
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304720 case WE_ENABLE_STRICT_FCC_REG:
4721 {
4722 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4723 struct wiphy *wiphy = NULL;
4724 long lrc;
4725 int status;
4726
4727 wiphy = hddCtxt->wiphy;
4728 if(wiphy == NULL)
4729 {
4730 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4731 break;
4732 }
4733 init_completion(&hddCtxt->wiphy_channel_update_event);
4734
4735 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4736
4737 status = regulatory_hint(wiphy, "00");
4738 if(status < 0)
4739 {
4740 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4741 break;
4742 }
4743
4744 /* Wait for completion */
4745 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4746 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4747 if (lrc <= 0)
4748 {
4749 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4750 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4751 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4752 }
4753 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4754
4755 break;
4756 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004757 case WE_SET_DEBUG_LOG:
4758 {
4759 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4760 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4761 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4762 break;
4763 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05304764#ifdef FEATURE_WLAN_TDLS
4765 case WE_SET_TDLS_OFF_CHAN:
4766 {
4767 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
4769 __func__, set_value);
4770 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
4771 break;
4772 }
4773 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
4774 {
4775 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
4777 __func__, set_value);
4778 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
4779 break;
4780 }
4781 case WE_SET_TDLS_OFF_CHAN_MODE:
4782 {
4783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
4784 __func__, set_value);
4785 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
4786 break;
4787 }
4788#endif
Peng Xu2446a892014-09-05 17:21:18 +05304789 case WE_SET_SCAN_BAND_PREFERENCE:
4790 {
4791 tSmeConfigParams smeConfig;
4792 memset(&smeConfig, 0x00, sizeof(smeConfig));
4793 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
4794 ret = -EINVAL;
4795 break;
4796 }
4797 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
4798
4799 if (eCSR_BAND_ALL == set_value ||
4800 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
4801 sme_GetConfigParam(hHal, &smeConfig);
4802 smeConfig.csrConfig.scanBandPreference = set_value;
4803
4804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4805 "set band scan preference = %d\n",
4806 smeConfig.csrConfig.scanBandPreference);
4807
4808 sme_UpdateConfig(hHal, &smeConfig);
4809 }
4810 else {
4811 ret = -EINVAL;
4812 }
4813 break;
4814 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304815
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 default:
4817 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004818 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 sub_cmd, set_value);
4820 break;
4821 }
4822 }
4823
4824 return ret;
4825}
4826
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304827static int iw_setint_getnone(struct net_device *dev,
4828 struct iw_request_info *info,
4829 union iwreq_data *wrqu, char *extra)
4830{
4831 int ret;
4832
4833 vos_ssr_protect(__func__);
4834 ret = __iw_setint_getnone(dev, info, wrqu, extra);
4835 vos_ssr_unprotect(__func__);
4836
4837 return 0;
4838}
Jeff Johnson295189b2012-06-20 16:38:30 -07004839/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304840static int __iw_setchar_getnone(struct net_device *dev,
4841 struct iw_request_info *info,
4842 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004843{
4844 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05304845 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004847 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4849 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4850#ifdef WLAN_FEATURE_VOWIFI
4851 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4852#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05304853 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07004854
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004855 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4856 {
4857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4858 "%s:LOGP in Progress. Ignore!!!", __func__);
4859 return -EBUSY;
4860 }
4861
Girish Gowli552fc072014-06-14 18:26:16 +05304862 /* helper function to get iwreq_data with compat handling. */
4863 if (hdd_priv_get_data(&s_priv_data, wrqu))
4864 {
4865 return -EINVAL;
4866 }
4867
4868 /* make sure all params are correctly passed to function */
4869 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
4870 {
4871 return -EINVAL;
4872 }
4873
4874 sub_cmd = s_priv_data.flags;
4875
Arif Hussain0273cba2014-01-07 20:58:29 -08004876 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05304877 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
4878 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004879 if (NULL == pBuffer)
4880 {
4881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4882 "mem_alloc_copy_from_user_helper fail");
4883 return -ENOMEM;
4884 }
4885
4886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05304887 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4889 "%s: Received data %s", __func__, pBuffer);
4890
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 switch(sub_cmd)
4892 {
4893 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004895 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 break;
4897 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004899 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 break;
4901#if defined WLAN_FEATURE_VOWIFI
4902 case WE_NEIGHBOR_REPORT_REQUEST:
4903 {
4904 tRrmNeighborReq neighborReq;
4905 tRrmNeighborRspCallbackInfo callbackInfo;
4906
4907 if (pConfig->fRrmEnable)
4908 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05304910 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 if( !neighborReq.no_ssid )
4912 {
Girish Gowli552fc072014-06-14 18:26:16 +05304913 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004914 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 }
4916
4917 callbackInfo.neighborRspCallback = NULL;
4918 callbackInfo.neighborRspCallbackContext = NULL;
4919 callbackInfo.timeout = 5000; //5 seconds
4920 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4921 }
4922 else
4923 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004924 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 ret = -EINVAL;
4926 }
4927 }
4928 break;
4929#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 case WE_SET_AP_WPS_IE:
4931 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05304932 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004935 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 if (VOS_STATUS_SUCCESS != vstatus)
4937 {
4938 ret = -EINVAL;
4939 }
4940 break;
4941 default:
4942 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004943 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 ret = -EINVAL;
4945 break;
4946 }
4947 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004948 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 return ret;
4950}
4951
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304952static int iw_setchar_getnone(struct net_device *dev,
4953 struct iw_request_info *info,
4954 union iwreq_data *wrqu, char *extra)
4955{
4956 int ret;
4957
4958 vos_ssr_protect(__func__);
4959 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
4960 vos_ssr_unprotect(__func__);
4961
4962 return ret;
4963}
4964
Jeff Johnson295189b2012-06-20 16:38:30 -07004965/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304966static int __iw_setnone_getint(struct net_device *dev,
4967 struct iw_request_info *info,
4968 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004969{
4970 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4971 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowli385be612014-09-18 11:17:20 +05304972 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 int *value = (int *)extra;
4974 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05304975 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004976
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004977 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4978 {
4979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4980 "%s:LOGP in Progress. Ignore!!!", __func__);
4981 return -EBUSY;
4982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004983
4984 switch (value[0])
4985 {
4986 case WE_GET_11D_STATE:
4987 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004988 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304990
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4992
Arif Hussain6d2a3322013-11-17 19:50:10 -08004993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004994
4995 break;
4996 }
4997
4998 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 break;
5001
5002 case WE_PMC_STATE:
5003 {
5004 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 break;
5007 }
5008 case WE_GET_WLAN_DBG:
5009 {
5010 vos_trace_display();
5011 *value = 0;
5012 break;
5013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 case WE_GET_MAX_ASSOC:
5015 {
5016 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
5017 {
c_hpothub8245442013-11-20 23:41:09 +05305018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5019 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 ret = -EIO;
5021 }
Girish Gowli385be612014-09-18 11:17:20 +05305022#ifdef WLAN_SOFTAP_VSTA_FEATURE
5023 if (pHddCtx->cfg_ini->fEnableVSTASupport)
5024 {
5025 if (*value > VSTA_NUM_ASSOC_STA)
5026 {
5027 *value = VSTA_NUM_ASSOC_STA;
5028 }
5029 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
5030 (*value > (VSTA_NUM_ASSOC_STA -
5031 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
5032 {
5033 *value = (VSTA_NUM_ASSOC_STA -
5034 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
5035 }
5036 }
5037 else
5038#endif
5039 {
5040 if (*value > NUM_ASSOC_STA)
5041 {
5042 *value = NUM_ASSOC_STA;
5043 }
5044 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
5045 (*value > (NUM_ASSOC_STA -
5046 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
5047 {
5048 *value = (NUM_ASSOC_STA -
5049 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
5050 }
5051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 break;
5053 }
5054
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 case WE_GET_WDI_DBG:
5056 {
5057 wpalTraceDisplay();
5058 *value = 0;
5059 break;
5060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005061
5062 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
5063 {
5064 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
5065 break;
5066 }
5067 case WE_GET_CONCURRENCY_MODE:
5068 {
5069 *value = hdd_get_concurrency_mode ( );
5070
Arif Hussain6d2a3322013-11-17 19:50:10 -08005071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 break;
5073 }
5074
Peng Xu2446a892014-09-05 17:21:18 +05305075 case WE_GET_SCAN_BAND_PREFERENCE:
5076 {
5077 sme_GetConfigParam(hHal, &smeConfig);
5078 *value = smeConfig.csrConfig.scanBandPreference;
5079
5080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5081 "scanBandPreference = %d\n", *value);
5082 break;
5083 }
5084
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 default:
5086 {
5087 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
5088 break;
5089 }
5090 }
5091
5092 return ret;
5093}
5094
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305095static int iw_setnone_getint(struct net_device *dev,
5096 struct iw_request_info *info,
5097 union iwreq_data *wrqu, char *extra)
5098{
5099 int ret;
5100
5101 vos_ssr_protect(__func__);
5102 ret = __iw_setnone_getint(dev, info, wrqu, extra);
5103 vos_ssr_unprotect(__func__);
5104
5105 return ret;
5106
5107}
Jeff Johnson295189b2012-06-20 16:38:30 -07005108/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305109int __iw_set_three_ints_getnone(struct net_device *dev,
5110 struct iw_request_info *info,
5111 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005112{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005113 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 int *value = (int *)extra;
5115 int sub_cmd = value[0];
5116 int ret = 0;
5117
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005118 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5119 {
5120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5121 "%s:LOGP in Progress. Ignore!!!", __func__);
5122 return -EBUSY;
5123 }
5124
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 switch(sub_cmd)
5126 {
5127 case WE_SET_WLAN_DBG:
5128 {
5129 vos_trace_setValue( value[1], value[2], value[3]);
5130 break;
5131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 case WE_SET_WDI_DBG:
5133 {
5134 wpalTraceSetLevel( value[1], value[2], value[3]);
5135 break;
5136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 case WE_SET_SAP_CHANNELS:
5138 {
5139 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
5140 break;
5141 }
5142
5143 default:
5144 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005145 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 break;
5147 }
5148 }
5149 return ret;
5150}
5151
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305152int iw_set_three_ints_getnone(struct net_device *dev,
5153 struct iw_request_info *info,
5154 union iwreq_data *wrqu, char *extra)
5155{
5156 int ret;
5157
5158 vos_ssr_protect(__func__);
5159 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
5160 vos_ssr_unprotect(__func__);
5161
5162 return ret;
5163}
5164
5165static int __iw_get_char_setnone(struct net_device *dev,
5166 struct iw_request_info *info,
5167 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005168{
5169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5170 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07005171#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005172 hdd_wext_state_t *pWextState;
5173#endif
5174
5175 if (pAdapter == NULL)
5176 {
5177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5178 "%s: pAdapter is NULL!", __func__);
5179 return -EINVAL;
5180 }
5181#ifdef WLAN_FEATURE_11W
5182 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07005183#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005184
Yue Ma3ede6052013-08-29 00:33:26 -07005185 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
5186 {
5187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5188 "%s: HDD Context is NULL!", __func__);
5189
5190 return -EINVAL;
5191 }
5192
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005193 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5194 {
5195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5196 "%s:LOGP in Progress. Ignore!!!", __func__);
5197 return -EBUSY;
5198 }
5199
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 switch(sub_cmd)
5201 {
5202 case WE_WLAN_VERSION:
5203 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08005204 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 break;
5206 }
5207
5208 case WE_GET_STATS:
5209 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305210 tHalHandle hHal = NULL;
5211 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5213 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
5214 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
5215
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305216
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 snprintf(extra, WE_MAX_STR_LEN,
5218 "\nTransmit"
5219 "\ncalled %u, dropped %u, backpressured %u, queued %u"
5220 "\n dropped BK %u, BE %u, VI %u, VO %u"
5221 "\n classified BK %u, BE %u, VI %u, VO %u"
5222 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
5223 "\n queued BK %u, BE %u, VI %u, VO %u"
5224 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07005225 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 "\n fetched BK %u, BE %u, VI %u, VO %u"
5227 "\n dequeued BK %u, BE %u, VI %u, VO %u"
5228 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07005229 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 "\n flushed BK %u, BE %u, VI %u, VO %u"
5231 "\n\nReceive"
5232 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
5233 "\n\nResetsStats"
5234 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
5235 "\n",
5236 pStats->txXmitCalled,
5237 pStats->txXmitDropped,
5238 pStats->txXmitBackPressured,
5239 pStats->txXmitQueued,
5240
5241 pStats->txXmitDroppedAC[WLANTL_AC_BK],
5242 pStats->txXmitDroppedAC[WLANTL_AC_BE],
5243 pStats->txXmitDroppedAC[WLANTL_AC_VI],
5244 pStats->txXmitDroppedAC[WLANTL_AC_VO],
5245
5246 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
5247 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
5248 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
5249 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
5250
5251 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
5252 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
5253 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
5254 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
5255
5256 pStats->txXmitQueuedAC[WLANTL_AC_BK],
5257 pStats->txXmitQueuedAC[WLANTL_AC_BE],
5258 pStats->txXmitQueuedAC[WLANTL_AC_VI],
5259 pStats->txXmitQueuedAC[WLANTL_AC_VO],
5260
5261 pStats->txFetched,
5262 pStats->txFetchEmpty,
5263 pStats->txFetchLowResources,
5264 pStats->txFetchDequeueError,
5265
5266 pStats->txFetchDequeued,
5267 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07005268 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 pStats->txCompleted,
5270 pStats->txFlushed,
5271
5272 pStats->txFetchedAC[WLANTL_AC_BK],
5273 pStats->txFetchedAC[WLANTL_AC_BE],
5274 pStats->txFetchedAC[WLANTL_AC_VI],
5275 pStats->txFetchedAC[WLANTL_AC_VO],
5276
5277 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
5278 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
5279 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
5280 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
5281
5282 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
5283 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
5284 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
5285 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
5286
Ravi Joshi41914632013-10-21 23:02:21 -07005287 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
5288 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
5289 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
5290 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
5291
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 pStats->txFlushedAC[WLANTL_AC_BK],
5293 pStats->txFlushedAC[WLANTL_AC_BE],
5294 pStats->txFlushedAC[WLANTL_AC_VI],
5295 pStats->txFlushedAC[WLANTL_AC_VO],
5296
5297 pStats->rxChains,
5298 pStats->rxPackets,
5299 pStats->rxDropped,
5300 pStats->rxDelivered,
5301 pStats->rxRefused,
5302
5303 pResetStats->totalLogpResets,
5304 pResetStats->totalCMD53Failures,
5305 pResetStats->totalMutexReadFailures,
5306 pResetStats->totalMIFErrorFailures,
5307 pResetStats->totalFWHearbeatFailures,
5308 pResetStats->totalUnknownExceptions
5309 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305310 wrqu->data.length = strlen(extra);
5311
5312 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
5313
5314 if (hHal)
5315 pMac = PMAC_STRUCT( hHal );
5316
5317 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
5318 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
5319 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05305320 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
5321 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
5322 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
5323 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305324 "\n",
5325 pMac->pmm.BmpscntSleep,
5326 pMac->pmm.BmpscntAwake,
5327 pMac->pmm.BmpsSleeReqFailCnt,
5328 pMac->pmm.BmpsWakeupReqFailCnt,
5329 pMac->pmm.ImpsCntSleep,
5330 pMac->pmm.ImpsCntAwake,
5331 pMac->pmm.ImpsSleepErrCnt,
5332 pMac->pmm.ImpsWakeupErrCnt,
5333 pMac->pmm.ImpsLastErr
5334 );
5335 }
5336
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 wrqu->data.length = strlen(extra)+1;
5338 break;
5339 }
5340
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305341/* The case prints the current state of the HDD, SME, CSR, PE, TL
5342 *it can be extended for WDI Global State as well.
5343 *And currently it only checks P2P_CLIENT adapter.
5344 *P2P_DEVICE and P2P_GO have not been added as of now.
5345*/
5346 case WE_GET_STATES:
5347 {
5348 int buf = 0, len = 0;
5349 int adapter_num = 0;
5350 int count = 0, check = 1;
5351
5352 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005353 tHalHandle hHal = NULL;
5354 tpAniSirGlobal pMac = NULL;
5355 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305356
5357 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5358 hdd_adapter_t *useAdapter = NULL;
5359
5360 /* Print wlan0 or p2p0 states based on the adapter_num
5361 *by using the correct adapter
5362 */
5363 while ( adapter_num < 2 )
5364 {
5365 if ( WLAN_ADAPTER == adapter_num )
5366 {
5367 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005368 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305369 "\n\n wlan0 States:-");
5370 len += buf;
5371 }
5372 else if ( P2P_ADAPTER == adapter_num )
5373 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005374 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305375 "\n\n p2p0 States:-");
5376 len += buf;
5377
5378 if( !pHddCtx )
5379 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005380 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305381 "\n pHddCtx is NULL");
5382 len += buf;
5383 break;
5384 }
5385
5386 /*Printing p2p0 states only in the case when the device is
5387 configured as a p2p_client*/
5388 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
5389 if ( !useAdapter )
5390 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005391 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305392 "\n Device not configured as P2P_CLIENT.");
5393 len += buf;
5394 break;
5395 }
5396 }
5397
5398 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005399 if (!hHal) {
5400 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5401 "\n pMac is NULL");
5402 len += buf;
5403 break;
5404 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305405 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005406 if (!pMac) {
5407 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5408 "\n pMac is NULL");
5409 len += buf;
5410 break;
5411 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305412 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
5413 if( !pHddStaCtx )
5414 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005415 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305416 "\n pHddStaCtx is NULL");
5417 len += buf;
5418 break;
5419 }
5420
5421 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
5422
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005423 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305424 "\n HDD Conn State - %s "
5425 "\n \n SME State:"
5426 "\n Neighbour Roam State - %s"
5427 "\n CSR State - %s"
5428 "\n CSR Substate - %s"
5429 "\n \n TL STA %d State: %s",
5430 macTraceGetHDDWlanConnState(
5431 pHddStaCtx->conn_info.connState),
5432 macTraceGetNeighbourRoamState(
5433 pMac->roam.neighborRoamInfo.neighborRoamState),
5434 macTraceGetcsrRoamState(
5435 pMac->roam.curState[useAdapter->sessionId]),
5436 macTraceGetcsrRoamSubState(
5437 pMac->roam.curSubState[useAdapter->sessionId]),
5438 pHddStaCtx->conn_info.staId[0],
5439 macTraceGetTLState(tlState)
5440 );
5441 len += buf;
5442 adapter_num++;
5443 }
5444
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005445 if (pMac) {
5446 /* Printing Lim State starting with global lim states */
5447 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5448 "\n \n LIM STATES:-"
5449 "\n Global Sme State - %s "\
5450 "\n Global mlm State - %s "\
5451 "\n",
5452 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
5453 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
5454 );
5455 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305456
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005457 /*printing the PE Sme and Mlm states for valid lim sessions*/
5458 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305459 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005460 if ( pMac->lim.gpSession[count].valid )
5461 {
5462 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5463 "\n Lim Valid Session %d:-"
5464 "\n PE Sme State - %s "
5465 "\n PE Mlm State - %s "
5466 "\n",
5467 check,
5468 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
5469 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
5470 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305471
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005472 len += buf;
5473 check++;
5474 }
5475 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305476 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305477 }
5478
5479 wrqu->data.length = strlen(extra)+1;
5480 break;
5481 }
5482
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 case WE_GET_CFG:
5484 {
5485 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
5486 wrqu->data.length = strlen(extra)+1;
5487 break;
5488 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005489#ifdef WLAN_FEATURE_11AC
5490 case WE_GET_RSSI:
5491 {
5492 v_S7_t s7Rssi = 0;
5493 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
5494 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
5495 wrqu->data.length = strlen(extra)+1;
5496 break;
5497 }
5498#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305499
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005500#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005501 case WE_GET_ROAM_RSSI:
5502 {
5503 v_S7_t s7Rssi = 0;
5504 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
5505 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
5506 wrqu->data.length = strlen(extra)+1;
5507 break;
5508 }
5509#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 case WE_GET_WMM_STATUS:
5511 {
5512 snprintf(extra, WE_MAX_STR_LEN,
5513 "\nDir: 0=up, 1=down, 3=both\n"
5514 "|------------------------|\n"
5515 "|AC | ACM |Admitted| Dir |\n"
5516 "|------------------------|\n"
5517 "|VO | %d | %3s | %d |\n"
5518 "|VI | %d | %3s | %d |\n"
5519 "|BE | %d | %3s | %d |\n"
5520 "|BK | %d | %3s | %d |\n"
5521 "|------------------------|\n",
5522 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
5523 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
5524 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
5525 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
5526 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
5527 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
5528 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
5529 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
5530 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5531 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5532 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5533 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5534
Jeff Johnsone7245742012-09-05 17:12:55 -07005535
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 wrqu->data.length = strlen(extra)+1;
5537 break;
5538 }
5539 case WE_GET_CHANNEL_LIST:
5540 {
5541 VOS_STATUS status;
5542 v_U8_t i, len;
5543 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305544 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5545 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5546 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 tChannelListInfo channel_list;
5548
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005549 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005551 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005553 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 return -EINVAL;
5555 }
5556 buf = extra;
5557
5558 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005559 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5560 * needed = 5 * number of channels. Check ifsufficient
5561 * buffer is available and then proceed to fill the buffer.
5562 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5564 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005565 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005566 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005567 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 return -EINVAL;
5569 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005570 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5571 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305572 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5573 {
5574 //Printing Country code in getChannelList
5575 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5576 {
5577 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5578 "%c ", pBuf[i]);
5579 }
5580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 for(i = 0 ; i < channel_list.num_channels; i++)
5582 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005583 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 }
5586 wrqu->data.length = strlen(extra)+1;
5587
5588 break;
5589 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005590#ifdef FEATURE_WLAN_TDLS
5591 case WE_GET_TDLS_PEERS:
5592 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005593 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005594 break;
5595 }
5596#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005597#ifdef WLAN_FEATURE_11W
5598 case WE_GET_11W_INFO:
5599 {
5600 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5601
5602 snprintf(extra, WE_MAX_STR_LEN,
5603 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5604 "\n Number of Unprotected Disassocs %d"
5605 "\n Number of Unprotected Deauths %d",
5606 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5607 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5608 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5609 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5610 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5611
5612 wrqu->data.length = strlen(extra)+1;
5613 break;
5614 }
5615#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05305616 case WE_GET_SNR:
5617 {
5618 v_S7_t s7snr = 0;
5619 int status = 0;
5620 hdd_context_t *pHddCtx;
5621 hdd_station_ctx_t *pHddStaCtx;
5622
5623 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5624 status = wlan_hdd_validate_context(pHddCtx);
5625 if (0 != status)
5626 {
5627 hddLog(LOGE, "%s: getSNR: HDD context is not valid", __func__);
5628 return status;
5629 }
5630
5631 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5632
5633 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
5634 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5635 {
5636 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
5637 " ConnectionState-%d", __func__,
5638 pHddCtx->cfg_ini->fEnableSNRMonitoring,
5639 pHddStaCtx->conn_info.connState);
5640 return -ENONET;
5641 }
5642
5643 /*update the stats in TL*/
5644 wlan_hdd_get_station_stats(pAdapter);
5645 wlan_hdd_get_snr(pAdapter, &s7snr);
5646 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
5647 wrqu->data.length = strlen(extra) + 1;
5648 break;
5649 }
5650
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305651 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005653 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 break;
5655 }
5656 }
5657
5658 return 0;
5659}
5660
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305661static int iw_get_char_setnone(struct net_device *dev,
5662 struct iw_request_info *info,
5663 union iwreq_data *wrqu, char *extra)
5664{
5665 int ret;
5666
5667 vos_ssr_protect(__func__);
5668 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
5669 vos_ssr_unprotect(__func__);
5670
5671 return ret;
5672}
5673
Jeff Johnson295189b2012-06-20 16:38:30 -07005674/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305675static int __iw_setnone_getnone(struct net_device *dev,
5676 struct iw_request_info *info,
5677 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005678{
5679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305680 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005681 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305682 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005683
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005684 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5685 {
5686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5687 "%s:LOGP in Progress. Ignore!!!", __func__);
5688 return -EBUSY;
5689 }
5690
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305691 /* helper function to get iwreq_data with compat handling. */
5692 if (hdd_priv_get_data(&s_priv_data, wrqu))
5693 {
5694 return -EINVAL;
5695 }
5696
5697 sub_cmd = s_priv_data.flags;
5698
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 switch (sub_cmd)
5700 {
5701 case WE_CLEAR_STATS:
5702 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5705 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5706 break;
5707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 case WE_INIT_AP:
5709 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305710 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5711
5712 /* As Soft AP mode might been changed to STA already with
5713 * killing of Hostapd, need to find the adpater by name
5714 * rather than mode */
5715 hdd_adapter_t* pAdapter_to_stop =
5716 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5717 if( pAdapter_to_stop )
5718 {
5719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5720 "Adapter with name softap.0 already "
5721 "exist, ignoring the request.\nRemove the "
5722 "adapter and try again\n");
5723 break;
5724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 pr_info("Init AP trigger\n");
5726 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5727 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5728 break;
5729 }
5730 case WE_STOP_AP:
5731 {
5732 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5733 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5734 * this is a dead code and need to find the adpater by name rather than mode */
5735 hdd_adapter_t* pAdapter_to_stop =
5736 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5737 if( pAdapter_to_stop )
5738 {
5739 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5740
5741 pr_info("Stopping AP mode\n");
5742
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305743 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5744 {
5745 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5746 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5747 }
5748
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305750 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5752 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5753
5754 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5755 pAdapter_to_stop->macAddressCurrent.bytes);
5756 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5757 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305758
5759 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5760 {
5761 /* put the device back into BMPS */
5762 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 }
5765 else
5766 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005767 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 }
5769
5770 break;
5771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005772#ifdef WLAN_BTAMP_FEATURE
5773 case WE_ENABLE_AMP:
5774 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 WLANBAP_RegisterWithHCI(pAdapter);
5777 break;
5778 }
5779 case WE_DISABLE_AMP:
5780 {
5781 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5782 VOS_STATUS status;
5783
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005785
5786 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5787 status = WLANBAP_StopAmp();
5788 if(VOS_STATUS_SUCCESS != status )
5789 {
5790 pHddCtx->isAmpAllowed = VOS_TRUE;
5791 hddLog(VOS_TRACE_LEVEL_FATAL,
5792 "%s: Failed to stop AMP", __func__);
5793 }
5794 else
5795 {
5796 //a state m/c implementation in PAL is TBD to avoid this delay
5797 msleep(500);
5798 pHddCtx->isAmpAllowed = VOS_FALSE;
5799 WLANBAP_DeregisterFromHCI();
5800 }
5801
5802 break;
5803 }
5804#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005805 case WE_ENABLE_DXE_STALL_DETECT:
5806 {
schang6295e542013-03-12 15:31:23 -07005807 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5808 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005809 break;
5810 }
5811 case WE_DISPLAY_DXE_SNAP_SHOT:
5812 {
schang6295e542013-03-12 15:31:23 -07005813 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5814 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005815 break;
5816 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305817 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5818 {
5819 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5820 hdd_wmm_tx_snapshot(pAdapter);
5821 WLANTL_TLDebugMessage(VOS_TRUE);
5822 break;
5823 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305824
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305825 case WE_SET_REASSOC_TRIGGER:
5826 {
5827 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5828 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5829 v_U32_t roamId = 0;
5830 tCsrRoamModifyProfileFields modProfileFields;
5831 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5832 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5833 return 0;
5834 }
5835
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305836 case WE_STOP_OBSS_SCAN:
5837 {
5838 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5839 2.OBSS scan is stopped by Firmware during the disassociation
5840 3.OBSS stop comamnd is added for debugging purpose*/
5841 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5842 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005843
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305844 if (pAdapter == NULL)
5845 {
5846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5847 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305848 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305849 }
5850 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5851 if (pMac == NULL)
5852 {
5853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5854 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305855 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305856 }
5857 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5858 }
5859 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05305860#ifdef DEBUG_ROAM_DELAY
5861 case WE_DUMP_ROAM_TIMER_LOG:
5862 {
5863 vos_dump_roam_time_log_service();
5864 break;
5865 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305866
Mukul Sharma84f27252014-07-14 18:11:42 +05305867 case WE_RESET_ROAM_TIMER_LOG:
5868 {
5869 vos_reset_roam_timer_log();
5870 break;
5871 }
5872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 default:
5874 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005875 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 break;
5877 }
5878 }
5879
5880 return ret;
5881}
5882
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305883static int iw_setnone_getnone(struct net_device *dev,
5884 struct iw_request_info *info,
5885 union iwreq_data *wrqu, char *extra)
5886{
5887 int ret;
5888
5889 vos_ssr_protect(__func__);
5890 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
5891 vos_ssr_unprotect(__func__);
5892
5893 return ret;
5894}
5895
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305896void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5897{
5898 /*
5899 * Function to display HDD WMM information
5900 * for Tx Queues.
5901 * Prints globala as well as per client depending
5902 * whether the clients are registered or not.
5903 */
5904 int i = 0, j = 0;
5905 for ( i=0; i< NUM_TX_QUEUES; i++)
5906 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305907 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005908 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305909 i, pAdapter->wmm_tx_queue[i].count,
5910 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305911 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305912 }
5913
5914 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5915 {
5916 if(pAdapter->aStaInfo[i].isUsed)
5917 {
5918 hddLog(LOGE, "******STAIndex: %d*********", i);
5919 for ( j=0; j< NUM_TX_QUEUES; j++)
5920 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305921 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005922 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305923 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5924 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5925 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305926 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305927 }
5928 }
5929 }
5930
5931}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305932int __iw_set_var_ints_getnone(struct net_device *dev,
5933 struct iw_request_info *info,
5934 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005935{
5936 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5937 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05305938 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 int apps_args[MAX_VAR_ARGS] = {0};
Girish Gowlid4522fd2014-06-14 17:20:27 +05305940 int num_args;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005941 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05305942 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005943 hdd_ap_ctx_t *pAPCtx = NULL;
5944 int cmd = 0;
5945 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05305946 int ret = 0;
Girish Gowlid4522fd2014-06-14 17:20:27 +05305947 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005948
Girish Gowlid4522fd2014-06-14 17:20:27 +05305949 /* helper function to get iwreq_data with compat handling. */
5950 if (hdd_priv_get_data(&s_priv_data, wrqu))
5951 {
5952 return -EINVAL;
5953 }
5954
5955 if (NULL == s_priv_data.pointer)
5956 {
5957 return -EINVAL;
5958 }
5959
5960 sub_cmd = s_priv_data.flags;
5961 num_args = s_priv_data.length;
5962
5963 hddLog(LOG1, "%s: Received length %d", __func__, s_priv_data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005964
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05305965 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5966 ret = wlan_hdd_validate_context(pHddCtx);
5967 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005968 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05305969 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5970 "%s: HDD context is Null", __func__);
5971 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005972 }
5973
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 if (num_args > MAX_VAR_ARGS)
5975 {
5976 num_args = MAX_VAR_ARGS;
5977 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005978
5979 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlid4522fd2014-06-14 17:20:27 +05305980 if (copy_from_user(apps_args, s_priv_data.pointer, (sizeof(int)) * num_args))
Arif Hussain0273cba2014-01-07 20:58:29 -08005981 {
5982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5983 "%s: failed to copy data to user buffer", __func__);
5984 return -EFAULT;
5985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005986
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005987 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5988 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5989 {
5990 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5991 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5992 {
5993 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5994 staId = pStaCtx->conn_info.staId[0];
5995 }
5996 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5997 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5998 {
5999 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
6000 staId = pAPCtx->uBCStaId;
6001 }
6002 else
6003 {
6004 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
6005 return 0;
6006 }
6007 }
6008
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 switch (sub_cmd)
6010 {
6011 case WE_LOG_DUMP_CMD:
6012 {
6013 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006014 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 apps_args[3], apps_args[4]);
6016
6017 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
6018 apps_args[3], apps_args[4]);
6019
6020 }
6021 break;
6022
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 case WE_P2P_NOA_CMD:
6024 {
6025 p2p_app_setP2pPs_t p2pNoA;
6026
6027 p2pNoA.opp_ps = apps_args[0];
6028 p2pNoA.ctWindow = apps_args[1];
6029 p2pNoA.duration = apps_args[2];
6030 p2pNoA.interval = apps_args[3];
6031 p2pNoA.count = apps_args[4];
6032 p2pNoA.single_noa_duration = apps_args[5];
6033 p2pNoA.psSelection = apps_args[6];
6034
6035 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
6036 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006037 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
6039
6040 hdd_setP2pPs(dev, &p2pNoA);
6041
6042 }
6043 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006044
Katya Nigamc2f29dc2014-01-20 19:29:30 +05306045 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
6046 {
6047 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
6048 __func__, apps_args[0], apps_args[1]);
6049 vosTraceEnable(apps_args[0], apps_args[1]);
6050 }
6051 break;
6052
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07006053 case WE_MTRACE_DUMP_CMD:
6054 {
6055 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
6056 "bitmask_of_module %d ",
6057 __func__, apps_args[0], apps_args[1], apps_args[2],
6058 apps_args[3]);
6059 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
6060 apps_args[2], apps_args[3]);
6061
6062 }
6063 break;
6064
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006065 case WE_MCC_CONFIG_CREDENTIAL :
6066 {
6067 cmd = 287; //Command should be updated if there is any change
6068 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08006069 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006070 {
6071 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
6072 }
6073 else
6074 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006075 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006076 return 0;
6077 }
6078 }
6079 break;
6080
6081 case WE_MCC_CONFIG_PARAMS :
6082 {
6083 cmd = 288; //command Should be updated if there is any change
6084 // in the Riva dump command
6085 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
6086 }
6087 break;
6088
Chilam NG571c65a2013-01-19 12:27:36 +05306089#ifdef FEATURE_WLAN_TDLS
6090 case WE_TDLS_CONFIG_PARAMS :
6091 {
6092 tdls_config_params_t tdlsParams;
6093
Chilam Ng01120412013-02-19 18:32:21 -08006094 tdlsParams.tdls = apps_args[0];
6095 tdlsParams.tx_period_t = apps_args[1];
6096 tdlsParams.tx_packet_n = apps_args[2];
6097 tdlsParams.discovery_period_t = apps_args[3];
6098 tdlsParams.discovery_tries_n = apps_args[4];
6099 tdlsParams.idle_timeout_t = apps_args[5];
6100 tdlsParams.idle_packet_n = apps_args[6];
6101 tdlsParams.rssi_hysteresis = apps_args[7];
6102 tdlsParams.rssi_trigger_threshold = apps_args[8];
6103 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05306104
Chilam Ng01120412013-02-19 18:32:21 -08006105 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05306106 }
6107 break;
6108#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 default:
6110 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006111 hddLog(LOGE, "%s: Invalid IOCTL command %d",
6112 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 }
6114 break;
6115 }
6116
6117 return 0;
6118}
6119
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306120int iw_set_var_ints_getnone(struct net_device *dev,
6121 struct iw_request_info *info,
6122 union iwreq_data *wrqu, char *extra)
6123{
6124 int ret;
6125 vos_ssr_protect(__func__);
6126 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
6127 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006128
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306129 return ret;
6130}
6131
6132static int __iw_add_tspec(struct net_device *dev,
6133 struct iw_request_info *info,
6134 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006135{
6136 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6137 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6138 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6139 int params[HDD_WLAN_WMM_PARAM_COUNT];
6140 sme_QosWmmTspecInfo tSpec;
6141 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05306142 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006143
6144 // make sure the application is sufficiently priviledged
6145 // note that the kernel will do this for "set" ioctls, but since
6146 // this ioctl wants to return status to user space it must be
6147 // defined as a "get" ioctl
6148 if (!capable(CAP_NET_ADMIN))
6149 {
6150 return -EPERM;
6151 }
6152
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006153 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6154 {
6155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6156 "%s:LOGP in Progress. Ignore!!!", __func__);
6157 return -EBUSY;
6158 }
6159
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 // we must be associated in order to add a tspec
6161 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6162 {
6163 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6164 return 0;
6165 }
6166
6167 // since we are defined to be a "get" ioctl, and since the number
6168 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05306169 // will pass down in the iwreq_data, we must copy the "set" params.
6170 // We must handle the compat for iwreq_data in 32U/64K environment.
6171
6172 // helper fucntion to get iwreq_data with compat handling.
6173 if (hdd_priv_get_data(&s_priv_data, wrqu))
6174 {
6175 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6176 return 0;
6177 }
6178
6179 // make sure all params are correctly passed to function
6180 if ((NULL == s_priv_data.pointer) ||
6181 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
6182 {
6183 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6184 return 0;
6185 }
6186
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05306188 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 {
6190 // hmmm, can't get them
6191 return -EIO;
6192 }
6193
6194 // clear the tspec
6195 memset(&tSpec, 0, sizeof(tSpec));
6196
6197 // validate the handle
6198 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6199 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6200 {
6201 // that one is reserved
6202 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6203 return 0;
6204 }
6205
6206 // validate the TID
6207 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
6208 {
6209 // out of range
6210 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6211 return 0;
6212 }
6213 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
6214
6215 // validate the direction
6216 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
6217 {
6218 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
6219 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
6220 break;
6221
6222 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
6223 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
6224 break;
6225
6226 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
6227 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
6228 break;
6229
6230 default:
6231 // unknown
6232 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6233 return 0;
6234 }
6235
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05306236 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
6237
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 // validate the user priority
6239 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
6240 {
6241 // out of range
6242 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6243 return 0;
6244 }
6245 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05306246 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
6247 {
6248 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
6249 return 0;
6250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006251
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05306252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6253 "%s:TS_INFO PSB %d UP %d !!!", __func__,
6254 tSpec.ts_info.psb, tSpec.ts_info.up);
6255
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
6257 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
6258 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
6259 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
6260 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
6261 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
6262 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
6263 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
6264 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
6265 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
6266 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
6267 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
6268
6269 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
6270
6271 // validate the ts info ack policy
6272 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
6273 {
6274 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
6275 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
6276 break;
6277
6278 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
6279 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
6280 break;
6281
6282 default:
6283 // unknown
6284 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6285 return 0;
6286 }
6287
6288 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
6289 return 0;
6290}
6291
6292
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306293static int iw_add_tspec(struct net_device *dev,
6294 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 union iwreq_data *wrqu, char *extra)
6296{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306297 int ret;
6298
6299 vos_ssr_protect(__func__);
6300 ret = __iw_add_tspec(dev, info, wrqu, extra);
6301 vos_ssr_unprotect(__func__);
6302
6303 return ret;
6304}
6305
6306static int __iw_del_tspec(struct net_device *dev,
6307 struct iw_request_info *info,
6308 union iwreq_data *wrqu, char *extra)
6309{
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6311 int *params = (int *)extra;
6312 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6313 v_U32_t handle;
6314
6315 // make sure the application is sufficiently priviledged
6316 // note that the kernel will do this for "set" ioctls, but since
6317 // this ioctl wants to return status to user space it must be
6318 // defined as a "get" ioctl
6319 if (!capable(CAP_NET_ADMIN))
6320 {
6321 return -EPERM;
6322 }
6323
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006324 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6325 {
6326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6327 "%s:LOGP in Progress. Ignore!!!", __func__);
6328 return -EBUSY;
6329 }
6330
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 // although we are defined to be a "get" ioctl, the params we require
6332 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
6333 // is no need to copy the params from user space
6334
6335 // validate the handle
6336 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6337 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6338 {
6339 // that one is reserved
6340 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6341 return 0;
6342 }
6343
6344 *pStatus = hdd_wmm_delts(pAdapter, handle);
6345 return 0;
6346}
6347
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306348static int iw_del_tspec(struct net_device *dev,
6349 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 union iwreq_data *wrqu, char *extra)
6351{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306352 int ret;
6353
6354 vos_ssr_protect(__func__);
6355 ret = __iw_del_tspec(dev, info, wrqu, extra);
6356 vos_ssr_unprotect(__func__);
6357
6358 return ret;
6359}
6360
6361
6362static int __iw_get_tspec(struct net_device *dev,
6363 struct iw_request_info *info,
6364 union iwreq_data *wrqu, char *extra)
6365{
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6367 int *params = (int *)extra;
6368 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6369 v_U32_t handle;
6370
6371 // although we are defined to be a "get" ioctl, the params we require
6372 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
6373 // is no need to copy the params from user space
6374
6375 // validate the handle
6376 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6377 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6378 {
6379 // that one is reserved
6380 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6381 return 0;
6382 }
6383
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006384 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6385 {
6386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6387 "%s:LOGP in Progress. Ignore!!!", __func__);
6388 return -EBUSY;
6389 }
6390
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 *pStatus = hdd_wmm_checkts(pAdapter, handle);
6392 return 0;
6393}
6394
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306395static int iw_get_tspec(struct net_device *dev,
6396 struct iw_request_info *info,
6397 union iwreq_data *wrqu, char *extra)
6398{
6399 int ret;
6400
6401 vos_ssr_protect(__func__);
6402 ret = __iw_get_tspec(dev, info, wrqu, extra);
6403 vos_ssr_unprotect(__func__);
6404
6405 return ret;
6406}
6407
Jeff Johnson295189b2012-06-20 16:38:30 -07006408#ifdef WLAN_FEATURE_VOWIFI_11R
6409//
6410//
6411// Each time the supplicant has the auth_request or reassoc request
6412// IEs ready. This is pushed to the driver. The driver will inturn use
6413// it to send out the auth req and reassoc req for 11r FT Assoc.
6414//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306415static int __iw_set_fties(struct net_device *dev,
6416 struct iw_request_info *info,
6417 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006418{
6419 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6420 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6421 //v_CONTEXT_t pVosContext;
6422
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006423 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6424 {
6425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6426 "%s:LOGP in Progress. Ignore!!!", __func__);
6427 return -EBUSY;
6428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 if (!wrqu->data.length)
6430 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006431 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 return -EINVAL;
6433 }
6434 if (wrqu->data.pointer == NULL)
6435 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006436 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 return -EINVAL;
6438 }
6439
6440 // Added for debug on reception of Re-assoc Req.
6441 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6442 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006443 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006445 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 }
6447
6448#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08006449 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07006450#endif
6451
6452 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08006453 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 wrqu->data.length);
6455
6456 return 0;
6457}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306458
6459static int iw_set_fties(struct net_device *dev,
6460 struct iw_request_info *info,
6461 union iwreq_data *wrqu, char *extra)
6462{
6463 int ret;
6464
6465 vos_ssr_protect(__func__);
6466 ret = __iw_set_fties(dev, info, wrqu, extra);
6467 vos_ssr_unprotect(__func__);
6468
6469 return ret;
6470}
Jeff Johnson295189b2012-06-20 16:38:30 -07006471#endif
6472
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306473static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006474 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08006476{
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006478 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006480 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006481 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006482 tpSirRcvFltMcAddrList mc_addr_list_ptr;
6483 int idx;
6484 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07006485
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006486 if (pHddCtx->isLogpInProgress)
6487 {
6488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6489 "%s:LOGP in Progress. Ignore!!!", __func__);
6490 return -EBUSY;
6491 }
6492
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306493 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
6494 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306495#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07006496
Amar Singhalf3a6e762013-02-19 15:06:50 -08006497 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6498 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006499 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006500 hddLog(VOS_TRACE_LEVEL_ERROR,
6501 "%s: vos_mem_alloc failed", __func__);
6502 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006503 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006504
6505 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6506
6507 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6508 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6509
6510 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6511 mc_addr_list_ptr->ulMulticastAddrCnt);
6512
6513 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006514 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006515 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6516 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6517
6518 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6519 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006520 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006521
Amar Singhalf3a6e762013-02-19 15:06:50 -08006522 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6523 vos_mem_free(mc_addr_list_ptr);
6524 if (eHAL_STATUS_SUCCESS != ret_val)
6525 {
6526 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6527 __func__);
6528 return -EINVAL;
6529 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306530#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306531 }
6532 else
6533 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006534
Amar Singhalf3a6e762013-02-19 15:06:50 -08006535 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6536 "%s: Set MC BC Filter Config request: %d suspend %d",
6537 __func__, pRequest->mcastBcastFilterSetting,
6538 pHddCtx->hdd_wlan_suspended);
6539
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306540 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006541
6542 if (pHddCtx->hdd_wlan_suspended)
6543 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006544 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6545 if (NULL == wlanRxpFilterParam)
6546 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306547 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006548 "%s: vos_mem_alloc failed", __func__);
6549 return -EINVAL;
6550 }
6551
Amar Singhalf3a6e762013-02-19 15:06:50 -08006552 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6553 pRequest->mcastBcastFilterSetting;
6554 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6555
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306556 hdd_conf_hostoffload(pAdapter, TRUE);
6557 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6558 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006559
6560 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6561 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306562 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006563 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6564 wlanRxpFilterParam->setMcstBcstFilter);
6565
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306566 if (eHAL_STATUS_SUCCESS !=
6567 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6568 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006569 {
6570 hddLog(VOS_TRACE_LEVEL_ERROR,
6571 "%s: Failure to execute set HW MC/BC Filter request",
6572 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006573 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006574 return -EINVAL;
6575 }
6576
c_hpothud3ce76d2014-10-28 10:34:13 +05306577 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
6578 {
6579 pHddCtx->sus_res_mcastbcast_filter =
6580 pRequest->mcastBcastFilterSetting;
6581 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006582 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006584
6585 return 0;
6586}
6587
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306588static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
6589 struct iw_request_info *info,
6590 union iwreq_data *wrqu, char *extra)
6591{
6592 int ret;
6593
6594 vos_ssr_protect(__func__);
6595 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
6596 vos_ssr_unprotect(__func__);
6597
6598 return ret;
6599}
6600
6601static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
6602 struct iw_request_info *info,
6603 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006604{
6605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6606 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306607 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006608 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006609
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306610 //Reset the filter to INI value as we have to clear the dynamic filter
6611 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006612
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306613 //Configure FW with new setting
6614 if (pHddCtx->hdd_wlan_suspended)
6615 {
6616 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6617 if (NULL == wlanRxpFilterParam)
6618 {
6619 hddLog(VOS_TRACE_LEVEL_ERROR,
6620 "%s: vos_mem_alloc failed", __func__);
6621 return -EINVAL;
6622 }
6623
6624 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6625 pHddCtx->configuredMcastBcastFilter;
6626 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6627
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306628 hdd_conf_hostoffload(pAdapter, TRUE);
6629 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6630 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306631
6632 if (eHAL_STATUS_SUCCESS !=
6633 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6634 wlanRxpFilterParam))
6635 {
6636 hddLog(VOS_TRACE_LEVEL_ERROR,
6637 "%s: Failure to execute set HW MC/BC Filter request",
6638 __func__);
6639 vos_mem_free(wlanRxpFilterParam);
6640 return -EINVAL;
6641 }
c_hpothud3ce76d2014-10-28 10:34:13 +05306642
6643 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
6644 {
6645 pHddCtx->sus_res_mcastbcast_filter =
6646 pHddCtx->cfg_ini->mcastBcastFilterSetting;
6647 }
6648
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 return 0;
6651}
6652
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306653
6654static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
6655 struct iw_request_info *info,
6656 union iwreq_data *wrqu, char *extra)
6657{
6658 int ret;
6659
6660 vos_ssr_protect(__func__);
6661 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
6662 vos_ssr_unprotect(__func__);
6663
6664 return ret;
6665}
6666
6667static int __iw_set_host_offload(struct net_device *dev,
6668 struct iw_request_info *info,
6669 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006670{
6671 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006672 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 tSirHostOffloadReq offloadRequest;
6674
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006675 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6676 {
6677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6678 "%s:LOGP in Progress. Ignore!!!", __func__);
6679 return -EBUSY;
6680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 /* Debug display of request components. */
6682 switch (pRequest->offloadType)
6683 {
6684 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006685 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006686 switch (pRequest->enableOrDisable)
6687 {
6688 case WLAN_OFFLOAD_DISABLE:
6689 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6690 break;
6691 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6692 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6693 case WLAN_OFFLOAD_ENABLE:
6694 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6695 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6696 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6697 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6698 }
6699 break;
6700
6701 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006702 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006703 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 switch (pRequest->enableOrDisable)
6705 {
6706 case WLAN_OFFLOAD_DISABLE:
6707 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6708 break;
6709 case WLAN_OFFLOAD_ENABLE:
6710 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6711 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6712 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6713 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6714 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6715 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6716 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6717 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6718 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6719 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6720 }
6721 }
6722
6723 /* Execute offload request. The reason that we can copy the request information
6724 from the ioctl structure to the SME structure is that they are laid out
6725 exactly the same. Otherwise, each piece of information would have to be
6726 copied individually. */
6727 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006728 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6729 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006731 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 __func__);
6733 return -EINVAL;
6734 }
6735
6736 return 0;
6737}
6738
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306739static int iw_set_host_offload(struct net_device *dev,
6740 struct iw_request_info *info,
6741 union iwreq_data *wrqu, char *extra)
6742{
6743 int ret;
6744
6745 vos_ssr_protect(__func__);
6746 ret = __iw_set_host_offload(dev, info, wrqu, extra);
6747 vos_ssr_unprotect(__func__);
6748
6749 return ret;
6750}
6751
6752static int __iw_set_keepalive_params(struct net_device *dev,
6753 struct iw_request_info *info,
6754 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006755{
6756 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006757 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 tSirKeepAliveReq keepaliveRequest;
6759
6760 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6761 {
6762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006763 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 return 0;
6765 }
6766
6767 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006768 hddLog(VOS_TRACE_LEVEL_INFO,
6769 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6770 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006771
6772 switch (pRequest->packetType)
6773 {
6774 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006775 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 break;
6777
6778 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6779
Arif Hussain6d2a3322013-11-17 19:50:10 -08006780 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006781 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006782
6783 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6784 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6785 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6786
6787 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6788 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6789 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6790
6791 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6792 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6793 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6794 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6795 break;
6796
6797 }
6798
6799 /* Execute keep alive request. The reason that we can copy the request information
6800 from the ioctl structure to the SME structure is that they are laid out
6801 exactly the same. Otherwise, each piece of information would have to be
6802 copied individually. */
6803 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6804
Arif Hussain6d2a3322013-11-17 19:50:10 -08006805 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006806
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006807 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006808 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006810 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006811 __func__);
6812 return -EINVAL;
6813 }
6814
6815 return 0;
6816}
6817
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306818static int iw_set_keepalive_params(struct net_device *dev,
6819 struct iw_request_info *info,
6820 union iwreq_data *wrqu, char *extra)
6821{
6822 int ret;
6823 vos_ssr_protect(__func__);
6824 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
6825 vos_ssr_unprotect(__func__);
6826
6827 return ret;
6828}
6829
Jeff Johnson295189b2012-06-20 16:38:30 -07006830#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006831int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006832 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006833{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006834 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6835 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 int i=0;
6837
6838 if (pHddCtx->cfg_ini->disablePacketFilter)
6839 {
6840 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006841 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 return 0;
6843 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006844 if (pHddCtx->isLogpInProgress)
6845 {
6846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6847 "%s:LOGP in Progress. Ignore!!!", __func__);
6848 return -EBUSY;
6849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 /* Debug display of request components. */
6851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006852 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006853
6854 switch (pRequest->filterAction)
6855 {
6856 case HDD_RCV_FILTER_SET:
6857 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006858 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006859
6860 packetFilterSetReq.filterId = pRequest->filterId;
6861 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6862 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006863 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 __func__, pRequest->numParams);
6865 return -EINVAL;
6866 }
6867 packetFilterSetReq.numFieldParams = pRequest->numParams;
6868 packetFilterSetReq.coalesceTime = 0;
6869 packetFilterSetReq.filterType = 1;
6870 for (i=0; i < pRequest->numParams; i++)
6871 {
6872 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6873 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6874 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6875 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6876 packetFilterSetReq.paramsData[i].reserved = 0;
6877
Arif Hussain6d2a3322013-11-17 19:50:10 -08006878 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6880 packetFilterSetReq.filterType);
6881
Arif Hussain6d2a3322013-11-17 19:50:10 -08006882 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6884
6885 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6886 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6887 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6888 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6889
Arif Hussain6d2a3322013-11-17 19:50:10 -08006890 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6892 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6893 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6894
Arif Hussain6d2a3322013-11-17 19:50:10 -08006895 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6897 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6898 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6899 }
6900
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006901 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006903 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 __func__);
6905 return -EINVAL;
6906 }
6907
6908 break;
6909
6910 case HDD_RCV_FILTER_CLEAR:
6911
Arif Hussain6d2a3322013-11-17 19:50:10 -08006912 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006913 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006915 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006917 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 __func__);
6919 return -EINVAL;
6920 }
6921 break;
6922
6923 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006924 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006925 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 return -EINVAL;
6927 }
6928 return 0;
6929}
6930
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306931int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6932 tANI_U8 sessionId)
6933{
6934 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6935 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6936
6937 if (NULL == pHddCtx)
6938 {
6939 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6940 return -EINVAL;
6941 }
6942
6943 if (pHddCtx->isLogpInProgress)
6944 {
6945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6946 "%s:LOGP in Progress. Ignore!!!", __func__);
6947 return -EBUSY;
6948 }
6949
6950 if (pHddCtx->cfg_ini->disablePacketFilter)
6951 {
6952 hddLog(VOS_TRACE_LEVEL_ERROR,
6953 "%s: Packet Filtering Disabled. Returning ",
6954 __func__ );
6955 return -EINVAL;
6956 }
6957
6958 switch (filterType)
6959 {
6960 /* For setting IPV6 MC and UC Filter we need to configure
6961 * 2 filters, one for MC and one for UC.
6962 * The Filter ID shouldn't be swapped, which results in making
6963 * UC Filter ineffective.
6964 * We have Hardcode all the values
6965 *
6966 * Reason for a seperate UC filter is because, driver need to
6967 * specify the FW that the specific filter is for unicast
6968 * otherwise FW will not pass the unicast frames by default
6969 * through the filter. This is required to avoid any performance
6970 * hits when no unicast filter is set and only MC/BC are set.
6971 * The way driver informs host is by using the MAC protocol
6972 * layer, CMP flag set to MAX, CMP Data set to 1.
6973 */
6974
6975 case HDD_FILTER_IPV6_MC_UC:
6976 /* Setting IPV6 MC Filter below
6977 */
6978 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6979 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6980 packetFilterSetReq.numFieldParams = 2;
6981 packetFilterSetReq.paramsData[0].protocolLayer =
6982 HDD_FILTER_PROTO_TYPE_MAC;
6983 packetFilterSetReq.paramsData[0].cmpFlag =
6984 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6985 packetFilterSetReq.paramsData[0].dataOffset =
6986 WLAN_HDD_80211_FRM_DA_OFFSET;
6987 packetFilterSetReq.paramsData[0].dataLength = 1;
6988 packetFilterSetReq.paramsData[0].compareData[0] =
6989 HDD_IPV6_MC_CMP_DATA;
6990
6991 packetFilterSetReq.paramsData[1].protocolLayer =
6992 HDD_FILTER_PROTO_TYPE_ARP;
6993 packetFilterSetReq.paramsData[1].cmpFlag =
6994 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6995 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6996 packetFilterSetReq.paramsData[1].dataLength = 2;
6997 packetFilterSetReq.paramsData[1].compareData[0] =
6998 HDD_IPV6_CMP_DATA_0;
6999 packetFilterSetReq.paramsData[1].compareData[1] =
7000 HDD_IPV6_CMP_DATA_1;
7001
7002
7003 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
7004 &packetFilterSetReq, sessionId))
7005 {
7006 hddLog(VOS_TRACE_LEVEL_ERROR,
7007 "%s: Failure to execute Set IPv6 Mulicast Filter",
7008 __func__);
7009 return -EINVAL;
7010 }
7011
7012 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
7013
7014 /*
7015 * Setting IPV6 UC Filter below
7016 */
7017 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
7018 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
7019 packetFilterSetReq.numFieldParams = 2;
7020 packetFilterSetReq.paramsData[0].protocolLayer =
7021 HDD_FILTER_PROTO_TYPE_MAC;
7022 packetFilterSetReq.paramsData[0].cmpFlag =
7023 HDD_FILTER_CMP_TYPE_MAX;
7024 packetFilterSetReq.paramsData[0].dataOffset = 0;
7025 packetFilterSetReq.paramsData[0].dataLength = 1;
7026 packetFilterSetReq.paramsData[0].compareData[0] =
7027 HDD_IPV6_UC_CMP_DATA;
7028
7029 packetFilterSetReq.paramsData[1].protocolLayer =
7030 HDD_FILTER_PROTO_TYPE_ARP;
7031 packetFilterSetReq.paramsData[1].cmpFlag =
7032 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7033 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
7034 packetFilterSetReq.paramsData[1].dataLength = 2;
7035 packetFilterSetReq.paramsData[1].compareData[0] =
7036 HDD_IPV6_CMP_DATA_0;
7037 packetFilterSetReq.paramsData[1].compareData[1] =
7038 HDD_IPV6_CMP_DATA_1;
7039
7040 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
7041 &packetFilterSetReq, sessionId))
7042 {
7043 hddLog(VOS_TRACE_LEVEL_ERROR,
7044 "%s: Failure to execute Set IPv6 Unicast Filter",
7045 __func__);
7046 return -EINVAL;
7047 }
7048
7049 break;
7050
7051 case HDD_FILTER_IPV6_MC:
7052 /*
7053 * IPV6 UC Filter might be already set,
7054 * clear the UC Filter. As the Filter
7055 * IDs are static, we can directly clear it.
7056 */
7057 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
7058 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
7059 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
7060 &packetFilterClrReq, sessionId))
7061 {
7062 hddLog(VOS_TRACE_LEVEL_ERROR,
7063 "%s: Failure to execute Clear IPv6 Unicast Filter",
7064 __func__);
7065 return -EINVAL;
7066 }
7067
7068 /*
7069 * Setting IPV6 MC Filter below
7070 */
7071 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
7072 packetFilterSetReq.numFieldParams = 2;
7073 packetFilterSetReq.paramsData[0].protocolLayer =
7074 HDD_FILTER_PROTO_TYPE_MAC;
7075 packetFilterSetReq.paramsData[0].cmpFlag =
7076 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7077 packetFilterSetReq.paramsData[0].dataOffset =
7078 WLAN_HDD_80211_FRM_DA_OFFSET;
7079 packetFilterSetReq.paramsData[0].dataLength = 1;
7080 packetFilterSetReq.paramsData[0].compareData[0] =
7081 HDD_IPV6_MC_CMP_DATA;
7082
7083 packetFilterSetReq.paramsData[1].protocolLayer =
7084 HDD_FILTER_PROTO_TYPE_ARP;
7085 packetFilterSetReq.paramsData[1].cmpFlag =
7086 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7087 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
7088 packetFilterSetReq.paramsData[1].dataLength = 2;
7089 packetFilterSetReq.paramsData[1].compareData[0] =
7090 HDD_IPV6_CMP_DATA_0;
7091 packetFilterSetReq.paramsData[1].compareData[1] =
7092 HDD_IPV6_CMP_DATA_1;
7093
7094
7095 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
7096 &packetFilterSetReq, sessionId))
7097 {
7098 hddLog(VOS_TRACE_LEVEL_ERROR,
7099 "%s: Failure to execute Set IPv6 Multicast Filter",
7100 __func__);
7101 return -EINVAL;
7102 }
7103 break;
7104
7105 default :
7106 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7107 "%s: Packet Filter Request: Invalid",
7108 __func__);
7109 return -EINVAL;
7110 }
7111 return 0;
7112}
7113
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307114void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07007115{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307116 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307117 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07007118 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307119 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007120
Yue Ma3ede6052013-08-29 00:33:26 -07007121 if (NULL == pHddCtx)
7122 {
7123 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
7124 return;
7125 }
7126
7127 hHal = pHddCtx->hHal;
7128
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307129 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307131 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
7132 return;
7133 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307134
7135 /* Check if INI is enabled or not, other wise just return
7136 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05307137 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307138 {
7139 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7140 if (NULL == pMulticastAddrs)
7141 {
7142 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
7143 return;
7144 }
7145
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 if (set)
7147 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307148 /* Following pre-conditions should be satisfied before wei
7149 * configure the MC address list.
7150 */
7151 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
7152 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
7153 && pAdapter->mc_addr_list.mc_cnt
7154 && (eConnectionState_Associated ==
7155 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7156 {
7157 pMulticastAddrs->ulMulticastAddrCnt =
7158 pAdapter->mc_addr_list.mc_cnt;
7159 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
7160 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007161 memcpy(pMulticastAddrs->multicastAddr[i],
7162 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307163 sizeof(pAdapter->mc_addr_list.addr[i]));
7164 hddLog(VOS_TRACE_LEVEL_INFO,
7165 "%s: %s multicast filter: addr ="
7166 MAC_ADDRESS_STR,
7167 __func__, set ? "setting" : "clearing",
7168 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
7169 }
7170 /* Set multicast filter */
7171 sme_8023MulticastList(hHal, pAdapter->sessionId,
7172 pMulticastAddrs);
7173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307175 else
7176 {
7177 /* Need to clear only if it was previously configured
7178 */
7179 if (pAdapter->mc_addr_list.isFilterApplied)
7180 {
7181 pMulticastAddrs->ulMulticastAddrCnt = 0;
7182 sme_8023MulticastList(hHal, pAdapter->sessionId,
7183 pMulticastAddrs);
7184 }
7185
7186 }
7187 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07007188 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307190 else
7191 {
7192 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05307193 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307194 }
7195 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007196}
7197
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307198static int __iw_set_packet_filter_params(struct net_device *dev,
7199 struct iw_request_info *info,
7200 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307201{
Jeff Johnson295189b2012-06-20 16:38:30 -07007202 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007203 tpPacketFilterCfg pRequest = NULL;
7204 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05307205 struct iw_point s_priv_data;
7206
7207 if (hdd_priv_get_data(&s_priv_data, wrqu))
7208 {
7209 return -EINVAL;
7210 }
7211
7212 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
7213 {
7214 return -EINVAL;
7215 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007216
Arif Hussain0273cba2014-01-07 20:58:29 -08007217 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05307218 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
7219 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08007220 if (NULL == pRequest)
7221 {
7222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7223 "mem_alloc_copy_from_user_helper fail");
7224 return -ENOMEM;
7225 }
7226
7227 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
7228 kfree(pRequest);
7229
7230 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007231}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307232
7233static int iw_set_packet_filter_params(struct net_device *dev,
7234 struct iw_request_info *info,
7235 union iwreq_data *wrqu, char *extra)
7236{
7237 int ret;
7238
7239 vos_ssr_protect(__func__);
7240 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
7241 vos_ssr_unprotect(__func__);
7242
7243 return ret;
7244}
Jeff Johnson295189b2012-06-20 16:38:30 -07007245#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307246static int __iw_get_statistics(struct net_device *dev,
7247 struct iw_request_info *info,
7248 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007249{
7250
7251 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
7252 eHalStatus status = eHAL_STATUS_SUCCESS;
7253 hdd_wext_state_t *pWextState;
7254 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7255 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7256 char *p = extra;
7257 int tlen = 0;
7258 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
7259
7260 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
7261 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
7262
7263 ENTER();
7264
7265 if (pHddCtx->isLogpInProgress) {
7266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
7267 return -EINVAL;
7268 }
7269
7270 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
7271
7272 wrqu->txpower.value = 0;
7273 }
7274 else {
7275 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
7276 SME_SUMMARY_STATS |
7277 SME_GLOBAL_CLASSA_STATS |
7278 SME_GLOBAL_CLASSB_STATS |
7279 SME_GLOBAL_CLASSC_STATS |
7280 SME_GLOBAL_CLASSD_STATS |
7281 SME_PER_STA_STATS,
7282 hdd_StatisticsCB, 0, FALSE,
7283 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
7284
7285 if (eHAL_STATUS_SUCCESS != status)
7286 {
7287 hddLog(VOS_TRACE_LEVEL_ERROR,
7288 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007289 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 return -EINVAL;
7291 }
7292
7293 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7294
7295 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
7296 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7297 {
7298 hddLog(VOS_TRACE_LEVEL_ERROR,
7299 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007300 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 /*Remove the SME statistics list by passing NULL in callback argument*/
7302 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
7303 SME_SUMMARY_STATS |
7304 SME_GLOBAL_CLASSA_STATS |
7305 SME_GLOBAL_CLASSB_STATS |
7306 SME_GLOBAL_CLASSC_STATS |
7307 SME_GLOBAL_CLASSD_STATS |
7308 SME_PER_STA_STATS,
7309 NULL, 0, FALSE,
7310 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
7311
7312 return -EINVAL;
7313 }
7314 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
7315 (tANI_U8) sizeof (pStats->retry_cnt),
7316 (char*) &(pStats->retry_cnt[0]),
7317 tlen);
7318
7319 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
7320 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
7321 (char*) &(pStats->multiple_retry_cnt[0]),
7322 tlen);
7323
7324 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
7325 (tANI_U8) sizeof (pStats->tx_frm_cnt),
7326 (char*) &(pStats->tx_frm_cnt[0]),
7327 tlen);
7328
7329 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
7330 (tANI_U8) sizeof (pStats->rx_frm_cnt),
7331 (char*) &(pStats->rx_frm_cnt),
7332 tlen);
7333
7334 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
7335 (tANI_U8) sizeof (pStats->frm_dup_cnt),
7336 (char*) &(pStats->frm_dup_cnt),
7337 tlen);
7338
7339 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
7340 (tANI_U8) sizeof (pStats->fail_cnt),
7341 (char*) &(pStats->fail_cnt[0]),
7342 tlen);
7343
7344 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
7345 (tANI_U8) sizeof (pStats->rts_fail_cnt),
7346 (char*) &(pStats->rts_fail_cnt),
7347 tlen);
7348
7349 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
7350 (tANI_U8) sizeof (pStats->ack_fail_cnt),
7351 (char*) &(pStats->ack_fail_cnt),
7352 tlen);
7353
7354 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
7355 (tANI_U8) sizeof (pStats->rts_succ_cnt),
7356 (char*) &(pStats->rts_succ_cnt),
7357 tlen);
7358
7359 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
7360 (tANI_U8) sizeof (pStats->rx_discard_cnt),
7361 (char*) &(pStats->rx_discard_cnt),
7362 tlen);
7363
7364 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
7365 (tANI_U8) sizeof (pStats->rx_error_cnt),
7366 (char*) &(pStats->rx_error_cnt),
7367 tlen);
7368
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007369 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07007370 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007371 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07007372 tlen);
7373
7374 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
7375 (tANI_U8) sizeof (dStats->rx_byte_cnt),
7376 (char*) &(dStats->rx_byte_cnt),
7377 tlen);
7378
7379 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
7380 (tANI_U8) sizeof (dStats->rx_rate),
7381 (char*) &(dStats->rx_rate),
7382 tlen);
7383
7384 /* Transmit rate, in units of 500 kbit/sec */
7385 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
7386 (tANI_U8) sizeof (aStats->tx_rate),
7387 (char*) &(aStats->tx_rate),
7388 tlen);
7389
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007390 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
7391 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
7392 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07007393 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007394 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
7395 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
7396 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007397 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007398 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
7399 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
7400 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007401 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007402 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
7403 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
7404 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07007405 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007406 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
7407 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
7408 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007409 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007410 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
7411 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
7412 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007413 tlen);
7414
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 wrqu->data.length = tlen;
7416
7417 }
7418
7419 EXIT();
7420
7421 return 0;
7422}
7423
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307424static int iw_get_statistics(struct net_device *dev,
7425 struct iw_request_info *info,
7426 union iwreq_data *wrqu, char *extra)
7427{
7428 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007429
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307430 vos_ssr_protect(__func__);
7431 ret = __iw_get_statistics(dev, info, wrqu, extra);
7432 vos_ssr_unprotect(__func__);
7433
7434 return ret;
7435}
Jeff Johnson295189b2012-06-20 16:38:30 -07007436#ifdef FEATURE_WLAN_SCAN_PNO
7437
7438/*Max Len for PNO notification*/
7439#define MAX_PNO_NOTIFY_LEN 100
7440void found_pref_network_cb (void *callbackContext,
7441 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7442{
7443 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7444 union iwreq_data wrqu;
7445 char buf[MAX_PNO_NOTIFY_LEN+1];
7446
7447 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
7448 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
7449
7450 // create the event
7451 memset(&wrqu, 0, sizeof(wrqu));
7452 memset(buf, 0, sizeof(buf));
7453
7454 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
7455 pPrefNetworkFoundInd->ssId.ssId,
7456 (unsigned int)pPrefNetworkFoundInd->rssi);
7457
7458 wrqu.data.pointer = buf;
7459 wrqu.data.length = strlen(buf);
7460
7461 // send the event
7462
7463 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
7464
7465}
7466
7467
7468/*string based input*/
7469VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
7470 union iwreq_data *wrqu, char *extra, int nOffset)
7471{
7472 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05307473 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07007474 /* pnoRequest is a large struct, so we make it static to avoid stack
7475 overflow. This API is only invoked via ioctl, so it is
7476 serialized by the kernel rtnl_lock and hence does not need to be
7477 reentrant */
7478 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07007479 char *ptr;
7480 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05307481 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7483
7484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7485 "PNO data len %d data %s",
7486 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007487 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007488
7489 if (wrqu->data.length <= nOffset )
7490 {
7491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
7492 return VOS_STATUS_E_FAILURE;
7493 }
7494
7495 pnoRequest.enable = 0;
7496 pnoRequest.ucNetworksCount = 0;
7497 /*-----------------------------------------------------------------------
7498 Input is string based and expected to be like this:
7499
7500 <enabled> <netw_count>
7501 for each network:
7502 <ssid_len> <ssid> <authentication> <encryption>
7503 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
7504 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
7505
7506 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07007507 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 -07007508
7509 this translates into:
7510 -----------------------------
7511 enable PNO
7512 look for 2 networks:
7513 test - with authentication type 0 and encryption type 0,
7514 that can be found on 3 channels: 1 6 and 11 ,
7515 SSID bcast type is unknown (directed probe will be sent if AP not found)
7516 and must meet -40dBm RSSI
7517
7518 test2 - with auth and enrytption type 4/4
7519 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
7520 bcast type is non-bcast (directed probe will be sent)
7521 and must not meet any RSSI threshold
7522
Jeff Johnson8301aa12013-03-28 14:27:29 -07007523 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08007525 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007526
Wilson Yang623f6592013-10-08 16:33:37 -07007527 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
7528 {
7529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7530 "PNO enable input is not valid %s",ptr);
7531 return VOS_STATUS_E_FAILURE;
7532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007533
7534 if ( 0 == pnoRequest.enable )
7535 {
7536 /*Disable PNO*/
7537 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05307538 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7539 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 pAdapter->sessionId,
7541 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307542 if (eHAL_STATUS_SUCCESS != status)
7543 {
7544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7545 "%s: failed to disable PNO", __func__);
7546 return VOS_STATUS_E_FAILURE;
7547 }
7548 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 return VOS_STATUS_SUCCESS;
7550 }
7551
c_hpothu37f21312014-04-09 21:49:54 +05307552 if (TRUE == pHddCtx->isPnoEnable)
7553 {
7554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7555 FL("already PNO is enabled"));
7556 return -EBUSY;
7557 }
7558 pHddCtx->isPnoEnable = TRUE;
7559
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07007561
7562 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
7563 {
7564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7565 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307566 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007568
7569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7570 "PNO enable %d networks count %d offset %d",
7571 pnoRequest.enable,
7572 pnoRequest.ucNetworksCount,
7573 nOffset);
7574
7575 /* Parameters checking:
7576 ucNetworksCount has to be larger than 0*/
7577 if (( 0 == pnoRequest.ucNetworksCount ) ||
7578 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7579 {
7580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05307581 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 }
7583
7584 ptr += nOffset;
7585
7586 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
7587 {
7588
7589 pnoRequest.aNetworks[i].ssId.length = 0;
7590
Wilson Yang623f6592013-10-08 16:33:37 -07007591 ucParams = sscanf(ptr,"%hhu %n",
7592 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
7593
7594 if (1 != ucParams)
7595 {
7596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7597 "PNO ssid length input is not valid %s",ptr);
7598 return VOS_STATUS_E_FAILURE;
7599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007600
7601 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
7602 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
7603 {
7604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7605 "SSID Len %d is not correct for network %d",
7606 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05307607 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 }
7609
7610 /*Advance to SSID*/
7611 ptr += nOffset;
7612
Jeff Johnson8301aa12013-03-28 14:27:29 -07007613 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08007614 pnoRequest.aNetworks[i].ssId.length);
7615 ptr += pnoRequest.aNetworks[i].ssId.length;
7616
Jeff Johnson02797792013-10-26 19:17:13 -07007617 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007618 &(pnoRequest.aNetworks[i].authentication),
7619 &(pnoRequest.aNetworks[i].encryption),
7620 &(pnoRequest.aNetworks[i].ucChannelCount),
7621 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007622
Wilson Yang623f6592013-10-08 16:33:37 -07007623 if ( 3 != ucParams )
7624 {
7625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7626 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307627 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007628 }
7629
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007631 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08007632 "auth %d encry %d channel count %d offset %d",
7633 pnoRequest.aNetworks[i].ssId.length,
7634 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
7635 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7636 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7637 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7638 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7639 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7640 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7641 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7642 pnoRequest.aNetworks[i].authentication,
7643 pnoRequest.aNetworks[i].encryption,
7644 pnoRequest.aNetworks[i].ucChannelCount,
7645 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007646
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 /*Advance to channel list*/
7648 ptr += nOffset;
7649
Wilson Yang623f6592013-10-08 16:33:37 -07007650 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 {
7652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7653 "Incorrect number of channels");
7654 return VOS_STATUS_E_FAILURE;
7655 }
7656
7657 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7658 {
7659 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7660 {
Wilson Yang623f6592013-10-08 16:33:37 -07007661 if (1 != sscanf(ptr,"%hhu %n",
7662 &(pnoRequest.aNetworks[i].aChannels[j]),
7663 &nOffset))
7664 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7665 "PNO network channel input is not valid %s",ptr);
7666 return VOS_STATUS_E_FAILURE;
7667 }
7668 /*Advance to next channel number*/
7669 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 }
7671 }
7672
Jeff Johnson02797792013-10-26 19:17:13 -07007673 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007674 &(pnoRequest.aNetworks[i].bcastNetwType),
7675 &nOffset))
7676 {
7677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7678 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307679 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007681
7682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7683 "PNO bcastNetwType %d offset %d",
7684 pnoRequest.aNetworks[i].bcastNetwType,
7685 nOffset );
7686
7687 /*Advance to rssi Threshold*/
7688 ptr += nOffset;
7689
Wilson Yang623f6592013-10-08 16:33:37 -07007690 if (1 != sscanf(ptr,"%hhu %n",
7691 &(pnoRequest.aNetworks[i].rssiThreshold),
7692 &nOffset))
7693 {
7694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7695 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307696 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007698
7699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7700 "PNO rssi %d offset %d",
7701 pnoRequest.aNetworks[i].rssiThreshold,
7702 nOffset );
7703 /*Advance to next network*/
7704 ptr += nOffset;
7705 }/*For ucNetworkCount*/
7706
7707 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007708 &(pnoRequest.scanTimers.ucScanTimersCount),
7709 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007710
7711 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007712 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 {
7714 ptr += nOffset;
7715
Jeff Johnson8301aa12013-03-28 14:27:29 -07007716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7717 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 pnoRequest.scanTimers.ucScanTimersCount,
7719 nOffset );
7720
7721 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7722 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007724 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307725 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 }
7727
7728 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7729 {
Jeff Johnson02797792013-10-26 19:17:13 -07007730 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007731 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7732 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7733 &nOffset);
7734
Wilson Yang623f6592013-10-08 16:33:37 -07007735 if (2 != ucParams)
7736 {
7737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7738 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307739 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007740 }
7741
Jeff Johnson8301aa12013-03-28 14:27:29 -07007742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7743 "PNO Timer value %d Timer repeat %d offset %d",
7744 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7746 nOffset );
7747
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 ptr += nOffset;
7749 }
7750
7751 }
7752 else
7753 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7755 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007756 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7757
7758 /*Scan timers defaults to 5 minutes*/
7759 pnoRequest.scanTimers.ucScanTimersCount = 1;
7760 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7761 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7762 }
7763
Wilson Yang623f6592013-10-08 16:33:37 -07007764 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007765
7766 pnoRequest.modePNO = ucMode;
7767 /*for LA we just expose suspend option*/
7768 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7769 {
7770 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7771 }
7772
c_hpothu37f21312014-04-09 21:49:54 +05307773 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 pAdapter->sessionId,
7775 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307776 if (eHAL_STATUS_SUCCESS == status)
7777 {
7778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7779 "%s: PNO enabled", __func__);
7780 return VOS_STATUS_SUCCESS;
7781 }
7782error:
7783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7784 "%s: Failed to enable PNO", __func__);
7785 pHddCtx->isPnoEnable = FALSE;
7786 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007787}/*iw_set_pno*/
7788
7789VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7790 union iwreq_data *wrqu, char *extra, int nOffset)
7791{
7792 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7793 v_U8_t rssiThreshold = 0;
7794 v_U8_t nRead;
7795
Arif Hussain7adce1b2013-11-11 22:59:34 -08007796 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 &rssiThreshold);
7798
7799 if ( 1 != nRead )
7800 {
7801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7802 "Incorrect format");
7803 return VOS_STATUS_E_FAILURE;
7804 }
7805
7806 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7807 return VOS_STATUS_SUCCESS;
7808}
7809
7810
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307811static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 struct iw_request_info *info,
7813 union iwreq_data *wrqu, char *extra)
7814{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007815 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7816
7817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007819
7820 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7821 {
7822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7823 "%s:LOGP in Progress. Ignore!!!", __func__);
7824 return -EBUSY;
7825 }
7826 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007827}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307828
7829static int iw_set_pno_priv(struct net_device *dev,
7830 struct iw_request_info *info,
7831 union iwreq_data *wrqu, char *extra)
7832{
7833 int ret;
7834
7835 vos_ssr_protect(__func__);
7836 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
7837 vos_ssr_unprotect(__func__);
7838
7839 return ret;
7840}
Jeff Johnson295189b2012-06-20 16:38:30 -07007841#endif /*FEATURE_WLAN_SCAN_PNO*/
7842
7843//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307844int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007845{
7846 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7847 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7848 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307849 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05307850 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307852 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307853 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
7854 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07007855
Atul Mittal54378cb2014-04-02 16:51:50 +05307856 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 {
7858 case WLAN_HDD_UI_BAND_AUTO:
7859 band = eCSR_BAND_ALL;
7860 break;
7861 case WLAN_HDD_UI_BAND_5_GHZ:
7862 band = eCSR_BAND_5G;
7863 break;
7864 case WLAN_HDD_UI_BAND_2_4_GHZ:
7865 band = eCSR_BAND_24;
7866 break;
7867 default:
7868 band = eCSR_BAND_MAX;
7869 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307870 connectedBand =
7871 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007872
Atul Mittal54378cb2014-04-02 16:51:50 +05307873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007874 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007875
7876 if (band == eCSR_BAND_MAX)
7877 {
7878 /* Received change band request with invalid band value */
7879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307880 "%s: Invalid band value %u", __func__, ui_band);
7881 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007882 }
7883
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307884 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7885 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7886 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7887 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007889 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007890 band, pHddCtx->cfg_ini->nBandCapability);
7891 return -EIO;
7892 }
7893
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7895 {
7896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7897 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007898 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 return -EIO;
7900 }
7901
7902 if (currBand != band)
7903 {
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307904 /* Return failure if current country code is world regulatory domain*/
7905 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
7906 pMac->scan.countryCodeCurrent[1] == '0') )
7907 {
7908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7909 "%s: failed to set the band value to %u as country code is 00",
7910 __func__, band);
7911 return -EAGAIN;
7912 }
7913
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 /* Change band request received.
7915 * Abort pending scan requests, flush the existing scan results,
7916 * and change the band capability
7917 */
7918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7919 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007920 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007921
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307922 /* We need to change the band and flush the scan results here itself
7923 * as we may get timeout for disconnection in which we will return
7924 * with out doing any of these
7925 */
7926 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7927 {
7928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7929 "%s: failed to set the band value to %u ",
7930 __func__, band);
7931 return -EINVAL;
7932 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307933 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
7934 {
7935 v_COUNTRYCODE_t curr_country;
7936 curr_country[0]=pMac->scan.countryCodeCurrent[0];
7937 curr_country[1]=pMac->scan.countryCodeCurrent[1];
7938
7939 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
7940 * information available in NV so to get the channel information from kernel
7941 * we need to send regulatory hint for the currunt country
7942 * And to set the same country again we need to set the dummy country
7943 * first and then the actual country.
7944 */
7945
7946#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
7947 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
7948#else
7949 regulatory_hint_user("00");
7950#endif
7951
7952 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
7953#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
7954 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
7955#else
7956 regulatory_hint_user(curr_country);
7957#endif
7958 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
7959 }
7960 else
7961 {
7962 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
7963 (void *)pHddCtx->wiphy, (eCsrBand)band);
7964 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307965 pScanInfo = &pHddCtx->scan_info;
7966 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
7967 {
7968 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
7969 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7970 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307971 sme_FilterScanResults(hHal, pAdapter->sessionId);
7972
7973 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307974 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7975 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007976 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007977 eHalStatus status = eHAL_STATUS_SUCCESS;
7978 long lrc;
7979
7980 /* STA already connected on current band, So issue disconnect first,
7981 * then change the band*/
7982
7983 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05307984 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05307985 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007986
Jeff Johnson295189b2012-06-20 16:38:30 -07007987 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7988
7989 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7990 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7991
Jeff Johnson43971f52012-07-17 12:26:56 -07007992 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 {
7994 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007995 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007996 __func__, (int)status );
7997 return -EINVAL;
7998 }
7999
8000 lrc = wait_for_completion_interruptible_timeout(
8001 &pAdapter->disconnect_comp_var,
8002 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8003
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308004 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07008005
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07008006 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008007 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07008008
8009 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
8010 }
8011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05308013 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008014}
8015
Atul Mittal54378cb2014-04-02 16:51:50 +05308016int hdd_setBand_helper(struct net_device *dev, const char *command)
8017{
8018 u8 band;
8019
8020 /*convert the band value from ascii to integer*/
8021 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
8022
8023 return hdd_setBand(dev, band);
8024
8025}
8026
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308027static int __iw_set_band_config(struct net_device *dev,
8028 struct iw_request_info *info,
8029 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008030{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008031 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05308032 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008033
Arif Hussain0273cba2014-01-07 20:58:29 -08008034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008035
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008036 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
8037 {
8038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8039 "%s:LOGP in Progress. Ignore!!!", __func__);
8040 return -EBUSY;
8041 }
8042
Atul Mittal54378cb2014-04-02 16:51:50 +05308043 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008044}
8045
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308046static int iw_set_band_config(struct net_device *dev,
8047 struct iw_request_info *info,
8048 union iwreq_data *wrqu, char *extra)
8049{
8050 int ret;
8051
8052 vos_ssr_protect(__func__);
8053 ret = __iw_set_band_config(dev, info, wrqu, extra);
8054 vos_ssr_unprotect(__func__);
8055
8056 return ret;
8057}
8058
8059static int __iw_set_power_params_priv(struct net_device *dev,
8060 struct iw_request_info *info,
8061 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008062{
Arif Hussain0273cba2014-01-07 20:58:29 -08008063 int ret;
8064 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8066 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08008067 /* ODD number is used for set, copy data using copy_from_user */
8068 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
8069 wrqu->data.length);
8070 if (NULL == ptr)
8071 {
8072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8073 "mem_alloc_copy_from_user_helper fail");
8074 return -ENOMEM;
8075 }
8076
8077 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
8078 kfree(ptr);
8079 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008080}
8081
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308082static int iw_set_power_params_priv(struct net_device *dev,
8083 struct iw_request_info *info,
8084 union iwreq_data *wrqu, char *extra)
8085{
8086 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008087
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308088 vos_ssr_protect(__func__);
8089 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
8090 vos_ssr_unprotect(__func__);
8091
8092 return ret;
8093}
Jeff Johnson295189b2012-06-20 16:38:30 -07008094
8095/*string based input*/
8096VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
8097 union iwreq_data *wrqu, char *extra, int nOffset)
8098{
8099 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8100 tSirSetPowerParamsReq powerRequest;
8101 char *ptr;
8102 v_U8_t ucType;
8103 v_U32_t uTotalSize, uValue;
8104 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8105
8106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8107 "Power Params data len %d data %s",
8108 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008109 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008110
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008111 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
8112 {
8113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8114 "%s:LOGP in Progress. Ignore!!!", __func__);
8115 return -EBUSY;
8116 }
8117
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 if (wrqu->data.length <= nOffset )
8119 {
8120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
8121 return VOS_STATUS_E_FAILURE;
8122 }
8123
8124 uTotalSize = wrqu->data.length - nOffset;
8125
8126 /*-----------------------------------------------------------------------
8127 Input is string based and expected to be like this:
8128
8129 <param_type> <param_value> <param_type> <param_value> ...
8130
8131 e.g:
8132 1 2 2 3 3 0 4 1 5 1
8133
8134 e.g. setting just a few:
8135 1 2 4 1
8136
8137 parameter types:
8138 -----------------------------
8139 1 - Ignore DTIM
8140 2 - Listen Interval
8141 3 - Broadcast Multicas Filter
8142 4 - Beacon Early Termination
8143 5 - Beacon Early Termination Interval
8144 -----------------------------------------------------------------------*/
8145 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
8146 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
8147 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
8148 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
8149 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
8150
Arif Hussain7adce1b2013-11-11 22:59:34 -08008151 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008152
8153 while ( uTotalSize )
8154 {
Wilson Yang6f971452013-10-08 15:00:00 -07008155 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
8156 {
8157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8158 "Invalid input parameter type %s",ptr);
8159 return VOS_STATUS_E_FAILURE;
8160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008161
8162 uTotalSize -= nOffset;
8163
8164 if (!uTotalSize)
8165 {
8166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08008167 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 ucType, nOffset);
8169 return VOS_STATUS_E_FAILURE;
8170 }
8171
8172 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07008173
Jeff Johnson02797792013-10-26 19:17:13 -07008174 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07008175 {
8176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8177 "Invalid input parameter value %s",ptr);
8178 return VOS_STATUS_E_FAILURE;
8179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008180
8181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8182 "Power request parameter %d value %d offset %d",
8183 ucType, uValue, nOffset);
8184
8185 switch (ucType)
8186 {
8187 case eSIR_IGNORE_DTIM:
8188 powerRequest.uIgnoreDTIM = uValue;
8189 break;
8190 case eSIR_LISTEN_INTERVAL:
8191 powerRequest.uListenInterval = uValue;
8192 break;
8193 case eSIR_MCAST_BCAST_FILTER:
8194 powerRequest.uBcastMcastFilter = uValue;
8195 break;
8196 case eSIR_ENABLE_BET:
8197 powerRequest.uEnableBET = uValue;
8198 break;
8199 case eSIR_BET_INTERVAL:
8200 powerRequest.uBETInterval = uValue;
8201 break;
8202 default:
8203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08008204 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008205 ucType, uValue, nOffset);
8206 return VOS_STATUS_E_FAILURE;
8207 }
8208
8209 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8211 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07008212 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07008214 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008215 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07008216 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
8217 {
8218 uTotalSize = 0;
8219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008220
8221 }/*Go for as long as we have a valid string*/
8222
8223 /* put the device into full power*/
8224 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
8225
8226 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08008227 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008228
8229 /* put the device back to power save*/
8230 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
8231
8232 return VOS_STATUS_SUCCESS;
8233}/*iw_set_power_params*/
8234
Atul Mittalc0f739f2014-07-31 13:47:47 +05308235// tdlsoffchan
8236#ifdef FEATURE_WLAN_TDLS
8237
Atul Mittal87ec2422014-09-24 13:12:50 +05308238int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05308239{
8240 if (offchannel < 0 || offchannel > 165)
8241 {
8242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
8243 __func__, offchannel);
8244 return -1;
8245
8246 }
8247
8248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
8249 __func__, tdlsOffCh, offchannel);
8250
8251 tdlsOffCh = offchannel;
8252 return 0;
8253}
8254
Atul Mittal87ec2422014-09-24 13:12:50 +05308255int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05308256{
8257 if (offchanoffset == 0)
8258 {
8259 tdlsOffChBwOffset = 0;
8260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8261 __func__, tdlsOffChBwOffset);
8262
8263 return 0;
8264
8265 }
8266
8267 if ( offchanoffset == 40 )
8268 {
8269 tdlsOffChBwOffset = 1;
8270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8271 __func__, tdlsOffChBwOffset);
8272
8273 return 0;
8274
8275 }
8276 if (offchanoffset == -40)
8277 {
8278 tdlsOffChBwOffset = 3;
8279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8280 __func__, tdlsOffChBwOffset);
8281
8282 return 0;
8283
8284 }
8285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
8286 __func__, offchanoffset);
8287 return -1;
8288}
8289
Atul Mittal87ec2422014-09-24 13:12:50 +05308290int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05308291{
8292 hddTdlsPeer_t *connPeer = NULL;
8293 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8294 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8295
8296 if (offchanmode < 0 || offchanmode > 4)
8297 {
8298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8299 "%s: Invalid tdls off channel mode %d",
8300 __func__, offchanmode);
8301 return -1;
8302 }
8303
8304 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8305 {
8306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8307 "%s: tdls off channel mode req in not associated state %d",
8308 __func__, offchanmode);
8309 return -1;
8310 }
8311
8312 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
8313 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
8314 {
8315 /* Send TDLS Channel Switch Request to connected peer */
8316 connPeer = wlan_hdd_tdls_get_first_connected_peer(pAdapter);
8317 if (NULL == connPeer) {
8318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8319 "%s: No TDLS Connected Peer", __func__);
8320 return -1;
8321 }
8322 }
8323 else
8324 {
8325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8326 "%s: TDLS Connection not supported", __func__);
8327 return -1;
8328 }
8329
8330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8331 ("%s: TDLS Channel Switch in swmode=%d"),
8332 __func__, offchanmode);
8333
8334 switch (offchanmode)
8335 {
8336 case 1:/*Enable*/
8337 case 2:/*Disable*/
8338 {
8339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8340 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
8341 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8342 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
8343 {
8344
8345 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
8346 pAdapter->sessionId, connPeer->peerMac,
8347 tdlsOffCh, tdlsOffChBwOffset,
8348 offchanmode);
8349 }
8350 else
8351 {
8352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8353 "%s: TDLS Off Channel not supported", __func__);
8354 return -1;
8355 }
8356 break;
8357 }
8358 case 3:
8359 {
8360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8361 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
8362 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8363
8364 break;
8365 }
8366 case 4:
8367 {
8368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8369 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
8370 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8371 break;
8372 }
8373 default:
8374 {
8375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8376 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
8377 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8378 break;
8379 }
8380
8381 }
8382
8383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
8384 __func__, offchanmode);
8385 return 0;
8386}
Atul Mittalc0f739f2014-07-31 13:47:47 +05308387#endif
8388
Jeff Johnson295189b2012-06-20 16:38:30 -07008389
8390// Define the Wireless Extensions to the Linux Network Device structure
8391// A number of these routines are NULL (meaning they are not implemented.)
8392
8393static const iw_handler we_handler[] =
8394{
8395 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
8396 (iw_handler) iw_get_name, /* SIOCGIWNAME */
8397 (iw_handler) NULL, /* SIOCSIWNWID */
8398 (iw_handler) NULL, /* SIOCGIWNWID */
8399 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
8400 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
8401 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
8402 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
8403 (iw_handler) NULL, /* SIOCSIWSENS */
8404 (iw_handler) NULL, /* SIOCGIWSENS */
8405 (iw_handler) NULL, /* SIOCSIWRANGE */
8406 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
8407 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
8408 (iw_handler) NULL, /* SIOCGIWPRIV */
8409 (iw_handler) NULL, /* SIOCSIWSTATS */
8410 (iw_handler) NULL, /* SIOCGIWSTATS */
8411 iw_handler_set_spy, /* SIOCSIWSPY */
8412 iw_handler_get_spy, /* SIOCGIWSPY */
8413 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
8414 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
8415 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
8416 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
8417 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
8418 (iw_handler) NULL, /* SIOCGIWAPLIST */
8419 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
8420 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
8421 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
8422 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
8423 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
8424 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
8425 (iw_handler) NULL, /* -- hole -- */
8426 (iw_handler) NULL, /* -- hole -- */
8427 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
8428 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
8429 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
8430 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
8431 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
8432 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
8433 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
8434 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
8435 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
8436 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
8437 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
8438 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
8439 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
8440 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
8441 (iw_handler) NULL, /* -- hole -- */
8442 (iw_handler) NULL, /* -- hole -- */
8443 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
8444 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
8445 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
8446 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
8447 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
8448 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
8449 (iw_handler) NULL, /* SIOCSIWPMKSA */
8450};
8451
8452static const iw_handler we_private[] = {
8453
8454 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
8455 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
8456 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
8457 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
8458 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
8459 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
8460 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
8461 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
8462 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
8463 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07008464#ifdef FEATURE_OEM_DATA_SUPPORT
8465 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
8466 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
8467#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008468
Jeff Johnson295189b2012-06-20 16:38:30 -07008469#ifdef WLAN_FEATURE_VOWIFI_11R
8470 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
8471#endif
8472 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
8473 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
8474 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
8475#ifdef WLAN_FEATURE_PACKET_FILTERING
8476 ,
8477 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
8478#endif
8479#ifdef FEATURE_WLAN_SCAN_PNO
8480 ,
8481 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
8482#endif
8483 ,
8484 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
8485 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
8486 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
8487 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07008488 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07008489};
8490
8491/*Maximum command length can be only 15 */
8492static const struct iw_priv_args we_private_args[] = {
8493
8494 /* handlers for main ioctl */
8495 { WLAN_PRIV_SET_INT_GET_NONE,
8496 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8497 0,
8498 "" },
8499
8500 /* handlers for sub-ioctl */
8501 { WE_SET_11D_STATE,
8502 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8503 0,
8504 "set11Dstate" },
8505
8506 { WE_WOWL,
8507 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8508 0,
8509 "wowl" },
8510
8511 { WE_SET_POWER,
8512 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8513 0,
8514 "setPower" },
8515
8516 { WE_SET_MAX_ASSOC,
8517 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8518 0,
8519 "setMaxAssoc" },
8520
8521 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
8522 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8523 0,
8524 "setAutoChannel" },
8525
8526 { WE_SET_DATA_INACTIVITY_TO,
8527 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8528 0,
8529 "inactivityTO" },
8530
8531 { WE_SET_MAX_TX_POWER,
8532 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8533 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07008534 "setMaxTxPower" },
8535
8536 { WE_SET_MAX_TX_POWER_2_4,
8537 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8538 0,
8539 "setTxMaxPower2G" },
8540
8541 { WE_SET_MAX_TX_POWER_5_0,
8542 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8543 0,
8544 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07008545
8546 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
8547 * as well to keep same syntax as in SAP. Now onwards, STA
8548 * will support both */
8549 { WE_SET_MAX_TX_POWER,
8550 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8551 0,
8552 "setTxMaxPower" },
8553
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 /* set Higher DTIM Transition (DTIM1 to DTIM3)
8555 * 1 = enable and 0 = disable */
8556 {
8557 WE_SET_HIGHER_DTIM_TRANSITION,
8558 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8559 0,
8560 "setHDtimTransn" },
8561
8562 { WE_SET_TM_LEVEL,
8563 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008564 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 "setTmLevel" },
8566
Kiet Lam46b8e4e2013-11-06 21:49:53 +05308567 { WE_ENABLE_STRICT_FCC_REG,
8568 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8569 0,
8570 "setStrictFCCreg" },
8571
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08008572 { WE_SET_DEBUG_LOG,
8573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8574 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05308575#ifdef FEATURE_WLAN_TDLS
8576 {
8577 WE_SET_TDLS_OFF_CHAN,
8578 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8579 0,
8580 "tdlsoffchan" },
8581 {
8582 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
8583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8584 0,
8585 "tdlsecchnoffst" },
8586 {
8587 WE_SET_TDLS_OFF_CHAN_MODE,
8588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8589 0,
8590 "tdlsoffchnmode" },
8591#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08008592
Peng Xu2446a892014-09-05 17:21:18 +05308593 { WE_SET_SCAN_BAND_PREFERENCE,
8594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8595 0, "set_scan_pref" },
8596
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 /* handlers for main ioctl */
8598 { WLAN_PRIV_SET_NONE_GET_INT,
8599 0,
8600 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8601 "" },
8602
8603 /* handlers for sub-ioctl */
8604 { WE_GET_11D_STATE,
8605 0,
8606 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8607 "get11Dstate" },
8608
8609 { WE_IBSS_STATUS,
8610 0,
8611 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8612 "getAdhocStatus" },
8613
8614 { WE_PMC_STATE,
8615 0,
8616 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8617 "pmcState" },
8618
8619 { WE_GET_WLAN_DBG,
8620 0,
8621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8622 "getwlandbg" },
8623
Jeff Johnson295189b2012-06-20 16:38:30 -07008624 { WE_GET_MAX_ASSOC,
8625 0,
8626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8627 "getMaxAssoc" },
8628
Jeff Johnson295189b2012-06-20 16:38:30 -07008629 { WE_GET_WDI_DBG,
8630 0,
8631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8632 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008633
8634 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
8635 0,
8636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8637 "getAutoChannel" },
8638
8639 { WE_GET_CONCURRENCY_MODE,
8640 0,
8641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8642 "getconcurrency" },
8643
Peng Xu2446a892014-09-05 17:21:18 +05308644 { WE_GET_SCAN_BAND_PREFERENCE,
8645 0,
8646 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8647 "get_scan_pref"},
8648
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 /* handlers for main ioctl */
8650 { WLAN_PRIV_SET_CHAR_GET_NONE,
8651 IW_PRIV_TYPE_CHAR| 512,
8652 0,
8653 "" },
8654
8655 /* handlers for sub-ioctl */
8656 { WE_WOWL_ADD_PTRN,
8657 IW_PRIV_TYPE_CHAR| 512,
8658 0,
8659 "wowlAddPtrn" },
8660
8661 { WE_WOWL_DEL_PTRN,
8662 IW_PRIV_TYPE_CHAR| 512,
8663 0,
8664 "wowlDelPtrn" },
8665
8666#if defined WLAN_FEATURE_VOWIFI
8667 /* handlers for sub-ioctl */
8668 { WE_NEIGHBOR_REPORT_REQUEST,
8669 IW_PRIV_TYPE_CHAR | 512,
8670 0,
8671 "neighbor" },
8672#endif
8673 { WE_SET_AP_WPS_IE,
8674 IW_PRIV_TYPE_CHAR| 512,
8675 0,
8676 "set_ap_wps_ie" },
8677
8678 { WE_SET_CONFIG,
8679 IW_PRIV_TYPE_CHAR| 512,
8680 0,
8681 "setConfig" },
8682
8683 /* handlers for main ioctl */
8684 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
8685 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8686 0,
8687 "" },
8688
8689 /* handlers for sub-ioctl */
8690 { WE_SET_WLAN_DBG,
8691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8692 0,
8693 "setwlandbg" },
8694
Jeff Johnson295189b2012-06-20 16:38:30 -07008695 { WE_SET_WDI_DBG,
8696 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8697 0,
8698 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008699
8700 { WE_SET_SAP_CHANNELS,
8701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8702 0,
8703 "setsapchannels" },
8704
8705 /* handlers for main ioctl */
8706 { WLAN_PRIV_GET_CHAR_SET_NONE,
8707 0,
8708 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8709 "" },
8710
8711 /* handlers for sub-ioctl */
8712 { WE_WLAN_VERSION,
8713 0,
8714 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8715 "version" },
8716 { WE_GET_STATS,
8717 0,
8718 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8719 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308720 { WE_GET_STATES,
8721 0,
8722 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8723 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 { WE_GET_CFG,
8725 0,
8726 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8727 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07008728#ifdef WLAN_FEATURE_11AC
8729 { WE_GET_RSSI,
8730 0,
8731 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8732 "getRSSI" },
8733#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008734#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008735 { WE_GET_ROAM_RSSI,
8736 0,
8737 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8738 "getRoamRSSI" },
8739#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 { WE_GET_WMM_STATUS,
8741 0,
8742 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8743 "getWmmStatus" },
8744 {
8745 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308746 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008747 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8748 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08008749#ifdef FEATURE_WLAN_TDLS
8750 {
8751 WE_GET_TDLS_PEERS,
8752 0,
8753 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8754 "getTdlsPeers" },
8755#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008756#ifdef WLAN_FEATURE_11W
8757 {
8758 WE_GET_11W_INFO,
8759 0,
8760 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8761 "getPMFInfo" },
8762#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05308763 { WE_GET_SNR,
8764 0,
8765 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8766 "getSNR" },
8767
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 /* handlers for main ioctl */
8769 { WLAN_PRIV_SET_NONE_GET_NONE,
8770 0,
8771 0,
8772 "" },
8773
8774 /* handlers for sub-ioctl */
8775 { WE_CLEAR_STATS,
8776 0,
8777 0,
8778 "clearStats" },
8779 { WE_INIT_AP,
8780 0,
8781 0,
8782 "initAP" },
8783 { WE_STOP_AP,
8784 0,
8785 0,
8786 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308787#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 { WE_ENABLE_AMP,
8789 0,
8790 0,
8791 "enableAMP" },
8792 { WE_DISABLE_AMP,
8793 0,
8794 0,
8795 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308796#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008797 { WE_ENABLE_DXE_STALL_DETECT,
8798 0,
8799 0,
8800 "dxeStallDetect" },
8801 { WE_DISPLAY_DXE_SNAP_SHOT,
8802 0,
8803 0,
8804 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308805 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
8806 0,
8807 0,
8808 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07008809 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05308810 WE_SET_REASSOC_TRIGGER,
8811 0,
8812 0,
8813 "reassoc" },
8814 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05308815 WE_STOP_OBSS_SCAN,
8816 0,
8817 0,
8818 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +05308819#ifdef DEBUG_ROAM_DELAY
8820 {
8821 WE_DUMP_ROAM_TIMER_LOG,
8822 0,
8823 0,
8824 "dumpRoamDelay" },
8825 {
8826 WE_RESET_ROAM_TIMER_LOG,
8827 0,
8828 0,
8829 "resetRoamDelay" },
8830#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 /* handlers for main ioctl */
8832 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
8833 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8834 0,
8835 "" },
8836
8837 /* handlers for sub-ioctl */
8838 { WE_LOG_DUMP_CMD,
8839 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8840 0,
8841 "dump" },
8842
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008843 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308844 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8845 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8846 0,
8847 "setdumplog" },
8848
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008849 { WE_MTRACE_DUMP_CMD,
8850 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8851 0,
8852 "dumplog" },
8853
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008854 /* handlers for sub ioctl */
8855 {
8856 WE_MCC_CONFIG_CREDENTIAL,
8857 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8858 0,
8859 "setMccCrdnl" },
8860
8861 /* handlers for sub ioctl */
8862 {
8863 WE_MCC_CONFIG_PARAMS,
8864 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8865 0,
8866 "setMccConfig" },
8867
Chilam NG571c65a2013-01-19 12:27:36 +05308868#ifdef FEATURE_WLAN_TDLS
8869 /* handlers for sub ioctl */
8870 {
8871 WE_TDLS_CONFIG_PARAMS,
8872 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8873 0,
8874 "setTdlsConfig" },
8875#endif
8876
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 /* handlers for main ioctl */
8878 { WLAN_PRIV_ADD_TSPEC,
8879 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8880 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8881 "addTspec" },
8882
8883 /* handlers for main ioctl */
8884 { WLAN_PRIV_DEL_TSPEC,
8885 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8886 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8887 "delTspec" },
8888
8889 /* handlers for main ioctl */
8890 { WLAN_PRIV_GET_TSPEC,
8891 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8892 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8893 "getTspec" },
8894
Jeff Johnsone7245742012-09-05 17:12:55 -07008895#ifdef FEATURE_OEM_DATA_SUPPORT
8896 /* handlers for main ioctl - OEM DATA */
8897 {
8898 WLAN_PRIV_SET_OEM_DATA_REQ,
8899 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8900 0,
8901 "set_oem_data_req" },
8902
8903 /* handlers for main ioctl - OEM DATA */
8904 {
8905 WLAN_PRIV_GET_OEM_DATA_RSP,
8906 0,
8907 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8908 "get_oem_data_rsp" },
8909#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008910
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 /* handlers for main ioctl - host offload */
8912 {
8913 WLAN_PRIV_SET_HOST_OFFLOAD,
8914 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8915 0,
8916 "setHostOffload" },
8917
8918 {
8919 WLAN_GET_WLAN_STATISTICS,
8920 0,
8921 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8922 "getWlanStats" },
8923
8924 {
8925 WLAN_SET_KEEPALIVE_PARAMS,
8926 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8927 0,
8928 "setKeepAlive" },
8929#ifdef WLAN_FEATURE_PACKET_FILTERING
8930 {
8931 WLAN_SET_PACKET_FILTER_PARAMS,
8932 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8933 0,
8934 "setPktFilter" },
8935#endif
8936#ifdef FEATURE_WLAN_SCAN_PNO
8937 {
8938 WLAN_SET_PNO,
8939 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8940 0,
8941 "setpno" },
8942#endif
8943 {
8944 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308945 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008946 0,
8947 "SETBAND" },
8948 /* handlers for dynamic MC BC ioctl */
8949 {
8950 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008951 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008952 0,
8953 "setMCBCFilter" },
8954 {
8955 WLAN_PRIV_CLEAR_MCBC_FILTER,
8956 0,
8957 0,
8958 "clearMCBCFilter" },
8959 {
8960 WLAN_SET_POWER_PARAMS,
8961 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8962 0,
8963 "setpowerparams" },
8964 {
8965 WLAN_GET_LINK_SPEED,
8966 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308967 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008968};
8969
8970
8971
8972const struct iw_handler_def we_handler_def = {
8973 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8974 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8975 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8976
8977 .standard = (iw_handler *)we_handler,
8978 .private = (iw_handler *)we_private,
8979 .private_args = we_private_args,
8980 .get_wireless_stats = get_wireless_stats,
8981};
8982
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008983int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8984{
8985 v_U32_t cmd = 288; //Command to RIVA
8986 hdd_context_t *pHddCtx = NULL;
8987 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8988 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8989 /*
8990 *configMccParam : specify the bit which needs to be modified
8991 *allowed to update based on wlan_qcom_cfg.ini
8992 * configuration
8993 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8994 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8995 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8996 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8997 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8998 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8999 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
9000 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
9001 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
9002 * Bit 9 : Reserved
9003 */
9004 switch (arg1)
9005 {
9006 //Update MCC SCHEDULE_TIME_SLICE parameter
9007 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
9008 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
9009 {
9010 if((arg2 >= 5) && (arg2 <= 20))
9011 {
9012 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9013 }
9014 else
9015 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009016 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009017 return 0;
9018 }
9019 }
9020 break;
9021
9022 //Update MCC MAX_NULL_SEND_TIME parameter
9023 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
9024 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
9025 {
9026 if((arg2 >= 1) && (arg2 <= 10))
9027 {
9028 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9029 }
9030 else
9031 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009032 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009033 return 0;
9034 }
9035 }
9036 break;
9037
9038 //Update MCC TX_EARLY_STOP_TIME parameter
9039 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
9040 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
9041 {
9042 if((arg2 >= 1) && (arg2 <= 10))
9043 {
9044 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9045 }
9046 else
9047 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009048 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009049 return 0;
9050 }
9051 }
9052 break;
9053
9054 //Update MCC RX_DRAIN_TIME parameter
9055 case MCC_RX_DRAIN_TIME_CFG_PARAM :
9056 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
9057 {
9058 if((arg2 >= 1) && (arg2 <= 10))
9059 {
9060 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9061 }
9062 else
9063 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009064 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009065 return 0;
9066 }
9067 }
9068 break;
9069
9070 //Update MCC CHANNEL_SWITCH_TIME parameter
9071 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
9072 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
9073 {
9074 if((arg2 >= 1) && (arg2 <= 20))
9075 {
9076 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9077 }
9078 else
9079 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009080 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009081 return 0;
9082 }
9083 }
9084 break;
9085
9086 //Update MCC MIN_CHANNEL_TIME parameter
9087 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
9088 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
9089 {
9090 if((arg2 >= 5) && (arg2 <= 20))
9091 {
9092 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9093 }
9094 else
9095 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009096 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009097 return 0;
9098 }
9099 }
9100 break;
9101
9102 //Update MCC PARK_BEFORE_TBTT parameter
9103 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
9104 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
9105 {
9106 if((arg2 >= 1) && (arg2 <= 5))
9107 {
9108 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9109 }
9110 else
9111 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009112 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009113 return 0;
9114 }
9115 }
9116 break;
9117
9118 //Update MCC MIN_AFTER_DTIM parameter
9119 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
9120 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
9121 {
9122 if((arg2 >= 5) && (arg2 <= 15))
9123 {
9124 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9125 }
9126 else
9127 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009128 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009129 return 0;
9130 }
9131 }
9132 break;
9133
9134 //Update MCC TOO_CLOSE_MARGIN parameter
9135 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
9136 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
9137 {
9138 if((arg2 >= 1) && (arg2 <= 3))
9139 {
9140 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9141 }
9142 else
9143 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009144 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009145 return 0;
9146 }
9147 }
9148 break;
9149
9150 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009151 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009152 __FUNCTION__,arg1);
9153 break;
9154 }
9155 return 0;
9156}
9157
Jeff Johnson295189b2012-06-20 16:38:30 -07009158int hdd_set_wext(hdd_adapter_t *pAdapter)
9159{
9160 hdd_wext_state_t *pwextBuf;
9161 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009162 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009163
9164 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9165
9166 // Now configure the roaming profile links. To SSID and bssid.
9167 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
9168 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
9169
9170 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
9171 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
9172
9173 /*Set the numOfChannels to zero to scan all the channels*/
9174 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
9175 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
9176
9177 /* Default is no encryption */
9178 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
9179 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
9180
9181 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
9182 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
9183
9184 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
9185
9186 /* Default is no authentication */
9187 pwextBuf->roamProfile.AuthType.numEntries = 1;
9188 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
9189
9190 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
9191 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
9192
9193 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009194 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009195
9196 hdd_clearRoamProfileIe(pAdapter);
9197
9198 return VOS_STATUS_SUCCESS;
9199
9200 }
9201
9202int hdd_register_wext(struct net_device *dev)
9203 {
9204 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9205 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9206 VOS_STATUS status;
9207
9208 ENTER();
9209
9210 // Zero the memory. This zeros the profile structure.
9211 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
9212
9213 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
9214
9215
9216 status = hdd_set_wext(pAdapter);
9217
9218 if(!VOS_IS_STATUS_SUCCESS(status)) {
9219
Arif Hussain6d2a3322013-11-17 19:50:10 -08009220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 return eHAL_STATUS_FAILURE;
9222 }
9223
9224 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
9225 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 return eHAL_STATUS_FAILURE;
9228 }
9229
9230 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
9231 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009233 return eHAL_STATUS_FAILURE;
9234 }
9235
9236 // Register as a wireless device
9237 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
9238
9239 EXIT();
9240 return 0;
9241}
9242
9243int hdd_UnregisterWext(struct net_device *dev)
9244{
9245#if 0
9246 hdd_wext_state_t *wextBuf;
9247 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9248
9249 ENTER();
9250 // Set up the pointer to the Wireless Extensions state structure
9251 wextBuf = pAdapter->pWextState;
9252
9253 // De-allocate the Wireless Extensions state structure
9254 kfree(wextBuf);
9255
9256 // Clear out the pointer to the Wireless Extensions state structure
9257 pAdapter->pWextState = NULL;
9258
9259 EXIT();
9260#endif
c_hpothu5f0b6eb2014-09-15 13:36:50 +05309261
9262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s", __func__);
9263 rtnl_lock();
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 dev->wireless_handlers = NULL;
c_hpothu5f0b6eb2014-09-15 13:36:50 +05309265 rtnl_unlock();
9266
Jeff Johnson295189b2012-06-20 16:38:30 -07009267 return 0;
9268}
9269
9270