blob: 1a85c2adce222dbef63320f7180f7fee45f025ce [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"
85#include <vos_power.h>
86#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#ifdef DEBUG_ROAM_DELAY
107#include "vos_utils.h"
108#endif
109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#ifdef CONFIG_HAS_EARLYSUSPEND
111extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
112extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
113#endif
114
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800116#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
119#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530120#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123// tdlsoffchan
124#ifdef FEATURE_WLAN_TDLS
125static int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel);
126static int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset);
127static int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode);
128static int tdlsOffCh = 1;
129static int tdlsOffChBwOffset = 0;
130#endif
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700131static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
133
Jeff Johnson295189b2012-06-20 16:38:30 -0700134/* To Validate Channel against the Frequency and Vice-Versa */
135static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
136 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
137 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
138 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
139 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
140 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
141 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
142 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800143 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
144 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800146#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700147
148/* Private ioctls and their sub-ioctls */
149#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
150#define WE_SET_11D_STATE 1
151#define WE_WOWL 2
152#define WE_SET_POWER 3
153#define WE_SET_MAX_ASSOC 4
154#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
155#define WE_SET_DATA_INACTIVITY_TO 6
156#define WE_SET_MAX_TX_POWER 7
157#define WE_SET_HIGHER_DTIM_TRANSITION 8
158#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530159#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700160#define WE_SET_MAX_TX_POWER_2_4 11
161#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800162/* Private IOCTL for debug connection issues */
163#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530164// tdlsoffchan
165#ifdef FEATURE_WLAN_TDLS
166#define WE_SET_TDLS_OFF_CHAN 14
167#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
168#define WE_SET_TDLS_OFF_CHAN_MODE 16
169#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700170
171/* Private ioctls and their sub-ioctls */
172#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
173#define WE_GET_11D_STATE 1
174#define WE_IBSS_STATUS 2
175#define WE_PMC_STATE 3
176#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700177#define WE_GET_MAX_ASSOC 6
178#define WE_GET_WDI_DBG 7
179#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
180#define WE_GET_CONCURRENCY_MODE 9
181/* Private ioctls and their sub-ioctls */
182#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
183
184/* Private ioctls and their sub-ioctls */
185#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
186#define WE_WOWL_ADD_PTRN 1
187#define WE_WOWL_DEL_PTRN 2
188#if defined WLAN_FEATURE_VOWIFI
189#define WE_NEIGHBOR_REPORT_REQUEST 3
190#endif
191#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
192#define WE_SET_CONFIG 5
193
194/* Private ioctls and their sub-ioctls */
195#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
196#define WE_SET_WLAN_DBG 1
197#define WE_SET_WDI_DBG 2
198#define WE_SET_SAP_CHANNELS 3
199
200/* Private ioctls and their sub-ioctls */
201#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
202#define WE_WLAN_VERSION 1
203#define WE_GET_STATS 2
204#define WE_GET_CFG 3
205#define WE_GET_WMM_STATUS 4
206#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700207#ifdef WLAN_FEATURE_11AC
208#define WE_GET_RSSI 6
209#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800210#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800211#ifdef FEATURE_WLAN_TDLS
212#define WE_GET_TDLS_PEERS 8
213#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700214#ifdef WLAN_FEATURE_11W
215#define WE_GET_11W_INFO 9
216#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530217#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530218#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700219
220/* Private ioctls and their sub-ioctls */
221#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
222#define WE_CLEAR_STATS 1
223#define WE_INIT_AP 2
224#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530225#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700226#define WE_ENABLE_AMP 4
227#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530228#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700229#define WE_ENABLE_DXE_STALL_DETECT 6
230#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700231#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530232#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530233#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700234
Mukul Sharma84f27252014-07-14 18:11:42 +0530235#ifdef DEBUG_ROAM_DELAY
236#define WE_DUMP_ROAM_TIMER_LOG 12
237#define WE_RESET_ROAM_TIMER_LOG 13
238#endif
239
Jeff Johnson295189b2012-06-20 16:38:30 -0700240/* Private ioctls and their sub-ioctls */
241#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
242#define WE_LOG_DUMP_CMD 1
243
Jeff Johnson295189b2012-06-20 16:38:30 -0700244#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800245//IOCTL to configure MCC params
246#define WE_MCC_CONFIG_CREDENTIAL 3
247#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
Chilam NG571c65a2013-01-19 12:27:36 +0530249#ifdef FEATURE_WLAN_TDLS
250#define WE_TDLS_CONFIG_PARAMS 5
251#endif
252
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700253#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530254#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700255
Chilam Ng01120412013-02-19 18:32:21 -0800256#ifdef FEATURE_WLAN_TDLS
257#undef MAX_VAR_ARGS
258#define MAX_VAR_ARGS 10
259#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700260#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800261#endif
262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263/* Private ioctls (with no sub-ioctls) */
264/* note that they must be odd so that they have "get" semantics */
265#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
266#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
267#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
268
Girish Gowli464c9c82014-06-09 19:47:53 +0530269/* (SIOCIWFIRSTPRIV + 8) is currently unused */
270/* (SIOCIWFIRSTPRIV + 16) is currently unused */
271/* (SIOCIWFIRSTPRIV + 10) is currently unused */
272/* (SIOCIWFIRSTPRIV + 12) is currently unused */
273/* (SIOCIWFIRSTPRIV + 14) is currently unused */
274/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700275
Jeff Johnsone7245742012-09-05 17:12:55 -0700276#ifdef FEATURE_OEM_DATA_SUPPORT
277/* Private ioctls for setting the measurement configuration */
278#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
279#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
280#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700281
282#ifdef WLAN_FEATURE_VOWIFI_11R
283#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
284#endif
285
286/* Private ioctl for setting the host offload feature */
287#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
288
289/* Private ioctl to get the statistics */
290#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
291
292/* Private ioctl to set the Keep Alive Params */
293#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
294#ifdef WLAN_FEATURE_PACKET_FILTERING
295/* Private ioctl to set the Packet Filtering Params */
296#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
297#endif
298
299#ifdef FEATURE_WLAN_SCAN_PNO
300/* Private ioctl to get the statistics */
301#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
302#endif
303
304#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
305
306#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
307#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700308/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700309
Jeff Johnson295189b2012-06-20 16:38:30 -0700310#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
311#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
312
313#define WLAN_STATS_INVALID 0
314#define WLAN_STATS_RETRY_CNT 1
315#define WLAN_STATS_MUL_RETRY_CNT 2
316#define WLAN_STATS_TX_FRM_CNT 3
317#define WLAN_STATS_RX_FRM_CNT 4
318#define WLAN_STATS_FRM_DUP_CNT 5
319#define WLAN_STATS_FAIL_CNT 6
320#define WLAN_STATS_RTS_FAIL_CNT 7
321#define WLAN_STATS_ACK_FAIL_CNT 8
322#define WLAN_STATS_RTS_SUC_CNT 9
323#define WLAN_STATS_RX_DISCARD_CNT 10
324#define WLAN_STATS_RX_ERROR_CNT 11
325#define WLAN_STATS_TX_BYTE_CNT 12
326
327#define WLAN_STATS_RX_BYTE_CNT 13
328#define WLAN_STATS_RX_RATE 14
329#define WLAN_STATS_TX_RATE 15
330
Jeff Johnsone7245742012-09-05 17:12:55 -0700331#define WLAN_STATS_RX_UC_BYTE_CNT 16
332#define WLAN_STATS_RX_MC_BYTE_CNT 17
333#define WLAN_STATS_RX_BC_BYTE_CNT 18
334#define WLAN_STATS_TX_UC_BYTE_CNT 19
335#define WLAN_STATS_TX_MC_BYTE_CNT 20
336#define WLAN_STATS_TX_BC_BYTE_CNT 21
337
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800338#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
339 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
340 { \
341 *__p++ = __type; \
342 *__p++ = __size; \
343 memcpy(__p, __val, __size); \
344 __p += __size; \
345 __tlen += __size + 2; \
346 } \
347 else \
348 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800349 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800350 } \
351 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352
353#define VERSION_VALUE_MAX_LEN 32
354
355#define TX_PER_TRACKING_DEFAULT_RATIO 5
356#define TX_PER_TRACKING_MAX_RATIO 10
357#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
358
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530359#define WLAN_ADAPTER 0
360#define P2P_ADAPTER 1
361
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530362/*
363 * When supplicant sends SETBAND ioctl it queries for channels from
364 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
365 * This is not required if the return type from ioctl is
366 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
367 * event as part of regulatory_hint.
368 */
369enum {
370 SEND_CHANNEL_CHANGE_EVENT = 0,
371 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
372};
373
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800374/*MCC Configuration parameters */
375enum {
376 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
377 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
378 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
379 MCC_RX_DRAIN_TIME_CFG_PARAM,
380 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
381 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
382 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
383 MCC_MIN_AFTER_DTIM_CFG_PARAM,
384 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
385};
386
387int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
388 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
389
Jeff Johnson295189b2012-06-20 16:38:30 -0700390#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800391int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700392 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700393#endif
394
Jeff Johnson295189b2012-06-20 16:38:30 -0700395/**---------------------------------------------------------------------------
396
Arif Hussain0273cba2014-01-07 20:58:29 -0800397 \brief mem_alloc_copy_from_user_helper -
398
399 Helper function to allocate buffer and copy user data.
400
401 \param - wrqu - Pointer to IOCTL Data.
402 len - size
403
404 \return - On Success pointer to buffer, On failure NULL
405
406 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530407void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800408{
409 u8 *ptr = NULL;
410
411 /* in order to protect the code, an extra byte is post appended to the buffer
412 * and the null termination is added. However, when allocating (len+1) byte
413 * of memory, we need to make sure that there is no uint overflow when doing
414 * addition. In theory check len < UINT_MAX protects the uint overflow. For
415 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
416 * guess, now, it is assumed that the private command buffer size is no
417 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
418 */
419 if (len > MAX_USER_COMMAND_SIZE)
420 {
421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
422 "Invalid length");
423 return NULL;
424 }
425
426 ptr = kmalloc(len + 1, GFP_KERNEL);
427 if (NULL == ptr)
428 {
429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
430 "unable to allocate memory");
431 return NULL;
432 }
433
434 if (copy_from_user(ptr, wrqu_data, len))
435 {
436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
437 "%s: failed to copy data to user buffer", __func__);
438 kfree(ptr);
439 return NULL;
440 }
441 ptr[len] = '\0';
442 return ptr;
443}
444
Girish Gowli488ef492014-06-12 18:44:33 +0530445// Function to handle and get compatible struct iw_point passed to ioctl.
446int hdd_priv_get_data(struct iw_point *p_priv_data,
447 union iwreq_data *wrqu)
448{
449 if ((NULL == p_priv_data) || (NULL == wrqu))
450 {
451 return -EINVAL;
452 }
453
454#ifdef CONFIG_COMPAT
455 if (is_compat_task())
456 {
457 struct compat_iw_point *p_compat_priv_data;
458
459 // Compat task: typecast to campat structure and copy the members.
460 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
461
462 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
463 p_priv_data->length = p_compat_priv_data->length;
464 p_priv_data->flags = p_compat_priv_data->flags;
465 }//if(is_compat_task())
466 else
467 {
468#endif //#ifdef CONFIG_COMPAT
469
470 // Non compat task: directly copy the structure.
471 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
472
473#ifdef CONFIG_COMPAT
474 }//else of - if(is_compat_task())
475#endif //#ifdef CONFIG_COMPAT
476
477 return 0;
478}
479
Arif Hussain0273cba2014-01-07 20:58:29 -0800480/**---------------------------------------------------------------------------
481
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 \brief hdd_wlan_get_version() -
483
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800484 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700485
486 \param - pAdapter Pointer to the adapter.
487 wrqu - Pointer to IOCTL REQUEST Data.
488 extra - Pointer to char
489
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800490 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700491
492 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800493void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
494 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700495{
496 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800497 tSirVersionString wcnss_SW_version;
498 tSirVersionString wcnss_HW_version;
499 char *pSWversion;
500 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800503 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
504 sizeof(wcnss_SW_version));
505 if (VOS_IS_STATUS_SUCCESS(status))
506 {
507 pSWversion = wcnss_SW_version;
508 }
509 else
510 {
511 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 }
513
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800514 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
515 sizeof(wcnss_HW_version));
516 if (VOS_IS_STATUS_SUCCESS(status))
517 {
518 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800520 else
521 {
522 pHWversion = "Unknown";
523 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700524
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700525 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800526 "Host SW:%s, FW:%s, HW:%s",
527 QWLAN_VERSIONSTR,
528 pSWversion,
529 pHWversion);
530
531 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700532}
533
Jeff Johnson295189b2012-06-20 16:38:30 -0700534int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
535{
536 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
537 v_U32_t threshold = 0,status = 0;
538
539 ENTER();
540
Agarwal Ashish971c2882013-10-30 20:11:12 +0530541 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
542 {
543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 "%s:LOGP in Progress. Ignore!!!",__func__);
545 return status;
546 }
547
548 if ( eHAL_STATUS_SUCCESS !=
549 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
550 {
c_hpothub8245442013-11-20 23:41:09 +0530551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
552 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 return -EIO;
554 }
555 wrqu->rts.value = threshold;
556
557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800558 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700559
560 EXIT();
561
562 return 0;
563}
564
565int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
566{
567 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
568 v_U32_t threshold = 0,status = 0;
569
570 ENTER();
571
Agarwal Ashish971c2882013-10-30 20:11:12 +0530572 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
573 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
575 "%s:LOGP in Progress. Ignore!!!",__func__);
576 return status;
577 }
578
579 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
580 != eHAL_STATUS_SUCCESS )
581 {
c_hpothub8245442013-11-20 23:41:09 +0530582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
583 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 return -EIO;
585 }
586 wrqu->frag.value = threshold;
587
588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800589 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700590
591 EXIT();
592
593 return 0;
594}
595
596int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
597{
Jeff Johnsone7245742012-09-05 17:12:55 -0700598 int i;
599 if (channel > 0)
600 {
601 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
602 {
603 if (channel == freq_chan_map[i].chan)
604 {
605 *pfreq = freq_chan_map[i].freq;
606 return 1;
607 }
608 }
609 }
610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800611 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700612 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700613}
614
615static v_BOOL_t
616hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
617{
618 v_BOOL_t rsnType = VOS_FALSE;
619 // is the authType supported?
620 switch (authType)
621 {
622 case eCSR_AUTH_TYPE_NONE: //never used
623 rsnType = eANI_BOOLEAN_FALSE;
624 break;
625 // MAC layer authentication types
626 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
627 rsnType = eANI_BOOLEAN_FALSE;
628 break;
629 case eCSR_AUTH_TYPE_SHARED_KEY:
630 rsnType = eANI_BOOLEAN_FALSE;
631 break;
632 case eCSR_AUTH_TYPE_AUTOSWITCH:
633 rsnType = eANI_BOOLEAN_FALSE;
634 break;
635
636 // Upper layer authentication types
637 case eCSR_AUTH_TYPE_WPA:
638 rsnType = eANI_BOOLEAN_TRUE;
639 break;
640 case eCSR_AUTH_TYPE_WPA_PSK:
641 rsnType = eANI_BOOLEAN_TRUE;
642 break;
643 case eCSR_AUTH_TYPE_WPA_NONE:
644 rsnType = eANI_BOOLEAN_TRUE;
645 break;
646#ifdef WLAN_FEATURE_VOWIFI_11R
647 case eCSR_AUTH_TYPE_FT_RSN:
648#endif
649 case eCSR_AUTH_TYPE_RSN:
650 rsnType = eANI_BOOLEAN_TRUE;
651 break;
652#ifdef WLAN_FEATURE_VOWIFI_11R
653 case eCSR_AUTH_TYPE_FT_RSN_PSK:
654#endif
655 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700656#ifdef WLAN_FEATURE_11W
657 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
658#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 rsnType = eANI_BOOLEAN_TRUE;
660 break;
661 //case eCSR_AUTH_TYPE_FAILED:
662 case eCSR_AUTH_TYPE_UNKNOWN:
663 rsnType = eANI_BOOLEAN_FALSE;
664 break;
665 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800666 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
667 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 rsnType = eANI_BOOLEAN_FALSE;
669 break;
670 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800671 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700672 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 return rsnType;
674}
675
676static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
677{
678 struct statsContext *pStatsContext;
679 hdd_adapter_t *pAdapter;
680
681 if (ioctl_debug)
682 {
683 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700684 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 }
686
687 if (NULL == pContext)
688 {
689 hddLog(VOS_TRACE_LEVEL_ERROR,
690 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700691 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 return;
693 }
694
Jeff Johnson295189b2012-06-20 16:38:30 -0700695 pStatsContext = pContext;
696 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800697
698 /* there is a race condition that exists between this callback
699 function and the caller since the caller could time out either
700 before or while this code is executing. we use a spinlock to
701 serialize these actions */
702 spin_lock(&hdd_context_lock);
703
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
705 {
706 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800707 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 hddLog(VOS_TRACE_LEVEL_WARN,
709 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700710 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 if (ioctl_debug)
712 {
713 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700714 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 }
716 return;
717 }
718
Jeff Johnson72a40512013-12-19 10:14:15 -0800719 /* context is valid so caller is still waiting */
720
721 /* paranoia: invalidate the magic */
722 pStatsContext->magic = 0;
723
724 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 pAdapter->rssi = rssi;
726
Jeff Johnson72a40512013-12-19 10:14:15 -0800727 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700728 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800729
730 /* serialization is complete */
731 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700732}
733
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530734static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
735{
736 struct statsContext *pStatsContext;
737 hdd_adapter_t *pAdapter;
738
739 if (ioctl_debug)
740 {
741 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
742 __func__, (int)snr, (int)staId, pContext);
743 }
744
745 if (NULL == pContext)
746 {
747 hddLog(VOS_TRACE_LEVEL_ERROR,
748 "%s: Bad param, pContext [%p]",
749 __func__, pContext);
750 return;
751 }
752
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530753 pStatsContext = pContext;
754 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800755
756 /* there is a race condition that exists between this callback
757 function and the caller since the caller could time out either
758 before or while this code is executing. we use a spinlock to
759 serialize these actions */
760 spin_lock(&hdd_context_lock);
761
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530762 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
763 {
764 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800765 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530766 hddLog(VOS_TRACE_LEVEL_WARN,
767 "%s: Invalid context, pAdapter [%p] magic [%08x]",
768 __func__, pAdapter, pStatsContext->magic);
769 if (ioctl_debug)
770 {
771 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
772 __func__, pAdapter, pStatsContext->magic);
773 }
774 return;
775 }
776
Jeff Johnson72a40512013-12-19 10:14:15 -0800777 /* context is valid so caller is still waiting */
778
779 /* paranoia: invalidate the magic */
780 pStatsContext->magic = 0;
781
782 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530783 pAdapter->snr = snr;
784
Jeff Johnson72a40512013-12-19 10:14:15 -0800785 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530786 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800787
788 /* serialization is complete */
789 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530790}
791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
793{
794 struct statsContext context;
795 hdd_context_t *pHddCtx;
796 hdd_station_ctx_t *pHddStaCtx;
797 eHalStatus hstatus;
798 long lrc;
799
800 if (NULL == pAdapter)
801 {
802 hddLog(VOS_TRACE_LEVEL_WARN,
803 "%s: Invalid context, pAdapter", __func__);
804 return VOS_STATUS_E_FAULT;
805 }
806 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
807 {
808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
809 /* return a cached value */
810 *rssi_value = pAdapter->rssi;
811 return VOS_STATUS_SUCCESS;
812 }
813
814 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
815 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
816
817 init_completion(&context.completion);
818 context.pAdapter = pAdapter;
819 context.magic = RSSI_CONTEXT_MAGIC;
820
821 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
822 pHddStaCtx->conn_info.staId[ 0 ],
823 pHddStaCtx->conn_info.bssId,
824 &context, pHddCtx->pvosContext);
825 if (eHAL_STATUS_SUCCESS != hstatus)
826 {
827 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700828 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 /* we'll returned a cached value below */
830 }
831 else
832 {
833 /* request was sent -- wait for the response */
834 lrc = wait_for_completion_interruptible_timeout(&context.completion,
835 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 if (lrc <= 0)
837 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800838 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700839 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 /* we'll now returned a cached value below */
841 }
842 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800843
844 /* either we never sent a request, we sent a request and received a
845 response or we sent a request and timed out. if we never sent a
846 request or if we sent a request and got a response, we want to
847 clear the magic out of paranoia. if we timed out there is a
848 race condition such that the callback function could be
849 executing at the same time we are. of primary concern is if the
850 callback function had already verified the "magic" but had not
851 yet set the completion variable when a timeout occurred. we
852 serialize these activities by invalidating the magic while
853 holding a shared spinlock which will cause us to block if the
854 callback is currently executing */
855 spin_lock(&hdd_context_lock);
856 context.magic = 0;
857 spin_unlock(&hdd_context_lock);
858
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 *rssi_value = pAdapter->rssi;
860
861 return VOS_STATUS_SUCCESS;
862}
863
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530864VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
865{
866 struct statsContext context;
867 hdd_context_t *pHddCtx;
868 hdd_station_ctx_t *pHddStaCtx;
869 eHalStatus hstatus;
870 long lrc;
871 int valid;
872
873 if (NULL == pAdapter)
874 {
875 hddLog(VOS_TRACE_LEVEL_ERROR,
876 "%s: Invalid context, pAdapter", __func__);
877 return VOS_STATUS_E_FAULT;
878 }
879
880 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
881
882 valid = wlan_hdd_validate_context(pHddCtx);
883 if (0 != valid)
884 {
885 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
886 return VOS_STATUS_E_FAULT;
887 }
888
889 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
890 if (NULL == pHddStaCtx)
891 {
892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
893 return VOS_STATUS_E_FAULT;
894 }
895
896 init_completion(&context.completion);
897 context.pAdapter = pAdapter;
898 context.magic = SNR_CONTEXT_MAGIC;
899
900 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
901 pHddStaCtx->conn_info.staId[ 0 ],
902 pHddStaCtx->conn_info.bssId,
903 &context);
904 if (eHAL_STATUS_SUCCESS != hstatus)
905 {
906 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
907 __func__);
908 /* we'll returned a cached value below */
909 }
910 else
911 {
912 /* request was sent -- wait for the response */
913 lrc = wait_for_completion_interruptible_timeout(&context.completion,
914 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530915 if (lrc <= 0)
916 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800917 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530918 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530919 /* we'll now returned a cached value below */
920 }
921 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800922
923 /* either we never sent a request, we sent a request and received a
924 response or we sent a request and timed out. if we never sent a
925 request or if we sent a request and got a response, we want to
926 clear the magic out of paranoia. if we timed out there is a
927 race condition such that the callback function could be
928 executing at the same time we are. of primary concern is if the
929 callback function had already verified the "magic" but had not
930 yet set the completion variable when a timeout occurred. we
931 serialize these activities by invalidating the magic while
932 holding a shared spinlock which will cause us to block if the
933 callback is currently executing */
934 spin_lock(&hdd_context_lock);
935 context.magic = 0;
936 spin_unlock(&hdd_context_lock);
937
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530938 *snr = pAdapter->snr;
939
940 return VOS_STATUS_SUCCESS;
941}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800942#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800943
944static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
945{
946 struct statsContext *pStatsContext;
947 hdd_adapter_t *pAdapter;
948 if (ioctl_debug)
949 {
950 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
951 __func__, (int)rssi, (int)staId, pContext);
952 }
953
954 if (NULL == pContext)
955 {
956 hddLog(VOS_TRACE_LEVEL_ERROR,
957 "%s: Bad param, pContext [%p]",
958 __func__, pContext);
959 return;
960 }
961
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800962 pStatsContext = pContext;
963 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800964
965 /* there is a race condition that exists between this callback
966 function and the caller since the caller could time out either
967 before or while this code is executing. we use a spinlock to
968 serialize these actions */
969 spin_lock(&hdd_context_lock);
970
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800971 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
972 {
973 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800974 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800975 hddLog(VOS_TRACE_LEVEL_WARN,
976 "%s: Invalid context, pAdapter [%p] magic [%08x]",
977 __func__, pAdapter, pStatsContext->magic);
978 if (ioctl_debug)
979 {
980 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
981 __func__, pAdapter, pStatsContext->magic);
982 }
983 return;
984 }
985
Jeff Johnson72a40512013-12-19 10:14:15 -0800986 /* context is valid so caller is still waiting */
987
988 /* paranoia: invalidate the magic */
989 pStatsContext->magic = 0;
990
991 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800992 pAdapter->rssi = rssi;
993
Jeff Johnson72a40512013-12-19 10:14:15 -0800994 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800995 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800996
997 /* serialization is complete */
998 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800999}
1000
1001
1002
1003VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1004{
1005 struct statsContext context;
1006 hdd_context_t *pHddCtx = NULL;
1007 hdd_station_ctx_t *pHddStaCtx = NULL;
1008 eHalStatus hstatus;
1009 long lrc;
1010
1011 if (NULL == pAdapter)
1012 {
1013 hddLog(VOS_TRACE_LEVEL_WARN,
1014 "%s: Invalid context, pAdapter", __func__);
1015 return VOS_STATUS_E_FAULT;
1016 }
1017 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1018 {
1019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1020 /* return a cached value */
1021 *rssi_value = pAdapter->rssi;
1022 return VOS_STATUS_SUCCESS;
1023 }
1024
1025 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1026 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1027
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301028 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001029 {
1030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1031 /* return a cached value */
1032 *rssi_value = 0;
1033 return VOS_STATUS_SUCCESS;
1034 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301035
1036 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1037 {
1038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1039 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1040 *rssi_value = pAdapter->rssi;
1041 return VOS_STATUS_SUCCESS;
1042 }
1043
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001044 init_completion(&context.completion);
1045 context.pAdapter = pAdapter;
1046 context.magic = RSSI_CONTEXT_MAGIC;
1047
1048 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1049 pHddStaCtx->conn_info.staId[ 0 ],
1050 pHddStaCtx->conn_info.bssId,
1051 &context, pHddCtx->pvosContext);
1052 if (eHAL_STATUS_SUCCESS != hstatus)
1053 {
1054 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1055 __func__);
1056 /* we'll returned a cached value below */
1057 }
1058 else
1059 {
1060 /* request was sent -- wait for the response */
1061 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1062 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001063 if (lrc <= 0)
1064 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001065 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001066 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001067 /* we'll now returned a cached value below */
1068 }
1069 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001070
1071 /* either we never sent a request, we sent a request and received a
1072 response or we sent a request and timed out. if we never sent a
1073 request or if we sent a request and got a response, we want to
1074 clear the magic out of paranoia. if we timed out there is a
1075 race condition such that the callback function could be
1076 executing at the same time we are. of primary concern is if the
1077 callback function had already verified the "magic" but had not
1078 yet set the completion variable when a timeout occurred. we
1079 serialize these activities by invalidating the magic while
1080 holding a shared spinlock which will cause us to block if the
1081 callback is currently executing */
1082 spin_lock(&hdd_context_lock);
1083 context.magic = 0;
1084 spin_unlock(&hdd_context_lock);
1085
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001086 *rssi_value = pAdapter->rssi;
1087
1088 return VOS_STATUS_SUCCESS;
1089}
1090#endif
1091
1092
Jeff Johnson295189b2012-06-20 16:38:30 -07001093void hdd_StatisticsCB( void *pStats, void *pContext )
1094{
1095 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1096 hdd_stats_t *pStatsCache = NULL;
1097 hdd_wext_state_t *pWextState;
1098 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1099
1100 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1101 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1102 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1103 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1104 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1105 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1106
1107 if (pAdapter!= NULL)
1108 pStatsCache = &pAdapter->hdd_stats;
1109
1110
1111 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1112 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1113 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1114 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1115 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1116 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1117
1118 if (pStatsCache!=NULL)
1119 {
1120 // and copy the stats into the cache we keep in the adapter instance structure
1121 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1122 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1123 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1124 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1125 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1126 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1127 }
1128
1129 if(pAdapter)
1130 {
1131 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1132 if(pWextState)
1133 {
1134 vos_status = vos_event_set(&pWextState->vosevent);
1135 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1136 {
1137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001138 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 return;
1140 }
1141 }
1142 }
1143}
1144
1145void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1146{
1147 v_CONTEXT_t pVosContext;
1148 hdd_context_t *pHddCtx;
1149 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1150#if 0
1151 hdd_wext_state_t *pWextState;
1152 v_U32_t roamId;
1153#endif
1154
1155 ENTER();
1156
1157 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1158
1159 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1160 if (NULL == pHddCtx)
1161 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001162 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 return;
1164 }
1165#if 0
1166 pWextState = pAdapter->pWextState;
1167#endif
1168
1169 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1170 {
1171 //TODO Verify is this is really used. If yes need to fix it.
1172 hdd_reconnect_all_adapters( pHddCtx );
1173#if 0
1174 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1175 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1176 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1177
1178 if(VOS_STATUS_SUCCESS == vosStatus)
1179 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1180 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1181
1182 sme_RoamConnect(halHandle,
1183 pAdapter->sessionId, &(pWextState->roamProfile),
1184 &roamId);
1185#endif
1186 }
1187
1188 EXIT();
1189
1190}
1191
1192void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1193{
1194 int i = 0;
1195 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1196
1197 /* clear WPA/RSN/WSC IE information in the profile */
1198 pWextState->roamProfile.nWPAReqIELength = 0;
1199 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1200 pWextState->roamProfile.nRSNReqIELength = 0;
1201 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1202
Chet Lanctot186b5732013-03-18 10:26:30 -07001203#ifdef FEATURE_WLAN_WAPI
1204 pWextState->roamProfile.nWAPIReqIELength = 0;
1205 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1206#endif
1207
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001209 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301211 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1213 pWextState->roamProfile.nAddIEAssocLength = 0;
1214
1215 pWextState->roamProfile.EncryptionType.numEntries = 1;
1216 pWextState->roamProfile.EncryptionType.encryptionType[0]
1217 = eCSR_ENCRYPT_TYPE_NONE;
1218
1219 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1220 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1221 = eCSR_ENCRYPT_TYPE_NONE;
1222
1223 pWextState->roamProfile.AuthType.numEntries = 1;
1224 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1225
Chet Lanctot186b5732013-03-18 10:26:30 -07001226#ifdef WLAN_FEATURE_11W
1227 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1228 pWextState->roamProfile.MFPRequired = 0;
1229 pWextState->roamProfile.MFPCapable = 0;
1230#endif
1231
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 pWextState->authKeyMgmt = 0;
1233
1234 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1235 {
1236 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1237 {
1238 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1239 }
1240 }
1241#ifdef FEATURE_WLAN_WAPI
1242 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1243 pAdapter->wapi_info.nWapiMode = 0;
1244#endif
1245
1246 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1247
1248}
1249
1250void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1251{
1252 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001253
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001254 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1255 {
1256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1257 "%s: Invalid pAdapter magic", __func__);
1258 }
1259 else
1260 {
1261 complete(&pAdapter->ula_complete);
1262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001263}
1264
1265VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1266{
1267 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001269 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001270
1271 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1272 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001273 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001274
1275 /*To avoid race condition between the set key and the last EAPOL
1276 packet, notify TL to finish upper layer authentication incase if the
1277 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001278 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001279
1280 if ( vos_status != VOS_STATUS_SUCCESS )
1281 {
1282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1283 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1284 __LINE__, vos_status );
1285 return vos_status;
1286
1287 }
1288
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001289 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301291 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001292 {
1293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301294 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001295 /* we'll still fall through and return success since the
1296 * connection may still get established but is just taking
1297 * too long for us to wait */
1298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 }
1300 return VOS_STATUS_SUCCESS;
1301}
1302
1303v_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)
1304{
1305
1306 int left = ie_len;
1307 v_U8_t *ptr = ie;
1308 v_U8_t elem_id,elem_len;
1309 v_U8_t eid = 0xDD;
1310
1311 if ( NULL == ie || 0 == ie_len )
1312 return NULL;
1313
1314 while(left >= 2)
1315 {
1316 elem_id = ptr[0];
1317 elem_len = ptr[1];
1318 left -= 2;
1319 if(elem_len > left)
1320 {
1321 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001322 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 eid,elem_len,left);
1324 return NULL;
1325 }
1326 if (elem_id == eid)
1327 {
1328 if(memcmp( &ptr[2], oui, oui_size)==0)
1329 return ptr;
1330 }
1331
1332 left -= elem_len;
1333 ptr += (elem_len + 2);
1334 }
1335 return NULL;
1336}
1337
1338static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1339 union iwreq_data *wrqu, char *extra)
1340{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001341 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 /* Do nothing for now */
1343 return 0;
1344}
1345
1346static int iw_get_name(struct net_device *dev,
1347 struct iw_request_info *info,
1348 char *wrqu, char *extra)
1349{
1350
1351 ENTER();
1352 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1353 EXIT();
1354 return 0;
1355}
1356
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301357static int __iw_set_mode(struct net_device *dev,
1358 struct iw_request_info *info,
1359 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001360{
1361 hdd_wext_state_t *pWextState;
1362 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1363 tCsrRoamProfile *pRoamProfile;
1364 eCsrRoamBssType LastBSSType;
1365 eMib_dot11DesiredBssType connectedBssType;
1366 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001368
1369 ENTER();
1370
1371 if (NULL == pAdapter)
1372 {
1373 hddLog(VOS_TRACE_LEVEL_WARN,
1374 "%s: Invalid context, pAdapter", __func__);
1375 return 0;
1376 }
1377
1378 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1380 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 return 0;
1382 }
1383
1384 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1385 if (pWextState == NULL)
1386 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301387 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 return -EINVAL;
1389 }
1390
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 pRoamProfile = &pWextState->roamProfile;
1393 LastBSSType = pRoamProfile->BSSType;
1394
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301395 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001396
1397 switch (wrqu->mode)
1398 {
1399 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301400 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1402 // Set the phymode correctly for IBSS.
1403 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1404 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001405 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 break;
1408 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301409 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 break;
1413 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301414 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1416 break;
1417 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301418 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 return -EOPNOTSUPP;
1420 }
1421
1422 if ( LastBSSType != pRoamProfile->BSSType )
1423 {
1424 //the BSS mode changed
1425 // We need to issue disconnect if connected or in IBSS disconnect state
1426 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1427 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1428 {
1429 VOS_STATUS vosStatus;
1430 // need to issue a disconnect to CSR.
1431 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1432 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1433 pAdapter->sessionId,
1434 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1435 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301436 {
1437 long ret;
1438 ret = wait_for_completion_interruptible_timeout(
1439 &pAdapter->disconnect_comp_var,
1440 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1441 if (ret <= 0)
1442 hddLog(VOS_TRACE_LEVEL_ERROR,
1443 FL("failed wait on disconnect_comp_var %ld"), ret);
1444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 }
1446 }
1447
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 EXIT();
1449 return 0;
1450}
1451
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301452static int iw_set_mode(struct net_device *dev,
1453 struct iw_request_info *info,
1454 union iwreq_data *wrqu, char *extra)
1455{
1456 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001457
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301458 vos_ssr_protect(__func__);
1459 ret = __iw_set_mode(dev, info, wrqu, extra);
1460 vos_ssr_unprotect(__func__);
1461
1462 return ret;
1463}
1464
1465static int __iw_get_mode(struct net_device *dev,
1466 struct iw_request_info *info,
1467 union iwreq_data *wrqu,
1468 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001469{
1470
1471 hdd_wext_state_t *pWextState;
1472 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1473
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301474 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001475
1476 if (NULL == pAdapter)
1477 {
1478 hddLog(VOS_TRACE_LEVEL_WARN,
1479 "%s: Invalid context, pAdapter", __func__);
1480 return 0;
1481 }
1482
1483 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1485 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 return 0;
1487 }
1488
1489 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1490 if (pWextState == NULL)
1491 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301492 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 return -EINVAL;
1494 }
1495
1496 switch (pWextState->roamProfile.BSSType)
1497 {
1498 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001499 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301500 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 break;
1502 case eCSR_BSS_TYPE_IBSS:
1503 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001504 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301505 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 break;
1507 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001508 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301509 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 break;
1511 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001512 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 break;
1514 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301515
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 return 0;
1517}
1518
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301519static int iw_get_mode(struct net_device *dev,
1520 struct iw_request_info *info,
1521 union iwreq_data *wrqu,
1522 char *extra)
1523{
1524 int ret;
1525
1526 vos_ssr_protect(__func__);
1527 ret = __iw_get_mode(dev, info, wrqu, extra);
1528 vos_ssr_unprotect(__func__);
1529
1530 return ret;
1531}
1532
1533static int __iw_set_freq(struct net_device *dev,
1534 struct iw_request_info *info,
1535 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001536{
1537 v_U32_t numChans = 0;
1538 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1539 v_U32_t indx = 0;
1540 v_U32_t status = 0;
1541
1542 hdd_wext_state_t *pWextState;
1543 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1544 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1545 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1546 tCsrRoamProfile * pRoamProfile;
1547 ENTER();
1548
1549 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1551 return status;
1552 }
1553
1554 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1555
1556 pRoamProfile = &pWextState->roamProfile;
1557
Arif Hussain6d2a3322013-11-17 19:50:10 -08001558 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001559
1560 /* Link is up then return cant set channel*/
1561 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1562 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1563 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001564 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 return -EOPNOTSUPP;
1566 }
1567
1568 /* Settings by Frequency as input */
1569 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1570 (wrqu->freq.m <= (tANI_U32)5.825e8))
1571 {
1572 tANI_U32 freq = wrqu->freq.m / 100000;
1573
1574 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1575 indx++;
1576 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1577 {
1578 return -EINVAL;
1579 }
1580 wrqu->freq.e = 0;
1581 wrqu->freq.m = freq_chan_map[indx].chan;
1582
1583 }
1584
1585 if (wrqu->freq.e == 0)
1586 {
1587 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1588 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1589 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001590 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001591 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1593 return -EINVAL;
1594 }
1595
1596 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1597
1598 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1599 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1601 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 return -EIO;
1603 }
1604
1605 for (indx = 0; indx < numChans; indx++) {
1606 if (wrqu->freq.m == validChan[indx]){
1607 break;
1608 }
1609 }
1610 }
1611 else{
1612
1613 return -EINVAL;
1614 }
1615
1616 if(indx >= numChans)
1617 {
1618 return -EINVAL;
1619 }
1620
1621 /* Set the Operational Channel */
1622 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1623 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1624 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1625
Arif Hussain6d2a3322013-11-17 19:50:10 -08001626 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001627
1628 EXIT();
1629
1630 return status;
1631}
1632
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301633static int iw_set_freq(struct net_device *dev,
1634 struct iw_request_info *info,
1635 union iwreq_data *wrqu, char *extra)
1636{
1637 int ret;
1638
1639 vos_ssr_protect(__func__);
1640 ret = __iw_set_freq(dev, info, wrqu, extra);
1641 vos_ssr_unprotect(__func__);
1642
1643 return ret;
1644}
1645
1646static int __iw_get_freq(struct net_device *dev,
1647 struct iw_request_info *info,
1648 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001649{
Jeff Johnsone7245742012-09-05 17:12:55 -07001650 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1652 tHalHandle hHal;
1653 hdd_wext_state_t *pWextState;
1654 tCsrRoamProfile * pRoamProfile;
1655 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1656
1657 ENTER();
1658
1659 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1661 return status;
1662 }
1663
1664 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1665 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1666
1667 pRoamProfile = &pWextState->roamProfile;
1668
1669 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1670 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001671 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 {
c_hpothub8245442013-11-20 23:41:09 +05301673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1674 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 return -EIO;
1676 }
1677 else
1678 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001679 status = hdd_wlan_get_freq(channel, &freq);
1680 if( TRUE == status )
1681 {
1682 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1683 * iwlist & iwconfig command shows frequency into proper
1684 * format (2.412 GHz instead of 246.2 MHz)*/
1685 fwrq->m = freq;
1686 fwrq->e = MHZ;
1687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 }
1689 }
1690 else
1691 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001692 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1693 * iwlist & iwconfig command shows frequency into proper
1694 * format (2.412 GHz instead of 246.2 MHz)*/
1695 fwrq->m = 0;
1696 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001698 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001699}
1700
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301701static int iw_get_freq(struct net_device *dev,
1702 struct iw_request_info *info,
1703 struct iw_freq *fwrq, char *extra)
1704{
1705 int ret;
1706
1707 vos_ssr_protect(__func__);
1708 ret = __iw_get_freq(dev, info, fwrq, extra);
1709 vos_ssr_unprotect(__func__);
1710
1711 return ret;
1712}
1713
1714static int __iw_get_tx_power(struct net_device *dev,
1715 struct iw_request_info *info,
1716 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001717{
1718
1719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1720 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1721 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1722
1723 if (pHddCtx->isLogpInProgress)
1724 {
1725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1726 "%s:LOGP in Progress. Ignore!!!",__func__);
1727 return -EBUSY;
1728 }
1729
1730 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1731 {
1732 wrqu->txpower.value = 0;
1733 return 0;
1734 }
1735 wlan_hdd_get_classAstats(pAdapter);
1736 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1737
1738 return 0;
1739}
1740
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301741static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 struct iw_request_info *info,
1743 union iwreq_data *wrqu, char *extra)
1744{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301745 int ret;
1746
1747 vos_ssr_protect(__func__);
1748 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1749 vos_ssr_unprotect(__func__);
1750
1751 return ret;
1752}
1753
1754static int __iw_set_tx_power(struct net_device *dev,
1755 struct iw_request_info *info,
1756 union iwreq_data *wrqu, char *extra)
1757{
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1759 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1760
1761 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1762 {
1763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1764 return 0;
1765 }
1766
1767 ENTER();
1768
1769 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1770 {
c_hpothub8245442013-11-20 23:41:09 +05301771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1772 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 return -EIO;
1774 }
1775
1776 EXIT();
1777
1778 return 0;
1779}
1780
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301781static int iw_set_tx_power(struct net_device *dev,
1782 struct iw_request_info *info,
1783 union iwreq_data *wrqu, char *extra)
1784{
1785 int ret;
1786
1787 vos_ssr_protect(__func__);
1788 ret = __iw_set_tx_power(dev, info, wrqu, extra);
1789 vos_ssr_unprotect(__func__);
1790
1791 return ret;
1792}
1793
1794static int __iw_get_bitrate(struct net_device *dev,
1795 struct iw_request_info *info,
1796 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001797{
1798 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1799 eHalStatus status = eHAL_STATUS_SUCCESS;
1800 hdd_wext_state_t *pWextState;
1801 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1802 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1803
1804 ENTER();
1805
1806 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1808 return status;
1809 }
1810
1811 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1812 wrqu->bitrate.value = 0;
1813 }
1814 else {
1815 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1816 SME_SUMMARY_STATS |
1817 SME_GLOBAL_CLASSA_STATS |
1818 SME_GLOBAL_CLASSB_STATS |
1819 SME_GLOBAL_CLASSC_STATS |
1820 SME_GLOBAL_CLASSD_STATS |
1821 SME_PER_STA_STATS,
1822 hdd_StatisticsCB, 0, FALSE,
1823 pHddStaCtx->conn_info.staId[0], pAdapter );
1824
1825 if(eHAL_STATUS_SUCCESS != status)
1826 {
1827 hddLog(VOS_TRACE_LEVEL_ERROR,
1828 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001829 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 return status;
1831 }
1832
1833 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1834
1835 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1836
1837 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1838 {
1839 hddLog(VOS_TRACE_LEVEL_ERROR,
1840 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001841 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 return VOS_STATUS_E_FAILURE;
1843 }
1844
1845 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1846 }
1847
1848 EXIT();
1849
1850 return vos_status;
1851}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301852
1853static int iw_get_bitrate(struct net_device *dev,
1854 struct iw_request_info *info,
1855 union iwreq_data *wrqu, char *extra)
1856{
1857 int ret;
1858
1859 vos_ssr_protect(__func__);
1860 ret = __iw_get_bitrate(dev, info, wrqu, extra);
1861 vos_ssr_unprotect(__func__);
1862
1863 return ret;
1864}
1865
1866
Jeff Johnson295189b2012-06-20 16:38:30 -07001867/* ccm call back function */
1868
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301869static int __iw_set_bitrate(struct net_device *dev,
1870 struct iw_request_info *info,
1871 union iwreq_data *wrqu,
1872 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001873{
1874 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1875 hdd_wext_state_t *pWextState;
1876 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1877 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1878 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1879 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1880 v_U32_t i, rate;
1881 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1882
1883 ENTER();
1884
1885 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1887 return 0;
1888 }
1889
1890 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1891
1892 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1893 {
1894 return -ENXIO ;
1895 }
1896
1897 rate = wrqu->bitrate.value;
1898
1899 if (rate == -1)
1900 {
1901 rate = WNI_CFG_FIXED_RATE_AUTO;
1902 valid_rate = TRUE;
1903 }
1904 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1905 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1906 {
1907 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1908 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1909 {
1910 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1911 WNI_CFG_SUPPORTED_RATES_11A,
1912 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1913 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1914 WNI_CFG_SUPPORTED_RATES_11B,
1915 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1916 {
1917 for (i = 0; i < (b_len + a_len); ++i)
1918 {
1919 /* supported rates returned is double the actual rate so we divide it by 2 */
1920 if ((supp_rates[i]&0x7F)/2 == rate)
1921 {
1922 valid_rate = TRUE;
1923 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1924 break;
1925 }
1926 }
1927 }
1928 }
1929 }
1930 if (valid_rate != TRUE)
1931 {
1932 return -EINVAL;
1933 }
1934 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1935 WNI_CFG_FIXED_RATE, rate,
1936 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1937 {
c_hpothub8245442013-11-20 23:41:09 +05301938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1939 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 return -EIO;
1941 }
1942 return 0;
1943}
1944
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301945static int iw_set_bitrate(struct net_device *dev,
1946 struct iw_request_info *info,
1947 union iwreq_data *wrqu,
1948 char *extra)
1949{
1950 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001951
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301952 vos_ssr_protect(__func__);
1953 ret = __iw_set_bitrate(dev, info, wrqu, extra);
1954 vos_ssr_unprotect(__func__);
1955
1956 return ret;
1957}
1958
1959static int __iw_set_genie(struct net_device *dev,
1960 struct iw_request_info *info,
1961 union iwreq_data *wrqu,
1962 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001963{
1964 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1965 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001966 u_int8_t *genie = NULL;
1967 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 v_U16_t remLen;
1969
1970 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001971
1972 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1974 "%s:LOGP in Progress. Ignore!!!", __func__);
1975 return 0;
1976 }
1977
1978 if (!wrqu->data.length) {
1979 hdd_clearRoamProfileIe(pAdapter);
1980 EXIT();
1981 return 0;
1982 }
1983
1984 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1985 wrqu->data.length);
1986 if (NULL == base_genie)
1987 {
1988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1989 "mem_alloc_copy_from_user_helper fail");
1990 return -ENOMEM;
1991 }
1992
1993 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001994
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 remLen = wrqu->data.length;
1996
Arif Hussain6d2a3322013-11-17 19:50:10 -08001997 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001998
1999 /* clear any previous genIE before this call */
2000 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2001
2002 while (remLen >= 2)
2003 {
2004 v_U16_t eLen = 0;
2005 v_U8_t elementId;
2006 elementId = *genie++;
2007 eLen = *genie++;
2008 remLen -= 2;
2009
Arif Hussain6d2a3322013-11-17 19:50:10 -08002010 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 __func__, elementId, eLen);
2012
2013 switch ( elementId )
2014 {
2015 case IE_EID_VENDOR:
2016 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002017 {
2018 kfree(base_genie);
2019 return -EINVAL;
2020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002021
2022 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2023 {
2024 v_U16_t curGenIELen = pWextState->genIE.length;
2025 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2026 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2027
2028 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2029 {
2030 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002031 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002033 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 return -ENOMEM;
2035 }
2036 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2037 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2038 pWextState->genIE.length += eLen + 2;
2039 }
2040 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2041 {
2042 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2043 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2044 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2045 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2046 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2047 }
2048 else /* any vendorId except WPA IE should be accumulated to genIE */
2049 {
2050 v_U16_t curGenIELen = pWextState->genIE.length;
2051 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2052 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2053
2054 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2055 {
2056 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002057 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002059 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 return -ENOMEM;
2061 }
2062 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2063 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2064 pWextState->genIE.length += eLen + 2;
2065 }
2066 break;
2067 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002068 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2070 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2071 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2072 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2073 break;
2074
2075 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002076 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002077 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 return 0;
2079 }
2080 genie += eLen;
2081 remLen -= eLen;
2082 }
2083 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002084 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 return 0;
2086}
2087
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302088static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 struct iw_request_info *info,
2090 union iwreq_data *wrqu,
2091 char *extra)
2092{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302093 int ret;
2094
2095 vos_ssr_protect(__func__);
2096 ret = __iw_set_genie(dev, info, wrqu, extra);
2097 vos_ssr_unprotect(__func__);
2098
2099 return ret;
2100}
2101
2102static int __iw_get_genie(struct net_device *dev,
2103 struct iw_request_info *info,
2104 union iwreq_data *wrqu,
2105 char *extra)
2106{
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 hdd_wext_state_t *pWextState;
2108 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2109 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2110 eHalStatus status;
2111 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2112 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2113
2114 ENTER();
2115
2116 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2118 return 0;
2119 }
2120
2121
Arif Hussain6d2a3322013-11-17 19:50:10 -08002122 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07002123
2124 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2125
2126 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2127 {
2128 return -ENXIO;
2129 }
2130
2131 // Return something ONLY if we are associated with an RSN or WPA network
2132 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2133 pWextState->roamProfile.negotiatedAuthType))
2134 {
2135 return -ENXIO;
2136 }
2137
2138 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2139 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2140 pAdapter->sessionId,
2141 &length,
2142 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002143 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2144 if (wrqu->data.length < length)
2145 {
2146 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2147 return -EFAULT;
2148 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002149 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002150 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002151
Arif Hussain6d2a3322013-11-17 19:50:10 -08002152 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002153
2154 EXIT();
2155
2156 return 0;
2157}
2158
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302159static int iw_get_genie(struct net_device *dev,
2160 struct iw_request_info *info,
2161 union iwreq_data *wrqu,
2162 char *extra)
2163{
2164 int ret;
2165
2166 vos_ssr_protect(__func__);
2167 ret = __iw_get_genie(dev, info, wrqu, extra);
2168 vos_ssr_unprotect(__func__);
2169
2170 return ret;
2171}
2172
2173
2174static int __iw_get_encode(struct net_device *dev,
2175 struct iw_request_info *info,
2176 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002177{
2178 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2179 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2180 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2181 int keyId;
2182 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2183 int i;
2184
2185 ENTER();
2186
2187 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2189 return 0;
2190 }
2191
2192 keyId = pRoamProfile->Keys.defaultIndex;
2193
2194 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2195 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002196 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 return -EINVAL;
2198 }
2199
2200 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2201 {
2202 dwrq->flags |= IW_ENCODE_ENABLED;
2203 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2204 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2205
2206 dwrq->flags |= (keyId + 1);
2207
2208 }
2209 else
2210 {
2211 dwrq->flags |= IW_ENCODE_DISABLED;
2212 }
2213
2214 for(i=0; i < MAX_WEP_KEYS; i++)
2215 {
2216 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2217 {
2218 continue;
2219 }
2220 else
2221 {
2222 break;
2223 }
2224 }
2225
2226 if(MAX_WEP_KEYS == i)
2227 {
2228 dwrq->flags |= IW_ENCODE_NOKEY;
2229 }
2230
2231 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2232
2233 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2234 {
2235 dwrq->flags |= IW_ENCODE_OPEN;
2236 }
2237 else
2238 {
2239 dwrq->flags |= IW_ENCODE_RESTRICTED;
2240 }
2241 EXIT();
2242 return 0;
2243}
2244
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302245static int iw_get_encode(struct net_device *dev,
2246 struct iw_request_info *info,
2247 struct iw_point *dwrq, char *extra)
2248{
2249 int ret;
2250
2251 vos_ssr_protect(__func__);
2252 ret = __iw_get_encode(dev, info, dwrq, extra);
2253 vos_ssr_unprotect(__func__);
2254
2255 return ret;
2256}
2257
Jeff Johnson295189b2012-06-20 16:38:30 -07002258#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2259#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2260
2261
2262/*
2263 * This function sends a single 'key' to LIM at all time.
2264 */
2265
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302266static int __iw_get_rts_threshold(struct net_device *dev,
2267 struct iw_request_info *info,
2268 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002269{
2270 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2271 v_U32_t status = 0;
2272
2273 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2274
2275 return status;
2276}
2277
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302278static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 struct iw_request_info *info,
2280 union iwreq_data *wrqu, char *extra)
2281{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302282 int ret;
2283
2284 vos_ssr_protect(__func__);
2285 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2286 vos_ssr_unprotect(__func__);
2287
2288 return ret;
2289}
2290
2291static int __iw_set_rts_threshold(struct net_device *dev,
2292 struct iw_request_info *info,
2293 union iwreq_data *wrqu, char *extra)
2294{
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2296 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2297
2298 ENTER();
2299
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002300 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2301 {
2302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2303 "%s:LOGP in Progress. Ignore!!!", __func__);
2304 return -EAGAIN;
2305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2307 {
2308 return -EINVAL;
2309 }
2310
2311 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2312 {
c_hpothub8245442013-11-20 23:41:09 +05302313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2314 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 return -EIO;
2316 }
2317
2318 EXIT();
2319
2320 return 0;
2321}
2322
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302323static int iw_set_rts_threshold(struct net_device *dev,
2324 struct iw_request_info *info,
2325 union iwreq_data *wrqu, char *extra)
2326{
2327 int ret;
2328
2329 vos_ssr_protect(__func__);
2330 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2331 vos_ssr_unprotect(__func__);
2332
2333 return ret;
2334}
2335
2336static int __iw_get_frag_threshold(struct net_device *dev,
2337 struct iw_request_info *info,
2338 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002339{
2340 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2341 v_U32_t status = 0;
2342
2343 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2344
2345 return status;
2346}
2347
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302348static int iw_get_frag_threshold(struct net_device *dev,
2349 struct iw_request_info *info,
2350 union iwreq_data *wrqu, char *extra)
2351{
2352 int ret;
2353
2354 vos_ssr_protect(__func__);
2355 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2356 vos_ssr_unprotect(__func__);
2357
2358 return ret;
2359}
2360
2361static int __iw_set_frag_threshold(struct net_device *dev,
2362 struct iw_request_info *info,
2363 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002364{
2365 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2366 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2367
2368 ENTER();
2369
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002370 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2371 {
2372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2373 "%s:LOGP in Progress. Ignore!!!", __func__);
2374 return -EBUSY;
2375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2377 {
2378 return -EINVAL;
2379 }
2380
2381 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2382 {
c_hpothub8245442013-11-20 23:41:09 +05302383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2384 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 return -EIO;
2386 }
2387
2388 EXIT();
2389
2390 return 0;
2391}
2392
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302393static int iw_set_frag_threshold(struct net_device *dev,
2394 struct iw_request_info *info,
2395 union iwreq_data *wrqu, char *extra)
2396{
2397 int ret;
2398
2399 vos_ssr_protect(__func__);
2400 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2401 vos_ssr_unprotect(__func__);
2402
2403 return ret;
2404}
2405
Jeff Johnson295189b2012-06-20 16:38:30 -07002406static int iw_get_power_mode(struct net_device *dev,
2407 struct iw_request_info *info,
2408 union iwreq_data *wrqu, char *extra)
2409{
2410 ENTER();
2411 return -EOPNOTSUPP;
2412}
2413
2414static int iw_set_power_mode(struct net_device *dev,
2415 struct iw_request_info *info,
2416 union iwreq_data *wrqu, char *extra)
2417{
2418 ENTER();
2419 return -EOPNOTSUPP;
2420}
2421
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302422static int __iw_get_range(struct net_device *dev,
2423 struct iw_request_info *info,
2424 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002425{
2426 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2427 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2428 struct iw_range *range = (struct iw_range *) extra;
2429
2430 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2431
2432 v_U32_t num_channels = sizeof(channels);
2433 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2434 v_U32_t a_len;
2435 v_U32_t b_len;
2436 v_U32_t active_phy_mode = 0;
2437 v_U8_t index = 0, i;
2438
2439 ENTER();
2440
2441 wrqu->data.length = sizeof(struct iw_range);
2442 memset(range, 0, sizeof(struct iw_range));
2443
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002444 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2445 {
2446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2447 "%s:LOGP in Progress. Ignore!!!", __func__);
2448 return -EBUSY;
2449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002450
2451 /*Get the phy mode*/
2452 if (ccmCfgGetInt(hHal,
2453 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2454 {
2455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002456 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002457
2458 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2459 {
2460 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002461 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002462 if (ccmCfgGetStr(hHal,
2463 WNI_CFG_SUPPORTED_RATES_11A,
2464 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2465 {
2466 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2467 {
2468 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2469 }
2470 for (i = 0; i < a_len; i++)
2471 {
2472 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2473 }
2474 range->num_bitrates = a_len;
2475 }
2476 else
2477 {
2478 return -EIO;
2479 }
2480 }
2481 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2482 {
2483 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002484 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 if (ccmCfgGetStr(hHal,
2486 WNI_CFG_SUPPORTED_RATES_11B,
2487 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2488 {
2489 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2490 {
2491 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2492 }
2493 for (i = 0; i < b_len; i++)
2494 {
2495 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2496 }
2497 range->num_bitrates = b_len;
2498 }
2499 else
2500 {
2501 return -EIO;
2502 }
2503 }
2504 }
2505
2506 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2507 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2508 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2509
2510 range->encoding_size[0] = 5;
2511 range->encoding_size[1] = 13;
2512 range->num_encoding_sizes = 2;
2513 range->max_encoding_tokens = MAX_WEP_KEYS;
2514
2515 // we support through Wireless Extensions 22
2516 range->we_version_compiled = WIRELESS_EXT;
2517 range->we_version_source = 22;
2518
2519 /*Supported Channels and Frequencies*/
2520 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2521 {
c_hpothub8245442013-11-20 23:41:09 +05302522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2523 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 return -EIO;
2525 }
2526 if (num_channels > IW_MAX_FREQUENCIES)
2527 {
2528 num_channels = IW_MAX_FREQUENCIES;
2529 }
2530
2531 range->num_channels = num_channels;
2532 range->num_frequency = num_channels;
2533
2534 for (index=0; index < num_channels; index++)
2535 {
2536 v_U32_t frq_indx = 0;
2537
2538 range->freq[index].i = channels[index];
2539 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2540 {
2541 if(channels[index] == freq_chan_map[frq_indx].chan)
2542 {
2543 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2544 range->freq[index].e = 1;
2545 break;
2546 }
2547 frq_indx++;
2548 }
2549 }
2550
2551 /* Event capability (kernel + driver) */
2552 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2553 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2554 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2555 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2556
2557 /*Encryption capability*/
2558 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2559 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2560
2561 /* Txpower capability */
2562 range->txpower_capa = IW_TXPOW_MWATT;
2563
2564 /*Scanning capability*/
2565 #if WIRELESS_EXT >= 22
2566 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2567 #endif
2568
2569 EXIT();
2570 return 0;
2571}
2572
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302573static int iw_get_range(struct net_device *dev,
2574 struct iw_request_info *info,
2575 union iwreq_data *wrqu, char *extra)
2576{
2577 int ret;
2578
2579 vos_ssr_protect(__func__);
2580 ret = __iw_get_range(dev, info, wrqu, extra);
2581 vos_ssr_unprotect(__func__);
2582
2583 return ret;
2584}
2585
Jeff Johnson295189b2012-06-20 16:38:30 -07002586/* Callback function registered with PMC to know status of PMC request */
2587static void iw_power_callback_fn (void *pContext, eHalStatus status)
2588{
2589 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002590
2591 if (NULL == pContext)
2592 {
2593 hddLog(VOS_TRACE_LEVEL_ERROR,
2594 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002595 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 return;
2597 }
2598
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002600
Jeff Johnson72a40512013-12-19 10:14:15 -08002601 /* there is a race condition that exists between this callback
2602 function and the caller since the caller could time out either
2603 before or while this code is executing. we use a spinlock to
2604 serialize these actions */
2605 spin_lock(&hdd_context_lock);
2606
2607 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 {
2609 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002610 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002612 "%s: Invalid context, magic [%08x]",
2613 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614
2615 if (ioctl_debug)
2616 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002617 pr_info("%s: Invalid context, magic [%08x]\n",
2618 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 }
2620 return;
2621 }
2622
Jeff Johnson72a40512013-12-19 10:14:15 -08002623 /* context is valid so caller is still waiting */
2624
2625 /* paranoia: invalidate the magic */
2626 pStatsContext->magic = 0;
2627
2628 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002630
2631 /* serialization is complete */
2632 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002633}
2634
2635/* Callback function for tx per hit */
2636void hdd_tx_per_hit_cb (void *pCallbackContext)
2637{
2638 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2639 unsigned char tx_fail[16];
2640 union iwreq_data wrqu;
2641
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05302642 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07002643 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002644 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 return;
2646 }
2647 memset(&wrqu, 0, sizeof(wrqu));
2648 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2649 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2650}
2651
2652void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2653{
2654 struct statsContext *pStatsContext;
2655 tCsrGlobalClassAStatsInfo *pClassAStats;
2656 hdd_adapter_t *pAdapter;
2657
2658 if (ioctl_debug)
2659 {
2660 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002661 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 }
2663
2664 if ((NULL == pStats) || (NULL == pContext))
2665 {
2666 hddLog(VOS_TRACE_LEVEL_ERROR,
2667 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002668 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 return;
2670 }
2671
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 pClassAStats = pStats;
2673 pStatsContext = pContext;
2674 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002675
2676 /* there is a race condition that exists between this callback
2677 function and the caller since the caller could time out either
2678 before or while this code is executing. we use a spinlock to
2679 serialize these actions */
2680 spin_lock(&hdd_context_lock);
2681
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2683 {
2684 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002685 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 hddLog(VOS_TRACE_LEVEL_WARN,
2687 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002688 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 if (ioctl_debug)
2690 {
2691 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002692 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 }
2694 return;
2695 }
2696
Jeff Johnson72a40512013-12-19 10:14:15 -08002697 /* context is valid so caller is still waiting */
2698
2699 /* paranoia: invalidate the magic */
2700 pStatsContext->magic = 0;
2701
2702 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2704
Jeff Johnson72a40512013-12-19 10:14:15 -08002705 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002707
2708 /* serialization is complete */
2709 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002710}
2711
2712VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2713{
2714 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2715 eHalStatus hstatus;
2716 long lrc;
2717 struct statsContext context;
2718
2719 if (NULL == pAdapter)
2720 {
2721 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2722 return VOS_STATUS_E_FAULT;
2723 }
2724 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2725 {
2726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2727 return VOS_STATUS_SUCCESS;
2728 }
2729
2730 /* we are connected
2731 prepare our callback context */
2732 init_completion(&context.completion);
2733 context.pAdapter = pAdapter;
2734 context.magic = STATS_CONTEXT_MAGIC;
2735 /* query only for Class A statistics (which include link speed) */
2736 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2737 eCSR_HDD,
2738 SME_GLOBAL_CLASSA_STATS,
2739 hdd_GetClassA_statisticsCB,
2740 0, // not periodic
2741 FALSE, //non-cached results
2742 pHddStaCtx->conn_info.staId[0],
2743 &context);
2744 if (eHAL_STATUS_SUCCESS != hstatus)
2745 {
2746 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002747 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002748 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 /* we'll returned a cached value below */
2750 }
2751 else
2752 {
2753 /* request was sent -- wait for the response */
2754 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2755 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 if (lrc <= 0)
2757 {
2758 hddLog(VOS_TRACE_LEVEL_ERROR,
2759 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002760 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 }
2762 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002763
2764 /* either we never sent a request, we sent a request and received a
2765 response or we sent a request and timed out. if we never sent a
2766 request or if we sent a request and got a response, we want to
2767 clear the magic out of paranoia. if we timed out there is a
2768 race condition such that the callback function could be
2769 executing at the same time we are. of primary concern is if the
2770 callback function had already verified the "magic" but had not
2771 yet set the completion variable when a timeout occurred. we
2772 serialize these activities by invalidating the magic while
2773 holding a shared spinlock which will cause us to block if the
2774 callback is currently executing */
2775 spin_lock(&hdd_context_lock);
2776 context.magic = 0;
2777 spin_unlock(&hdd_context_lock);
2778
2779 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 return VOS_STATUS_SUCCESS;
2781}
2782
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002783static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2784{
2785 struct statsContext *pStatsContext;
2786 tCsrSummaryStatsInfo *pSummaryStats;
2787 tCsrGlobalClassAStatsInfo *pClassAStats;
2788 hdd_adapter_t *pAdapter;
2789
2790 if (ioctl_debug)
2791 {
2792 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002793 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002794 }
2795
2796 if ((NULL == pStats) || (NULL == pContext))
2797 {
2798 hddLog(VOS_TRACE_LEVEL_ERROR,
2799 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002800 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002801 return;
2802 }
2803
Jeff Johnson72a40512013-12-19 10:14:15 -08002804 /* there is a race condition that exists between this callback
2805 function and the caller since the caller could time out either
2806 before or while this code is executing. we use a spinlock to
2807 serialize these actions */
2808 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002809
2810 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2811 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2812 pStatsContext = pContext;
2813 pAdapter = pStatsContext->pAdapter;
2814 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2815 {
2816 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002817 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002818 hddLog(VOS_TRACE_LEVEL_WARN,
2819 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002820 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002821 if (ioctl_debug)
2822 {
2823 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002824 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002825 }
2826 return;
2827 }
2828
Jeff Johnson72a40512013-12-19 10:14:15 -08002829 /* context is valid so caller is still waiting */
2830
2831 /* paranoia: invalidate the magic */
2832 pStatsContext->magic = 0;
2833
2834 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002835 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2836 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2837
Jeff Johnson72a40512013-12-19 10:14:15 -08002838 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002839 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002840
2841 /* serialization is complete */
2842 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002843}
2844
2845VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2846{
2847 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2848 eHalStatus hstatus;
2849 long lrc;
2850 struct statsContext context;
2851
2852 if (NULL == pAdapter)
2853 {
2854 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2855 return VOS_STATUS_SUCCESS;
2856 }
2857
2858 /* we are connected
2859 prepare our callback context */
2860 init_completion(&context.completion);
2861 context.pAdapter = pAdapter;
2862 context.magic = STATS_CONTEXT_MAGIC;
2863
2864 /* query only for Summary & Class A statistics */
2865 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2866 eCSR_HDD,
2867 SME_SUMMARY_STATS |
2868 SME_GLOBAL_CLASSA_STATS,
2869 hdd_get_station_statisticsCB,
2870 0, // not periodic
2871 FALSE, //non-cached results
2872 pHddStaCtx->conn_info.staId[0],
2873 &context);
2874 if (eHAL_STATUS_SUCCESS != hstatus)
2875 {
2876 hddLog(VOS_TRACE_LEVEL_ERROR,
2877 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002878 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002879 /* we'll return with cached values */
2880 }
2881 else
2882 {
2883 /* request was sent -- wait for the response */
2884 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2885 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002886
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002887 if (lrc <= 0)
2888 {
2889 hddLog(VOS_TRACE_LEVEL_ERROR,
2890 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002891 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002892 }
2893 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002894
2895 /* either we never sent a request, we sent a request and received a
2896 response or we sent a request and timed out. if we never sent a
2897 request or if we sent a request and got a response, we want to
2898 clear the magic out of paranoia. if we timed out there is a
2899 race condition such that the callback function could be
2900 executing at the same time we are. of primary concern is if the
2901 callback function had already verified the "magic" but had not
2902 yet set the completion variable when a timeout occurred. we
2903 serialize these activities by invalidating the magic while
2904 holding a shared spinlock which will cause us to block if the
2905 callback is currently executing */
2906 spin_lock(&hdd_context_lock);
2907 context.magic = 0;
2908 spin_unlock(&hdd_context_lock);
2909
2910 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002911 return VOS_STATUS_SUCCESS;
2912}
2913
2914
Jeff Johnson295189b2012-06-20 16:38:30 -07002915/*
2916 * Support for the LINKSPEED private command
2917 * Per the WiFi framework the response must be of the form
2918 * "LinkSpeed xx"
2919 */
2920static int iw_get_linkspeed(struct net_device *dev,
2921 struct iw_request_info *info,
2922 union iwreq_data *wrqu, char *extra)
2923{
2924 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302925 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002926 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302927 int len = sizeof(v_U32_t) + 1;
2928 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302930 VOS_STATUS status;
2931 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002932
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302933 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2934
2935 valid = wlan_hdd_validate_context(pHddCtx);
2936
2937 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002938 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302939 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2940 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002941 }
2942
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2944 {
2945 /* we are not connected so we don't have a classAstats */
2946 link_speed = 0;
2947 }
2948 else
2949 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302950 status = wlan_hdd_get_classAstats(pAdapter);
2951
2952 if (!VOS_IS_STATUS_SUCCESS(status ))
2953 {
2954 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2955 return -EINVAL;
2956 }
2957
2958 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2959 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2960 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2961 &link_speed);
2962
2963 link_speed = link_speed / 10;
2964
2965 if (0 == link_speed)
2966 {
2967 /* The linkspeed returned by HAL is in units of 500kbps.
2968 * converting it to mbps.
2969 * This is required to support legacy firmware which does
2970 * not return link capacity.
2971 */
2972 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2973 }
2974
Jeff Johnson295189b2012-06-20 16:38:30 -07002975 }
2976
2977 wrqu->data.length = len;
2978 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002979 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 if ((rc < 0) || (rc >= len))
2981 {
2982 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302983 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 return -EIO;
2985 }
2986
2987 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002988 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002989}
2990
Arif Hussain695279c2014-03-24 14:06:07 -07002991/*
2992 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2993 *
2994 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05302995static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07002996 struct iw_request_info *info,
2997 union iwreq_data *wrqu, char *extra)
2998{
2999 int rc;
3000
3001 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3002
3003 if (rc < 0)
3004 return rc;
3005
3006 /* a value is being successfully returned */
3007 return 0;
3008}
Jeff Johnson295189b2012-06-20 16:38:30 -07003009
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303010static int iw_get_linkspeed_priv(struct net_device *dev,
3011 struct iw_request_info *info,
3012 union iwreq_data *wrqu, char *extra)
3013{
3014 int ret;
3015
3016 vos_ssr_protect(__func__);
3017 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3018 vos_ssr_unprotect(__func__);
3019
3020 return ret;
3021}
3022
Jeff Johnson295189b2012-06-20 16:38:30 -07003023/*
3024 * Support for the RSSI & RSSI-APPROX private commands
3025 * Per the WiFi framework the response must be of the form
3026 * "<ssid> rssi <xx>"
3027 * unless we are not associated, in which case the response is
3028 * "OK"
3029 */
3030static int iw_get_rssi(struct net_device *dev,
3031 struct iw_request_info *info,
3032 union iwreq_data *wrqu, char *extra)
3033{
3034 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003035 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 int len = wrqu->data.length;
3037 v_S7_t s7Rssi = 0;
3038 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3039 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3040 VOS_STATUS vosStatus;
3041 int rc;
3042
3043 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3044 (0 == ssidlen) || (ssidlen >= len))
3045 {
3046 /* we are not connected or our SSID is too long
3047 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003048 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 }
3050 else
3051 {
3052 /* we are connected with a valid SSID
3053 so we can write the SSID into the return buffer
3054 (note that it is not NUL-terminated) */
3055 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3056
3057 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3058
3059 if (VOS_STATUS_SUCCESS == vosStatus)
3060 {
3061 /* append the rssi to the ssid in the format required by
3062 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003063 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303064 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 }
3066 else
3067 {
3068 rc = -1;
3069 }
3070 }
3071
3072 /* verify that we wrote a valid response */
3073 if ((rc < 0) || (rc >= len))
3074 {
3075 // encoding or length error?
3076 hddLog(VOS_TRACE_LEVEL_ERROR,
3077 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003078 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 return -EIO;
3080 }
3081
3082 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003083 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003084}
3085
3086/*
3087 * Support for SoftAP channel range private command
3088 */
3089static int iw_softap_set_channel_range( struct net_device *dev,
3090 int startChannel,
3091 int endChannel,
3092 int band)
3093{
Jeff Johnson43971f52012-07-17 12:26:56 -07003094 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 int ret = 0;
3096 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3097 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003098 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3099
Jeff Johnson295189b2012-06-20 16:38:30 -07003100
3101 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3102 if (VOS_STATUS_SUCCESS != status)
3103 {
3104 ret = -EINVAL;
3105 }
Yathish9f22e662012-12-10 14:21:35 -08003106 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 return ret;
3108}
3109
3110VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3111{
3112 struct statsContext context;
3113 eHalStatus status;
3114 hdd_context_t *pHddCtx;
3115
3116 if (NULL == pAdapter)
3117 {
3118 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3119 return VOS_STATUS_E_FAULT;
3120 }
3121
3122 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3123 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303124 if (pHddCtx->isLogpInProgress) {
3125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3126 "%s:LOGP in Progress. Ignore!!!", __func__);
3127 return VOS_STATUS_E_FAILURE;
3128 }
3129
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 init_completion(&context.completion);
3131
3132 context.pAdapter = pAdapter;
3133 context.magic = POWER_CONTEXT_MAGIC;
3134
3135 if (DRIVER_POWER_MODE_ACTIVE == mode)
3136 {
3137 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3138 "Full Power", __func__);
3139 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3140 iw_power_callback_fn, &context,
3141 eSME_FULL_PWR_NEEDED_BY_HDD);
3142 // Enter Full power command received from GUI this means we are disconnected
3143 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3144 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3145 if (eHAL_STATUS_PMC_PENDING == status)
3146 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003147 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 int lrc = wait_for_completion_interruptible_timeout(
3149 &context.completion,
3150 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003151
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 if (lrc <= 0)
3153 {
3154 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003155 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 }
3157 }
3158 }
3159 else if (DRIVER_POWER_MODE_AUTO == mode)
3160 {
3161 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3162 {
3163 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3164 __func__);
3165 // Enter BMPS command received from GUI this means DHCP is completed
3166 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3167 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3168 FALSE);
3169 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3170 iw_power_callback_fn, &context);
3171 if (eHAL_STATUS_PMC_PENDING == status)
3172 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003173 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 int lrc = wait_for_completion_interruptible_timeout(
3175 &context.completion,
3176 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 if (lrc <= 0)
3178 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003179 hddLog(VOS_TRACE_LEVEL_ERROR,
3180 "%s: SME %s while requesting BMPS",
3181 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 }
3183 }
3184 }
3185 else
3186 {
3187 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3188 "enabled in the cfg");
3189 }
3190 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003191
3192 /* either we never sent a request, we sent a request and received a
3193 response or we sent a request and timed out. if we never sent a
3194 request or if we sent a request and got a response, we want to
3195 clear the magic out of paranoia. if we timed out there is a
3196 race condition such that the callback function could be
3197 executing at the same time we are. of primary concern is if the
3198 callback function had already verified the "magic" but had not
3199 yet set the completion variable when a timeout occurred. we
3200 serialize these activities by invalidating the magic while
3201 holding a shared spinlock which will cause us to block if the
3202 callback is currently executing */
3203 spin_lock(&hdd_context_lock);
3204 context.magic = 0;
3205 spin_unlock(&hdd_context_lock);
3206
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 return VOS_STATUS_SUCCESS;
3208}
3209
3210VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3211 hdd_adapter_t *pAdapter)
3212{
3213 VOS_STATUS vos_Status;
3214
3215 if ((NULL == pAdapter) || (NULL == pHddCtx))
3216 {
3217 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3218 return VOS_STATUS_E_FAULT;
3219 }
3220
3221 /**Exit from Deep sleep or standby if we get the driver
3222 START cmd from android GUI
3223 */
3224 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3225 {
3226 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3227 "from Stand by",__func__);
3228 vos_Status = hdd_exit_standby(pHddCtx);
3229 }
3230 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3231 {
3232 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3233 "from deep sleep",__func__);
3234 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3235 }
3236 else
3237 {
3238 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3239 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3240 vos_Status = VOS_STATUS_SUCCESS;
3241 }
3242
3243 return vos_Status;
3244}
3245
3246VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3247{
3248 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3249
3250 if (NULL == pHddCtx)
3251 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303252 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 return VOS_STATUS_E_FAULT;
3254 }
3255
3256 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3257 {
3258 //Execute standby procedure.
3259 //Executing standby procedure will cause the STA to
3260 //disassociate first and then the chip will be put into standby.
3261 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3262 vos_Status = hdd_enter_standby(pHddCtx);
3263 }
3264 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3265 pHddCtx->cfg_ini->nEnableDriverStop)
3266 {
3267 //Execute deep sleep procedure
3268 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003269 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 //Deep sleep not supported
3271 vos_Status = hdd_enter_standby(pHddCtx);
3272 }
3273 else
3274 {
3275 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3276 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3277 vos_Status = VOS_STATUS_SUCCESS;
3278 }
3279
3280 return vos_Status;
3281}
3282
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003283
3284void* wlan_hdd_change_country_code_callback(void *pAdapter)
3285{
3286
3287 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003288 complete(&call_back_pAdapter->change_country_code);
3289
3290 return NULL;
3291}
3292
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303293static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 struct iw_request_info *info,
3295 union iwreq_data *wrqu, char *extra)
3296{
3297 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003298 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 int cmd_len = wrqu->data.length;
3300 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003301 int rc = 0;
3302 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3303
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3305
3306 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003307 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3308 wrqu->data.length);
3309 if (NULL == cmd)
3310 {
3311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3312 "mem_alloc_copy_from_user_helper fail");
3313 return -ENOMEM;
3314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003315
3316 if (ioctl_debug)
3317 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003318 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 }
3320
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003321 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3322 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003323
3324 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003325 if (ioctl_debug)
3326 {
3327 pr_info("%s: RESTART in progress\n", __func__);
3328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003329
Arif Hussain24bfa702014-01-22 13:51:30 -08003330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003332 kfree(cmd);
3333 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003334 }
3335
Arif Hussain24bfa702014-01-22 13:51:30 -08003336 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003338 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3340 "%s: Error in iw_set_scan!", __func__);
3341 rc = -EINVAL;
3342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 }
3344 else if( strcasecmp(cmd, "start") == 0 ) {
3345
Arif Hussain6d2a3322013-11-17 19:50:10 -08003346 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003348
Arif Hussain24bfa702014-01-22 13:51:30 -08003349 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3350 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 {
3352 union iwreq_data wrqu;
3353 char buf[10];
3354
3355 memset(&wrqu, 0, sizeof(wrqu));
3356 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3357 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3358 }
3359 else
3360 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003361 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3362 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 }
3364 goto done;
3365 }
3366 else if( strcasecmp(cmd, "stop") == 0 )
3367 {
3368 union iwreq_data wrqu;
3369 char buf[10];
3370
Arif Hussain6d2a3322013-11-17 19:50:10 -08003371 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003372
3373 wlan_hdd_enter_lowpower(pHddCtx);
3374 memset(&wrqu, 0, sizeof(wrqu));
3375 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3376 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 goto done;
3378 }
3379 else if (strcasecmp(cmd, "macaddr") == 0)
3380 {
3381 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3382 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3383 }
3384 else if (strcasecmp(cmd, "scan-active") == 0)
3385 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303386 hddLog(VOS_TRACE_LEVEL_ERROR,
3387 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003388 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 ret = snprintf(cmd, cmd_len, "OK");
3390 }
3391 else if (strcasecmp(cmd, "scan-passive") == 0)
3392 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303393 hddLog(VOS_TRACE_LEVEL_ERROR,
3394 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003395 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 ret = snprintf(cmd, cmd_len, "OK");
3397 }
3398 else if( strcasecmp(cmd, "scan-mode") == 0 )
3399 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003400 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 }
3402 else if( strcasecmp(cmd, "linkspeed") == 0 )
3403 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003404 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 }
3406 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3407 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003408 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003409 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003410
3411 country_code = cmd + 8;
3412
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003413 init_completion(&pAdapter->change_country_code);
3414
Arif Hussain24bfa702014-01-22 13:51:30 -08003415 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003416 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 country_code,
3418 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303419 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303420 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303421 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003422
3423 /* Wait for completion */
3424 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3425 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3426
3427 if (lrc <= 0)
3428 {
3429 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003430 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003431 }
3432
Arif Hussain24bfa702014-01-22 13:51:30 -08003433 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003435 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003436 "%s: SME Change Country code fail", __func__);
3437 kfree(cmd);
3438 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 }
3440 }
3441 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3442 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003443 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 }
3445 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3446 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003447 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003448
Wilson Yang1be3e652013-10-09 15:18:31 -07003449 if (9 < cmd_len)
3450 {
3451 ptr = (char*)(cmd + 9);
3452
3453 }else{
3454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3455 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003456 kfree(cmd);
3457 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003458 }
3459
3460 if (1 != sscanf(ptr,"%d",&mode))
3461 {
3462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3463 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003464 kfree(cmd);
3465 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003466 }
3467
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 wlan_hdd_enter_bmps(pAdapter, mode);
3469 /*TODO:Set the power mode*/
3470 }
3471 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3472 v_U32_t pmc_state;
3473 v_U16_t value;
3474
3475 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3476 if(pmc_state == BMPS) {
3477 value = DRIVER_POWER_MODE_AUTO;
3478 }
3479 else {
3480 value = DRIVER_POWER_MODE_ACTIVE;
3481 }
3482 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3483 }
3484 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003485 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 /*TODO: set the btcoexmode*/
3487 }
3488 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3489
Arif Hussain6d2a3322013-11-17 19:50:10 -08003490 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 /*TODO: Return the btcoex status*/
3492 }
3493 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3494
Arif Hussain6d2a3322013-11-17 19:50:10 -08003495 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003496
3497 /*TODO: Enable Rx data Filter*/
3498 }
3499 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3500
Arif Hussain6d2a3322013-11-17 19:50:10 -08003501 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003502
3503 /*TODO: Disable Rx data Filter*/
3504 }
3505 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3506
Arif Hussain6d2a3322013-11-17 19:50:10 -08003507 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 /*TODO: rxfilter-statistics*/
3509 }
3510 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3511
Arif Hussain6d2a3322013-11-17 19:50:10 -08003512 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 /*TODO: rxfilter-add*/
3514 }
3515 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3516
Arif Hussain6d2a3322013-11-17 19:50:10 -08003517 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 /*TODO: rxfilter-remove*/
3519 }
3520#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003521 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3522 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3523 /*TODO: support pnosetup*/
3524 }
3525 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3526 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3527 /*TODO: support pnoforce*/
3528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3530
Arif Hussain6d2a3322013-11-17 19:50:10 -08003531 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003532 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3533 kfree(cmd);
3534 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 }
3536 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003537 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003538 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3539 kfree(cmd);
3540 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 }
3542#endif /*FEATURE_WLAN_SCAN_PNO*/
3543 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003544 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003545 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3546 kfree(cmd);
3547 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 }
3549 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3550 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003551 char *ptr;
3552
3553 if (18 < cmd_len)
3554 {
3555 ptr = (char*)(cmd + 18);
3556 }else{
3557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3558 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003559 kfree(cmd);
3560 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003561 }
3562
Jeff Johnson02797792013-10-26 19:17:13 -07003563 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003564 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3565 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3566 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3567 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3568 {
3569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3570 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003571 kfree(cmd);
3572 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003574
3575 // parameters checking
3576 // period has to be larger than 0
3577 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3578 {
3579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003580 kfree(cmd);
3581 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 }
3583
3584 // use default value 5 is the input is not reasonable. in unit of 10%
3585 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3586 {
3587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3588 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3589 }
3590
3591 // default is 5
3592 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3593 {
3594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3595 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3596 }
3597
Arif Hussain24bfa702014-01-22 13:51:30 -08003598 if (eHAL_STATUS_SUCCESS !=
3599 sme_SetTxPerTracking(pHddCtx->hHal,
3600 hdd_tx_per_hit_cb,
3601 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003603 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 }
3605 }
3606 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003607 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3608 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 }
3610done:
3611 /* many of the commands write information back into the command
3612 string using snprintf(). check the return value here in one
3613 place */
3614 if ((ret < 0) || (ret >= cmd_len))
3615 {
3616 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003617 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003619 else if (ret > 0)
3620 {
3621 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3622 {
3623 hddLog(VOS_TRACE_LEVEL_ERROR,
3624 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003625 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003626 return -EFAULT;
3627 }
3628 wrqu->data.length = ret;
3629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003630
3631 if (ioctl_debug)
3632 {
3633 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003634 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003636 kfree(cmd);
3637 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003638}
3639
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303640static int iw_set_priv(struct net_device *dev,
3641 struct iw_request_info *info,
3642 union iwreq_data *wrqu, char *extra)
3643{
3644 int ret;
3645 vos_ssr_protect(__func__);
3646 ret = __iw_set_priv(dev, info, wrqu, extra);
3647 vos_ssr_unprotect(__func__);
3648
3649 return ret;
3650}
3651
Jeff Johnson295189b2012-06-20 16:38:30 -07003652static int iw_set_nick(struct net_device *dev,
3653 struct iw_request_info *info,
3654 union iwreq_data *wrqu, char *extra)
3655{
3656 ENTER();
3657 return 0;
3658}
3659
3660static int iw_get_nick(struct net_device *dev,
3661 struct iw_request_info *info,
3662 union iwreq_data *wrqu, char *extra)
3663{
3664 ENTER();
3665 return 0;
3666}
3667
3668static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3669{
3670 ENTER();
3671 return NULL;
3672}
3673
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303674static int __iw_set_encode(struct net_device *dev,
3675 struct iw_request_info *info,
3676 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003677
3678{
3679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3680 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3681 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3682 struct iw_point *encoderq = &(wrqu->encoding);
3683 v_U32_t keyId;
3684 v_U8_t key_length;
3685 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3686 v_BOOL_t fKeyPresent = 0;
3687 int i;
3688 eHalStatus status = eHAL_STATUS_SUCCESS;
3689
3690
3691 ENTER();
3692
3693 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3694 {
3695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3696 "%s:LOGP in Progress. Ignore!!!",__func__);
3697 return 0;
3698 }
3699
3700
3701 keyId = encoderq->flags & IW_ENCODE_INDEX;
3702
3703 if(keyId)
3704 {
3705 if(keyId > MAX_WEP_KEYS)
3706 {
3707 return -EINVAL;
3708 }
3709
3710 fKeyPresent = 1;
3711 keyId--;
3712 }
3713 else
3714 {
3715 fKeyPresent = 0;
3716 }
3717
3718
3719 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3720 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 if(!fKeyPresent) {
3723
3724 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3725
3726 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3727 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3728 }
3729 }
3730 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3731 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3732 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3733 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3734
3735 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3736 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3737
3738 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3739 {
3740 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3741 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003742 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303743 {
3744 long ret;
3745 ret = wait_for_completion_interruptible_timeout(
3746 &pAdapter->disconnect_comp_var,
3747 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3748 if (ret <= 0)
3749 hddLog(VOS_TRACE_LEVEL_ERROR,
3750 FL("failed wait on disconnect_comp_var %ld"), ret);
3751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 }
3753
3754 return status;
3755
3756 }
3757
3758 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3759 {
3760 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3761
3762 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3763
3764 }
3765
3766
3767 if(wrqu->data.length > 0)
3768 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003769 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003770
3771 key_length = wrqu->data.length;
3772
3773 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3774
3775 if(5 == key_length)
3776 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003777 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003778
3779 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3780 {
3781 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3782 }
3783 else
3784 {
3785 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3786 }
3787 }
3788 else if(13 == key_length)
3789 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003790 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003791
3792 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3793 {
3794 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3795 }
3796 else
3797 {
3798 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3799 }
3800 }
3801 else
3802 {
3803 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003804 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 return -EINVAL;
3806 }
3807
3808 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3809 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3810 pWextState->roamProfile.EncryptionType.numEntries = 1;
3811 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3812 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3813 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3814
3815 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3816 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3817 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3818 {
3819
3820 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3821
3822 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3823 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3824
3825 return status;
3826 }
3827 }
3828
3829 return 0;
3830}
3831
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303832static int iw_set_encode(struct net_device *dev,
3833 struct iw_request_info *info,
3834 union iwreq_data *wrqu,char *extra)
3835{
3836 int ret;
3837
3838 vos_ssr_protect(__func__);
3839 ret = __iw_set_encode(dev, info, wrqu, extra);
3840 vos_ssr_unprotect(__func__);
3841
3842 return ret;
3843}
3844
3845static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 struct iw_request_info *info,
3847 struct iw_point *dwrq,
3848 char *extra)
3849{
3850 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3851 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3852 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3853 int keyId;
3854 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3855 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3856 int i;
3857
3858 ENTER();
3859
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003860 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3861 {
3862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3863 "%s:LOGP in Progress. Ignore!!!", __func__);
3864 return -EBUSY;
3865 }
3866
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 keyId = pRoamProfile->Keys.defaultIndex;
3868
3869 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3870 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003871 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 return -EINVAL;
3873 }
3874
3875 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3876 {
3877 dwrq->flags |= IW_ENCODE_ENABLED;
3878 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303879 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3880 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 }
3882 else
3883 {
3884 dwrq->flags |= IW_ENCODE_DISABLED;
3885 }
3886
3887 for(i=0; i < MAX_WEP_KEYS; i++)
3888 {
3889 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3890 {
3891 continue;
3892 }
3893 else
3894 {
3895 break;
3896 }
3897 }
3898
3899 if(MAX_WEP_KEYS == i)
3900 {
3901 dwrq->flags |= IW_ENCODE_NOKEY;
3902 }
3903 else
3904 {
3905 dwrq->flags |= IW_ENCODE_ENABLED;
3906 }
3907
3908 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3909
3910 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3911 {
3912 dwrq->flags |= IW_ENCODE_DISABLED;
3913 }
3914
3915 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3916
3917 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3918 {
3919 dwrq->flags |= IW_ENCODE_OPEN;
3920 }
3921 else
3922 {
3923 dwrq->flags |= IW_ENCODE_RESTRICTED;
3924 }
3925 EXIT();
3926 return 0;
3927
3928}
3929
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303930static int iw_get_encodeext(struct net_device *dev,
3931 struct iw_request_info *info,
3932 struct iw_point *dwrq,
3933 char *extra)
3934{
3935 int ret;
3936 vos_ssr_protect(__func__);
3937 ret = __iw_get_encodeext(dev, info, dwrq, extra);
3938 vos_ssr_unprotect(__func__);
3939
3940 return ret;
3941}
3942
3943static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 struct iw_request_info *info,
3945 union iwreq_data *wrqu, char *extra)
3946{
3947 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3948 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3949 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3950 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3951
3952 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3953 v_U32_t status = 0;
3954
3955 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3956
3957 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3958
3959 int key_index;
3960 struct iw_point *encoding = &wrqu->encoding;
3961 tCsrRoamSetKey setKey;
3962 v_U32_t roamId= 0xFF;
3963 VOS_STATUS vos_status;
3964
3965 ENTER();
3966
3967 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3968 {
3969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3970 "%s:LOGP in Progress. Ignore!!!",__func__);
3971 return 0;
3972 }
3973
3974 key_index = encoding->flags & IW_ENCODE_INDEX;
3975
3976 if(key_index > 0) {
3977
3978 /*Convert from 1-based to 0-based keying*/
3979 key_index--;
3980 }
3981 if(!ext->key_len) {
3982
3983 /*Set the encrytion type to NONE*/
3984 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3985 return status;
3986 }
3987
3988 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3989 (IW_ENCODE_ALG_WEP == ext->alg))
3990 {
3991 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3992
Agarwal Ashish971c2882013-10-30 20:11:12 +05303993 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3994 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 return -EINVAL;
3996 }
3997 else {
3998 /*Static wep, update the roam profile with the keys */
3999 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4000 key_index < CSR_MAX_NUM_KEY) {
4001 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4002 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4003
4004 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4005 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4006
4007 }
4008 }
4009 return status;
4010 }
4011
4012 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4013
4014 setKey.keyId = key_index;
4015 setKey.keyLength = ext->key_len;
4016
4017 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4018 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4019 }
4020
4021 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4022 /*Key direction for group is RX only*/
4023 setKey.keyDirection = eSIR_RX_ONLY;
4024 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4025 }
4026 else {
4027
4028 setKey.keyDirection = eSIR_TX_RX;
4029 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4030 }
4031
4032 /*For supplicant pae role is zero*/
4033 setKey.paeRole = 0;
4034
4035 switch(ext->alg)
4036 {
4037 case IW_ENCODE_ALG_NONE:
4038 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4039 break;
4040
4041 case IW_ENCODE_ALG_WEP:
4042 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4043 break;
4044
4045 case IW_ENCODE_ALG_TKIP:
4046 {
4047 v_U8_t *pKey = &setKey.Key[0];
4048
4049 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4050
4051 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4052
4053 /*Supplicant sends the 32bytes key in this order
4054
4055 |--------------|----------|----------|
4056 | Tk1 |TX-MIC | RX Mic |
4057 |--------------|----------|----------|
4058 <---16bytes---><--8bytes--><--8bytes-->
4059
4060 */
4061 /*Sme expects the 32 bytes key to be in the below order
4062
4063 |--------------|----------|----------|
4064 | Tk1 |RX-MIC | TX Mic |
4065 |--------------|----------|----------|
4066 <---16bytes---><--8bytes--><--8bytes-->
4067 */
4068 /* Copy the Temporal Key 1 (TK1) */
4069 vos_mem_copy(pKey,ext->key,16);
4070
4071 /*Copy the rx mic first*/
4072 vos_mem_copy(&pKey[16],&ext->key[24],8);
4073
4074 /*Copy the tx mic */
4075 vos_mem_copy(&pKey[24],&ext->key[16],8);
4076
4077 }
4078 break;
4079
4080 case IW_ENCODE_ALG_CCMP:
4081 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4082 break;
4083
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004084#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004085#define IW_ENCODE_ALG_KRK 6
4086 case IW_ENCODE_ALG_KRK:
4087 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4088 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004089#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004090
4091 default:
4092 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4093 break;
4094 }
4095
4096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004097 ("%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 -07004098
4099#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304100 /* The supplicant may attempt to set the PTK once pre-authentication
4101 is done. Save the key in the UMAC and include it in the ADD
4102 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304104 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304106 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4107 "%s: Update PreAuth Key success", __func__);
4108 return 0;
4109 }
4110 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4111 {
4112 hddLog(VOS_TRACE_LEVEL_ERROR,
4113 "%s: Update PreAuth Key failed", __func__);
4114 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 }
4116#endif /* WLAN_FEATURE_VOWIFI_11R */
4117
4118 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4119
4120 vos_status = wlan_hdd_check_ula_done(pAdapter);
4121 if ( vos_status != VOS_STATUS_SUCCESS )
4122 {
4123 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4124 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4125 __LINE__, vos_status );
4126
4127 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4128 }
4129
4130 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4131
4132 if ( halStatus != eHAL_STATUS_SUCCESS )
4133 {
4134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4135 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4136 __LINE__, halStatus );
4137
4138 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4139 }
4140
4141 return halStatus;
4142}
4143
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304144static int iw_set_encodeext(struct net_device *dev,
4145 struct iw_request_info *info,
4146 union iwreq_data *wrqu, char *extra)
4147{
4148 int ret;
4149
4150 vos_ssr_protect(__func__);
4151 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4152 vos_ssr_unprotect(__func__);
4153
4154 return ret;
4155}
4156
4157static int __iw_set_retry(struct net_device *dev,
4158 struct iw_request_info *info,
4159 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004160{
4161 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4162 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4163
4164 ENTER();
4165
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004166 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4167 {
4168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4169 "%s:LOGP in Progress. Ignore!!!", __func__);
4170 return -EBUSY;
4171 }
4172
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4174 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4175
Arif Hussain6d2a3322013-11-17 19:50:10 -08004176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004177
4178 return -EINVAL;
4179 }
4180
4181 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
4182
4183 if((wrqu->retry.flags & IW_RETRY_LONG))
4184 {
4185 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4186 {
c_hpothub8245442013-11-20 23:41:09 +05304187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4188 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 return -EIO;
4190 }
4191 }
4192 else if((wrqu->retry.flags & IW_RETRY_SHORT))
4193 {
4194 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4195 {
c_hpothub8245442013-11-20 23:41:09 +05304196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4197 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 return -EIO;
4199 }
4200 }
4201 }
4202 else
4203 {
4204 return -EOPNOTSUPP;
4205 }
4206
Arif Hussain6d2a3322013-11-17 19:50:10 -08004207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208
4209 EXIT();
4210
4211 return 0;
4212
4213}
4214
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304215static int iw_set_retry(struct net_device *dev,
4216 struct iw_request_info *info,
4217 union iwreq_data *wrqu, char *extra)
4218{
4219 int ret;
4220
4221 vos_ssr_protect(__func__);
4222 ret = __iw_set_retry(dev, info, wrqu, extra);
4223 vos_ssr_unprotect(__func__);
4224
4225 return ret;
4226}
4227
4228static int __iw_get_retry(struct net_device *dev,
4229 struct iw_request_info *info,
4230 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004231{
4232 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4233 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4234 v_U32_t retry = 0;
4235
4236 ENTER();
4237
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004238 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4239 {
4240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4241 "%s:LOGP in Progress. Ignore!!!", __func__);
4242 return -EBUSY;
4243 }
4244
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 if((wrqu->retry.flags & IW_RETRY_LONG))
4246 {
4247 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4248
4249 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
4250 {
c_hpothub8245442013-11-20 23:41:09 +05304251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4252 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 return -EIO;
4254 }
4255
4256 wrqu->retry.value = retry;
4257 }
4258 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
4259 {
4260 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4261
4262 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
4263 {
c_hpothub8245442013-11-20 23:41:09 +05304264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4265 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 return -EIO;
4267 }
4268
4269 wrqu->retry.value = retry;
4270 }
4271 else {
4272 return -EOPNOTSUPP;
4273 }
4274
Arif Hussain6d2a3322013-11-17 19:50:10 -08004275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004276
4277 EXIT();
4278
4279 return 0;
4280}
4281
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304282static int iw_get_retry(struct net_device *dev,
4283 struct iw_request_info *info,
4284 union iwreq_data *wrqu, char *extra)
4285{
4286 int ret;
4287
4288 vos_ssr_protect(__func__);
4289 ret = __iw_get_retry(dev, info, wrqu, extra);
4290 vos_ssr_unprotect(__func__);
4291
4292 return ret;
4293}
4294
4295static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 struct iw_request_info *info,
4297 union iwreq_data *wrqu,
4298 char *extra)
4299{
4300 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4301 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4302 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4303 eHalStatus status = eHAL_STATUS_SUCCESS;
4304
4305 ENTER();
4306
4307 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4308 {
4309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4310 "%s:LOGP in Progress. Ignore!!!",__func__);
4311 return 0;
4312 }
4313
4314 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4315 switch (mlme->cmd) {
4316 case IW_MLME_DISASSOC:
4317 case IW_MLME_DEAUTH:
4318
4319 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
4320 {
4321 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4322
4323 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4324 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4325
4326 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4327 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
4328
Jeff Johnson43971f52012-07-17 12:26:56 -07004329 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304330 {
4331 long ret;
4332 ret = wait_for_completion_interruptible_timeout(
4333 &pAdapter->disconnect_comp_var,
4334 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4335 if (ret <= 0)
4336 hddLog(VOS_TRACE_LEVEL_ERROR,
4337 FL("failed wait on disconnect_comp_var %ld"), ret);
4338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08004340 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004341 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07004342
4343 /* Resetting authKeyMgmt */
4344 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
4345
4346 netif_tx_disable(dev);
4347 netif_carrier_off(dev);
4348
4349 }
4350 else
4351 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004352 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 -07004353 }
4354 break;
4355 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004356 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 return -EINVAL;
4358 }//end of switch
4359
4360 EXIT();
4361
4362 return status;
4363
4364}
4365
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304366static int iw_set_mlme(struct net_device *dev,
4367 struct iw_request_info *info,
4368 union iwreq_data *wrqu,
4369 char *extra)
4370{
4371 int ret;
4372
4373 vos_ssr_protect(__func__);
4374 ret = __iw_set_mlme(dev, info, wrqu, extra);
4375 vos_ssr_unprotect(__func__);
4376
4377 return ret;
4378}
4379
Jeff Johnson295189b2012-06-20 16:38:30 -07004380/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304381static int __iw_setint_getnone(struct net_device *dev,
4382 struct iw_request_info *info,
4383 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004384{
4385 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4386 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4387 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4388 int *value = (int *)extra;
4389 int sub_cmd = value[0];
4390 int set_value = value[1];
4391 int ret = 0; /* success */
4392 int enable_pbm, enable_mp;
4393#ifdef CONFIG_HAS_EARLYSUSPEND
4394 v_U8_t nEnableSuspendOld;
4395#endif
4396 INIT_COMPLETION(pWextState->completion_var);
4397
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004398 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4399 {
4400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4401 "%s:LOGP in Progress. Ignore!!!", __func__);
4402 return -EBUSY;
4403 }
4404
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 switch(sub_cmd)
4406 {
4407 case WE_SET_11D_STATE:
4408 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004409 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004410 memset(&smeConfig, 0x00, sizeof(smeConfig));
4411
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4413
4414 sme_GetConfigParam(hHal,&smeConfig);
4415 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4416
Arif Hussain6d2a3322013-11-17 19:50:10 -08004417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004418
4419 sme_UpdateConfig(hHal,&smeConfig);
4420 }
4421 else {
4422 return -EINVAL;
4423 }
4424 break;
4425 }
4426
4427 case WE_WOWL:
4428 {
4429 switch (set_value)
4430 {
4431 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05304432 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 break;
4434 case 0x01:
4435 case 0x02:
4436 case 0x03:
4437 enable_mp = (set_value & 0x01) ? 1 : 0;
4438 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004439 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4441 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4442 break;
4443 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004444 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 ret = -EINVAL;
4446 break;
4447 }
4448
4449 break;
4450 }
4451 case WE_SET_POWER:
4452 {
4453 switch (set_value)
4454 {
4455 case 0: //Full Power
4456 {
4457 struct statsContext context;
4458 eHalStatus status;
4459
4460 init_completion(&context.completion);
4461
4462 context.pAdapter = pAdapter;
4463 context.magic = POWER_CONTEXT_MAGIC;
4464
4465 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4466 iw_power_callback_fn, &context,
4467 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004468 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 {
4470 int lrc = wait_for_completion_interruptible_timeout(
4471 &context.completion,
4472 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004473
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 if (lrc <= 0)
4475 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004476 hddLog(VOS_TRACE_LEVEL_ERROR,
4477 "%s: SME %s while requesting fullpower",
4478 __func__, (0 == lrc) ?
4479 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 }
4481 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004482 /* either we have a response or we timed out. if we timed
4483 out there is a race condition such that the callback
4484 function could be executing at the same time we are. of
4485 primary concern is if the callback function had already
4486 verified the "magic" but had not yet set the completion
4487 variable when a timeout occurred. we serialize these
4488 activities by invalidating the magic while holding a
4489 shared spinlock which will cause us to block if the
4490 callback is currently executing */
4491 spin_lock(&hdd_context_lock);
4492 context.magic = 0;
4493 spin_unlock(&hdd_context_lock);
4494
Arif Hussain6d2a3322013-11-17 19:50:10 -08004495 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 break;
4497 }
4498 case 1: //Enable BMPS
4499 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4500 break;
4501 case 2: //Disable BMPS
4502 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4503 break;
4504 case 3: //Request Bmps
4505 {
4506 struct statsContext context;
4507 eHalStatus status;
4508
4509 init_completion(&context.completion);
4510
4511 context.pAdapter = pAdapter;
4512 context.magic = POWER_CONTEXT_MAGIC;
4513
4514 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4515 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004516 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 {
4518 int lrc = wait_for_completion_interruptible_timeout(
4519 &context.completion,
4520 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 if (lrc <= 0)
4522 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004523 hddLog(VOS_TRACE_LEVEL_ERROR,
4524 "%s: SME %s while requesting BMPS",
4525 __func__, (0 == lrc) ? "timeout" :
4526 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 }
4528 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004529 /* either we have a response or we timed out. if we
4530 timed out there is a race condition such that the
4531 callback function could be executing at the same
4532 time we are. of primary concern is if the callback
4533 function had already verified the "magic" but had
4534 not yet set the completion variable when a timeout
4535 occurred. we serialize these activities by
4536 invalidating the magic while holding a shared
4537 spinlock which will cause us to block if the
4538 callback is currently executing */
4539 spin_lock(&hdd_context_lock);
4540 context.magic = 0;
4541 spin_unlock(&hdd_context_lock);
4542
Arif Hussain6d2a3322013-11-17 19:50:10 -08004543 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 break;
4545 }
4546 case 4: //Enable IMPS
4547 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4548 break;
4549 case 5: //Disable IMPS
4550 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4551 break;
4552 case 6: //Enable Standby
4553 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4554 break;
4555 case 7: //Disable Standby
4556 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4557 break;
4558 case 8: //Request Standby
4559#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004560#endif
4561 break;
4562 case 9: //Start Auto Bmps Timer
4563 sme_StartAutoBmpsTimer(hHal);
4564 break;
4565 case 10://Stop Auto BMPS Timer
4566 sme_StopAutoBmpsTimer(hHal);
4567 break;
4568#ifdef CONFIG_HAS_EARLYSUSPEND
4569 case 11://suspend to standby
4570#ifdef CONFIG_HAS_EARLYSUSPEND
4571 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4572 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4574#endif
4575 break;
4576 case 12://suspend to deep sleep
4577#ifdef CONFIG_HAS_EARLYSUSPEND
4578 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4579 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4581#endif
4582 break;
4583 case 13://resume from suspend
4584#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004585#endif
4586 break;
4587#endif
4588 case 14://reset wlan (power down/power up)
4589 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4590 break;
4591 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004592 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 ret = -EINVAL;
4594 break;
4595 }
4596 break;
4597 }
4598
4599 case WE_SET_MAX_ASSOC:
4600 {
4601 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4602 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4603 {
4604 ret = -EINVAL;
4605 }
4606 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4607 set_value, NULL, eANI_BOOLEAN_FALSE)
4608 != eHAL_STATUS_SUCCESS )
4609 {
c_hpothub8245442013-11-20 23:41:09 +05304610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4611 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 ret = -EIO;
4613 }
4614 break;
4615 }
4616
4617 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4618 {
4619 if( 0 == set_value )
4620 {
4621 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4622 }
4623 else if ( 1 == set_value )
4624 {
4625 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4626 }
4627 else
4628 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004629 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 ret = -EINVAL;
4631 }
4632 break;
4633 }
4634
4635 case WE_SET_DATA_INACTIVITY_TO:
4636 {
4637 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4638 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4639 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4640 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4641 set_value,
4642 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4643 {
4644 hddLog(LOGE,"Failure: Could not pass on "
4645 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004646 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 ret = -EINVAL;
4648 }
4649 break;
4650 }
4651 case WE_SET_MAX_TX_POWER:
4652 {
4653 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4654 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4655
4656 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4657 __func__, set_value);
4658 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4659 eHAL_STATUS_SUCCESS )
4660 {
4661 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4662 __func__);
4663 return -EIO;
4664 }
4665
4666 break;
4667 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004668 case WE_SET_MAX_TX_POWER_2_4:
4669 {
4670 hddLog(VOS_TRACE_LEVEL_INFO,
4671 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4672 __func__, set_value);
4673 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4674 eHAL_STATUS_SUCCESS)
4675 {
4676 hddLog(VOS_TRACE_LEVEL_ERROR,
4677 "%s: Setting maximum tx power failed for 2.4 GHz band",
4678 __func__);
4679 return -EIO;
4680 }
4681
4682 break;
4683 }
4684 case WE_SET_MAX_TX_POWER_5_0:
4685 {
4686 hddLog(VOS_TRACE_LEVEL_INFO,
4687 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4688 __func__, set_value);
4689 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4690 eHAL_STATUS_SUCCESS)
4691 {
4692 hddLog(VOS_TRACE_LEVEL_ERROR,
4693 "%s: Setting maximum tx power failed for 5.0 GHz band",
4694 __func__);
4695 return -EIO;
4696 }
4697
4698 break;
4699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 case WE_SET_HIGHER_DTIM_TRANSITION:
4701 {
4702 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4703 (set_value == eANI_BOOLEAN_TRUE)))
4704 {
4705 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4706 ret = -EINVAL;
4707 }
4708 else
4709 {
4710 if(pAdapter->higherDtimTransition != set_value)
4711 {
4712 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004713 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 }
4715 }
4716
4717 break;
4718 }
4719
4720 case WE_SET_TM_LEVEL:
4721 {
4722 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004723 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4725
4726 break;
4727 }
4728
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304729 case WE_ENABLE_STRICT_FCC_REG:
4730 {
4731 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4732 struct wiphy *wiphy = NULL;
4733 long lrc;
4734 int status;
4735
4736 wiphy = hddCtxt->wiphy;
4737 if(wiphy == NULL)
4738 {
4739 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4740 break;
4741 }
4742 init_completion(&hddCtxt->wiphy_channel_update_event);
4743
4744 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4745
4746 status = regulatory_hint(wiphy, "00");
4747 if(status < 0)
4748 {
4749 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4750 break;
4751 }
4752
4753 /* Wait for completion */
4754 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4755 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4756 if (lrc <= 0)
4757 {
4758 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4759 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4760 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4761 }
4762 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4763
4764 break;
4765 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004766 case WE_SET_DEBUG_LOG:
4767 {
4768 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4769 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4770 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4771 break;
4772 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05304773#ifdef FEATURE_WLAN_TDLS
4774 case WE_SET_TDLS_OFF_CHAN:
4775 {
4776 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
4778 __func__, set_value);
4779 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
4780 break;
4781 }
4782 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
4783 {
4784 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
4786 __func__, set_value);
4787 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
4788 break;
4789 }
4790 case WE_SET_TDLS_OFF_CHAN_MODE:
4791 {
4792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
4793 __func__, set_value);
4794 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
4795 break;
4796 }
4797#endif
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304798
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 default:
4800 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004801 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 sub_cmd, set_value);
4803 break;
4804 }
4805 }
4806
4807 return ret;
4808}
4809
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304810static int iw_setint_getnone(struct net_device *dev,
4811 struct iw_request_info *info,
4812 union iwreq_data *wrqu, char *extra)
4813{
4814 int ret;
4815
4816 vos_ssr_protect(__func__);
4817 ret = __iw_setint_getnone(dev, info, wrqu, extra);
4818 vos_ssr_unprotect(__func__);
4819
4820 return 0;
4821}
Jeff Johnson295189b2012-06-20 16:38:30 -07004822/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304823static int __iw_setchar_getnone(struct net_device *dev,
4824 struct iw_request_info *info,
4825 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004826{
4827 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05304828 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004830 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4832 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4833#ifdef WLAN_FEATURE_VOWIFI
4834 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4835#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05304836 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07004837
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004838 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4839 {
4840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4841 "%s:LOGP in Progress. Ignore!!!", __func__);
4842 return -EBUSY;
4843 }
4844
Girish Gowli552fc072014-06-14 18:26:16 +05304845 /* helper function to get iwreq_data with compat handling. */
4846 if (hdd_priv_get_data(&s_priv_data, wrqu))
4847 {
4848 return -EINVAL;
4849 }
4850
4851 /* make sure all params are correctly passed to function */
4852 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
4853 {
4854 return -EINVAL;
4855 }
4856
4857 sub_cmd = s_priv_data.flags;
4858
Arif Hussain0273cba2014-01-07 20:58:29 -08004859 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05304860 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
4861 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004862 if (NULL == pBuffer)
4863 {
4864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4865 "mem_alloc_copy_from_user_helper fail");
4866 return -ENOMEM;
4867 }
4868
4869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05304870 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4872 "%s: Received data %s", __func__, pBuffer);
4873
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 switch(sub_cmd)
4875 {
4876 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004878 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 break;
4880 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004882 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 break;
4884#if defined WLAN_FEATURE_VOWIFI
4885 case WE_NEIGHBOR_REPORT_REQUEST:
4886 {
4887 tRrmNeighborReq neighborReq;
4888 tRrmNeighborRspCallbackInfo callbackInfo;
4889
4890 if (pConfig->fRrmEnable)
4891 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05304893 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 if( !neighborReq.no_ssid )
4895 {
Girish Gowli552fc072014-06-14 18:26:16 +05304896 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004897 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 }
4899
4900 callbackInfo.neighborRspCallback = NULL;
4901 callbackInfo.neighborRspCallbackContext = NULL;
4902 callbackInfo.timeout = 5000; //5 seconds
4903 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4904 }
4905 else
4906 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004907 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 ret = -EINVAL;
4909 }
4910 }
4911 break;
4912#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 case WE_SET_AP_WPS_IE:
4914 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05304915 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004918 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 if (VOS_STATUS_SUCCESS != vstatus)
4920 {
4921 ret = -EINVAL;
4922 }
4923 break;
4924 default:
4925 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004926 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 ret = -EINVAL;
4928 break;
4929 }
4930 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004931 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 return ret;
4933}
4934
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304935static int iw_setchar_getnone(struct net_device *dev,
4936 struct iw_request_info *info,
4937 union iwreq_data *wrqu, char *extra)
4938{
4939 int ret;
4940
4941 vos_ssr_protect(__func__);
4942 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
4943 vos_ssr_unprotect(__func__);
4944
4945 return ret;
4946}
4947
Jeff Johnson295189b2012-06-20 16:38:30 -07004948/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304949static int __iw_setnone_getint(struct net_device *dev,
4950 struct iw_request_info *info,
4951 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004952{
4953 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4954 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4955 int *value = (int *)extra;
4956 int ret = 0; /* success */
4957
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004958 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4959 {
4960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4961 "%s:LOGP in Progress. Ignore!!!", __func__);
4962 return -EBUSY;
4963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004964
4965 switch (value[0])
4966 {
4967 case WE_GET_11D_STATE:
4968 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004969 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304971
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4973
Arif Hussain6d2a3322013-11-17 19:50:10 -08004974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975
4976 break;
4977 }
4978
4979 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 break;
4982
4983 case WE_PMC_STATE:
4984 {
4985 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 break;
4988 }
4989 case WE_GET_WLAN_DBG:
4990 {
4991 vos_trace_display();
4992 *value = 0;
4993 break;
4994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 case WE_GET_MAX_ASSOC:
4996 {
4997 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4998 {
c_hpothub8245442013-11-20 23:41:09 +05304999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5000 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 ret = -EIO;
5002 }
5003 break;
5004 }
5005
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 case WE_GET_WDI_DBG:
5007 {
5008 wpalTraceDisplay();
5009 *value = 0;
5010 break;
5011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005012
5013 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
5014 {
5015 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
5016 break;
5017 }
5018 case WE_GET_CONCURRENCY_MODE:
5019 {
5020 *value = hdd_get_concurrency_mode ( );
5021
Arif Hussain6d2a3322013-11-17 19:50:10 -08005022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 break;
5024 }
5025
5026 default:
5027 {
5028 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
5029 break;
5030 }
5031 }
5032
5033 return ret;
5034}
5035
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305036static int iw_setnone_getint(struct net_device *dev,
5037 struct iw_request_info *info,
5038 union iwreq_data *wrqu, char *extra)
5039{
5040 int ret;
5041
5042 vos_ssr_protect(__func__);
5043 ret = __iw_setnone_getint(dev, info, wrqu, extra);
5044 vos_ssr_unprotect(__func__);
5045
5046 return ret;
5047
5048}
Jeff Johnson295189b2012-06-20 16:38:30 -07005049/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305050int __iw_set_three_ints_getnone(struct net_device *dev,
5051 struct iw_request_info *info,
5052 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005053{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005054 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 int *value = (int *)extra;
5056 int sub_cmd = value[0];
5057 int ret = 0;
5058
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005059 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5060 {
5061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5062 "%s:LOGP in Progress. Ignore!!!", __func__);
5063 return -EBUSY;
5064 }
5065
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 switch(sub_cmd)
5067 {
5068 case WE_SET_WLAN_DBG:
5069 {
5070 vos_trace_setValue( value[1], value[2], value[3]);
5071 break;
5072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 case WE_SET_WDI_DBG:
5074 {
5075 wpalTraceSetLevel( value[1], value[2], value[3]);
5076 break;
5077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 case WE_SET_SAP_CHANNELS:
5079 {
5080 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
5081 break;
5082 }
5083
5084 default:
5085 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005086 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 break;
5088 }
5089 }
5090 return ret;
5091}
5092
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305093int iw_set_three_ints_getnone(struct net_device *dev,
5094 struct iw_request_info *info,
5095 union iwreq_data *wrqu, char *extra)
5096{
5097 int ret;
5098
5099 vos_ssr_protect(__func__);
5100 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
5101 vos_ssr_unprotect(__func__);
5102
5103 return ret;
5104}
5105
5106static int __iw_get_char_setnone(struct net_device *dev,
5107 struct iw_request_info *info,
5108 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005109{
5110 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5111 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07005112#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005113 hdd_wext_state_t *pWextState;
5114#endif
5115
5116 if (pAdapter == NULL)
5117 {
5118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5119 "%s: pAdapter is NULL!", __func__);
5120 return -EINVAL;
5121 }
5122#ifdef WLAN_FEATURE_11W
5123 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07005124#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005125
Yue Ma3ede6052013-08-29 00:33:26 -07005126 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
5127 {
5128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5129 "%s: HDD Context is NULL!", __func__);
5130
5131 return -EINVAL;
5132 }
5133
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005134 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5135 {
5136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5137 "%s:LOGP in Progress. Ignore!!!", __func__);
5138 return -EBUSY;
5139 }
5140
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 switch(sub_cmd)
5142 {
5143 case WE_WLAN_VERSION:
5144 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08005145 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 break;
5147 }
5148
5149 case WE_GET_STATS:
5150 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305151 tHalHandle hHal = NULL;
5152 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5154 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
5155 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
5156
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305157
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 snprintf(extra, WE_MAX_STR_LEN,
5159 "\nTransmit"
5160 "\ncalled %u, dropped %u, backpressured %u, queued %u"
5161 "\n dropped BK %u, BE %u, VI %u, VO %u"
5162 "\n classified BK %u, BE %u, VI %u, VO %u"
5163 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
5164 "\n queued BK %u, BE %u, VI %u, VO %u"
5165 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07005166 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 "\n fetched BK %u, BE %u, VI %u, VO %u"
5168 "\n dequeued BK %u, BE %u, VI %u, VO %u"
5169 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07005170 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 "\n flushed BK %u, BE %u, VI %u, VO %u"
5172 "\n\nReceive"
5173 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
5174 "\n\nResetsStats"
5175 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
5176 "\n",
5177 pStats->txXmitCalled,
5178 pStats->txXmitDropped,
5179 pStats->txXmitBackPressured,
5180 pStats->txXmitQueued,
5181
5182 pStats->txXmitDroppedAC[WLANTL_AC_BK],
5183 pStats->txXmitDroppedAC[WLANTL_AC_BE],
5184 pStats->txXmitDroppedAC[WLANTL_AC_VI],
5185 pStats->txXmitDroppedAC[WLANTL_AC_VO],
5186
5187 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
5188 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
5189 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
5190 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
5191
5192 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
5193 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
5194 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
5195 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
5196
5197 pStats->txXmitQueuedAC[WLANTL_AC_BK],
5198 pStats->txXmitQueuedAC[WLANTL_AC_BE],
5199 pStats->txXmitQueuedAC[WLANTL_AC_VI],
5200 pStats->txXmitQueuedAC[WLANTL_AC_VO],
5201
5202 pStats->txFetched,
5203 pStats->txFetchEmpty,
5204 pStats->txFetchLowResources,
5205 pStats->txFetchDequeueError,
5206
5207 pStats->txFetchDequeued,
5208 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07005209 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 pStats->txCompleted,
5211 pStats->txFlushed,
5212
5213 pStats->txFetchedAC[WLANTL_AC_BK],
5214 pStats->txFetchedAC[WLANTL_AC_BE],
5215 pStats->txFetchedAC[WLANTL_AC_VI],
5216 pStats->txFetchedAC[WLANTL_AC_VO],
5217
5218 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
5219 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
5220 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
5221 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
5222
5223 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
5224 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
5225 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
5226 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
5227
Ravi Joshi41914632013-10-21 23:02:21 -07005228 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
5229 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
5230 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
5231 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
5232
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 pStats->txFlushedAC[WLANTL_AC_BK],
5234 pStats->txFlushedAC[WLANTL_AC_BE],
5235 pStats->txFlushedAC[WLANTL_AC_VI],
5236 pStats->txFlushedAC[WLANTL_AC_VO],
5237
5238 pStats->rxChains,
5239 pStats->rxPackets,
5240 pStats->rxDropped,
5241 pStats->rxDelivered,
5242 pStats->rxRefused,
5243
5244 pResetStats->totalLogpResets,
5245 pResetStats->totalCMD53Failures,
5246 pResetStats->totalMutexReadFailures,
5247 pResetStats->totalMIFErrorFailures,
5248 pResetStats->totalFWHearbeatFailures,
5249 pResetStats->totalUnknownExceptions
5250 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305251 wrqu->data.length = strlen(extra);
5252
5253 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
5254
5255 if (hHal)
5256 pMac = PMAC_STRUCT( hHal );
5257
5258 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
5259 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
5260 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05305261 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
5262 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
5263 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
5264 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305265 "\n",
5266 pMac->pmm.BmpscntSleep,
5267 pMac->pmm.BmpscntAwake,
5268 pMac->pmm.BmpsSleeReqFailCnt,
5269 pMac->pmm.BmpsWakeupReqFailCnt,
5270 pMac->pmm.ImpsCntSleep,
5271 pMac->pmm.ImpsCntAwake,
5272 pMac->pmm.ImpsSleepErrCnt,
5273 pMac->pmm.ImpsWakeupErrCnt,
5274 pMac->pmm.ImpsLastErr
5275 );
5276 }
5277
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 wrqu->data.length = strlen(extra)+1;
5279 break;
5280 }
5281
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305282/* The case prints the current state of the HDD, SME, CSR, PE, TL
5283 *it can be extended for WDI Global State as well.
5284 *And currently it only checks P2P_CLIENT adapter.
5285 *P2P_DEVICE and P2P_GO have not been added as of now.
5286*/
5287 case WE_GET_STATES:
5288 {
5289 int buf = 0, len = 0;
5290 int adapter_num = 0;
5291 int count = 0, check = 1;
5292
5293 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005294 tHalHandle hHal = NULL;
5295 tpAniSirGlobal pMac = NULL;
5296 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305297
5298 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5299 hdd_adapter_t *useAdapter = NULL;
5300
5301 /* Print wlan0 or p2p0 states based on the adapter_num
5302 *by using the correct adapter
5303 */
5304 while ( adapter_num < 2 )
5305 {
5306 if ( WLAN_ADAPTER == adapter_num )
5307 {
5308 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005309 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305310 "\n\n wlan0 States:-");
5311 len += buf;
5312 }
5313 else if ( P2P_ADAPTER == adapter_num )
5314 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005315 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305316 "\n\n p2p0 States:-");
5317 len += buf;
5318
5319 if( !pHddCtx )
5320 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005321 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305322 "\n pHddCtx is NULL");
5323 len += buf;
5324 break;
5325 }
5326
5327 /*Printing p2p0 states only in the case when the device is
5328 configured as a p2p_client*/
5329 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
5330 if ( !useAdapter )
5331 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005332 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305333 "\n Device not configured as P2P_CLIENT.");
5334 len += buf;
5335 break;
5336 }
5337 }
5338
5339 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005340 if (!hHal) {
5341 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5342 "\n pMac is NULL");
5343 len += buf;
5344 break;
5345 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305346 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005347 if (!pMac) {
5348 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5349 "\n pMac is NULL");
5350 len += buf;
5351 break;
5352 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305353 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
5354 if( !pHddStaCtx )
5355 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005356 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305357 "\n pHddStaCtx is NULL");
5358 len += buf;
5359 break;
5360 }
5361
5362 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
5363
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005364 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305365 "\n HDD Conn State - %s "
5366 "\n \n SME State:"
5367 "\n Neighbour Roam State - %s"
5368 "\n CSR State - %s"
5369 "\n CSR Substate - %s"
5370 "\n \n TL STA %d State: %s",
5371 macTraceGetHDDWlanConnState(
5372 pHddStaCtx->conn_info.connState),
5373 macTraceGetNeighbourRoamState(
5374 pMac->roam.neighborRoamInfo.neighborRoamState),
5375 macTraceGetcsrRoamState(
5376 pMac->roam.curState[useAdapter->sessionId]),
5377 macTraceGetcsrRoamSubState(
5378 pMac->roam.curSubState[useAdapter->sessionId]),
5379 pHddStaCtx->conn_info.staId[0],
5380 macTraceGetTLState(tlState)
5381 );
5382 len += buf;
5383 adapter_num++;
5384 }
5385
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005386 if (pMac) {
5387 /* Printing Lim State starting with global lim states */
5388 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5389 "\n \n LIM STATES:-"
5390 "\n Global Sme State - %s "\
5391 "\n Global mlm State - %s "\
5392 "\n",
5393 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
5394 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
5395 );
5396 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305397
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005398 /*printing the PE Sme and Mlm states for valid lim sessions*/
5399 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305400 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005401 if ( pMac->lim.gpSession[count].valid )
5402 {
5403 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5404 "\n Lim Valid Session %d:-"
5405 "\n PE Sme State - %s "
5406 "\n PE Mlm State - %s "
5407 "\n",
5408 check,
5409 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
5410 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
5411 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305412
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005413 len += buf;
5414 check++;
5415 }
5416 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305417 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305418 }
5419
5420 wrqu->data.length = strlen(extra)+1;
5421 break;
5422 }
5423
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 case WE_GET_CFG:
5425 {
5426 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
5427 wrqu->data.length = strlen(extra)+1;
5428 break;
5429 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005430#ifdef WLAN_FEATURE_11AC
5431 case WE_GET_RSSI:
5432 {
5433 v_S7_t s7Rssi = 0;
5434 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
5435 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
5436 wrqu->data.length = strlen(extra)+1;
5437 break;
5438 }
5439#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305440
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005441#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005442 case WE_GET_ROAM_RSSI:
5443 {
5444 v_S7_t s7Rssi = 0;
5445 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
5446 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
5447 wrqu->data.length = strlen(extra)+1;
5448 break;
5449 }
5450#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 case WE_GET_WMM_STATUS:
5452 {
5453 snprintf(extra, WE_MAX_STR_LEN,
5454 "\nDir: 0=up, 1=down, 3=both\n"
5455 "|------------------------|\n"
5456 "|AC | ACM |Admitted| Dir |\n"
5457 "|------------------------|\n"
5458 "|VO | %d | %3s | %d |\n"
5459 "|VI | %d | %3s | %d |\n"
5460 "|BE | %d | %3s | %d |\n"
5461 "|BK | %d | %3s | %d |\n"
5462 "|------------------------|\n",
5463 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
5464 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
5465 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
5466 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
5467 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
5468 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
5469 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
5470 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
5471 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5472 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5473 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5474 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5475
Jeff Johnsone7245742012-09-05 17:12:55 -07005476
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 wrqu->data.length = strlen(extra)+1;
5478 break;
5479 }
5480 case WE_GET_CHANNEL_LIST:
5481 {
5482 VOS_STATUS status;
5483 v_U8_t i, len;
5484 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305485 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5486 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5487 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 tChannelListInfo channel_list;
5489
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005490 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005492 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005494 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 return -EINVAL;
5496 }
5497 buf = extra;
5498
5499 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005500 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5501 * needed = 5 * number of channels. Check ifsufficient
5502 * buffer is available and then proceed to fill the buffer.
5503 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5505 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005506 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005507 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005508 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 return -EINVAL;
5510 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005511 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5512 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305513 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5514 {
5515 //Printing Country code in getChannelList
5516 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5517 {
5518 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5519 "%c ", pBuf[i]);
5520 }
5521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 for(i = 0 ; i < channel_list.num_channels; i++)
5523 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005524 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 }
5527 wrqu->data.length = strlen(extra)+1;
5528
5529 break;
5530 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005531#ifdef FEATURE_WLAN_TDLS
5532 case WE_GET_TDLS_PEERS:
5533 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005534 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005535 break;
5536 }
5537#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005538#ifdef WLAN_FEATURE_11W
5539 case WE_GET_11W_INFO:
5540 {
5541 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5542
5543 snprintf(extra, WE_MAX_STR_LEN,
5544 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5545 "\n Number of Unprotected Disassocs %d"
5546 "\n Number of Unprotected Deauths %d",
5547 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5548 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5549 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5550 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5551 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5552
5553 wrqu->data.length = strlen(extra)+1;
5554 break;
5555 }
5556#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05305557 case WE_GET_SNR:
5558 {
5559 v_S7_t s7snr = 0;
5560 int status = 0;
5561 hdd_context_t *pHddCtx;
5562 hdd_station_ctx_t *pHddStaCtx;
5563
5564 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5565 status = wlan_hdd_validate_context(pHddCtx);
5566 if (0 != status)
5567 {
5568 hddLog(LOGE, "%s: getSNR: HDD context is not valid", __func__);
5569 return status;
5570 }
5571
5572 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5573
5574 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
5575 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5576 {
5577 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
5578 " ConnectionState-%d", __func__,
5579 pHddCtx->cfg_ini->fEnableSNRMonitoring,
5580 pHddStaCtx->conn_info.connState);
5581 return -ENONET;
5582 }
5583
5584 /*update the stats in TL*/
5585 wlan_hdd_get_station_stats(pAdapter);
5586 wlan_hdd_get_snr(pAdapter, &s7snr);
5587 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
5588 wrqu->data.length = strlen(extra) + 1;
5589 break;
5590 }
5591
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305592 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005594 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 break;
5596 }
5597 }
5598
5599 return 0;
5600}
5601
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305602static int iw_get_char_setnone(struct net_device *dev,
5603 struct iw_request_info *info,
5604 union iwreq_data *wrqu, char *extra)
5605{
5606 int ret;
5607
5608 vos_ssr_protect(__func__);
5609 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
5610 vos_ssr_unprotect(__func__);
5611
5612 return ret;
5613}
5614
Jeff Johnson295189b2012-06-20 16:38:30 -07005615/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305616static int __iw_setnone_getnone(struct net_device *dev,
5617 struct iw_request_info *info,
5618 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005619{
5620 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305621 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005622 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305623 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005624
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005625 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5626 {
5627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5628 "%s:LOGP in Progress. Ignore!!!", __func__);
5629 return -EBUSY;
5630 }
5631
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305632 /* helper function to get iwreq_data with compat handling. */
5633 if (hdd_priv_get_data(&s_priv_data, wrqu))
5634 {
5635 return -EINVAL;
5636 }
5637
5638 sub_cmd = s_priv_data.flags;
5639
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 switch (sub_cmd)
5641 {
5642 case WE_CLEAR_STATS:
5643 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005645 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5646 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5647 break;
5648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 case WE_INIT_AP:
5650 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305651 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5652
5653 /* As Soft AP mode might been changed to STA already with
5654 * killing of Hostapd, need to find the adpater by name
5655 * rather than mode */
5656 hdd_adapter_t* pAdapter_to_stop =
5657 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5658 if( pAdapter_to_stop )
5659 {
5660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5661 "Adapter with name softap.0 already "
5662 "exist, ignoring the request.\nRemove the "
5663 "adapter and try again\n");
5664 break;
5665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 pr_info("Init AP trigger\n");
5667 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5668 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5669 break;
5670 }
5671 case WE_STOP_AP:
5672 {
5673 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5674 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5675 * this is a dead code and need to find the adpater by name rather than mode */
5676 hdd_adapter_t* pAdapter_to_stop =
5677 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5678 if( pAdapter_to_stop )
5679 {
5680 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5681
5682 pr_info("Stopping AP mode\n");
5683
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305684 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5685 {
5686 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5687 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5688 }
5689
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305691 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5693 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5694
5695 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5696 pAdapter_to_stop->macAddressCurrent.bytes);
5697 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5698 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305699
5700 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5701 {
5702 /* put the device back into BMPS */
5703 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 }
5706 else
5707 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005708 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 }
5710
5711 break;
5712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005713#ifdef WLAN_BTAMP_FEATURE
5714 case WE_ENABLE_AMP:
5715 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 WLANBAP_RegisterWithHCI(pAdapter);
5718 break;
5719 }
5720 case WE_DISABLE_AMP:
5721 {
5722 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5723 VOS_STATUS status;
5724
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005726
5727 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5728 status = WLANBAP_StopAmp();
5729 if(VOS_STATUS_SUCCESS != status )
5730 {
5731 pHddCtx->isAmpAllowed = VOS_TRUE;
5732 hddLog(VOS_TRACE_LEVEL_FATAL,
5733 "%s: Failed to stop AMP", __func__);
5734 }
5735 else
5736 {
5737 //a state m/c implementation in PAL is TBD to avoid this delay
5738 msleep(500);
5739 pHddCtx->isAmpAllowed = VOS_FALSE;
5740 WLANBAP_DeregisterFromHCI();
5741 }
5742
5743 break;
5744 }
5745#endif
5746
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005747 case WE_ENABLE_DXE_STALL_DETECT:
5748 {
schang6295e542013-03-12 15:31:23 -07005749 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5750 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005751 break;
5752 }
5753 case WE_DISPLAY_DXE_SNAP_SHOT:
5754 {
schang6295e542013-03-12 15:31:23 -07005755 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5756 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005757 break;
5758 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305759 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5760 {
5761 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5762 hdd_wmm_tx_snapshot(pAdapter);
5763 WLANTL_TLDebugMessage(VOS_TRUE);
5764 break;
5765 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305766
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305767 case WE_SET_REASSOC_TRIGGER:
5768 {
5769 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5770 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5771 v_U32_t roamId = 0;
5772 tCsrRoamModifyProfileFields modProfileFields;
5773 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5774 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5775 return 0;
5776 }
5777
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305778 case WE_STOP_OBSS_SCAN:
5779 {
5780 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5781 2.OBSS scan is stopped by Firmware during the disassociation
5782 3.OBSS stop comamnd is added for debugging purpose*/
5783 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5784 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005785
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305786 if (pAdapter == NULL)
5787 {
5788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5789 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305790 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305791 }
5792 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5793 if (pMac == NULL)
5794 {
5795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5796 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305797 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305798 }
5799 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5800 }
5801 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05305802#ifdef DEBUG_ROAM_DELAY
5803 case WE_DUMP_ROAM_TIMER_LOG:
5804 {
5805 vos_dump_roam_time_log_service();
5806 break;
5807 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305808
Mukul Sharma84f27252014-07-14 18:11:42 +05305809 case WE_RESET_ROAM_TIMER_LOG:
5810 {
5811 vos_reset_roam_timer_log();
5812 break;
5813 }
5814#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 default:
5816 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005817 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 break;
5819 }
5820 }
5821
5822 return ret;
5823}
5824
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305825static int iw_setnone_getnone(struct net_device *dev,
5826 struct iw_request_info *info,
5827 union iwreq_data *wrqu, char *extra)
5828{
5829 int ret;
5830
5831 vos_ssr_protect(__func__);
5832 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
5833 vos_ssr_unprotect(__func__);
5834
5835 return ret;
5836}
5837
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305838void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5839{
5840 /*
5841 * Function to display HDD WMM information
5842 * for Tx Queues.
5843 * Prints globala as well as per client depending
5844 * whether the clients are registered or not.
5845 */
5846 int i = 0, j = 0;
5847 for ( i=0; i< NUM_TX_QUEUES; i++)
5848 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305849 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005850 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305851 i, pAdapter->wmm_tx_queue[i].count,
5852 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305853 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305854 }
5855
5856 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5857 {
5858 if(pAdapter->aStaInfo[i].isUsed)
5859 {
5860 hddLog(LOGE, "******STAIndex: %d*********", i);
5861 for ( j=0; j< NUM_TX_QUEUES; j++)
5862 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305863 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005864 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305865 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5866 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5867 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305868 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305869 }
5870 }
5871 }
5872
5873}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305874int __iw_set_var_ints_getnone(struct net_device *dev,
5875 struct iw_request_info *info,
5876 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005877{
5878 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5879 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05305880 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 int apps_args[MAX_VAR_ARGS] = {0};
Girish Gowlid4522fd2014-06-14 17:20:27 +05305882 int num_args;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005883 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05305884 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005885 hdd_ap_ctx_t *pAPCtx = NULL;
5886 int cmd = 0;
5887 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05305888 int ret = 0;
Girish Gowlid4522fd2014-06-14 17:20:27 +05305889 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005890
Girish Gowlid4522fd2014-06-14 17:20:27 +05305891 /* helper function to get iwreq_data with compat handling. */
5892 if (hdd_priv_get_data(&s_priv_data, wrqu))
5893 {
5894 return -EINVAL;
5895 }
5896
5897 if (NULL == s_priv_data.pointer)
5898 {
5899 return -EINVAL;
5900 }
5901
5902 sub_cmd = s_priv_data.flags;
5903 num_args = s_priv_data.length;
5904
5905 hddLog(LOG1, "%s: Received length %d", __func__, s_priv_data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005906
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05305907 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5908 ret = wlan_hdd_validate_context(pHddCtx);
5909 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005910 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05305911 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5912 "%s: HDD context is Null", __func__);
5913 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005914 }
5915
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 if (num_args > MAX_VAR_ARGS)
5917 {
5918 num_args = MAX_VAR_ARGS;
5919 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005920
5921 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlid4522fd2014-06-14 17:20:27 +05305922 if (copy_from_user(apps_args, s_priv_data.pointer, (sizeof(int)) * num_args))
Arif Hussain0273cba2014-01-07 20:58:29 -08005923 {
5924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5925 "%s: failed to copy data to user buffer", __func__);
5926 return -EFAULT;
5927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005928
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005929 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5930 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5931 {
5932 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5933 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5934 {
5935 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5936 staId = pStaCtx->conn_info.staId[0];
5937 }
5938 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5939 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5940 {
5941 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5942 staId = pAPCtx->uBCStaId;
5943 }
5944 else
5945 {
5946 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5947 return 0;
5948 }
5949 }
5950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 switch (sub_cmd)
5952 {
5953 case WE_LOG_DUMP_CMD:
5954 {
5955 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005956 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 apps_args[3], apps_args[4]);
5958
5959 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5960 apps_args[3], apps_args[4]);
5961
5962 }
5963 break;
5964
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 case WE_P2P_NOA_CMD:
5966 {
5967 p2p_app_setP2pPs_t p2pNoA;
5968
5969 p2pNoA.opp_ps = apps_args[0];
5970 p2pNoA.ctWindow = apps_args[1];
5971 p2pNoA.duration = apps_args[2];
5972 p2pNoA.interval = apps_args[3];
5973 p2pNoA.count = apps_args[4];
5974 p2pNoA.single_noa_duration = apps_args[5];
5975 p2pNoA.psSelection = apps_args[6];
5976
5977 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5978 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005979 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5981
5982 hdd_setP2pPs(dev, &p2pNoA);
5983
5984 }
5985 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305987 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5988 {
5989 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5990 __func__, apps_args[0], apps_args[1]);
5991 vosTraceEnable(apps_args[0], apps_args[1]);
5992 }
5993 break;
5994
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005995 case WE_MTRACE_DUMP_CMD:
5996 {
5997 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5998 "bitmask_of_module %d ",
5999 __func__, apps_args[0], apps_args[1], apps_args[2],
6000 apps_args[3]);
6001 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
6002 apps_args[2], apps_args[3]);
6003
6004 }
6005 break;
6006
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006007 case WE_MCC_CONFIG_CREDENTIAL :
6008 {
6009 cmd = 287; //Command should be updated if there is any change
6010 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08006011 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006012 {
6013 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
6014 }
6015 else
6016 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006017 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006018 return 0;
6019 }
6020 }
6021 break;
6022
6023 case WE_MCC_CONFIG_PARAMS :
6024 {
6025 cmd = 288; //command Should be updated if there is any change
6026 // in the Riva dump command
6027 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
6028 }
6029 break;
6030
Chilam NG571c65a2013-01-19 12:27:36 +05306031#ifdef FEATURE_WLAN_TDLS
6032 case WE_TDLS_CONFIG_PARAMS :
6033 {
6034 tdls_config_params_t tdlsParams;
6035
Chilam Ng01120412013-02-19 18:32:21 -08006036 tdlsParams.tdls = apps_args[0];
6037 tdlsParams.tx_period_t = apps_args[1];
6038 tdlsParams.tx_packet_n = apps_args[2];
6039 tdlsParams.discovery_period_t = apps_args[3];
6040 tdlsParams.discovery_tries_n = apps_args[4];
6041 tdlsParams.idle_timeout_t = apps_args[5];
6042 tdlsParams.idle_packet_n = apps_args[6];
6043 tdlsParams.rssi_hysteresis = apps_args[7];
6044 tdlsParams.rssi_trigger_threshold = apps_args[8];
6045 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05306046
Chilam Ng01120412013-02-19 18:32:21 -08006047 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05306048 }
6049 break;
6050#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 default:
6052 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006053 hddLog(LOGE, "%s: Invalid IOCTL command %d",
6054 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 }
6056 break;
6057 }
6058
6059 return 0;
6060}
6061
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306062int iw_set_var_ints_getnone(struct net_device *dev,
6063 struct iw_request_info *info,
6064 union iwreq_data *wrqu, char *extra)
6065{
6066 int ret;
6067 vos_ssr_protect(__func__);
6068 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
6069 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006070
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306071 return ret;
6072}
6073
6074static int __iw_add_tspec(struct net_device *dev,
6075 struct iw_request_info *info,
6076 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006077{
6078 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6079 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6080 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6081 int params[HDD_WLAN_WMM_PARAM_COUNT];
6082 sme_QosWmmTspecInfo tSpec;
6083 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05306084 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006085
6086 // make sure the application is sufficiently priviledged
6087 // note that the kernel will do this for "set" ioctls, but since
6088 // this ioctl wants to return status to user space it must be
6089 // defined as a "get" ioctl
6090 if (!capable(CAP_NET_ADMIN))
6091 {
6092 return -EPERM;
6093 }
6094
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006095 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6096 {
6097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6098 "%s:LOGP in Progress. Ignore!!!", __func__);
6099 return -EBUSY;
6100 }
6101
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 // we must be associated in order to add a tspec
6103 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6104 {
6105 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6106 return 0;
6107 }
6108
6109 // since we are defined to be a "get" ioctl, and since the number
6110 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05306111 // will pass down in the iwreq_data, we must copy the "set" params.
6112 // We must handle the compat for iwreq_data in 32U/64K environment.
6113
6114 // helper fucntion to get iwreq_data with compat handling.
6115 if (hdd_priv_get_data(&s_priv_data, wrqu))
6116 {
6117 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6118 return 0;
6119 }
6120
6121 // make sure all params are correctly passed to function
6122 if ((NULL == s_priv_data.pointer) ||
6123 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
6124 {
6125 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6126 return 0;
6127 }
6128
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05306130 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 {
6132 // hmmm, can't get them
6133 return -EIO;
6134 }
6135
6136 // clear the tspec
6137 memset(&tSpec, 0, sizeof(tSpec));
6138
6139 // validate the handle
6140 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6141 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6142 {
6143 // that one is reserved
6144 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6145 return 0;
6146 }
6147
6148 // validate the TID
6149 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
6150 {
6151 // out of range
6152 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6153 return 0;
6154 }
6155 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
6156
6157 // validate the direction
6158 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
6159 {
6160 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
6161 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
6162 break;
6163
6164 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
6165 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
6166 break;
6167
6168 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
6169 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
6170 break;
6171
6172 default:
6173 // unknown
6174 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6175 return 0;
6176 }
6177
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05306178 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
6179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 // validate the user priority
6181 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
6182 {
6183 // out of range
6184 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6185 return 0;
6186 }
6187 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05306188 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
6189 {
6190 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
6191 return 0;
6192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006193
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05306194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6195 "%s:TS_INFO PSB %d UP %d !!!", __func__,
6196 tSpec.ts_info.psb, tSpec.ts_info.up);
6197
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
6199 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
6200 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
6201 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
6202 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
6203 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
6204 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
6205 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
6206 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
6207 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
6208 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
6209 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
6210
6211 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
6212
6213 // validate the ts info ack policy
6214 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
6215 {
6216 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
6217 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
6218 break;
6219
6220 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
6221 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
6222 break;
6223
6224 default:
6225 // unknown
6226 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6227 return 0;
6228 }
6229
6230 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
6231 return 0;
6232}
6233
6234
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306235static int iw_add_tspec(struct net_device *dev,
6236 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 union iwreq_data *wrqu, char *extra)
6238{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306239 int ret;
6240
6241 vos_ssr_protect(__func__);
6242 ret = __iw_add_tspec(dev, info, wrqu, extra);
6243 vos_ssr_unprotect(__func__);
6244
6245 return ret;
6246}
6247
6248static int __iw_del_tspec(struct net_device *dev,
6249 struct iw_request_info *info,
6250 union iwreq_data *wrqu, char *extra)
6251{
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6253 int *params = (int *)extra;
6254 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6255 v_U32_t handle;
6256
6257 // make sure the application is sufficiently priviledged
6258 // note that the kernel will do this for "set" ioctls, but since
6259 // this ioctl wants to return status to user space it must be
6260 // defined as a "get" ioctl
6261 if (!capable(CAP_NET_ADMIN))
6262 {
6263 return -EPERM;
6264 }
6265
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006266 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6267 {
6268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6269 "%s:LOGP in Progress. Ignore!!!", __func__);
6270 return -EBUSY;
6271 }
6272
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 // although we are defined to be a "get" ioctl, the params we require
6274 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
6275 // is no need to copy the params from user space
6276
6277 // validate the handle
6278 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6279 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6280 {
6281 // that one is reserved
6282 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6283 return 0;
6284 }
6285
6286 *pStatus = hdd_wmm_delts(pAdapter, handle);
6287 return 0;
6288}
6289
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306290static int iw_del_tspec(struct net_device *dev,
6291 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 union iwreq_data *wrqu, char *extra)
6293{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306294 int ret;
6295
6296 vos_ssr_protect(__func__);
6297 ret = __iw_del_tspec(dev, info, wrqu, extra);
6298 vos_ssr_unprotect(__func__);
6299
6300 return ret;
6301}
6302
6303
6304static int __iw_get_tspec(struct net_device *dev,
6305 struct iw_request_info *info,
6306 union iwreq_data *wrqu, char *extra)
6307{
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6309 int *params = (int *)extra;
6310 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6311 v_U32_t handle;
6312
6313 // although we are defined to be a "get" ioctl, the params we require
6314 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
6315 // is no need to copy the params from user space
6316
6317 // validate the handle
6318 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6319 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6320 {
6321 // that one is reserved
6322 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6323 return 0;
6324 }
6325
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006326 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6327 {
6328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6329 "%s:LOGP in Progress. Ignore!!!", __func__);
6330 return -EBUSY;
6331 }
6332
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 *pStatus = hdd_wmm_checkts(pAdapter, handle);
6334 return 0;
6335}
6336
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306337static int iw_get_tspec(struct net_device *dev,
6338 struct iw_request_info *info,
6339 union iwreq_data *wrqu, char *extra)
6340{
6341 int ret;
6342
6343 vos_ssr_protect(__func__);
6344 ret = __iw_get_tspec(dev, info, wrqu, extra);
6345 vos_ssr_unprotect(__func__);
6346
6347 return ret;
6348}
6349
Jeff Johnson295189b2012-06-20 16:38:30 -07006350#ifdef WLAN_FEATURE_VOWIFI_11R
6351//
6352//
6353// Each time the supplicant has the auth_request or reassoc request
6354// IEs ready. This is pushed to the driver. The driver will inturn use
6355// it to send out the auth req and reassoc req for 11r FT Assoc.
6356//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306357static int __iw_set_fties(struct net_device *dev,
6358 struct iw_request_info *info,
6359 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006360{
6361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6362 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6363 //v_CONTEXT_t pVosContext;
6364
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006365 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6366 {
6367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6368 "%s:LOGP in Progress. Ignore!!!", __func__);
6369 return -EBUSY;
6370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 if (!wrqu->data.length)
6372 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006373 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 return -EINVAL;
6375 }
6376 if (wrqu->data.pointer == NULL)
6377 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006378 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 return -EINVAL;
6380 }
6381
6382 // Added for debug on reception of Re-assoc Req.
6383 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6384 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006385 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006387 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 }
6389
6390#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08006391 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07006392#endif
6393
6394 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08006395 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 wrqu->data.length);
6397
6398 return 0;
6399}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306400
6401static int iw_set_fties(struct net_device *dev,
6402 struct iw_request_info *info,
6403 union iwreq_data *wrqu, char *extra)
6404{
6405 int ret;
6406
6407 vos_ssr_protect(__func__);
6408 ret = __iw_set_fties(dev, info, wrqu, extra);
6409 vos_ssr_unprotect(__func__);
6410
6411 return ret;
6412}
Jeff Johnson295189b2012-06-20 16:38:30 -07006413#endif
6414
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306415static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006416 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08006418{
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006420 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006422 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006423 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006424 tpSirRcvFltMcAddrList mc_addr_list_ptr;
6425 int idx;
6426 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07006427
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006428 if (pHddCtx->isLogpInProgress)
6429 {
6430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6431 "%s:LOGP in Progress. Ignore!!!", __func__);
6432 return -EBUSY;
6433 }
6434
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306435 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
6436 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306437#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07006438
Amar Singhalf3a6e762013-02-19 15:06:50 -08006439 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6440 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006441 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006442 hddLog(VOS_TRACE_LEVEL_ERROR,
6443 "%s: vos_mem_alloc failed", __func__);
6444 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006445 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006446
6447 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6448
6449 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6450 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6451
6452 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6453 mc_addr_list_ptr->ulMulticastAddrCnt);
6454
6455 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006456 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006457 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6458 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6459
6460 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6461 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006462 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006463
Amar Singhalf3a6e762013-02-19 15:06:50 -08006464 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6465 vos_mem_free(mc_addr_list_ptr);
6466 if (eHAL_STATUS_SUCCESS != ret_val)
6467 {
6468 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6469 __func__);
6470 return -EINVAL;
6471 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306472#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306473 }
6474 else
6475 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006476
Amar Singhalf3a6e762013-02-19 15:06:50 -08006477 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6478 "%s: Set MC BC Filter Config request: %d suspend %d",
6479 __func__, pRequest->mcastBcastFilterSetting,
6480 pHddCtx->hdd_wlan_suspended);
6481
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306482 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006483
6484 if (pHddCtx->hdd_wlan_suspended)
6485 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006486 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6487 if (NULL == wlanRxpFilterParam)
6488 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306489 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006490 "%s: vos_mem_alloc failed", __func__);
6491 return -EINVAL;
6492 }
6493
Amar Singhalf3a6e762013-02-19 15:06:50 -08006494 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6495 pRequest->mcastBcastFilterSetting;
6496 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6497
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306498 hdd_conf_hostoffload(pAdapter, TRUE);
6499 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6500 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006501
6502 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6503 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306504 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006505 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6506 wlanRxpFilterParam->setMcstBcstFilter);
6507
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306508 if (eHAL_STATUS_SUCCESS !=
6509 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6510 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006511 {
6512 hddLog(VOS_TRACE_LEVEL_ERROR,
6513 "%s: Failure to execute set HW MC/BC Filter request",
6514 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006515 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006516 return -EINVAL;
6517 }
6518
Amar Singhalf3a6e762013-02-19 15:06:50 -08006519 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006521
6522 return 0;
6523}
6524
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306525static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
6526 struct iw_request_info *info,
6527 union iwreq_data *wrqu, char *extra)
6528{
6529 int ret;
6530
6531 vos_ssr_protect(__func__);
6532 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
6533 vos_ssr_unprotect(__func__);
6534
6535 return ret;
6536}
6537
6538static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
6539 struct iw_request_info *info,
6540 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006541{
6542 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6543 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306544 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006545 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006546
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306547 //Reset the filter to INI value as we have to clear the dynamic filter
6548 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006549
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306550 //Configure FW with new setting
6551 if (pHddCtx->hdd_wlan_suspended)
6552 {
6553 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6554 if (NULL == wlanRxpFilterParam)
6555 {
6556 hddLog(VOS_TRACE_LEVEL_ERROR,
6557 "%s: vos_mem_alloc failed", __func__);
6558 return -EINVAL;
6559 }
6560
6561 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6562 pHddCtx->configuredMcastBcastFilter;
6563 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6564
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306565 hdd_conf_hostoffload(pAdapter, TRUE);
6566 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6567 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306568
6569 if (eHAL_STATUS_SUCCESS !=
6570 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6571 wlanRxpFilterParam))
6572 {
6573 hddLog(VOS_TRACE_LEVEL_ERROR,
6574 "%s: Failure to execute set HW MC/BC Filter request",
6575 __func__);
6576 vos_mem_free(wlanRxpFilterParam);
6577 return -EINVAL;
6578 }
6579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 return 0;
6581}
6582
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306583
6584static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
6585 struct iw_request_info *info,
6586 union iwreq_data *wrqu, char *extra)
6587{
6588 int ret;
6589
6590 vos_ssr_protect(__func__);
6591 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
6592 vos_ssr_unprotect(__func__);
6593
6594 return ret;
6595}
6596
6597static int __iw_set_host_offload(struct net_device *dev,
6598 struct iw_request_info *info,
6599 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006600{
6601 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006602 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 tSirHostOffloadReq offloadRequest;
6604
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006605 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6606 {
6607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6608 "%s:LOGP in Progress. Ignore!!!", __func__);
6609 return -EBUSY;
6610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 /* Debug display of request components. */
6612 switch (pRequest->offloadType)
6613 {
6614 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006615 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 switch (pRequest->enableOrDisable)
6617 {
6618 case WLAN_OFFLOAD_DISABLE:
6619 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6620 break;
6621 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6622 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6623 case WLAN_OFFLOAD_ENABLE:
6624 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6625 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6626 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6627 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6628 }
6629 break;
6630
6631 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006632 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006633 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 switch (pRequest->enableOrDisable)
6635 {
6636 case WLAN_OFFLOAD_DISABLE:
6637 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6638 break;
6639 case WLAN_OFFLOAD_ENABLE:
6640 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6641 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6642 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6643 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6644 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6645 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6646 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6647 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6648 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6649 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6650 }
6651 }
6652
6653 /* Execute offload request. The reason that we can copy the request information
6654 from the ioctl structure to the SME structure is that they are laid out
6655 exactly the same. Otherwise, each piece of information would have to be
6656 copied individually. */
6657 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006658 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6659 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006661 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 __func__);
6663 return -EINVAL;
6664 }
6665
6666 return 0;
6667}
6668
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306669static int iw_set_host_offload(struct net_device *dev,
6670 struct iw_request_info *info,
6671 union iwreq_data *wrqu, char *extra)
6672{
6673 int ret;
6674
6675 vos_ssr_protect(__func__);
6676 ret = __iw_set_host_offload(dev, info, wrqu, extra);
6677 vos_ssr_unprotect(__func__);
6678
6679 return ret;
6680}
6681
6682static int __iw_set_keepalive_params(struct net_device *dev,
6683 struct iw_request_info *info,
6684 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006685{
6686 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006687 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 tSirKeepAliveReq keepaliveRequest;
6689
6690 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6691 {
6692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006693 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 return 0;
6695 }
6696
6697 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006698 hddLog(VOS_TRACE_LEVEL_INFO,
6699 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6700 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006701
6702 switch (pRequest->packetType)
6703 {
6704 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006705 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 break;
6707
6708 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6709
Arif Hussain6d2a3322013-11-17 19:50:10 -08006710 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006711 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006712
6713 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6714 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6715 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6716
6717 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6718 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6719 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6720
6721 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6722 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6723 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6724 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6725 break;
6726
6727 }
6728
6729 /* Execute keep alive request. The reason that we can copy the request information
6730 from the ioctl structure to the SME structure is that they are laid out
6731 exactly the same. Otherwise, each piece of information would have to be
6732 copied individually. */
6733 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6734
Arif Hussain6d2a3322013-11-17 19:50:10 -08006735 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006736
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006737 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006738 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006740 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 __func__);
6742 return -EINVAL;
6743 }
6744
6745 return 0;
6746}
6747
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306748static int iw_set_keepalive_params(struct net_device *dev,
6749 struct iw_request_info *info,
6750 union iwreq_data *wrqu, char *extra)
6751{
6752 int ret;
6753 vos_ssr_protect(__func__);
6754 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
6755 vos_ssr_unprotect(__func__);
6756
6757 return ret;
6758}
6759
Jeff Johnson295189b2012-06-20 16:38:30 -07006760#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006761int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006762 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006763{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006764 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6765 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 int i=0;
6767
6768 if (pHddCtx->cfg_ini->disablePacketFilter)
6769 {
6770 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006771 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 return 0;
6773 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006774 if (pHddCtx->isLogpInProgress)
6775 {
6776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6777 "%s:LOGP in Progress. Ignore!!!", __func__);
6778 return -EBUSY;
6779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 /* Debug display of request components. */
6781 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006782 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006783
6784 switch (pRequest->filterAction)
6785 {
6786 case HDD_RCV_FILTER_SET:
6787 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006788 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006789
6790 packetFilterSetReq.filterId = pRequest->filterId;
6791 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6792 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006793 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 __func__, pRequest->numParams);
6795 return -EINVAL;
6796 }
6797 packetFilterSetReq.numFieldParams = pRequest->numParams;
6798 packetFilterSetReq.coalesceTime = 0;
6799 packetFilterSetReq.filterType = 1;
6800 for (i=0; i < pRequest->numParams; i++)
6801 {
6802 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6803 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6804 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6805 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6806 packetFilterSetReq.paramsData[i].reserved = 0;
6807
Arif Hussain6d2a3322013-11-17 19:50:10 -08006808 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6810 packetFilterSetReq.filterType);
6811
Arif Hussain6d2a3322013-11-17 19:50:10 -08006812 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006813 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6814
6815 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6816 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6817 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6818 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6819
Arif Hussain6d2a3322013-11-17 19:50:10 -08006820 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6822 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6823 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6824
Arif Hussain6d2a3322013-11-17 19:50:10 -08006825 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6827 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6828 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6829 }
6830
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006831 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006833 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 __func__);
6835 return -EINVAL;
6836 }
6837
6838 break;
6839
6840 case HDD_RCV_FILTER_CLEAR:
6841
Arif Hussain6d2a3322013-11-17 19:50:10 -08006842 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006843 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006844 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006845 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006847 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 __func__);
6849 return -EINVAL;
6850 }
6851 break;
6852
6853 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006854 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006855 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 return -EINVAL;
6857 }
6858 return 0;
6859}
6860
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306861int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6862 tANI_U8 sessionId)
6863{
6864 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6865 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6866
6867 if (NULL == pHddCtx)
6868 {
6869 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6870 return -EINVAL;
6871 }
6872
6873 if (pHddCtx->isLogpInProgress)
6874 {
6875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6876 "%s:LOGP in Progress. Ignore!!!", __func__);
6877 return -EBUSY;
6878 }
6879
6880 if (pHddCtx->cfg_ini->disablePacketFilter)
6881 {
6882 hddLog(VOS_TRACE_LEVEL_ERROR,
6883 "%s: Packet Filtering Disabled. Returning ",
6884 __func__ );
6885 return -EINVAL;
6886 }
6887
6888 switch (filterType)
6889 {
6890 /* For setting IPV6 MC and UC Filter we need to configure
6891 * 2 filters, one for MC and one for UC.
6892 * The Filter ID shouldn't be swapped, which results in making
6893 * UC Filter ineffective.
6894 * We have Hardcode all the values
6895 *
6896 * Reason for a seperate UC filter is because, driver need to
6897 * specify the FW that the specific filter is for unicast
6898 * otherwise FW will not pass the unicast frames by default
6899 * through the filter. This is required to avoid any performance
6900 * hits when no unicast filter is set and only MC/BC are set.
6901 * The way driver informs host is by using the MAC protocol
6902 * layer, CMP flag set to MAX, CMP Data set to 1.
6903 */
6904
6905 case HDD_FILTER_IPV6_MC_UC:
6906 /* Setting IPV6 MC Filter below
6907 */
6908 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6909 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6910 packetFilterSetReq.numFieldParams = 2;
6911 packetFilterSetReq.paramsData[0].protocolLayer =
6912 HDD_FILTER_PROTO_TYPE_MAC;
6913 packetFilterSetReq.paramsData[0].cmpFlag =
6914 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6915 packetFilterSetReq.paramsData[0].dataOffset =
6916 WLAN_HDD_80211_FRM_DA_OFFSET;
6917 packetFilterSetReq.paramsData[0].dataLength = 1;
6918 packetFilterSetReq.paramsData[0].compareData[0] =
6919 HDD_IPV6_MC_CMP_DATA;
6920
6921 packetFilterSetReq.paramsData[1].protocolLayer =
6922 HDD_FILTER_PROTO_TYPE_ARP;
6923 packetFilterSetReq.paramsData[1].cmpFlag =
6924 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6925 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6926 packetFilterSetReq.paramsData[1].dataLength = 2;
6927 packetFilterSetReq.paramsData[1].compareData[0] =
6928 HDD_IPV6_CMP_DATA_0;
6929 packetFilterSetReq.paramsData[1].compareData[1] =
6930 HDD_IPV6_CMP_DATA_1;
6931
6932
6933 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6934 &packetFilterSetReq, sessionId))
6935 {
6936 hddLog(VOS_TRACE_LEVEL_ERROR,
6937 "%s: Failure to execute Set IPv6 Mulicast Filter",
6938 __func__);
6939 return -EINVAL;
6940 }
6941
6942 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6943
6944 /*
6945 * Setting IPV6 UC Filter below
6946 */
6947 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6948 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6949 packetFilterSetReq.numFieldParams = 2;
6950 packetFilterSetReq.paramsData[0].protocolLayer =
6951 HDD_FILTER_PROTO_TYPE_MAC;
6952 packetFilterSetReq.paramsData[0].cmpFlag =
6953 HDD_FILTER_CMP_TYPE_MAX;
6954 packetFilterSetReq.paramsData[0].dataOffset = 0;
6955 packetFilterSetReq.paramsData[0].dataLength = 1;
6956 packetFilterSetReq.paramsData[0].compareData[0] =
6957 HDD_IPV6_UC_CMP_DATA;
6958
6959 packetFilterSetReq.paramsData[1].protocolLayer =
6960 HDD_FILTER_PROTO_TYPE_ARP;
6961 packetFilterSetReq.paramsData[1].cmpFlag =
6962 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6963 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6964 packetFilterSetReq.paramsData[1].dataLength = 2;
6965 packetFilterSetReq.paramsData[1].compareData[0] =
6966 HDD_IPV6_CMP_DATA_0;
6967 packetFilterSetReq.paramsData[1].compareData[1] =
6968 HDD_IPV6_CMP_DATA_1;
6969
6970 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6971 &packetFilterSetReq, sessionId))
6972 {
6973 hddLog(VOS_TRACE_LEVEL_ERROR,
6974 "%s: Failure to execute Set IPv6 Unicast Filter",
6975 __func__);
6976 return -EINVAL;
6977 }
6978
6979 break;
6980
6981 case HDD_FILTER_IPV6_MC:
6982 /*
6983 * IPV6 UC Filter might be already set,
6984 * clear the UC Filter. As the Filter
6985 * IDs are static, we can directly clear it.
6986 */
6987 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6988 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6989 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6990 &packetFilterClrReq, sessionId))
6991 {
6992 hddLog(VOS_TRACE_LEVEL_ERROR,
6993 "%s: Failure to execute Clear IPv6 Unicast Filter",
6994 __func__);
6995 return -EINVAL;
6996 }
6997
6998 /*
6999 * Setting IPV6 MC Filter below
7000 */
7001 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
7002 packetFilterSetReq.numFieldParams = 2;
7003 packetFilterSetReq.paramsData[0].protocolLayer =
7004 HDD_FILTER_PROTO_TYPE_MAC;
7005 packetFilterSetReq.paramsData[0].cmpFlag =
7006 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7007 packetFilterSetReq.paramsData[0].dataOffset =
7008 WLAN_HDD_80211_FRM_DA_OFFSET;
7009 packetFilterSetReq.paramsData[0].dataLength = 1;
7010 packetFilterSetReq.paramsData[0].compareData[0] =
7011 HDD_IPV6_MC_CMP_DATA;
7012
7013 packetFilterSetReq.paramsData[1].protocolLayer =
7014 HDD_FILTER_PROTO_TYPE_ARP;
7015 packetFilterSetReq.paramsData[1].cmpFlag =
7016 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7017 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
7018 packetFilterSetReq.paramsData[1].dataLength = 2;
7019 packetFilterSetReq.paramsData[1].compareData[0] =
7020 HDD_IPV6_CMP_DATA_0;
7021 packetFilterSetReq.paramsData[1].compareData[1] =
7022 HDD_IPV6_CMP_DATA_1;
7023
7024
7025 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
7026 &packetFilterSetReq, sessionId))
7027 {
7028 hddLog(VOS_TRACE_LEVEL_ERROR,
7029 "%s: Failure to execute Set IPv6 Multicast Filter",
7030 __func__);
7031 return -EINVAL;
7032 }
7033 break;
7034
7035 default :
7036 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7037 "%s: Packet Filter Request: Invalid",
7038 __func__);
7039 return -EINVAL;
7040 }
7041 return 0;
7042}
7043
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307044void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07007045{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307046 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307047 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07007048 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307049 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007050
Yue Ma3ede6052013-08-29 00:33:26 -07007051 if (NULL == pHddCtx)
7052 {
7053 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
7054 return;
7055 }
7056
7057 hHal = pHddCtx->hHal;
7058
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307059 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307061 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
7062 return;
7063 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307064
7065 /* Check if INI is enabled or not, other wise just return
7066 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05307067 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307068 {
7069 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7070 if (NULL == pMulticastAddrs)
7071 {
7072 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
7073 return;
7074 }
7075
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 if (set)
7077 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307078 /* Following pre-conditions should be satisfied before wei
7079 * configure the MC address list.
7080 */
7081 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
7082 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
7083 && pAdapter->mc_addr_list.mc_cnt
7084 && (eConnectionState_Associated ==
7085 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7086 {
7087 pMulticastAddrs->ulMulticastAddrCnt =
7088 pAdapter->mc_addr_list.mc_cnt;
7089 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
7090 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007091 memcpy(pMulticastAddrs->multicastAddr[i],
7092 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307093 sizeof(pAdapter->mc_addr_list.addr[i]));
7094 hddLog(VOS_TRACE_LEVEL_INFO,
7095 "%s: %s multicast filter: addr ="
7096 MAC_ADDRESS_STR,
7097 __func__, set ? "setting" : "clearing",
7098 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
7099 }
7100 /* Set multicast filter */
7101 sme_8023MulticastList(hHal, pAdapter->sessionId,
7102 pMulticastAddrs);
7103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007104 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307105 else
7106 {
7107 /* Need to clear only if it was previously configured
7108 */
7109 if (pAdapter->mc_addr_list.isFilterApplied)
7110 {
7111 pMulticastAddrs->ulMulticastAddrCnt = 0;
7112 sme_8023MulticastList(hHal, pAdapter->sessionId,
7113 pMulticastAddrs);
7114 }
7115
7116 }
7117 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07007118 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307120 else
7121 {
7122 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05307123 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307124 }
7125 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007126}
7127
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307128static int __iw_set_packet_filter_params(struct net_device *dev,
7129 struct iw_request_info *info,
7130 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307131{
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007133 tpPacketFilterCfg pRequest = NULL;
7134 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05307135 struct iw_point s_priv_data;
7136
7137 if (hdd_priv_get_data(&s_priv_data, wrqu))
7138 {
7139 return -EINVAL;
7140 }
7141
7142 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
7143 {
7144 return -EINVAL;
7145 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007146
Arif Hussain0273cba2014-01-07 20:58:29 -08007147 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05307148 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
7149 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08007150 if (NULL == pRequest)
7151 {
7152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7153 "mem_alloc_copy_from_user_helper fail");
7154 return -ENOMEM;
7155 }
7156
7157 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
7158 kfree(pRequest);
7159
7160 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007161}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307162
7163static int iw_set_packet_filter_params(struct net_device *dev,
7164 struct iw_request_info *info,
7165 union iwreq_data *wrqu, char *extra)
7166{
7167 int ret;
7168
7169 vos_ssr_protect(__func__);
7170 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
7171 vos_ssr_unprotect(__func__);
7172
7173 return ret;
7174}
Jeff Johnson295189b2012-06-20 16:38:30 -07007175#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307176static int __iw_get_statistics(struct net_device *dev,
7177 struct iw_request_info *info,
7178 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007179{
7180
7181 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
7182 eHalStatus status = eHAL_STATUS_SUCCESS;
7183 hdd_wext_state_t *pWextState;
7184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7185 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7186 char *p = extra;
7187 int tlen = 0;
7188 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
7189
7190 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
7191 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
7192
7193 ENTER();
7194
7195 if (pHddCtx->isLogpInProgress) {
7196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
7197 return -EINVAL;
7198 }
7199
7200 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
7201
7202 wrqu->txpower.value = 0;
7203 }
7204 else {
7205 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
7206 SME_SUMMARY_STATS |
7207 SME_GLOBAL_CLASSA_STATS |
7208 SME_GLOBAL_CLASSB_STATS |
7209 SME_GLOBAL_CLASSC_STATS |
7210 SME_GLOBAL_CLASSD_STATS |
7211 SME_PER_STA_STATS,
7212 hdd_StatisticsCB, 0, FALSE,
7213 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
7214
7215 if (eHAL_STATUS_SUCCESS != status)
7216 {
7217 hddLog(VOS_TRACE_LEVEL_ERROR,
7218 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007219 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 return -EINVAL;
7221 }
7222
7223 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7224
7225 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
7226 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7227 {
7228 hddLog(VOS_TRACE_LEVEL_ERROR,
7229 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007230 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 /*Remove the SME statistics list by passing NULL in callback argument*/
7232 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
7233 SME_SUMMARY_STATS |
7234 SME_GLOBAL_CLASSA_STATS |
7235 SME_GLOBAL_CLASSB_STATS |
7236 SME_GLOBAL_CLASSC_STATS |
7237 SME_GLOBAL_CLASSD_STATS |
7238 SME_PER_STA_STATS,
7239 NULL, 0, FALSE,
7240 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
7241
7242 return -EINVAL;
7243 }
7244 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
7245 (tANI_U8) sizeof (pStats->retry_cnt),
7246 (char*) &(pStats->retry_cnt[0]),
7247 tlen);
7248
7249 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
7250 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
7251 (char*) &(pStats->multiple_retry_cnt[0]),
7252 tlen);
7253
7254 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
7255 (tANI_U8) sizeof (pStats->tx_frm_cnt),
7256 (char*) &(pStats->tx_frm_cnt[0]),
7257 tlen);
7258
7259 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
7260 (tANI_U8) sizeof (pStats->rx_frm_cnt),
7261 (char*) &(pStats->rx_frm_cnt),
7262 tlen);
7263
7264 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
7265 (tANI_U8) sizeof (pStats->frm_dup_cnt),
7266 (char*) &(pStats->frm_dup_cnt),
7267 tlen);
7268
7269 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
7270 (tANI_U8) sizeof (pStats->fail_cnt),
7271 (char*) &(pStats->fail_cnt[0]),
7272 tlen);
7273
7274 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
7275 (tANI_U8) sizeof (pStats->rts_fail_cnt),
7276 (char*) &(pStats->rts_fail_cnt),
7277 tlen);
7278
7279 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
7280 (tANI_U8) sizeof (pStats->ack_fail_cnt),
7281 (char*) &(pStats->ack_fail_cnt),
7282 tlen);
7283
7284 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
7285 (tANI_U8) sizeof (pStats->rts_succ_cnt),
7286 (char*) &(pStats->rts_succ_cnt),
7287 tlen);
7288
7289 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
7290 (tANI_U8) sizeof (pStats->rx_discard_cnt),
7291 (char*) &(pStats->rx_discard_cnt),
7292 tlen);
7293
7294 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
7295 (tANI_U8) sizeof (pStats->rx_error_cnt),
7296 (char*) &(pStats->rx_error_cnt),
7297 tlen);
7298
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007299 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07007300 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007301 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 tlen);
7303
7304 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
7305 (tANI_U8) sizeof (dStats->rx_byte_cnt),
7306 (char*) &(dStats->rx_byte_cnt),
7307 tlen);
7308
7309 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
7310 (tANI_U8) sizeof (dStats->rx_rate),
7311 (char*) &(dStats->rx_rate),
7312 tlen);
7313
7314 /* Transmit rate, in units of 500 kbit/sec */
7315 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
7316 (tANI_U8) sizeof (aStats->tx_rate),
7317 (char*) &(aStats->tx_rate),
7318 tlen);
7319
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007320 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
7321 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
7322 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07007323 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007324 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
7325 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
7326 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007327 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007328 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
7329 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
7330 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007331 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007332 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
7333 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
7334 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07007335 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007336 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
7337 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
7338 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007339 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007340 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
7341 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
7342 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007343 tlen);
7344
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 wrqu->data.length = tlen;
7346
7347 }
7348
7349 EXIT();
7350
7351 return 0;
7352}
7353
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307354static int iw_get_statistics(struct net_device *dev,
7355 struct iw_request_info *info,
7356 union iwreq_data *wrqu, char *extra)
7357{
7358 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007359
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307360 vos_ssr_protect(__func__);
7361 ret = __iw_get_statistics(dev, info, wrqu, extra);
7362 vos_ssr_unprotect(__func__);
7363
7364 return ret;
7365}
Jeff Johnson295189b2012-06-20 16:38:30 -07007366#ifdef FEATURE_WLAN_SCAN_PNO
7367
7368/*Max Len for PNO notification*/
7369#define MAX_PNO_NOTIFY_LEN 100
7370void found_pref_network_cb (void *callbackContext,
7371 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7372{
7373 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7374 union iwreq_data wrqu;
7375 char buf[MAX_PNO_NOTIFY_LEN+1];
7376
7377 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
7378 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
7379
7380 // create the event
7381 memset(&wrqu, 0, sizeof(wrqu));
7382 memset(buf, 0, sizeof(buf));
7383
7384 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
7385 pPrefNetworkFoundInd->ssId.ssId,
7386 (unsigned int)pPrefNetworkFoundInd->rssi);
7387
7388 wrqu.data.pointer = buf;
7389 wrqu.data.length = strlen(buf);
7390
7391 // send the event
7392
7393 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
7394
7395}
7396
7397
7398/*string based input*/
7399VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
7400 union iwreq_data *wrqu, char *extra, int nOffset)
7401{
7402 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05307403 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07007404 /* pnoRequest is a large struct, so we make it static to avoid stack
7405 overflow. This API is only invoked via ioctl, so it is
7406 serialized by the kernel rtnl_lock and hence does not need to be
7407 reentrant */
7408 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 char *ptr;
7410 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05307411 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7413
7414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7415 "PNO data len %d data %s",
7416 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007417 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007418
7419 if (wrqu->data.length <= nOffset )
7420 {
7421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
7422 return VOS_STATUS_E_FAILURE;
7423 }
7424
7425 pnoRequest.enable = 0;
7426 pnoRequest.ucNetworksCount = 0;
7427 /*-----------------------------------------------------------------------
7428 Input is string based and expected to be like this:
7429
7430 <enabled> <netw_count>
7431 for each network:
7432 <ssid_len> <ssid> <authentication> <encryption>
7433 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
7434 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
7435
7436 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07007437 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 -07007438
7439 this translates into:
7440 -----------------------------
7441 enable PNO
7442 look for 2 networks:
7443 test - with authentication type 0 and encryption type 0,
7444 that can be found on 3 channels: 1 6 and 11 ,
7445 SSID bcast type is unknown (directed probe will be sent if AP not found)
7446 and must meet -40dBm RSSI
7447
7448 test2 - with auth and enrytption type 4/4
7449 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
7450 bcast type is non-bcast (directed probe will be sent)
7451 and must not meet any RSSI threshold
7452
Jeff Johnson8301aa12013-03-28 14:27:29 -07007453 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07007454 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08007455 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007456
Wilson Yang623f6592013-10-08 16:33:37 -07007457 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
7458 {
7459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7460 "PNO enable input is not valid %s",ptr);
7461 return VOS_STATUS_E_FAILURE;
7462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007463
7464 if ( 0 == pnoRequest.enable )
7465 {
7466 /*Disable PNO*/
7467 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05307468 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7469 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007470 pAdapter->sessionId,
7471 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307472 if (eHAL_STATUS_SUCCESS != status)
7473 {
7474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7475 "%s: failed to disable PNO", __func__);
7476 return VOS_STATUS_E_FAILURE;
7477 }
7478 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007479 return VOS_STATUS_SUCCESS;
7480 }
7481
c_hpothu37f21312014-04-09 21:49:54 +05307482 if (TRUE == pHddCtx->isPnoEnable)
7483 {
7484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7485 FL("already PNO is enabled"));
7486 return -EBUSY;
7487 }
7488 pHddCtx->isPnoEnable = TRUE;
7489
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07007491
7492 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
7493 {
7494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7495 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307496 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007498
7499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7500 "PNO enable %d networks count %d offset %d",
7501 pnoRequest.enable,
7502 pnoRequest.ucNetworksCount,
7503 nOffset);
7504
7505 /* Parameters checking:
7506 ucNetworksCount has to be larger than 0*/
7507 if (( 0 == pnoRequest.ucNetworksCount ) ||
7508 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7509 {
7510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05307511 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 }
7513
7514 ptr += nOffset;
7515
7516 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
7517 {
7518
7519 pnoRequest.aNetworks[i].ssId.length = 0;
7520
Wilson Yang623f6592013-10-08 16:33:37 -07007521 ucParams = sscanf(ptr,"%hhu %n",
7522 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
7523
7524 if (1 != ucParams)
7525 {
7526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7527 "PNO ssid length input is not valid %s",ptr);
7528 return VOS_STATUS_E_FAILURE;
7529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007530
7531 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
7532 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
7533 {
7534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7535 "SSID Len %d is not correct for network %d",
7536 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05307537 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 }
7539
7540 /*Advance to SSID*/
7541 ptr += nOffset;
7542
Jeff Johnson8301aa12013-03-28 14:27:29 -07007543 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08007544 pnoRequest.aNetworks[i].ssId.length);
7545 ptr += pnoRequest.aNetworks[i].ssId.length;
7546
Jeff Johnson02797792013-10-26 19:17:13 -07007547 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007548 &(pnoRequest.aNetworks[i].authentication),
7549 &(pnoRequest.aNetworks[i].encryption),
7550 &(pnoRequest.aNetworks[i].ucChannelCount),
7551 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007552
Wilson Yang623f6592013-10-08 16:33:37 -07007553 if ( 3 != ucParams )
7554 {
7555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7556 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307557 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007558 }
7559
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007561 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08007562 "auth %d encry %d channel count %d offset %d",
7563 pnoRequest.aNetworks[i].ssId.length,
7564 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
7565 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
7566 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
7567 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
7568 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
7569 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
7570 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
7571 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
7572 pnoRequest.aNetworks[i].authentication,
7573 pnoRequest.aNetworks[i].encryption,
7574 pnoRequest.aNetworks[i].ucChannelCount,
7575 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07007576
Jeff Johnson295189b2012-06-20 16:38:30 -07007577 /*Advance to channel list*/
7578 ptr += nOffset;
7579
Wilson Yang623f6592013-10-08 16:33:37 -07007580 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07007581 {
7582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7583 "Incorrect number of channels");
7584 return VOS_STATUS_E_FAILURE;
7585 }
7586
7587 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
7588 {
7589 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
7590 {
Wilson Yang623f6592013-10-08 16:33:37 -07007591 if (1 != sscanf(ptr,"%hhu %n",
7592 &(pnoRequest.aNetworks[i].aChannels[j]),
7593 &nOffset))
7594 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7595 "PNO network channel input is not valid %s",ptr);
7596 return VOS_STATUS_E_FAILURE;
7597 }
7598 /*Advance to next channel number*/
7599 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 }
7601 }
7602
Jeff Johnson02797792013-10-26 19:17:13 -07007603 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007604 &(pnoRequest.aNetworks[i].bcastNetwType),
7605 &nOffset))
7606 {
7607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7608 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307609 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007611
7612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7613 "PNO bcastNetwType %d offset %d",
7614 pnoRequest.aNetworks[i].bcastNetwType,
7615 nOffset );
7616
7617 /*Advance to rssi Threshold*/
7618 ptr += nOffset;
7619
Wilson Yang623f6592013-10-08 16:33:37 -07007620 if (1 != sscanf(ptr,"%hhu %n",
7621 &(pnoRequest.aNetworks[i].rssiThreshold),
7622 &nOffset))
7623 {
7624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7625 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307626 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007628
7629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7630 "PNO rssi %d offset %d",
7631 pnoRequest.aNetworks[i].rssiThreshold,
7632 nOffset );
7633 /*Advance to next network*/
7634 ptr += nOffset;
7635 }/*For ucNetworkCount*/
7636
7637 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007638 &(pnoRequest.scanTimers.ucScanTimersCount),
7639 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007640
7641 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007642 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 {
7644 ptr += nOffset;
7645
Jeff Johnson8301aa12013-03-28 14:27:29 -07007646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7647 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 pnoRequest.scanTimers.ucScanTimersCount,
7649 nOffset );
7650
7651 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7652 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007654 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307655 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007656 }
7657
7658 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7659 {
Jeff Johnson02797792013-10-26 19:17:13 -07007660 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7662 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7663 &nOffset);
7664
Wilson Yang623f6592013-10-08 16:33:37 -07007665 if (2 != ucParams)
7666 {
7667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7668 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307669 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007670 }
7671
Jeff Johnson8301aa12013-03-28 14:27:29 -07007672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7673 "PNO Timer value %d Timer repeat %d offset %d",
7674 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007675 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7676 nOffset );
7677
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 ptr += nOffset;
7679 }
7680
7681 }
7682 else
7683 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7685 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7687
7688 /*Scan timers defaults to 5 minutes*/
7689 pnoRequest.scanTimers.ucScanTimersCount = 1;
7690 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7691 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7692 }
7693
Wilson Yang623f6592013-10-08 16:33:37 -07007694 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007695
7696 pnoRequest.modePNO = ucMode;
7697 /*for LA we just expose suspend option*/
7698 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7699 {
7700 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7701 }
7702
c_hpothu37f21312014-04-09 21:49:54 +05307703 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 pAdapter->sessionId,
7705 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307706 if (eHAL_STATUS_SUCCESS == status)
7707 {
7708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7709 "%s: PNO enabled", __func__);
7710 return VOS_STATUS_SUCCESS;
7711 }
7712error:
7713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7714 "%s: Failed to enable PNO", __func__);
7715 pHddCtx->isPnoEnable = FALSE;
7716 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007717}/*iw_set_pno*/
7718
7719VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7720 union iwreq_data *wrqu, char *extra, int nOffset)
7721{
7722 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7723 v_U8_t rssiThreshold = 0;
7724 v_U8_t nRead;
7725
Arif Hussain7adce1b2013-11-11 22:59:34 -08007726 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007727 &rssiThreshold);
7728
7729 if ( 1 != nRead )
7730 {
7731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7732 "Incorrect format");
7733 return VOS_STATUS_E_FAILURE;
7734 }
7735
7736 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7737 return VOS_STATUS_SUCCESS;
7738}
7739
7740
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307741static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 struct iw_request_info *info,
7743 union iwreq_data *wrqu, char *extra)
7744{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007745 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7746
7747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007749
7750 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7751 {
7752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7753 "%s:LOGP in Progress. Ignore!!!", __func__);
7754 return -EBUSY;
7755 }
7756 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007757}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307758
7759static int iw_set_pno_priv(struct net_device *dev,
7760 struct iw_request_info *info,
7761 union iwreq_data *wrqu, char *extra)
7762{
7763 int ret;
7764
7765 vos_ssr_protect(__func__);
7766 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
7767 vos_ssr_unprotect(__func__);
7768
7769 return ret;
7770}
Jeff Johnson295189b2012-06-20 16:38:30 -07007771#endif /*FEATURE_WLAN_SCAN_PNO*/
7772
7773//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307774int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007775{
7776 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7777 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7778 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307779 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007780 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307781 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307782 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
7783 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07007784
Atul Mittal54378cb2014-04-02 16:51:50 +05307785 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 {
7787 case WLAN_HDD_UI_BAND_AUTO:
7788 band = eCSR_BAND_ALL;
7789 break;
7790 case WLAN_HDD_UI_BAND_5_GHZ:
7791 band = eCSR_BAND_5G;
7792 break;
7793 case WLAN_HDD_UI_BAND_2_4_GHZ:
7794 band = eCSR_BAND_24;
7795 break;
7796 default:
7797 band = eCSR_BAND_MAX;
7798 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307799 connectedBand =
7800 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007801
Atul Mittal54378cb2014-04-02 16:51:50 +05307802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007803 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007804
7805 if (band == eCSR_BAND_MAX)
7806 {
7807 /* Received change band request with invalid band value */
7808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307809 "%s: Invalid band value %u", __func__, ui_band);
7810 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007811 }
7812
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307813 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7814 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7815 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7816 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007818 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007819 band, pHddCtx->cfg_ini->nBandCapability);
7820 return -EIO;
7821 }
7822
Jeff Johnson295189b2012-06-20 16:38:30 -07007823 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7824 {
7825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7826 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007827 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007828 return -EIO;
7829 }
7830
7831 if (currBand != band)
7832 {
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307833 /* Return failure if current country code is world regulatory domain*/
7834 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
7835 pMac->scan.countryCodeCurrent[1] == '0') )
7836 {
7837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7838 "%s: failed to set the band value to %u as country code is 00",
7839 __func__, band);
7840 return -EAGAIN;
7841 }
7842
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 /* Change band request received.
7844 * Abort pending scan requests, flush the existing scan results,
7845 * and change the band capability
7846 */
7847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7848 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007849 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007850
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307851 /* We need to change the band and flush the scan results here itself
7852 * as we may get timeout for disconnection in which we will return
7853 * with out doing any of these
7854 */
7855 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7856 {
7857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7858 "%s: failed to set the band value to %u ",
7859 __func__, band);
7860 return -EINVAL;
7861 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307862 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
7863 {
7864 v_COUNTRYCODE_t curr_country;
7865 curr_country[0]=pMac->scan.countryCodeCurrent[0];
7866 curr_country[1]=pMac->scan.countryCodeCurrent[1];
7867
7868 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
7869 * information available in NV so to get the channel information from kernel
7870 * we need to send regulatory hint for the currunt country
7871 * And to set the same country again we need to set the dummy country
7872 * first and then the actual country.
7873 */
7874
7875#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
7876 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
7877#else
7878 regulatory_hint_user("00");
7879#endif
7880
7881 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
7882#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
7883 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
7884#else
7885 regulatory_hint_user(curr_country);
7886#endif
7887 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
7888 }
7889 else
7890 {
7891 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
7892 (void *)pHddCtx->wiphy, (eCsrBand)band);
7893 }
7894
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307895 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7896 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7897 sme_FilterScanResults(hHal, pAdapter->sessionId);
7898
7899 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307900 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7901 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007902 {
7903 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7904 eHalStatus status = eHAL_STATUS_SUCCESS;
7905 long lrc;
7906
7907 /* STA already connected on current band, So issue disconnect first,
7908 * then change the band*/
7909
7910 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05307911 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
7912 " Set HDD connState to eConnectionState_NotConnected",
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 __func__, csrGetCurrentBand(hHal), band);
7914
7915 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7916 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7917
7918 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7919 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7920
Jeff Johnson43971f52012-07-17 12:26:56 -07007921 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 {
7923 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007924 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007925 __func__, (int)status );
7926 return -EINVAL;
7927 }
7928
7929 lrc = wait_for_completion_interruptible_timeout(
7930 &pAdapter->disconnect_comp_var,
7931 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7932
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307933 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007934
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007935 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007936 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007937
7938 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7939 }
7940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007941 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307942 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007943}
7944
Atul Mittal54378cb2014-04-02 16:51:50 +05307945int hdd_setBand_helper(struct net_device *dev, const char *command)
7946{
7947 u8 band;
7948
7949 /*convert the band value from ascii to integer*/
7950 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7951
7952 return hdd_setBand(dev, band);
7953
7954}
7955
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307956static int __iw_set_band_config(struct net_device *dev,
7957 struct iw_request_info *info,
7958 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007959{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007960 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307961 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007962
Arif Hussain0273cba2014-01-07 20:58:29 -08007963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007964
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007965 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7966 {
7967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7968 "%s:LOGP in Progress. Ignore!!!", __func__);
7969 return -EBUSY;
7970 }
7971
Atul Mittal54378cb2014-04-02 16:51:50 +05307972 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007973}
7974
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307975static int iw_set_band_config(struct net_device *dev,
7976 struct iw_request_info *info,
7977 union iwreq_data *wrqu, char *extra)
7978{
7979 int ret;
7980
7981 vos_ssr_protect(__func__);
7982 ret = __iw_set_band_config(dev, info, wrqu, extra);
7983 vos_ssr_unprotect(__func__);
7984
7985 return ret;
7986}
7987
7988static int __iw_set_power_params_priv(struct net_device *dev,
7989 struct iw_request_info *info,
7990 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007991{
Arif Hussain0273cba2014-01-07 20:58:29 -08007992 int ret;
7993 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7995 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007996 /* ODD number is used for set, copy data using copy_from_user */
7997 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7998 wrqu->data.length);
7999 if (NULL == ptr)
8000 {
8001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8002 "mem_alloc_copy_from_user_helper fail");
8003 return -ENOMEM;
8004 }
8005
8006 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
8007 kfree(ptr);
8008 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008009}
8010
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308011static int iw_set_power_params_priv(struct net_device *dev,
8012 struct iw_request_info *info,
8013 union iwreq_data *wrqu, char *extra)
8014{
8015 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008016
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308017 vos_ssr_protect(__func__);
8018 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
8019 vos_ssr_unprotect(__func__);
8020
8021 return ret;
8022}
Jeff Johnson295189b2012-06-20 16:38:30 -07008023
8024/*string based input*/
8025VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
8026 union iwreq_data *wrqu, char *extra, int nOffset)
8027{
8028 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8029 tSirSetPowerParamsReq powerRequest;
8030 char *ptr;
8031 v_U8_t ucType;
8032 v_U32_t uTotalSize, uValue;
8033 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8034
8035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8036 "Power Params data len %d data %s",
8037 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008038 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008039
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008040 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
8041 {
8042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8043 "%s:LOGP in Progress. Ignore!!!", __func__);
8044 return -EBUSY;
8045 }
8046
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 if (wrqu->data.length <= nOffset )
8048 {
8049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
8050 return VOS_STATUS_E_FAILURE;
8051 }
8052
8053 uTotalSize = wrqu->data.length - nOffset;
8054
8055 /*-----------------------------------------------------------------------
8056 Input is string based and expected to be like this:
8057
8058 <param_type> <param_value> <param_type> <param_value> ...
8059
8060 e.g:
8061 1 2 2 3 3 0 4 1 5 1
8062
8063 e.g. setting just a few:
8064 1 2 4 1
8065
8066 parameter types:
8067 -----------------------------
8068 1 - Ignore DTIM
8069 2 - Listen Interval
8070 3 - Broadcast Multicas Filter
8071 4 - Beacon Early Termination
8072 5 - Beacon Early Termination Interval
8073 -----------------------------------------------------------------------*/
8074 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
8075 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
8076 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
8077 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
8078 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
8079
Arif Hussain7adce1b2013-11-11 22:59:34 -08008080 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008081
8082 while ( uTotalSize )
8083 {
Wilson Yang6f971452013-10-08 15:00:00 -07008084 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
8085 {
8086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8087 "Invalid input parameter type %s",ptr);
8088 return VOS_STATUS_E_FAILURE;
8089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008090
8091 uTotalSize -= nOffset;
8092
8093 if (!uTotalSize)
8094 {
8095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08008096 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 ucType, nOffset);
8098 return VOS_STATUS_E_FAILURE;
8099 }
8100
8101 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07008102
Jeff Johnson02797792013-10-26 19:17:13 -07008103 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07008104 {
8105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8106 "Invalid input parameter value %s",ptr);
8107 return VOS_STATUS_E_FAILURE;
8108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008109
8110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8111 "Power request parameter %d value %d offset %d",
8112 ucType, uValue, nOffset);
8113
8114 switch (ucType)
8115 {
8116 case eSIR_IGNORE_DTIM:
8117 powerRequest.uIgnoreDTIM = uValue;
8118 break;
8119 case eSIR_LISTEN_INTERVAL:
8120 powerRequest.uListenInterval = uValue;
8121 break;
8122 case eSIR_MCAST_BCAST_FILTER:
8123 powerRequest.uBcastMcastFilter = uValue;
8124 break;
8125 case eSIR_ENABLE_BET:
8126 powerRequest.uEnableBET = uValue;
8127 break;
8128 case eSIR_BET_INTERVAL:
8129 powerRequest.uBETInterval = uValue;
8130 break;
8131 default:
8132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08008133 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 ucType, uValue, nOffset);
8135 return VOS_STATUS_E_FAILURE;
8136 }
8137
8138 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8140 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07008141 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07008143 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008144 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07008145 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
8146 {
8147 uTotalSize = 0;
8148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008149
8150 }/*Go for as long as we have a valid string*/
8151
8152 /* put the device into full power*/
8153 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
8154
8155 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08008156 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008157
8158 /* put the device back to power save*/
8159 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
8160
8161 return VOS_STATUS_SUCCESS;
8162}/*iw_set_power_params*/
8163
Atul Mittalc0f739f2014-07-31 13:47:47 +05308164// tdlsoffchan
8165#ifdef FEATURE_WLAN_TDLS
8166
8167static int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
8168{
8169 if (offchannel < 0 || offchannel > 165)
8170 {
8171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
8172 __func__, offchannel);
8173 return -1;
8174
8175 }
8176
8177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
8178 __func__, tdlsOffCh, offchannel);
8179
8180 tdlsOffCh = offchannel;
8181 return 0;
8182}
8183
8184static int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
8185{
8186 if (offchanoffset == 0)
8187 {
8188 tdlsOffChBwOffset = 0;
8189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8190 __func__, tdlsOffChBwOffset);
8191
8192 return 0;
8193
8194 }
8195
8196 if ( offchanoffset == 40 )
8197 {
8198 tdlsOffChBwOffset = 1;
8199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8200 __func__, tdlsOffChBwOffset);
8201
8202 return 0;
8203
8204 }
8205 if (offchanoffset == -40)
8206 {
8207 tdlsOffChBwOffset = 3;
8208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8209 __func__, tdlsOffChBwOffset);
8210
8211 return 0;
8212
8213 }
8214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
8215 __func__, offchanoffset);
8216 return -1;
8217}
8218
8219static int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
8220{
8221 hddTdlsPeer_t *connPeer = NULL;
8222 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8223 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8224
8225 if (offchanmode < 0 || offchanmode > 4)
8226 {
8227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8228 "%s: Invalid tdls off channel mode %d",
8229 __func__, offchanmode);
8230 return -1;
8231 }
8232
8233 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8234 {
8235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8236 "%s: tdls off channel mode req in not associated state %d",
8237 __func__, offchanmode);
8238 return -1;
8239 }
8240
8241 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
8242 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
8243 {
8244 /* Send TDLS Channel Switch Request to connected peer */
8245 connPeer = wlan_hdd_tdls_get_first_connected_peer(pAdapter);
8246 if (NULL == connPeer) {
8247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8248 "%s: No TDLS Connected Peer", __func__);
8249 return -1;
8250 }
8251 }
8252 else
8253 {
8254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8255 "%s: TDLS Connection not supported", __func__);
8256 return -1;
8257 }
8258
8259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8260 ("%s: TDLS Channel Switch in swmode=%d"),
8261 __func__, offchanmode);
8262
8263 switch (offchanmode)
8264 {
8265 case 1:/*Enable*/
8266 case 2:/*Disable*/
8267 {
8268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8269 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
8270 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8271 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
8272 {
8273
8274 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
8275 pAdapter->sessionId, connPeer->peerMac,
8276 tdlsOffCh, tdlsOffChBwOffset,
8277 offchanmode);
8278 }
8279 else
8280 {
8281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8282 "%s: TDLS Off Channel not supported", __func__);
8283 return -1;
8284 }
8285 break;
8286 }
8287 case 3:
8288 {
8289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8290 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
8291 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8292
8293 break;
8294 }
8295 case 4:
8296 {
8297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8298 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
8299 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8300 break;
8301 }
8302 default:
8303 {
8304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8305 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
8306 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8307 break;
8308 }
8309
8310 }
8311
8312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
8313 __func__, offchanmode);
8314 return 0;
8315}
8316
8317#endif
8318
Jeff Johnson295189b2012-06-20 16:38:30 -07008319
8320// Define the Wireless Extensions to the Linux Network Device structure
8321// A number of these routines are NULL (meaning they are not implemented.)
8322
8323static const iw_handler we_handler[] =
8324{
8325 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
8326 (iw_handler) iw_get_name, /* SIOCGIWNAME */
8327 (iw_handler) NULL, /* SIOCSIWNWID */
8328 (iw_handler) NULL, /* SIOCGIWNWID */
8329 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
8330 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
8331 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
8332 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
8333 (iw_handler) NULL, /* SIOCSIWSENS */
8334 (iw_handler) NULL, /* SIOCGIWSENS */
8335 (iw_handler) NULL, /* SIOCSIWRANGE */
8336 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
8337 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
8338 (iw_handler) NULL, /* SIOCGIWPRIV */
8339 (iw_handler) NULL, /* SIOCSIWSTATS */
8340 (iw_handler) NULL, /* SIOCGIWSTATS */
8341 iw_handler_set_spy, /* SIOCSIWSPY */
8342 iw_handler_get_spy, /* SIOCGIWSPY */
8343 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
8344 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
8345 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
8346 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
8347 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
8348 (iw_handler) NULL, /* SIOCGIWAPLIST */
8349 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
8350 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
8351 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
8352 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
8353 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
8354 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
8355 (iw_handler) NULL, /* -- hole -- */
8356 (iw_handler) NULL, /* -- hole -- */
8357 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
8358 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
8359 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
8360 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
8361 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
8362 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
8363 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
8364 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
8365 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
8366 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
8367 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
8368 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
8369 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
8370 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
8371 (iw_handler) NULL, /* -- hole -- */
8372 (iw_handler) NULL, /* -- hole -- */
8373 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
8374 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
8375 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
8376 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
8377 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
8378 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
8379 (iw_handler) NULL, /* SIOCSIWPMKSA */
8380};
8381
8382static const iw_handler we_private[] = {
8383
8384 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
8385 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
8386 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
8387 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
8388 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
8389 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
8390 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
8391 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
8392 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
8393 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07008394#ifdef FEATURE_OEM_DATA_SUPPORT
8395 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
8396 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
8397#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008398
Jeff Johnson295189b2012-06-20 16:38:30 -07008399#ifdef WLAN_FEATURE_VOWIFI_11R
8400 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
8401#endif
8402 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
8403 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
8404 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
8405#ifdef WLAN_FEATURE_PACKET_FILTERING
8406 ,
8407 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
8408#endif
8409#ifdef FEATURE_WLAN_SCAN_PNO
8410 ,
8411 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
8412#endif
8413 ,
8414 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
8415 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
8416 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
8417 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07008418 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07008419};
8420
8421/*Maximum command length can be only 15 */
8422static const struct iw_priv_args we_private_args[] = {
8423
8424 /* handlers for main ioctl */
8425 { WLAN_PRIV_SET_INT_GET_NONE,
8426 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8427 0,
8428 "" },
8429
8430 /* handlers for sub-ioctl */
8431 { WE_SET_11D_STATE,
8432 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8433 0,
8434 "set11Dstate" },
8435
8436 { WE_WOWL,
8437 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8438 0,
8439 "wowl" },
8440
8441 { WE_SET_POWER,
8442 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8443 0,
8444 "setPower" },
8445
8446 { WE_SET_MAX_ASSOC,
8447 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8448 0,
8449 "setMaxAssoc" },
8450
8451 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
8452 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8453 0,
8454 "setAutoChannel" },
8455
8456 { WE_SET_DATA_INACTIVITY_TO,
8457 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8458 0,
8459 "inactivityTO" },
8460
8461 { WE_SET_MAX_TX_POWER,
8462 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8463 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07008464 "setMaxTxPower" },
8465
8466 { WE_SET_MAX_TX_POWER_2_4,
8467 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8468 0,
8469 "setTxMaxPower2G" },
8470
8471 { WE_SET_MAX_TX_POWER_5_0,
8472 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8473 0,
8474 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07008475
8476 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
8477 * as well to keep same syntax as in SAP. Now onwards, STA
8478 * will support both */
8479 { WE_SET_MAX_TX_POWER,
8480 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8481 0,
8482 "setTxMaxPower" },
8483
Jeff Johnson295189b2012-06-20 16:38:30 -07008484 /* set Higher DTIM Transition (DTIM1 to DTIM3)
8485 * 1 = enable and 0 = disable */
8486 {
8487 WE_SET_HIGHER_DTIM_TRANSITION,
8488 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8489 0,
8490 "setHDtimTransn" },
8491
8492 { WE_SET_TM_LEVEL,
8493 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008494 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 "setTmLevel" },
8496
Kiet Lam46b8e4e2013-11-06 21:49:53 +05308497 { WE_ENABLE_STRICT_FCC_REG,
8498 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8499 0,
8500 "setStrictFCCreg" },
8501
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08008502 { WE_SET_DEBUG_LOG,
8503 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8504 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05308505#ifdef FEATURE_WLAN_TDLS
8506 {
8507 WE_SET_TDLS_OFF_CHAN,
8508 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8509 0,
8510 "tdlsoffchan" },
8511 {
8512 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
8513 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8514 0,
8515 "tdlsecchnoffst" },
8516 {
8517 WE_SET_TDLS_OFF_CHAN_MODE,
8518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8519 0,
8520 "tdlsoffchnmode" },
8521#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08008522
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 /* handlers for main ioctl */
8524 { WLAN_PRIV_SET_NONE_GET_INT,
8525 0,
8526 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8527 "" },
8528
8529 /* handlers for sub-ioctl */
8530 { WE_GET_11D_STATE,
8531 0,
8532 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8533 "get11Dstate" },
8534
8535 { WE_IBSS_STATUS,
8536 0,
8537 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8538 "getAdhocStatus" },
8539
8540 { WE_PMC_STATE,
8541 0,
8542 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8543 "pmcState" },
8544
8545 { WE_GET_WLAN_DBG,
8546 0,
8547 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8548 "getwlandbg" },
8549
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 { WE_GET_MAX_ASSOC,
8551 0,
8552 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8553 "getMaxAssoc" },
8554
Jeff Johnson295189b2012-06-20 16:38:30 -07008555 { WE_GET_WDI_DBG,
8556 0,
8557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8558 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008559
8560 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
8561 0,
8562 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8563 "getAutoChannel" },
8564
8565 { WE_GET_CONCURRENCY_MODE,
8566 0,
8567 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8568 "getconcurrency" },
8569
8570 /* handlers for main ioctl */
8571 { WLAN_PRIV_SET_CHAR_GET_NONE,
8572 IW_PRIV_TYPE_CHAR| 512,
8573 0,
8574 "" },
8575
8576 /* handlers for sub-ioctl */
8577 { WE_WOWL_ADD_PTRN,
8578 IW_PRIV_TYPE_CHAR| 512,
8579 0,
8580 "wowlAddPtrn" },
8581
8582 { WE_WOWL_DEL_PTRN,
8583 IW_PRIV_TYPE_CHAR| 512,
8584 0,
8585 "wowlDelPtrn" },
8586
8587#if defined WLAN_FEATURE_VOWIFI
8588 /* handlers for sub-ioctl */
8589 { WE_NEIGHBOR_REPORT_REQUEST,
8590 IW_PRIV_TYPE_CHAR | 512,
8591 0,
8592 "neighbor" },
8593#endif
8594 { WE_SET_AP_WPS_IE,
8595 IW_PRIV_TYPE_CHAR| 512,
8596 0,
8597 "set_ap_wps_ie" },
8598
8599 { WE_SET_CONFIG,
8600 IW_PRIV_TYPE_CHAR| 512,
8601 0,
8602 "setConfig" },
8603
8604 /* handlers for main ioctl */
8605 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
8606 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8607 0,
8608 "" },
8609
8610 /* handlers for sub-ioctl */
8611 { WE_SET_WLAN_DBG,
8612 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8613 0,
8614 "setwlandbg" },
8615
Jeff Johnson295189b2012-06-20 16:38:30 -07008616 { WE_SET_WDI_DBG,
8617 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8618 0,
8619 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008620
8621 { WE_SET_SAP_CHANNELS,
8622 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
8623 0,
8624 "setsapchannels" },
8625
8626 /* handlers for main ioctl */
8627 { WLAN_PRIV_GET_CHAR_SET_NONE,
8628 0,
8629 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8630 "" },
8631
8632 /* handlers for sub-ioctl */
8633 { WE_WLAN_VERSION,
8634 0,
8635 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8636 "version" },
8637 { WE_GET_STATS,
8638 0,
8639 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8640 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308641 { WE_GET_STATES,
8642 0,
8643 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8644 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008645 { WE_GET_CFG,
8646 0,
8647 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8648 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07008649#ifdef WLAN_FEATURE_11AC
8650 { WE_GET_RSSI,
8651 0,
8652 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8653 "getRSSI" },
8654#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008655#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008656 { WE_GET_ROAM_RSSI,
8657 0,
8658 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8659 "getRoamRSSI" },
8660#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 { WE_GET_WMM_STATUS,
8662 0,
8663 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8664 "getWmmStatus" },
8665 {
8666 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308667 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8669 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08008670#ifdef FEATURE_WLAN_TDLS
8671 {
8672 WE_GET_TDLS_PEERS,
8673 0,
8674 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8675 "getTdlsPeers" },
8676#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008677#ifdef WLAN_FEATURE_11W
8678 {
8679 WE_GET_11W_INFO,
8680 0,
8681 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8682 "getPMFInfo" },
8683#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05308684 { WE_GET_SNR,
8685 0,
8686 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8687 "getSNR" },
8688
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 /* handlers for main ioctl */
8690 { WLAN_PRIV_SET_NONE_GET_NONE,
8691 0,
8692 0,
8693 "" },
8694
8695 /* handlers for sub-ioctl */
8696 { WE_CLEAR_STATS,
8697 0,
8698 0,
8699 "clearStats" },
8700 { WE_INIT_AP,
8701 0,
8702 0,
8703 "initAP" },
8704 { WE_STOP_AP,
8705 0,
8706 0,
8707 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308708#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 { WE_ENABLE_AMP,
8710 0,
8711 0,
8712 "enableAMP" },
8713 { WE_DISABLE_AMP,
8714 0,
8715 0,
8716 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308717#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008718 { WE_ENABLE_DXE_STALL_DETECT,
8719 0,
8720 0,
8721 "dxeStallDetect" },
8722 { WE_DISPLAY_DXE_SNAP_SHOT,
8723 0,
8724 0,
8725 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308726 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
8727 0,
8728 0,
8729 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07008730 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05308731 WE_SET_REASSOC_TRIGGER,
8732 0,
8733 0,
8734 "reassoc" },
8735 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05308736 WE_STOP_OBSS_SCAN,
8737 0,
8738 0,
8739 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +05308740#ifdef DEBUG_ROAM_DELAY
8741 {
8742 WE_DUMP_ROAM_TIMER_LOG,
8743 0,
8744 0,
8745 "dumpRoamDelay" },
8746 {
8747 WE_RESET_ROAM_TIMER_LOG,
8748 0,
8749 0,
8750 "resetRoamDelay" },
8751#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008752 /* handlers for main ioctl */
8753 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
8754 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8755 0,
8756 "" },
8757
8758 /* handlers for sub-ioctl */
8759 { WE_LOG_DUMP_CMD,
8760 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8761 0,
8762 "dump" },
8763
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008764 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308765 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8766 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8767 0,
8768 "setdumplog" },
8769
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008770 { WE_MTRACE_DUMP_CMD,
8771 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8772 0,
8773 "dumplog" },
8774
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008775 /* handlers for sub ioctl */
8776 {
8777 WE_MCC_CONFIG_CREDENTIAL,
8778 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8779 0,
8780 "setMccCrdnl" },
8781
8782 /* handlers for sub ioctl */
8783 {
8784 WE_MCC_CONFIG_PARAMS,
8785 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8786 0,
8787 "setMccConfig" },
8788
Chilam NG571c65a2013-01-19 12:27:36 +05308789#ifdef FEATURE_WLAN_TDLS
8790 /* handlers for sub ioctl */
8791 {
8792 WE_TDLS_CONFIG_PARAMS,
8793 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8794 0,
8795 "setTdlsConfig" },
8796#endif
8797
Jeff Johnson295189b2012-06-20 16:38:30 -07008798 /* handlers for main ioctl */
8799 { WLAN_PRIV_ADD_TSPEC,
8800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8801 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8802 "addTspec" },
8803
8804 /* handlers for main ioctl */
8805 { WLAN_PRIV_DEL_TSPEC,
8806 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8807 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8808 "delTspec" },
8809
8810 /* handlers for main ioctl */
8811 { WLAN_PRIV_GET_TSPEC,
8812 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8813 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8814 "getTspec" },
8815
Jeff Johnsone7245742012-09-05 17:12:55 -07008816#ifdef FEATURE_OEM_DATA_SUPPORT
8817 /* handlers for main ioctl - OEM DATA */
8818 {
8819 WLAN_PRIV_SET_OEM_DATA_REQ,
8820 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8821 0,
8822 "set_oem_data_req" },
8823
8824 /* handlers for main ioctl - OEM DATA */
8825 {
8826 WLAN_PRIV_GET_OEM_DATA_RSP,
8827 0,
8828 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8829 "get_oem_data_rsp" },
8830#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008831
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 /* handlers for main ioctl - host offload */
8833 {
8834 WLAN_PRIV_SET_HOST_OFFLOAD,
8835 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8836 0,
8837 "setHostOffload" },
8838
8839 {
8840 WLAN_GET_WLAN_STATISTICS,
8841 0,
8842 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8843 "getWlanStats" },
8844
8845 {
8846 WLAN_SET_KEEPALIVE_PARAMS,
8847 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8848 0,
8849 "setKeepAlive" },
8850#ifdef WLAN_FEATURE_PACKET_FILTERING
8851 {
8852 WLAN_SET_PACKET_FILTER_PARAMS,
8853 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8854 0,
8855 "setPktFilter" },
8856#endif
8857#ifdef FEATURE_WLAN_SCAN_PNO
8858 {
8859 WLAN_SET_PNO,
8860 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8861 0,
8862 "setpno" },
8863#endif
8864 {
8865 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308866 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008867 0,
8868 "SETBAND" },
8869 /* handlers for dynamic MC BC ioctl */
8870 {
8871 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008872 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 0,
8874 "setMCBCFilter" },
8875 {
8876 WLAN_PRIV_CLEAR_MCBC_FILTER,
8877 0,
8878 0,
8879 "clearMCBCFilter" },
8880 {
8881 WLAN_SET_POWER_PARAMS,
8882 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8883 0,
8884 "setpowerparams" },
8885 {
8886 WLAN_GET_LINK_SPEED,
8887 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308888 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008889};
8890
8891
8892
8893const struct iw_handler_def we_handler_def = {
8894 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8895 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8896 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8897
8898 .standard = (iw_handler *)we_handler,
8899 .private = (iw_handler *)we_private,
8900 .private_args = we_private_args,
8901 .get_wireless_stats = get_wireless_stats,
8902};
8903
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008904int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8905{
8906 v_U32_t cmd = 288; //Command to RIVA
8907 hdd_context_t *pHddCtx = NULL;
8908 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8909 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8910 /*
8911 *configMccParam : specify the bit which needs to be modified
8912 *allowed to update based on wlan_qcom_cfg.ini
8913 * configuration
8914 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8915 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8916 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8917 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8918 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8919 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8920 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8921 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8922 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8923 * Bit 9 : Reserved
8924 */
8925 switch (arg1)
8926 {
8927 //Update MCC SCHEDULE_TIME_SLICE parameter
8928 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8929 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8930 {
8931 if((arg2 >= 5) && (arg2 <= 20))
8932 {
8933 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8934 }
8935 else
8936 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008937 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008938 return 0;
8939 }
8940 }
8941 break;
8942
8943 //Update MCC MAX_NULL_SEND_TIME parameter
8944 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8945 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8946 {
8947 if((arg2 >= 1) && (arg2 <= 10))
8948 {
8949 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8950 }
8951 else
8952 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008953 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008954 return 0;
8955 }
8956 }
8957 break;
8958
8959 //Update MCC TX_EARLY_STOP_TIME parameter
8960 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8961 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8962 {
8963 if((arg2 >= 1) && (arg2 <= 10))
8964 {
8965 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8966 }
8967 else
8968 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008969 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008970 return 0;
8971 }
8972 }
8973 break;
8974
8975 //Update MCC RX_DRAIN_TIME parameter
8976 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8977 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8978 {
8979 if((arg2 >= 1) && (arg2 <= 10))
8980 {
8981 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8982 }
8983 else
8984 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008985 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008986 return 0;
8987 }
8988 }
8989 break;
8990
8991 //Update MCC CHANNEL_SWITCH_TIME parameter
8992 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8993 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8994 {
8995 if((arg2 >= 1) && (arg2 <= 20))
8996 {
8997 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8998 }
8999 else
9000 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009001 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009002 return 0;
9003 }
9004 }
9005 break;
9006
9007 //Update MCC MIN_CHANNEL_TIME parameter
9008 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
9009 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
9010 {
9011 if((arg2 >= 5) && (arg2 <= 20))
9012 {
9013 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9014 }
9015 else
9016 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009017 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009018 return 0;
9019 }
9020 }
9021 break;
9022
9023 //Update MCC PARK_BEFORE_TBTT parameter
9024 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
9025 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
9026 {
9027 if((arg2 >= 1) && (arg2 <= 5))
9028 {
9029 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9030 }
9031 else
9032 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009033 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009034 return 0;
9035 }
9036 }
9037 break;
9038
9039 //Update MCC MIN_AFTER_DTIM parameter
9040 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
9041 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
9042 {
9043 if((arg2 >= 5) && (arg2 <= 15))
9044 {
9045 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9046 }
9047 else
9048 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009049 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009050 return 0;
9051 }
9052 }
9053 break;
9054
9055 //Update MCC TOO_CLOSE_MARGIN parameter
9056 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
9057 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
9058 {
9059 if((arg2 >= 1) && (arg2 <= 3))
9060 {
9061 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9062 }
9063 else
9064 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009065 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009066 return 0;
9067 }
9068 }
9069 break;
9070
9071 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009072 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009073 __FUNCTION__,arg1);
9074 break;
9075 }
9076 return 0;
9077}
9078
Jeff Johnson295189b2012-06-20 16:38:30 -07009079int hdd_set_wext(hdd_adapter_t *pAdapter)
9080{
9081 hdd_wext_state_t *pwextBuf;
9082 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009083 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009084
9085 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9086
9087 // Now configure the roaming profile links. To SSID and bssid.
9088 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
9089 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
9090
9091 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
9092 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
9093
9094 /*Set the numOfChannels to zero to scan all the channels*/
9095 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
9096 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
9097
9098 /* Default is no encryption */
9099 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
9100 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
9101
9102 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
9103 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
9104
9105 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
9106
9107 /* Default is no authentication */
9108 pwextBuf->roamProfile.AuthType.numEntries = 1;
9109 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
9110
9111 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
9112 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
9113
9114 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009115 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009116
9117 hdd_clearRoamProfileIe(pAdapter);
9118
9119 return VOS_STATUS_SUCCESS;
9120
9121 }
9122
9123int hdd_register_wext(struct net_device *dev)
9124 {
9125 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9126 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9127 VOS_STATUS status;
9128
9129 ENTER();
9130
9131 // Zero the memory. This zeros the profile structure.
9132 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
9133
9134 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
9135
9136
9137 status = hdd_set_wext(pAdapter);
9138
9139 if(!VOS_IS_STATUS_SUCCESS(status)) {
9140
Arif Hussain6d2a3322013-11-17 19:50:10 -08009141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 return eHAL_STATUS_FAILURE;
9143 }
9144
9145 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
9146 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 return eHAL_STATUS_FAILURE;
9149 }
9150
9151 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
9152 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009154 return eHAL_STATUS_FAILURE;
9155 }
9156
9157 // Register as a wireless device
9158 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
9159
9160 EXIT();
9161 return 0;
9162}
9163
9164int hdd_UnregisterWext(struct net_device *dev)
9165{
9166#if 0
9167 hdd_wext_state_t *wextBuf;
9168 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9169
9170 ENTER();
9171 // Set up the pointer to the Wireless Extensions state structure
9172 wextBuf = pAdapter->pWextState;
9173
9174 // De-allocate the Wireless Extensions state structure
9175 kfree(wextBuf);
9176
9177 // Clear out the pointer to the Wireless Extensions state structure
9178 pAdapter->pWextState = NULL;
9179
9180 EXIT();
9181#endif
c_hpothu5f0b6eb2014-09-15 13:36:50 +05309182
9183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s", __func__);
9184 rtnl_lock();
Jeff Johnson295189b2012-06-20 16:38:30 -07009185 dev->wireless_handlers = NULL;
c_hpothu5f0b6eb2014-09-15 13:36:50 +05309186 rtnl_unlock();
9187
Jeff Johnson295189b2012-06-20 16:38:30 -07009188 return 0;
9189}
9190
9191