blob: f330860123503bbf93dd0181bc5978a94c50f52e [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
Jeff Johnson295189b2012-06-20 16:38:30 -0700218
219/* Private ioctls and their sub-ioctls */
220#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
221#define WE_CLEAR_STATS 1
222#define WE_INIT_AP 2
223#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530224#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700225#define WE_ENABLE_AMP 4
226#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530227#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700228#define WE_ENABLE_DXE_STALL_DETECT 6
229#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700230#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530231#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530232#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
Mukul Sharma84f27252014-07-14 18:11:42 +0530234#ifdef DEBUG_ROAM_DELAY
235#define WE_DUMP_ROAM_TIMER_LOG 12
236#define WE_RESET_ROAM_TIMER_LOG 13
237#endif
238
Jeff Johnson295189b2012-06-20 16:38:30 -0700239/* Private ioctls and their sub-ioctls */
240#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
241#define WE_LOG_DUMP_CMD 1
242
Jeff Johnson295189b2012-06-20 16:38:30 -0700243#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800244//IOCTL to configure MCC params
245#define WE_MCC_CONFIG_CREDENTIAL 3
246#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700247
Chilam NG571c65a2013-01-19 12:27:36 +0530248#ifdef FEATURE_WLAN_TDLS
249#define WE_TDLS_CONFIG_PARAMS 5
250#endif
251
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700252#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530253#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700254
Chilam Ng01120412013-02-19 18:32:21 -0800255#ifdef FEATURE_WLAN_TDLS
256#undef MAX_VAR_ARGS
257#define MAX_VAR_ARGS 10
258#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700259#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800260#endif
261
Jeff Johnson295189b2012-06-20 16:38:30 -0700262/* Private ioctls (with no sub-ioctls) */
263/* note that they must be odd so that they have "get" semantics */
264#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
265#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
266#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
267
Girish Gowli464c9c82014-06-09 19:47:53 +0530268/* (SIOCIWFIRSTPRIV + 8) is currently unused */
269/* (SIOCIWFIRSTPRIV + 16) is currently unused */
270/* (SIOCIWFIRSTPRIV + 10) is currently unused */
271/* (SIOCIWFIRSTPRIV + 12) is currently unused */
272/* (SIOCIWFIRSTPRIV + 14) is currently unused */
273/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700274
Jeff Johnsone7245742012-09-05 17:12:55 -0700275#ifdef FEATURE_OEM_DATA_SUPPORT
276/* Private ioctls for setting the measurement configuration */
277#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
278#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
279#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700280
281#ifdef WLAN_FEATURE_VOWIFI_11R
282#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
283#endif
284
285/* Private ioctl for setting the host offload feature */
286#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
287
288/* Private ioctl to get the statistics */
289#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
290
291/* Private ioctl to set the Keep Alive Params */
292#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
293#ifdef WLAN_FEATURE_PACKET_FILTERING
294/* Private ioctl to set the Packet Filtering Params */
295#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
296#endif
297
298#ifdef FEATURE_WLAN_SCAN_PNO
299/* Private ioctl to get the statistics */
300#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
301#endif
302
303#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
304
305#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
306#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700307/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
310#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
311
312#define WLAN_STATS_INVALID 0
313#define WLAN_STATS_RETRY_CNT 1
314#define WLAN_STATS_MUL_RETRY_CNT 2
315#define WLAN_STATS_TX_FRM_CNT 3
316#define WLAN_STATS_RX_FRM_CNT 4
317#define WLAN_STATS_FRM_DUP_CNT 5
318#define WLAN_STATS_FAIL_CNT 6
319#define WLAN_STATS_RTS_FAIL_CNT 7
320#define WLAN_STATS_ACK_FAIL_CNT 8
321#define WLAN_STATS_RTS_SUC_CNT 9
322#define WLAN_STATS_RX_DISCARD_CNT 10
323#define WLAN_STATS_RX_ERROR_CNT 11
324#define WLAN_STATS_TX_BYTE_CNT 12
325
326#define WLAN_STATS_RX_BYTE_CNT 13
327#define WLAN_STATS_RX_RATE 14
328#define WLAN_STATS_TX_RATE 15
329
Jeff Johnsone7245742012-09-05 17:12:55 -0700330#define WLAN_STATS_RX_UC_BYTE_CNT 16
331#define WLAN_STATS_RX_MC_BYTE_CNT 17
332#define WLAN_STATS_RX_BC_BYTE_CNT 18
333#define WLAN_STATS_TX_UC_BYTE_CNT 19
334#define WLAN_STATS_TX_MC_BYTE_CNT 20
335#define WLAN_STATS_TX_BC_BYTE_CNT 21
336
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800337#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
338 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
339 { \
340 *__p++ = __type; \
341 *__p++ = __size; \
342 memcpy(__p, __val, __size); \
343 __p += __size; \
344 __tlen += __size + 2; \
345 } \
346 else \
347 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800348 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800349 } \
350 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700351
352#define VERSION_VALUE_MAX_LEN 32
353
354#define TX_PER_TRACKING_DEFAULT_RATIO 5
355#define TX_PER_TRACKING_MAX_RATIO 10
356#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
357
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530358#define WLAN_ADAPTER 0
359#define P2P_ADAPTER 1
360
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530361/*
362 * When supplicant sends SETBAND ioctl it queries for channels from
363 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
364 * This is not required if the return type from ioctl is
365 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
366 * event as part of regulatory_hint.
367 */
368enum {
369 SEND_CHANNEL_CHANGE_EVENT = 0,
370 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
371};
372
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800373/*MCC Configuration parameters */
374enum {
375 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
376 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
377 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
378 MCC_RX_DRAIN_TIME_CFG_PARAM,
379 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
380 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
381 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
382 MCC_MIN_AFTER_DTIM_CFG_PARAM,
383 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
384};
385
386int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
387 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
388
Jeff Johnson295189b2012-06-20 16:38:30 -0700389#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800390int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700391 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700392#endif
393
Jeff Johnson295189b2012-06-20 16:38:30 -0700394/**---------------------------------------------------------------------------
395
Arif Hussain0273cba2014-01-07 20:58:29 -0800396 \brief mem_alloc_copy_from_user_helper -
397
398 Helper function to allocate buffer and copy user data.
399
400 \param - wrqu - Pointer to IOCTL Data.
401 len - size
402
403 \return - On Success pointer to buffer, On failure NULL
404
405 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530406void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800407{
408 u8 *ptr = NULL;
409
410 /* in order to protect the code, an extra byte is post appended to the buffer
411 * and the null termination is added. However, when allocating (len+1) byte
412 * of memory, we need to make sure that there is no uint overflow when doing
413 * addition. In theory check len < UINT_MAX protects the uint overflow. For
414 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
415 * guess, now, it is assumed that the private command buffer size is no
416 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
417 */
418 if (len > MAX_USER_COMMAND_SIZE)
419 {
420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
421 "Invalid length");
422 return NULL;
423 }
424
425 ptr = kmalloc(len + 1, GFP_KERNEL);
426 if (NULL == ptr)
427 {
428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
429 "unable to allocate memory");
430 return NULL;
431 }
432
433 if (copy_from_user(ptr, wrqu_data, len))
434 {
435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
436 "%s: failed to copy data to user buffer", __func__);
437 kfree(ptr);
438 return NULL;
439 }
440 ptr[len] = '\0';
441 return ptr;
442}
443
Girish Gowli488ef492014-06-12 18:44:33 +0530444// Function to handle and get compatible struct iw_point passed to ioctl.
445int hdd_priv_get_data(struct iw_point *p_priv_data,
446 union iwreq_data *wrqu)
447{
448 if ((NULL == p_priv_data) || (NULL == wrqu))
449 {
450 return -EINVAL;
451 }
452
453#ifdef CONFIG_COMPAT
454 if (is_compat_task())
455 {
456 struct compat_iw_point *p_compat_priv_data;
457
458 // Compat task: typecast to campat structure and copy the members.
459 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
460
461 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
462 p_priv_data->length = p_compat_priv_data->length;
463 p_priv_data->flags = p_compat_priv_data->flags;
464 }//if(is_compat_task())
465 else
466 {
467#endif //#ifdef CONFIG_COMPAT
468
469 // Non compat task: directly copy the structure.
470 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
471
472#ifdef CONFIG_COMPAT
473 }//else of - if(is_compat_task())
474#endif //#ifdef CONFIG_COMPAT
475
476 return 0;
477}
478
Arif Hussain0273cba2014-01-07 20:58:29 -0800479/**---------------------------------------------------------------------------
480
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 \brief hdd_wlan_get_version() -
482
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800483 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700484
485 \param - pAdapter Pointer to the adapter.
486 wrqu - Pointer to IOCTL REQUEST Data.
487 extra - Pointer to char
488
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800489 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700490
491 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800492void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
493 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700494{
495 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800496 tSirVersionString wcnss_SW_version;
497 tSirVersionString wcnss_HW_version;
498 char *pSWversion;
499 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700501
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800502 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
503 sizeof(wcnss_SW_version));
504 if (VOS_IS_STATUS_SUCCESS(status))
505 {
506 pSWversion = wcnss_SW_version;
507 }
508 else
509 {
510 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 }
512
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800513 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
514 sizeof(wcnss_HW_version));
515 if (VOS_IS_STATUS_SUCCESS(status))
516 {
517 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800519 else
520 {
521 pHWversion = "Unknown";
522 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700523
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700524 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800525 "Host SW:%s, FW:%s, HW:%s",
526 QWLAN_VERSIONSTR,
527 pSWversion,
528 pHWversion);
529
530 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531}
532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
534{
535 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
536 v_U32_t threshold = 0,status = 0;
537
538 ENTER();
539
Agarwal Ashish971c2882013-10-30 20:11:12 +0530540 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
541 {
542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 "%s:LOGP in Progress. Ignore!!!",__func__);
544 return status;
545 }
546
547 if ( eHAL_STATUS_SUCCESS !=
548 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
549 {
c_hpothub8245442013-11-20 23:41:09 +0530550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
551 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 return -EIO;
553 }
554 wrqu->rts.value = threshold;
555
556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800557 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700558
559 EXIT();
560
561 return 0;
562}
563
564int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
565{
566 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
567 v_U32_t threshold = 0,status = 0;
568
569 ENTER();
570
Agarwal Ashish971c2882013-10-30 20:11:12 +0530571 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
572 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
574 "%s:LOGP in Progress. Ignore!!!",__func__);
575 return status;
576 }
577
578 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
579 != eHAL_STATUS_SUCCESS )
580 {
c_hpothub8245442013-11-20 23:41:09 +0530581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
582 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 return -EIO;
584 }
585 wrqu->frag.value = threshold;
586
587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800588 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700589
590 EXIT();
591
592 return 0;
593}
594
595int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
596{
Jeff Johnsone7245742012-09-05 17:12:55 -0700597 int i;
598 if (channel > 0)
599 {
600 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
601 {
602 if (channel == freq_chan_map[i].chan)
603 {
604 *pfreq = freq_chan_map[i].freq;
605 return 1;
606 }
607 }
608 }
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800610 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700611 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700612}
613
614static v_BOOL_t
615hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
616{
617 v_BOOL_t rsnType = VOS_FALSE;
618 // is the authType supported?
619 switch (authType)
620 {
621 case eCSR_AUTH_TYPE_NONE: //never used
622 rsnType = eANI_BOOLEAN_FALSE;
623 break;
624 // MAC layer authentication types
625 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
626 rsnType = eANI_BOOLEAN_FALSE;
627 break;
628 case eCSR_AUTH_TYPE_SHARED_KEY:
629 rsnType = eANI_BOOLEAN_FALSE;
630 break;
631 case eCSR_AUTH_TYPE_AUTOSWITCH:
632 rsnType = eANI_BOOLEAN_FALSE;
633 break;
634
635 // Upper layer authentication types
636 case eCSR_AUTH_TYPE_WPA:
637 rsnType = eANI_BOOLEAN_TRUE;
638 break;
639 case eCSR_AUTH_TYPE_WPA_PSK:
640 rsnType = eANI_BOOLEAN_TRUE;
641 break;
642 case eCSR_AUTH_TYPE_WPA_NONE:
643 rsnType = eANI_BOOLEAN_TRUE;
644 break;
645#ifdef WLAN_FEATURE_VOWIFI_11R
646 case eCSR_AUTH_TYPE_FT_RSN:
647#endif
648 case eCSR_AUTH_TYPE_RSN:
649 rsnType = eANI_BOOLEAN_TRUE;
650 break;
651#ifdef WLAN_FEATURE_VOWIFI_11R
652 case eCSR_AUTH_TYPE_FT_RSN_PSK:
653#endif
654 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700655#ifdef WLAN_FEATURE_11W
656 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
657#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 rsnType = eANI_BOOLEAN_TRUE;
659 break;
660 //case eCSR_AUTH_TYPE_FAILED:
661 case eCSR_AUTH_TYPE_UNKNOWN:
662 rsnType = eANI_BOOLEAN_FALSE;
663 break;
664 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800665 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
666 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 rsnType = eANI_BOOLEAN_FALSE;
668 break;
669 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800670 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700671 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 return rsnType;
673}
674
675static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
676{
677 struct statsContext *pStatsContext;
678 hdd_adapter_t *pAdapter;
679
680 if (ioctl_debug)
681 {
682 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700683 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 }
685
686 if (NULL == pContext)
687 {
688 hddLog(VOS_TRACE_LEVEL_ERROR,
689 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700690 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 return;
692 }
693
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 pStatsContext = pContext;
695 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800696
697 /* there is a race condition that exists between this callback
698 function and the caller since the caller could time out either
699 before or while this code is executing. we use a spinlock to
700 serialize these actions */
701 spin_lock(&hdd_context_lock);
702
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
704 {
705 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800706 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 hddLog(VOS_TRACE_LEVEL_WARN,
708 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700709 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 if (ioctl_debug)
711 {
712 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700713 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 }
715 return;
716 }
717
Jeff Johnson72a40512013-12-19 10:14:15 -0800718 /* context is valid so caller is still waiting */
719
720 /* paranoia: invalidate the magic */
721 pStatsContext->magic = 0;
722
723 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 pAdapter->rssi = rssi;
725
Jeff Johnson72a40512013-12-19 10:14:15 -0800726 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800728
729 /* serialization is complete */
730 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731}
732
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530733static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
734{
735 struct statsContext *pStatsContext;
736 hdd_adapter_t *pAdapter;
737
738 if (ioctl_debug)
739 {
740 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
741 __func__, (int)snr, (int)staId, pContext);
742 }
743
744 if (NULL == pContext)
745 {
746 hddLog(VOS_TRACE_LEVEL_ERROR,
747 "%s: Bad param, pContext [%p]",
748 __func__, pContext);
749 return;
750 }
751
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530752 pStatsContext = pContext;
753 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800754
755 /* there is a race condition that exists between this callback
756 function and the caller since the caller could time out either
757 before or while this code is executing. we use a spinlock to
758 serialize these actions */
759 spin_lock(&hdd_context_lock);
760
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530761 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
762 {
763 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800764 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530765 hddLog(VOS_TRACE_LEVEL_WARN,
766 "%s: Invalid context, pAdapter [%p] magic [%08x]",
767 __func__, pAdapter, pStatsContext->magic);
768 if (ioctl_debug)
769 {
770 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
771 __func__, pAdapter, pStatsContext->magic);
772 }
773 return;
774 }
775
Jeff Johnson72a40512013-12-19 10:14:15 -0800776 /* context is valid so caller is still waiting */
777
778 /* paranoia: invalidate the magic */
779 pStatsContext->magic = 0;
780
781 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530782 pAdapter->snr = snr;
783
Jeff Johnson72a40512013-12-19 10:14:15 -0800784 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530785 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800786
787 /* serialization is complete */
788 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530789}
790
Jeff Johnson295189b2012-06-20 16:38:30 -0700791VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
792{
793 struct statsContext context;
794 hdd_context_t *pHddCtx;
795 hdd_station_ctx_t *pHddStaCtx;
796 eHalStatus hstatus;
797 long lrc;
798
799 if (NULL == pAdapter)
800 {
801 hddLog(VOS_TRACE_LEVEL_WARN,
802 "%s: Invalid context, pAdapter", __func__);
803 return VOS_STATUS_E_FAULT;
804 }
805 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
806 {
807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
808 /* return a cached value */
809 *rssi_value = pAdapter->rssi;
810 return VOS_STATUS_SUCCESS;
811 }
812
813 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
814 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
815
816 init_completion(&context.completion);
817 context.pAdapter = pAdapter;
818 context.magic = RSSI_CONTEXT_MAGIC;
819
820 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
821 pHddStaCtx->conn_info.staId[ 0 ],
822 pHddStaCtx->conn_info.bssId,
823 &context, pHddCtx->pvosContext);
824 if (eHAL_STATUS_SUCCESS != hstatus)
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700827 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 /* we'll returned a cached value below */
829 }
830 else
831 {
832 /* request was sent -- wait for the response */
833 lrc = wait_for_completion_interruptible_timeout(&context.completion,
834 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 if (lrc <= 0)
836 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800837 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700838 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 /* we'll now returned a cached value below */
840 }
841 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800842
843 /* either we never sent a request, we sent a request and received a
844 response or we sent a request and timed out. if we never sent a
845 request or if we sent a request and got a response, we want to
846 clear the magic out of paranoia. if we timed out there is a
847 race condition such that the callback function could be
848 executing at the same time we are. of primary concern is if the
849 callback function had already verified the "magic" but had not
850 yet set the completion variable when a timeout occurred. we
851 serialize these activities by invalidating the magic while
852 holding a shared spinlock which will cause us to block if the
853 callback is currently executing */
854 spin_lock(&hdd_context_lock);
855 context.magic = 0;
856 spin_unlock(&hdd_context_lock);
857
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 *rssi_value = pAdapter->rssi;
859
860 return VOS_STATUS_SUCCESS;
861}
862
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530863VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
864{
865 struct statsContext context;
866 hdd_context_t *pHddCtx;
867 hdd_station_ctx_t *pHddStaCtx;
868 eHalStatus hstatus;
869 long lrc;
870 int valid;
871
872 if (NULL == pAdapter)
873 {
874 hddLog(VOS_TRACE_LEVEL_ERROR,
875 "%s: Invalid context, pAdapter", __func__);
876 return VOS_STATUS_E_FAULT;
877 }
878
879 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
880
881 valid = wlan_hdd_validate_context(pHddCtx);
882 if (0 != valid)
883 {
884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
885 return VOS_STATUS_E_FAULT;
886 }
887
888 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
889 if (NULL == pHddStaCtx)
890 {
891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
892 return VOS_STATUS_E_FAULT;
893 }
894
895 init_completion(&context.completion);
896 context.pAdapter = pAdapter;
897 context.magic = SNR_CONTEXT_MAGIC;
898
899 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
900 pHddStaCtx->conn_info.staId[ 0 ],
901 pHddStaCtx->conn_info.bssId,
902 &context);
903 if (eHAL_STATUS_SUCCESS != hstatus)
904 {
905 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
906 __func__);
907 /* we'll returned a cached value below */
908 }
909 else
910 {
911 /* request was sent -- wait for the response */
912 lrc = wait_for_completion_interruptible_timeout(&context.completion,
913 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530914 if (lrc <= 0)
915 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530917 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530918 /* we'll now returned a cached value below */
919 }
920 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800921
922 /* either we never sent a request, we sent a request and received a
923 response or we sent a request and timed out. if we never sent a
924 request or if we sent a request and got a response, we want to
925 clear the magic out of paranoia. if we timed out there is a
926 race condition such that the callback function could be
927 executing at the same time we are. of primary concern is if the
928 callback function had already verified the "magic" but had not
929 yet set the completion variable when a timeout occurred. we
930 serialize these activities by invalidating the magic while
931 holding a shared spinlock which will cause us to block if the
932 callback is currently executing */
933 spin_lock(&hdd_context_lock);
934 context.magic = 0;
935 spin_unlock(&hdd_context_lock);
936
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530937 *snr = pAdapter->snr;
938
939 return VOS_STATUS_SUCCESS;
940}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800941#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800942
943static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
944{
945 struct statsContext *pStatsContext;
946 hdd_adapter_t *pAdapter;
947 if (ioctl_debug)
948 {
949 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
950 __func__, (int)rssi, (int)staId, pContext);
951 }
952
953 if (NULL == pContext)
954 {
955 hddLog(VOS_TRACE_LEVEL_ERROR,
956 "%s: Bad param, pContext [%p]",
957 __func__, pContext);
958 return;
959 }
960
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800961 pStatsContext = pContext;
962 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800963
964 /* there is a race condition that exists between this callback
965 function and the caller since the caller could time out either
966 before or while this code is executing. we use a spinlock to
967 serialize these actions */
968 spin_lock(&hdd_context_lock);
969
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800970 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
971 {
972 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800973 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800974 hddLog(VOS_TRACE_LEVEL_WARN,
975 "%s: Invalid context, pAdapter [%p] magic [%08x]",
976 __func__, pAdapter, pStatsContext->magic);
977 if (ioctl_debug)
978 {
979 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
980 __func__, pAdapter, pStatsContext->magic);
981 }
982 return;
983 }
984
Jeff Johnson72a40512013-12-19 10:14:15 -0800985 /* context is valid so caller is still waiting */
986
987 /* paranoia: invalidate the magic */
988 pStatsContext->magic = 0;
989
990 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800991 pAdapter->rssi = rssi;
992
Jeff Johnson72a40512013-12-19 10:14:15 -0800993 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800994 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800995
996 /* serialization is complete */
997 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800998}
999
1000
1001
1002VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1003{
1004 struct statsContext context;
1005 hdd_context_t *pHddCtx = NULL;
1006 hdd_station_ctx_t *pHddStaCtx = NULL;
1007 eHalStatus hstatus;
1008 long lrc;
1009
1010 if (NULL == pAdapter)
1011 {
1012 hddLog(VOS_TRACE_LEVEL_WARN,
1013 "%s: Invalid context, pAdapter", __func__);
1014 return VOS_STATUS_E_FAULT;
1015 }
1016 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1017 {
1018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1019 /* return a cached value */
1020 *rssi_value = pAdapter->rssi;
1021 return VOS_STATUS_SUCCESS;
1022 }
1023
1024 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1025 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1026
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301027 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001028 {
1029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1030 /* return a cached value */
1031 *rssi_value = 0;
1032 return VOS_STATUS_SUCCESS;
1033 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301034
1035 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1036 {
1037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1038 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1039 *rssi_value = pAdapter->rssi;
1040 return VOS_STATUS_SUCCESS;
1041 }
1042
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001043 init_completion(&context.completion);
1044 context.pAdapter = pAdapter;
1045 context.magic = RSSI_CONTEXT_MAGIC;
1046
1047 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1048 pHddStaCtx->conn_info.staId[ 0 ],
1049 pHddStaCtx->conn_info.bssId,
1050 &context, pHddCtx->pvosContext);
1051 if (eHAL_STATUS_SUCCESS != hstatus)
1052 {
1053 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1054 __func__);
1055 /* we'll returned a cached value below */
1056 }
1057 else
1058 {
1059 /* request was sent -- wait for the response */
1060 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1061 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001062 if (lrc <= 0)
1063 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001064 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001065 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001066 /* we'll now returned a cached value below */
1067 }
1068 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001069
1070 /* either we never sent a request, we sent a request and received a
1071 response or we sent a request and timed out. if we never sent a
1072 request or if we sent a request and got a response, we want to
1073 clear the magic out of paranoia. if we timed out there is a
1074 race condition such that the callback function could be
1075 executing at the same time we are. of primary concern is if the
1076 callback function had already verified the "magic" but had not
1077 yet set the completion variable when a timeout occurred. we
1078 serialize these activities by invalidating the magic while
1079 holding a shared spinlock which will cause us to block if the
1080 callback is currently executing */
1081 spin_lock(&hdd_context_lock);
1082 context.magic = 0;
1083 spin_unlock(&hdd_context_lock);
1084
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001085 *rssi_value = pAdapter->rssi;
1086
1087 return VOS_STATUS_SUCCESS;
1088}
1089#endif
1090
1091
Jeff Johnson295189b2012-06-20 16:38:30 -07001092void hdd_StatisticsCB( void *pStats, void *pContext )
1093{
1094 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1095 hdd_stats_t *pStatsCache = NULL;
1096 hdd_wext_state_t *pWextState;
1097 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1098
1099 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1100 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1101 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1102 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1103 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1104 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1105
1106 if (pAdapter!= NULL)
1107 pStatsCache = &pAdapter->hdd_stats;
1108
1109
1110 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1111 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1112 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1113 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1114 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1115 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1116
1117 if (pStatsCache!=NULL)
1118 {
1119 // and copy the stats into the cache we keep in the adapter instance structure
1120 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1121 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1122 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1123 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1124 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1125 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1126 }
1127
1128 if(pAdapter)
1129 {
1130 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1131 if(pWextState)
1132 {
1133 vos_status = vos_event_set(&pWextState->vosevent);
1134 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1135 {
1136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001137 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 return;
1139 }
1140 }
1141 }
1142}
1143
1144void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1145{
1146 v_CONTEXT_t pVosContext;
1147 hdd_context_t *pHddCtx;
1148 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1149#if 0
1150 hdd_wext_state_t *pWextState;
1151 v_U32_t roamId;
1152#endif
1153
1154 ENTER();
1155
1156 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1157
1158 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1159 if (NULL == pHddCtx)
1160 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001161 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 return;
1163 }
1164#if 0
1165 pWextState = pAdapter->pWextState;
1166#endif
1167
1168 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1169 {
1170 //TODO Verify is this is really used. If yes need to fix it.
1171 hdd_reconnect_all_adapters( pHddCtx );
1172#if 0
1173 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1174 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1175 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1176
1177 if(VOS_STATUS_SUCCESS == vosStatus)
1178 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1179 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1180
1181 sme_RoamConnect(halHandle,
1182 pAdapter->sessionId, &(pWextState->roamProfile),
1183 &roamId);
1184#endif
1185 }
1186
1187 EXIT();
1188
1189}
1190
1191void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1192{
1193 int i = 0;
1194 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1195
1196 /* clear WPA/RSN/WSC IE information in the profile */
1197 pWextState->roamProfile.nWPAReqIELength = 0;
1198 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1199 pWextState->roamProfile.nRSNReqIELength = 0;
1200 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1201
Chet Lanctot186b5732013-03-18 10:26:30 -07001202#ifdef FEATURE_WLAN_WAPI
1203 pWextState->roamProfile.nWAPIReqIELength = 0;
1204 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1205#endif
1206
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001208 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001209 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301210 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1212 pWextState->roamProfile.nAddIEAssocLength = 0;
1213
1214 pWextState->roamProfile.EncryptionType.numEntries = 1;
1215 pWextState->roamProfile.EncryptionType.encryptionType[0]
1216 = eCSR_ENCRYPT_TYPE_NONE;
1217
1218 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1219 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1220 = eCSR_ENCRYPT_TYPE_NONE;
1221
1222 pWextState->roamProfile.AuthType.numEntries = 1;
1223 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1224
Chet Lanctot186b5732013-03-18 10:26:30 -07001225#ifdef WLAN_FEATURE_11W
1226 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1227 pWextState->roamProfile.MFPRequired = 0;
1228 pWextState->roamProfile.MFPCapable = 0;
1229#endif
1230
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 pWextState->authKeyMgmt = 0;
1232
1233 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1234 {
1235 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1236 {
1237 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1238 }
1239 }
1240#ifdef FEATURE_WLAN_WAPI
1241 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1242 pAdapter->wapi_info.nWapiMode = 0;
1243#endif
1244
1245 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1246
1247}
1248
1249void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1250{
1251 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001252
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001253 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1254 {
1255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1256 "%s: Invalid pAdapter magic", __func__);
1257 }
1258 else
1259 {
1260 complete(&pAdapter->ula_complete);
1261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001262}
1263
1264VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1265{
1266 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001268 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001269
1270 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1271 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001272 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001273
1274 /*To avoid race condition between the set key and the last EAPOL
1275 packet, notify TL to finish upper layer authentication incase if the
1276 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001277 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001278
1279 if ( vos_status != VOS_STATUS_SUCCESS )
1280 {
1281 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1282 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1283 __LINE__, vos_status );
1284 return vos_status;
1285
1286 }
1287
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001288 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301290 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001291 {
1292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301293 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001294 /* we'll still fall through and return success since the
1295 * connection may still get established but is just taking
1296 * too long for us to wait */
1297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 }
1299 return VOS_STATUS_SUCCESS;
1300}
1301
1302v_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)
1303{
1304
1305 int left = ie_len;
1306 v_U8_t *ptr = ie;
1307 v_U8_t elem_id,elem_len;
1308 v_U8_t eid = 0xDD;
1309
1310 if ( NULL == ie || 0 == ie_len )
1311 return NULL;
1312
1313 while(left >= 2)
1314 {
1315 elem_id = ptr[0];
1316 elem_len = ptr[1];
1317 left -= 2;
1318 if(elem_len > left)
1319 {
1320 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001321 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 eid,elem_len,left);
1323 return NULL;
1324 }
1325 if (elem_id == eid)
1326 {
1327 if(memcmp( &ptr[2], oui, oui_size)==0)
1328 return ptr;
1329 }
1330
1331 left -= elem_len;
1332 ptr += (elem_len + 2);
1333 }
1334 return NULL;
1335}
1336
1337static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1338 union iwreq_data *wrqu, char *extra)
1339{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001340 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 /* Do nothing for now */
1342 return 0;
1343}
1344
1345static int iw_get_name(struct net_device *dev,
1346 struct iw_request_info *info,
1347 char *wrqu, char *extra)
1348{
1349
1350 ENTER();
1351 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1352 EXIT();
1353 return 0;
1354}
1355
1356static int iw_set_mode(struct net_device *dev,
1357 struct iw_request_info *info,
1358 union iwreq_data *wrqu, char *extra)
1359{
1360 hdd_wext_state_t *pWextState;
1361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1362 tCsrRoamProfile *pRoamProfile;
1363 eCsrRoamBssType LastBSSType;
1364 eMib_dot11DesiredBssType connectedBssType;
1365 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001367
1368 ENTER();
1369
1370 if (NULL == pAdapter)
1371 {
1372 hddLog(VOS_TRACE_LEVEL_WARN,
1373 "%s: Invalid context, pAdapter", __func__);
1374 return 0;
1375 }
1376
1377 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1379 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 return 0;
1381 }
1382
1383 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1384 if (pWextState == NULL)
1385 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301386 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 return -EINVAL;
1388 }
1389
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 pRoamProfile = &pWextState->roamProfile;
1392 LastBSSType = pRoamProfile->BSSType;
1393
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301394 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395
1396 switch (wrqu->mode)
1397 {
1398 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301399 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1401 // Set the phymode correctly for IBSS.
1402 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1403 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001404 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 break;
1407 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301408 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 break;
1412 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301413 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1415 break;
1416 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301417 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 return -EOPNOTSUPP;
1419 }
1420
1421 if ( LastBSSType != pRoamProfile->BSSType )
1422 {
1423 //the BSS mode changed
1424 // We need to issue disconnect if connected or in IBSS disconnect state
1425 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1426 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1427 {
1428 VOS_STATUS vosStatus;
1429 // need to issue a disconnect to CSR.
1430 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1431 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1432 pAdapter->sessionId,
1433 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1434 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301435 {
1436 long ret;
1437 ret = wait_for_completion_interruptible_timeout(
1438 &pAdapter->disconnect_comp_var,
1439 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1440 if (ret <= 0)
1441 hddLog(VOS_TRACE_LEVEL_ERROR,
1442 FL("failed wait on disconnect_comp_var %ld"), ret);
1443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 }
1445 }
1446
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 EXIT();
1448 return 0;
1449}
1450
1451
1452static int iw_get_mode(struct net_device *dev,
1453 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301454 union iwreq_data *wrqu,
1455 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001456{
1457
1458 hdd_wext_state_t *pWextState;
1459 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1460
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301461 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001462
1463 if (NULL == pAdapter)
1464 {
1465 hddLog(VOS_TRACE_LEVEL_WARN,
1466 "%s: Invalid context, pAdapter", __func__);
1467 return 0;
1468 }
1469
1470 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1472 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 return 0;
1474 }
1475
1476 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1477 if (pWextState == NULL)
1478 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301479 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 return -EINVAL;
1481 }
1482
1483 switch (pWextState->roamProfile.BSSType)
1484 {
1485 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001486 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301487 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 break;
1489 case eCSR_BSS_TYPE_IBSS:
1490 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001491 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301492 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 break;
1494 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001495 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301496 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 break;
1498 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001499 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 break;
1501 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301502
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 return 0;
1504}
1505
1506static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1507 union iwreq_data *wrqu, char *extra)
1508{
1509 v_U32_t numChans = 0;
1510 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1511 v_U32_t indx = 0;
1512 v_U32_t status = 0;
1513
1514 hdd_wext_state_t *pWextState;
1515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1516 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1517 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1518 tCsrRoamProfile * pRoamProfile;
1519 ENTER();
1520
1521 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1523 return status;
1524 }
1525
1526 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1527
1528 pRoamProfile = &pWextState->roamProfile;
1529
Arif Hussain6d2a3322013-11-17 19:50:10 -08001530 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001531
1532 /* Link is up then return cant set channel*/
1533 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1534 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1535 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001536 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 return -EOPNOTSUPP;
1538 }
1539
1540 /* Settings by Frequency as input */
1541 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1542 (wrqu->freq.m <= (tANI_U32)5.825e8))
1543 {
1544 tANI_U32 freq = wrqu->freq.m / 100000;
1545
1546 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1547 indx++;
1548 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1549 {
1550 return -EINVAL;
1551 }
1552 wrqu->freq.e = 0;
1553 wrqu->freq.m = freq_chan_map[indx].chan;
1554
1555 }
1556
1557 if (wrqu->freq.e == 0)
1558 {
1559 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1560 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1561 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001562 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001563 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1565 return -EINVAL;
1566 }
1567
1568 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1569
1570 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1571 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1573 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 return -EIO;
1575 }
1576
1577 for (indx = 0; indx < numChans; indx++) {
1578 if (wrqu->freq.m == validChan[indx]){
1579 break;
1580 }
1581 }
1582 }
1583 else{
1584
1585 return -EINVAL;
1586 }
1587
1588 if(indx >= numChans)
1589 {
1590 return -EINVAL;
1591 }
1592
1593 /* Set the Operational Channel */
1594 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1595 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1596 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1597
Arif Hussain6d2a3322013-11-17 19:50:10 -08001598 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001599
1600 EXIT();
1601
1602 return status;
1603}
1604
1605static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1606 struct iw_freq *fwrq, char *extra)
1607{
Jeff Johnsone7245742012-09-05 17:12:55 -07001608 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1610 tHalHandle hHal;
1611 hdd_wext_state_t *pWextState;
1612 tCsrRoamProfile * pRoamProfile;
1613 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1614
1615 ENTER();
1616
1617 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1619 return status;
1620 }
1621
1622 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1623 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1624
1625 pRoamProfile = &pWextState->roamProfile;
1626
1627 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1628 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001629 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 {
c_hpothub8245442013-11-20 23:41:09 +05301631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1632 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 return -EIO;
1634 }
1635 else
1636 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 status = hdd_wlan_get_freq(channel, &freq);
1638 if( TRUE == status )
1639 {
1640 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1641 * iwlist & iwconfig command shows frequency into proper
1642 * format (2.412 GHz instead of 246.2 MHz)*/
1643 fwrq->m = freq;
1644 fwrq->e = MHZ;
1645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 }
1647 }
1648 else
1649 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001650 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1651 * iwlist & iwconfig command shows frequency into proper
1652 * format (2.412 GHz instead of 246.2 MHz)*/
1653 fwrq->m = 0;
1654 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001656 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001657}
1658
1659static int iw_get_tx_power(struct net_device *dev,
1660 struct iw_request_info *info,
1661 union iwreq_data *wrqu, char *extra)
1662{
1663
1664 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1665 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1666 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1667
1668 if (pHddCtx->isLogpInProgress)
1669 {
1670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1671 "%s:LOGP in Progress. Ignore!!!",__func__);
1672 return -EBUSY;
1673 }
1674
1675 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1676 {
1677 wrqu->txpower.value = 0;
1678 return 0;
1679 }
1680 wlan_hdd_get_classAstats(pAdapter);
1681 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1682
1683 return 0;
1684}
1685
1686static int iw_set_tx_power(struct net_device *dev,
1687 struct iw_request_info *info,
1688 union iwreq_data *wrqu, char *extra)
1689{
1690 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1691 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1692
1693 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1694 {
1695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1696 return 0;
1697 }
1698
1699 ENTER();
1700
1701 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1702 {
c_hpothub8245442013-11-20 23:41:09 +05301703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1704 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 return -EIO;
1706 }
1707
1708 EXIT();
1709
1710 return 0;
1711}
1712
1713static int iw_get_bitrate(struct net_device *dev,
1714 struct iw_request_info *info,
1715 union iwreq_data *wrqu, char *extra)
1716{
1717 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1718 eHalStatus status = eHAL_STATUS_SUCCESS;
1719 hdd_wext_state_t *pWextState;
1720 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1721 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1722
1723 ENTER();
1724
1725 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1727 return status;
1728 }
1729
1730 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1731 wrqu->bitrate.value = 0;
1732 }
1733 else {
1734 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1735 SME_SUMMARY_STATS |
1736 SME_GLOBAL_CLASSA_STATS |
1737 SME_GLOBAL_CLASSB_STATS |
1738 SME_GLOBAL_CLASSC_STATS |
1739 SME_GLOBAL_CLASSD_STATS |
1740 SME_PER_STA_STATS,
1741 hdd_StatisticsCB, 0, FALSE,
1742 pHddStaCtx->conn_info.staId[0], pAdapter );
1743
1744 if(eHAL_STATUS_SUCCESS != status)
1745 {
1746 hddLog(VOS_TRACE_LEVEL_ERROR,
1747 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001748 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 return status;
1750 }
1751
1752 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1753
1754 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1755
1756 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1757 {
1758 hddLog(VOS_TRACE_LEVEL_ERROR,
1759 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001760 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 return VOS_STATUS_E_FAILURE;
1762 }
1763
1764 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1765 }
1766
1767 EXIT();
1768
1769 return vos_status;
1770}
1771/* ccm call back function */
1772
1773static int iw_set_bitrate(struct net_device *dev,
1774 struct iw_request_info *info,
1775 union iwreq_data *wrqu,
1776 char *extra)
1777{
1778 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1779 hdd_wext_state_t *pWextState;
1780 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1781 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1782 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1783 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1784 v_U32_t i, rate;
1785 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1786
1787 ENTER();
1788
1789 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1791 return 0;
1792 }
1793
1794 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1795
1796 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1797 {
1798 return -ENXIO ;
1799 }
1800
1801 rate = wrqu->bitrate.value;
1802
1803 if (rate == -1)
1804 {
1805 rate = WNI_CFG_FIXED_RATE_AUTO;
1806 valid_rate = TRUE;
1807 }
1808 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1809 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1810 {
1811 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1812 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1813 {
1814 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1815 WNI_CFG_SUPPORTED_RATES_11A,
1816 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1817 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1818 WNI_CFG_SUPPORTED_RATES_11B,
1819 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1820 {
1821 for (i = 0; i < (b_len + a_len); ++i)
1822 {
1823 /* supported rates returned is double the actual rate so we divide it by 2 */
1824 if ((supp_rates[i]&0x7F)/2 == rate)
1825 {
1826 valid_rate = TRUE;
1827 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1828 break;
1829 }
1830 }
1831 }
1832 }
1833 }
1834 if (valid_rate != TRUE)
1835 {
1836 return -EINVAL;
1837 }
1838 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1839 WNI_CFG_FIXED_RATE, rate,
1840 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1841 {
c_hpothub8245442013-11-20 23:41:09 +05301842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1843 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001844 return -EIO;
1845 }
1846 return 0;
1847}
1848
1849
1850static int iw_set_genie(struct net_device *dev,
1851 struct iw_request_info *info,
1852 union iwreq_data *wrqu,
1853 char *extra)
1854{
1855 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1856 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001857 u_int8_t *genie = NULL;
1858 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 v_U16_t remLen;
1860
1861 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001862
1863 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1865 "%s:LOGP in Progress. Ignore!!!", __func__);
1866 return 0;
1867 }
1868
1869 if (!wrqu->data.length) {
1870 hdd_clearRoamProfileIe(pAdapter);
1871 EXIT();
1872 return 0;
1873 }
1874
1875 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1876 wrqu->data.length);
1877 if (NULL == base_genie)
1878 {
1879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1880 "mem_alloc_copy_from_user_helper fail");
1881 return -ENOMEM;
1882 }
1883
1884 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001885
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 remLen = wrqu->data.length;
1887
Arif Hussain6d2a3322013-11-17 19:50:10 -08001888 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001889
1890 /* clear any previous genIE before this call */
1891 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1892
1893 while (remLen >= 2)
1894 {
1895 v_U16_t eLen = 0;
1896 v_U8_t elementId;
1897 elementId = *genie++;
1898 eLen = *genie++;
1899 remLen -= 2;
1900
Arif Hussain6d2a3322013-11-17 19:50:10 -08001901 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 __func__, elementId, eLen);
1903
1904 switch ( elementId )
1905 {
1906 case IE_EID_VENDOR:
1907 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001908 {
1909 kfree(base_genie);
1910 return -EINVAL;
1911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001912
1913 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1914 {
1915 v_U16_t curGenIELen = pWextState->genIE.length;
1916 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1917 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1918
1919 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1920 {
1921 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001922 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001924 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 return -ENOMEM;
1926 }
1927 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1928 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1929 pWextState->genIE.length += eLen + 2;
1930 }
1931 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1932 {
1933 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1934 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1935 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1936 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1937 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1938 }
1939 else /* any vendorId except WPA IE should be accumulated to genIE */
1940 {
1941 v_U16_t curGenIELen = pWextState->genIE.length;
1942 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1943 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1944
1945 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1946 {
1947 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001948 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001950 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 return -ENOMEM;
1952 }
1953 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1954 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1955 pWextState->genIE.length += eLen + 2;
1956 }
1957 break;
1958 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001959 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1961 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1962 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1963 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1964 break;
1965
1966 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001967 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001968 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 return 0;
1970 }
1971 genie += eLen;
1972 remLen -= eLen;
1973 }
1974 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001975 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 return 0;
1977}
1978
1979static int iw_get_genie(struct net_device *dev,
1980 struct iw_request_info *info,
1981 union iwreq_data *wrqu,
1982 char *extra)
1983{
1984 hdd_wext_state_t *pWextState;
1985 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1986 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1987 eHalStatus status;
1988 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1989 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1990
1991 ENTER();
1992
1993 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1995 return 0;
1996 }
1997
1998
Arif Hussain6d2a3322013-11-17 19:50:10 -08001999 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07002000
2001 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2002
2003 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2004 {
2005 return -ENXIO;
2006 }
2007
2008 // Return something ONLY if we are associated with an RSN or WPA network
2009 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2010 pWextState->roamProfile.negotiatedAuthType))
2011 {
2012 return -ENXIO;
2013 }
2014
2015 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2016 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2017 pAdapter->sessionId,
2018 &length,
2019 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002020 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2021 if (wrqu->data.length < length)
2022 {
2023 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2024 return -EFAULT;
2025 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002026 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002027 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002028
Arif Hussain6d2a3322013-11-17 19:50:10 -08002029 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002030
2031 EXIT();
2032
2033 return 0;
2034}
2035
2036static int iw_get_encode(struct net_device *dev,
2037 struct iw_request_info *info,
2038 struct iw_point *dwrq, char *extra)
2039{
2040 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2041 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2042 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2043 int keyId;
2044 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2045 int i;
2046
2047 ENTER();
2048
2049 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2051 return 0;
2052 }
2053
2054 keyId = pRoamProfile->Keys.defaultIndex;
2055
2056 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2057 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002058 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 return -EINVAL;
2060 }
2061
2062 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2063 {
2064 dwrq->flags |= IW_ENCODE_ENABLED;
2065 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2066 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2067
2068 dwrq->flags |= (keyId + 1);
2069
2070 }
2071 else
2072 {
2073 dwrq->flags |= IW_ENCODE_DISABLED;
2074 }
2075
2076 for(i=0; i < MAX_WEP_KEYS; i++)
2077 {
2078 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2079 {
2080 continue;
2081 }
2082 else
2083 {
2084 break;
2085 }
2086 }
2087
2088 if(MAX_WEP_KEYS == i)
2089 {
2090 dwrq->flags |= IW_ENCODE_NOKEY;
2091 }
2092
2093 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2094
2095 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2096 {
2097 dwrq->flags |= IW_ENCODE_OPEN;
2098 }
2099 else
2100 {
2101 dwrq->flags |= IW_ENCODE_RESTRICTED;
2102 }
2103 EXIT();
2104 return 0;
2105}
2106
2107#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2108#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2109
2110
2111/*
2112 * This function sends a single 'key' to LIM at all time.
2113 */
2114
2115static int iw_get_rts_threshold(struct net_device *dev,
2116 struct iw_request_info *info,
2117 union iwreq_data *wrqu, char *extra)
2118{
2119 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2120 v_U32_t status = 0;
2121
2122 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2123
2124 return status;
2125}
2126
2127static int iw_set_rts_threshold(struct net_device *dev,
2128 struct iw_request_info *info,
2129 union iwreq_data *wrqu, char *extra)
2130{
2131 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2132 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2133
2134 ENTER();
2135
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002136 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2137 {
2138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2139 "%s:LOGP in Progress. Ignore!!!", __func__);
2140 return -EAGAIN;
2141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2143 {
2144 return -EINVAL;
2145 }
2146
2147 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2148 {
c_hpothub8245442013-11-20 23:41:09 +05302149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2150 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 return -EIO;
2152 }
2153
2154 EXIT();
2155
2156 return 0;
2157}
2158
2159static int iw_get_frag_threshold(struct net_device *dev,
2160 struct iw_request_info *info,
2161 union iwreq_data *wrqu, char *extra)
2162{
2163 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2164 v_U32_t status = 0;
2165
2166 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2167
2168 return status;
2169}
2170
2171static int iw_set_frag_threshold(struct net_device *dev,
2172 struct iw_request_info *info,
2173 union iwreq_data *wrqu, char *extra)
2174{
2175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2176 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2177
2178 ENTER();
2179
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002180 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2181 {
2182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2183 "%s:LOGP in Progress. Ignore!!!", __func__);
2184 return -EBUSY;
2185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2187 {
2188 return -EINVAL;
2189 }
2190
2191 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2192 {
c_hpothub8245442013-11-20 23:41:09 +05302193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2194 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 return -EIO;
2196 }
2197
2198 EXIT();
2199
2200 return 0;
2201}
2202
2203static int iw_get_power_mode(struct net_device *dev,
2204 struct iw_request_info *info,
2205 union iwreq_data *wrqu, char *extra)
2206{
2207 ENTER();
2208 return -EOPNOTSUPP;
2209}
2210
2211static int iw_set_power_mode(struct net_device *dev,
2212 struct iw_request_info *info,
2213 union iwreq_data *wrqu, char *extra)
2214{
2215 ENTER();
2216 return -EOPNOTSUPP;
2217}
2218
2219static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2220 union iwreq_data *wrqu, char *extra)
2221{
2222 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2223 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2224 struct iw_range *range = (struct iw_range *) extra;
2225
2226 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2227
2228 v_U32_t num_channels = sizeof(channels);
2229 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2230 v_U32_t a_len;
2231 v_U32_t b_len;
2232 v_U32_t active_phy_mode = 0;
2233 v_U8_t index = 0, i;
2234
2235 ENTER();
2236
2237 wrqu->data.length = sizeof(struct iw_range);
2238 memset(range, 0, sizeof(struct iw_range));
2239
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002240 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2241 {
2242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2243 "%s:LOGP in Progress. Ignore!!!", __func__);
2244 return -EBUSY;
2245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002246
2247 /*Get the phy mode*/
2248 if (ccmCfgGetInt(hHal,
2249 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2250 {
2251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002252 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002253
2254 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2255 {
2256 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002257 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 if (ccmCfgGetStr(hHal,
2259 WNI_CFG_SUPPORTED_RATES_11A,
2260 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2261 {
2262 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2263 {
2264 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2265 }
2266 for (i = 0; i < a_len; i++)
2267 {
2268 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2269 }
2270 range->num_bitrates = a_len;
2271 }
2272 else
2273 {
2274 return -EIO;
2275 }
2276 }
2277 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2278 {
2279 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002280 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 if (ccmCfgGetStr(hHal,
2282 WNI_CFG_SUPPORTED_RATES_11B,
2283 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2284 {
2285 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2286 {
2287 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2288 }
2289 for (i = 0; i < b_len; i++)
2290 {
2291 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2292 }
2293 range->num_bitrates = b_len;
2294 }
2295 else
2296 {
2297 return -EIO;
2298 }
2299 }
2300 }
2301
2302 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2303 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2304 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2305
2306 range->encoding_size[0] = 5;
2307 range->encoding_size[1] = 13;
2308 range->num_encoding_sizes = 2;
2309 range->max_encoding_tokens = MAX_WEP_KEYS;
2310
2311 // we support through Wireless Extensions 22
2312 range->we_version_compiled = WIRELESS_EXT;
2313 range->we_version_source = 22;
2314
2315 /*Supported Channels and Frequencies*/
2316 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2317 {
c_hpothub8245442013-11-20 23:41:09 +05302318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2319 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 return -EIO;
2321 }
2322 if (num_channels > IW_MAX_FREQUENCIES)
2323 {
2324 num_channels = IW_MAX_FREQUENCIES;
2325 }
2326
2327 range->num_channels = num_channels;
2328 range->num_frequency = num_channels;
2329
2330 for (index=0; index < num_channels; index++)
2331 {
2332 v_U32_t frq_indx = 0;
2333
2334 range->freq[index].i = channels[index];
2335 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2336 {
2337 if(channels[index] == freq_chan_map[frq_indx].chan)
2338 {
2339 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2340 range->freq[index].e = 1;
2341 break;
2342 }
2343 frq_indx++;
2344 }
2345 }
2346
2347 /* Event capability (kernel + driver) */
2348 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2349 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2350 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2351 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2352
2353 /*Encryption capability*/
2354 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2355 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2356
2357 /* Txpower capability */
2358 range->txpower_capa = IW_TXPOW_MWATT;
2359
2360 /*Scanning capability*/
2361 #if WIRELESS_EXT >= 22
2362 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2363 #endif
2364
2365 EXIT();
2366 return 0;
2367}
2368
2369/* Callback function registered with PMC to know status of PMC request */
2370static void iw_power_callback_fn (void *pContext, eHalStatus status)
2371{
2372 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002373
2374 if (NULL == pContext)
2375 {
2376 hddLog(VOS_TRACE_LEVEL_ERROR,
2377 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002378 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 return;
2380 }
2381
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
Jeff Johnson72a40512013-12-19 10:14:15 -08002384 /* there is a race condition that exists between this callback
2385 function and the caller since the caller could time out either
2386 before or while this code is executing. we use a spinlock to
2387 serialize these actions */
2388 spin_lock(&hdd_context_lock);
2389
2390 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 {
2392 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002393 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002395 "%s: Invalid context, magic [%08x]",
2396 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002397
2398 if (ioctl_debug)
2399 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002400 pr_info("%s: Invalid context, magic [%08x]\n",
2401 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 }
2403 return;
2404 }
2405
Jeff Johnson72a40512013-12-19 10:14:15 -08002406 /* context is valid so caller is still waiting */
2407
2408 /* paranoia: invalidate the magic */
2409 pStatsContext->magic = 0;
2410
2411 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002413
2414 /* serialization is complete */
2415 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002416}
2417
2418/* Callback function for tx per hit */
2419void hdd_tx_per_hit_cb (void *pCallbackContext)
2420{
2421 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2422 unsigned char tx_fail[16];
2423 union iwreq_data wrqu;
2424
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05302425 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002427 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 return;
2429 }
2430 memset(&wrqu, 0, sizeof(wrqu));
2431 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2432 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2433}
2434
2435void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2436{
2437 struct statsContext *pStatsContext;
2438 tCsrGlobalClassAStatsInfo *pClassAStats;
2439 hdd_adapter_t *pAdapter;
2440
2441 if (ioctl_debug)
2442 {
2443 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002444 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 }
2446
2447 if ((NULL == pStats) || (NULL == pContext))
2448 {
2449 hddLog(VOS_TRACE_LEVEL_ERROR,
2450 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002451 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 return;
2453 }
2454
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 pClassAStats = pStats;
2456 pStatsContext = pContext;
2457 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002458
2459 /* there is a race condition that exists between this callback
2460 function and the caller since the caller could time out either
2461 before or while this code is executing. we use a spinlock to
2462 serialize these actions */
2463 spin_lock(&hdd_context_lock);
2464
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2466 {
2467 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002468 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 hddLog(VOS_TRACE_LEVEL_WARN,
2470 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002471 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 if (ioctl_debug)
2473 {
2474 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002475 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 }
2477 return;
2478 }
2479
Jeff Johnson72a40512013-12-19 10:14:15 -08002480 /* context is valid so caller is still waiting */
2481
2482 /* paranoia: invalidate the magic */
2483 pStatsContext->magic = 0;
2484
2485 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2487
Jeff Johnson72a40512013-12-19 10:14:15 -08002488 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002490
2491 /* serialization is complete */
2492 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002493}
2494
2495VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2496{
2497 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2498 eHalStatus hstatus;
2499 long lrc;
2500 struct statsContext context;
2501
2502 if (NULL == pAdapter)
2503 {
2504 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2505 return VOS_STATUS_E_FAULT;
2506 }
2507 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2508 {
2509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2510 return VOS_STATUS_SUCCESS;
2511 }
2512
2513 /* we are connected
2514 prepare our callback context */
2515 init_completion(&context.completion);
2516 context.pAdapter = pAdapter;
2517 context.magic = STATS_CONTEXT_MAGIC;
2518 /* query only for Class A statistics (which include link speed) */
2519 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2520 eCSR_HDD,
2521 SME_GLOBAL_CLASSA_STATS,
2522 hdd_GetClassA_statisticsCB,
2523 0, // not periodic
2524 FALSE, //non-cached results
2525 pHddStaCtx->conn_info.staId[0],
2526 &context);
2527 if (eHAL_STATUS_SUCCESS != hstatus)
2528 {
2529 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002530 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002531 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 /* we'll returned a cached value below */
2533 }
2534 else
2535 {
2536 /* request was sent -- wait for the response */
2537 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2538 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 if (lrc <= 0)
2540 {
2541 hddLog(VOS_TRACE_LEVEL_ERROR,
2542 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002543 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 }
2545 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002546
2547 /* either we never sent a request, we sent a request and received a
2548 response or we sent a request and timed out. if we never sent a
2549 request or if we sent a request and got a response, we want to
2550 clear the magic out of paranoia. if we timed out there is a
2551 race condition such that the callback function could be
2552 executing at the same time we are. of primary concern is if the
2553 callback function had already verified the "magic" but had not
2554 yet set the completion variable when a timeout occurred. we
2555 serialize these activities by invalidating the magic while
2556 holding a shared spinlock which will cause us to block if the
2557 callback is currently executing */
2558 spin_lock(&hdd_context_lock);
2559 context.magic = 0;
2560 spin_unlock(&hdd_context_lock);
2561
2562 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 return VOS_STATUS_SUCCESS;
2564}
2565
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002566static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2567{
2568 struct statsContext *pStatsContext;
2569 tCsrSummaryStatsInfo *pSummaryStats;
2570 tCsrGlobalClassAStatsInfo *pClassAStats;
2571 hdd_adapter_t *pAdapter;
2572
2573 if (ioctl_debug)
2574 {
2575 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002576 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002577 }
2578
2579 if ((NULL == pStats) || (NULL == pContext))
2580 {
2581 hddLog(VOS_TRACE_LEVEL_ERROR,
2582 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002583 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002584 return;
2585 }
2586
Jeff Johnson72a40512013-12-19 10:14:15 -08002587 /* there is a race condition that exists between this callback
2588 function and the caller since the caller could time out either
2589 before or while this code is executing. we use a spinlock to
2590 serialize these actions */
2591 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002592
2593 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2594 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2595 pStatsContext = pContext;
2596 pAdapter = pStatsContext->pAdapter;
2597 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2598 {
2599 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002600 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002601 hddLog(VOS_TRACE_LEVEL_WARN,
2602 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002603 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002604 if (ioctl_debug)
2605 {
2606 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002607 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002608 }
2609 return;
2610 }
2611
Jeff Johnson72a40512013-12-19 10:14:15 -08002612 /* context is valid so caller is still waiting */
2613
2614 /* paranoia: invalidate the magic */
2615 pStatsContext->magic = 0;
2616
2617 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002618 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2619 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2620
Jeff Johnson72a40512013-12-19 10:14:15 -08002621 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002622 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002623
2624 /* serialization is complete */
2625 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002626}
2627
2628VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2629{
2630 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2631 eHalStatus hstatus;
2632 long lrc;
2633 struct statsContext context;
2634
2635 if (NULL == pAdapter)
2636 {
2637 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2638 return VOS_STATUS_SUCCESS;
2639 }
2640
2641 /* we are connected
2642 prepare our callback context */
2643 init_completion(&context.completion);
2644 context.pAdapter = pAdapter;
2645 context.magic = STATS_CONTEXT_MAGIC;
2646
2647 /* query only for Summary & Class A statistics */
2648 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2649 eCSR_HDD,
2650 SME_SUMMARY_STATS |
2651 SME_GLOBAL_CLASSA_STATS,
2652 hdd_get_station_statisticsCB,
2653 0, // not periodic
2654 FALSE, //non-cached results
2655 pHddStaCtx->conn_info.staId[0],
2656 &context);
2657 if (eHAL_STATUS_SUCCESS != hstatus)
2658 {
2659 hddLog(VOS_TRACE_LEVEL_ERROR,
2660 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002661 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002662 /* we'll return with cached values */
2663 }
2664 else
2665 {
2666 /* request was sent -- wait for the response */
2667 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2668 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002669
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002670 if (lrc <= 0)
2671 {
2672 hddLog(VOS_TRACE_LEVEL_ERROR,
2673 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002674 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002675 }
2676 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002677
2678 /* either we never sent a request, we sent a request and received a
2679 response or we sent a request and timed out. if we never sent a
2680 request or if we sent a request and got a response, we want to
2681 clear the magic out of paranoia. if we timed out there is a
2682 race condition such that the callback function could be
2683 executing at the same time we are. of primary concern is if the
2684 callback function had already verified the "magic" but had not
2685 yet set the completion variable when a timeout occurred. we
2686 serialize these activities by invalidating the magic while
2687 holding a shared spinlock which will cause us to block if the
2688 callback is currently executing */
2689 spin_lock(&hdd_context_lock);
2690 context.magic = 0;
2691 spin_unlock(&hdd_context_lock);
2692
2693 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002694 return VOS_STATUS_SUCCESS;
2695}
2696
2697
Jeff Johnson295189b2012-06-20 16:38:30 -07002698/*
2699 * Support for the LINKSPEED private command
2700 * Per the WiFi framework the response must be of the form
2701 * "LinkSpeed xx"
2702 */
2703static int iw_get_linkspeed(struct net_device *dev,
2704 struct iw_request_info *info,
2705 union iwreq_data *wrqu, char *extra)
2706{
2707 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302708 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302710 int len = sizeof(v_U32_t) + 1;
2711 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302713 VOS_STATUS status;
2714 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002715
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302716 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2717
2718 valid = wlan_hdd_validate_context(pHddCtx);
2719
2720 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002721 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302722 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2723 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002724 }
2725
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2727 {
2728 /* we are not connected so we don't have a classAstats */
2729 link_speed = 0;
2730 }
2731 else
2732 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302733 status = wlan_hdd_get_classAstats(pAdapter);
2734
2735 if (!VOS_IS_STATUS_SUCCESS(status ))
2736 {
2737 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2738 return -EINVAL;
2739 }
2740
2741 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2742 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2743 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2744 &link_speed);
2745
2746 link_speed = link_speed / 10;
2747
2748 if (0 == link_speed)
2749 {
2750 /* The linkspeed returned by HAL is in units of 500kbps.
2751 * converting it to mbps.
2752 * This is required to support legacy firmware which does
2753 * not return link capacity.
2754 */
2755 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2756 }
2757
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 }
2759
2760 wrqu->data.length = len;
2761 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002762 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002763 if ((rc < 0) || (rc >= len))
2764 {
2765 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302766 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 return -EIO;
2768 }
2769
2770 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002771 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002772}
2773
Arif Hussain695279c2014-03-24 14:06:07 -07002774/*
2775 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2776 *
2777 */
2778static int iw_get_linkspeed_priv(struct net_device *dev,
2779 struct iw_request_info *info,
2780 union iwreq_data *wrqu, char *extra)
2781{
2782 int rc;
2783
2784 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2785
2786 if (rc < 0)
2787 return rc;
2788
2789 /* a value is being successfully returned */
2790 return 0;
2791}
Jeff Johnson295189b2012-06-20 16:38:30 -07002792
2793/*
2794 * Support for the RSSI & RSSI-APPROX private commands
2795 * Per the WiFi framework the response must be of the form
2796 * "<ssid> rssi <xx>"
2797 * unless we are not associated, in which case the response is
2798 * "OK"
2799 */
2800static int iw_get_rssi(struct net_device *dev,
2801 struct iw_request_info *info,
2802 union iwreq_data *wrqu, char *extra)
2803{
2804 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002805 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 int len = wrqu->data.length;
2807 v_S7_t s7Rssi = 0;
2808 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2809 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2810 VOS_STATUS vosStatus;
2811 int rc;
2812
2813 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2814 (0 == ssidlen) || (ssidlen >= len))
2815 {
2816 /* we are not connected or our SSID is too long
2817 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002818 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 }
2820 else
2821 {
2822 /* we are connected with a valid SSID
2823 so we can write the SSID into the return buffer
2824 (note that it is not NUL-terminated) */
2825 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2826
2827 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2828
2829 if (VOS_STATUS_SUCCESS == vosStatus)
2830 {
2831 /* append the rssi to the ssid in the format required by
2832 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002833 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302834 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 }
2836 else
2837 {
2838 rc = -1;
2839 }
2840 }
2841
2842 /* verify that we wrote a valid response */
2843 if ((rc < 0) || (rc >= len))
2844 {
2845 // encoding or length error?
2846 hddLog(VOS_TRACE_LEVEL_ERROR,
2847 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002848 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 return -EIO;
2850 }
2851
2852 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002853 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002854}
2855
2856/*
2857 * Support for SoftAP channel range private command
2858 */
2859static int iw_softap_set_channel_range( struct net_device *dev,
2860 int startChannel,
2861 int endChannel,
2862 int band)
2863{
Jeff Johnson43971f52012-07-17 12:26:56 -07002864 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 int ret = 0;
2866 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2867 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002868 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2869
Jeff Johnson295189b2012-06-20 16:38:30 -07002870
2871 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2872 if (VOS_STATUS_SUCCESS != status)
2873 {
2874 ret = -EINVAL;
2875 }
Yathish9f22e662012-12-10 14:21:35 -08002876 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 return ret;
2878}
2879
2880VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2881{
2882 struct statsContext context;
2883 eHalStatus status;
2884 hdd_context_t *pHddCtx;
2885
2886 if (NULL == pAdapter)
2887 {
2888 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2889 return VOS_STATUS_E_FAULT;
2890 }
2891
2892 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2893 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05302894 if (pHddCtx->isLogpInProgress) {
2895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2896 "%s:LOGP in Progress. Ignore!!!", __func__);
2897 return VOS_STATUS_E_FAILURE;
2898 }
2899
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 init_completion(&context.completion);
2901
2902 context.pAdapter = pAdapter;
2903 context.magic = POWER_CONTEXT_MAGIC;
2904
2905 if (DRIVER_POWER_MODE_ACTIVE == mode)
2906 {
2907 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2908 "Full Power", __func__);
2909 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2910 iw_power_callback_fn, &context,
2911 eSME_FULL_PWR_NEEDED_BY_HDD);
2912 // Enter Full power command received from GUI this means we are disconnected
2913 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2914 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2915 if (eHAL_STATUS_PMC_PENDING == status)
2916 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002917 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 int lrc = wait_for_completion_interruptible_timeout(
2919 &context.completion,
2920 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002921
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 if (lrc <= 0)
2923 {
2924 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002925 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002926 }
2927 }
2928 }
2929 else if (DRIVER_POWER_MODE_AUTO == mode)
2930 {
2931 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2932 {
2933 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2934 __func__);
2935 // Enter BMPS command received from GUI this means DHCP is completed
2936 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2937 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2938 FALSE);
2939 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2940 iw_power_callback_fn, &context);
2941 if (eHAL_STATUS_PMC_PENDING == status)
2942 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002943 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 int lrc = wait_for_completion_interruptible_timeout(
2945 &context.completion,
2946 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 if (lrc <= 0)
2948 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002949 hddLog(VOS_TRACE_LEVEL_ERROR,
2950 "%s: SME %s while requesting BMPS",
2951 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 }
2953 }
2954 }
2955 else
2956 {
2957 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2958 "enabled in the cfg");
2959 }
2960 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002961
2962 /* either we never sent a request, we sent a request and received a
2963 response or we sent a request and timed out. if we never sent a
2964 request or if we sent a request and got a response, we want to
2965 clear the magic out of paranoia. if we timed out there is a
2966 race condition such that the callback function could be
2967 executing at the same time we are. of primary concern is if the
2968 callback function had already verified the "magic" but had not
2969 yet set the completion variable when a timeout occurred. we
2970 serialize these activities by invalidating the magic while
2971 holding a shared spinlock which will cause us to block if the
2972 callback is currently executing */
2973 spin_lock(&hdd_context_lock);
2974 context.magic = 0;
2975 spin_unlock(&hdd_context_lock);
2976
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 return VOS_STATUS_SUCCESS;
2978}
2979
2980VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2981 hdd_adapter_t *pAdapter)
2982{
2983 VOS_STATUS vos_Status;
2984
2985 if ((NULL == pAdapter) || (NULL == pHddCtx))
2986 {
2987 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2988 return VOS_STATUS_E_FAULT;
2989 }
2990
2991 /**Exit from Deep sleep or standby if we get the driver
2992 START cmd from android GUI
2993 */
2994 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2995 {
2996 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2997 "from Stand by",__func__);
2998 vos_Status = hdd_exit_standby(pHddCtx);
2999 }
3000 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3001 {
3002 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3003 "from deep sleep",__func__);
3004 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3005 }
3006 else
3007 {
3008 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3009 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3010 vos_Status = VOS_STATUS_SUCCESS;
3011 }
3012
3013 return vos_Status;
3014}
3015
3016VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3017{
3018 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3019
3020 if (NULL == pHddCtx)
3021 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303022 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 return VOS_STATUS_E_FAULT;
3024 }
3025
3026 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3027 {
3028 //Execute standby procedure.
3029 //Executing standby procedure will cause the STA to
3030 //disassociate first and then the chip will be put into standby.
3031 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3032 vos_Status = hdd_enter_standby(pHddCtx);
3033 }
3034 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3035 pHddCtx->cfg_ini->nEnableDriverStop)
3036 {
3037 //Execute deep sleep procedure
3038 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003039 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 //Deep sleep not supported
3041 vos_Status = hdd_enter_standby(pHddCtx);
3042 }
3043 else
3044 {
3045 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3046 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3047 vos_Status = VOS_STATUS_SUCCESS;
3048 }
3049
3050 return vos_Status;
3051}
3052
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003053
3054void* wlan_hdd_change_country_code_callback(void *pAdapter)
3055{
3056
3057 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003058 complete(&call_back_pAdapter->change_country_code);
3059
3060 return NULL;
3061}
3062
Jeff Johnson295189b2012-06-20 16:38:30 -07003063static int iw_set_priv(struct net_device *dev,
3064 struct iw_request_info *info,
3065 union iwreq_data *wrqu, char *extra)
3066{
3067 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003068 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 int cmd_len = wrqu->data.length;
3070 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003071 int rc = 0;
3072 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3073
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3075
3076 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003077 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3078 wrqu->data.length);
3079 if (NULL == cmd)
3080 {
3081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3082 "mem_alloc_copy_from_user_helper fail");
3083 return -ENOMEM;
3084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003085
3086 if (ioctl_debug)
3087 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003088 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 }
3090
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003091 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3092 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003093
3094 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003095 if (ioctl_debug)
3096 {
3097 pr_info("%s: RESTART in progress\n", __func__);
3098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003099
Arif Hussain24bfa702014-01-22 13:51:30 -08003100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003102 kfree(cmd);
3103 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 }
3105
Arif Hussain24bfa702014-01-22 13:51:30 -08003106 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003108 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3110 "%s: Error in iw_set_scan!", __func__);
3111 rc = -EINVAL;
3112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 }
3114 else if( strcasecmp(cmd, "start") == 0 ) {
3115
Arif Hussain6d2a3322013-11-17 19:50:10 -08003116 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003118
Arif Hussain24bfa702014-01-22 13:51:30 -08003119 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3120 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 {
3122 union iwreq_data wrqu;
3123 char buf[10];
3124
3125 memset(&wrqu, 0, sizeof(wrqu));
3126 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3127 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3128 }
3129 else
3130 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003131 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3132 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 }
3134 goto done;
3135 }
3136 else if( strcasecmp(cmd, "stop") == 0 )
3137 {
3138 union iwreq_data wrqu;
3139 char buf[10];
3140
Arif Hussain6d2a3322013-11-17 19:50:10 -08003141 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003142
3143 wlan_hdd_enter_lowpower(pHddCtx);
3144 memset(&wrqu, 0, sizeof(wrqu));
3145 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3146 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 goto done;
3148 }
3149 else if (strcasecmp(cmd, "macaddr") == 0)
3150 {
3151 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3152 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3153 }
3154 else if (strcasecmp(cmd, "scan-active") == 0)
3155 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303156 hddLog(VOS_TRACE_LEVEL_ERROR,
3157 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003158 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 ret = snprintf(cmd, cmd_len, "OK");
3160 }
3161 else if (strcasecmp(cmd, "scan-passive") == 0)
3162 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303163 hddLog(VOS_TRACE_LEVEL_ERROR,
3164 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003165 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 ret = snprintf(cmd, cmd_len, "OK");
3167 }
3168 else if( strcasecmp(cmd, "scan-mode") == 0 )
3169 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003170 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 }
3172 else if( strcasecmp(cmd, "linkspeed") == 0 )
3173 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003174 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 }
3176 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3177 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003178 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003179 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003180
3181 country_code = cmd + 8;
3182
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003183 init_completion(&pAdapter->change_country_code);
3184
Arif Hussain24bfa702014-01-22 13:51:30 -08003185 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003186 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 country_code,
3188 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303189 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303190 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303191 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003192
3193 /* Wait for completion */
3194 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3195 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3196
3197 if (lrc <= 0)
3198 {
3199 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003200 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003201 }
3202
Arif Hussain24bfa702014-01-22 13:51:30 -08003203 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003205 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003206 "%s: SME Change Country code fail", __func__);
3207 kfree(cmd);
3208 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 }
3210 }
3211 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3212 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003213 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 }
3215 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3216 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003217 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003218
Wilson Yang1be3e652013-10-09 15:18:31 -07003219 if (9 < cmd_len)
3220 {
3221 ptr = (char*)(cmd + 9);
3222
3223 }else{
3224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3225 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003226 kfree(cmd);
3227 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003228 }
3229
3230 if (1 != sscanf(ptr,"%d",&mode))
3231 {
3232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3233 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003234 kfree(cmd);
3235 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003236 }
3237
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 wlan_hdd_enter_bmps(pAdapter, mode);
3239 /*TODO:Set the power mode*/
3240 }
3241 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3242 v_U32_t pmc_state;
3243 v_U16_t value;
3244
3245 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3246 if(pmc_state == BMPS) {
3247 value = DRIVER_POWER_MODE_AUTO;
3248 }
3249 else {
3250 value = DRIVER_POWER_MODE_ACTIVE;
3251 }
3252 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3253 }
3254 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003255 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 /*TODO: set the btcoexmode*/
3257 }
3258 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3259
Arif Hussain6d2a3322013-11-17 19:50:10 -08003260 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 /*TODO: Return the btcoex status*/
3262 }
3263 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3264
Arif Hussain6d2a3322013-11-17 19:50:10 -08003265 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003266
3267 /*TODO: Enable Rx data Filter*/
3268 }
3269 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3270
Arif Hussain6d2a3322013-11-17 19:50:10 -08003271 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003272
3273 /*TODO: Disable Rx data Filter*/
3274 }
3275 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3276
Arif Hussain6d2a3322013-11-17 19:50:10 -08003277 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 /*TODO: rxfilter-statistics*/
3279 }
3280 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3281
Arif Hussain6d2a3322013-11-17 19:50:10 -08003282 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 /*TODO: rxfilter-add*/
3284 }
3285 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3286
Arif Hussain6d2a3322013-11-17 19:50:10 -08003287 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 /*TODO: rxfilter-remove*/
3289 }
3290#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003291 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3292 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3293 /*TODO: support pnosetup*/
3294 }
3295 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3296 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3297 /*TODO: support pnoforce*/
3298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3300
Arif Hussain6d2a3322013-11-17 19:50:10 -08003301 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003302 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3303 kfree(cmd);
3304 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 }
3306 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003307 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003308 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3309 kfree(cmd);
3310 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 }
3312#endif /*FEATURE_WLAN_SCAN_PNO*/
3313 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003314 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003315 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3316 kfree(cmd);
3317 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 }
3319 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3320 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003321 char *ptr;
3322
3323 if (18 < cmd_len)
3324 {
3325 ptr = (char*)(cmd + 18);
3326 }else{
3327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3328 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003329 kfree(cmd);
3330 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003331 }
3332
Jeff Johnson02797792013-10-26 19:17:13 -07003333 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003334 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3335 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3336 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3337 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3338 {
3339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3340 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003341 kfree(cmd);
3342 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003344
3345 // parameters checking
3346 // period has to be larger than 0
3347 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3348 {
3349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003350 kfree(cmd);
3351 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 }
3353
3354 // use default value 5 is the input is not reasonable. in unit of 10%
3355 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3356 {
3357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3358 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3359 }
3360
3361 // default is 5
3362 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3363 {
3364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3365 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3366 }
3367
Arif Hussain24bfa702014-01-22 13:51:30 -08003368 if (eHAL_STATUS_SUCCESS !=
3369 sme_SetTxPerTracking(pHddCtx->hHal,
3370 hdd_tx_per_hit_cb,
3371 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003373 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 }
3375 }
3376 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003377 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3378 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 }
3380done:
3381 /* many of the commands write information back into the command
3382 string using snprintf(). check the return value here in one
3383 place */
3384 if ((ret < 0) || (ret >= cmd_len))
3385 {
3386 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003387 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003389 else if (ret > 0)
3390 {
3391 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3392 {
3393 hddLog(VOS_TRACE_LEVEL_ERROR,
3394 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003395 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003396 return -EFAULT;
3397 }
3398 wrqu->data.length = ret;
3399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003400
3401 if (ioctl_debug)
3402 {
3403 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003404 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003406 kfree(cmd);
3407 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003408}
3409
3410static int iw_set_nick(struct net_device *dev,
3411 struct iw_request_info *info,
3412 union iwreq_data *wrqu, char *extra)
3413{
3414 ENTER();
3415 return 0;
3416}
3417
3418static int iw_get_nick(struct net_device *dev,
3419 struct iw_request_info *info,
3420 union iwreq_data *wrqu, char *extra)
3421{
3422 ENTER();
3423 return 0;
3424}
3425
3426static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3427{
3428 ENTER();
3429 return NULL;
3430}
3431
3432static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3433 union iwreq_data *wrqu,char *extra)
3434
3435{
3436 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3437 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3438 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3439 struct iw_point *encoderq = &(wrqu->encoding);
3440 v_U32_t keyId;
3441 v_U8_t key_length;
3442 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3443 v_BOOL_t fKeyPresent = 0;
3444 int i;
3445 eHalStatus status = eHAL_STATUS_SUCCESS;
3446
3447
3448 ENTER();
3449
3450 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3451 {
3452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3453 "%s:LOGP in Progress. Ignore!!!",__func__);
3454 return 0;
3455 }
3456
3457
3458 keyId = encoderq->flags & IW_ENCODE_INDEX;
3459
3460 if(keyId)
3461 {
3462 if(keyId > MAX_WEP_KEYS)
3463 {
3464 return -EINVAL;
3465 }
3466
3467 fKeyPresent = 1;
3468 keyId--;
3469 }
3470 else
3471 {
3472 fKeyPresent = 0;
3473 }
3474
3475
3476 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3477 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 if(!fKeyPresent) {
3480
3481 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3482
3483 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3484 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3485 }
3486 }
3487 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3488 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3489 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3490 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3491
3492 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3493 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3494
3495 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3496 {
3497 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3498 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003499 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303500 {
3501 long ret;
3502 ret = wait_for_completion_interruptible_timeout(
3503 &pAdapter->disconnect_comp_var,
3504 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3505 if (ret <= 0)
3506 hddLog(VOS_TRACE_LEVEL_ERROR,
3507 FL("failed wait on disconnect_comp_var %ld"), ret);
3508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 }
3510
3511 return status;
3512
3513 }
3514
3515 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3516 {
3517 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3518
3519 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3520
3521 }
3522
3523
3524 if(wrqu->data.length > 0)
3525 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003526 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003527
3528 key_length = wrqu->data.length;
3529
3530 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3531
3532 if(5 == key_length)
3533 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003534 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003535
3536 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3537 {
3538 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3539 }
3540 else
3541 {
3542 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3543 }
3544 }
3545 else if(13 == key_length)
3546 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003547 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003548
3549 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3550 {
3551 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3552 }
3553 else
3554 {
3555 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3556 }
3557 }
3558 else
3559 {
3560 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003561 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 return -EINVAL;
3563 }
3564
3565 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3566 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3567 pWextState->roamProfile.EncryptionType.numEntries = 1;
3568 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3569 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3570 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3571
3572 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3573 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3574 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3575 {
3576
3577 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3578
3579 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3580 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3581
3582 return status;
3583 }
3584 }
3585
3586 return 0;
3587}
3588
3589static int iw_get_encodeext(struct net_device *dev,
3590 struct iw_request_info *info,
3591 struct iw_point *dwrq,
3592 char *extra)
3593{
3594 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3595 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3596 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3597 int keyId;
3598 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3599 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3600 int i;
3601
3602 ENTER();
3603
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003604 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3605 {
3606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3607 "%s:LOGP in Progress. Ignore!!!", __func__);
3608 return -EBUSY;
3609 }
3610
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 keyId = pRoamProfile->Keys.defaultIndex;
3612
3613 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3614 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003615 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 return -EINVAL;
3617 }
3618
3619 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3620 {
3621 dwrq->flags |= IW_ENCODE_ENABLED;
3622 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303623 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3624 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 }
3626 else
3627 {
3628 dwrq->flags |= IW_ENCODE_DISABLED;
3629 }
3630
3631 for(i=0; i < MAX_WEP_KEYS; i++)
3632 {
3633 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3634 {
3635 continue;
3636 }
3637 else
3638 {
3639 break;
3640 }
3641 }
3642
3643 if(MAX_WEP_KEYS == i)
3644 {
3645 dwrq->flags |= IW_ENCODE_NOKEY;
3646 }
3647 else
3648 {
3649 dwrq->flags |= IW_ENCODE_ENABLED;
3650 }
3651
3652 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3653
3654 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3655 {
3656 dwrq->flags |= IW_ENCODE_DISABLED;
3657 }
3658
3659 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3660
3661 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3662 {
3663 dwrq->flags |= IW_ENCODE_OPEN;
3664 }
3665 else
3666 {
3667 dwrq->flags |= IW_ENCODE_RESTRICTED;
3668 }
3669 EXIT();
3670 return 0;
3671
3672}
3673
3674static int iw_set_encodeext(struct net_device *dev,
3675 struct iw_request_info *info,
3676 union iwreq_data *wrqu, char *extra)
3677{
3678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3679 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3680 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3681 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3682
3683 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3684 v_U32_t status = 0;
3685
3686 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3687
3688 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3689
3690 int key_index;
3691 struct iw_point *encoding = &wrqu->encoding;
3692 tCsrRoamSetKey setKey;
3693 v_U32_t roamId= 0xFF;
3694 VOS_STATUS vos_status;
3695
3696 ENTER();
3697
3698 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3699 {
3700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3701 "%s:LOGP in Progress. Ignore!!!",__func__);
3702 return 0;
3703 }
3704
3705 key_index = encoding->flags & IW_ENCODE_INDEX;
3706
3707 if(key_index > 0) {
3708
3709 /*Convert from 1-based to 0-based keying*/
3710 key_index--;
3711 }
3712 if(!ext->key_len) {
3713
3714 /*Set the encrytion type to NONE*/
3715 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3716 return status;
3717 }
3718
3719 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3720 (IW_ENCODE_ALG_WEP == ext->alg))
3721 {
3722 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3723
Agarwal Ashish971c2882013-10-30 20:11:12 +05303724 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3725 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 return -EINVAL;
3727 }
3728 else {
3729 /*Static wep, update the roam profile with the keys */
3730 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3731 key_index < CSR_MAX_NUM_KEY) {
3732 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3733 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3734
3735 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3736 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3737
3738 }
3739 }
3740 return status;
3741 }
3742
3743 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3744
3745 setKey.keyId = key_index;
3746 setKey.keyLength = ext->key_len;
3747
3748 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3749 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3750 }
3751
3752 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3753 /*Key direction for group is RX only*/
3754 setKey.keyDirection = eSIR_RX_ONLY;
3755 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3756 }
3757 else {
3758
3759 setKey.keyDirection = eSIR_TX_RX;
3760 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3761 }
3762
3763 /*For supplicant pae role is zero*/
3764 setKey.paeRole = 0;
3765
3766 switch(ext->alg)
3767 {
3768 case IW_ENCODE_ALG_NONE:
3769 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3770 break;
3771
3772 case IW_ENCODE_ALG_WEP:
3773 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3774 break;
3775
3776 case IW_ENCODE_ALG_TKIP:
3777 {
3778 v_U8_t *pKey = &setKey.Key[0];
3779
3780 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3781
3782 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3783
3784 /*Supplicant sends the 32bytes key in this order
3785
3786 |--------------|----------|----------|
3787 | Tk1 |TX-MIC | RX Mic |
3788 |--------------|----------|----------|
3789 <---16bytes---><--8bytes--><--8bytes-->
3790
3791 */
3792 /*Sme expects the 32 bytes key to be in the below order
3793
3794 |--------------|----------|----------|
3795 | Tk1 |RX-MIC | TX Mic |
3796 |--------------|----------|----------|
3797 <---16bytes---><--8bytes--><--8bytes-->
3798 */
3799 /* Copy the Temporal Key 1 (TK1) */
3800 vos_mem_copy(pKey,ext->key,16);
3801
3802 /*Copy the rx mic first*/
3803 vos_mem_copy(&pKey[16],&ext->key[24],8);
3804
3805 /*Copy the tx mic */
3806 vos_mem_copy(&pKey[24],&ext->key[16],8);
3807
3808 }
3809 break;
3810
3811 case IW_ENCODE_ALG_CCMP:
3812 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3813 break;
3814
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003815#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003816#define IW_ENCODE_ALG_KRK 6
3817 case IW_ENCODE_ALG_KRK:
3818 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3819 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003820#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003821
3822 default:
3823 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3824 break;
3825 }
3826
3827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003828 ("%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 -07003829
3830#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303831 /* The supplicant may attempt to set the PTK once pre-authentication
3832 is done. Save the key in the UMAC and include it in the ADD
3833 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303835 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303837 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3838 "%s: Update PreAuth Key success", __func__);
3839 return 0;
3840 }
3841 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3842 {
3843 hddLog(VOS_TRACE_LEVEL_ERROR,
3844 "%s: Update PreAuth Key failed", __func__);
3845 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 }
3847#endif /* WLAN_FEATURE_VOWIFI_11R */
3848
3849 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3850
3851 vos_status = wlan_hdd_check_ula_done(pAdapter);
3852 if ( vos_status != VOS_STATUS_SUCCESS )
3853 {
3854 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3855 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3856 __LINE__, vos_status );
3857
3858 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3859 }
3860
3861 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3862
3863 if ( halStatus != eHAL_STATUS_SUCCESS )
3864 {
3865 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3866 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3867 __LINE__, halStatus );
3868
3869 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3870 }
3871
3872 return halStatus;
3873}
3874
3875static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3876 union iwreq_data *wrqu, char *extra)
3877{
3878 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3879 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3880
3881 ENTER();
3882
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003883 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3884 {
3885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3886 "%s:LOGP in Progress. Ignore!!!", __func__);
3887 return -EBUSY;
3888 }
3889
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3891 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3892
Arif Hussain6d2a3322013-11-17 19:50:10 -08003893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003894
3895 return -EINVAL;
3896 }
3897
3898 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3899
3900 if((wrqu->retry.flags & IW_RETRY_LONG))
3901 {
3902 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3903 {
c_hpothub8245442013-11-20 23:41:09 +05303904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3905 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 return -EIO;
3907 }
3908 }
3909 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3910 {
3911 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3912 {
c_hpothub8245442013-11-20 23:41:09 +05303913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3914 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 return -EIO;
3916 }
3917 }
3918 }
3919 else
3920 {
3921 return -EOPNOTSUPP;
3922 }
3923
Arif Hussain6d2a3322013-11-17 19:50:10 -08003924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003925
3926 EXIT();
3927
3928 return 0;
3929
3930}
3931
3932static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3933 union iwreq_data *wrqu, char *extra)
3934{
3935 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3936 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3937 v_U32_t retry = 0;
3938
3939 ENTER();
3940
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003941 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3942 {
3943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3944 "%s:LOGP in Progress. Ignore!!!", __func__);
3945 return -EBUSY;
3946 }
3947
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 if((wrqu->retry.flags & IW_RETRY_LONG))
3949 {
3950 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3951
3952 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3953 {
c_hpothub8245442013-11-20 23:41:09 +05303954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3955 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 return -EIO;
3957 }
3958
3959 wrqu->retry.value = retry;
3960 }
3961 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3962 {
3963 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3964
3965 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3966 {
c_hpothub8245442013-11-20 23:41:09 +05303967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3968 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 return -EIO;
3970 }
3971
3972 wrqu->retry.value = retry;
3973 }
3974 else {
3975 return -EOPNOTSUPP;
3976 }
3977
Arif Hussain6d2a3322013-11-17 19:50:10 -08003978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979
3980 EXIT();
3981
3982 return 0;
3983}
3984
3985static int iw_set_mlme(struct net_device *dev,
3986 struct iw_request_info *info,
3987 union iwreq_data *wrqu,
3988 char *extra)
3989{
3990 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3991 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3992 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3993 eHalStatus status = eHAL_STATUS_SUCCESS;
3994
3995 ENTER();
3996
3997 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3998 {
3999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4000 "%s:LOGP in Progress. Ignore!!!",__func__);
4001 return 0;
4002 }
4003
4004 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4005 switch (mlme->cmd) {
4006 case IW_MLME_DISASSOC:
4007 case IW_MLME_DEAUTH:
4008
4009 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
4010 {
4011 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4012
4013 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4014 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4015
4016 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4017 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
4018
Jeff Johnson43971f52012-07-17 12:26:56 -07004019 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304020 {
4021 long ret;
4022 ret = wait_for_completion_interruptible_timeout(
4023 &pAdapter->disconnect_comp_var,
4024 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4025 if (ret <= 0)
4026 hddLog(VOS_TRACE_LEVEL_ERROR,
4027 FL("failed wait on disconnect_comp_var %ld"), ret);
4028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08004030 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004031 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07004032
4033 /* Resetting authKeyMgmt */
4034 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
4035
4036 netif_tx_disable(dev);
4037 netif_carrier_off(dev);
4038
4039 }
4040 else
4041 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004042 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 -07004043 }
4044 break;
4045 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004046 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 return -EINVAL;
4048 }//end of switch
4049
4050 EXIT();
4051
4052 return status;
4053
4054}
4055
4056/* set param sub-ioctls */
4057static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
4058 union iwreq_data *wrqu, char *extra)
4059{
4060 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4061 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4062 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4063 int *value = (int *)extra;
4064 int sub_cmd = value[0];
4065 int set_value = value[1];
4066 int ret = 0; /* success */
4067 int enable_pbm, enable_mp;
4068#ifdef CONFIG_HAS_EARLYSUSPEND
4069 v_U8_t nEnableSuspendOld;
4070#endif
4071 INIT_COMPLETION(pWextState->completion_var);
4072
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004073 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4074 {
4075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4076 "%s:LOGP in Progress. Ignore!!!", __func__);
4077 return -EBUSY;
4078 }
4079
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 switch(sub_cmd)
4081 {
4082 case WE_SET_11D_STATE:
4083 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004084 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004085 memset(&smeConfig, 0x00, sizeof(smeConfig));
4086
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4088
4089 sme_GetConfigParam(hHal,&smeConfig);
4090 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4091
Arif Hussain6d2a3322013-11-17 19:50:10 -08004092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004093
4094 sme_UpdateConfig(hHal,&smeConfig);
4095 }
4096 else {
4097 return -EINVAL;
4098 }
4099 break;
4100 }
4101
4102 case WE_WOWL:
4103 {
4104 switch (set_value)
4105 {
4106 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004107 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 break;
4109 case 0x01:
4110 case 0x02:
4111 case 0x03:
4112 enable_mp = (set_value & 0x01) ? 1 : 0;
4113 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004114 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4116 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4117 break;
4118 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004119 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 ret = -EINVAL;
4121 break;
4122 }
4123
4124 break;
4125 }
4126 case WE_SET_POWER:
4127 {
4128 switch (set_value)
4129 {
4130 case 0: //Full Power
4131 {
4132 struct statsContext context;
4133 eHalStatus status;
4134
4135 init_completion(&context.completion);
4136
4137 context.pAdapter = pAdapter;
4138 context.magic = POWER_CONTEXT_MAGIC;
4139
4140 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4141 iw_power_callback_fn, &context,
4142 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004143 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 {
4145 int lrc = wait_for_completion_interruptible_timeout(
4146 &context.completion,
4147 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004148
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 if (lrc <= 0)
4150 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004151 hddLog(VOS_TRACE_LEVEL_ERROR,
4152 "%s: SME %s while requesting fullpower",
4153 __func__, (0 == lrc) ?
4154 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 }
4156 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004157 /* either we have a response or we timed out. if we timed
4158 out there is a race condition such that the callback
4159 function could be executing at the same time we are. of
4160 primary concern is if the callback function had already
4161 verified the "magic" but had not yet set the completion
4162 variable when a timeout occurred. we serialize these
4163 activities by invalidating the magic while holding a
4164 shared spinlock which will cause us to block if the
4165 callback is currently executing */
4166 spin_lock(&hdd_context_lock);
4167 context.magic = 0;
4168 spin_unlock(&hdd_context_lock);
4169
Arif Hussain6d2a3322013-11-17 19:50:10 -08004170 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 break;
4172 }
4173 case 1: //Enable BMPS
4174 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4175 break;
4176 case 2: //Disable BMPS
4177 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4178 break;
4179 case 3: //Request Bmps
4180 {
4181 struct statsContext context;
4182 eHalStatus status;
4183
4184 init_completion(&context.completion);
4185
4186 context.pAdapter = pAdapter;
4187 context.magic = POWER_CONTEXT_MAGIC;
4188
4189 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4190 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004191 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 {
4193 int lrc = wait_for_completion_interruptible_timeout(
4194 &context.completion,
4195 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 if (lrc <= 0)
4197 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004198 hddLog(VOS_TRACE_LEVEL_ERROR,
4199 "%s: SME %s while requesting BMPS",
4200 __func__, (0 == lrc) ? "timeout" :
4201 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 }
4203 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004204 /* either we have a response or we timed out. if we
4205 timed out there is a race condition such that the
4206 callback function could be executing at the same
4207 time we are. of primary concern is if the callback
4208 function had already verified the "magic" but had
4209 not yet set the completion variable when a timeout
4210 occurred. we serialize these activities by
4211 invalidating the magic while holding a shared
4212 spinlock which will cause us to block if the
4213 callback is currently executing */
4214 spin_lock(&hdd_context_lock);
4215 context.magic = 0;
4216 spin_unlock(&hdd_context_lock);
4217
Arif Hussain6d2a3322013-11-17 19:50:10 -08004218 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 break;
4220 }
4221 case 4: //Enable IMPS
4222 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4223 break;
4224 case 5: //Disable IMPS
4225 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4226 break;
4227 case 6: //Enable Standby
4228 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4229 break;
4230 case 7: //Disable Standby
4231 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4232 break;
4233 case 8: //Request Standby
4234#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004235#endif
4236 break;
4237 case 9: //Start Auto Bmps Timer
4238 sme_StartAutoBmpsTimer(hHal);
4239 break;
4240 case 10://Stop Auto BMPS Timer
4241 sme_StopAutoBmpsTimer(hHal);
4242 break;
4243#ifdef CONFIG_HAS_EARLYSUSPEND
4244 case 11://suspend to standby
4245#ifdef CONFIG_HAS_EARLYSUSPEND
4246 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4247 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4249#endif
4250 break;
4251 case 12://suspend to deep sleep
4252#ifdef CONFIG_HAS_EARLYSUSPEND
4253 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4254 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4256#endif
4257 break;
4258 case 13://resume from suspend
4259#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004260#endif
4261 break;
4262#endif
4263 case 14://reset wlan (power down/power up)
4264 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4265 break;
4266 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004267 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 ret = -EINVAL;
4269 break;
4270 }
4271 break;
4272 }
4273
4274 case WE_SET_MAX_ASSOC:
4275 {
4276 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4277 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4278 {
4279 ret = -EINVAL;
4280 }
4281 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4282 set_value, NULL, eANI_BOOLEAN_FALSE)
4283 != eHAL_STATUS_SUCCESS )
4284 {
c_hpothub8245442013-11-20 23:41:09 +05304285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4286 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 ret = -EIO;
4288 }
4289 break;
4290 }
4291
4292 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4293 {
4294 if( 0 == set_value )
4295 {
4296 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4297 }
4298 else if ( 1 == set_value )
4299 {
4300 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4301 }
4302 else
4303 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004304 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 ret = -EINVAL;
4306 }
4307 break;
4308 }
4309
4310 case WE_SET_DATA_INACTIVITY_TO:
4311 {
4312 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4313 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4314 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4315 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4316 set_value,
4317 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4318 {
4319 hddLog(LOGE,"Failure: Could not pass on "
4320 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004321 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 ret = -EINVAL;
4323 }
4324 break;
4325 }
4326 case WE_SET_MAX_TX_POWER:
4327 {
4328 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4329 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4330
4331 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4332 __func__, set_value);
4333 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4334 eHAL_STATUS_SUCCESS )
4335 {
4336 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4337 __func__);
4338 return -EIO;
4339 }
4340
4341 break;
4342 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004343 case WE_SET_MAX_TX_POWER_2_4:
4344 {
4345 hddLog(VOS_TRACE_LEVEL_INFO,
4346 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4347 __func__, set_value);
4348 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4349 eHAL_STATUS_SUCCESS)
4350 {
4351 hddLog(VOS_TRACE_LEVEL_ERROR,
4352 "%s: Setting maximum tx power failed for 2.4 GHz band",
4353 __func__);
4354 return -EIO;
4355 }
4356
4357 break;
4358 }
4359 case WE_SET_MAX_TX_POWER_5_0:
4360 {
4361 hddLog(VOS_TRACE_LEVEL_INFO,
4362 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4363 __func__, set_value);
4364 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4365 eHAL_STATUS_SUCCESS)
4366 {
4367 hddLog(VOS_TRACE_LEVEL_ERROR,
4368 "%s: Setting maximum tx power failed for 5.0 GHz band",
4369 __func__);
4370 return -EIO;
4371 }
4372
4373 break;
4374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 case WE_SET_HIGHER_DTIM_TRANSITION:
4376 {
4377 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4378 (set_value == eANI_BOOLEAN_TRUE)))
4379 {
4380 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4381 ret = -EINVAL;
4382 }
4383 else
4384 {
4385 if(pAdapter->higherDtimTransition != set_value)
4386 {
4387 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004388 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 }
4390 }
4391
4392 break;
4393 }
4394
4395 case WE_SET_TM_LEVEL:
4396 {
4397 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004398 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4400
4401 break;
4402 }
4403
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304404 case WE_ENABLE_STRICT_FCC_REG:
4405 {
4406 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4407 struct wiphy *wiphy = NULL;
4408 long lrc;
4409 int status;
4410
4411 wiphy = hddCtxt->wiphy;
4412 if(wiphy == NULL)
4413 {
4414 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4415 break;
4416 }
4417 init_completion(&hddCtxt->wiphy_channel_update_event);
4418
4419 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4420
4421 status = regulatory_hint(wiphy, "00");
4422 if(status < 0)
4423 {
4424 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4425 break;
4426 }
4427
4428 /* Wait for completion */
4429 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4430 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4431 if (lrc <= 0)
4432 {
4433 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4434 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4435 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4436 }
4437 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4438
4439 break;
4440 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004441 case WE_SET_DEBUG_LOG:
4442 {
4443 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4444 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4445 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4446 break;
4447 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05304448#ifdef FEATURE_WLAN_TDLS
4449 case WE_SET_TDLS_OFF_CHAN:
4450 {
4451 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
4453 __func__, set_value);
4454 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
4455 break;
4456 }
4457 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
4458 {
4459 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
4461 __func__, set_value);
4462 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
4463 break;
4464 }
4465 case WE_SET_TDLS_OFF_CHAN_MODE:
4466 {
4467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
4468 __func__, set_value);
4469 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
4470 break;
4471 }
4472#endif
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304473
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 default:
4475 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004476 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 sub_cmd, set_value);
4478 break;
4479 }
4480 }
4481
4482 return ret;
4483}
4484
4485/* set param sub-ioctls */
4486static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4487 union iwreq_data *wrqu, char *extra)
4488{
4489 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05304490 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004492 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4494 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4495#ifdef WLAN_FEATURE_VOWIFI
4496 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4497#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05304498 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07004499
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004500 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4501 {
4502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4503 "%s:LOGP in Progress. Ignore!!!", __func__);
4504 return -EBUSY;
4505 }
4506
Girish Gowli552fc072014-06-14 18:26:16 +05304507 /* helper function to get iwreq_data with compat handling. */
4508 if (hdd_priv_get_data(&s_priv_data, wrqu))
4509 {
4510 return -EINVAL;
4511 }
4512
4513 /* make sure all params are correctly passed to function */
4514 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
4515 {
4516 return -EINVAL;
4517 }
4518
4519 sub_cmd = s_priv_data.flags;
4520
Arif Hussain0273cba2014-01-07 20:58:29 -08004521 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05304522 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
4523 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004524 if (NULL == pBuffer)
4525 {
4526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4527 "mem_alloc_copy_from_user_helper fail");
4528 return -ENOMEM;
4529 }
4530
4531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05304532 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4534 "%s: Received data %s", __func__, pBuffer);
4535
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 switch(sub_cmd)
4537 {
4538 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004540 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 break;
4542 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004544 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 break;
4546#if defined WLAN_FEATURE_VOWIFI
4547 case WE_NEIGHBOR_REPORT_REQUEST:
4548 {
4549 tRrmNeighborReq neighborReq;
4550 tRrmNeighborRspCallbackInfo callbackInfo;
4551
4552 if (pConfig->fRrmEnable)
4553 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05304555 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 if( !neighborReq.no_ssid )
4557 {
Girish Gowli552fc072014-06-14 18:26:16 +05304558 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004559 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 }
4561
4562 callbackInfo.neighborRspCallback = NULL;
4563 callbackInfo.neighborRspCallbackContext = NULL;
4564 callbackInfo.timeout = 5000; //5 seconds
4565 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4566 }
4567 else
4568 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004569 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 ret = -EINVAL;
4571 }
4572 }
4573 break;
4574#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 case WE_SET_AP_WPS_IE:
4576 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05304577 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004580 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 if (VOS_STATUS_SUCCESS != vstatus)
4582 {
4583 ret = -EINVAL;
4584 }
4585 break;
4586 default:
4587 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004588 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 ret = -EINVAL;
4590 break;
4591 }
4592 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004593 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 return ret;
4595}
4596
4597/* get param sub-ioctls */
4598static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4599 union iwreq_data *wrqu, char *extra)
4600{
4601 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4602 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4603 int *value = (int *)extra;
4604 int ret = 0; /* success */
4605
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004606 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4607 {
4608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4609 "%s:LOGP in Progress. Ignore!!!", __func__);
4610 return -EBUSY;
4611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004612
4613 switch (value[0])
4614 {
4615 case WE_GET_11D_STATE:
4616 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004617 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304619
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4621
Arif Hussain6d2a3322013-11-17 19:50:10 -08004622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004623
4624 break;
4625 }
4626
4627 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 break;
4630
4631 case WE_PMC_STATE:
4632 {
4633 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 break;
4636 }
4637 case WE_GET_WLAN_DBG:
4638 {
4639 vos_trace_display();
4640 *value = 0;
4641 break;
4642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 case WE_GET_MAX_ASSOC:
4644 {
4645 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4646 {
c_hpothub8245442013-11-20 23:41:09 +05304647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4648 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 ret = -EIO;
4650 }
4651 break;
4652 }
4653
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 case WE_GET_WDI_DBG:
4655 {
4656 wpalTraceDisplay();
4657 *value = 0;
4658 break;
4659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004660
4661 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4662 {
4663 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4664 break;
4665 }
4666 case WE_GET_CONCURRENCY_MODE:
4667 {
4668 *value = hdd_get_concurrency_mode ( );
4669
Arif Hussain6d2a3322013-11-17 19:50:10 -08004670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 break;
4672 }
4673
4674 default:
4675 {
4676 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4677 break;
4678 }
4679 }
4680
4681 return ret;
4682}
4683
4684/* set param sub-ioctls */
4685int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4686 union iwreq_data *wrqu, char *extra)
4687{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004688 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 int *value = (int *)extra;
4690 int sub_cmd = value[0];
4691 int ret = 0;
4692
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004693 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4694 {
4695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4696 "%s:LOGP in Progress. Ignore!!!", __func__);
4697 return -EBUSY;
4698 }
4699
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 switch(sub_cmd)
4701 {
4702 case WE_SET_WLAN_DBG:
4703 {
4704 vos_trace_setValue( value[1], value[2], value[3]);
4705 break;
4706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 case WE_SET_WDI_DBG:
4708 {
4709 wpalTraceSetLevel( value[1], value[2], value[3]);
4710 break;
4711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 case WE_SET_SAP_CHANNELS:
4713 {
4714 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4715 break;
4716 }
4717
4718 default:
4719 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004720 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 break;
4722 }
4723 }
4724 return ret;
4725}
4726
4727static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4728 union iwreq_data *wrqu, char *extra)
4729{
4730 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4731 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004732#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004733 hdd_wext_state_t *pWextState;
4734#endif
4735
4736 if (pAdapter == NULL)
4737 {
4738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4739 "%s: pAdapter is NULL!", __func__);
4740 return -EINVAL;
4741 }
4742#ifdef WLAN_FEATURE_11W
4743 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004744#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004745
Yue Ma3ede6052013-08-29 00:33:26 -07004746 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4747 {
4748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4749 "%s: HDD Context is NULL!", __func__);
4750
4751 return -EINVAL;
4752 }
4753
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004754 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4755 {
4756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4757 "%s:LOGP in Progress. Ignore!!!", __func__);
4758 return -EBUSY;
4759 }
4760
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 switch(sub_cmd)
4762 {
4763 case WE_WLAN_VERSION:
4764 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004765 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 break;
4767 }
4768
4769 case WE_GET_STATS:
4770 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304771 tHalHandle hHal = NULL;
4772 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4774 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4775 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4776
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304777
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 snprintf(extra, WE_MAX_STR_LEN,
4779 "\nTransmit"
4780 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4781 "\n dropped BK %u, BE %u, VI %u, VO %u"
4782 "\n classified BK %u, BE %u, VI %u, VO %u"
4783 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4784 "\n queued BK %u, BE %u, VI %u, VO %u"
4785 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004786 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 "\n fetched BK %u, BE %u, VI %u, VO %u"
4788 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4789 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004790 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 "\n flushed BK %u, BE %u, VI %u, VO %u"
4792 "\n\nReceive"
4793 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4794 "\n\nResetsStats"
4795 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4796 "\n",
4797 pStats->txXmitCalled,
4798 pStats->txXmitDropped,
4799 pStats->txXmitBackPressured,
4800 pStats->txXmitQueued,
4801
4802 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4803 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4804 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4805 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4806
4807 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4808 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4809 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4810 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4811
4812 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4813 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4814 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4815 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4816
4817 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4818 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4819 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4820 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4821
4822 pStats->txFetched,
4823 pStats->txFetchEmpty,
4824 pStats->txFetchLowResources,
4825 pStats->txFetchDequeueError,
4826
4827 pStats->txFetchDequeued,
4828 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004829 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 pStats->txCompleted,
4831 pStats->txFlushed,
4832
4833 pStats->txFetchedAC[WLANTL_AC_BK],
4834 pStats->txFetchedAC[WLANTL_AC_BE],
4835 pStats->txFetchedAC[WLANTL_AC_VI],
4836 pStats->txFetchedAC[WLANTL_AC_VO],
4837
4838 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4839 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4840 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4841 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4842
4843 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4844 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4845 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4846 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4847
Ravi Joshi41914632013-10-21 23:02:21 -07004848 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4849 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4850 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4851 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4852
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 pStats->txFlushedAC[WLANTL_AC_BK],
4854 pStats->txFlushedAC[WLANTL_AC_BE],
4855 pStats->txFlushedAC[WLANTL_AC_VI],
4856 pStats->txFlushedAC[WLANTL_AC_VO],
4857
4858 pStats->rxChains,
4859 pStats->rxPackets,
4860 pStats->rxDropped,
4861 pStats->rxDelivered,
4862 pStats->rxRefused,
4863
4864 pResetStats->totalLogpResets,
4865 pResetStats->totalCMD53Failures,
4866 pResetStats->totalMutexReadFailures,
4867 pResetStats->totalMIFErrorFailures,
4868 pResetStats->totalFWHearbeatFailures,
4869 pResetStats->totalUnknownExceptions
4870 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304871 wrqu->data.length = strlen(extra);
4872
4873 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
4874
4875 if (hHal)
4876 pMac = PMAC_STRUCT( hHal );
4877
4878 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
4879 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
4880 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05304881 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
4882 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
4883 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
4884 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304885 "\n",
4886 pMac->pmm.BmpscntSleep,
4887 pMac->pmm.BmpscntAwake,
4888 pMac->pmm.BmpsSleeReqFailCnt,
4889 pMac->pmm.BmpsWakeupReqFailCnt,
4890 pMac->pmm.ImpsCntSleep,
4891 pMac->pmm.ImpsCntAwake,
4892 pMac->pmm.ImpsSleepErrCnt,
4893 pMac->pmm.ImpsWakeupErrCnt,
4894 pMac->pmm.ImpsLastErr
4895 );
4896 }
4897
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 wrqu->data.length = strlen(extra)+1;
4899 break;
4900 }
4901
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304902/* The case prints the current state of the HDD, SME, CSR, PE, TL
4903 *it can be extended for WDI Global State as well.
4904 *And currently it only checks P2P_CLIENT adapter.
4905 *P2P_DEVICE and P2P_GO have not been added as of now.
4906*/
4907 case WE_GET_STATES:
4908 {
4909 int buf = 0, len = 0;
4910 int adapter_num = 0;
4911 int count = 0, check = 1;
4912
4913 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004914 tHalHandle hHal = NULL;
4915 tpAniSirGlobal pMac = NULL;
4916 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304917
4918 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4919 hdd_adapter_t *useAdapter = NULL;
4920
4921 /* Print wlan0 or p2p0 states based on the adapter_num
4922 *by using the correct adapter
4923 */
4924 while ( adapter_num < 2 )
4925 {
4926 if ( WLAN_ADAPTER == adapter_num )
4927 {
4928 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004929 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304930 "\n\n wlan0 States:-");
4931 len += buf;
4932 }
4933 else if ( P2P_ADAPTER == adapter_num )
4934 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004935 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304936 "\n\n p2p0 States:-");
4937 len += buf;
4938
4939 if( !pHddCtx )
4940 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004941 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304942 "\n pHddCtx is NULL");
4943 len += buf;
4944 break;
4945 }
4946
4947 /*Printing p2p0 states only in the case when the device is
4948 configured as a p2p_client*/
4949 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4950 if ( !useAdapter )
4951 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004952 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304953 "\n Device not configured as P2P_CLIENT.");
4954 len += buf;
4955 break;
4956 }
4957 }
4958
4959 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004960 if (!hHal) {
4961 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4962 "\n pMac is NULL");
4963 len += buf;
4964 break;
4965 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304966 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004967 if (!pMac) {
4968 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4969 "\n pMac is NULL");
4970 len += buf;
4971 break;
4972 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304973 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4974 if( !pHddStaCtx )
4975 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004976 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304977 "\n pHddStaCtx is NULL");
4978 len += buf;
4979 break;
4980 }
4981
4982 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4983
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004984 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304985 "\n HDD Conn State - %s "
4986 "\n \n SME State:"
4987 "\n Neighbour Roam State - %s"
4988 "\n CSR State - %s"
4989 "\n CSR Substate - %s"
4990 "\n \n TL STA %d State: %s",
4991 macTraceGetHDDWlanConnState(
4992 pHddStaCtx->conn_info.connState),
4993 macTraceGetNeighbourRoamState(
4994 pMac->roam.neighborRoamInfo.neighborRoamState),
4995 macTraceGetcsrRoamState(
4996 pMac->roam.curState[useAdapter->sessionId]),
4997 macTraceGetcsrRoamSubState(
4998 pMac->roam.curSubState[useAdapter->sessionId]),
4999 pHddStaCtx->conn_info.staId[0],
5000 macTraceGetTLState(tlState)
5001 );
5002 len += buf;
5003 adapter_num++;
5004 }
5005
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005006 if (pMac) {
5007 /* Printing Lim State starting with global lim states */
5008 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5009 "\n \n LIM STATES:-"
5010 "\n Global Sme State - %s "\
5011 "\n Global mlm State - %s "\
5012 "\n",
5013 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
5014 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
5015 );
5016 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305017
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005018 /*printing the PE Sme and Mlm states for valid lim sessions*/
5019 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305020 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005021 if ( pMac->lim.gpSession[count].valid )
5022 {
5023 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5024 "\n Lim Valid Session %d:-"
5025 "\n PE Sme State - %s "
5026 "\n PE Mlm State - %s "
5027 "\n",
5028 check,
5029 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
5030 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
5031 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305032
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005033 len += buf;
5034 check++;
5035 }
5036 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305037 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305038 }
5039
5040 wrqu->data.length = strlen(extra)+1;
5041 break;
5042 }
5043
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 case WE_GET_CFG:
5045 {
5046 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
5047 wrqu->data.length = strlen(extra)+1;
5048 break;
5049 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005050#ifdef WLAN_FEATURE_11AC
5051 case WE_GET_RSSI:
5052 {
5053 v_S7_t s7Rssi = 0;
5054 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
5055 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
5056 wrqu->data.length = strlen(extra)+1;
5057 break;
5058 }
5059#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305060
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005061#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005062 case WE_GET_ROAM_RSSI:
5063 {
5064 v_S7_t s7Rssi = 0;
5065 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
5066 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
5067 wrqu->data.length = strlen(extra)+1;
5068 break;
5069 }
5070#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 case WE_GET_WMM_STATUS:
5072 {
5073 snprintf(extra, WE_MAX_STR_LEN,
5074 "\nDir: 0=up, 1=down, 3=both\n"
5075 "|------------------------|\n"
5076 "|AC | ACM |Admitted| Dir |\n"
5077 "|------------------------|\n"
5078 "|VO | %d | %3s | %d |\n"
5079 "|VI | %d | %3s | %d |\n"
5080 "|BE | %d | %3s | %d |\n"
5081 "|BK | %d | %3s | %d |\n"
5082 "|------------------------|\n",
5083 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
5084 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
5085 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
5086 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
5087 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
5088 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
5089 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
5090 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
5091 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5092 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5093 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5094 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5095
Jeff Johnsone7245742012-09-05 17:12:55 -07005096
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 wrqu->data.length = strlen(extra)+1;
5098 break;
5099 }
5100 case WE_GET_CHANNEL_LIST:
5101 {
5102 VOS_STATUS status;
5103 v_U8_t i, len;
5104 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305105 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5106 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5107 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 tChannelListInfo channel_list;
5109
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005110 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005111 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005112 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005114 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 return -EINVAL;
5116 }
5117 buf = extra;
5118
5119 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005120 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5121 * needed = 5 * number of channels. Check ifsufficient
5122 * buffer is available and then proceed to fill the buffer.
5123 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5125 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005126 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005127 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005128 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 return -EINVAL;
5130 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005131 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5132 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305133 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5134 {
5135 //Printing Country code in getChannelList
5136 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5137 {
5138 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5139 "%c ", pBuf[i]);
5140 }
5141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 for(i = 0 ; i < channel_list.num_channels; i++)
5143 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005144 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 }
5147 wrqu->data.length = strlen(extra)+1;
5148
5149 break;
5150 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005151#ifdef FEATURE_WLAN_TDLS
5152 case WE_GET_TDLS_PEERS:
5153 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005154 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005155 break;
5156 }
5157#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005158#ifdef WLAN_FEATURE_11W
5159 case WE_GET_11W_INFO:
5160 {
5161 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5162
5163 snprintf(extra, WE_MAX_STR_LEN,
5164 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5165 "\n Number of Unprotected Disassocs %d"
5166 "\n Number of Unprotected Deauths %d",
5167 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5168 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5169 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5170 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5171 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5172
5173 wrqu->data.length = strlen(extra)+1;
5174 break;
5175 }
5176#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305177 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005178 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005179 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 break;
5181 }
5182 }
5183
5184 return 0;
5185}
5186
5187/* action sub-ioctls */
5188static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5189 union iwreq_data *wrqu, char *extra)
5190{
5191 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305192 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005193 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305194 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005195
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005196 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5197 {
5198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5199 "%s:LOGP in Progress. Ignore!!!", __func__);
5200 return -EBUSY;
5201 }
5202
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305203 /* helper function to get iwreq_data with compat handling. */
5204 if (hdd_priv_get_data(&s_priv_data, wrqu))
5205 {
5206 return -EINVAL;
5207 }
5208
5209 sub_cmd = s_priv_data.flags;
5210
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 switch (sub_cmd)
5212 {
5213 case WE_CLEAR_STATS:
5214 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5217 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5218 break;
5219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 case WE_INIT_AP:
5221 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305222 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5223
5224 /* As Soft AP mode might been changed to STA already with
5225 * killing of Hostapd, need to find the adpater by name
5226 * rather than mode */
5227 hdd_adapter_t* pAdapter_to_stop =
5228 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5229 if( pAdapter_to_stop )
5230 {
5231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5232 "Adapter with name softap.0 already "
5233 "exist, ignoring the request.\nRemove the "
5234 "adapter and try again\n");
5235 break;
5236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 pr_info("Init AP trigger\n");
5238 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5239 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5240 break;
5241 }
5242 case WE_STOP_AP:
5243 {
5244 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5245 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5246 * this is a dead code and need to find the adpater by name rather than mode */
5247 hdd_adapter_t* pAdapter_to_stop =
5248 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5249 if( pAdapter_to_stop )
5250 {
5251 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5252
5253 pr_info("Stopping AP mode\n");
5254
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305255 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5256 {
5257 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5258 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5259 }
5260
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305262 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5264 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5265
5266 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5267 pAdapter_to_stop->macAddressCurrent.bytes);
5268 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5269 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305270
5271 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5272 {
5273 /* put the device back into BMPS */
5274 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 }
5277 else
5278 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005279 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 }
5281
5282 break;
5283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005284#ifdef WLAN_BTAMP_FEATURE
5285 case WE_ENABLE_AMP:
5286 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 WLANBAP_RegisterWithHCI(pAdapter);
5289 break;
5290 }
5291 case WE_DISABLE_AMP:
5292 {
5293 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5294 VOS_STATUS status;
5295
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005297
5298 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5299 status = WLANBAP_StopAmp();
5300 if(VOS_STATUS_SUCCESS != status )
5301 {
5302 pHddCtx->isAmpAllowed = VOS_TRUE;
5303 hddLog(VOS_TRACE_LEVEL_FATAL,
5304 "%s: Failed to stop AMP", __func__);
5305 }
5306 else
5307 {
5308 //a state m/c implementation in PAL is TBD to avoid this delay
5309 msleep(500);
5310 pHddCtx->isAmpAllowed = VOS_FALSE;
5311 WLANBAP_DeregisterFromHCI();
5312 }
5313
5314 break;
5315 }
5316#endif
5317
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005318 case WE_ENABLE_DXE_STALL_DETECT:
5319 {
schang6295e542013-03-12 15:31:23 -07005320 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5321 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005322 break;
5323 }
5324 case WE_DISPLAY_DXE_SNAP_SHOT:
5325 {
schang6295e542013-03-12 15:31:23 -07005326 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5327 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005328 break;
5329 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305330 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5331 {
5332 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5333 hdd_wmm_tx_snapshot(pAdapter);
5334 WLANTL_TLDebugMessage(VOS_TRUE);
5335 break;
5336 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305337
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305338 case WE_SET_REASSOC_TRIGGER:
5339 {
5340 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5341 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5342 v_U32_t roamId = 0;
5343 tCsrRoamModifyProfileFields modProfileFields;
5344 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5345 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5346 return 0;
5347 }
5348
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305349 case WE_STOP_OBSS_SCAN:
5350 {
5351 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5352 2.OBSS scan is stopped by Firmware during the disassociation
5353 3.OBSS stop comamnd is added for debugging purpose*/
5354 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5355 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005356
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305357 if (pAdapter == NULL)
5358 {
5359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5360 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305361 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305362 }
5363 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5364 if (pMac == NULL)
5365 {
5366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5367 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305368 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305369 }
5370 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5371 }
5372 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05305373#ifdef DEBUG_ROAM_DELAY
5374 case WE_DUMP_ROAM_TIMER_LOG:
5375 {
5376 vos_dump_roam_time_log_service();
5377 break;
5378 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305379
Mukul Sharma84f27252014-07-14 18:11:42 +05305380 case WE_RESET_ROAM_TIMER_LOG:
5381 {
5382 vos_reset_roam_timer_log();
5383 break;
5384 }
5385#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 default:
5387 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005388 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 break;
5390 }
5391 }
5392
5393 return ret;
5394}
5395
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305396void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5397{
5398 /*
5399 * Function to display HDD WMM information
5400 * for Tx Queues.
5401 * Prints globala as well as per client depending
5402 * whether the clients are registered or not.
5403 */
5404 int i = 0, j = 0;
5405 for ( i=0; i< NUM_TX_QUEUES; i++)
5406 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305407 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005408 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305409 i, pAdapter->wmm_tx_queue[i].count,
5410 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305411 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305412 }
5413
5414 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5415 {
5416 if(pAdapter->aStaInfo[i].isUsed)
5417 {
5418 hddLog(LOGE, "******STAIndex: %d*********", i);
5419 for ( j=0; j< NUM_TX_QUEUES; j++)
5420 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305421 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005422 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305423 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5424 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5425 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305426 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305427 }
5428 }
5429 }
5430
5431}
Jeff Johnson295189b2012-06-20 16:38:30 -07005432int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5433 union iwreq_data *wrqu, char *extra)
5434{
5435 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5436 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05305437 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 int apps_args[MAX_VAR_ARGS] = {0};
Girish Gowlid4522fd2014-06-14 17:20:27 +05305439 int num_args;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005440 hdd_station_ctx_t *pStaCtx = NULL ;
5441 hdd_ap_ctx_t *pAPCtx = NULL;
5442 int cmd = 0;
5443 int staId = 0;
Girish Gowlid4522fd2014-06-14 17:20:27 +05305444 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005445
Girish Gowlid4522fd2014-06-14 17:20:27 +05305446 /* helper function to get iwreq_data with compat handling. */
5447 if (hdd_priv_get_data(&s_priv_data, wrqu))
5448 {
5449 return -EINVAL;
5450 }
5451
5452 if (NULL == s_priv_data.pointer)
5453 {
5454 return -EINVAL;
5455 }
5456
5457 sub_cmd = s_priv_data.flags;
5458 num_args = s_priv_data.length;
5459
5460 hddLog(LOG1, "%s: Received length %d", __func__, s_priv_data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005461
5462 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5463 {
5464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5465 "%s:LOGP in Progress. Ignore!!!", __func__);
5466 return -EBUSY;
5467 }
5468
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 if (num_args > MAX_VAR_ARGS)
5470 {
5471 num_args = MAX_VAR_ARGS;
5472 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005473
5474 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlid4522fd2014-06-14 17:20:27 +05305475 if (copy_from_user(apps_args, s_priv_data.pointer, (sizeof(int)) * num_args))
Arif Hussain0273cba2014-01-07 20:58:29 -08005476 {
5477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5478 "%s: failed to copy data to user buffer", __func__);
5479 return -EFAULT;
5480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005481
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005482 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5483 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5484 {
5485 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5486 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5487 {
5488 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5489 staId = pStaCtx->conn_info.staId[0];
5490 }
5491 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5492 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5493 {
5494 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5495 staId = pAPCtx->uBCStaId;
5496 }
5497 else
5498 {
5499 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5500 return 0;
5501 }
5502 }
5503
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 switch (sub_cmd)
5505 {
5506 case WE_LOG_DUMP_CMD:
5507 {
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305508 vos_ssr_protect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005510 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 apps_args[3], apps_args[4]);
5512
5513 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5514 apps_args[3], apps_args[4]);
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305515 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005516
5517 }
5518 break;
5519
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 case WE_P2P_NOA_CMD:
5521 {
5522 p2p_app_setP2pPs_t p2pNoA;
5523
5524 p2pNoA.opp_ps = apps_args[0];
5525 p2pNoA.ctWindow = apps_args[1];
5526 p2pNoA.duration = apps_args[2];
5527 p2pNoA.interval = apps_args[3];
5528 p2pNoA.count = apps_args[4];
5529 p2pNoA.single_noa_duration = apps_args[5];
5530 p2pNoA.psSelection = apps_args[6];
5531
5532 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5533 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005534 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5536
5537 hdd_setP2pPs(dev, &p2pNoA);
5538
5539 }
5540 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005541
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305542 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5543 {
5544 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5545 __func__, apps_args[0], apps_args[1]);
5546 vosTraceEnable(apps_args[0], apps_args[1]);
5547 }
5548 break;
5549
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005550 case WE_MTRACE_DUMP_CMD:
5551 {
5552 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5553 "bitmask_of_module %d ",
5554 __func__, apps_args[0], apps_args[1], apps_args[2],
5555 apps_args[3]);
5556 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5557 apps_args[2], apps_args[3]);
5558
5559 }
5560 break;
5561
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005562 case WE_MCC_CONFIG_CREDENTIAL :
5563 {
5564 cmd = 287; //Command should be updated if there is any change
5565 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005566 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005567 {
5568 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5569 }
5570 else
5571 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005572 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005573 return 0;
5574 }
5575 }
5576 break;
5577
5578 case WE_MCC_CONFIG_PARAMS :
5579 {
5580 cmd = 288; //command Should be updated if there is any change
5581 // in the Riva dump command
5582 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5583 }
5584 break;
5585
Chilam NG571c65a2013-01-19 12:27:36 +05305586#ifdef FEATURE_WLAN_TDLS
5587 case WE_TDLS_CONFIG_PARAMS :
5588 {
5589 tdls_config_params_t tdlsParams;
5590
Chilam Ng01120412013-02-19 18:32:21 -08005591 tdlsParams.tdls = apps_args[0];
5592 tdlsParams.tx_period_t = apps_args[1];
5593 tdlsParams.tx_packet_n = apps_args[2];
5594 tdlsParams.discovery_period_t = apps_args[3];
5595 tdlsParams.discovery_tries_n = apps_args[4];
5596 tdlsParams.idle_timeout_t = apps_args[5];
5597 tdlsParams.idle_packet_n = apps_args[6];
5598 tdlsParams.rssi_hysteresis = apps_args[7];
5599 tdlsParams.rssi_trigger_threshold = apps_args[8];
5600 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305601
Chilam Ng01120412013-02-19 18:32:21 -08005602 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305603 }
5604 break;
5605#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 default:
5607 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005608 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5609 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 }
5611 break;
5612 }
5613
5614 return 0;
5615}
5616
5617
5618static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5619 union iwreq_data *wrqu, char *extra)
5620{
5621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5622 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5623 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5624 int params[HDD_WLAN_WMM_PARAM_COUNT];
5625 sme_QosWmmTspecInfo tSpec;
5626 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05305627 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005628
5629 // make sure the application is sufficiently priviledged
5630 // note that the kernel will do this for "set" ioctls, but since
5631 // this ioctl wants to return status to user space it must be
5632 // defined as a "get" ioctl
5633 if (!capable(CAP_NET_ADMIN))
5634 {
5635 return -EPERM;
5636 }
5637
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005638 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5639 {
5640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5641 "%s:LOGP in Progress. Ignore!!!", __func__);
5642 return -EBUSY;
5643 }
5644
Jeff Johnson295189b2012-06-20 16:38:30 -07005645 // we must be associated in order to add a tspec
5646 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5647 {
5648 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5649 return 0;
5650 }
5651
5652 // since we are defined to be a "get" ioctl, and since the number
5653 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05305654 // will pass down in the iwreq_data, we must copy the "set" params.
5655 // We must handle the compat for iwreq_data in 32U/64K environment.
5656
5657 // helper fucntion to get iwreq_data with compat handling.
5658 if (hdd_priv_get_data(&s_priv_data, wrqu))
5659 {
5660 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5661 return 0;
5662 }
5663
5664 // make sure all params are correctly passed to function
5665 if ((NULL == s_priv_data.pointer) ||
5666 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
5667 {
5668 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5669 return 0;
5670 }
5671
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05305673 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 {
5675 // hmmm, can't get them
5676 return -EIO;
5677 }
5678
5679 // clear the tspec
5680 memset(&tSpec, 0, sizeof(tSpec));
5681
5682 // validate the handle
5683 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5684 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5685 {
5686 // that one is reserved
5687 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5688 return 0;
5689 }
5690
5691 // validate the TID
5692 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5693 {
5694 // out of range
5695 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5696 return 0;
5697 }
5698 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5699
5700 // validate the direction
5701 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5702 {
5703 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5704 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5705 break;
5706
5707 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5708 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5709 break;
5710
5711 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5712 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5713 break;
5714
5715 default:
5716 // unknown
5717 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5718 return 0;
5719 }
5720
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305721 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5722
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 // validate the user priority
5724 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5725 {
5726 // out of range
5727 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5728 return 0;
5729 }
5730 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305731 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5732 {
5733 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5734 return 0;
5735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005736
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5738 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5739 tSpec.ts_info.psb, tSpec.ts_info.up);
5740
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5742 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5743 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5744 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5745 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5746 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5747 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5748 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5749 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5750 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5751 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5752 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5753
5754 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5755
5756 // validate the ts info ack policy
5757 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5758 {
5759 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5760 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5761 break;
5762
5763 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5764 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5765 break;
5766
5767 default:
5768 // unknown
5769 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5770 return 0;
5771 }
5772
5773 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5774 return 0;
5775}
5776
5777
5778static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5779 union iwreq_data *wrqu, char *extra)
5780{
5781 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5782 int *params = (int *)extra;
5783 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5784 v_U32_t handle;
5785
5786 // make sure the application is sufficiently priviledged
5787 // note that the kernel will do this for "set" ioctls, but since
5788 // this ioctl wants to return status to user space it must be
5789 // defined as a "get" ioctl
5790 if (!capable(CAP_NET_ADMIN))
5791 {
5792 return -EPERM;
5793 }
5794
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005795 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5796 {
5797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5798 "%s:LOGP in Progress. Ignore!!!", __func__);
5799 return -EBUSY;
5800 }
5801
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 // although we are defined to be a "get" ioctl, the params we require
5803 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5804 // is no need to copy the params from user space
5805
5806 // validate the handle
5807 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5808 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5809 {
5810 // that one is reserved
5811 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5812 return 0;
5813 }
5814
5815 *pStatus = hdd_wmm_delts(pAdapter, handle);
5816 return 0;
5817}
5818
5819
5820static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5821 union iwreq_data *wrqu, char *extra)
5822{
5823 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5824 int *params = (int *)extra;
5825 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5826 v_U32_t handle;
5827
5828 // although we are defined to be a "get" ioctl, the params we require
5829 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5830 // is no need to copy the params from user space
5831
5832 // validate the handle
5833 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5834 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5835 {
5836 // that one is reserved
5837 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5838 return 0;
5839 }
5840
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005841 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5842 {
5843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5844 "%s:LOGP in Progress. Ignore!!!", __func__);
5845 return -EBUSY;
5846 }
5847
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5849 return 0;
5850}
5851
Jeff Johnson295189b2012-06-20 16:38:30 -07005852#ifdef WLAN_FEATURE_VOWIFI_11R
5853//
5854//
5855// Each time the supplicant has the auth_request or reassoc request
5856// IEs ready. This is pushed to the driver. The driver will inturn use
5857// it to send out the auth req and reassoc req for 11r FT Assoc.
5858//
5859static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5860 union iwreq_data *wrqu, char *extra)
5861{
5862 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5863 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5864 //v_CONTEXT_t pVosContext;
5865
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005866 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5867 {
5868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5869 "%s:LOGP in Progress. Ignore!!!", __func__);
5870 return -EBUSY;
5871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 if (!wrqu->data.length)
5873 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005874 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 return -EINVAL;
5876 }
5877 if (wrqu->data.pointer == NULL)
5878 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005879 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 return -EINVAL;
5881 }
5882
5883 // Added for debug on reception of Re-assoc Req.
5884 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5885 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005886 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005888 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 }
5890
5891#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005892 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005893#endif
5894
5895 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005896 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 wrqu->data.length);
5898
5899 return 0;
5900}
5901#endif
5902
Amar Singhalf3a6e762013-02-19 15:06:50 -08005903static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005904 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005906{
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005908 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005910 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005911 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005912 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5913 int idx;
5914 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005915
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005916 if (pHddCtx->isLogpInProgress)
5917 {
5918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5919 "%s:LOGP in Progress. Ignore!!!", __func__);
5920 return -EBUSY;
5921 }
5922
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305923 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5924 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305925#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005926
Amar Singhalf3a6e762013-02-19 15:06:50 -08005927 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5928 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005929 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005930 hddLog(VOS_TRACE_LEVEL_ERROR,
5931 "%s: vos_mem_alloc failed", __func__);
5932 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005933 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005934
5935 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5936
5937 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5938 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5939
5940 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5941 mc_addr_list_ptr->ulMulticastAddrCnt);
5942
5943 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005944 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005945 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5946 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5947
5948 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5949 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005950 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005951
Amar Singhalf3a6e762013-02-19 15:06:50 -08005952 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5953 vos_mem_free(mc_addr_list_ptr);
5954 if (eHAL_STATUS_SUCCESS != ret_val)
5955 {
5956 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5957 __func__);
5958 return -EINVAL;
5959 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305960#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305961 }
5962 else
5963 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005964
Amar Singhalf3a6e762013-02-19 15:06:50 -08005965 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5966 "%s: Set MC BC Filter Config request: %d suspend %d",
5967 __func__, pRequest->mcastBcastFilterSetting,
5968 pHddCtx->hdd_wlan_suspended);
5969
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305970 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005971
5972 if (pHddCtx->hdd_wlan_suspended)
5973 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005974 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5975 if (NULL == wlanRxpFilterParam)
5976 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305977 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005978 "%s: vos_mem_alloc failed", __func__);
5979 return -EINVAL;
5980 }
5981
Amar Singhalf3a6e762013-02-19 15:06:50 -08005982 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5983 pRequest->mcastBcastFilterSetting;
5984 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5985
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305986 hdd_conf_hostoffload(pAdapter, TRUE);
5987 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5988 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005989
5990 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5991 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305992 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08005993 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5994 wlanRxpFilterParam->setMcstBcstFilter);
5995
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305996 if (eHAL_STATUS_SUCCESS !=
5997 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5998 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08005999 {
6000 hddLog(VOS_TRACE_LEVEL_ERROR,
6001 "%s: Failure to execute set HW MC/BC Filter request",
6002 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006003 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006004 return -EINVAL;
6005 }
6006
Amar Singhalf3a6e762013-02-19 15:06:50 -08006007 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006009
6010 return 0;
6011}
6012
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006013static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006014 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 union iwreq_data *wrqu, char *extra)
6016{
6017 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6018 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306019 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006020 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006021
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306022 //Reset the filter to INI value as we have to clear the dynamic filter
6023 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006024
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306025 //Configure FW with new setting
6026 if (pHddCtx->hdd_wlan_suspended)
6027 {
6028 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6029 if (NULL == wlanRxpFilterParam)
6030 {
6031 hddLog(VOS_TRACE_LEVEL_ERROR,
6032 "%s: vos_mem_alloc failed", __func__);
6033 return -EINVAL;
6034 }
6035
6036 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6037 pHddCtx->configuredMcastBcastFilter;
6038 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6039
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306040 hdd_conf_hostoffload(pAdapter, TRUE);
6041 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6042 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306043
6044 if (eHAL_STATUS_SUCCESS !=
6045 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6046 wlanRxpFilterParam))
6047 {
6048 hddLog(VOS_TRACE_LEVEL_ERROR,
6049 "%s: Failure to execute set HW MC/BC Filter request",
6050 __func__);
6051 vos_mem_free(wlanRxpFilterParam);
6052 return -EINVAL;
6053 }
6054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 return 0;
6056}
6057
6058static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6059 union iwreq_data *wrqu, char *extra)
6060{
6061 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006062 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 tSirHostOffloadReq offloadRequest;
6064
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006065 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6066 {
6067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6068 "%s:LOGP in Progress. Ignore!!!", __func__);
6069 return -EBUSY;
6070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 /* Debug display of request components. */
6072 switch (pRequest->offloadType)
6073 {
6074 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006075 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 switch (pRequest->enableOrDisable)
6077 {
6078 case WLAN_OFFLOAD_DISABLE:
6079 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6080 break;
6081 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6082 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6083 case WLAN_OFFLOAD_ENABLE:
6084 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6085 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6086 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6087 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6088 }
6089 break;
6090
6091 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006092 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006093 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 switch (pRequest->enableOrDisable)
6095 {
6096 case WLAN_OFFLOAD_DISABLE:
6097 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6098 break;
6099 case WLAN_OFFLOAD_ENABLE:
6100 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6101 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6102 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6103 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6104 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6105 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6106 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6107 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6108 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6109 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6110 }
6111 }
6112
6113 /* Execute offload request. The reason that we can copy the request information
6114 from the ioctl structure to the SME structure is that they are laid out
6115 exactly the same. Otherwise, each piece of information would have to be
6116 copied individually. */
6117 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006118 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6119 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006121 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 __func__);
6123 return -EINVAL;
6124 }
6125
6126 return 0;
6127}
6128
6129static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6130 union iwreq_data *wrqu, char *extra)
6131{
6132 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006133 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 tSirKeepAliveReq keepaliveRequest;
6135
6136 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6137 {
6138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006139 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 return 0;
6141 }
6142
6143 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006144 hddLog(VOS_TRACE_LEVEL_INFO,
6145 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6146 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006147
6148 switch (pRequest->packetType)
6149 {
6150 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006151 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 break;
6153
6154 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6155
Arif Hussain6d2a3322013-11-17 19:50:10 -08006156 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006157 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006158
6159 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6160 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6161 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6162
6163 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6164 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6165 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6166
6167 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6168 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6169 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6170 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6171 break;
6172
6173 }
6174
6175 /* Execute keep alive request. The reason that we can copy the request information
6176 from the ioctl structure to the SME structure is that they are laid out
6177 exactly the same. Otherwise, each piece of information would have to be
6178 copied individually. */
6179 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6180
Arif Hussain6d2a3322013-11-17 19:50:10 -08006181 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006182
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006183 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006184 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006186 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 __func__);
6188 return -EINVAL;
6189 }
6190
6191 return 0;
6192}
6193
6194#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006195int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006196 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006197{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006198 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6199 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 int i=0;
6201
6202 if (pHddCtx->cfg_ini->disablePacketFilter)
6203 {
6204 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006205 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 return 0;
6207 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006208 if (pHddCtx->isLogpInProgress)
6209 {
6210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6211 "%s:LOGP in Progress. Ignore!!!", __func__);
6212 return -EBUSY;
6213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 /* Debug display of request components. */
6215 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006216 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006217
6218 switch (pRequest->filterAction)
6219 {
6220 case HDD_RCV_FILTER_SET:
6221 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006222 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006223
6224 packetFilterSetReq.filterId = pRequest->filterId;
6225 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6226 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 __func__, pRequest->numParams);
6229 return -EINVAL;
6230 }
6231 packetFilterSetReq.numFieldParams = pRequest->numParams;
6232 packetFilterSetReq.coalesceTime = 0;
6233 packetFilterSetReq.filterType = 1;
6234 for (i=0; i < pRequest->numParams; i++)
6235 {
6236 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6237 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6238 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6239 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6240 packetFilterSetReq.paramsData[i].reserved = 0;
6241
Arif Hussain6d2a3322013-11-17 19:50:10 -08006242 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6244 packetFilterSetReq.filterType);
6245
Arif Hussain6d2a3322013-11-17 19:50:10 -08006246 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6248
6249 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6250 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6251 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6252 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6253
Arif Hussain6d2a3322013-11-17 19:50:10 -08006254 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6256 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6257 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6258
Arif Hussain6d2a3322013-11-17 19:50:10 -08006259 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6261 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6262 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6263 }
6264
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006265 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006267 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 __func__);
6269 return -EINVAL;
6270 }
6271
6272 break;
6273
6274 case HDD_RCV_FILTER_CLEAR:
6275
Arif Hussain6d2a3322013-11-17 19:50:10 -08006276 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006277 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006279 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006281 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 __func__);
6283 return -EINVAL;
6284 }
6285 break;
6286
6287 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006288 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006289 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 return -EINVAL;
6291 }
6292 return 0;
6293}
6294
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306295int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6296 tANI_U8 sessionId)
6297{
6298 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6299 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6300
6301 if (NULL == pHddCtx)
6302 {
6303 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6304 return -EINVAL;
6305 }
6306
6307 if (pHddCtx->isLogpInProgress)
6308 {
6309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6310 "%s:LOGP in Progress. Ignore!!!", __func__);
6311 return -EBUSY;
6312 }
6313
6314 if (pHddCtx->cfg_ini->disablePacketFilter)
6315 {
6316 hddLog(VOS_TRACE_LEVEL_ERROR,
6317 "%s: Packet Filtering Disabled. Returning ",
6318 __func__ );
6319 return -EINVAL;
6320 }
6321
6322 switch (filterType)
6323 {
6324 /* For setting IPV6 MC and UC Filter we need to configure
6325 * 2 filters, one for MC and one for UC.
6326 * The Filter ID shouldn't be swapped, which results in making
6327 * UC Filter ineffective.
6328 * We have Hardcode all the values
6329 *
6330 * Reason for a seperate UC filter is because, driver need to
6331 * specify the FW that the specific filter is for unicast
6332 * otherwise FW will not pass the unicast frames by default
6333 * through the filter. This is required to avoid any performance
6334 * hits when no unicast filter is set and only MC/BC are set.
6335 * The way driver informs host is by using the MAC protocol
6336 * layer, CMP flag set to MAX, CMP Data set to 1.
6337 */
6338
6339 case HDD_FILTER_IPV6_MC_UC:
6340 /* Setting IPV6 MC Filter below
6341 */
6342 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6343 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6344 packetFilterSetReq.numFieldParams = 2;
6345 packetFilterSetReq.paramsData[0].protocolLayer =
6346 HDD_FILTER_PROTO_TYPE_MAC;
6347 packetFilterSetReq.paramsData[0].cmpFlag =
6348 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6349 packetFilterSetReq.paramsData[0].dataOffset =
6350 WLAN_HDD_80211_FRM_DA_OFFSET;
6351 packetFilterSetReq.paramsData[0].dataLength = 1;
6352 packetFilterSetReq.paramsData[0].compareData[0] =
6353 HDD_IPV6_MC_CMP_DATA;
6354
6355 packetFilterSetReq.paramsData[1].protocolLayer =
6356 HDD_FILTER_PROTO_TYPE_ARP;
6357 packetFilterSetReq.paramsData[1].cmpFlag =
6358 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6359 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6360 packetFilterSetReq.paramsData[1].dataLength = 2;
6361 packetFilterSetReq.paramsData[1].compareData[0] =
6362 HDD_IPV6_CMP_DATA_0;
6363 packetFilterSetReq.paramsData[1].compareData[1] =
6364 HDD_IPV6_CMP_DATA_1;
6365
6366
6367 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6368 &packetFilterSetReq, sessionId))
6369 {
6370 hddLog(VOS_TRACE_LEVEL_ERROR,
6371 "%s: Failure to execute Set IPv6 Mulicast Filter",
6372 __func__);
6373 return -EINVAL;
6374 }
6375
6376 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6377
6378 /*
6379 * Setting IPV6 UC Filter below
6380 */
6381 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6382 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6383 packetFilterSetReq.numFieldParams = 2;
6384 packetFilterSetReq.paramsData[0].protocolLayer =
6385 HDD_FILTER_PROTO_TYPE_MAC;
6386 packetFilterSetReq.paramsData[0].cmpFlag =
6387 HDD_FILTER_CMP_TYPE_MAX;
6388 packetFilterSetReq.paramsData[0].dataOffset = 0;
6389 packetFilterSetReq.paramsData[0].dataLength = 1;
6390 packetFilterSetReq.paramsData[0].compareData[0] =
6391 HDD_IPV6_UC_CMP_DATA;
6392
6393 packetFilterSetReq.paramsData[1].protocolLayer =
6394 HDD_FILTER_PROTO_TYPE_ARP;
6395 packetFilterSetReq.paramsData[1].cmpFlag =
6396 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6397 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6398 packetFilterSetReq.paramsData[1].dataLength = 2;
6399 packetFilterSetReq.paramsData[1].compareData[0] =
6400 HDD_IPV6_CMP_DATA_0;
6401 packetFilterSetReq.paramsData[1].compareData[1] =
6402 HDD_IPV6_CMP_DATA_1;
6403
6404 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6405 &packetFilterSetReq, sessionId))
6406 {
6407 hddLog(VOS_TRACE_LEVEL_ERROR,
6408 "%s: Failure to execute Set IPv6 Unicast Filter",
6409 __func__);
6410 return -EINVAL;
6411 }
6412
6413 break;
6414
6415 case HDD_FILTER_IPV6_MC:
6416 /*
6417 * IPV6 UC Filter might be already set,
6418 * clear the UC Filter. As the Filter
6419 * IDs are static, we can directly clear it.
6420 */
6421 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6422 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6423 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6424 &packetFilterClrReq, sessionId))
6425 {
6426 hddLog(VOS_TRACE_LEVEL_ERROR,
6427 "%s: Failure to execute Clear IPv6 Unicast Filter",
6428 __func__);
6429 return -EINVAL;
6430 }
6431
6432 /*
6433 * Setting IPV6 MC Filter below
6434 */
6435 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6436 packetFilterSetReq.numFieldParams = 2;
6437 packetFilterSetReq.paramsData[0].protocolLayer =
6438 HDD_FILTER_PROTO_TYPE_MAC;
6439 packetFilterSetReq.paramsData[0].cmpFlag =
6440 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6441 packetFilterSetReq.paramsData[0].dataOffset =
6442 WLAN_HDD_80211_FRM_DA_OFFSET;
6443 packetFilterSetReq.paramsData[0].dataLength = 1;
6444 packetFilterSetReq.paramsData[0].compareData[0] =
6445 HDD_IPV6_MC_CMP_DATA;
6446
6447 packetFilterSetReq.paramsData[1].protocolLayer =
6448 HDD_FILTER_PROTO_TYPE_ARP;
6449 packetFilterSetReq.paramsData[1].cmpFlag =
6450 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6451 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6452 packetFilterSetReq.paramsData[1].dataLength = 2;
6453 packetFilterSetReq.paramsData[1].compareData[0] =
6454 HDD_IPV6_CMP_DATA_0;
6455 packetFilterSetReq.paramsData[1].compareData[1] =
6456 HDD_IPV6_CMP_DATA_1;
6457
6458
6459 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6460 &packetFilterSetReq, sessionId))
6461 {
6462 hddLog(VOS_TRACE_LEVEL_ERROR,
6463 "%s: Failure to execute Set IPv6 Multicast Filter",
6464 __func__);
6465 return -EINVAL;
6466 }
6467 break;
6468
6469 default :
6470 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6471 "%s: Packet Filter Request: Invalid",
6472 __func__);
6473 return -EINVAL;
6474 }
6475 return 0;
6476}
6477
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306478void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006479{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306480 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306481 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006482 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306483 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006484
Yue Ma3ede6052013-08-29 00:33:26 -07006485 if (NULL == pHddCtx)
6486 {
6487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6488 return;
6489 }
6490
6491 hHal = pHddCtx->hHal;
6492
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306493 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306495 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6496 return;
6497 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306498
6499 /* Check if INI is enabled or not, other wise just return
6500 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306501 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306502 {
6503 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6504 if (NULL == pMulticastAddrs)
6505 {
6506 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6507 return;
6508 }
6509
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 if (set)
6511 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306512 /* Following pre-conditions should be satisfied before wei
6513 * configure the MC address list.
6514 */
6515 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6516 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6517 && pAdapter->mc_addr_list.mc_cnt
6518 && (eConnectionState_Associated ==
6519 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6520 {
6521 pMulticastAddrs->ulMulticastAddrCnt =
6522 pAdapter->mc_addr_list.mc_cnt;
6523 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6524 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006525 memcpy(pMulticastAddrs->multicastAddr[i],
6526 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306527 sizeof(pAdapter->mc_addr_list.addr[i]));
6528 hddLog(VOS_TRACE_LEVEL_INFO,
6529 "%s: %s multicast filter: addr ="
6530 MAC_ADDRESS_STR,
6531 __func__, set ? "setting" : "clearing",
6532 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6533 }
6534 /* Set multicast filter */
6535 sme_8023MulticastList(hHal, pAdapter->sessionId,
6536 pMulticastAddrs);
6537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306539 else
6540 {
6541 /* Need to clear only if it was previously configured
6542 */
6543 if (pAdapter->mc_addr_list.isFilterApplied)
6544 {
6545 pMulticastAddrs->ulMulticastAddrCnt = 0;
6546 sme_8023MulticastList(hHal, pAdapter->sessionId,
6547 pMulticastAddrs);
6548 }
6549
6550 }
6551 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006552 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006553 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306554 else
6555 {
6556 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306557 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306558 }
6559 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006560}
6561
6562static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6563 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306564{
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006566 tpPacketFilterCfg pRequest = NULL;
6567 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306568 struct iw_point s_priv_data;
6569
6570 if (hdd_priv_get_data(&s_priv_data, wrqu))
6571 {
6572 return -EINVAL;
6573 }
6574
6575 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6576 {
6577 return -EINVAL;
6578 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006579
Arif Hussain0273cba2014-01-07 20:58:29 -08006580 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306581 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6582 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006583 if (NULL == pRequest)
6584 {
6585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6586 "mem_alloc_copy_from_user_helper fail");
6587 return -ENOMEM;
6588 }
6589
6590 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6591 kfree(pRequest);
6592
6593 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006594}
6595#endif
6596static int iw_get_statistics(struct net_device *dev,
6597 struct iw_request_info *info,
6598 union iwreq_data *wrqu, char *extra)
6599{
6600
6601 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6602 eHalStatus status = eHAL_STATUS_SUCCESS;
6603 hdd_wext_state_t *pWextState;
6604 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6605 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6606 char *p = extra;
6607 int tlen = 0;
6608 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6609
6610 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6611 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6612
6613 ENTER();
6614
6615 if (pHddCtx->isLogpInProgress) {
6616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6617 return -EINVAL;
6618 }
6619
6620 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6621
6622 wrqu->txpower.value = 0;
6623 }
6624 else {
6625 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6626 SME_SUMMARY_STATS |
6627 SME_GLOBAL_CLASSA_STATS |
6628 SME_GLOBAL_CLASSB_STATS |
6629 SME_GLOBAL_CLASSC_STATS |
6630 SME_GLOBAL_CLASSD_STATS |
6631 SME_PER_STA_STATS,
6632 hdd_StatisticsCB, 0, FALSE,
6633 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6634
6635 if (eHAL_STATUS_SUCCESS != status)
6636 {
6637 hddLog(VOS_TRACE_LEVEL_ERROR,
6638 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006639 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 return -EINVAL;
6641 }
6642
6643 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6644
6645 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6646 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6647 {
6648 hddLog(VOS_TRACE_LEVEL_ERROR,
6649 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006650 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 /*Remove the SME statistics list by passing NULL in callback argument*/
6652 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6653 SME_SUMMARY_STATS |
6654 SME_GLOBAL_CLASSA_STATS |
6655 SME_GLOBAL_CLASSB_STATS |
6656 SME_GLOBAL_CLASSC_STATS |
6657 SME_GLOBAL_CLASSD_STATS |
6658 SME_PER_STA_STATS,
6659 NULL, 0, FALSE,
6660 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6661
6662 return -EINVAL;
6663 }
6664 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6665 (tANI_U8) sizeof (pStats->retry_cnt),
6666 (char*) &(pStats->retry_cnt[0]),
6667 tlen);
6668
6669 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6670 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6671 (char*) &(pStats->multiple_retry_cnt[0]),
6672 tlen);
6673
6674 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6675 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6676 (char*) &(pStats->tx_frm_cnt[0]),
6677 tlen);
6678
6679 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6680 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6681 (char*) &(pStats->rx_frm_cnt),
6682 tlen);
6683
6684 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6685 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6686 (char*) &(pStats->frm_dup_cnt),
6687 tlen);
6688
6689 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6690 (tANI_U8) sizeof (pStats->fail_cnt),
6691 (char*) &(pStats->fail_cnt[0]),
6692 tlen);
6693
6694 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6695 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6696 (char*) &(pStats->rts_fail_cnt),
6697 tlen);
6698
6699 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6700 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6701 (char*) &(pStats->ack_fail_cnt),
6702 tlen);
6703
6704 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6705 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6706 (char*) &(pStats->rts_succ_cnt),
6707 tlen);
6708
6709 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6710 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6711 (char*) &(pStats->rx_discard_cnt),
6712 tlen);
6713
6714 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6715 (tANI_U8) sizeof (pStats->rx_error_cnt),
6716 (char*) &(pStats->rx_error_cnt),
6717 tlen);
6718
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006719 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006720 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006721 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 tlen);
6723
6724 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6725 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6726 (char*) &(dStats->rx_byte_cnt),
6727 tlen);
6728
6729 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6730 (tANI_U8) sizeof (dStats->rx_rate),
6731 (char*) &(dStats->rx_rate),
6732 tlen);
6733
6734 /* Transmit rate, in units of 500 kbit/sec */
6735 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6736 (tANI_U8) sizeof (aStats->tx_rate),
6737 (char*) &(aStats->tx_rate),
6738 tlen);
6739
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006740 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6741 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6742 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006743 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006744 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6745 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6746 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006747 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006748 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6749 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6750 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006751 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006752 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6753 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6754 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006755 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006756 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6757 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6758 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006759 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006760 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6761 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6762 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006763 tlen);
6764
Jeff Johnson295189b2012-06-20 16:38:30 -07006765 wrqu->data.length = tlen;
6766
6767 }
6768
6769 EXIT();
6770
6771 return 0;
6772}
6773
6774
6775#ifdef FEATURE_WLAN_SCAN_PNO
6776
6777/*Max Len for PNO notification*/
6778#define MAX_PNO_NOTIFY_LEN 100
6779void found_pref_network_cb (void *callbackContext,
6780 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6781{
6782 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6783 union iwreq_data wrqu;
6784 char buf[MAX_PNO_NOTIFY_LEN+1];
6785
6786 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6787 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6788
6789 // create the event
6790 memset(&wrqu, 0, sizeof(wrqu));
6791 memset(buf, 0, sizeof(buf));
6792
6793 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6794 pPrefNetworkFoundInd->ssId.ssId,
6795 (unsigned int)pPrefNetworkFoundInd->rssi);
6796
6797 wrqu.data.pointer = buf;
6798 wrqu.data.length = strlen(buf);
6799
6800 // send the event
6801
6802 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6803
6804}
6805
6806
6807/*string based input*/
6808VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6809 union iwreq_data *wrqu, char *extra, int nOffset)
6810{
6811 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05306812 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006813 /* pnoRequest is a large struct, so we make it static to avoid stack
6814 overflow. This API is only invoked via ioctl, so it is
6815 serialized by the kernel rtnl_lock and hence does not need to be
6816 reentrant */
6817 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006818 char *ptr;
6819 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05306820 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6822
6823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6824 "PNO data len %d data %s",
6825 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006826 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006827
6828 if (wrqu->data.length <= nOffset )
6829 {
6830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6831 return VOS_STATUS_E_FAILURE;
6832 }
6833
6834 pnoRequest.enable = 0;
6835 pnoRequest.ucNetworksCount = 0;
6836 /*-----------------------------------------------------------------------
6837 Input is string based and expected to be like this:
6838
6839 <enabled> <netw_count>
6840 for each network:
6841 <ssid_len> <ssid> <authentication> <encryption>
6842 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6843 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6844
6845 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006846 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 -07006847
6848 this translates into:
6849 -----------------------------
6850 enable PNO
6851 look for 2 networks:
6852 test - with authentication type 0 and encryption type 0,
6853 that can be found on 3 channels: 1 6 and 11 ,
6854 SSID bcast type is unknown (directed probe will be sent if AP not found)
6855 and must meet -40dBm RSSI
6856
6857 test2 - with auth and enrytption type 4/4
6858 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6859 bcast type is non-bcast (directed probe will be sent)
6860 and must not meet any RSSI threshold
6861
Jeff Johnson8301aa12013-03-28 14:27:29 -07006862 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006864 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006865
Wilson Yang623f6592013-10-08 16:33:37 -07006866 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6867 {
6868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6869 "PNO enable input is not valid %s",ptr);
6870 return VOS_STATUS_E_FAILURE;
6871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006872
6873 if ( 0 == pnoRequest.enable )
6874 {
6875 /*Disable PNO*/
6876 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05306877 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
6878 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 pAdapter->sessionId,
6880 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05306881 if (eHAL_STATUS_SUCCESS != status)
6882 {
6883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6884 "%s: failed to disable PNO", __func__);
6885 return VOS_STATUS_E_FAILURE;
6886 }
6887 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 return VOS_STATUS_SUCCESS;
6889 }
6890
c_hpothu37f21312014-04-09 21:49:54 +05306891 if (TRUE == pHddCtx->isPnoEnable)
6892 {
6893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6894 FL("already PNO is enabled"));
6895 return -EBUSY;
6896 }
6897 pHddCtx->isPnoEnable = TRUE;
6898
Jeff Johnson295189b2012-06-20 16:38:30 -07006899 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006900
6901 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6902 {
6903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6904 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306905 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006907
6908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6909 "PNO enable %d networks count %d offset %d",
6910 pnoRequest.enable,
6911 pnoRequest.ucNetworksCount,
6912 nOffset);
6913
6914 /* Parameters checking:
6915 ucNetworksCount has to be larger than 0*/
6916 if (( 0 == pnoRequest.ucNetworksCount ) ||
6917 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6918 {
6919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05306920 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 }
6922
6923 ptr += nOffset;
6924
6925 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6926 {
6927
6928 pnoRequest.aNetworks[i].ssId.length = 0;
6929
Wilson Yang623f6592013-10-08 16:33:37 -07006930 ucParams = sscanf(ptr,"%hhu %n",
6931 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6932
6933 if (1 != ucParams)
6934 {
6935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6936 "PNO ssid length input is not valid %s",ptr);
6937 return VOS_STATUS_E_FAILURE;
6938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006939
6940 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6941 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6942 {
6943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6944 "SSID Len %d is not correct for network %d",
6945 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05306946 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 }
6948
6949 /*Advance to SSID*/
6950 ptr += nOffset;
6951
Jeff Johnson8301aa12013-03-28 14:27:29 -07006952 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006953 pnoRequest.aNetworks[i].ssId.length);
6954 ptr += pnoRequest.aNetworks[i].ssId.length;
6955
Jeff Johnson02797792013-10-26 19:17:13 -07006956 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006957 &(pnoRequest.aNetworks[i].authentication),
6958 &(pnoRequest.aNetworks[i].encryption),
6959 &(pnoRequest.aNetworks[i].ucChannelCount),
6960 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006961
Wilson Yang623f6592013-10-08 16:33:37 -07006962 if ( 3 != ucParams )
6963 {
6964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6965 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306966 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006967 }
6968
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006970 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006971 "auth %d encry %d channel count %d offset %d",
6972 pnoRequest.aNetworks[i].ssId.length,
6973 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6974 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6975 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6976 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6977 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6978 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6979 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6980 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6981 pnoRequest.aNetworks[i].authentication,
6982 pnoRequest.aNetworks[i].encryption,
6983 pnoRequest.aNetworks[i].ucChannelCount,
6984 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006985
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 /*Advance to channel list*/
6987 ptr += nOffset;
6988
Wilson Yang623f6592013-10-08 16:33:37 -07006989 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 {
6991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6992 "Incorrect number of channels");
6993 return VOS_STATUS_E_FAILURE;
6994 }
6995
6996 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6997 {
6998 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6999 {
Wilson Yang623f6592013-10-08 16:33:37 -07007000 if (1 != sscanf(ptr,"%hhu %n",
7001 &(pnoRequest.aNetworks[i].aChannels[j]),
7002 &nOffset))
7003 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7004 "PNO network channel input is not valid %s",ptr);
7005 return VOS_STATUS_E_FAILURE;
7006 }
7007 /*Advance to next channel number*/
7008 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 }
7010 }
7011
Jeff Johnson02797792013-10-26 19:17:13 -07007012 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007013 &(pnoRequest.aNetworks[i].bcastNetwType),
7014 &nOffset))
7015 {
7016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7017 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307018 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007020
7021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7022 "PNO bcastNetwType %d offset %d",
7023 pnoRequest.aNetworks[i].bcastNetwType,
7024 nOffset );
7025
7026 /*Advance to rssi Threshold*/
7027 ptr += nOffset;
7028
Wilson Yang623f6592013-10-08 16:33:37 -07007029 if (1 != sscanf(ptr,"%hhu %n",
7030 &(pnoRequest.aNetworks[i].rssiThreshold),
7031 &nOffset))
7032 {
7033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7034 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307035 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007037
7038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7039 "PNO rssi %d offset %d",
7040 pnoRequest.aNetworks[i].rssiThreshold,
7041 nOffset );
7042 /*Advance to next network*/
7043 ptr += nOffset;
7044 }/*For ucNetworkCount*/
7045
7046 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007047 &(pnoRequest.scanTimers.ucScanTimersCount),
7048 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007049
7050 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007051 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 {
7053 ptr += nOffset;
7054
Jeff Johnson8301aa12013-03-28 14:27:29 -07007055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7056 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 pnoRequest.scanTimers.ucScanTimersCount,
7058 nOffset );
7059
7060 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7061 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307064 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 }
7066
7067 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7068 {
Jeff Johnson02797792013-10-26 19:17:13 -07007069 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7071 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7072 &nOffset);
7073
Wilson Yang623f6592013-10-08 16:33:37 -07007074 if (2 != ucParams)
7075 {
7076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7077 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307078 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007079 }
7080
Jeff Johnson8301aa12013-03-28 14:27:29 -07007081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7082 "PNO Timer value %d Timer repeat %d offset %d",
7083 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7085 nOffset );
7086
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 ptr += nOffset;
7088 }
7089
7090 }
7091 else
7092 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7094 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7096
7097 /*Scan timers defaults to 5 minutes*/
7098 pnoRequest.scanTimers.ucScanTimersCount = 1;
7099 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7100 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7101 }
7102
Wilson Yang623f6592013-10-08 16:33:37 -07007103 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007104
7105 pnoRequest.modePNO = ucMode;
7106 /*for LA we just expose suspend option*/
7107 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7108 {
7109 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7110 }
7111
c_hpothu37f21312014-04-09 21:49:54 +05307112 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 pAdapter->sessionId,
7114 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307115 if (eHAL_STATUS_SUCCESS == status)
7116 {
7117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7118 "%s: PNO enabled", __func__);
7119 return VOS_STATUS_SUCCESS;
7120 }
7121error:
7122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7123 "%s: Failed to enable PNO", __func__);
7124 pHddCtx->isPnoEnable = FALSE;
7125 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007126}/*iw_set_pno*/
7127
7128VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7129 union iwreq_data *wrqu, char *extra, int nOffset)
7130{
7131 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7132 v_U8_t rssiThreshold = 0;
7133 v_U8_t nRead;
7134
Arif Hussain7adce1b2013-11-11 22:59:34 -08007135 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 &rssiThreshold);
7137
7138 if ( 1 != nRead )
7139 {
7140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7141 "Incorrect format");
7142 return VOS_STATUS_E_FAILURE;
7143 }
7144
7145 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7146 return VOS_STATUS_SUCCESS;
7147}
7148
7149
7150static int iw_set_pno_priv(struct net_device *dev,
7151 struct iw_request_info *info,
7152 union iwreq_data *wrqu, char *extra)
7153{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007154 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7155
7156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007158
7159 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7160 {
7161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7162 "%s:LOGP in Progress. Ignore!!!", __func__);
7163 return -EBUSY;
7164 }
7165 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007166}
7167#endif /*FEATURE_WLAN_SCAN_PNO*/
7168
7169//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307170int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007171{
7172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7173 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7174 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307175 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307177 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307178 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
7179 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07007180
Atul Mittal54378cb2014-04-02 16:51:50 +05307181 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 {
7183 case WLAN_HDD_UI_BAND_AUTO:
7184 band = eCSR_BAND_ALL;
7185 break;
7186 case WLAN_HDD_UI_BAND_5_GHZ:
7187 band = eCSR_BAND_5G;
7188 break;
7189 case WLAN_HDD_UI_BAND_2_4_GHZ:
7190 band = eCSR_BAND_24;
7191 break;
7192 default:
7193 band = eCSR_BAND_MAX;
7194 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307195 connectedBand =
7196 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007197
Atul Mittal54378cb2014-04-02 16:51:50 +05307198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007199 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007200
7201 if (band == eCSR_BAND_MAX)
7202 {
7203 /* Received change band request with invalid band value */
7204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307205 "%s: Invalid band value %u", __func__, ui_band);
7206 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 }
7208
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307209 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7210 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7211 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7212 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007214 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007215 band, pHddCtx->cfg_ini->nBandCapability);
7216 return -EIO;
7217 }
7218
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7220 {
7221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7222 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007223 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 return -EIO;
7225 }
7226
7227 if (currBand != band)
7228 {
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307229 /* Return failure if current country code is world regulatory domain*/
7230 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
7231 pMac->scan.countryCodeCurrent[1] == '0') )
7232 {
7233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7234 "%s: failed to set the band value to %u as country code is 00",
7235 __func__, band);
7236 return -EAGAIN;
7237 }
7238
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 /* Change band request received.
7240 * Abort pending scan requests, flush the existing scan results,
7241 * and change the band capability
7242 */
7243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7244 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007245 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007246
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307247 /* We need to change the band and flush the scan results here itself
7248 * as we may get timeout for disconnection in which we will return
7249 * with out doing any of these
7250 */
7251 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7252 {
7253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7254 "%s: failed to set the band value to %u ",
7255 __func__, band);
7256 return -EINVAL;
7257 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307258 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
7259 {
7260 v_COUNTRYCODE_t curr_country;
7261 curr_country[0]=pMac->scan.countryCodeCurrent[0];
7262 curr_country[1]=pMac->scan.countryCodeCurrent[1];
7263
7264 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
7265 * information available in NV so to get the channel information from kernel
7266 * we need to send regulatory hint for the currunt country
7267 * And to set the same country again we need to set the dummy country
7268 * first and then the actual country.
7269 */
7270
7271#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
7272 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
7273#else
7274 regulatory_hint_user("00");
7275#endif
7276
7277 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
7278#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
7279 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
7280#else
7281 regulatory_hint_user(curr_country);
7282#endif
7283 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
7284 }
7285 else
7286 {
7287 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
7288 (void *)pHddCtx->wiphy, (eCsrBand)band);
7289 }
7290
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307291 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7292 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7293 sme_FilterScanResults(hHal, pAdapter->sessionId);
7294
7295 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307296 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7297 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 {
7299 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7300 eHalStatus status = eHAL_STATUS_SUCCESS;
7301 long lrc;
7302
7303 /* STA already connected on current band, So issue disconnect first,
7304 * then change the band*/
7305
7306 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05307307 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
7308 " Set HDD connState to eConnectionState_NotConnected",
Jeff Johnson295189b2012-06-20 16:38:30 -07007309 __func__, csrGetCurrentBand(hHal), band);
7310
7311 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7312 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7313
7314 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7315 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7316
Jeff Johnson43971f52012-07-17 12:26:56 -07007317 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 {
7319 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007320 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 __func__, (int)status );
7322 return -EINVAL;
7323 }
7324
7325 lrc = wait_for_completion_interruptible_timeout(
7326 &pAdapter->disconnect_comp_var,
7327 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7328
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307329 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007330
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007331 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007332 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007333
7334 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7335 }
7336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05307338 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007339}
7340
Atul Mittal54378cb2014-04-02 16:51:50 +05307341int hdd_setBand_helper(struct net_device *dev, const char *command)
7342{
7343 u8 band;
7344
7345 /*convert the band value from ascii to integer*/
7346 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7347
7348 return hdd_setBand(dev, band);
7349
7350}
7351
Jeff Johnson295189b2012-06-20 16:38:30 -07007352static int iw_set_band_config(struct net_device *dev,
7353 struct iw_request_info *info,
7354 union iwreq_data *wrqu, char *extra)
7355{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007356 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307357 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007358
Arif Hussain0273cba2014-01-07 20:58:29 -08007359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007360
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007361 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7362 {
7363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7364 "%s:LOGP in Progress. Ignore!!!", __func__);
7365 return -EBUSY;
7366 }
7367
Atul Mittal54378cb2014-04-02 16:51:50 +05307368 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007369}
7370
7371static int iw_set_power_params_priv(struct net_device *dev,
7372 struct iw_request_info *info,
7373 union iwreq_data *wrqu, char *extra)
7374{
Arif Hussain0273cba2014-01-07 20:58:29 -08007375 int ret;
7376 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7378 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007379 /* ODD number is used for set, copy data using copy_from_user */
7380 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7381 wrqu->data.length);
7382 if (NULL == ptr)
7383 {
7384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7385 "mem_alloc_copy_from_user_helper fail");
7386 return -ENOMEM;
7387 }
7388
7389 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7390 kfree(ptr);
7391 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007392}
7393
7394
7395
7396/*string based input*/
7397VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7398 union iwreq_data *wrqu, char *extra, int nOffset)
7399{
7400 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7401 tSirSetPowerParamsReq powerRequest;
7402 char *ptr;
7403 v_U8_t ucType;
7404 v_U32_t uTotalSize, uValue;
7405 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7406
7407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7408 "Power Params data len %d data %s",
7409 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007410 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007411
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007412 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7413 {
7414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7415 "%s:LOGP in Progress. Ignore!!!", __func__);
7416 return -EBUSY;
7417 }
7418
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 if (wrqu->data.length <= nOffset )
7420 {
7421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7422 return VOS_STATUS_E_FAILURE;
7423 }
7424
7425 uTotalSize = wrqu->data.length - nOffset;
7426
7427 /*-----------------------------------------------------------------------
7428 Input is string based and expected to be like this:
7429
7430 <param_type> <param_value> <param_type> <param_value> ...
7431
7432 e.g:
7433 1 2 2 3 3 0 4 1 5 1
7434
7435 e.g. setting just a few:
7436 1 2 4 1
7437
7438 parameter types:
7439 -----------------------------
7440 1 - Ignore DTIM
7441 2 - Listen Interval
7442 3 - Broadcast Multicas Filter
7443 4 - Beacon Early Termination
7444 5 - Beacon Early Termination Interval
7445 -----------------------------------------------------------------------*/
7446 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7447 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7448 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7449 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7450 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7451
Arif Hussain7adce1b2013-11-11 22:59:34 -08007452 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007453
7454 while ( uTotalSize )
7455 {
Wilson Yang6f971452013-10-08 15:00:00 -07007456 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7457 {
7458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7459 "Invalid input parameter type %s",ptr);
7460 return VOS_STATUS_E_FAILURE;
7461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007462
7463 uTotalSize -= nOffset;
7464
7465 if (!uTotalSize)
7466 {
7467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007468 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007469 ucType, nOffset);
7470 return VOS_STATUS_E_FAILURE;
7471 }
7472
7473 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007474
Jeff Johnson02797792013-10-26 19:17:13 -07007475 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007476 {
7477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7478 "Invalid input parameter value %s",ptr);
7479 return VOS_STATUS_E_FAILURE;
7480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007481
7482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7483 "Power request parameter %d value %d offset %d",
7484 ucType, uValue, nOffset);
7485
7486 switch (ucType)
7487 {
7488 case eSIR_IGNORE_DTIM:
7489 powerRequest.uIgnoreDTIM = uValue;
7490 break;
7491 case eSIR_LISTEN_INTERVAL:
7492 powerRequest.uListenInterval = uValue;
7493 break;
7494 case eSIR_MCAST_BCAST_FILTER:
7495 powerRequest.uBcastMcastFilter = uValue;
7496 break;
7497 case eSIR_ENABLE_BET:
7498 powerRequest.uEnableBET = uValue;
7499 break;
7500 case eSIR_BET_INTERVAL:
7501 powerRequest.uBETInterval = uValue;
7502 break;
7503 default:
7504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007505 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007506 ucType, uValue, nOffset);
7507 return VOS_STATUS_E_FAILURE;
7508 }
7509
7510 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7512 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007513 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007515 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007516 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007517 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7518 {
7519 uTotalSize = 0;
7520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007521
7522 }/*Go for as long as we have a valid string*/
7523
7524 /* put the device into full power*/
7525 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7526
7527 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007528 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007529
7530 /* put the device back to power save*/
7531 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7532
7533 return VOS_STATUS_SUCCESS;
7534}/*iw_set_power_params*/
7535
Atul Mittalc0f739f2014-07-31 13:47:47 +05307536// tdlsoffchan
7537#ifdef FEATURE_WLAN_TDLS
7538
7539static int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
7540{
7541 if (offchannel < 0 || offchannel > 165)
7542 {
7543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
7544 __func__, offchannel);
7545 return -1;
7546
7547 }
7548
7549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
7550 __func__, tdlsOffCh, offchannel);
7551
7552 tdlsOffCh = offchannel;
7553 return 0;
7554}
7555
7556static int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
7557{
7558 if (offchanoffset == 0)
7559 {
7560 tdlsOffChBwOffset = 0;
7561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
7562 __func__, tdlsOffChBwOffset);
7563
7564 return 0;
7565
7566 }
7567
7568 if ( offchanoffset == 40 )
7569 {
7570 tdlsOffChBwOffset = 1;
7571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
7572 __func__, tdlsOffChBwOffset);
7573
7574 return 0;
7575
7576 }
7577 if (offchanoffset == -40)
7578 {
7579 tdlsOffChBwOffset = 3;
7580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
7581 __func__, tdlsOffChBwOffset);
7582
7583 return 0;
7584
7585 }
7586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
7587 __func__, offchanoffset);
7588 return -1;
7589}
7590
7591static int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
7592{
7593 hddTdlsPeer_t *connPeer = NULL;
7594 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7595 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7596
7597 if (offchanmode < 0 || offchanmode > 4)
7598 {
7599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7600 "%s: Invalid tdls off channel mode %d",
7601 __func__, offchanmode);
7602 return -1;
7603 }
7604
7605 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7606 {
7607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7608 "%s: tdls off channel mode req in not associated state %d",
7609 __func__, offchanmode);
7610 return -1;
7611 }
7612
7613 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
7614 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
7615 {
7616 /* Send TDLS Channel Switch Request to connected peer */
7617 connPeer = wlan_hdd_tdls_get_first_connected_peer(pAdapter);
7618 if (NULL == connPeer) {
7619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7620 "%s: No TDLS Connected Peer", __func__);
7621 return -1;
7622 }
7623 }
7624 else
7625 {
7626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7627 "%s: TDLS Connection not supported", __func__);
7628 return -1;
7629 }
7630
7631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7632 ("%s: TDLS Channel Switch in swmode=%d"),
7633 __func__, offchanmode);
7634
7635 switch (offchanmode)
7636 {
7637 case 1:/*Enable*/
7638 case 2:/*Disable*/
7639 {
7640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7641 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
7642 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
7643 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
7644 {
7645
7646 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
7647 pAdapter->sessionId, connPeer->peerMac,
7648 tdlsOffCh, tdlsOffChBwOffset,
7649 offchanmode);
7650 }
7651 else
7652 {
7653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7654 "%s: TDLS Off Channel not supported", __func__);
7655 return -1;
7656 }
7657 break;
7658 }
7659 case 3:
7660 {
7661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7662 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
7663 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
7664
7665 break;
7666 }
7667 case 4:
7668 {
7669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7670 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
7671 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
7672 break;
7673 }
7674 default:
7675 {
7676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7677 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
7678 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
7679 break;
7680 }
7681
7682 }
7683
7684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
7685 __func__, offchanmode);
7686 return 0;
7687}
7688
7689#endif
7690
Jeff Johnson295189b2012-06-20 16:38:30 -07007691
7692// Define the Wireless Extensions to the Linux Network Device structure
7693// A number of these routines are NULL (meaning they are not implemented.)
7694
7695static const iw_handler we_handler[] =
7696{
7697 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7698 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7699 (iw_handler) NULL, /* SIOCSIWNWID */
7700 (iw_handler) NULL, /* SIOCGIWNWID */
7701 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7702 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7703 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7704 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7705 (iw_handler) NULL, /* SIOCSIWSENS */
7706 (iw_handler) NULL, /* SIOCGIWSENS */
7707 (iw_handler) NULL, /* SIOCSIWRANGE */
7708 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7709 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7710 (iw_handler) NULL, /* SIOCGIWPRIV */
7711 (iw_handler) NULL, /* SIOCSIWSTATS */
7712 (iw_handler) NULL, /* SIOCGIWSTATS */
7713 iw_handler_set_spy, /* SIOCSIWSPY */
7714 iw_handler_get_spy, /* SIOCGIWSPY */
7715 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7716 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7717 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7718 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7719 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7720 (iw_handler) NULL, /* SIOCGIWAPLIST */
7721 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7722 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7723 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7724 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7725 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7726 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7727 (iw_handler) NULL, /* -- hole -- */
7728 (iw_handler) NULL, /* -- hole -- */
7729 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7730 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7731 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7732 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7733 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7734 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7735 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7736 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7737 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7738 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7739 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7740 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7741 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7742 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7743 (iw_handler) NULL, /* -- hole -- */
7744 (iw_handler) NULL, /* -- hole -- */
7745 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7746 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7747 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7748 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7749 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7750 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7751 (iw_handler) NULL, /* SIOCSIWPMKSA */
7752};
7753
7754static const iw_handler we_private[] = {
7755
7756 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7757 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7758 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7759 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7760 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7761 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7762 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7763 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7764 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7765 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007766#ifdef FEATURE_OEM_DATA_SUPPORT
7767 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7768 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7769#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007770
Jeff Johnson295189b2012-06-20 16:38:30 -07007771#ifdef WLAN_FEATURE_VOWIFI_11R
7772 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7773#endif
7774 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7775 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7776 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7777#ifdef WLAN_FEATURE_PACKET_FILTERING
7778 ,
7779 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7780#endif
7781#ifdef FEATURE_WLAN_SCAN_PNO
7782 ,
7783 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7784#endif
7785 ,
7786 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7787 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7788 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7789 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007790 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007791};
7792
7793/*Maximum command length can be only 15 */
7794static const struct iw_priv_args we_private_args[] = {
7795
7796 /* handlers for main ioctl */
7797 { WLAN_PRIV_SET_INT_GET_NONE,
7798 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7799 0,
7800 "" },
7801
7802 /* handlers for sub-ioctl */
7803 { WE_SET_11D_STATE,
7804 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7805 0,
7806 "set11Dstate" },
7807
7808 { WE_WOWL,
7809 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7810 0,
7811 "wowl" },
7812
7813 { WE_SET_POWER,
7814 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7815 0,
7816 "setPower" },
7817
7818 { WE_SET_MAX_ASSOC,
7819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7820 0,
7821 "setMaxAssoc" },
7822
7823 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7824 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7825 0,
7826 "setAutoChannel" },
7827
7828 { WE_SET_DATA_INACTIVITY_TO,
7829 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7830 0,
7831 "inactivityTO" },
7832
7833 { WE_SET_MAX_TX_POWER,
7834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7835 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007836 "setMaxTxPower" },
7837
7838 { WE_SET_MAX_TX_POWER_2_4,
7839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7840 0,
7841 "setTxMaxPower2G" },
7842
7843 { WE_SET_MAX_TX_POWER_5_0,
7844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7845 0,
7846 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007847
7848 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7849 * as well to keep same syntax as in SAP. Now onwards, STA
7850 * will support both */
7851 { WE_SET_MAX_TX_POWER,
7852 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7853 0,
7854 "setTxMaxPower" },
7855
Jeff Johnson295189b2012-06-20 16:38:30 -07007856 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7857 * 1 = enable and 0 = disable */
7858 {
7859 WE_SET_HIGHER_DTIM_TRANSITION,
7860 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7861 0,
7862 "setHDtimTransn" },
7863
7864 { WE_SET_TM_LEVEL,
7865 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007866 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 "setTmLevel" },
7868
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307869 { WE_ENABLE_STRICT_FCC_REG,
7870 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7871 0,
7872 "setStrictFCCreg" },
7873
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007874 { WE_SET_DEBUG_LOG,
7875 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7876 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05307877#ifdef FEATURE_WLAN_TDLS
7878 {
7879 WE_SET_TDLS_OFF_CHAN,
7880 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7881 0,
7882 "tdlsoffchan" },
7883 {
7884 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
7885 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7886 0,
7887 "tdlsecchnoffst" },
7888 {
7889 WE_SET_TDLS_OFF_CHAN_MODE,
7890 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7891 0,
7892 "tdlsoffchnmode" },
7893#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007894
Jeff Johnson295189b2012-06-20 16:38:30 -07007895 /* handlers for main ioctl */
7896 { WLAN_PRIV_SET_NONE_GET_INT,
7897 0,
7898 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7899 "" },
7900
7901 /* handlers for sub-ioctl */
7902 { WE_GET_11D_STATE,
7903 0,
7904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7905 "get11Dstate" },
7906
7907 { WE_IBSS_STATUS,
7908 0,
7909 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7910 "getAdhocStatus" },
7911
7912 { WE_PMC_STATE,
7913 0,
7914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7915 "pmcState" },
7916
7917 { WE_GET_WLAN_DBG,
7918 0,
7919 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7920 "getwlandbg" },
7921
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 { WE_GET_MAX_ASSOC,
7923 0,
7924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7925 "getMaxAssoc" },
7926
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 { WE_GET_WDI_DBG,
7928 0,
7929 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7930 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007931
7932 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7933 0,
7934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7935 "getAutoChannel" },
7936
7937 { WE_GET_CONCURRENCY_MODE,
7938 0,
7939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7940 "getconcurrency" },
7941
7942 /* handlers for main ioctl */
7943 { WLAN_PRIV_SET_CHAR_GET_NONE,
7944 IW_PRIV_TYPE_CHAR| 512,
7945 0,
7946 "" },
7947
7948 /* handlers for sub-ioctl */
7949 { WE_WOWL_ADD_PTRN,
7950 IW_PRIV_TYPE_CHAR| 512,
7951 0,
7952 "wowlAddPtrn" },
7953
7954 { WE_WOWL_DEL_PTRN,
7955 IW_PRIV_TYPE_CHAR| 512,
7956 0,
7957 "wowlDelPtrn" },
7958
7959#if defined WLAN_FEATURE_VOWIFI
7960 /* handlers for sub-ioctl */
7961 { WE_NEIGHBOR_REPORT_REQUEST,
7962 IW_PRIV_TYPE_CHAR | 512,
7963 0,
7964 "neighbor" },
7965#endif
7966 { WE_SET_AP_WPS_IE,
7967 IW_PRIV_TYPE_CHAR| 512,
7968 0,
7969 "set_ap_wps_ie" },
7970
7971 { WE_SET_CONFIG,
7972 IW_PRIV_TYPE_CHAR| 512,
7973 0,
7974 "setConfig" },
7975
7976 /* handlers for main ioctl */
7977 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7978 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7979 0,
7980 "" },
7981
7982 /* handlers for sub-ioctl */
7983 { WE_SET_WLAN_DBG,
7984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7985 0,
7986 "setwlandbg" },
7987
Jeff Johnson295189b2012-06-20 16:38:30 -07007988 { WE_SET_WDI_DBG,
7989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7990 0,
7991 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007992
7993 { WE_SET_SAP_CHANNELS,
7994 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7995 0,
7996 "setsapchannels" },
7997
7998 /* handlers for main ioctl */
7999 { WLAN_PRIV_GET_CHAR_SET_NONE,
8000 0,
8001 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8002 "" },
8003
8004 /* handlers for sub-ioctl */
8005 { WE_WLAN_VERSION,
8006 0,
8007 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8008 "version" },
8009 { WE_GET_STATS,
8010 0,
8011 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8012 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308013 { WE_GET_STATES,
8014 0,
8015 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8016 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 { WE_GET_CFG,
8018 0,
8019 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8020 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07008021#ifdef WLAN_FEATURE_11AC
8022 { WE_GET_RSSI,
8023 0,
8024 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8025 "getRSSI" },
8026#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008027#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008028 { WE_GET_ROAM_RSSI,
8029 0,
8030 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8031 "getRoamRSSI" },
8032#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 { WE_GET_WMM_STATUS,
8034 0,
8035 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8036 "getWmmStatus" },
8037 {
8038 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308039 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8041 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08008042#ifdef FEATURE_WLAN_TDLS
8043 {
8044 WE_GET_TDLS_PEERS,
8045 0,
8046 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8047 "getTdlsPeers" },
8048#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008049#ifdef WLAN_FEATURE_11W
8050 {
8051 WE_GET_11W_INFO,
8052 0,
8053 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8054 "getPMFInfo" },
8055#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 /* handlers for main ioctl */
8057 { WLAN_PRIV_SET_NONE_GET_NONE,
8058 0,
8059 0,
8060 "" },
8061
8062 /* handlers for sub-ioctl */
8063 { WE_CLEAR_STATS,
8064 0,
8065 0,
8066 "clearStats" },
8067 { WE_INIT_AP,
8068 0,
8069 0,
8070 "initAP" },
8071 { WE_STOP_AP,
8072 0,
8073 0,
8074 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308075#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 { WE_ENABLE_AMP,
8077 0,
8078 0,
8079 "enableAMP" },
8080 { WE_DISABLE_AMP,
8081 0,
8082 0,
8083 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308084#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008085 { WE_ENABLE_DXE_STALL_DETECT,
8086 0,
8087 0,
8088 "dxeStallDetect" },
8089 { WE_DISPLAY_DXE_SNAP_SHOT,
8090 0,
8091 0,
8092 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308093 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
8094 0,
8095 0,
8096 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07008097 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05308098 WE_SET_REASSOC_TRIGGER,
8099 0,
8100 0,
8101 "reassoc" },
8102 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05308103 WE_STOP_OBSS_SCAN,
8104 0,
8105 0,
8106 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +05308107#ifdef DEBUG_ROAM_DELAY
8108 {
8109 WE_DUMP_ROAM_TIMER_LOG,
8110 0,
8111 0,
8112 "dumpRoamDelay" },
8113 {
8114 WE_RESET_ROAM_TIMER_LOG,
8115 0,
8116 0,
8117 "resetRoamDelay" },
8118#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 /* handlers for main ioctl */
8120 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
8121 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8122 0,
8123 "" },
8124
8125 /* handlers for sub-ioctl */
8126 { WE_LOG_DUMP_CMD,
8127 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8128 0,
8129 "dump" },
8130
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008131 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308132 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8133 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8134 0,
8135 "setdumplog" },
8136
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008137 { WE_MTRACE_DUMP_CMD,
8138 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8139 0,
8140 "dumplog" },
8141
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008142 /* handlers for sub ioctl */
8143 {
8144 WE_MCC_CONFIG_CREDENTIAL,
8145 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8146 0,
8147 "setMccCrdnl" },
8148
8149 /* handlers for sub ioctl */
8150 {
8151 WE_MCC_CONFIG_PARAMS,
8152 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8153 0,
8154 "setMccConfig" },
8155
Chilam NG571c65a2013-01-19 12:27:36 +05308156#ifdef FEATURE_WLAN_TDLS
8157 /* handlers for sub ioctl */
8158 {
8159 WE_TDLS_CONFIG_PARAMS,
8160 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8161 0,
8162 "setTdlsConfig" },
8163#endif
8164
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 /* handlers for main ioctl */
8166 { WLAN_PRIV_ADD_TSPEC,
8167 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8169 "addTspec" },
8170
8171 /* handlers for main ioctl */
8172 { WLAN_PRIV_DEL_TSPEC,
8173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8174 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8175 "delTspec" },
8176
8177 /* handlers for main ioctl */
8178 { WLAN_PRIV_GET_TSPEC,
8179 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8181 "getTspec" },
8182
Jeff Johnsone7245742012-09-05 17:12:55 -07008183#ifdef FEATURE_OEM_DATA_SUPPORT
8184 /* handlers for main ioctl - OEM DATA */
8185 {
8186 WLAN_PRIV_SET_OEM_DATA_REQ,
8187 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8188 0,
8189 "set_oem_data_req" },
8190
8191 /* handlers for main ioctl - OEM DATA */
8192 {
8193 WLAN_PRIV_GET_OEM_DATA_RSP,
8194 0,
8195 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8196 "get_oem_data_rsp" },
8197#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008198
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 /* handlers for main ioctl - host offload */
8200 {
8201 WLAN_PRIV_SET_HOST_OFFLOAD,
8202 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8203 0,
8204 "setHostOffload" },
8205
8206 {
8207 WLAN_GET_WLAN_STATISTICS,
8208 0,
8209 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8210 "getWlanStats" },
8211
8212 {
8213 WLAN_SET_KEEPALIVE_PARAMS,
8214 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8215 0,
8216 "setKeepAlive" },
8217#ifdef WLAN_FEATURE_PACKET_FILTERING
8218 {
8219 WLAN_SET_PACKET_FILTER_PARAMS,
8220 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8221 0,
8222 "setPktFilter" },
8223#endif
8224#ifdef FEATURE_WLAN_SCAN_PNO
8225 {
8226 WLAN_SET_PNO,
8227 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8228 0,
8229 "setpno" },
8230#endif
8231 {
8232 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 0,
8235 "SETBAND" },
8236 /* handlers for dynamic MC BC ioctl */
8237 {
8238 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008239 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 0,
8241 "setMCBCFilter" },
8242 {
8243 WLAN_PRIV_CLEAR_MCBC_FILTER,
8244 0,
8245 0,
8246 "clearMCBCFilter" },
8247 {
8248 WLAN_SET_POWER_PARAMS,
8249 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8250 0,
8251 "setpowerparams" },
8252 {
8253 WLAN_GET_LINK_SPEED,
8254 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308255 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008256};
8257
8258
8259
8260const struct iw_handler_def we_handler_def = {
8261 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8262 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8263 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8264
8265 .standard = (iw_handler *)we_handler,
8266 .private = (iw_handler *)we_private,
8267 .private_args = we_private_args,
8268 .get_wireless_stats = get_wireless_stats,
8269};
8270
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008271int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8272{
8273 v_U32_t cmd = 288; //Command to RIVA
8274 hdd_context_t *pHddCtx = NULL;
8275 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8276 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8277 /*
8278 *configMccParam : specify the bit which needs to be modified
8279 *allowed to update based on wlan_qcom_cfg.ini
8280 * configuration
8281 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8282 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8283 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8284 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8285 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8286 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8287 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8288 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8289 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8290 * Bit 9 : Reserved
8291 */
8292 switch (arg1)
8293 {
8294 //Update MCC SCHEDULE_TIME_SLICE parameter
8295 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8296 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8297 {
8298 if((arg2 >= 5) && (arg2 <= 20))
8299 {
8300 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8301 }
8302 else
8303 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008304 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008305 return 0;
8306 }
8307 }
8308 break;
8309
8310 //Update MCC MAX_NULL_SEND_TIME parameter
8311 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8312 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8313 {
8314 if((arg2 >= 1) && (arg2 <= 10))
8315 {
8316 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8317 }
8318 else
8319 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008320 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008321 return 0;
8322 }
8323 }
8324 break;
8325
8326 //Update MCC TX_EARLY_STOP_TIME parameter
8327 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8328 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8329 {
8330 if((arg2 >= 1) && (arg2 <= 10))
8331 {
8332 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8333 }
8334 else
8335 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008336 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008337 return 0;
8338 }
8339 }
8340 break;
8341
8342 //Update MCC RX_DRAIN_TIME parameter
8343 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8344 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8345 {
8346 if((arg2 >= 1) && (arg2 <= 10))
8347 {
8348 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8349 }
8350 else
8351 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008352 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008353 return 0;
8354 }
8355 }
8356 break;
8357
8358 //Update MCC CHANNEL_SWITCH_TIME parameter
8359 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8360 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8361 {
8362 if((arg2 >= 1) && (arg2 <= 20))
8363 {
8364 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8365 }
8366 else
8367 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008368 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008369 return 0;
8370 }
8371 }
8372 break;
8373
8374 //Update MCC MIN_CHANNEL_TIME parameter
8375 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8376 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8377 {
8378 if((arg2 >= 5) && (arg2 <= 20))
8379 {
8380 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8381 }
8382 else
8383 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008384 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008385 return 0;
8386 }
8387 }
8388 break;
8389
8390 //Update MCC PARK_BEFORE_TBTT parameter
8391 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8392 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8393 {
8394 if((arg2 >= 1) && (arg2 <= 5))
8395 {
8396 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8397 }
8398 else
8399 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008400 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008401 return 0;
8402 }
8403 }
8404 break;
8405
8406 //Update MCC MIN_AFTER_DTIM parameter
8407 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8408 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8409 {
8410 if((arg2 >= 5) && (arg2 <= 15))
8411 {
8412 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8413 }
8414 else
8415 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008416 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008417 return 0;
8418 }
8419 }
8420 break;
8421
8422 //Update MCC TOO_CLOSE_MARGIN parameter
8423 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8424 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8425 {
8426 if((arg2 >= 1) && (arg2 <= 3))
8427 {
8428 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8429 }
8430 else
8431 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008432 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008433 return 0;
8434 }
8435 }
8436 break;
8437
8438 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008439 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008440 __FUNCTION__,arg1);
8441 break;
8442 }
8443 return 0;
8444}
8445
Jeff Johnson295189b2012-06-20 16:38:30 -07008446int hdd_set_wext(hdd_adapter_t *pAdapter)
8447{
8448 hdd_wext_state_t *pwextBuf;
8449 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008450 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008451
8452 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8453
8454 // Now configure the roaming profile links. To SSID and bssid.
8455 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8456 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8457
8458 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8459 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8460
8461 /*Set the numOfChannels to zero to scan all the channels*/
8462 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8463 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8464
8465 /* Default is no encryption */
8466 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8467 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8468
8469 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8470 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8471
8472 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8473
8474 /* Default is no authentication */
8475 pwextBuf->roamProfile.AuthType.numEntries = 1;
8476 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8477
8478 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8479 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8480
8481 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008482 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008483
8484 hdd_clearRoamProfileIe(pAdapter);
8485
8486 return VOS_STATUS_SUCCESS;
8487
8488 }
8489
8490int hdd_register_wext(struct net_device *dev)
8491 {
8492 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8493 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8494 VOS_STATUS status;
8495
8496 ENTER();
8497
8498 // Zero the memory. This zeros the profile structure.
8499 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8500
8501 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8502
8503
8504 status = hdd_set_wext(pAdapter);
8505
8506 if(!VOS_IS_STATUS_SUCCESS(status)) {
8507
Arif Hussain6d2a3322013-11-17 19:50:10 -08008508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 return eHAL_STATUS_FAILURE;
8510 }
8511
8512 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8513 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008515 return eHAL_STATUS_FAILURE;
8516 }
8517
8518 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8519 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 return eHAL_STATUS_FAILURE;
8522 }
8523
8524 // Register as a wireless device
8525 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8526
8527 EXIT();
8528 return 0;
8529}
8530
8531int hdd_UnregisterWext(struct net_device *dev)
8532{
8533#if 0
8534 hdd_wext_state_t *wextBuf;
8535 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8536
8537 ENTER();
8538 // Set up the pointer to the Wireless Extensions state structure
8539 wextBuf = pAdapter->pWextState;
8540
8541 // De-allocate the Wireless Extensions state structure
8542 kfree(wextBuf);
8543
8544 // Clear out the pointer to the Wireless Extensions state structure
8545 pAdapter->pWextState = NULL;
8546
8547 EXIT();
8548#endif
8549 dev->wireless_handlers = NULL;
8550 return 0;
8551}
8552
8553