blob: b1593d634fb14eafe7bd6c07344b83d74c1410bd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala9c070ad2013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, 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/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/**========================================================================
43
44 \file wlan_hdd_hostapd.c
45 \brief WLAN Host Device Driver implementation
46
47 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
48
49 Qualcomm Confidential and Proprietary.
50
51 ========================================================================*/
52/**=========================================================================
53 EDIT HISTORY FOR FILE
54
55
56 This section contains comments describing changes made to the module.
57 Notice that changes are listed in reverse chronological order.
58
59 $Header:$ $DateTime: $ $Author: $
60
61
62 when who what, where, why
63 -------- --- --------------------------------------------------------
64 04/5/09 Shailender Created module.
65 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
66 ==========================================================================*/
67/*--------------------------------------------------------------------------
68 Include Files
69 ------------------------------------------------------------------------*/
70
71#include <linux/version.h>
72#include <linux/module.h>
73#include <linux/kernel.h>
74#include <linux/init.h>
75#include <linux/wireless.h>
76#include <linux/semaphore.h>
77#include <vos_api.h>
78#include <vos_sched.h>
79#include <linux/etherdevice.h>
80#include <wlan_hdd_includes.h>
81#include <qc_sap_ioctl.h>
82#include <wlan_hdd_hostapd.h>
83#include <sapApi.h>
84#include <sapInternal.h>
85#include <wlan_qct_tl.h>
86#include <wlan_hdd_softap_tx_rx.h>
87#include <wlan_hdd_main.h>
88#include <linux/netdevice.h>
89#include <linux/mmc/sdio_func.h>
90#include "wlan_nlink_common.h"
91#include "wlan_btc_svc.h"
92#include <bap_hdd_main.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_hdd_p2p.h"
Leo Changb77d2882013-08-22 14:59:44 -070094#include "cfgApi.h"
95#include "wniCfgAp.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#define IS_UP(_dev) \
98 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
99#define IS_UP_AUTO(_ic) \
100 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
101#define WE_WLAN_VERSION 1
102#define STATS_CONTEXT_MAGIC 0x53544154
Yathish Hanumapuradoddi Shivannad1951422013-03-25 14:12:32 -0700103#define WE_GET_STA_INFO_SIZE 30
104/* WEXT limition: MAX allowed buf len for any *
105 * IW_PRIV_TYPE_CHAR is 2Kbytes *
106 */
107#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700108
109struct statsContext
110{
111 struct completion completion;
112 hdd_adapter_t *pAdapter;
113 unsigned int magic;
114};
115#define SAP_24GHZ_CH_COUNT (14)
Leo Changb77d2882013-08-22 14:59:44 -0700116
117#define SAP_MAX_GET_ASSOC_STAS_TIMEOUT 500
118/* Max possible supported rate count
119 * Legacy 14 + 11N MCS 8 + 11AC MCS 10 */
120#define SAP_MAX_SUPPORTED_RATE_COUNT 32
121#define SAP_LEGACY_RATE_MASK 0x007F
122#define SAP_GET_STAS_RATE_TIMEOUT 1000
123#define SAP_AC_MCS_MAP_MASK 0x03
124#define SAP_AC_MCS_MAP_OFFSET 7
125
126#define SAP_LEGACY_RATE_COUNT SIR_NUM_11B_RATES + SIR_NUM_11A_RATES
127#define SAP_11N_RATE_COUNT 8
128
129#define SAP_RATE_SUPPORT_MAP_LEGACY_MASK 0x0001
130#define SAP_RATE_SUPPORT_MAP_N_MASK 0x001E
131#define SAP_RATE_SUPPORT_MAP_AC_MASK 0x07E0
132
133#define SAP_MAX_24_CHANNEL_NUMBER 14
134#define SAP_GET_STAS_COOKIE 0xC000C1EE
135
136/* Temp put here, will locate correct location
137 * work on progress with UMAC */
138/* Should syn with FW definition */
139typedef enum
140{
141 WNI_CFG_FIXED_RATE_SAP_AUTO,
142 WNI_CFG_FIXED_RATE_11B_LONG_1_MBPS,
143 WNI_CFG_FIXED_RATE_11B_LONG_2_MBPS,
144 WNI_CFG_FIXED_RATE_11B_LONG_5_5_MBPS,
145 WNI_CFG_FIXED_RATE_11B_LONG_11_MBPS,
146 WNI_CFG_FIXED_RATE_11A_6_MBPS,
147 WNI_CFG_FIXED_RATE_11A_9_MBPS,
148 WNI_CFG_FIXED_RATE_11A_12_MBPS,
149 WNI_CFG_FIXED_RATE_11A_18_MBPS,
150 WNI_CFG_FIXED_RATE_11A_24_MBPS,
151 WNI_CFG_FIXED_RATE_11A_36_MBPS,
152 WNI_CFG_FIXED_RATE_11A_48_MBPS,
153 WNI_CFG_FIXED_RATE_11A_54_MBPS,
154 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_6_5_MBPS,
155 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_13_MBPS,
156 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_19_5_MBPS,
157 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_26_MBPS,
158 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_39_MBPS,
159 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_52_MBPS,
160 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_58_5_MBPS,
161 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_65_MBPS,
162 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_7_2_MBPS,
163 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_14_4_MBPS,
164 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_21_7_MBPS,
165 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_28_9_MBPS,
166 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_43_3_MBPS,
167 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_57_8_MBPS,
168 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_65_MBPS,
169 WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_72_2_MBPS,
170 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_13_5_MBPS,
171 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_27_MBPS, /* 30 */
172 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_40_5_MBPS,
173 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_54_MBPS,
174 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_81_MBPS,
175 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_108_MBPS,
176 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_121_5_MBPS,
177 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_135_MBPS,
178 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_15_MBPS,
179 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_30_MBPS,
180 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_45_MBPS,
181 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_60_MBPS,
182 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_90_MBPS,
183 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_120_MBPS,
184 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_135_MBPS,
185 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_150_MBPS,
186 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_GF_13_5_MBPS,
187 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_GF_27_MBPS,
188 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_GF_40_5_MBPS,
189 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_GF_54_MBPS,
190 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_GF_81_MBPS,
191 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_GF_108_MBPS,
192 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_GF_121_5_MBPS,
193 WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_GF_135_MBPS,
194 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_6_5MBPS,
195 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_13MBPS,
196 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_19_5MBPS,
197 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_26MBPS,
198 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_39MBPS,
199 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_52MBPS,
200 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_58_5MBPS,
201 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_65MBPS, /* 60 */
202 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_78MBPS,
203 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_NGI_86_5_MBPS,
204 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_SGI_21_667MBPS,
205 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_SGI_28_889MBPS,
206 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_SGI_43_333MBPS,
207 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_SGI_57_778MBPS,
208 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_SGI_65MBPS,
209 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_SGI_72_222MBPS,
210 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_SGI_86_667MBPS,
211 WNI_CFG_FIXED_RATE_VHT_SIMO_CB_SGI_96_1_MBPS,
212 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_13_5MBPS,
213 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_27MBPS,
214 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_40_5MBPS,
215 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_54MBPS,
216 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_81MBPS,
217 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_108MBPS,
218 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_121_5MBPS,
219 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_135MBPS,
220 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_RESERVED,
221 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_162MBPS,
222 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_180MBPS,
223 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_15MBPS,
224 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_30MBPS,
225 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_45MBPS,
226 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_60MBPS,
227 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_90MBPS,
228 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_120MBPS,
229 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_135MBPS,
230 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_150MBPS,
231 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_RESERVED, /* 90 */
232 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_180MBPS,
233 WNI_CFG_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_200MBPS,
234 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_29_25MBPS,
235 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_58_5MBPS,
236 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_87_75MBPS,
237 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_117MBPS,
238 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_175_5MBPS,
239 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_234MBPS,
240 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_263_25MBPS,
241 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_292_5MBPS,
242 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_RESERVED,
243 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_351MBPS,
244 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_390MBPS,
245 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_32_5MBPS,
246 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_65MBPS,
247 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_97_5MBPS,
248 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_130MBPS,
249 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_195MBPS,
250 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_260MBPS,
251 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_292_5MBPS,
252 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_325MBPS,
253 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_RESERVED,
254 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_390MBPS,
255 WNI_CFG_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_433_33MBPS,
256 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_6_5MBPS,
257 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_13MBPS,
258 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_19_5MBPS,
259 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_26MBPS,
260 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_39MBPS,
261 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_52MBPS, /* 120 */
262 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_58_5MBPS,
263 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_65MBPS,
264 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_78MBPS,
265 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_86_5_MBPS,
266 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_7_2222MBPS,
267 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_14_444MBPS,
268 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_21_667MBPS,
269 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_28_889MBPS,
270 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_43_333MBPS,
271 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_57_778MBPS,
272 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_65MBPS,
273 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_72_222MBPS,
274 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_86_667MBPS,
275 WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_96_1_MBPS,
276 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_13_5MBPS,
277 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_27MBPS,
278 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_40_5MBPS,
279 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_54MBPS,
280 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_81MBPS,
281 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_108MBPS,
282 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_121_5MBPS,
283 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_135MBPS,
284 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_RESERVED,
285 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_162MBPS,
286 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_180MBPS,
287 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_15MBPS,
288 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_30MBPS,
289 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_45MBPS,
290 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_60MBPS,
291 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_90MBPS, /* 150 */
292 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_120MBPS,
293 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_135MBPS,
294 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_150MBPS,
295 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_RESERVED,
296 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_180MBPS,
297 WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_200MBPS,
298 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_29_25MBPS,
299 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_58_5MBPS,
300 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_87_75MBPS,
301 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_117MBPS,
302 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_175_5MBPS,
303 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_234MBPS,
304 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_263_25MBPS,
305 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_292_5MBPS,
306 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_RESERVED,
307 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_351MBPS,
308 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_390MBPS,
309 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_32_5MBPS,
310 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_65MBPS,
311 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_97_5MBPS,
312 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_130MBPS,
313 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_195MBPS,
314 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_260MBPS,
315 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_292_5MBPS,
316 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_325MBPS,
317 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_RESERVED,
318 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_390MBPS,
319 WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_433_33MBPS,
320 WNI_CFG_FIXED_RATE_11A_DUP_6_MBPS,
321 WNI_CFG_FIXED_RATE_11A_DUP_9_MBPS, /* 180 */
322 WNI_CFG_FIXED_RATE_11A_DUP_12_MBPS,
323 WNI_CFG_FIXED_RATE_11A_DUP_18_MBPS,
324 WNI_CFG_FIXED_RATE_11A_DUP_24_MBPS,
325 WNI_CFG_FIXED_RATE_11A_DUP_36_MBPS,
326 WNI_CFG_FIXED_RATE_11A_DUP_48_MBPS,
327 WNI_CFG_FIXED_RATE_11A_DUP_54_MBPS,
328 WNI_CFG_FIXED_RATE_11A_80MHZ_DUP_6_MBPS,
329 WNI_CFG_FIXED_RATE_11A_80MHZDUP_9_MBPS,
330 WNI_CFG_FIXED_RATE_11A_80MHZ_DUP_12_MBPS,
331 WNI_CFG_FIXED_RATE_11A_80MHZ_DUP_18_MBPS,
332 WNI_CFG_FIXED_RATE_11A_80MHZ_DUP_24_MBPS,
333 WNI_CFG_FIXED_RATE_11A_80MHZ_DUP_36_MBPS,
334 WNI_CFG_FIXED_RATE_11A_80MHZ_DUP_48_MBPS,
335 WNI_CFG_FIXED_RATE_11A_80MHZ_DUP_54_MBPS,
336 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_6_5_MBPS,
337 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_13_MBPS,
338 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_19_5_MBPS,
339 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_26_MBPS,
340 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_39_MBPS,
341 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_52_MBPS,
342 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_58_5_MBPS,
343 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_65_MBPS,
344 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_SG_7_2_MBPS,
345 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_SG_14_4_MBPS,
346 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_SG_21_7_MBPS,
347 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_SG_28_9_MBPS,
348 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_SG_43_3_MBPS,
349 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_SG_57_8_MBPS,
350 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_SG_65_MBPS,
351 WNI_CFG_LDPC_FIXED_RATE_MCS_1NSS_MM_SG_72_2_MBPS, /* 210 */
352 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_13_5_MBPS,
353 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_27_MBPS,
354 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_40_5_MBPS,
355 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_54_MBPS,
356 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_81_MBPS,
357 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_108_MBPS,
358 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_121_5_MBPS,
359 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_135_MBPS,
360 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_15_MBPS,
361 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_30_MBPS,
362 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_45_MBPS,
363 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_60_MBPS,
364 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_90_MBPS,
365 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_120_MBPS,
366 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_135_MBPS,
367 WNI_CFG_LDPC_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_150_MBPS
368} eCfgFixedRateCfgType;
369
370/* Legacy IDX based rate table */
371typedef struct
372{
373 v_U16_t legacy_rate_index;
374 v_U32_t legacy_rate;
375} supported_legacy_rate_t;
376static const supported_legacy_rate_t legacy_rate[] =
377{
378/* IDX Rate, 100kbps */
379 {2, 10},
380 {4, 20},
381 {11, 55},
382 {12, 60},
383 {18, 90},
384 {24, 120},
385 {36, 180},
386 {48, 240},
387 {66, 330},
388 {72, 360},
389 {96, 480},
390 {108, 540}
391};
392
393/* 11N MCS based rate table */
394typedef struct
395{
396 v_U8_t mcs_index_11n;
397 v_U32_t rate_11n[4];
398} supported_11n_rate_t;
399static const supported_11n_rate_t mcs_rate_11n[] =
400{
401/* MCS L20 L40 S20 S40 */
402 {0, {65, 135, 72, 150}},
403 {1, {130, 270, 144, 300}},
404 {2, {195, 405, 217, 450}},
405 {3, {260, 540, 289, 600}},
406 {4, {390, 810, 433, 900}},
407 {5, {520, 1080, 578, 1200}},
408 {6, {585, 1215, 650, 1350}},
409 {7, {650, 1350, 722, 1500}}
410};
411
412/* 11AC MCS based rate table */
413typedef struct
414{
415 v_U8_t mcs_index_11ac;
416 v_U16_t cb80_rate_11ac[2];
417 v_U16_t cb40_rate_11ac[2];
418 v_U16_t cb20_rate_11ac[2];
419} supported_11ac_rate_t;
420static const supported_11ac_rate_t mcs_rate_11ac[] =
421{
422/* MCS L80 S80 L40 S40 L20 S40*/
423 {0, {293, 325}, {135, 150}, {65, 72}},
424 {1, {585, 650}, {270, 300}, {130, 144}},
425 {2, {878, 975}, {405, 450}, {195, 217}},
426 {3, {1170, 1300}, {540, 600}, {260, 289}},
427 {4, {1755, 1950}, {810, 900}, {390, 433}},
428 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
429 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
430 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
431 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
432 {9, {3900, 4333}, {1800, 2000}, {860, 867}}
433};
434
435typedef struct
436{
437 eCfgFixedRateCfgType eRateCfg;
438 v_U16_t rate;
439} rate_cfg_item_mapping_t;
440
441static rate_cfg_item_mapping_t legacy_rate_mapping[] =
442{
443 {WNI_CFG_FIXED_RATE_11B_LONG_1_MBPS, 10},
444 {WNI_CFG_FIXED_RATE_11B_LONG_2_MBPS, 20},
445 {WNI_CFG_FIXED_RATE_11B_LONG_5_5_MBPS, 55},
446 {WNI_CFG_FIXED_RATE_11B_LONG_11_MBPS, 110},
447 {WNI_CFG_FIXED_RATE_11A_6_MBPS, 60},
448 {WNI_CFG_FIXED_RATE_11A_9_MBPS, 90},
449 {WNI_CFG_FIXED_RATE_11A_12_MBPS, 120},
450 {WNI_CFG_FIXED_RATE_11A_18_MBPS, 180},
451 {WNI_CFG_FIXED_RATE_11A_24_MBPS, 240},
452 {WNI_CFG_FIXED_RATE_11A_36_MBPS, 360},
453 {WNI_CFG_FIXED_RATE_11A_48_MBPS, 480},
454 {WNI_CFG_FIXED_RATE_11A_54_MBPS, 540}
455};
456static rate_cfg_item_mapping_t n_l20_rate_mapping[] =
457{
458 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_6_5_MBPS, 65},
459 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_13_MBPS, 130},
460 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_19_5_MBPS, 195},
461 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_26_MBPS, 260},
462 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_39_MBPS, 390},
463 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_52_MBPS, 520},
464 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_58_5_MBPS, 585},
465 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_65_MBPS, 650}
466};
467static rate_cfg_item_mapping_t n_s20_rate_mapping[] =
468{
469 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_7_2_MBPS, 72},
470 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_14_4_MBPS, 144},
471 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_21_7_MBPS, 217},
472 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_28_9_MBPS, 289},
473 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_43_3_MBPS, 433},
474 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_57_8_MBPS, 578},
475 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_65_MBPS, 650},
476 {WNI_CFG_FIXED_RATE_MCS_1NSS_MM_SG_72_2_MBPS, 722}
477};
478static rate_cfg_item_mapping_t n_l40_rate_mapping[] =
479{
480 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_13_5_MBPS, 135},
481 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_27_MBPS, 270},
482 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_40_5_MBPS, 405},
483 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_54_MBPS, 540},
484 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_81_MBPS, 810},
485 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_108_MBPS, 1080},
486 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_121_5_MBPS, 1215},
487 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_135_MBPS, 1350}
488};
489static rate_cfg_item_mapping_t n_s40_rate_mapping[] =
490{
491 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_15_MBPS, 150},
492 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_30_MBPS, 300},
493 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_45_MBPS, 450},
494 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_60_MBPS, 600},
495 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_90_MBPS, 900},
496 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_120_MBPS, 1200},
497 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_135_MBPS, 1350},
498 {WNI_CFG_FIXED_RATE_MCS_40MHZ_1NSS_MM_SG_150_MBPS, 1500}
499};
500
501#ifdef WLAN_FEATURE_11AC
502static rate_cfg_item_mapping_t ac_l20_rate_mapping[] =
503{
504 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_6_5MBPS, 65},
505 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_13MBPS, 130},
506 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_19_5MBPS, 195},
507 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_26MBPS, 260},
508 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_39MBPS, 390},
509 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_52MBPS, 520},
510 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_58_5MBPS, 585},
511 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_65MBPS, 650},
512 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_78MBPS, 780},
513 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_NGI_86_5_MBPS, 865}
514};
515static rate_cfg_item_mapping_t ac_s20_rate_mapping[] =
516{
517 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_7_2222MBPS, 72},
518 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_14_444MBPS, 144},
519 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_21_667MBPS, 217},
520 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_28_889MBPS, 289},
521 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_43_333MBPS, 433},
522 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_57_778MBPS, 578},
523 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_65MBPS, 650},
524 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_72_222MBPS, 722},
525 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_86_667MBPS, 867},
526 {WNI_CFG_LDPC_FIXED_RATE_VHT_SIMO_CB_SGI_96_1_MBPS, 961}
527};
528static rate_cfg_item_mapping_t ac_l40_rate_mapping[] =
529{
530 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_13_5MBPS, 135},
531 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_27MBPS, 270},
532 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_40_5MBPS, 405},
533 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_54MBPS, 540},
534 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_81MBPS, 810},
535 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_108MBPS, 1080},
536 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_121_5MBPS, 1215},
537 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_135MBPS, 1350},
538 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_162MBPS, 1620},
539 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_NGI_180MBPS, 1800}
540};
541static rate_cfg_item_mapping_t ac_s40_rate_mapping[] =
542{
543 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_15MBPS, 150},
544 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_30MBPS, 300},
545 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_45MBPS, 450},
546 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_60MBPS, 600},
547 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_90MBPS, 900},
548 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_120MBPS, 1200},
549 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_135MBPS, 1350},
550 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_150MBPS, 1500},
551 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_180MBPS, 1800},
552 {WNI_CFG_LDPC_FIXED_RATE_VHT_40MHZ_SIMO_CB_SGI_200MBPS, 2000}
553};
554static rate_cfg_item_mapping_t ac_l80_rate_mapping[] =
555{
556 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_29_25MBPS, 293},
557 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_58_5MBPS, 585},
558 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_87_75MBPS, 878},
559 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_117MBPS, 1170},
560 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_175_5MBPS, 1755},
561 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_234MBPS, 2340},
562 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_263_25MBPS, 2633},
563 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_292_5MBPS, 2925},
564 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_351MBPS, 3510},
565 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_NGI_390MBPS, 3900}
566};
567static rate_cfg_item_mapping_t ac_s80_rate_mapping[] =
568{
569 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_32_5MBPS, 325},
570 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_65MBPS, 650},
571 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_97_5MBPS, 975},
572 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_130MBPS, 1300},
573 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_195MBPS, 1950},
574 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_260MBPS, 2600},
575 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_292_5MBPS, 2925},
576 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_325MBPS, 3250},
577 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_390MBPS, 3900},
578 {WNI_CFG_LDPC_FIXED_RATE_VHT_80MHZ_SIMO_CB_SGI_433_33MBPS, 4333}
579};
580#endif /* WLAN_FEATURE_11AC */
581
582typedef enum
583{
584 RATE_CFG_RATE_LEGACY,
585 RATE_CFG_RATE_11N_MCS_LGI_20,
586 RATE_CFG_RATE_11N_MCS_SGI_20,
587 RATE_CFG_RATE_11N_MCS_LGI_40,
588 RATE_CFG_RATE_11N_MCS_SGI_40,
589 RATE_CFG_RATE_11AC_MCS_LGI_20,
590 RATE_CFG_RATE_11AC_MCS_SGI_20,
591 RATE_CFG_RATE_11AC_MCS_LGI_40,
592 RATE_CFG_RATE_11AC_MCS_SGI_40,
593 RATE_CFG_RATE_11AC_MCS_LGI_80,
594 RATE_CFG_RATE_11AC_MCS_SGI_80
595} rate_cfg_supported_rate_t;
596
597typedef enum
598{
599 RATE_CFG_RATE_11AC_MAX_MCS_7,
600 RATE_CFG_RATE_11AC_MAX_MCS_8,
601 RATE_CFG_RATE_11AC_MAX_MCS_9
602} rate_cfg_11ac_max_mcs_t;
603
604typedef enum
605{
606 RATE_CFG_RATE_BW_20,
607 RATE_CFG_RATE_BW_40,
608 RATE_CFG_RATE_BW_80
609} rate_cfg_supported_bw_t;
610
611typedef enum
612{
613 RATE_CFG_RATE_GI_LONG,
614 RATE_CFG_RATE_GI_SHORT
615} rate_cfg_gi_t;
616
Jeff Johnson295189b2012-06-20 16:38:30 -0700617/*---------------------------------------------------------------------------
618 * Function definitions
619 *-------------------------------------------------------------------------*/
620/**---------------------------------------------------------------------------
621
622 \brief hdd_hostapd_open() - HDD Open function for hostapd interface
623
624 This is called in response to ifconfig up
625
626 \param - dev Pointer to net_device structure
627
628 \return - 0 for success non-zero for failure
629
630 --------------------------------------------------------------------------*/
631int hdd_hostapd_open (struct net_device *dev)
632{
633 ENTER();
634
635 //Turn ON carrier state
636 netif_carrier_on(dev);
637 //Enable all Tx queues
638 netif_tx_start_all_queues(dev);
639
640 EXIT();
641 return 0;
642}
643/**---------------------------------------------------------------------------
644
645 \brief hdd_hostapd_stop() - HDD stop function for hostapd interface
646
647 This is called in response to ifconfig down
648
649 \param - dev Pointer to net_device structure
650
651 \return - 0 for success non-zero for failure
652
653 --------------------------------------------------------------------------*/
654int hdd_hostapd_stop (struct net_device *dev)
655{
656 ENTER();
657
658 //Stop all tx queues
659 netif_tx_disable(dev);
660
661 //Turn OFF carrier state
662 netif_carrier_off(dev);
663
664 EXIT();
665 return 0;
666}
667/**---------------------------------------------------------------------------
668
669 \brief hdd_hostapd_uninit() - HDD uninit function
670
671 This is called during the netdev unregister to uninitialize all data
672associated with the device
673
674 \param - dev Pointer to net_device structure
675
676 \return - void
677
678 --------------------------------------------------------------------------*/
679static void hdd_hostapd_uninit (struct net_device *dev)
680{
681 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
682
683 ENTER();
684
685 if (pHostapdAdapter && pHostapdAdapter->pHddCtx)
686 {
687 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter);
688
689 /* after uninit our adapter structure will no longer be valid */
690 pHostapdAdapter->dev = NULL;
691 }
692
693 EXIT();
694}
695
696
697/**============================================================================
698 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
699 transmitting packets. There are 2 versions of this function. One that uses
700 locked queue and other that uses lockless queues. Both have been retained to
701 do some performance testing
702 @param skb : [in] pointer to OS packet (sk_buff)
703 @param dev : [in] pointer to Libra network device
704
705 @return : NET_XMIT_DROP if packets are dropped
706 : NET_XMIT_SUCCESS if packet is enqueued succesfully
707 ===========================================================================*/
708int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
709{
710 return 0;
711}
712int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
713{
714 return 0;
715}
716
717int hdd_hostapd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
718{
719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
720 hdd_priv_data_t priv_data;
721 tANI_U8 *command = NULL;
722 int ret = 0;
723
724 if (NULL == pAdapter)
725 {
726 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700727 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700728 ret = -ENODEV;
729 goto exit;
730 }
731
Jeff Johnsone7245742012-09-05 17:12:55 -0700732 if ((!ifr) || (!ifr->ifr_data))
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 {
734 ret = -EINVAL;
735 goto exit;
736 }
737
738 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(hdd_priv_data_t)))
739 {
740 ret = -EFAULT;
741 goto exit;
742 }
743
744 command = kmalloc(priv_data.total_len, GFP_KERNEL);
745 if (!command)
746 {
747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700748 "%s: failed to allocate memory\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 ret = -ENOMEM;
750 goto exit;
751 }
752
753 if (copy_from_user(command, priv_data.buf, priv_data.total_len))
754 {
755 ret = -EFAULT;
756 goto exit;
757 }
758
759 if ((SIOCDEVPRIVATE + 1) == cmd)
760 {
761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
762 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
763
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 if(strncmp(command, "P2P_SET_NOA", 11) == 0 )
765 {
766 hdd_setP2pNoa(dev, command);
767 }
768 else if( strncmp(command, "P2P_SET_PS", 10) == 0 )
769 {
770 hdd_setP2pOpps(dev, command);
771 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700772
773 /*
774 command should be a string having format
775 SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces>
776 */
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700777 if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700778 {
779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700780 " Received Command to Set Preferred Channels for SAP in %s", __func__);
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700781
Mahesh Kumar Kalikot Veetilb10436b2013-02-07 12:31:28 -0800782 ret = sapSetPreferredChannel(command);
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700783 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 }
785exit:
786 if (command)
787 {
788 kfree(command);
789 }
790 return ret;
791}
792
793/**---------------------------------------------------------------------------
794
795 \brief hdd_hostapd_set_mac_address() -
796 This function sets the user specified mac address using
797 the command ifconfig wlanX hw ether <mac adress>.
798
799 \param - dev - Pointer to the net device.
800 - addr - Pointer to the sockaddr.
801 \return - 0 for success, non zero for failure
802
803 --------------------------------------------------------------------------*/
804
805static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
806{
807 struct sockaddr *psta_mac_addr = addr;
808 ENTER();
809 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
810 EXIT();
811 return 0;
812}
813void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
814{
815 struct net_device *dev = (struct net_device *)usrDataForCallback;
816 v_BYTE_t we_custom_event[64];
817 union iwreq_data wrqu;
818#ifdef DISABLE_CONCURRENCY_AUTOSAVE
819 VOS_STATUS vos_status;
820 hdd_adapter_t *pHostapdAdapter;
821 hdd_ap_ctx_t *pHddApCtx;
822#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
823
824 /* event_name space-delimiter driver_module_name */
825 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
826 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
827 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
828
829 ENTER();
830
831#ifdef DISABLE_CONCURRENCY_AUTOSAVE
832 if (vos_concurrent_sessions_running())
833 {
834 /*
835 This timer routine is going to be called only when AP
836 persona is up.
837 If there are concurrent sessions running we do not want
838 to shut down the Bss.Instead we run the timer again so
839 that if Autosave is enabled next time and other session
840 was down only then we bring down AP
841 */
842 pHostapdAdapter = netdev_priv(dev);
843 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
844 vos_status = vos_timer_start(
845 &pHddApCtx->hdd_ap_inactivity_timer,
846 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
847 * 1000);
848 if (!VOS_IS_STATUS_SUCCESS(vos_status))
849 {
850 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
851 }
852 EXIT();
853 return;
854 }
855#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
856 memset(&we_custom_event, '\0', sizeof(we_custom_event));
857 memcpy(&we_custom_event, autoShutEvent, event_len);
858
859 memset(&wrqu, 0, sizeof(wrqu));
860 wrqu.data.length = event_len;
861
862 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
863 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
864
865 EXIT();
866}
867
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800868VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
869{
870 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
871 ptSapContext pSapCtx = NULL;
872 eHalStatus halStatus = eHAL_STATUS_FAILURE;
873 v_PVOID_t hHal = NULL;
874
875 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
876 "%s: UPDATE Beacon Params", __func__);
877
878 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
879 pSapCtx = VOS_GET_SAP_CB(pVosContext);
880 if ( NULL == pSapCtx )
881 {
882 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
883 "%s: Invalid SAP pointer from pvosGCtx", __func__);
884 return VOS_STATUS_E_FAULT;
885 }
886
887 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
888 if ( NULL == hHal ){
889 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
890 "%s: Invalid HAL pointer from pvosGCtx", __func__);
891 return VOS_STATUS_E_FAULT;
892 }
893 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
894 if(halStatus == eHAL_STATUS_FAILURE ){
895 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
896 "%s: Failed to update Beacon Params", __func__);
897 return VOS_STATUS_E_FAILURE;
898 }
899 }
900 return VOS_STATUS_SUCCESS;
901}
902
903void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
904{
905 v_U8_t staId = 0;
906 struct net_device *dev;
907 dev = (struct net_device *)usrDataForCallback;
908
909 hddLog(LOGE, FL("Clearing all the STA entry....\n"));
910 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
911 {
912 if ( pHostapdAdapter->aStaInfo[staId].isUsed &&
913 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
914 {
915 //Disconnect all the stations
916 hdd_softap_sta_disassoc(pHostapdAdapter, &pHostapdAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
917 }
918 }
919}
920
921static int hdd_stop_p2p_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
922{
923 struct net_device *dev;
924 VOS_STATUS status = VOS_STATUS_SUCCESS;
925 dev = (struct net_device *)usrDataForCallback;
926 ENTER();
927 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
928 {
929 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
930 {
931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting P2P link!!!!!!"));
932 }
933 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
934 }
935 EXIT();
936 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
937}
Jeff Johnson295189b2012-06-20 16:38:30 -0700938
939VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
940{
941 hdd_adapter_t *pHostapdAdapter;
942 hdd_ap_ctx_t *pHddApCtx;
943 hdd_hostapd_state_t *pHostapdState;
944 struct net_device *dev;
945 eSapHddEvent sapEvent;
946 union iwreq_data wrqu;
947 v_BYTE_t *we_custom_event_generic = NULL;
948 int we_event = 0;
949 int i = 0;
950 v_U8_t staId;
951 VOS_STATUS vos_status;
952 v_BOOL_t bWPSState;
953 v_BOOL_t bApActive = FALSE;
954 v_BOOL_t bAuthRequired = TRUE;
955 tpSap_AssocMacAddr pAssocStasArray = NULL;
956 char unknownSTAEvent[IW_CUSTOM_MAX+1];
957 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
958 v_BYTE_t we_custom_start_event[64];
959 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800960 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -0800961 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsone3a76682013-04-03 10:21:46 -0700962 struct iw_michaelmicfailure msg;
Jeff Johnson295189b2012-06-20 16:38:30 -0700963
964 dev = (struct net_device *)usrDataForCallback;
965 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudi921f24f2013-07-24 12:53:33 +0530966
967 if ((NULL == pHostapdAdapter) ||
968 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
969 {
970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
971 "invalid adapter or adapter has invalid magic");
972 return eHAL_STATUS_FAILURE;
973 }
974
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
976 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
977 sapEvent = pSapEvent->sapHddEventCode;
978 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800979 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700980
981 switch(sapEvent)
982 {
983 case eSAP_START_BSS_EVENT :
984 hddLog(LOG1, FL("BSS configured status = %s, channel = %lu, bc sta Id = %d\n"),
985 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
986 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
987 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
988
989 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
990 vos_status = vos_event_set(&pHostapdState->vosEvent);
991
992 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
993 {
994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!\n"));
995 goto stopbss;
996 }
997 else
998 {
999 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
1000 //@@@ need wep logic here to set privacy bit
1001 hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
1002 }
1003
1004 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1005 {
1006 // AP Inactivity timer init and start
1007 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
1008 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
1009 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1010 hddLog(LOGE, FL("Failed to init AP inactivity timer\n"));
1011
1012 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1013 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1014 hddLog(LOGE, FL("Failed to init AP inactivity timer\n"));
1015
1016 }
1017 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
1018 pHostapdState->bssState = BSS_START;
1019
1020 // Send current operating channel of SoftAP to BTC-ES
1021 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
1022
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 //Check if there is any group key pending to set.
1024 if( pHddApCtx->groupKey.keyLength )
1025 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001026 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1028 &pHddApCtx->groupKey ) )
1029 {
1030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1031 "%s: WLANSAP_SetKeySta failed", __func__);
1032 }
1033 pHddApCtx->groupKey.keyLength = 0;
1034 }
1035 else if ( pHddApCtx->wepKey[0].keyLength )
1036 {
1037 int i=0;
1038 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
1039 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001040 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1042 &pHddApCtx->wepKey[i] ) )
1043 {
1044 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1045 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
1046 }
1047 pHddApCtx->wepKey[i].keyLength = 0;
1048 }
1049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
1051 startBssEvent = "SOFTAP.enabled";
1052 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
1053 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
1054 memset(&wrqu, 0, sizeof(wrqu));
1055 wrqu.data.length = strlen(startBssEvent);
1056 we_event = IWEVCUSTOM;
1057 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalliaa0e5c02013-03-21 14:25:04 -07001058 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 break; //Event will be sent after Switch-Case stmt
1060
1061 case eSAP_STOP_BSS_EVENT:
1062 hddLog(LOG1, FL("BSS stop status = %s\n"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1063 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1064
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001065 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001066 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001067
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 goto stopbss;
1070 case eSAP_STA_SET_KEY_EVENT:
1071 //TODO: forward the message to hostapd once implementtation is done for now just print
1072 hddLog(LOG1, FL("SET Key: configured status = %s\n"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
1073 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1074 return VOS_STATUS_SUCCESS;
1075 case eSAP_STA_DEL_KEY_EVENT:
1076 //TODO: forward the message to hostapd once implementtation is done for now just print
1077 hddLog(LOG1, FL("Event received %s\n"),"eSAP_STA_DEL_KEY_EVENT");
1078 return VOS_STATUS_SUCCESS;
1079 case eSAP_STA_MIC_FAILURE_EVENT:
1080 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 memset(&msg, '\0', sizeof(msg));
1082 msg.src_addr.sa_family = ARPHRD_ETHER;
Madan Mohan Koyyalamudi3d322162012-12-13 15:13:41 -08001083 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001085 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 msg.flags = IW_MICFAILURE_GROUP;
1087 else
1088 msg.flags = IW_MICFAILURE_PAIRWISE;
1089 memset(&wrqu, 0, sizeof(wrqu));
1090 wrqu.data.length = sizeof(msg);
1091 we_event = IWEVMICHAELMICFAILURE;
1092 we_custom_event_generic = (v_BYTE_t *)&msg;
1093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 /* inform mic failure to nl80211 */
1095 cfg80211_michael_mic_failure(dev,
1096 pSapEvent->sapevt.
1097 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001098 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 NL80211_KEYTYPE_GROUP :
1100 NL80211_KEYTYPE_PAIRWISE),
1101 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1102 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1103 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 break;
1105
1106 case eSAP_STA_ASSOC_EVENT:
1107 case eSAP_STA_REASSOC_EVENT:
1108 wrqu.addr.sa_family = ARPHRD_ETHER;
1109 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Madan Mohan Koyyalamudi3d322162012-12-13 15:13:41 -08001110 sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 hddLog(LOG1, " associated "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(wrqu.addr.sa_data));
1112 we_event = IWEVREGISTERED;
1113
1114 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1115
1116 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1117 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1118 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1119 {
1120 bAuthRequired = FALSE;
1121 }
1122
1123 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
1124 {
1125 hdd_softap_RegisterSTA( pHostapdAdapter,
1126 TRUE,
1127 pHddApCtx->uPrivacy,
1128 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1129 0,
1130 0,
1131 (v_MACADDR_t *)wrqu.addr.sa_data,
1132 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
1133 }
1134 else
1135 {
1136 hdd_softap_RegisterSTA( pHostapdAdapter,
1137 FALSE,
1138 pHddApCtx->uPrivacy,
1139 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1140 0,
1141 0,
1142 (v_MACADDR_t *)wrqu.addr.sa_data,
1143 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
Amar Singhal28cd9c12013-05-03 16:11:42 -07001144 }
1145
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 // Stop AP inactivity timer
1147 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1148 {
1149 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1150 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1151 hddLog(LOGE, FL("Failed to start AP inactivity timer\n"));
1152 }
Gopichand Nakkalab95de072013-07-09 23:31:37 +05301153 if (VOS_TIMER_STATE_RUNNING ==
1154 vos_timer_getCurrentState(&pHddCtx->hdd_p2p_go_conn_is_in_progress))
1155 {
1156 vos_timer_stop(&pHddCtx->hdd_p2p_go_conn_is_in_progress);
1157 }
Sameer Thalappileda904a2013-02-19 17:23:33 -08001158#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001159 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1160 {
1161 wake_unlock(&pHddCtx->sap_wake_lock);
1162 }
Amar Singhal28cd9c12013-05-03 16:11:42 -07001163 wake_lock_timeout(&pHddCtx->sap_wake_lock, msecs_to_jiffies(HDD_SAP_WAKE_LOCK_DURATION));
Sameer Thalappileda904a2013-02-19 17:23:33 -08001164#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001165#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1166 {
1167 struct station_info staInfo;
1168 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1169
1170 memset(&staInfo, 0, sizeof(staInfo));
1171 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1172 {
1173 staInfo.assoc_req_ies =
1174 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
1175 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001176#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001177 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
1178#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 cfg80211_new_sta(dev,
1180 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
1181 &staInfo, GFP_KERNEL);
1182 }
1183 else
1184 {
1185 hddLog(LOGE, FL(" Assoc Ie length is too long \n"));
1186 }
1187 }
1188#endif
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08001189 pScanInfo = &pHddCtx->scan_info;
1190 // Lets do abort scan to ensure smooth authentication for client
1191 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1192 {
Madan Mohan Koyyalamudi78f17402013-06-13 14:47:55 +05301193 hdd_abort_mac_scan(pHddCtx, pHostapdAdapter->sessionId);
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08001194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001195
1196 break;
1197 case eSAP_STA_DISASSOC_EVENT:
1198 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Madan Mohan Koyyalamudi3d322162012-12-13 15:13:41 -08001199 sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(wrqu.addr.sa_data));
1201 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1202 hddLog(LOG1," User initiated disassociation");
1203 else
1204 hddLog(LOG1," MAC initiated disassociation");
1205 we_event = IWEVEXPIRED;
1206 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1207 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1208 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 return VOS_STATUS_E_FAILURE;
1211 }
1212 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1213
1214 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1215 {
1216 spin_lock_bh( &pHostapdAdapter->staInfo_lock );
1217 // Start AP inactivity timer if no stations associated with it
1218 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1219 {
1220 if (pHostapdAdapter->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
1221 {
1222 bApActive = TRUE;
1223 break;
1224 }
1225 }
1226 spin_unlock_bh( &pHostapdAdapter->staInfo_lock );
1227
1228 if (bApActive == FALSE)
1229 {
1230 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1231 {
1232 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1233 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1234 hddLog(LOGE, FL("Failed to init AP inactivity timer\n"));
1235 }
1236 else
1237 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1238 }
1239 }
Gopichand Nakkalab95de072013-07-09 23:31:37 +05301240 if (VOS_TIMER_STATE_RUNNING ==
1241 vos_timer_getCurrentState(&pHddCtx->hdd_p2p_go_conn_is_in_progress))
1242 {
1243 vos_timer_stop(&pHddCtx->hdd_p2p_go_conn_is_in_progress);
1244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001245#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1246 cfg80211_del_sta(dev,
1247 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1248 GFP_KERNEL);
1249#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001250 //Update the beacon Interval if it is P2P GO
1251 hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 break;
1253 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1254 {
1255 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1256 union iwreq_data wreq;
1257
1258 down(&pHddApCtx->semWpsPBCOverlapInd);
1259 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1260
1261 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1262 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1263
1264 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
1265 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
1266 memset(&wreq, 0, sizeof(wreq));
1267 wreq.data.length = strlen(message); // This is length of message
1268 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1269
1270 return VOS_STATUS_SUCCESS;
1271 }
1272 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1273 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1274 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1275 { // List of associated stations
1276 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1277 {
1278 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1279 i+1,
1280 pAssocStasArray->assocId,
1281 pAssocStasArray->staId,
1282 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1283 pAssocStasArray++;
1284 }
1285 }
1286 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
1287 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 case eSAP_INDICATE_MGMT_FRAME:
1289 hdd_indicateMgmtFrame( pHostapdAdapter,
1290 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
1291 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
1292 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NGde0b4112013-01-19 12:27:36 +05301293 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 return VOS_STATUS_SUCCESS;
1295 case eSAP_REMAIN_CHAN_READY:
1296 hdd_remainChanReadyHandler( pHostapdAdapter );
1297 return VOS_STATUS_SUCCESS;
1298 case eSAP_SEND_ACTION_CNF:
1299 hdd_sendActionCnf( pHostapdAdapter,
1300 ( eSAP_STATUS_SUCCESS ==
1301 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1302 TRUE : FALSE );
1303 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 case eSAP_UNKNOWN_STA_JOIN:
1305 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1306 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1307 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1308 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1309 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1310 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1311 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1312 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1313 wrqu.data.pointer = unknownSTAEvent;
1314 wrqu.data.length = strlen(unknownSTAEvent);
1315 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
1316 hddLog(LOG1,"%s\n", unknownSTAEvent);
1317 break;
1318
1319 case eSAP_MAX_ASSOC_EXCEEDED:
1320 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1321 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1322 " one or more devices to enable the new device connection",
1323 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1324 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1325 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1326 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1327 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1328 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1329 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1330 wrqu.data.pointer = maxAssocExceededEvent;
1331 wrqu.data.length = strlen(maxAssocExceededEvent);
1332 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
1333 hddLog(LOG1,"%s\n", maxAssocExceededEvent);
1334 break;
1335 case eSAP_STA_ASSOC_IND:
1336 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001337
1338 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
1339 hddLog(LOG1, FL(" Disconnecting all the P2P Clients....\n"));
1340 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1341 return VOS_STATUS_SUCCESS;
1342
1343 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
1344 hdd_stop_p2p_link(pHostapdAdapter, usrDataForCallback);
1345 return VOS_STATUS_SUCCESS;
1346
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 default:
1348 hddLog(LOG1,"SAP message is not handled\n");
1349 goto stopbss;
1350 return VOS_STATUS_SUCCESS;
1351 }
1352 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1353 return VOS_STATUS_SUCCESS;
1354
1355stopbss :
1356 {
1357 v_BYTE_t we_custom_event[64];
1358 char *stopBssEvent = "STOP-BSS.response";//17
1359 int event_len = strlen(stopBssEvent);
1360
1361 hddLog(LOG1, FL("BSS stop status = %s"),
1362 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1363 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1364
1365 /* Change the BSS state now since, as we are shutting things down,
1366 * we don't want interfaces to become re-enabled */
1367 pHostapdState->bssState = BSS_STOP;
1368
Gopichand Nakkala5081f9e2013-05-27 13:55:40 +05301369 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1370 {
1371 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1372 {
1373 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1374 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1375 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1376 }
1377
1378 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1379 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1380 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1381 }
1382
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 /* Stop the pkts from n/w stack as we are going to free all of
1384 * the TX WMM queues for all STAID's */
1385 hdd_hostapd_stop(dev);
1386
1387 /* reclaim all resources allocated to the BSS */
1388 hdd_softap_stop_bss(pHostapdAdapter);
1389
Amar Singhald2b18102013-03-05 16:16:54 -08001390 /* once the event is set, structure dev/pHostapdAdapter should
1391 * not be touched since they are now subject to being deleted
1392 * by another thread */
1393 if (eSAP_STOP_BSS_EVENT == sapEvent)
1394 vos_event_set(&pHostapdState->vosEvent);
1395
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 /* notify userspace that the BSS has stopped */
1397 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1398 memcpy(&we_custom_event, stopBssEvent, event_len);
1399 memset(&wrqu, 0, sizeof(wrqu));
1400 wrqu.data.length = event_len;
1401 we_event = IWEVCUSTOM;
1402 we_custom_event_generic = we_custom_event;
1403 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalliaa0e5c02013-03-21 14:25:04 -07001404 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 }
1406 return VOS_STATUS_SUCCESS;
1407}
1408int hdd_softap_unpackIE(
1409 tHalHandle halHandle,
1410 eCsrEncryptionType *pEncryptType,
1411 eCsrEncryptionType *mcEncryptType,
1412 eCsrAuthType *pAuthType,
1413 u_int16_t gen_ie_len,
1414 u_int8_t *gen_ie )
1415{
1416 tDot11fIERSN dot11RSNIE;
1417 tDot11fIEWPA dot11WPAIE;
1418
1419 tANI_U8 *pRsnIe;
1420 tANI_U16 RSNIeLen;
1421
1422 if (NULL == halHandle)
1423 {
1424 hddLog(LOGE, FL("Error haHandle returned NULL\n"));
1425 return -EINVAL;
1426 }
1427
1428 // Validity checks
1429 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1430 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1431 return -EINVAL;
1432 // Type check
1433 if ( gen_ie[0] == DOT11F_EID_RSN)
1434 {
1435 // Validity checks
1436 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1437 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1438 {
1439 return VOS_STATUS_E_FAILURE;
1440 }
1441 // Skip past the EID byte and length byte
1442 pRsnIe = gen_ie + 2;
1443 RSNIeLen = gen_ie_len - 2;
1444 // Unpack the RSN IE
1445 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1446 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1447 pRsnIe,
1448 RSNIeLen,
1449 &dot11RSNIE);
1450 // Copy out the encryption and authentication types
1451 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001452 __func__, dot11RSNIE.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 hddLog(LOG1, FL("%s: authentication suite count: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001454 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 /*Here we have followed the apple base code,
1456 but probably I suspect we can do something different*/
1457 //dot11RSNIE.akm_suite_count
1458 // Just translate the FIRST one
1459 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1460 //dot11RSNIE.pwise_cipher_suite_count
1461 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1462 //dot11RSNIE.gp_cipher_suite_count
1463 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1464 // Set the PMKSA ID Cache for this interface
1465
1466 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1467 } else
1468 if (gen_ie[0] == DOT11F_EID_WPA)
1469 {
1470 // Validity checks
1471 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1472 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1473 {
1474 return VOS_STATUS_E_FAILURE;
1475 }
1476 // Skip past the EID byte and length byte - and four byte WiFi OUI
1477 pRsnIe = gen_ie + 2 + 4;
1478 RSNIeLen = gen_ie_len - (2 + 4);
1479 // Unpack the WPA IE
1480 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1481 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1482 pRsnIe,
1483 RSNIeLen,
1484 &dot11WPAIE);
1485 // Copy out the encryption and authentication types
1486 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001487 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 hddLog(LOG1, FL("%s: WPA authentication suite count: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001489 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 //dot11WPAIE.auth_suite_count
1491 // Just translate the FIRST one
1492 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1493 //dot11WPAIE.unicast_cipher_count
1494 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1495 //dot11WPAIE.unicast_cipher_count
1496 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
1497 }
1498 else
1499 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001500 hddLog(LOGW, FL("%s: gen_ie[0]: %d\n"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 return VOS_STATUS_E_FAILURE;
1502 }
1503 return VOS_STATUS_SUCCESS;
1504}
Leo Changb77d2882013-08-22 14:59:44 -07001505
1506/**---------------------------------------------------------------------------
1507
1508 \brief hdd_hostapd_set_mc_rate_cb() -
1509
1510 This is called to notify associated stas information ready
1511
1512 \param - sapEvent Pointer to get associated stas event
1513 \param - apDriver SoftAP context
1514
1515 \return - none
1516
1517 --------------------------------------------------------------------------*/
1518void hdd_hostapd_set_mc_rate_cb
1519(
1520 tSap_Event *sapEvent,
1521 void *apDriver
1522)
1523{
1524 hdd_ap_ctx_t *apCtxt;
1525
1526 if ((NULL == apDriver) || (NULL == sapEvent))
1527 {
1528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1529 "%s : Invalid arguments", __func__);
1530 return;
1531 }
1532
1533 apCtxt = (hdd_ap_ctx_t *)apDriver;
1534
1535 /* there is a race condition that exists between this callback function
1536 and the caller since the caller could time out either before or
1537 while this code is executing. we'll assume the timeout hasn't
1538 occurred, but we'll verify that right before complete our work */
1539 if (SAP_GET_STAS_COOKIE == apCtxt->getStasCookie)
1540 {
1541 vos_mem_copy((void *)&apCtxt->getStasEventBuffer,
1542 (void *)sapEvent,
1543 sizeof(tSap_Event));
1544 complete(&apCtxt->sap_get_associated_stas_complete);
1545 }
1546 else
1547 {
1548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1549 "%s : Invalid cookie", __func__);
1550 }
1551 return;
1552}
1553
1554/**---------------------------------------------------------------------------
1555
1556 \brief hdd_hostapd_set_mc_rate_update
1557
1558 This is called to find rate and send cfg command to FW
1559
1560 \param - sapEvent Pointer to get associated stas event
1561 \param - pHostapdAdapter SoftAP Adapter Context
1562
1563 \return - int, 0 success
1564 negative fail
1565
1566 --------------------------------------------------------------------------*/
1567static int hdd_hostapd_set_mc_rate_update
1568(
1569 tSap_Event *sapEvent,
1570 hdd_adapter_t *pHostapdAdapter
1571)
1572{
1573 tHalHandle hHal;
1574 hdd_ap_ctx_t *apCtxt;
1575 tSap_AssocMacAddr *assocSta;
1576 rate_cfg_11ac_max_mcs_t supportedAcMaxMcs = RATE_CFG_RATE_11AC_MAX_MCS_7;
1577 rate_cfg_supported_bw_t bandWidth;
1578 rate_cfg_gi_t gi;
1579 rate_cfg_item_mapping_t *nMappingTable = NULL;
1580 rate_cfg_item_mapping_t *acMappingTable = NULL;
1581 v_U8_t stasLoop, ratesLoop;
1582 v_U8_t rateArrayOrder;
1583 v_U8_t mcsTable11n;
1584 v_U16_t targetCfgId = 0;
1585 v_U16_t targetCfgValue = 0;
1586 v_U16_t currentRate;
1587 v_U16_t combinedSupportMap = 0xFFFF;
1588 v_U16_t supportMap = 0x0000;
1589 v_U16_t supportedChannelCount = 0;
1590 v_U32_t legacyRates[SAP_LEGACY_RATE_COUNT];
1591 int rc = 0;
1592 tSirRetStatus cfdStat;
1593
1594 if ((NULL == pHostapdAdapter) || (NULL == sapEvent))
1595 {
1596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1597 "%s : Invalid arguments", __func__);
1598 return -1;
1599 }
1600
1601 apCtxt = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1602 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1604 "setMcRateCB NUM SAT %d, targetMCRate %d, current channel %d",
1605 sapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta,
1606 apCtxt->targetMCRate,
1607 apCtxt->operatingChannel);
1608
1609 if (!sapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta)
1610 {
1611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1612 "Not connected any STA yet");
1613 return -1;
1614 }
1615
1616 for (stasLoop = 0;
1617 stasLoop < sapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta;
1618 stasLoop++)
1619 {
1620 vos_mem_zero((v_U8_t *)legacyRates,
1621 SAP_LEGACY_RATE_COUNT * sizeof(legacyRates));
1622 rateArrayOrder = 0;
1623 mcsTable11n = 0;
1624 supportedChannelCount = 0;
1625 assocSta = sapEvent->sapevt.sapAssocStaListEvent.pAssocStas++;
1626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1627 "ASSOSID %d, OPM %d, nBM %d, SGI40 %d, SGI20 %d, S40 %d",
1628 assocSta->assocId,
1629 assocSta->supportedRates.opRateMode,
1630 assocSta->supportedRates.aniEnhancedRateBitmap,
1631 assocSta->ShortGI40Mhz,
1632 assocSta->ShortGI20Mhz,
1633 assocSta->Support40Mhz);
1634
1635 /* Legacy Rate */
1636 for (ratesLoop = 0; ratesLoop < SIR_NUM_11B_RATES; ratesLoop++)
1637 {
1638 currentRate = assocSta->supportedRates.llbRates[ratesLoop] &
1639 SAP_LEGACY_RATE_MASK;
1640
1641 /* To fix KW error report */
1642 if (SAP_LEGACY_RATE_COUNT <= rateArrayOrder)
1643 {
1644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1645 "%s, Invalid array Size, break", __func__);
1646 break;
1647 }
1648
1649 /* Make 100kbps order */
1650 legacyRates[rateArrayOrder] = (currentRate * 100) / 20;
1651 rateArrayOrder++;
1652 if (currentRate)
1653 {
1654 supportedChannelCount++;
1655 }
1656 }
1657 for (ratesLoop = 0; ratesLoop < SIR_NUM_11A_RATES; ratesLoop++)
1658 {
1659 currentRate = assocSta->supportedRates.llaRates[ratesLoop] &
1660 SAP_LEGACY_RATE_MASK;
1661 /* To fix KW error report */
1662 if (SAP_LEGACY_RATE_COUNT <= rateArrayOrder)
1663 {
1664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1665 "%s, Invalid array Size, break", __func__);
1666 break;
1667 }
1668
1669 /* Make 100kbps order */
1670 legacyRates[rateArrayOrder] = (currentRate * 100) / 20;
1671 rateArrayOrder++;
1672 if (currentRate)
1673 {
1674 supportedChannelCount++;
1675 }
1676 }
1677 if (supportedChannelCount)
1678 {
1679 for (ratesLoop = 0; ratesLoop < SAP_LEGACY_RATE_COUNT; ratesLoop++)
1680 {
1681 if (legacyRates[ratesLoop] == apCtxt->targetMCRate)
1682 {
1683 supportMap |= (1 << RATE_CFG_RATE_LEGACY);
1684 break;
1685 }
1686 }
1687 }
1688
1689 /* 11N */
1690 if (eSTA_11n <= assocSta->supportedRates.opRateMode)
1691 {
1692 if (assocSta->Support40Mhz)
1693 {
1694 mcsTable11n |= 0x01;
1695 if (assocSta->ShortGI40Mhz)
1696 {
1697 mcsTable11n |= 0x02;
1698 supportMap |= (1 << RATE_CFG_RATE_11N_MCS_SGI_40);
1699 nMappingTable = n_s40_rate_mapping;
1700 }
1701 else
1702 {
1703 supportMap |= (1 << RATE_CFG_RATE_11N_MCS_LGI_40);
1704 nMappingTable = n_l40_rate_mapping;
1705 }
1706 }
1707 else
1708 {
1709 if (assocSta->ShortGI20Mhz)
1710 {
1711 mcsTable11n |= 0x02;
1712 supportMap |= (1 << RATE_CFG_RATE_11N_MCS_SGI_20);
1713 nMappingTable = n_s20_rate_mapping;
1714 }
1715 else
1716 {
1717 supportMap |= (1 << RATE_CFG_RATE_11N_MCS_LGI_20);
1718 nMappingTable = n_l20_rate_mapping;
1719 }
1720 }
1721 }
1722
1723#ifdef WLAN_FEATURE_11AC
1724 /* 11AC */
1725 if (eSTA_11ac <= assocSta->supportedRates.opRateMode)
1726 {
1727 /* Find supported MAX MCS */
1728 supportedAcMaxMcs = assocSta->supportedRates.vhtRxMCSMap &
1729 SAP_AC_MCS_MAP_MASK;
1730 supportedAcMaxMcs += SAP_AC_MCS_MAP_OFFSET;
1731 /* Find channel characteristics from MAX rate */
1732 if (mcs_rate_11ac[supportedAcMaxMcs].cb80_rate_11ac[0] ==
1733 assocSta->supportedRates.vhtRxHighestDataRate)
1734 {
1735 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_LGI_80);
1736 bandWidth = RATE_CFG_RATE_BW_80;
1737 gi = RATE_CFG_RATE_GI_LONG;
1738 acMappingTable = ac_l80_rate_mapping;
1739 }
1740 else if (mcs_rate_11ac[supportedAcMaxMcs].cb80_rate_11ac[1] ==
1741 assocSta->supportedRates.vhtRxHighestDataRate)
1742 {
1743 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_SGI_80);
1744 bandWidth = RATE_CFG_RATE_BW_80;
1745 gi = RATE_CFG_RATE_GI_SHORT;
1746 acMappingTable = ac_s80_rate_mapping;
1747 }
1748 else if (mcs_rate_11ac[supportedAcMaxMcs].cb40_rate_11ac[0] ==
1749 assocSta->supportedRates.vhtRxHighestDataRate)
1750 {
1751 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_LGI_40);
1752 bandWidth = RATE_CFG_RATE_BW_40;
1753 gi = RATE_CFG_RATE_GI_LONG;
1754 acMappingTable = ac_l40_rate_mapping;
1755 }
1756 else if (mcs_rate_11ac[supportedAcMaxMcs].cb40_rate_11ac[1] ==
1757 assocSta->supportedRates.vhtRxHighestDataRate)
1758 {
1759 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_SGI_40);
1760 bandWidth = RATE_CFG_RATE_BW_40;
1761 gi = RATE_CFG_RATE_GI_SHORT;
1762 acMappingTable = ac_s40_rate_mapping;
1763 }
1764 else if (mcs_rate_11ac[supportedAcMaxMcs].cb20_rate_11ac[0] ==
1765 assocSta->supportedRates.vhtRxHighestDataRate)
1766 {
1767 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_LGI_20);
1768 bandWidth = RATE_CFG_RATE_BW_20;
1769 gi = RATE_CFG_RATE_GI_LONG;
1770 acMappingTable = ac_l20_rate_mapping;
1771 }
1772 else if (mcs_rate_11ac[supportedAcMaxMcs].cb20_rate_11ac[1] ==
1773 assocSta->supportedRates.vhtRxHighestDataRate)
1774 {
1775 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_SGI_20);
1776 bandWidth = RATE_CFG_RATE_BW_20;
1777 gi = RATE_CFG_RATE_GI_SHORT;
1778 acMappingTable = ac_s20_rate_mapping;
1779 }
1780 }
1781#endif /* WLAN_FEATURE_11AC */
1782 combinedSupportMap &= supportMap;
1783 }
1784
1785 if ((!combinedSupportMap) &&
1786 (!sapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta))
1787 {
1788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1789 "%s, No Common supported rate, discard", __func__);
1790 return -1;
1791 }
1792
1793 /* Select target band */
1794 if (apCtxt->operatingChannel <=
1795 SAP_MAX_24_CHANNEL_NUMBER)
1796 {
1797 targetCfgId = WNI_CFG_FIXED_RATE_MULTICAST_24GHZ;
1798 }
1799 else
1800 {
1801 targetCfgId = WNI_CFG_FIXED_RATE_MULTICAST_5GHZ;
1802 }
1803
1804 /* First find from legacy */
1805 if (combinedSupportMap & SAP_RATE_SUPPORT_MAP_LEGACY_MASK)
1806 {
1807 for (ratesLoop = 0; ratesLoop < SAP_LEGACY_RATE_COUNT; ratesLoop++)
1808 {
1809 if (apCtxt->targetMCRate ==
1810 legacy_rate_mapping[ratesLoop].rate)
1811 {
1812 targetCfgValue = legacy_rate_mapping[ratesLoop].eRateCfg;
1813 break;
1814 }
1815 }
1816 }
1817
1818 /* If available same on 11N, update target rate */
1819 if ((combinedSupportMap & SAP_RATE_SUPPORT_MAP_N_MASK) &&
1820 (NULL != nMappingTable))
1821 {
1822 for (ratesLoop = 0; ratesLoop < SAP_11N_RATE_COUNT; ratesLoop++)
1823 {
1824 if (apCtxt->targetMCRate == nMappingTable[ratesLoop].rate)
1825 {
1826 targetCfgValue = nMappingTable[ratesLoop].eRateCfg;
1827 break;
1828 }
1829 }
1830 }
1831
1832#ifdef WLAN_FEATURE_11AC
1833 /* If available same on 11AC, update target rate */
1834 if ((combinedSupportMap & SAP_RATE_SUPPORT_MAP_AC_MASK) &&
1835 (NULL != acMappingTable))
1836 {
1837 for (ratesLoop = 0; ratesLoop < supportedAcMaxMcs; ratesLoop++)
1838 {
1839 if (apCtxt->targetMCRate == acMappingTable[ratesLoop].rate)
1840 {
1841 targetCfgValue = acMappingTable[ratesLoop].eRateCfg;
1842 break;
1843 }
1844 }
1845 }
1846#endif /* WLAN_FEATURE_11AC */
1847
1848 /* Finally send config to FW */
1849 if (targetCfgId && targetCfgValue)
1850 {
1851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1852 "%s, Target Band %d, cfg value %d",
1853 __func__, targetCfgId, targetCfgValue);
1854 cfdStat = cfgSetInt((tpAniSirGlobal)hHal,
1855 targetCfgId,
1856 targetCfgValue);
1857 if (eSIR_SUCCESS != cfdStat)
1858 {
1859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1860 "%s, CFG Fail %d",
1861 __func__, cfdStat);
1862 rc = -1;
1863 }
1864 }
1865
1866 return rc;
1867};
1868
1869/**---------------------------------------------------------------------------
1870
1871 \brief hdd_hostapd_set_mc_rate() -
1872
1873 This is called user application set forcefully MC rate
1874
1875 \param - pHostapdAdapter Pointer to adapter structure
1876 \param - targetRateHkbps MC rate to set, hundreds kbps order
1877
1878 \return - int, 0 success
1879 negative fail
1880
1881 --------------------------------------------------------------------------*/
1882int hdd_hostapd_set_mc_rate
1883(
1884 hdd_adapter_t *pHostapdAdapter,
1885 int targetRateHkbps
1886)
1887{
1888 tHalHandle hHal;
1889 hdd_ap_ctx_t *apCtxt;
1890 eHalStatus smeStatus;
1891 int rc;
1892
1893 if ((NULL == pHostapdAdapter) || (0 == targetRateHkbps))
1894 {
1895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1896 "%s : Invalid arguments", __func__);
1897 return -1;
1898 }
1899
1900 apCtxt = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1901 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1903 "hdd_hostapd_setMcRate %d", targetRateHkbps);
1904
1905 init_completion(&apCtxt->sap_get_associated_stas_complete);
1906
1907 apCtxt->getStasCookie = SAP_GET_STAS_COOKIE;
1908 apCtxt->targetMCRate = targetRateHkbps;
1909 apCtxt->getStasEventBuffer.sapevt.sapAssocStaListEvent.noOfAssocSta = 0;
1910 apCtxt->assocStasBuffer = (tSap_AssocMacAddr *)vos_mem_malloc(
1911 sizeof(tSap_AssocMacAddr) * HAL_NUM_ASSOC_STA);
1912 if (NULL == apCtxt->assocStasBuffer)
1913 {
1914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1915 "%s : Buffer Alloc fail", __func__);
1916 return -1;
1917 }
1918 smeStatus = sme_RoamGetAssociatedStas(hHal,
1919 pHostapdAdapter->sessionId,
1920 VOS_MODULE_ID_HDD,
1921 (void *)apCtxt,
1922 hdd_hostapd_set_mc_rate_cb,
1923 (tANI_U8 *)apCtxt->assocStasBuffer);
1924 if (smeStatus)
1925 {
1926 apCtxt->getStasCookie = 0;
1927 vos_mem_free(apCtxt->assocStasBuffer);
1928 apCtxt->assocStasBuffer = NULL;
1929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1930 "%s : SME Issue fail", __func__);
1931 return -1;
1932 }
1933
1934 /* Wait for completion */
1935 rc = wait_for_completion_interruptible_timeout(
1936 &apCtxt->sap_get_associated_stas_complete,
1937 msecs_to_jiffies(SAP_MAX_GET_ASSOC_STAS_TIMEOUT));
1938
1939 /* either we have a response or we timed out
1940 either way, first invalidate our cookie */
1941 apCtxt->getStasCookie = 0;
1942 if (0 >= rc)
1943 {
1944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1945 "%s : Wait timeout or interrupted", __func__);
1946
1947 /* there is a race condition such that the callback
1948 function could be executing at the same time we are. of
1949 primary concern is if the callback function had already
1950 verified the "magic" but hasn't yet set the completion
1951 variable. Since the completion variable is on our
1952 stack, we'll delay just a bit to make sure the data is
1953 still valid if that is the case */
1954 vos_sleep(50);
1955 /* we'll now try to test memory */
1956 }
1957
1958 rc = hdd_hostapd_set_mc_rate_update(
1959 &apCtxt->getStasEventBuffer,
1960 pHostapdAdapter);
1961 vos_mem_free(apCtxt->assocStasBuffer);
1962 apCtxt->assocStasBuffer = NULL;
1963
1964 return rc;
1965}
1966
Jeff Johnson295189b2012-06-20 16:38:30 -07001967int
1968static iw_softap_setparam(struct net_device *dev,
1969 struct iw_request_info *info,
1970 union iwreq_data *wrqu, char *extra)
1971{
1972 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1973 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1974 int *value = (int *)extra;
1975 int sub_cmd = value[0];
1976 int set_value = value[1];
1977 eHalStatus status;
1978 int ret = 0; /* success */
1979 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1980
1981 switch(sub_cmd)
1982 {
1983
1984 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001985 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 {
1987 ret = -EIO;
1988 }
1989 break;
1990
1991 case QCSAP_PARAM_ACL_MODE:
1992 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
1993 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1994 {
1995 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1996 ret = -EINVAL;
1997 }
1998 else
1999 {
2000 WLANSAP_SetMode(pVosContext, set_value);
2001 }
2002 break;
2003 case QCSAP_PARAM_MAX_ASSOC:
2004 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2005 {
2006 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2007 ret = -EINVAL;
2008 }
2009 else
2010 {
2011 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2012 {
2013 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2014 "Setting it to max allowed and continuing"),
2015 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2016 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2017 }
2018 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2019 set_value, NULL, eANI_BOOLEAN_FALSE);
2020 if ( status != eHAL_STATUS_SUCCESS )
2021 {
2022 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2023 status);
2024 ret = -EIO;
2025 }
2026 }
2027 break;
2028
2029 case QCSAP_PARAM_HIDE_SSID:
2030 {
2031 eHalStatus status = eHAL_STATUS_SUCCESS;
2032 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2033 if(eHAL_STATUS_SUCCESS != status)
2034 {
2035 hddLog(VOS_TRACE_LEVEL_ERROR,
2036 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002037 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 return status;
2039 }
2040 break;
2041 }
2042
Leo Changb77d2882013-08-22 14:59:44 -07002043 case QCSAP_PARAM_SET_MC_RATE:
2044 {
2045 if (hdd_hostapd_set_mc_rate(pHostapdAdapter, set_value))
2046 {
2047 hddLog(VOS_TRACE_LEVEL_ERROR,
2048 "%s: SET_MC_RATE failed", __func__);
2049 }
2050 break;
2051 }
2052
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 default:
2054 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2055 sub_cmd, set_value);
2056 ret = -EINVAL;
2057 break;
2058 }
2059
2060 return ret;
2061}
2062
2063
2064int
2065static iw_softap_getparam(struct net_device *dev,
2066 struct iw_request_info *info,
2067 union iwreq_data *wrqu, char *extra)
2068{
2069 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2070 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2071 int *value = (int *)extra;
2072 int sub_cmd = value[0];
2073 eHalStatus status;
2074 int ret = 0; /* success */
2075 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2076
2077 switch (sub_cmd)
2078 {
2079 case QCSAP_PARAM_MAX_ASSOC:
2080 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2081 if (eHAL_STATUS_SUCCESS != status)
2082 {
2083 ret = -EIO;
2084 }
2085 break;
2086
2087 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002088 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 {
2090 ret = -EIO;
2091 }
2092 *value = 0;
2093 break;
2094
2095 case QCSAP_PARAM_MODULE_DOWN_IND:
2096 {
2097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002098 "%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
2100#ifdef WLAN_BTAMP_FEATURE
2101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002102 "%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
2104#endif
2105 *value = 0;
2106 break;
Jeff Johnson43971f52012-07-17 12:26:56 -07002107 }
2108
2109 case QCSAP_PARAM_GET_WLAN_DBG:
2110 {
2111 vos_trace_display();
2112 *value = 0;
2113 break;
2114 }
2115
2116 case QCSAP_PARAM_AUTO_CHANNEL:
2117 {
2118 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2119 break;
2120 }
2121
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 default:
2123 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2124 ret = -EINVAL;
2125 break;
2126
2127 }
2128
2129 return ret;
2130}
2131
2132/* Usage:
2133 BLACK_LIST = 0
2134 WHITE_LIST = 1
2135 ADD MAC = 0
2136 REMOVE MAC = 1
2137
2138 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2139 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2140 while using this ioctl
2141
2142 Syntax:
2143 iwpriv softap.0 modify_acl
2144 <6 octet mac addr> <list type> <cmd type>
2145
2146 Examples:
2147 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2148 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2149 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2150 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2151*/
2152int iw_softap_modify_acl(struct net_device *dev, struct iw_request_info *info,
2153 union iwreq_data *wrqu, char *extra)
2154{
2155 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2156 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2157 v_BYTE_t *value = (v_BYTE_t*)extra;
2158 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2159 int listType, cmd, i;
2160 int ret = 0; /* success */
2161
2162 ENTER();
2163 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2164 {
2165 pPeerStaMac[i] = *(value+i);
2166 }
2167 listType = (int)(*(value+i));
2168 i++;
2169 cmd = (int)(*(value+i));
2170
2171 hddLog(LOG1, "%s: SAP Modify ACL arg0 %02x:%02x:%02x:%02x:%02x:%02x arg1 %d arg2 %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002172 __func__, pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 pPeerStaMac[3], pPeerStaMac[4], pPeerStaMac[5], listType, cmd);
2174
2175 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2176 != VOS_STATUS_SUCCESS)
2177 {
2178 hddLog(LOGE, FL("Modify ACL failed\n"));
2179 ret = -EIO;
2180 }
2181 EXIT();
2182 return ret;
2183}
2184
2185int
2186static iw_softap_getchannel(struct net_device *dev,
2187 struct iw_request_info *info,
2188 union iwreq_data *wrqu, char *extra)
2189{
2190 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2191
Jeff Johnson43971f52012-07-17 12:26:56 -07002192 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002193
Jeff Johnson43971f52012-07-17 12:26:56 -07002194 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 return 0;
2196}
2197
Jeff Johnsone7245742012-09-05 17:12:55 -07002198int
schangd82195a2013-03-13 18:41:24 -07002199static iw_softap_set_max_tx_power(struct net_device *dev,
Jeff Johnsone7245742012-09-05 17:12:55 -07002200 struct iw_request_info *info,
2201 union iwreq_data *wrqu, char *extra)
2202{
2203 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2204 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
schangd82195a2013-03-13 18:41:24 -07002205 int *value = (int *)extra;
Jeff Johnsone7245742012-09-05 17:12:55 -07002206 int set_value;
2207 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2208 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2209
schangd82195a2013-03-13 18:41:24 -07002210 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002211 return -ENOMEM;
2212
Leo Chang8a788222013-08-01 13:19:45 -07002213 /* Assign correct slef MAC address */
2214 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2215 VOS_MAC_ADDR_SIZE);
2216 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2217 VOS_MAC_ADDR_SIZE);
2218
schangd82195a2013-03-13 18:41:24 -07002219 set_value = value[0];
2220 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2221 {
2222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002223 __func__);
schangd82195a2013-03-13 18:41:24 -07002224 return -EIO;
2225 }
2226
2227 return 0;
2228}
2229
2230int
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05302231static iw_display_data_path_snapshot(struct net_device *dev,
2232 struct iw_request_info *info,
2233 union iwreq_data *wrqu, char *extra)
2234{
2235
2236 /* Function intitiating dumping states of
2237 * HDD(WMM Tx Queues)
2238 * TL State (with Per Client infor)
2239 * DXE Snapshot (Called at the end of TL Snapshot)
2240 */
2241 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2242 hddLog(LOGE, "%s: called for SAP",__func__);
2243 hdd_wmm_tx_snapshot(pHostapdAdapter);
2244 WLANTL_TLDebugMessage(VOS_TRUE);
2245 return 0;
2246}
2247
2248int
schangd82195a2013-03-13 18:41:24 -07002249static iw_softap_set_tx_power(struct net_device *dev,
2250 struct iw_request_info *info,
2251 union iwreq_data *wrqu, char *extra)
2252{
2253 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2254 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2255 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2256 int *value = (int *)extra;
2257 int set_value;
2258 ptSapContext pSapCtx = NULL;
2259
2260 if (NULL == value)
2261 return -ENOMEM;
2262
2263 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2264 if (NULL == pSapCtx)
2265 {
2266 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2267 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2268 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002269 }
2270
2271 set_value = value[0];
schangd82195a2013-03-13 18:41:24 -07002272 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002273 {
schangd82195a2013-03-13 18:41:24 -07002274 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002275 __func__);
2276 return -EIO;
2277 }
2278
2279 return 0;
2280}
2281
Jeff Johnson295189b2012-06-20 16:38:30 -07002282#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2283
2284int
2285static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2286 struct iw_request_info *info,
2287 union iwreq_data *wrqu, char *extra)
2288{
2289 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2290 unsigned char *pmaclist;
2291 hdd_station_info_t *pStaInfo = pHostapdAdapter->aStaInfo;
2292 int cnt = 0, len;
2293
2294
2295 pmaclist = wrqu->data.pointer + sizeof(unsigned long int);
2296 len = wrqu->data.length;
2297
2298 spin_lock_bh( &pHostapdAdapter->staInfo_lock );
2299 while((cnt < WLAN_MAX_STA_COUNT) && (len > (sizeof(v_MACADDR_t)+1))) {
2300 if (TRUE == pStaInfo[cnt].isUsed) {
2301
2302 if(!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes)) {
2303 memcpy((void *)pmaclist, (void *)&(pStaInfo[cnt].macAddrSTA), sizeof(v_MACADDR_t));
2304 pmaclist += sizeof(v_MACADDR_t);
2305 len -= sizeof(v_MACADDR_t);
2306 }
2307 }
2308 cnt++;
2309 }
2310 spin_unlock_bh( &pHostapdAdapter->staInfo_lock );
2311
2312 *pmaclist = '\0';
2313
2314 wrqu->data.length -= len;
2315
2316 *(unsigned long int *)(wrqu->data.pointer) = wrqu->data.length;
2317
2318 return 0;
2319}
2320
2321/* Usage:
2322 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2323 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2324 while using this ioctl
2325
2326 Syntax:
2327 iwpriv softap.0 disassoc_sta <6 octet mac address>
2328
2329 e.g.
2330 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2331 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2332*/
2333
2334int
2335static iw_softap_disassoc_sta(struct net_device *dev,
2336 struct iw_request_info *info,
2337 union iwreq_data *wrqu, char *extra)
2338{
2339 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2340 v_U8_t *peerMacAddr;
2341
2342 ENTER();
Gopichand Nakkalab576f6c2013-02-27 17:01:23 +05302343 /* iwpriv tool or framework calls this ioctl with
2344 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 */
Gopichand Nakkalab576f6c2013-02-27 17:01:23 +05302346 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002347
2348 hddLog(LOG1, "data %02x:%02x:%02x:%02x:%02x:%02x",
2349 peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
2350 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);
2351 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2352 EXIT();
2353 return 0;
2354}
2355
2356int
2357static iw_softap_ap_stats(struct net_device *dev,
2358 struct iw_request_info *info,
2359 union iwreq_data *wrqu, char *extra)
2360{
2361 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2362 WLANTL_TRANSFER_STA_TYPE statBuffer;
2363 char *pstatbuf;
2364 int len = wrqu->data.length;
2365 pstatbuf = wrqu->data.pointer;
2366
2367 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &statBuffer, (v_BOOL_t)wrqu->data.flags);
2368
2369 len = snprintf(pstatbuf, len,
2370 "RUF=%d RMF=%d RBF=%d "
2371 "RUB=%d RMB=%d RBB=%d "
2372 "TUF=%d TMF=%d TBF=%d "
2373 "TUB=%d TMB=%d TBB=%d",
2374 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt, (int)statBuffer.rxBCFcnt,
2375 (int)statBuffer.rxUCBcnt, (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2376 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt, (int)statBuffer.txBCFcnt,
2377 (int)statBuffer.txUCBcnt, (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt
2378 );
2379
2380 wrqu->data.length -= len;
2381 return 0;
2382}
2383
2384int
2385static iw_softap_commit(struct net_device *dev,
2386 struct iw_request_info *info,
2387 union iwreq_data *wrqu, char *extra)
2388{
2389 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2390 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2391 hdd_hostapd_state_t *pHostapdState;
2392 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2393 tpWLAN_SAPEventCB pSapEventCallback;
2394 tsap_Config_t *pConfig;
2395 s_CommitConfig_t *pCommitConfig;
2396 struct qc_mac_acl_entry *acl_entry = NULL;
2397 v_SINT_t i = 0, num_mac = 0;
2398 v_U32_t status = 0;
2399 eCsrAuthType RSNAuthType;
2400 eCsrEncryptionType RSNEncryptType;
2401 eCsrEncryptionType mcRSNEncryptType;
2402
2403 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
2404 pCommitConfig = (s_CommitConfig_t *)extra;
2405
2406 pConfig = kmalloc(sizeof(tsap_Config_t), GFP_KERNEL);
2407 if(NULL == pConfig) {
2408 hddLog(LOG1, "VOS unable to allocate memory\n");
2409 return -ENOMEM;
2410 }
2411 pConfig->beacon_int = pCommitConfig->beacon_int;
2412 pConfig->channel = pCommitConfig->channel;
2413
2414 /*Protection parameter to enable or disable*/
2415 pConfig->protEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
2416 pConfig->dtim_period = pCommitConfig->dtim_period;
2417 switch(pCommitConfig->hw_mode )
2418 {
2419 case eQC_DOT11_MODE_11A:
2420 pConfig->SapHw_mode = eSAP_DOT11_MODE_11a;
2421 break;
2422 case eQC_DOT11_MODE_11B:
2423 pConfig->SapHw_mode = eSAP_DOT11_MODE_11b;
2424 break;
2425 case eQC_DOT11_MODE_11G:
2426 pConfig->SapHw_mode = eSAP_DOT11_MODE_11g;
2427 break;
2428
2429 case eQC_DOT11_MODE_11N:
2430 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2431 break;
2432 case eQC_DOT11_MODE_11G_ONLY:
2433 pConfig->SapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
2434 break;
2435 case eQC_DOT11_MODE_11N_ONLY:
2436 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n_ONLY;
2437 break;
2438 default:
2439 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2440 break;
2441
2442 }
2443
2444 pConfig->ieee80211d = pCommitConfig->qcsap80211d;
2445 vos_mem_copy(pConfig->countryCode, pCommitConfig->countryCode, 3);
2446 if(pCommitConfig->authType == eQC_AUTH_TYPE_SHARED_KEY)
2447 pConfig->authType = eSAP_SHARED_KEY;
2448 else if(pCommitConfig->authType == eQC_AUTH_TYPE_OPEN_SYSTEM)
2449 pConfig->authType = eSAP_OPEN_SYSTEM;
2450 else
2451 pConfig->authType = eSAP_AUTO_SWITCH;
2452
2453 pConfig->privacy = pCommitConfig->privacy;
2454 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pCommitConfig->privacy;
2455 pConfig->wps_state = pCommitConfig->wps_state;
2456 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
2457 pConfig->RSNWPAReqIELength = pCommitConfig->RSNWPAReqIELength;
2458 if(pConfig->RSNWPAReqIELength){
2459 pConfig->pRSNWPAReqIE = &pCommitConfig->RSNWPAReqIE[0];
2460 if ((pConfig->pRSNWPAReqIE[0] == DOT11F_EID_RSN) || (pConfig->pRSNWPAReqIE[0] == DOT11F_EID_WPA)){
2461 // The actual processing may eventually be more extensive than this.
2462 // Right now, just consume any PMKIDs that are sent in by the app.
2463 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 vos_get_context( VOS_MODULE_ID_PE, pVosContext),
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 &RSNEncryptType,
2466 &mcRSNEncryptType,
2467 &RSNAuthType,
2468 pConfig->pRSNWPAReqIE[1]+2,
2469 pConfig->pRSNWPAReqIE );
2470
2471 if( VOS_STATUS_SUCCESS == status )
2472 {
2473 // Now copy over all the security attributes you have parsed out
2474 //TODO: Need to handle mixed mode
2475 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
2476 pConfig->mcRSNEncryptType = mcRSNEncryptType;
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05302477 hddLog( LOG1, FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
2479 }
2480 }
2481 }
2482 else
2483 {
2484 /* If no RSNIE, set encrypt type to NONE*/
2485 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
2486 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
2487 hddLog( LOG1, FL("EncryptionType = %d mcEncryptionType = %d\n"),
2488 pConfig->RSNEncryptType, pConfig->mcRSNEncryptType);
2489 }
2490
Chilam Ng20b2cb92013-04-01 15:37:32 -07002491 if (pConfig->RSNWPAReqIELength > QCSAP_MAX_OPT_IE) {
2492 hddLog(LOGE, FL("RSNWPAReqIELength: %d too large"), pConfig->RSNWPAReqIELength);
2493 kfree(pConfig);
2494 return -EIO;
2495 }
2496
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 pConfig->SSIDinfo.ssidHidden = pCommitConfig->SSIDinfo.ssidHidden;
2498 pConfig->SSIDinfo.ssid.length = pCommitConfig->SSIDinfo.ssid.length;
2499 vos_mem_copy(pConfig->SSIDinfo.ssid.ssId, pCommitConfig->SSIDinfo.ssid.ssId, pConfig->SSIDinfo.ssid.length);
2500 vos_mem_copy(pConfig->self_macaddr.bytes, pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
2501
2502 pConfig->SapMacaddr_acl = pCommitConfig->qc_macaddr_acl;
2503
2504 // ht_capab is not what the name conveys,this is used for protection bitmap
2505 pConfig->ht_capab = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2506
Gopichand Nakkala00c75182013-05-14 16:04:14 +05302507 if (pCommitConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2508 num_mac = pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 else
2510 num_mac = pConfig->num_accept_mac = pCommitConfig->num_accept_mac;
2511 acl_entry = pCommitConfig->accept_mac;
2512 for (i = 0; i < num_mac; i++)
2513 {
2514 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(v_MACADDR_t));
2515 acl_entry++;
2516 }
Gopichand Nakkala00c75182013-05-14 16:04:14 +05302517 if (pCommitConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2518 num_mac = pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 else
2520 num_mac = pConfig->num_deny_mac = pCommitConfig->num_deny_mac;
2521 acl_entry = pCommitConfig->deny_mac;
2522 for (i = 0; i < num_mac; i++)
2523 {
2524 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(v_MACADDR_t));
2525 acl_entry++;
2526 }
2527 //Uapsd Enabled Bit
2528 pConfig->UapsdEnable = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2529 //Enable OBSS protection
2530 pConfig->obssProtEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
2531 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apDisableIntraBssFwd;
2532
2533 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
2534 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
2535 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, (int)pConfig->channel);
2536 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
2537 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, pConfig->authType);
2538 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
2539 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
2540 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),pConfig->protEnabled, pConfig->obssProtEnabled);
2541 hddLog(LOGW,FL("DisableIntraBssFwd = %d\n"),(WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd);
2542
2543 pSapEventCallback = hdd_hostapd_SAPEventCB;
2544 pConfig->persona = pHostapdAdapter->device_mode;
2545 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,(v_PVOID_t)dev) != VOS_STATUS_SUCCESS)
2546 {
2547 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2548 }
2549
2550 kfree(pConfig);
2551
2552 hddLog(LOG1, FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2553 vos_status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2554
2555 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2556 {
2557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos wait for single_event failed!!\n"));
2558 VOS_ASSERT(0);
2559 }
2560
2561 pHostapdState->bCommit = TRUE;
2562 if(pHostapdState->vosStatus)
2563 {
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002564 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 }
2566 else
2567 {
2568 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2569 WLANSAP_Update_WpsIe ( pVosContext );
2570 return 0;
2571 }
2572}
2573static
2574int iw_softap_setmlme(struct net_device *dev,
2575 struct iw_request_info *info,
2576 union iwreq_data *wrqu, char *extra)
2577{
2578 struct sQcSapreq_mlme *pmlme;
2579 hdd_adapter_t *pHostapdAdapter = (hdd_adapter_t*)(netdev_priv(dev));
2580 v_MACADDR_t destAddress;
2581 pmlme = (struct sQcSapreq_mlme *)(wrqu->name);
2582 /* NOTE: this address is not valid incase of TKIP failure, since not filled */
2583 vos_mem_copy(&destAddress.bytes, pmlme->im_macaddr, sizeof(v_MACADDR_t));
2584 switch(pmlme->im_op)
2585 {
2586 case QCSAP_MLME_AUTHORIZE:
2587 hdd_softap_change_STA_state( pHostapdAdapter, &destAddress, WLANTL_STA_AUTHENTICATED);
2588 break;
2589 case QCSAP_MLME_ASSOC:
2590 //TODO:inform to TL after associating (not needed as we do in sapCallback)
2591 break;
2592 case QCSAP_MLME_UNAUTHORIZE:
2593 //TODO: send the disassoc to station
2594 //hdd_softap_change_STA_state( pHostapdAdapter, pmlme->im_macaddr, WLANTL_STA_AUTHENTICATED);
2595 break;
2596 case QCSAP_MLME_DISASSOC:
2597 hdd_softap_sta_disassoc(pHostapdAdapter,pmlme->im_macaddr);
2598 break;
2599 case QCSAP_MLME_DEAUTH:
2600 hdd_softap_sta_deauth(pHostapdAdapter,pmlme->im_macaddr);
2601 break;
2602 case QCSAP_MLME_MICFAILURE:
2603 hdd_softap_tkip_mic_fail_counter_measure(pHostapdAdapter,pmlme->im_reason);
2604 break;
2605 default:
2606 break;
2607 }
2608 return 0;
2609}
2610
2611static int iw_softap_set_channel_range(struct net_device *dev,
2612 struct iw_request_info *info,
2613 union iwreq_data *wrqu, char *extra)
2614{
2615 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2616 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi8bca2fd2012-12-05 16:40:18 -08002617 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002618
2619 int *value = (int *)extra;
2620 int startChannel = value[0];
2621 int endChannel = value[1];
2622 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002623 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 int ret = 0; /* success */
2625
2626 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2627 if(status != VOS_STATUS_SUCCESS)
2628 {
2629 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d\n"),
2630 startChannel,endChannel, band);
2631 ret = -EINVAL;
2632 }
Gopichand Nakkalac7b57c82013-01-07 14:52:52 -08002633
2634 pHddCtx->is_dynamic_channel_range_set = 1;
2635
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 return ret;
2637}
2638
2639int iw_softap_get_channel_list(struct net_device *dev,
2640 struct iw_request_info *info,
2641 union iwreq_data *wrqu, char *extra)
2642{
2643 v_U32_t num_channels = 0;
2644 v_U8_t i = 0;
2645 v_U8_t bandStartChannel = RF_CHAN_1;
2646 v_U8_t bandEndChannel = RF_CHAN_165;
2647 v_U32_t temp_num_channels = 0;
2648 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2649 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2650 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002652 eCsrBand curBand = eCSR_BAND_ALL;
2653
2654 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
2655 {
2656 hddLog(LOGE,FL("not able get the current frequency band\n"));
2657 return -EIO;
2658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 wrqu->data.length = sizeof(tChannelListInfo);
2660 ENTER();
2661
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002662 if (eCSR_BAND_24 == curBand)
2663 {
2664 bandStartChannel = RF_CHAN_1;
2665 bandEndChannel = RF_CHAN_14;
2666 }
2667 else if (eCSR_BAND_5G == curBand)
2668 {
2669 bandStartChannel = RF_CHAN_36;
2670 bandEndChannel = RF_CHAN_165;
2671 }
2672
Gopichand Nakkala9846ac42013-06-20 19:03:52 +05302673 hddLog(LOG1, FL("\n curBand = %d, bandStartChannel = %hu, "
2674 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002675 bandStartChannel, bandEndChannel );
2676
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 for( i = bandStartChannel; i <= bandEndChannel; i++ )
2678 {
2679 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
2680 {
2681 channel_list->channels[num_channels] = rfChannels[i].channelNum;
2682 num_channels++;
2683 }
2684 }
2685
2686 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
2687
2688 temp_num_channels = num_channels;
2689
2690 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
2691 {
2692 hddLog(LOG1,FL("Failed to get Domain ID, %d \n"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002693 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002694 }
2695
2696 if(REGDOMAIN_FCC == domainIdCurrentSoftap)
2697 {
2698 for(i = 0; i < temp_num_channels; i++)
2699 {
2700
2701 if((channel_list->channels[i] > 35) &&
2702 (channel_list->channels[i] < 49))
2703 {
2704 vos_mem_move(&channel_list->channels[i],
2705 &channel_list->channels[i+1],
2706 temp_num_channels - (i-1));
2707 num_channels--;
2708 temp_num_channels--;
2709 i--;
2710 }
2711 }
2712 }
2713
2714 hddLog(LOG1,FL(" number of channels %d\n"), num_channels);
2715
2716 if (num_channels > IW_MAX_FREQUENCIES)
2717 {
2718 num_channels = IW_MAX_FREQUENCIES;
2719 }
2720
2721 channel_list->num_channels = num_channels;
2722 EXIT();
2723
2724 return 0;
2725}
2726
2727static
2728int iw_get_genie(struct net_device *dev,
2729 struct iw_request_info *info,
2730 union iwreq_data *wrqu, char *extra)
2731{
2732 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2733 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2734 eHalStatus status;
2735 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2736 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2737 ENTER();
2738 hddLog(LOG1,FL("getGEN_IE ioctl\n"));
2739 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2740 status = WLANSap_getstationIE_information(pVosContext,
2741 &length,
2742 genIeBytes);
2743 wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2744 vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length);
2745
2746 hddLog(LOG1,FL(" RSN IE of %d bytes returned\n"), wrqu->data.length );
2747
2748
2749 EXIT();
2750 return 0;
2751}
2752static
2753int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
2754 struct iw_request_info *info,
2755 union iwreq_data *wrqu, char *extra)
2756{
2757 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2758 sQcSapreq_WPSPBCProbeReqIES_t *pWPSPBCProbeReqIEs;
2759 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
2760 ENTER();
2761
2762 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl\n"));
2763
2764 pWPSPBCProbeReqIEs = (sQcSapreq_WPSPBCProbeReqIES_t *)(wrqu->data.pointer);
2765 pWPSPBCProbeReqIEs->probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
2766 vos_mem_copy(pWPSPBCProbeReqIEs->probeReqIE, pHddApCtx->WPSPBCProbeReq.probeReqIE, pWPSPBCProbeReqIEs->probeReqIELen);
2767 vos_mem_copy(pWPSPBCProbeReqIEs->macaddr, pHddApCtx->WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
2768 wrqu->data.length = 12 + pWPSPBCProbeReqIEs->probeReqIELen;
2769 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR"\n"), MAC_ADDR_ARRAY(pWPSPBCProbeReqIEs->macaddr));
2770 up(&pHddApCtx->semWpsPBCOverlapInd);
2771 EXIT();
2772 return 0;
2773}
2774
2775/**---------------------------------------------------------------------------
2776
2777 \brief iw_set_auth_hostap() -
2778 This function sets the auth type received from the wpa_supplicant.
2779
2780 \param - dev - Pointer to the net device.
2781 - info - Pointer to the iw_request_info.
2782 - wrqu - Pointer to the iwreq_data.
2783 - extra - Pointer to the data.
2784 \return - 0 for success, non zero for failure
2785
2786 --------------------------------------------------------------------------*/
2787int iw_set_auth_hostap(struct net_device *dev,struct iw_request_info *info,
2788 union iwreq_data *wrqu,char *extra)
2789{
2790 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2791 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2792
2793 ENTER();
2794 switch(wrqu->param.flags & IW_AUTH_INDEX)
2795 {
2796 case IW_AUTH_TKIP_COUNTERMEASURES:
2797 {
2798 if(wrqu->param.value) {
2799 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2800 "Counter Measure started %d", wrqu->param.value);
2801 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
2802 }
2803 else {
2804 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2805 "Counter Measure stopped=%d", wrqu->param.value);
2806 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
2807 }
2808
2809 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
2810 wrqu->param.value);
2811 }
2812 break;
2813
2814 default:
2815
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002816 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 wrqu->param.flags & IW_AUTH_INDEX);
2818 break;
2819 }
2820
2821 EXIT();
2822 return 0;
2823}
2824
2825static int iw_set_ap_encodeext(struct net_device *dev,
2826 struct iw_request_info *info,
2827 union iwreq_data *wrqu, char *extra)
2828{
2829 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2830 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2831 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson43971f52012-07-17 12:26:56 -07002832 int retval = 0;
2833 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
2835 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2836 int key_index;
2837 struct iw_point *encoding = &wrqu->encoding;
2838 tCsrRoamSetKey setKey;
2839// tCsrRoamRemoveKey RemoveKey;
2840 int i;
Jeff Johnson43971f52012-07-17 12:26:56 -07002841
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 ENTER();
2843
2844 key_index = encoding->flags & IW_ENCODE_INDEX;
2845
2846 if(key_index > 0) {
2847
2848 /*Convert from 1-based to 0-based keying*/
2849 key_index--;
2850 }
2851 if(!ext->key_len) {
2852#if 0
2853 /*Set the encrytion type to NONE*/
2854#if 0
2855 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2856#endif
2857
2858 RemoveKey.keyId = key_index;
2859 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2860 /*Key direction for group is RX only*/
2861 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2862 }
2863 else {
2864 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2865 }
2866 switch(ext->alg)
2867 {
2868 case IW_ENCODE_ALG_NONE:
2869 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2870 break;
2871 case IW_ENCODE_ALG_WEP:
2872 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2873 break;
2874 case IW_ENCODE_ALG_TKIP:
2875 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07002876 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 case IW_ENCODE_ALG_CCMP:
2878 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
2879 break;
2880 default:
2881 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2882 break;
2883 }
2884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Remove key cipher_alg:%d key_len%d *pEncryptionType :%d \n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002885 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR"\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002887 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 );
Jeff Johnson43971f52012-07-17 12:26:56 -07002889 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
2890 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 {
2892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07002893 __LINE__, vstatus );
2894 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002896#endif
2897 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002898
Jeff Johnson43971f52012-07-17 12:26:56 -07002899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002900
2901 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2902
2903 setKey.keyId = key_index;
2904 setKey.keyLength = ext->key_len;
2905
2906 if(ext->key_len <= CSR_MAX_KEY_LEN) {
2907 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
2908 }
2909
2910 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2911 /*Key direction for group is RX only*/
2912 setKey.keyDirection = eSIR_RX_ONLY;
2913 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2914 }
2915 else {
2916
2917 setKey.keyDirection = eSIR_TX_RX;
2918 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2919 }
2920 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2921 {
2922 setKey.keyDirection = eSIR_TX_DEFAULT;
2923 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2924 }
2925
2926 /*For supplicant pae role is zero*/
2927 setKey.paeRole = 0;
2928
2929 switch(ext->alg)
2930 {
2931 case IW_ENCODE_ALG_NONE:
2932 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2933 break;
2934
2935 case IW_ENCODE_ALG_WEP:
2936 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2937 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002938 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 break;
2940
2941 case IW_ENCODE_ALG_TKIP:
2942 {
2943 v_U8_t *pKey = &setKey.Key[0];
2944
2945 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
2946
2947 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
2948
2949 /*Supplicant sends the 32bytes key in this order
2950
2951 |--------------|----------|----------|
2952 | Tk1 |TX-MIC | RX Mic |
2953 |--------------|----------|----------|
2954 <---16bytes---><--8bytes--><--8bytes-->
2955
2956 */
2957 /*Sme expects the 32 bytes key to be in the below order
2958
2959 |--------------|----------|----------|
2960 | Tk1 |RX-MIC | TX Mic |
2961 |--------------|----------|----------|
2962 <---16bytes---><--8bytes--><--8bytes-->
2963 */
2964 /* Copy the Temporal Key 1 (TK1) */
2965 vos_mem_copy(pKey,ext->key,16);
2966
2967 /*Copy the rx mic first*/
2968 vos_mem_copy(&pKey[16],&ext->key[24],8);
2969
2970 /*Copy the tx mic */
2971 vos_mem_copy(&pKey[24],&ext->key[16],8);
2972
2973 }
2974 break;
2975
2976 case IW_ENCODE_ALG_CCMP:
2977 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
2978 break;
2979
2980 default:
2981 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2982 break;
2983 }
2984
2985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae8997bd2013-04-10 11:36:29 +05302986 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 setKey.keyId);
2988 for(i=0; i< ext->key_len; i++)
2989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2990 ("%02x"), setKey.Key[i]);
2991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2992 ("\n"));
Jeff Johnson43971f52012-07-17 12:26:56 -07002993
2994 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
2995 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 {
2997 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07002998 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
2999 retval = -EINVAL;
3000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003001
Jeff Johnson43971f52012-07-17 12:26:56 -07003002 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003003}
Jeff Johnson43971f52012-07-17 12:26:56 -07003004
3005
Jeff Johnson295189b2012-06-20 16:38:30 -07003006static int iw_set_ap_mlme(struct net_device *dev,
3007 struct iw_request_info *info,
3008 union iwreq_data *wrqu,
3009 char *extra)
3010{
3011#if 0
3012 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3013 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3014
3015 ENTER();
3016
3017 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3018 switch (mlme->cmd) {
3019 case IW_MLME_DISASSOC:
3020 case IW_MLME_DEAUTH:
3021 hddLog(LOG1, "Station disassociate");
3022 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3023 {
3024 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3025
3026 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3027 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3028
3029 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3030
3031 //clear all the reason codes
3032 if (status != 0)
3033 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003034 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n", __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 }
3036
3037 netif_stop_queue(dev);
3038 netif_carrier_off(dev);
3039 }
3040 else
3041 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003042 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 }
3044 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003045 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 return -EINVAL;
3047 }//end of switch
3048 EXIT();
3049#endif
3050 return 0;
3051// return status;
3052}
3053
3054static int iw_get_ap_rts_threshold(struct net_device *dev,
3055 struct iw_request_info *info,
3056 union iwreq_data *wrqu, char *extra)
3057{
3058 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3059 v_U32_t status = 0;
3060
3061 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3062
3063 return status;
3064}
3065
3066static int iw_get_ap_frag_threshold(struct net_device *dev,
3067 struct iw_request_info *info,
3068 union iwreq_data *wrqu, char *extra)
3069{
3070 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3071 v_U32_t status = 0;
3072
3073 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3074
3075 return status;
3076}
3077
3078static int iw_get_ap_freq(struct net_device *dev, struct iw_request_info *info,
3079 struct iw_freq *fwrq, char *extra)
3080{
Jeff Johnsone7245742012-09-05 17:12:55 -07003081 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3083 tHalHandle hHal;
3084 hdd_hostapd_state_t *pHostapdState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003085 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003086
3087 ENTER();
3088
3089 if ((WLAN_HDD_GET_CTX(pHostapdAdapter))->isLogpInProgress) {
3090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3091 "%s:LOGP in Progress. Ignore!!!",__func__);
3092 return status;
3093 }
3094
3095 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3096 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3097
3098 if(pHostapdState->bssState == BSS_STOP )
3099 {
3100 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3101 != eHAL_STATUS_SUCCESS)
3102 {
3103 return -EIO;
3104 }
3105 else
3106 {
3107 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003108 if( TRUE == status)
3109 {
3110 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3111 * iwlist & iwconfig command shows frequency into proper
3112 * format (2.412 GHz instead of 246.2 MHz)*/
3113 fwrq->m = freq;
3114 fwrq->e = MHZ;
3115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 }
3117 }
3118 else
3119 {
3120 channel = pHddApCtx->operatingChannel;
3121 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003122 if( TRUE == status)
3123 {
3124 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3125 * iwlist & iwconfig command shows frequency into proper
3126 * format (2.412 GHz instead of 246.2 MHz)*/
3127 fwrq->m = freq;
3128 fwrq->e = MHZ;
3129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003131 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003132}
3133
3134static int iw_softap_setwpsie(struct net_device *dev,
3135 struct iw_request_info *info,
3136 union iwreq_data *wrqu,
3137 char *extra)
3138{
3139 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3140 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3141 hdd_hostapd_state_t *pHostapdState;
3142 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3143 u_int8_t *wps_genie = wrqu->data.pointer;
3144 u_int8_t *pos;
3145 tpSap_WPSIE pSap_WPSIe;
3146 u_int8_t WPSIeType;
3147 u_int16_t length;
3148 ENTER();
3149
3150 if(!wrqu->data.length)
3151 return 0;
3152
3153 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3154 if (NULL == pSap_WPSIe)
3155 {
3156 hddLog(LOGE, "VOS unable to allocate memory\n");
3157 return -ENOMEM;
3158 }
3159 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3160
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003161 hddLog(LOG1,"%s WPS IE type[0x%X] IE[0x%X], LEN[%d]\n", __func__, wps_genie[0], wps_genie[1], wps_genie[2]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 WPSIeType = wps_genie[0];
3163 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3164 {
3165 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3166 wps_genie = wps_genie + 1;
3167 switch ( wps_genie[0] )
3168 {
3169 case DOT11F_EID_WPA:
3170 if (wps_genie[1] < 2 + 4)
3171 {
3172 vos_mem_free(pSap_WPSIe);
3173 return -EINVAL;
3174 }
3175 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3176 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003177 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 pos = &wps_genie[6];
3179 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3180 {
3181 switch((u_int16_t)(*pos<<8) | *(pos+1))
3182 {
3183 case HDD_WPS_ELEM_VERSION:
3184 pos += 4;
3185 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
3186 hddLog(LOG1, "WPS version %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
3187 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3188 pos += 1;
3189 break;
3190
3191 case HDD_WPS_ELEM_WPS_STATE:
3192 pos +=4;
3193 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
3194 hddLog(LOG1, "WPS State %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
3195 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3196 pos += 1;
3197 break;
3198 case HDD_WPS_ELEM_APSETUPLOCK:
3199 pos += 4;
3200 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
3201 hddLog(LOG1, "AP setup lock %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
3202 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3203 pos += 1;
3204 break;
3205 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3206 pos += 4;
3207 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
3208 hddLog(LOG1, "Selected Registra %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
3209 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3210 pos += 1;
3211 break;
3212 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3213 pos += 4;
3214 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
3215 hddLog(LOG1, "Password ID: %x\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
3216 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3217 pos += 2;
3218 break;
3219 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3220 pos += 4;
3221 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
3222 hddLog(LOG1, "Select Registra Config Methods: %x\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
3223 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3224 pos += 2;
3225 break;
3226
3227 case HDD_WPS_ELEM_UUID_E:
3228 pos += 2;
3229 length = *pos<<8 | *(pos+1);
3230 pos += 2;
3231 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
3232 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
3233 pos += length;
3234 break;
3235 case HDD_WPS_ELEM_RF_BANDS:
3236 pos += 4;
3237 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
3238 hddLog(LOG1, "RF band: %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
3239 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
3240 pos += 1;
3241 break;
3242
3243 default:
3244 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)\n", (*pos<<8 | *(pos+1)));
3245 vos_mem_free(pSap_WPSIe);
3246 return -EINVAL;
3247 }
3248 }
3249 }
3250 else {
3251 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003252 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 }
3254 break;
3255
3256 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003257 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 vos_mem_free(pSap_WPSIe);
3259 return 0;
3260 }
3261 }
3262 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
3263 {
3264 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
3265 wps_genie = wps_genie + 1;
3266 switch ( wps_genie[0] )
3267 {
3268 case DOT11F_EID_WPA:
3269 if (wps_genie[1] < 2 + 4)
3270 {
3271 vos_mem_free(pSap_WPSIe);
3272 return -EINVAL;
3273 }
3274 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3275 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003276 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 pos = &wps_genie[6];
3278 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3279 {
3280 switch((u_int16_t)(*pos<<8) | *(pos+1))
3281 {
3282 case HDD_WPS_ELEM_VERSION:
3283 pos += 4;
3284 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
3285 hddLog(LOG1, "WPS version %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
3286 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
3287 pos += 1;
3288 break;
3289
3290 case HDD_WPS_ELEM_WPS_STATE:
3291 pos +=4;
3292 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
3293 hddLog(LOG1, "WPS State %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
3294 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
3295 pos += 1;
3296 break;
3297 case HDD_WPS_ELEM_APSETUPLOCK:
3298 pos += 4;
3299 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
3300 hddLog(LOG1, "AP setup lock %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
3301 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
3302 pos += 1;
3303 break;
3304 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3305 pos += 4;
3306 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
3307 hddLog(LOG1, "Selected Registra %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
3308 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
3309 pos += 1;
3310 break;
3311 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3312 pos += 4;
3313 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
3314 hddLog(LOG1, "Password ID: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
3315 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
3316 pos += 2;
3317 break;
3318 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3319 pos += 4;
3320 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
3321 hddLog(LOG1, "Select Registra Config Methods: %x\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
3322 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
3323 pos += 2;
3324 break;
3325 case HDD_WPS_ELEM_RSP_TYPE:
3326 pos += 4;
3327 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
3328 hddLog(LOG1, "Config Methods: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
3329 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
3330 pos += 1;
3331 break;
3332 case HDD_WPS_ELEM_UUID_E:
3333 pos += 2;
3334 length = *pos<<8 | *(pos+1);
3335 pos += 2;
3336 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
3337 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
3338 pos += length;
3339 break;
3340
3341 case HDD_WPS_ELEM_MANUFACTURER:
3342 pos += 2;
3343 length = *pos<<8 | *(pos+1);
3344 pos += 2;
3345 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
3346 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
3347 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
3348 pos += length;
3349 break;
3350
3351 case HDD_WPS_ELEM_MODEL_NAME:
3352 pos += 2;
3353 length = *pos<<8 | *(pos+1);
3354 pos += 2;
3355 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
3356 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
3357 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
3358 pos += length;
3359 break;
3360 case HDD_WPS_ELEM_MODEL_NUM:
3361 pos += 2;
3362 length = *pos<<8 | *(pos+1);
3363 pos += 2;
3364 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
3365 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
3366 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
3367 pos += length;
3368 break;
3369 case HDD_WPS_ELEM_SERIAL_NUM:
3370 pos += 2;
3371 length = *pos<<8 | *(pos+1);
3372 pos += 2;
3373 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
3374 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
3375 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
3376 pos += length;
3377 break;
3378 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
3379 pos += 4;
3380 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
3381 hddLog(LOG1, "primary dev category: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
3382 pos += 2;
3383
3384 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
3385 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x\n", pos[0], pos[1], pos[2], pos[3]);
3386 pos += 4;
3387 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
3388 hddLog(LOG1, "primary dev sub category: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
3389 pos += 2;
3390 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
3391 break;
3392 case HDD_WPS_ELEM_DEVICE_NAME:
3393 pos += 2;
3394 length = *pos<<8 | *(pos+1);
3395 pos += 2;
3396 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
3397 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
3398 pos += length;
3399 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
3400 break;
3401 case HDD_WPS_ELEM_CONFIG_METHODS:
3402 pos += 4;
3403 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
3404 hddLog(LOG1, "Config Methods: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
3405 pos += 2;
3406 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
3407 break;
3408
3409 case HDD_WPS_ELEM_RF_BANDS:
3410 pos += 4;
3411 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
3412 hddLog(LOG1, "RF band: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
3413 pos += 1;
3414 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
3415 break;
3416 } // switch
3417 }
3418 }
3419 else
3420 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003421 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 }
3423
3424 } // switch
3425 }
3426 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
3427 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3428 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
3429 {
3430 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3431 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
3432 WLANSAP_Update_WpsIe ( pVosContext );
3433 }
3434
3435 vos_mem_free(pSap_WPSIe);
3436 EXIT();
3437 return halStatus;
3438}
3439
3440static int iw_softap_stopbss(struct net_device *dev,
3441 struct iw_request_info *info,
3442 union iwreq_data *wrqu,
3443 char *extra)
3444{
3445 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3446 VOS_STATUS status = VOS_STATUS_SUCCESS;
3447 ENTER();
3448 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
3449 {
3450 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
3451 {
3452 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3453
3454 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
3455
3456 if (!VOS_IS_STATUS_SUCCESS(status))
3457 {
3458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3459 ("ERROR: HDD vos wait for single_event failed!!\n"));
3460 VOS_ASSERT(0);
3461 }
3462 }
3463 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
3464 }
3465 EXIT();
3466 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
3467}
3468
3469static int iw_softap_version(struct net_device *dev,
3470 struct iw_request_info *info,
Jeff Johnsonbb2eccc2013-02-12 14:23:57 -08003471 union iwreq_data *wrqu,
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 char *extra)
3473{
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Jeff Johnsonbb2eccc2013-02-12 14:23:57 -08003475
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 ENTER();
Jeff Johnsonbb2eccc2013-02-12 14:23:57 -08003477 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 return 0;
3480}
Gopichand Nakkalaba261272013-01-03 15:45:56 -08003481
Yathish Hanumapuradoddi Shivannad1951422013-03-25 14:12:32 -07003482VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkalaba261272013-01-03 15:45:56 -08003483{
3484 v_U8_t i;
Yathish Hanumapuradoddi Shivannad1951422013-03-25 14:12:32 -07003485 int len = 0;
3486 const char sta_info_header[] = "staId staAddress\n";
3487
3488 len = snprintf(pBuf, buf_len, sta_info_header);
3489 pBuf += len;
3490 buf_len -= len;
Gopichand Nakkalaba261272013-01-03 15:45:56 -08003491
3492 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
3493 {
3494 if(pAdapter->aStaInfo[i].isUsed)
3495 {
Yathish Hanumapuradoddi Shivannad1951422013-03-25 14:12:32 -07003496 len = snprintf(pBuf, buf_len, "%*d .%02x:%02x:%02x:%02x:%02x:%02x\n",
3497 strlen("staId"),
Gopichand Nakkalaba261272013-01-03 15:45:56 -08003498 pAdapter->aStaInfo[i].ucSTAId,
3499 pAdapter->aStaInfo[i].macAddrSTA.bytes[0],
3500 pAdapter->aStaInfo[i].macAddrSTA.bytes[1],
3501 pAdapter->aStaInfo[i].macAddrSTA.bytes[2],
3502 pAdapter->aStaInfo[i].macAddrSTA.bytes[3],
3503 pAdapter->aStaInfo[i].macAddrSTA.bytes[4],
3504 pAdapter->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivannad1951422013-03-25 14:12:32 -07003505 pBuf += len;
3506 buf_len -= len;
3507 }
3508 if(WE_GET_STA_INFO_SIZE > buf_len)
3509 {
3510 break;
Gopichand Nakkalaba261272013-01-03 15:45:56 -08003511 }
3512 }
3513 return VOS_STATUS_SUCCESS;
3514}
3515
3516static int iw_softap_get_sta_info(struct net_device *dev,
3517 struct iw_request_info *info,
3518 union iwreq_data *wrqu,
3519 char *extra)
3520{
3521 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3522 VOS_STATUS status;
3523 ENTER();
Yathish Hanumapuradoddi Shivannacc79e6d2013-04-08 20:05:56 -07003524 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkalaba261272013-01-03 15:45:56 -08003525 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
3526 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!\n",__func__);
3527 return -EINVAL;
3528 }
3529 wrqu->data.length = strlen(extra);
3530 EXIT();
3531 return 0;
3532}
3533
Jeff Johnson295189b2012-06-20 16:38:30 -07003534static int iw_set_ap_genie(struct net_device *dev,
3535 struct iw_request_info *info,
3536 union iwreq_data *wrqu,
3537 char *extra)
3538{
3539
3540 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3541 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3542 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3543 u_int8_t *genie = wrqu->data.pointer;
3544
3545 ENTER();
3546
3547 if(!wrqu->data.length)
3548 {
3549 EXIT();
3550 return 0;
3551 }
3552
3553 switch (genie[0])
3554 {
3555 case DOT11F_EID_WPA:
3556 case DOT11F_EID_RSN:
3557 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
3558 {
3559 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
3560 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
3561 }
3562 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
3563 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, wrqu->data.pointer, wrqu->data.length);
3564 break;
3565
3566 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003567 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 halStatus = 0;
3569 }
3570
3571 EXIT();
3572 return halStatus;
3573}
3574
3575static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
3576{
3577 eHalStatus hstatus;
3578 long lrc;
3579 struct statsContext context;
3580
3581 if (NULL == pAdapter)
3582 {
3583 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Padapter is NULL", __func__);
3584 return VOS_STATUS_E_FAULT;
3585 }
3586
3587 init_completion(&context.completion);
3588 context.pAdapter = pAdapter;
3589 context.magic = STATS_CONTEXT_MAGIC;
3590 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3591 eCSR_HDD,
3592 SME_GLOBAL_CLASSA_STATS,
3593 hdd_GetClassA_statisticsCB,
3594 0, // not periodic
3595 FALSE, //non-cached results
3596 staid,
3597 &context);
3598 if (eHAL_STATUS_SUCCESS != hstatus)
3599 {
3600 hddLog(VOS_TRACE_LEVEL_ERROR,
3601 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003602 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 }
3604 else
3605 {
3606 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3607 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3608 context.magic = 0;
3609 if (lrc <= 0)
3610 {
3611 hddLog(VOS_TRACE_LEVEL_ERROR,
3612 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003613 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 msleep(50);
3615 }
3616 }
3617 return VOS_STATUS_SUCCESS;
3618}
3619
3620int iw_get_softap_linkspeed(struct net_device *dev,
3621 struct iw_request_info *info,
3622 union iwreq_data *wrqu,
3623 char *extra)
3624
3625{
3626 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303627 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303629 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 unsigned short staId;
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303631 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
3633 VOS_STATUS status;
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303634 int rc, valid;
3635
3636 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3637
3638 valid = wlan_hdd_validate_context(pHddCtx);
3639
3640 if (0 != valid)
3641 {
3642 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context not valid"));
3643 return valid;
3644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003645
3646 if ( hdd_string_to_hex ((char *)wrqu->data.pointer, wrqu->data.length, macAddress ) )
3647 {
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303648 hddLog(VOS_TRACE_LEVEL_FATAL, FL("ERROR: Command not found"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 return -EINVAL;
3650 }
3651
3652 status = hdd_softap_GetStaId(pHostapdAdapter, (v_MACADDR_t *)macAddress, (void *)(&staId));
3653
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303654 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 {
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303656 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 link_speed = 0;
3658 }
3659 else
3660 {
3661 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303662
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 if (!VOS_IS_STATUS_SUCCESS(status ))
3664 {
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303665 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 return -EINVAL;
3667 }
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303668
3669 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
3670 staId, &link_speed);
3671
3672 link_speed = link_speed / 10;
3673
3674 if (0 == link_speed)
3675 {
3676 /* The linkspeed returned by HAL is in units of 500kbps.
3677 * converting it to mbps.
3678 * This is required to support legacy firmware which does
3679 * not return link capacity.
3680 */
3681 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 }
3684
3685 wrqu->data.length = len;
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303686 rc = snprintf(pLinkSpeed, len, "%lu", link_speed);
3687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 if ((rc < 0) || (rc >= len))
3689 {
3690 // encoding or length error?
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303691 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 return -EIO;
3693 }
3694
3695 return 0;
3696}
3697
3698static const iw_handler hostapd_handler[] =
3699{
3700 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3701 (iw_handler) NULL, /* SIOCGIWNAME */
3702 (iw_handler) NULL, /* SIOCSIWNWID */
3703 (iw_handler) NULL, /* SIOCGIWNWID */
3704 (iw_handler) NULL, /* SIOCSIWFREQ */
3705 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
3706 (iw_handler) NULL, /* SIOCSIWMODE */
3707 (iw_handler) NULL, /* SIOCGIWMODE */
3708 (iw_handler) NULL, /* SIOCSIWSENS */
3709 (iw_handler) NULL, /* SIOCGIWSENS */
3710 (iw_handler) NULL, /* SIOCSIWRANGE */
3711 (iw_handler) NULL, /* SIOCGIWRANGE */
3712 (iw_handler) NULL, /* SIOCSIWPRIV */
3713 (iw_handler) NULL, /* SIOCGIWPRIV */
3714 (iw_handler) NULL, /* SIOCSIWSTATS */
3715 (iw_handler) NULL, /* SIOCGIWSTATS */
3716 (iw_handler) NULL, /* SIOCSIWSPY */
3717 (iw_handler) NULL, /* SIOCGIWSPY */
3718 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3719 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3720 (iw_handler) NULL, /* SIOCSIWAP */
3721 (iw_handler) NULL, /* SIOCGIWAP */
3722 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
3723 (iw_handler) NULL, /* SIOCGIWAPLIST */
3724 (iw_handler) NULL, /* SIOCSIWSCAN */
3725 (iw_handler) NULL, /* SIOCGIWSCAN */
3726 (iw_handler) NULL, /* SIOCSIWESSID */
3727 (iw_handler) NULL, /* SIOCGIWESSID */
3728 (iw_handler) NULL, /* SIOCSIWNICKN */
3729 (iw_handler) NULL, /* SIOCGIWNICKN */
3730 (iw_handler) NULL, /* -- hole -- */
3731 (iw_handler) NULL, /* -- hole -- */
3732 (iw_handler) NULL, /* SIOCSIWRATE */
3733 (iw_handler) NULL, /* SIOCGIWRATE */
3734 (iw_handler) NULL, /* SIOCSIWRTS */
3735 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
3736 (iw_handler) NULL, /* SIOCSIWFRAG */
3737 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
3738 (iw_handler) NULL, /* SIOCSIWTXPOW */
3739 (iw_handler) NULL, /* SIOCGIWTXPOW */
3740 (iw_handler) NULL, /* SIOCSIWRETRY */
3741 (iw_handler) NULL, /* SIOCGIWRETRY */
3742 (iw_handler) NULL, /* SIOCSIWENCODE */
3743 (iw_handler) NULL, /* SIOCGIWENCODE */
3744 (iw_handler) NULL, /* SIOCSIWPOWER */
3745 (iw_handler) NULL, /* SIOCGIWPOWER */
3746 (iw_handler) NULL, /* -- hole -- */
3747 (iw_handler) NULL, /* -- hole -- */
3748 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
3749 (iw_handler) NULL, /* SIOCGIWGENIE */
3750 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
3751 (iw_handler) NULL, /* SIOCGIWAUTH */
3752 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
3753 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
3754 (iw_handler) NULL, /* SIOCSIWPMKSA */
3755};
3756
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -08003757#define IW_PRIV_TYPE_OPTIE (IW_PRIV_TYPE_BYTE | QCSAP_MAX_OPT_IE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003758#define IW_PRIV_TYPE_MLME \
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -08003759 (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_mlme))
Jeff Johnson295189b2012-06-20 16:38:30 -07003760
3761static const struct iw_priv_args hostapd_private_args[] = {
3762 { QCSAP_IOCTL_SETPARAM,
3763 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
3764 { QCSAP_IOCTL_SETPARAM,
3765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
3766 { QCSAP_PARAM_MAX_ASSOC,
3767 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
3768 { QCSAP_PARAM_HIDE_SSID,
3769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Changb77d2882013-08-22 14:59:44 -07003770 { QCSAP_PARAM_SET_MC_RATE,
3771 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 { QCSAP_IOCTL_GETPARAM,
3773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3774 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
3775 { QCSAP_IOCTL_GETPARAM, 0,
3776 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
3777 { QCSAP_PARAM_MAX_ASSOC, 0,
3778 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07003779 { QCSAP_PARAM_GET_WLAN_DBG, 0,
3780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
3781 { QCSAP_PARAM_AUTO_CHANNEL, 0,
3782 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 { QCSAP_PARAM_MODULE_DOWN_IND, 0,
3784 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "moduleDownInd" },
3785 { QCSAP_PARAM_CLR_ACL, 0,
3786 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
3787 { QCSAP_PARAM_ACL_MODE,
3788 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
3789 { QCSAP_IOCTL_COMMIT,
3790 IW_PRIV_TYPE_BYTE | sizeof(struct s_CommitConfig) | IW_PRIV_SIZE_FIXED, 0, "commit" },
3791 { QCSAP_IOCTL_SETMLME,
3792 IW_PRIV_TYPE_BYTE | sizeof(struct sQcSapreq_mlme)| IW_PRIV_SIZE_FIXED, 0, "setmlme" },
3793 { QCSAP_IOCTL_GET_STAWPAIE,
3794 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
3795 { QCSAP_IOCTL_SETWPAIE,
3796 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
3797 { QCSAP_IOCTL_STOPBSS,
3798 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
3799 { QCSAP_IOCTL_VERSION, 0,
3800 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkalaba261272013-01-03 15:45:56 -08003801 { QCSAP_IOCTL_GET_STA_INFO, 0,
3802 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
3804 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED | 1, 0, "getProbeReqIEs" },
3805 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07003806 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003807 { QCSAP_IOCTL_ASSOC_STA_MACADDR, 0,
3808 IW_PRIV_TYPE_BYTE | /*((WLAN_MAX_STA_COUNT*6)+100)*/1 , "get_assoc_stamac" },
3809 { QCSAP_IOCTL_DISASSOC_STA,
3810 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
3811 { QCSAP_IOCTL_AP_STATS,
3812 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE, 0, "ap_stats" },
3813 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
3814 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala11ab4da2013-05-29 15:33:14 +05303815 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003816
3817 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
3818 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
3819 /* handlers for sub-ioctl */
3820 { WE_SET_WLAN_DBG,
3821 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
3822 0,
3823 "setwlandbg" },
3824
3825 /* handlers for main ioctl */
3826 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
3827 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3828 0,
3829 "" },
3830
3831 /* handlers for sub-ioctl */
3832 { WE_LOG_DUMP_CMD,
3833 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3834 0,
3835 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 { WE_P2P_NOA_CMD,
3837 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3838 0,
3839 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08003840 /* handlers for sub ioctl */
3841 {
3842 WE_MCC_CONFIG_CREDENTIAL,
3843 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3844 0,
3845 "setMccCrdnl" },
3846
3847 /* handlers for sub ioctl */
3848 {
3849 WE_MCC_CONFIG_PARAMS,
3850 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3851 0,
3852 "setMccConfig" },
3853
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 /* handlers for main ioctl */
3855 { QCSAP_IOCTL_MODIFY_ACL,
3856 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
3857 0,
3858 "modify_acl" },
3859
3860 /* handlers for main ioctl */
3861 { QCSAP_IOCTL_GET_CHANNEL_LIST,
3862 0,
3863 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
3864 "getChannelList" },
3865
Jeff Johnsone7245742012-09-05 17:12:55 -07003866 /* handlers for main ioctl */
3867 { QCSAP_IOCTL_SET_TX_POWER,
3868 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3869 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05303870 "setTxPower" },
schangd82195a2013-03-13 18:41:24 -07003871
3872 /* handlers for main ioctl */
3873 { QCSAP_IOCTL_SET_MAX_TX_POWER,
3874 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3875 0,
3876 "setTxMaxPower" },
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05303877 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
3878 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE, 0, "dataSnapshot" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003879};
Jeff Johnsone7245742012-09-05 17:12:55 -07003880
Jeff Johnson295189b2012-06-20 16:38:30 -07003881static const iw_handler hostapd_private[] = {
3882 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
3883 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
3884 [QCSAP_IOCTL_COMMIT - SIOCIWFIRSTPRIV] = iw_softap_commit, //get priv ioctl
3885 [QCSAP_IOCTL_SETMLME - SIOCIWFIRSTPRIV] = iw_softap_setmlme,
3886 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
3887 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
3888 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
3889 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
3890 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
3891 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
3892 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
3893 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
3894 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
3895 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
3896 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
3897 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
3898 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
3899 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkalaba261272013-01-03 15:45:56 -08003900 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07003901 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
3902 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schangd82195a2013-03-13 18:41:24 -07003903 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudi56dfbbd2013-05-10 11:32:06 +05303904 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Jeff Johnson295189b2012-06-20 16:38:30 -07003905};
3906const struct iw_handler_def hostapd_handler_def = {
3907 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
3908 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
3909 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
3910 .standard = (iw_handler *)hostapd_handler,
3911 .private = (iw_handler *)hostapd_private,
3912 .private_args = hostapd_private_args,
3913 .get_wireless_stats = NULL,
3914};
3915#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
3916struct net_device_ops net_ops_struct = {
3917 .ndo_open = hdd_hostapd_open,
3918 .ndo_stop = hdd_hostapd_stop,
3919 .ndo_uninit = hdd_hostapd_uninit,
3920 .ndo_start_xmit = hdd_softap_hard_start_xmit,
3921 .ndo_tx_timeout = hdd_softap_tx_timeout,
3922 .ndo_get_stats = hdd_softap_stats,
3923 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
3924 .ndo_do_ioctl = hdd_hostapd_ioctl,
3925 .ndo_change_mtu = hdd_hostapd_change_mtu,
3926 .ndo_select_queue = hdd_hostapd_select_queue,
3927 };
3928#endif
3929
3930int hdd_set_hostapd(hdd_adapter_t *pAdapter)
3931{
3932 return VOS_STATUS_SUCCESS;
3933}
3934
3935void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
3936{
3937#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
3938 pWlanHostapdDev->netdev_ops = &net_ops_struct;
3939#else
3940 pWlanHostapdDev->open = hdd_hostapd_open;
3941 pWlanHostapdDev->stop = hdd_hostapd_stop;
3942 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
3943 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
3944 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
3945 pWlanHostapdDev->get_stats = hdd_softap_stats;
3946 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
3947 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
3948#endif
3949}
3950
3951VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
3952{
3953 hdd_hostapd_state_t * phostapdBuf;
3954 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere9d968292013-06-25 11:26:22 -07003955 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 VOS_STATUS status;
3957 ENTER();
3958 // Allocate the Wireless Extensions state structure
3959 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
3960
Kiran Kumar Lokere9d968292013-06-25 11:26:22 -07003961 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
3962
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 // Zero the memory. This zeros the profile structure.
3964 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
3965
3966 // Set up the pointer to the Wireless Extensions state structure
3967 // NOP
3968 status = hdd_set_hostapd(pAdapter);
3969 if(!VOS_IS_STATUS_SUCCESS(status)) {
3970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!\n"));
3971 return status;
3972 }
3973
3974 status = vos_event_init(&phostapdBuf->vosEvent);
3975 if (!VOS_IS_STATUS_SUCCESS(status))
3976 {
3977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!\n"));
3978 return status;
3979 }
3980
3981 init_completion(&pAdapter->session_close_comp_var);
3982 init_completion(&pAdapter->session_open_comp_var);
3983
3984 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
3985
3986 // Register as a wireless device
3987 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
3988
3989 //Initialize the data path module
3990 status = hdd_softap_init_tx_rx(pAdapter);
3991 if ( !VOS_IS_STATUS_SUCCESS( status ))
3992 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003993 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 }
3995
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 EXIT();
3998 return status;
3999}
4000
4001hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
4002{
4003 struct net_device *pWlanHostapdDev = NULL;
4004 hdd_adapter_t *pHostapdAdapter = NULL;
4005 v_CONTEXT_t pVosContext= NULL;
4006
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07004008
4009 if (pWlanHostapdDev != NULL)
4010 {
4011 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
4012
4013 //Init the net_device structure
4014 ether_setup(pWlanHostapdDev);
4015
4016 //Initialize the adapter context to zeros.
4017 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
4018 pHostapdAdapter->dev = pWlanHostapdDev;
4019 pHostapdAdapter->pHddCtx = pHddCtx;
4020 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
4021
4022 //Get the Global VOSS context.
4023 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
4024 //Save the adapter context in global context for future.
4025 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
4026
4027 //Init the net_device structure
4028 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
4029
4030 hdd_set_ap_ops( pHostapdAdapter->dev );
4031
4032 pWlanHostapdDev->tx_queue_len = NET_DEV_TX_QUEUE_LEN;
4033 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
4034 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
4035
4036 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
4037 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
4038
4039 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
4041 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
4042 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
4043 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
4045 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
4046#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4047 init_completion(&pHostapdAdapter->offchannel_tx_event);
4048#endif
4049
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
4051 }
4052 return pHostapdAdapter;
4053}
4054
4055VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
4056{
4057 struct net_device *dev = pAdapter->dev;
4058 VOS_STATUS status = VOS_STATUS_SUCCESS;
4059
4060 ENTER();
4061
4062 if( rtnl_lock_held )
4063 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08004064 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 if( dev_alloc_name(dev, dev->name) < 0 )
4066 {
4067 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
4068 return VOS_STATUS_E_FAILURE;
4069 }
4070 }
4071 if (register_netdevice(dev))
4072 {
4073 hddLog(VOS_TRACE_LEVEL_FATAL,
4074 "%s:Failed:register_netdevice", __func__);
4075 return VOS_STATUS_E_FAILURE;
4076 }
4077 }
4078 else
4079 {
4080 if (register_netdev(dev))
4081 {
4082 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
4083 return VOS_STATUS_E_FAILURE;
4084 }
4085 }
4086 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
4087
4088 EXIT();
4089 return status;
4090}
4091
4092VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter)
4093{
4094 ENTER();
4095
4096 hdd_softap_deinit_tx_rx(pAdapter);
4097
4098 /* if we are being called during driver unload, then the dev has already
4099 been invalidated. if we are being called at other times, then we can
4100 detatch the wireless device handlers */
4101 if (pAdapter->dev)
4102 {
4103 pAdapter->dev->wireless_handlers = NULL;
4104 }
4105 EXIT();
4106 return 0;
4107}