blob: 84f325af4f0bf59ff47ab618155a2217bdf52f76 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-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 Chang614d2072013-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 Shivanna7b659402013-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 Chang614d2072013-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 Veetil2aad8d82013-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 Koyyalamudicd784992013-01-11 15:30:36 -0800961 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-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 Koyyalamudie1b791f2013-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 Kohalli90e4c752013-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;
Kumar Pavan0cf0cf22012-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,
Kumar Pavan0cf0cf22012-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 Singhal6144c002013-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 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001153#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001154 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1155 {
1156 wake_unlock(&pHddCtx->sap_wake_lock);
1157 }
Amar Singhal6144c002013-05-03 16:11:42 -07001158 wake_lock_timeout(&pHddCtx->sap_wake_lock, msecs_to_jiffies(HDD_SAP_WAKE_LOCK_DURATION));
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001160#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1161 {
1162 struct station_info staInfo;
1163 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1164
1165 memset(&staInfo, 0, sizeof(staInfo));
1166 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1167 {
1168 staInfo.assoc_req_ies =
1169 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
1170 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001171#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001172 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
1173#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 cfg80211_new_sta(dev,
1175 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
1176 &staInfo, GFP_KERNEL);
1177 }
1178 else
1179 {
1180 hddLog(LOGE, FL(" Assoc Ie length is too long \n"));
1181 }
1182 }
1183#endif
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001184 pScanInfo = &pHddCtx->scan_info;
1185 // Lets do abort scan to ensure smooth authentication for client
1186 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1187 {
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05301188 hdd_abort_mac_scan(pHddCtx, pHostapdAdapter->sessionId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001190
1191 break;
1192 case eSAP_STA_DISASSOC_EVENT:
1193 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001194 sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(wrqu.addr.sa_data));
1196 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1197 hddLog(LOG1," User initiated disassociation");
1198 else
1199 hddLog(LOG1," MAC initiated disassociation");
1200 we_event = IWEVEXPIRED;
1201 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1202 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1203 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001204 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 -07001205 return VOS_STATUS_E_FAILURE;
1206 }
1207 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1208
1209 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1210 {
1211 spin_lock_bh( &pHostapdAdapter->staInfo_lock );
1212 // Start AP inactivity timer if no stations associated with it
1213 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1214 {
1215 if (pHostapdAdapter->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
1216 {
1217 bApActive = TRUE;
1218 break;
1219 }
1220 }
1221 spin_unlock_bh( &pHostapdAdapter->staInfo_lock );
1222
1223 if (bApActive == FALSE)
1224 {
1225 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1226 {
1227 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1228 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1229 hddLog(LOGE, FL("Failed to init AP inactivity timer\n"));
1230 }
1231 else
1232 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1233 }
1234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001235#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1236 cfg80211_del_sta(dev,
1237 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1238 GFP_KERNEL);
1239#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001240 //Update the beacon Interval if it is P2P GO
1241 hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 break;
1243 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1244 {
1245 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1246 union iwreq_data wreq;
1247
1248 down(&pHddApCtx->semWpsPBCOverlapInd);
1249 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1250
1251 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1252 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1253
1254 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
1255 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
1256 memset(&wreq, 0, sizeof(wreq));
1257 wreq.data.length = strlen(message); // This is length of message
1258 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1259
1260 return VOS_STATUS_SUCCESS;
1261 }
1262 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1263 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1264 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1265 { // List of associated stations
1266 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1267 {
1268 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1269 i+1,
1270 pAssocStasArray->assocId,
1271 pAssocStasArray->staId,
1272 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1273 pAssocStasArray++;
1274 }
1275 }
1276 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
1277 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 case eSAP_INDICATE_MGMT_FRAME:
1279 hdd_indicateMgmtFrame( pHostapdAdapter,
1280 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
1281 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
1282 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05301283 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 return VOS_STATUS_SUCCESS;
1285 case eSAP_REMAIN_CHAN_READY:
1286 hdd_remainChanReadyHandler( pHostapdAdapter );
1287 return VOS_STATUS_SUCCESS;
1288 case eSAP_SEND_ACTION_CNF:
1289 hdd_sendActionCnf( pHostapdAdapter,
1290 ( eSAP_STATUS_SUCCESS ==
1291 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1292 TRUE : FALSE );
1293 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 case eSAP_UNKNOWN_STA_JOIN:
1295 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1296 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1297 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1298 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1299 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1300 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1301 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1302 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1303 wrqu.data.pointer = unknownSTAEvent;
1304 wrqu.data.length = strlen(unknownSTAEvent);
1305 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
1306 hddLog(LOG1,"%s\n", unknownSTAEvent);
1307 break;
1308
1309 case eSAP_MAX_ASSOC_EXCEEDED:
1310 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1311 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1312 " one or more devices to enable the new device connection",
1313 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1314 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1315 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1316 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1317 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1318 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1319 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1320 wrqu.data.pointer = maxAssocExceededEvent;
1321 wrqu.data.length = strlen(maxAssocExceededEvent);
1322 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
1323 hddLog(LOG1,"%s\n", maxAssocExceededEvent);
1324 break;
1325 case eSAP_STA_ASSOC_IND:
1326 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001327
1328 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
1329 hddLog(LOG1, FL(" Disconnecting all the P2P Clients....\n"));
1330 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1331 return VOS_STATUS_SUCCESS;
1332
1333 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
1334 hdd_stop_p2p_link(pHostapdAdapter, usrDataForCallback);
1335 return VOS_STATUS_SUCCESS;
1336
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 default:
1338 hddLog(LOG1,"SAP message is not handled\n");
1339 goto stopbss;
1340 return VOS_STATUS_SUCCESS;
1341 }
1342 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1343 return VOS_STATUS_SUCCESS;
1344
1345stopbss :
1346 {
1347 v_BYTE_t we_custom_event[64];
1348 char *stopBssEvent = "STOP-BSS.response";//17
1349 int event_len = strlen(stopBssEvent);
1350
1351 hddLog(LOG1, FL("BSS stop status = %s"),
1352 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1353 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1354
1355 /* Change the BSS state now since, as we are shutting things down,
1356 * we don't want interfaces to become re-enabled */
1357 pHostapdState->bssState = BSS_STOP;
1358
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301359 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1360 {
1361 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1362 {
1363 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1364 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1365 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1366 }
1367
1368 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1369 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1370 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1371 }
1372
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 /* Stop the pkts from n/w stack as we are going to free all of
1374 * the TX WMM queues for all STAID's */
1375 hdd_hostapd_stop(dev);
1376
1377 /* reclaim all resources allocated to the BSS */
1378 hdd_softap_stop_bss(pHostapdAdapter);
1379
Amar Singhal37e6f052013-03-05 16:16:54 -08001380 /* once the event is set, structure dev/pHostapdAdapter should
1381 * not be touched since they are now subject to being deleted
1382 * by another thread */
1383 if (eSAP_STOP_BSS_EVENT == sapEvent)
1384 vos_event_set(&pHostapdState->vosEvent);
1385
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 /* notify userspace that the BSS has stopped */
1387 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1388 memcpy(&we_custom_event, stopBssEvent, event_len);
1389 memset(&wrqu, 0, sizeof(wrqu));
1390 wrqu.data.length = event_len;
1391 we_event = IWEVCUSTOM;
1392 we_custom_event_generic = we_custom_event;
1393 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001394 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 }
1396 return VOS_STATUS_SUCCESS;
1397}
1398int hdd_softap_unpackIE(
1399 tHalHandle halHandle,
1400 eCsrEncryptionType *pEncryptType,
1401 eCsrEncryptionType *mcEncryptType,
1402 eCsrAuthType *pAuthType,
1403 u_int16_t gen_ie_len,
1404 u_int8_t *gen_ie )
1405{
1406 tDot11fIERSN dot11RSNIE;
1407 tDot11fIEWPA dot11WPAIE;
1408
1409 tANI_U8 *pRsnIe;
1410 tANI_U16 RSNIeLen;
1411
1412 if (NULL == halHandle)
1413 {
1414 hddLog(LOGE, FL("Error haHandle returned NULL\n"));
1415 return -EINVAL;
1416 }
1417
1418 // Validity checks
1419 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1420 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1421 return -EINVAL;
1422 // Type check
1423 if ( gen_ie[0] == DOT11F_EID_RSN)
1424 {
1425 // Validity checks
1426 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1427 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1428 {
1429 return VOS_STATUS_E_FAILURE;
1430 }
1431 // Skip past the EID byte and length byte
1432 pRsnIe = gen_ie + 2;
1433 RSNIeLen = gen_ie_len - 2;
1434 // Unpack the RSN IE
1435 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1436 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1437 pRsnIe,
1438 RSNIeLen,
1439 &dot11RSNIE);
1440 // Copy out the encryption and authentication types
1441 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001442 __func__, dot11RSNIE.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 hddLog(LOG1, FL("%s: authentication suite count: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001444 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 /*Here we have followed the apple base code,
1446 but probably I suspect we can do something different*/
1447 //dot11RSNIE.akm_suite_count
1448 // Just translate the FIRST one
1449 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1450 //dot11RSNIE.pwise_cipher_suite_count
1451 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1452 //dot11RSNIE.gp_cipher_suite_count
1453 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1454 // Set the PMKSA ID Cache for this interface
1455
1456 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1457 } else
1458 if (gen_ie[0] == DOT11F_EID_WPA)
1459 {
1460 // Validity checks
1461 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1462 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1463 {
1464 return VOS_STATUS_E_FAILURE;
1465 }
1466 // Skip past the EID byte and length byte - and four byte WiFi OUI
1467 pRsnIe = gen_ie + 2 + 4;
1468 RSNIeLen = gen_ie_len - (2 + 4);
1469 // Unpack the WPA IE
1470 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1471 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1472 pRsnIe,
1473 RSNIeLen,
1474 &dot11WPAIE);
1475 // Copy out the encryption and authentication types
1476 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001477 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 hddLog(LOG1, FL("%s: WPA authentication suite count: %d\n"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001479 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 //dot11WPAIE.auth_suite_count
1481 // Just translate the FIRST one
1482 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1483 //dot11WPAIE.unicast_cipher_count
1484 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1485 //dot11WPAIE.unicast_cipher_count
1486 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
1487 }
1488 else
1489 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001490 hddLog(LOGW, FL("%s: gen_ie[0]: %d\n"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 return VOS_STATUS_E_FAILURE;
1492 }
1493 return VOS_STATUS_SUCCESS;
1494}
Leo Chang614d2072013-08-22 14:59:44 -07001495
1496/**---------------------------------------------------------------------------
1497
1498 \brief hdd_hostapd_set_mc_rate_cb() -
1499
1500 This is called to notify associated stas information ready
1501
1502 \param - sapEvent Pointer to get associated stas event
1503 \param - apDriver SoftAP context
1504
1505 \return - none
1506
1507 --------------------------------------------------------------------------*/
1508void hdd_hostapd_set_mc_rate_cb
1509(
1510 tSap_Event *sapEvent,
1511 void *apDriver
1512)
1513{
1514 hdd_ap_ctx_t *apCtxt;
1515
1516 if ((NULL == apDriver) || (NULL == sapEvent))
1517 {
1518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1519 "%s : Invalid arguments", __func__);
1520 return;
1521 }
1522
1523 apCtxt = (hdd_ap_ctx_t *)apDriver;
1524
1525 /* there is a race condition that exists between this callback function
1526 and the caller since the caller could time out either before or
1527 while this code is executing. we'll assume the timeout hasn't
1528 occurred, but we'll verify that right before complete our work */
1529 if (SAP_GET_STAS_COOKIE == apCtxt->getStasCookie)
1530 {
1531 vos_mem_copy((void *)&apCtxt->getStasEventBuffer,
1532 (void *)sapEvent,
1533 sizeof(tSap_Event));
1534 complete(&apCtxt->sap_get_associated_stas_complete);
1535 }
1536 else
1537 {
1538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1539 "%s : Invalid cookie", __func__);
1540 }
1541 return;
1542}
1543
1544/**---------------------------------------------------------------------------
1545
1546 \brief hdd_hostapd_set_mc_rate_update
1547
1548 This is called to find rate and send cfg command to FW
1549
1550 \param - sapEvent Pointer to get associated stas event
1551 \param - pHostapdAdapter SoftAP Adapter Context
1552
1553 \return - int, 0 success
1554 negative fail
1555
1556 --------------------------------------------------------------------------*/
1557static int hdd_hostapd_set_mc_rate_update
1558(
1559 tSap_Event *sapEvent,
1560 hdd_adapter_t *pHostapdAdapter
1561)
1562{
1563 tHalHandle hHal;
1564 hdd_ap_ctx_t *apCtxt;
1565 tSap_AssocMacAddr *assocSta;
1566 rate_cfg_11ac_max_mcs_t supportedAcMaxMcs = RATE_CFG_RATE_11AC_MAX_MCS_7;
1567 rate_cfg_supported_bw_t bandWidth;
1568 rate_cfg_gi_t gi;
1569 rate_cfg_item_mapping_t *nMappingTable = NULL;
1570 rate_cfg_item_mapping_t *acMappingTable = NULL;
1571 v_U8_t stasLoop, ratesLoop;
1572 v_U8_t rateArrayOrder;
1573 v_U8_t mcsTable11n;
1574 v_U16_t targetCfgId = 0;
1575 v_U16_t targetCfgValue = 0;
1576 v_U16_t currentRate;
1577 v_U16_t combinedSupportMap = 0xFFFF;
1578 v_U16_t supportMap = 0x0000;
1579 v_U16_t supportedChannelCount = 0;
1580 v_U32_t legacyRates[SAP_LEGACY_RATE_COUNT];
1581 int rc = 0;
1582 tSirRetStatus cfdStat;
1583
1584 if ((NULL == pHostapdAdapter) || (NULL == sapEvent))
1585 {
1586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1587 "%s : Invalid arguments", __func__);
1588 return -1;
1589 }
1590
1591 apCtxt = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1592 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1594 "setMcRateCB NUM SAT %d, targetMCRate %d, current channel %d",
1595 sapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta,
1596 apCtxt->targetMCRate,
1597 apCtxt->operatingChannel);
1598
1599 if (!sapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta)
1600 {
1601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1602 "Not connected any STA yet");
1603 return -1;
1604 }
1605
1606 for (stasLoop = 0;
1607 stasLoop < sapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta;
1608 stasLoop++)
1609 {
1610 vos_mem_zero((v_U8_t *)legacyRates,
1611 SAP_LEGACY_RATE_COUNT * sizeof(legacyRates));
1612 rateArrayOrder = 0;
1613 mcsTable11n = 0;
1614 supportedChannelCount = 0;
1615 assocSta = sapEvent->sapevt.sapAssocStaListEvent.pAssocStas++;
1616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1617 "ASSOSID %d, OPM %d, nBM %d, SGI40 %d, SGI20 %d, S40 %d",
1618 assocSta->assocId,
1619 assocSta->supportedRates.opRateMode,
1620 assocSta->supportedRates.aniEnhancedRateBitmap,
1621 assocSta->ShortGI40Mhz,
1622 assocSta->ShortGI20Mhz,
1623 assocSta->Support40Mhz);
1624
1625 /* Legacy Rate */
1626 for (ratesLoop = 0; ratesLoop < SIR_NUM_11B_RATES; ratesLoop++)
1627 {
1628 currentRate = assocSta->supportedRates.llbRates[ratesLoop] &
1629 SAP_LEGACY_RATE_MASK;
1630
1631 /* To fix KW error report */
1632 if (SAP_LEGACY_RATE_COUNT <= rateArrayOrder)
1633 {
1634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1635 "%s, Invalid array Size, break", __func__);
1636 break;
1637 }
1638
1639 /* Make 100kbps order */
1640 legacyRates[rateArrayOrder] = (currentRate * 100) / 20;
1641 rateArrayOrder++;
1642 if (currentRate)
1643 {
1644 supportedChannelCount++;
1645 }
1646 }
1647 for (ratesLoop = 0; ratesLoop < SIR_NUM_11A_RATES; ratesLoop++)
1648 {
1649 currentRate = assocSta->supportedRates.llaRates[ratesLoop] &
1650 SAP_LEGACY_RATE_MASK;
1651 /* To fix KW error report */
1652 if (SAP_LEGACY_RATE_COUNT <= rateArrayOrder)
1653 {
1654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1655 "%s, Invalid array Size, break", __func__);
1656 break;
1657 }
1658
1659 /* Make 100kbps order */
1660 legacyRates[rateArrayOrder] = (currentRate * 100) / 20;
1661 rateArrayOrder++;
1662 if (currentRate)
1663 {
1664 supportedChannelCount++;
1665 }
1666 }
1667 if (supportedChannelCount)
1668 {
1669 for (ratesLoop = 0; ratesLoop < SAP_LEGACY_RATE_COUNT; ratesLoop++)
1670 {
1671 if (legacyRates[ratesLoop] == apCtxt->targetMCRate)
1672 {
1673 supportMap |= (1 << RATE_CFG_RATE_LEGACY);
1674 break;
1675 }
1676 }
1677 }
1678
1679 /* 11N */
1680 if (eSTA_11n <= assocSta->supportedRates.opRateMode)
1681 {
1682 if (assocSta->Support40Mhz)
1683 {
1684 mcsTable11n |= 0x01;
1685 if (assocSta->ShortGI40Mhz)
1686 {
1687 mcsTable11n |= 0x02;
1688 supportMap |= (1 << RATE_CFG_RATE_11N_MCS_SGI_40);
1689 nMappingTable = n_s40_rate_mapping;
1690 }
1691 else
1692 {
1693 supportMap |= (1 << RATE_CFG_RATE_11N_MCS_LGI_40);
1694 nMappingTable = n_l40_rate_mapping;
1695 }
1696 }
1697 else
1698 {
1699 if (assocSta->ShortGI20Mhz)
1700 {
1701 mcsTable11n |= 0x02;
1702 supportMap |= (1 << RATE_CFG_RATE_11N_MCS_SGI_20);
1703 nMappingTable = n_s20_rate_mapping;
1704 }
1705 else
1706 {
1707 supportMap |= (1 << RATE_CFG_RATE_11N_MCS_LGI_20);
1708 nMappingTable = n_l20_rate_mapping;
1709 }
1710 }
1711 }
1712
1713#ifdef WLAN_FEATURE_11AC
1714 /* 11AC */
1715 if (eSTA_11ac <= assocSta->supportedRates.opRateMode)
1716 {
1717 /* Find supported MAX MCS */
1718 supportedAcMaxMcs = assocSta->supportedRates.vhtRxMCSMap &
1719 SAP_AC_MCS_MAP_MASK;
1720 supportedAcMaxMcs += SAP_AC_MCS_MAP_OFFSET;
1721 /* Find channel characteristics from MAX rate */
1722 if (mcs_rate_11ac[supportedAcMaxMcs].cb80_rate_11ac[0] ==
1723 assocSta->supportedRates.vhtRxHighestDataRate)
1724 {
1725 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_LGI_80);
1726 bandWidth = RATE_CFG_RATE_BW_80;
1727 gi = RATE_CFG_RATE_GI_LONG;
1728 acMappingTable = ac_l80_rate_mapping;
1729 }
1730 else if (mcs_rate_11ac[supportedAcMaxMcs].cb80_rate_11ac[1] ==
1731 assocSta->supportedRates.vhtRxHighestDataRate)
1732 {
1733 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_SGI_80);
1734 bandWidth = RATE_CFG_RATE_BW_80;
1735 gi = RATE_CFG_RATE_GI_SHORT;
1736 acMappingTable = ac_s80_rate_mapping;
1737 }
1738 else if (mcs_rate_11ac[supportedAcMaxMcs].cb40_rate_11ac[0] ==
1739 assocSta->supportedRates.vhtRxHighestDataRate)
1740 {
1741 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_LGI_40);
1742 bandWidth = RATE_CFG_RATE_BW_40;
1743 gi = RATE_CFG_RATE_GI_LONG;
1744 acMappingTable = ac_l40_rate_mapping;
1745 }
1746 else if (mcs_rate_11ac[supportedAcMaxMcs].cb40_rate_11ac[1] ==
1747 assocSta->supportedRates.vhtRxHighestDataRate)
1748 {
1749 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_SGI_40);
1750 bandWidth = RATE_CFG_RATE_BW_40;
1751 gi = RATE_CFG_RATE_GI_SHORT;
1752 acMappingTable = ac_s40_rate_mapping;
1753 }
1754 else if (mcs_rate_11ac[supportedAcMaxMcs].cb20_rate_11ac[0] ==
1755 assocSta->supportedRates.vhtRxHighestDataRate)
1756 {
1757 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_LGI_20);
1758 bandWidth = RATE_CFG_RATE_BW_20;
1759 gi = RATE_CFG_RATE_GI_LONG;
1760 acMappingTable = ac_l20_rate_mapping;
1761 }
1762 else if (mcs_rate_11ac[supportedAcMaxMcs].cb20_rate_11ac[1] ==
1763 assocSta->supportedRates.vhtRxHighestDataRate)
1764 {
1765 supportMap |= (1 << RATE_CFG_RATE_11AC_MCS_SGI_20);
1766 bandWidth = RATE_CFG_RATE_BW_20;
1767 gi = RATE_CFG_RATE_GI_SHORT;
1768 acMappingTable = ac_s20_rate_mapping;
1769 }
1770 }
1771#endif /* WLAN_FEATURE_11AC */
1772 combinedSupportMap &= supportMap;
1773 }
1774
1775 if ((!combinedSupportMap) &&
1776 (!sapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta))
1777 {
1778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1779 "%s, No Common supported rate, discard", __func__);
1780 return -1;
1781 }
1782
1783 /* Select target band */
1784 if (apCtxt->operatingChannel <=
1785 SAP_MAX_24_CHANNEL_NUMBER)
1786 {
1787 targetCfgId = WNI_CFG_FIXED_RATE_MULTICAST_24GHZ;
1788 }
1789 else
1790 {
1791 targetCfgId = WNI_CFG_FIXED_RATE_MULTICAST_5GHZ;
1792 }
1793
1794 /* First find from legacy */
1795 if (combinedSupportMap & SAP_RATE_SUPPORT_MAP_LEGACY_MASK)
1796 {
1797 for (ratesLoop = 0; ratesLoop < SAP_LEGACY_RATE_COUNT; ratesLoop++)
1798 {
1799 if (apCtxt->targetMCRate ==
1800 legacy_rate_mapping[ratesLoop].rate)
1801 {
1802 targetCfgValue = legacy_rate_mapping[ratesLoop].eRateCfg;
1803 break;
1804 }
1805 }
1806 }
1807
1808 /* If available same on 11N, update target rate */
1809 if ((combinedSupportMap & SAP_RATE_SUPPORT_MAP_N_MASK) &&
1810 (NULL != nMappingTable))
1811 {
1812 for (ratesLoop = 0; ratesLoop < SAP_11N_RATE_COUNT; ratesLoop++)
1813 {
1814 if (apCtxt->targetMCRate == nMappingTable[ratesLoop].rate)
1815 {
1816 targetCfgValue = nMappingTable[ratesLoop].eRateCfg;
1817 break;
1818 }
1819 }
1820 }
1821
1822#ifdef WLAN_FEATURE_11AC
1823 /* If available same on 11AC, update target rate */
1824 if ((combinedSupportMap & SAP_RATE_SUPPORT_MAP_AC_MASK) &&
1825 (NULL != acMappingTable))
1826 {
1827 for (ratesLoop = 0; ratesLoop < supportedAcMaxMcs; ratesLoop++)
1828 {
1829 if (apCtxt->targetMCRate == acMappingTable[ratesLoop].rate)
1830 {
1831 targetCfgValue = acMappingTable[ratesLoop].eRateCfg;
1832 break;
1833 }
1834 }
1835 }
1836#endif /* WLAN_FEATURE_11AC */
1837
1838 /* Finally send config to FW */
1839 if (targetCfgId && targetCfgValue)
1840 {
1841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1842 "%s, Target Band %d, cfg value %d",
1843 __func__, targetCfgId, targetCfgValue);
1844 cfdStat = cfgSetInt((tpAniSirGlobal)hHal,
1845 targetCfgId,
1846 targetCfgValue);
1847 if (eSIR_SUCCESS != cfdStat)
1848 {
1849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1850 "%s, CFG Fail %d",
1851 __func__, cfdStat);
1852 rc = -1;
1853 }
1854 }
1855
1856 return rc;
1857};
1858
1859/**---------------------------------------------------------------------------
1860
1861 \brief hdd_hostapd_set_mc_rate() -
1862
1863 This is called user application set forcefully MC rate
1864
1865 \param - pHostapdAdapter Pointer to adapter structure
1866 \param - targetRateHkbps MC rate to set, hundreds kbps order
1867
1868 \return - int, 0 success
1869 negative fail
1870
1871 --------------------------------------------------------------------------*/
1872int hdd_hostapd_set_mc_rate
1873(
1874 hdd_adapter_t *pHostapdAdapter,
1875 int targetRateHkbps
1876)
1877{
1878 tHalHandle hHal;
1879 hdd_ap_ctx_t *apCtxt;
1880 eHalStatus smeStatus;
1881 int rc;
1882
1883 if ((NULL == pHostapdAdapter) || (0 == targetRateHkbps))
1884 {
1885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1886 "%s : Invalid arguments", __func__);
1887 return -1;
1888 }
1889
1890 apCtxt = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1891 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1893 "hdd_hostapd_setMcRate %d", targetRateHkbps);
1894
1895 init_completion(&apCtxt->sap_get_associated_stas_complete);
1896
1897 apCtxt->getStasCookie = SAP_GET_STAS_COOKIE;
1898 apCtxt->targetMCRate = targetRateHkbps;
1899 apCtxt->getStasEventBuffer.sapevt.sapAssocStaListEvent.noOfAssocSta = 0;
1900 apCtxt->assocStasBuffer = (tSap_AssocMacAddr *)vos_mem_malloc(
1901 sizeof(tSap_AssocMacAddr) * HAL_NUM_ASSOC_STA);
1902 if (NULL == apCtxt->assocStasBuffer)
1903 {
1904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1905 "%s : Buffer Alloc fail", __func__);
1906 return -1;
1907 }
1908 smeStatus = sme_RoamGetAssociatedStas(hHal,
1909 pHostapdAdapter->sessionId,
1910 VOS_MODULE_ID_HDD,
1911 (void *)apCtxt,
1912 hdd_hostapd_set_mc_rate_cb,
1913 (tANI_U8 *)apCtxt->assocStasBuffer);
1914 if (smeStatus)
1915 {
1916 apCtxt->getStasCookie = 0;
1917 vos_mem_free(apCtxt->assocStasBuffer);
1918 apCtxt->assocStasBuffer = NULL;
1919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1920 "%s : SME Issue fail", __func__);
1921 return -1;
1922 }
1923
1924 /* Wait for completion */
1925 rc = wait_for_completion_interruptible_timeout(
1926 &apCtxt->sap_get_associated_stas_complete,
1927 msecs_to_jiffies(SAP_MAX_GET_ASSOC_STAS_TIMEOUT));
1928
1929 /* either we have a response or we timed out
1930 either way, first invalidate our cookie */
1931 apCtxt->getStasCookie = 0;
1932 if (0 >= rc)
1933 {
1934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1935 "%s : Wait timeout or interrupted", __func__);
1936
1937 /* there is a race condition such that the callback
1938 function could be executing at the same time we are. of
1939 primary concern is if the callback function had already
1940 verified the "magic" but hasn't yet set the completion
1941 variable. Since the completion variable is on our
1942 stack, we'll delay just a bit to make sure the data is
1943 still valid if that is the case */
1944 vos_sleep(50);
1945 /* we'll now try to test memory */
1946 }
1947
1948 rc = hdd_hostapd_set_mc_rate_update(
1949 &apCtxt->getStasEventBuffer,
1950 pHostapdAdapter);
1951 vos_mem_free(apCtxt->assocStasBuffer);
1952 apCtxt->assocStasBuffer = NULL;
1953
1954 return rc;
1955}
1956
Jeff Johnson295189b2012-06-20 16:38:30 -07001957int
1958static iw_softap_setparam(struct net_device *dev,
1959 struct iw_request_info *info,
1960 union iwreq_data *wrqu, char *extra)
1961{
1962 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1963 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1964 int *value = (int *)extra;
1965 int sub_cmd = value[0];
1966 int set_value = value[1];
1967 eHalStatus status;
1968 int ret = 0; /* success */
1969 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1970
1971 switch(sub_cmd)
1972 {
1973
1974 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001975 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 {
1977 ret = -EIO;
1978 }
1979 break;
1980
1981 case QCSAP_PARAM_ACL_MODE:
1982 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
1983 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1984 {
1985 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1986 ret = -EINVAL;
1987 }
1988 else
1989 {
1990 WLANSAP_SetMode(pVosContext, set_value);
1991 }
1992 break;
1993 case QCSAP_PARAM_MAX_ASSOC:
1994 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1995 {
1996 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1997 ret = -EINVAL;
1998 }
1999 else
2000 {
2001 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2002 {
2003 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2004 "Setting it to max allowed and continuing"),
2005 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2006 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2007 }
2008 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2009 set_value, NULL, eANI_BOOLEAN_FALSE);
2010 if ( status != eHAL_STATUS_SUCCESS )
2011 {
2012 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2013 status);
2014 ret = -EIO;
2015 }
2016 }
2017 break;
2018
2019 case QCSAP_PARAM_HIDE_SSID:
2020 {
2021 eHalStatus status = eHAL_STATUS_SUCCESS;
2022 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2023 if(eHAL_STATUS_SUCCESS != status)
2024 {
2025 hddLog(VOS_TRACE_LEVEL_ERROR,
2026 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002027 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 return status;
2029 }
2030 break;
2031 }
2032
Leo Chang614d2072013-08-22 14:59:44 -07002033 case QCSAP_PARAM_SET_MC_RATE:
2034 {
2035 if (hdd_hostapd_set_mc_rate(pHostapdAdapter, set_value))
2036 {
2037 hddLog(VOS_TRACE_LEVEL_ERROR,
2038 "%s: SET_MC_RATE failed", __func__);
2039 }
2040 break;
2041 }
2042
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 default:
2044 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2045 sub_cmd, set_value);
2046 ret = -EINVAL;
2047 break;
2048 }
2049
2050 return ret;
2051}
2052
2053
2054int
2055static iw_softap_getparam(struct net_device *dev,
2056 struct iw_request_info *info,
2057 union iwreq_data *wrqu, char *extra)
2058{
2059 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2060 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2061 int *value = (int *)extra;
2062 int sub_cmd = value[0];
2063 eHalStatus status;
2064 int ret = 0; /* success */
2065 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2066
2067 switch (sub_cmd)
2068 {
2069 case QCSAP_PARAM_MAX_ASSOC:
2070 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2071 if (eHAL_STATUS_SUCCESS != status)
2072 {
2073 ret = -EIO;
2074 }
2075 break;
2076
2077 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002078 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 {
2080 ret = -EIO;
2081 }
2082 *value = 0;
2083 break;
2084
2085 case QCSAP_PARAM_MODULE_DOWN_IND:
2086 {
2087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002088 "%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
2090#ifdef WLAN_BTAMP_FEATURE
2091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002092 "%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
2094#endif
2095 *value = 0;
2096 break;
Jeff Johnson43971f52012-07-17 12:26:56 -07002097 }
2098
2099 case QCSAP_PARAM_GET_WLAN_DBG:
2100 {
2101 vos_trace_display();
2102 *value = 0;
2103 break;
2104 }
2105
2106 case QCSAP_PARAM_AUTO_CHANNEL:
2107 {
2108 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2109 break;
2110 }
2111
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 default:
2113 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2114 ret = -EINVAL;
2115 break;
2116
2117 }
2118
2119 return ret;
2120}
2121
2122/* Usage:
2123 BLACK_LIST = 0
2124 WHITE_LIST = 1
2125 ADD MAC = 0
2126 REMOVE MAC = 1
2127
2128 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2129 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2130 while using this ioctl
2131
2132 Syntax:
2133 iwpriv softap.0 modify_acl
2134 <6 octet mac addr> <list type> <cmd type>
2135
2136 Examples:
2137 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2138 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2139 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2140 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2141*/
2142int iw_softap_modify_acl(struct net_device *dev, struct iw_request_info *info,
2143 union iwreq_data *wrqu, char *extra)
2144{
2145 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2146 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2147 v_BYTE_t *value = (v_BYTE_t*)extra;
2148 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2149 int listType, cmd, i;
2150 int ret = 0; /* success */
2151
2152 ENTER();
2153 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2154 {
2155 pPeerStaMac[i] = *(value+i);
2156 }
2157 listType = (int)(*(value+i));
2158 i++;
2159 cmd = (int)(*(value+i));
2160
2161 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 -07002162 __func__, pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 pPeerStaMac[3], pPeerStaMac[4], pPeerStaMac[5], listType, cmd);
2164
2165 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2166 != VOS_STATUS_SUCCESS)
2167 {
2168 hddLog(LOGE, FL("Modify ACL failed\n"));
2169 ret = -EIO;
2170 }
2171 EXIT();
2172 return ret;
2173}
2174
2175int
2176static iw_softap_getchannel(struct net_device *dev,
2177 struct iw_request_info *info,
2178 union iwreq_data *wrqu, char *extra)
2179{
2180 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2181
Jeff Johnson43971f52012-07-17 12:26:56 -07002182 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002183
Jeff Johnson43971f52012-07-17 12:26:56 -07002184 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 return 0;
2186}
2187
Jeff Johnsone7245742012-09-05 17:12:55 -07002188int
schang86c22c42013-03-13 18:41:24 -07002189static iw_softap_set_max_tx_power(struct net_device *dev,
Jeff Johnsone7245742012-09-05 17:12:55 -07002190 struct iw_request_info *info,
2191 union iwreq_data *wrqu, char *extra)
2192{
2193 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2194 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
schang86c22c42013-03-13 18:41:24 -07002195 int *value = (int *)extra;
Jeff Johnsone7245742012-09-05 17:12:55 -07002196 int set_value;
2197 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2198 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2199
schang86c22c42013-03-13 18:41:24 -07002200 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002201 return -ENOMEM;
2202
Leo Changd37675a2013-08-01 13:19:45 -07002203 /* Assign correct slef MAC address */
2204 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2205 VOS_MAC_ADDR_SIZE);
2206 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2207 VOS_MAC_ADDR_SIZE);
2208
schang86c22c42013-03-13 18:41:24 -07002209 set_value = value[0];
2210 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2211 {
2212 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002213 __func__);
schang86c22c42013-03-13 18:41:24 -07002214 return -EIO;
2215 }
2216
2217 return 0;
2218}
2219
2220int
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302221static iw_display_data_path_snapshot(struct net_device *dev,
2222 struct iw_request_info *info,
2223 union iwreq_data *wrqu, char *extra)
2224{
2225
2226 /* Function intitiating dumping states of
2227 * HDD(WMM Tx Queues)
2228 * TL State (with Per Client infor)
2229 * DXE Snapshot (Called at the end of TL Snapshot)
2230 */
2231 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2232 hddLog(LOGE, "%s: called for SAP",__func__);
2233 hdd_wmm_tx_snapshot(pHostapdAdapter);
2234 WLANTL_TLDebugMessage(VOS_TRUE);
2235 return 0;
2236}
2237
2238int
schang86c22c42013-03-13 18:41:24 -07002239static iw_softap_set_tx_power(struct net_device *dev,
2240 struct iw_request_info *info,
2241 union iwreq_data *wrqu, char *extra)
2242{
2243 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2244 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2245 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2246 int *value = (int *)extra;
2247 int set_value;
2248 ptSapContext pSapCtx = NULL;
2249
2250 if (NULL == value)
2251 return -ENOMEM;
2252
2253 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2254 if (NULL == pSapCtx)
2255 {
2256 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2257 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2258 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002259 }
2260
2261 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002262 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002263 {
schang86c22c42013-03-13 18:41:24 -07002264 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002265 __func__);
2266 return -EIO;
2267 }
2268
2269 return 0;
2270}
2271
Jeff Johnson295189b2012-06-20 16:38:30 -07002272#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2273
2274int
2275static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2276 struct iw_request_info *info,
2277 union iwreq_data *wrqu, char *extra)
2278{
2279 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2280 unsigned char *pmaclist;
2281 hdd_station_info_t *pStaInfo = pHostapdAdapter->aStaInfo;
2282 int cnt = 0, len;
2283
2284
2285 pmaclist = wrqu->data.pointer + sizeof(unsigned long int);
2286 len = wrqu->data.length;
2287
2288 spin_lock_bh( &pHostapdAdapter->staInfo_lock );
2289 while((cnt < WLAN_MAX_STA_COUNT) && (len > (sizeof(v_MACADDR_t)+1))) {
2290 if (TRUE == pStaInfo[cnt].isUsed) {
2291
2292 if(!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes)) {
2293 memcpy((void *)pmaclist, (void *)&(pStaInfo[cnt].macAddrSTA), sizeof(v_MACADDR_t));
2294 pmaclist += sizeof(v_MACADDR_t);
2295 len -= sizeof(v_MACADDR_t);
2296 }
2297 }
2298 cnt++;
2299 }
2300 spin_unlock_bh( &pHostapdAdapter->staInfo_lock );
2301
2302 *pmaclist = '\0';
2303
2304 wrqu->data.length -= len;
2305
2306 *(unsigned long int *)(wrqu->data.pointer) = wrqu->data.length;
2307
2308 return 0;
2309}
2310
2311/* Usage:
2312 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2313 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2314 while using this ioctl
2315
2316 Syntax:
2317 iwpriv softap.0 disassoc_sta <6 octet mac address>
2318
2319 e.g.
2320 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2321 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2322*/
2323
2324int
2325static iw_softap_disassoc_sta(struct net_device *dev,
2326 struct iw_request_info *info,
2327 union iwreq_data *wrqu, char *extra)
2328{
2329 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2330 v_U8_t *peerMacAddr;
2331
2332 ENTER();
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302333 /* iwpriv tool or framework calls this ioctl with
2334 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302336 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002337
2338 hddLog(LOG1, "data %02x:%02x:%02x:%02x:%02x:%02x",
2339 peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
2340 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);
2341 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2342 EXIT();
2343 return 0;
2344}
2345
2346int
2347static iw_softap_ap_stats(struct net_device *dev,
2348 struct iw_request_info *info,
2349 union iwreq_data *wrqu, char *extra)
2350{
2351 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2352 WLANTL_TRANSFER_STA_TYPE statBuffer;
2353 char *pstatbuf;
2354 int len = wrqu->data.length;
2355 pstatbuf = wrqu->data.pointer;
2356
2357 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &statBuffer, (v_BOOL_t)wrqu->data.flags);
2358
2359 len = snprintf(pstatbuf, len,
2360 "RUF=%d RMF=%d RBF=%d "
2361 "RUB=%d RMB=%d RBB=%d "
2362 "TUF=%d TMF=%d TBF=%d "
2363 "TUB=%d TMB=%d TBB=%d",
2364 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt, (int)statBuffer.rxBCFcnt,
2365 (int)statBuffer.rxUCBcnt, (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2366 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt, (int)statBuffer.txBCFcnt,
2367 (int)statBuffer.txUCBcnt, (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt
2368 );
2369
2370 wrqu->data.length -= len;
2371 return 0;
2372}
2373
2374int
2375static iw_softap_commit(struct net_device *dev,
2376 struct iw_request_info *info,
2377 union iwreq_data *wrqu, char *extra)
2378{
2379 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2380 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2381 hdd_hostapd_state_t *pHostapdState;
2382 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2383 tpWLAN_SAPEventCB pSapEventCallback;
2384 tsap_Config_t *pConfig;
2385 s_CommitConfig_t *pCommitConfig;
2386 struct qc_mac_acl_entry *acl_entry = NULL;
2387 v_SINT_t i = 0, num_mac = 0;
2388 v_U32_t status = 0;
2389 eCsrAuthType RSNAuthType;
2390 eCsrEncryptionType RSNEncryptType;
2391 eCsrEncryptionType mcRSNEncryptType;
2392
2393 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
2394 pCommitConfig = (s_CommitConfig_t *)extra;
2395
2396 pConfig = kmalloc(sizeof(tsap_Config_t), GFP_KERNEL);
2397 if(NULL == pConfig) {
2398 hddLog(LOG1, "VOS unable to allocate memory\n");
2399 return -ENOMEM;
2400 }
2401 pConfig->beacon_int = pCommitConfig->beacon_int;
2402 pConfig->channel = pCommitConfig->channel;
2403
2404 /*Protection parameter to enable or disable*/
2405 pConfig->protEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
2406 pConfig->dtim_period = pCommitConfig->dtim_period;
2407 switch(pCommitConfig->hw_mode )
2408 {
2409 case eQC_DOT11_MODE_11A:
2410 pConfig->SapHw_mode = eSAP_DOT11_MODE_11a;
2411 break;
2412 case eQC_DOT11_MODE_11B:
2413 pConfig->SapHw_mode = eSAP_DOT11_MODE_11b;
2414 break;
2415 case eQC_DOT11_MODE_11G:
2416 pConfig->SapHw_mode = eSAP_DOT11_MODE_11g;
2417 break;
2418
2419 case eQC_DOT11_MODE_11N:
2420 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2421 break;
2422 case eQC_DOT11_MODE_11G_ONLY:
2423 pConfig->SapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
2424 break;
2425 case eQC_DOT11_MODE_11N_ONLY:
2426 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n_ONLY;
2427 break;
2428 default:
2429 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2430 break;
2431
2432 }
2433
2434 pConfig->ieee80211d = pCommitConfig->qcsap80211d;
2435 vos_mem_copy(pConfig->countryCode, pCommitConfig->countryCode, 3);
2436 if(pCommitConfig->authType == eQC_AUTH_TYPE_SHARED_KEY)
2437 pConfig->authType = eSAP_SHARED_KEY;
2438 else if(pCommitConfig->authType == eQC_AUTH_TYPE_OPEN_SYSTEM)
2439 pConfig->authType = eSAP_OPEN_SYSTEM;
2440 else
2441 pConfig->authType = eSAP_AUTO_SWITCH;
2442
2443 pConfig->privacy = pCommitConfig->privacy;
2444 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pCommitConfig->privacy;
2445 pConfig->wps_state = pCommitConfig->wps_state;
2446 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
2447 pConfig->RSNWPAReqIELength = pCommitConfig->RSNWPAReqIELength;
2448 if(pConfig->RSNWPAReqIELength){
2449 pConfig->pRSNWPAReqIE = &pCommitConfig->RSNWPAReqIE[0];
2450 if ((pConfig->pRSNWPAReqIE[0] == DOT11F_EID_RSN) || (pConfig->pRSNWPAReqIE[0] == DOT11F_EID_WPA)){
2451 // The actual processing may eventually be more extensive than this.
2452 // Right now, just consume any PMKIDs that are sent in by the app.
2453 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 vos_get_context( VOS_MODULE_ID_PE, pVosContext),
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 &RSNEncryptType,
2456 &mcRSNEncryptType,
2457 &RSNAuthType,
2458 pConfig->pRSNWPAReqIE[1]+2,
2459 pConfig->pRSNWPAReqIE );
2460
2461 if( VOS_STATUS_SUCCESS == status )
2462 {
2463 // Now copy over all the security attributes you have parsed out
2464 //TODO: Need to handle mixed mode
2465 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
2466 pConfig->mcRSNEncryptType = mcRSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302467 hddLog( LOG1, FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
2469 }
2470 }
2471 }
2472 else
2473 {
2474 /* If no RSNIE, set encrypt type to NONE*/
2475 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
2476 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
2477 hddLog( LOG1, FL("EncryptionType = %d mcEncryptionType = %d\n"),
2478 pConfig->RSNEncryptType, pConfig->mcRSNEncryptType);
2479 }
2480
Chilam Ngc4244af2013-04-01 15:37:32 -07002481 if (pConfig->RSNWPAReqIELength > QCSAP_MAX_OPT_IE) {
2482 hddLog(LOGE, FL("RSNWPAReqIELength: %d too large"), pConfig->RSNWPAReqIELength);
2483 kfree(pConfig);
2484 return -EIO;
2485 }
2486
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 pConfig->SSIDinfo.ssidHidden = pCommitConfig->SSIDinfo.ssidHidden;
2488 pConfig->SSIDinfo.ssid.length = pCommitConfig->SSIDinfo.ssid.length;
2489 vos_mem_copy(pConfig->SSIDinfo.ssid.ssId, pCommitConfig->SSIDinfo.ssid.ssId, pConfig->SSIDinfo.ssid.length);
2490 vos_mem_copy(pConfig->self_macaddr.bytes, pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
2491
2492 pConfig->SapMacaddr_acl = pCommitConfig->qc_macaddr_acl;
2493
2494 // ht_capab is not what the name conveys,this is used for protection bitmap
2495 pConfig->ht_capab = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2496
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302497 if (pCommitConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2498 num_mac = pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 else
2500 num_mac = pConfig->num_accept_mac = pCommitConfig->num_accept_mac;
2501 acl_entry = pCommitConfig->accept_mac;
2502 for (i = 0; i < num_mac; i++)
2503 {
2504 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(v_MACADDR_t));
2505 acl_entry++;
2506 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302507 if (pCommitConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2508 num_mac = pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 else
2510 num_mac = pConfig->num_deny_mac = pCommitConfig->num_deny_mac;
2511 acl_entry = pCommitConfig->deny_mac;
2512 for (i = 0; i < num_mac; i++)
2513 {
2514 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(v_MACADDR_t));
2515 acl_entry++;
2516 }
2517 //Uapsd Enabled Bit
2518 pConfig->UapsdEnable = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2519 //Enable OBSS protection
2520 pConfig->obssProtEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
2521 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apDisableIntraBssFwd;
2522
2523 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
2524 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
2525 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, (int)pConfig->channel);
2526 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
2527 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, pConfig->authType);
2528 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
2529 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
2530 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),pConfig->protEnabled, pConfig->obssProtEnabled);
2531 hddLog(LOGW,FL("DisableIntraBssFwd = %d\n"),(WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd);
2532
2533 pSapEventCallback = hdd_hostapd_SAPEventCB;
2534 pConfig->persona = pHostapdAdapter->device_mode;
2535 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,(v_PVOID_t)dev) != VOS_STATUS_SUCCESS)
2536 {
2537 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2538 }
2539
2540 kfree(pConfig);
2541
2542 hddLog(LOG1, FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2543 vos_status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2544
2545 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2546 {
2547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos wait for single_event failed!!\n"));
2548 VOS_ASSERT(0);
2549 }
2550
2551 pHostapdState->bCommit = TRUE;
2552 if(pHostapdState->vosStatus)
2553 {
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002554 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 }
2556 else
2557 {
2558 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2559 WLANSAP_Update_WpsIe ( pVosContext );
2560 return 0;
2561 }
2562}
2563static
2564int iw_softap_setmlme(struct net_device *dev,
2565 struct iw_request_info *info,
2566 union iwreq_data *wrqu, char *extra)
2567{
2568 struct sQcSapreq_mlme *pmlme;
2569 hdd_adapter_t *pHostapdAdapter = (hdd_adapter_t*)(netdev_priv(dev));
2570 v_MACADDR_t destAddress;
2571 pmlme = (struct sQcSapreq_mlme *)(wrqu->name);
2572 /* NOTE: this address is not valid incase of TKIP failure, since not filled */
2573 vos_mem_copy(&destAddress.bytes, pmlme->im_macaddr, sizeof(v_MACADDR_t));
2574 switch(pmlme->im_op)
2575 {
2576 case QCSAP_MLME_AUTHORIZE:
2577 hdd_softap_change_STA_state( pHostapdAdapter, &destAddress, WLANTL_STA_AUTHENTICATED);
2578 break;
2579 case QCSAP_MLME_ASSOC:
2580 //TODO:inform to TL after associating (not needed as we do in sapCallback)
2581 break;
2582 case QCSAP_MLME_UNAUTHORIZE:
2583 //TODO: send the disassoc to station
2584 //hdd_softap_change_STA_state( pHostapdAdapter, pmlme->im_macaddr, WLANTL_STA_AUTHENTICATED);
2585 break;
2586 case QCSAP_MLME_DISASSOC:
2587 hdd_softap_sta_disassoc(pHostapdAdapter,pmlme->im_macaddr);
2588 break;
2589 case QCSAP_MLME_DEAUTH:
2590 hdd_softap_sta_deauth(pHostapdAdapter,pmlme->im_macaddr);
2591 break;
2592 case QCSAP_MLME_MICFAILURE:
2593 hdd_softap_tkip_mic_fail_counter_measure(pHostapdAdapter,pmlme->im_reason);
2594 break;
2595 default:
2596 break;
2597 }
2598 return 0;
2599}
2600
2601static int iw_softap_set_channel_range(struct net_device *dev,
2602 struct iw_request_info *info,
2603 union iwreq_data *wrqu, char *extra)
2604{
2605 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2606 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002607 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002608
2609 int *value = (int *)extra;
2610 int startChannel = value[0];
2611 int endChannel = value[1];
2612 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002613 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 int ret = 0; /* success */
2615
2616 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2617 if(status != VOS_STATUS_SUCCESS)
2618 {
2619 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d\n"),
2620 startChannel,endChannel, band);
2621 ret = -EINVAL;
2622 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08002623
2624 pHddCtx->is_dynamic_channel_range_set = 1;
2625
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 return ret;
2627}
2628
2629int iw_softap_get_channel_list(struct net_device *dev,
2630 struct iw_request_info *info,
2631 union iwreq_data *wrqu, char *extra)
2632{
2633 v_U32_t num_channels = 0;
2634 v_U8_t i = 0;
2635 v_U8_t bandStartChannel = RF_CHAN_1;
2636 v_U8_t bandEndChannel = RF_CHAN_165;
2637 v_U32_t temp_num_channels = 0;
2638 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2639 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2640 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002642 eCsrBand curBand = eCSR_BAND_ALL;
2643
2644 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
2645 {
2646 hddLog(LOGE,FL("not able get the current frequency band\n"));
2647 return -EIO;
2648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 wrqu->data.length = sizeof(tChannelListInfo);
2650 ENTER();
2651
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002652 if (eCSR_BAND_24 == curBand)
2653 {
2654 bandStartChannel = RF_CHAN_1;
2655 bandEndChannel = RF_CHAN_14;
2656 }
2657 else if (eCSR_BAND_5G == curBand)
2658 {
2659 bandStartChannel = RF_CHAN_36;
2660 bandEndChannel = RF_CHAN_165;
2661 }
2662
Gopichand Nakkala29d00192013-06-20 19:03:52 +05302663 hddLog(LOG1, FL("\n curBand = %d, bandStartChannel = %hu, "
2664 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002665 bandStartChannel, bandEndChannel );
2666
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 for( i = bandStartChannel; i <= bandEndChannel; i++ )
2668 {
2669 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
2670 {
2671 channel_list->channels[num_channels] = rfChannels[i].channelNum;
2672 num_channels++;
2673 }
2674 }
2675
2676 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
2677
2678 temp_num_channels = num_channels;
2679
2680 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
2681 {
2682 hddLog(LOG1,FL("Failed to get Domain ID, %d \n"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002683 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 }
2685
2686 if(REGDOMAIN_FCC == domainIdCurrentSoftap)
2687 {
2688 for(i = 0; i < temp_num_channels; i++)
2689 {
2690
2691 if((channel_list->channels[i] > 35) &&
2692 (channel_list->channels[i] < 49))
2693 {
2694 vos_mem_move(&channel_list->channels[i],
2695 &channel_list->channels[i+1],
2696 temp_num_channels - (i-1));
2697 num_channels--;
2698 temp_num_channels--;
2699 i--;
2700 }
2701 }
2702 }
2703
2704 hddLog(LOG1,FL(" number of channels %d\n"), num_channels);
2705
2706 if (num_channels > IW_MAX_FREQUENCIES)
2707 {
2708 num_channels = IW_MAX_FREQUENCIES;
2709 }
2710
2711 channel_list->num_channels = num_channels;
2712 EXIT();
2713
2714 return 0;
2715}
2716
2717static
2718int iw_get_genie(struct net_device *dev,
2719 struct iw_request_info *info,
2720 union iwreq_data *wrqu, char *extra)
2721{
2722 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2723 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2724 eHalStatus status;
2725 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2726 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2727 ENTER();
2728 hddLog(LOG1,FL("getGEN_IE ioctl\n"));
2729 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2730 status = WLANSap_getstationIE_information(pVosContext,
2731 &length,
2732 genIeBytes);
2733 wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2734 vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length);
2735
2736 hddLog(LOG1,FL(" RSN IE of %d bytes returned\n"), wrqu->data.length );
2737
2738
2739 EXIT();
2740 return 0;
2741}
2742static
2743int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
2744 struct iw_request_info *info,
2745 union iwreq_data *wrqu, char *extra)
2746{
2747 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2748 sQcSapreq_WPSPBCProbeReqIES_t *pWPSPBCProbeReqIEs;
2749 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
2750 ENTER();
2751
2752 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl\n"));
2753
2754 pWPSPBCProbeReqIEs = (sQcSapreq_WPSPBCProbeReqIES_t *)(wrqu->data.pointer);
2755 pWPSPBCProbeReqIEs->probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
2756 vos_mem_copy(pWPSPBCProbeReqIEs->probeReqIE, pHddApCtx->WPSPBCProbeReq.probeReqIE, pWPSPBCProbeReqIEs->probeReqIELen);
2757 vos_mem_copy(pWPSPBCProbeReqIEs->macaddr, pHddApCtx->WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
2758 wrqu->data.length = 12 + pWPSPBCProbeReqIEs->probeReqIELen;
2759 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR"\n"), MAC_ADDR_ARRAY(pWPSPBCProbeReqIEs->macaddr));
2760 up(&pHddApCtx->semWpsPBCOverlapInd);
2761 EXIT();
2762 return 0;
2763}
2764
2765/**---------------------------------------------------------------------------
2766
2767 \brief iw_set_auth_hostap() -
2768 This function sets the auth type received from the wpa_supplicant.
2769
2770 \param - dev - Pointer to the net device.
2771 - info - Pointer to the iw_request_info.
2772 - wrqu - Pointer to the iwreq_data.
2773 - extra - Pointer to the data.
2774 \return - 0 for success, non zero for failure
2775
2776 --------------------------------------------------------------------------*/
2777int iw_set_auth_hostap(struct net_device *dev,struct iw_request_info *info,
2778 union iwreq_data *wrqu,char *extra)
2779{
2780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2781 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2782
2783 ENTER();
2784 switch(wrqu->param.flags & IW_AUTH_INDEX)
2785 {
2786 case IW_AUTH_TKIP_COUNTERMEASURES:
2787 {
2788 if(wrqu->param.value) {
2789 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2790 "Counter Measure started %d", wrqu->param.value);
2791 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
2792 }
2793 else {
2794 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2795 "Counter Measure stopped=%d", wrqu->param.value);
2796 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
2797 }
2798
2799 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
2800 wrqu->param.value);
2801 }
2802 break;
2803
2804 default:
2805
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002806 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 wrqu->param.flags & IW_AUTH_INDEX);
2808 break;
2809 }
2810
2811 EXIT();
2812 return 0;
2813}
2814
2815static int iw_set_ap_encodeext(struct net_device *dev,
2816 struct iw_request_info *info,
2817 union iwreq_data *wrqu, char *extra)
2818{
2819 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2820 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2821 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson43971f52012-07-17 12:26:56 -07002822 int retval = 0;
2823 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
2825 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2826 int key_index;
2827 struct iw_point *encoding = &wrqu->encoding;
2828 tCsrRoamSetKey setKey;
2829// tCsrRoamRemoveKey RemoveKey;
2830 int i;
Jeff Johnson43971f52012-07-17 12:26:56 -07002831
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 ENTER();
2833
2834 key_index = encoding->flags & IW_ENCODE_INDEX;
2835
2836 if(key_index > 0) {
2837
2838 /*Convert from 1-based to 0-based keying*/
2839 key_index--;
2840 }
2841 if(!ext->key_len) {
2842#if 0
2843 /*Set the encrytion type to NONE*/
2844#if 0
2845 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2846#endif
2847
2848 RemoveKey.keyId = key_index;
2849 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2850 /*Key direction for group is RX only*/
2851 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2852 }
2853 else {
2854 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2855 }
2856 switch(ext->alg)
2857 {
2858 case IW_ENCODE_ALG_NONE:
2859 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2860 break;
2861 case IW_ENCODE_ALG_WEP:
2862 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2863 break;
2864 case IW_ENCODE_ALG_TKIP:
2865 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07002866 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 case IW_ENCODE_ALG_CCMP:
2868 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
2869 break;
2870 default:
2871 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2872 break;
2873 }
2874 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 -07002875 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 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 -07002877 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 );
Jeff Johnson43971f52012-07-17 12:26:56 -07002879 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
2880 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 {
2882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07002883 __LINE__, vstatus );
2884 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002886#endif
2887 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002888
Jeff Johnson43971f52012-07-17 12:26:56 -07002889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002890
2891 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2892
2893 setKey.keyId = key_index;
2894 setKey.keyLength = ext->key_len;
2895
2896 if(ext->key_len <= CSR_MAX_KEY_LEN) {
2897 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
2898 }
2899
2900 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2901 /*Key direction for group is RX only*/
2902 setKey.keyDirection = eSIR_RX_ONLY;
2903 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2904 }
2905 else {
2906
2907 setKey.keyDirection = eSIR_TX_RX;
2908 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2909 }
2910 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2911 {
2912 setKey.keyDirection = eSIR_TX_DEFAULT;
2913 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2914 }
2915
2916 /*For supplicant pae role is zero*/
2917 setKey.paeRole = 0;
2918
2919 switch(ext->alg)
2920 {
2921 case IW_ENCODE_ALG_NONE:
2922 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2923 break;
2924
2925 case IW_ENCODE_ALG_WEP:
2926 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2927 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002928 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 break;
2930
2931 case IW_ENCODE_ALG_TKIP:
2932 {
2933 v_U8_t *pKey = &setKey.Key[0];
2934
2935 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
2936
2937 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
2938
2939 /*Supplicant sends the 32bytes key in this order
2940
2941 |--------------|----------|----------|
2942 | Tk1 |TX-MIC | RX Mic |
2943 |--------------|----------|----------|
2944 <---16bytes---><--8bytes--><--8bytes-->
2945
2946 */
2947 /*Sme expects the 32 bytes key to be in the below order
2948
2949 |--------------|----------|----------|
2950 | Tk1 |RX-MIC | TX Mic |
2951 |--------------|----------|----------|
2952 <---16bytes---><--8bytes--><--8bytes-->
2953 */
2954 /* Copy the Temporal Key 1 (TK1) */
2955 vos_mem_copy(pKey,ext->key,16);
2956
2957 /*Copy the rx mic first*/
2958 vos_mem_copy(&pKey[16],&ext->key[24],8);
2959
2960 /*Copy the tx mic */
2961 vos_mem_copy(&pKey[24],&ext->key[16],8);
2962
2963 }
2964 break;
2965
2966 case IW_ENCODE_ALG_CCMP:
2967 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
2968 break;
2969
2970 default:
2971 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2972 break;
2973 }
2974
2975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302976 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 setKey.keyId);
2978 for(i=0; i< ext->key_len; i++)
2979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2980 ("%02x"), setKey.Key[i]);
2981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2982 ("\n"));
Jeff Johnson43971f52012-07-17 12:26:56 -07002983
2984 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
2985 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 {
2987 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07002988 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
2989 retval = -EINVAL;
2990 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002991
Jeff Johnson43971f52012-07-17 12:26:56 -07002992 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002993}
Jeff Johnson43971f52012-07-17 12:26:56 -07002994
2995
Jeff Johnson295189b2012-06-20 16:38:30 -07002996static int iw_set_ap_mlme(struct net_device *dev,
2997 struct iw_request_info *info,
2998 union iwreq_data *wrqu,
2999 char *extra)
3000{
3001#if 0
3002 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3003 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3004
3005 ENTER();
3006
3007 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3008 switch (mlme->cmd) {
3009 case IW_MLME_DISASSOC:
3010 case IW_MLME_DEAUTH:
3011 hddLog(LOG1, "Station disassociate");
3012 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3013 {
3014 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3015
3016 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3017 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3018
3019 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3020
3021 //clear all the reason codes
3022 if (status != 0)
3023 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003024 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 -07003025 }
3026
3027 netif_stop_queue(dev);
3028 netif_carrier_off(dev);
3029 }
3030 else
3031 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003032 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 -07003033 }
3034 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003035 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 return -EINVAL;
3037 }//end of switch
3038 EXIT();
3039#endif
3040 return 0;
3041// return status;
3042}
3043
3044static int iw_get_ap_rts_threshold(struct net_device *dev,
3045 struct iw_request_info *info,
3046 union iwreq_data *wrqu, char *extra)
3047{
3048 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3049 v_U32_t status = 0;
3050
3051 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3052
3053 return status;
3054}
3055
3056static int iw_get_ap_frag_threshold(struct net_device *dev,
3057 struct iw_request_info *info,
3058 union iwreq_data *wrqu, char *extra)
3059{
3060 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3061 v_U32_t status = 0;
3062
3063 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3064
3065 return status;
3066}
3067
3068static int iw_get_ap_freq(struct net_device *dev, struct iw_request_info *info,
3069 struct iw_freq *fwrq, char *extra)
3070{
Jeff Johnsone7245742012-09-05 17:12:55 -07003071 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3073 tHalHandle hHal;
3074 hdd_hostapd_state_t *pHostapdState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003075 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003076
3077 ENTER();
3078
3079 if ((WLAN_HDD_GET_CTX(pHostapdAdapter))->isLogpInProgress) {
3080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3081 "%s:LOGP in Progress. Ignore!!!",__func__);
3082 return status;
3083 }
3084
3085 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3086 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3087
3088 if(pHostapdState->bssState == BSS_STOP )
3089 {
3090 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3091 != eHAL_STATUS_SUCCESS)
3092 {
3093 return -EIO;
3094 }
3095 else
3096 {
3097 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003098 if( TRUE == status)
3099 {
3100 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3101 * iwlist & iwconfig command shows frequency into proper
3102 * format (2.412 GHz instead of 246.2 MHz)*/
3103 fwrq->m = freq;
3104 fwrq->e = MHZ;
3105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 }
3107 }
3108 else
3109 {
3110 channel = pHddApCtx->operatingChannel;
3111 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003112 if( TRUE == status)
3113 {
3114 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3115 * iwlist & iwconfig command shows frequency into proper
3116 * format (2.412 GHz instead of 246.2 MHz)*/
3117 fwrq->m = freq;
3118 fwrq->e = MHZ;
3119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003121 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003122}
3123
3124static int iw_softap_setwpsie(struct net_device *dev,
3125 struct iw_request_info *info,
3126 union iwreq_data *wrqu,
3127 char *extra)
3128{
3129 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3130 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3131 hdd_hostapd_state_t *pHostapdState;
3132 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3133 u_int8_t *wps_genie = wrqu->data.pointer;
3134 u_int8_t *pos;
3135 tpSap_WPSIE pSap_WPSIe;
3136 u_int8_t WPSIeType;
3137 u_int16_t length;
3138 ENTER();
3139
3140 if(!wrqu->data.length)
3141 return 0;
3142
3143 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3144 if (NULL == pSap_WPSIe)
3145 {
3146 hddLog(LOGE, "VOS unable to allocate memory\n");
3147 return -ENOMEM;
3148 }
3149 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3150
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003151 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 -07003152 WPSIeType = wps_genie[0];
3153 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3154 {
3155 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3156 wps_genie = wps_genie + 1;
3157 switch ( wps_genie[0] )
3158 {
3159 case DOT11F_EID_WPA:
3160 if (wps_genie[1] < 2 + 4)
3161 {
3162 vos_mem_free(pSap_WPSIe);
3163 return -EINVAL;
3164 }
3165 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3166 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003167 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 pos = &wps_genie[6];
3169 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3170 {
3171 switch((u_int16_t)(*pos<<8) | *(pos+1))
3172 {
3173 case HDD_WPS_ELEM_VERSION:
3174 pos += 4;
3175 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
3176 hddLog(LOG1, "WPS version %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
3177 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3178 pos += 1;
3179 break;
3180
3181 case HDD_WPS_ELEM_WPS_STATE:
3182 pos +=4;
3183 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
3184 hddLog(LOG1, "WPS State %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
3185 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3186 pos += 1;
3187 break;
3188 case HDD_WPS_ELEM_APSETUPLOCK:
3189 pos += 4;
3190 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
3191 hddLog(LOG1, "AP setup lock %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
3192 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3193 pos += 1;
3194 break;
3195 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3196 pos += 4;
3197 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
3198 hddLog(LOG1, "Selected Registra %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
3199 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3200 pos += 1;
3201 break;
3202 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3203 pos += 4;
3204 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
3205 hddLog(LOG1, "Password ID: %x\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
3206 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3207 pos += 2;
3208 break;
3209 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3210 pos += 4;
3211 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
3212 hddLog(LOG1, "Select Registra Config Methods: %x\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
3213 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3214 pos += 2;
3215 break;
3216
3217 case HDD_WPS_ELEM_UUID_E:
3218 pos += 2;
3219 length = *pos<<8 | *(pos+1);
3220 pos += 2;
3221 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
3222 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
3223 pos += length;
3224 break;
3225 case HDD_WPS_ELEM_RF_BANDS:
3226 pos += 4;
3227 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
3228 hddLog(LOG1, "RF band: %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
3229 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
3230 pos += 1;
3231 break;
3232
3233 default:
3234 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)\n", (*pos<<8 | *(pos+1)));
3235 vos_mem_free(pSap_WPSIe);
3236 return -EINVAL;
3237 }
3238 }
3239 }
3240 else {
3241 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003242 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 }
3244 break;
3245
3246 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003247 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 vos_mem_free(pSap_WPSIe);
3249 return 0;
3250 }
3251 }
3252 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
3253 {
3254 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
3255 wps_genie = wps_genie + 1;
3256 switch ( wps_genie[0] )
3257 {
3258 case DOT11F_EID_WPA:
3259 if (wps_genie[1] < 2 + 4)
3260 {
3261 vos_mem_free(pSap_WPSIe);
3262 return -EINVAL;
3263 }
3264 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3265 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003266 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 pos = &wps_genie[6];
3268 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3269 {
3270 switch((u_int16_t)(*pos<<8) | *(pos+1))
3271 {
3272 case HDD_WPS_ELEM_VERSION:
3273 pos += 4;
3274 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
3275 hddLog(LOG1, "WPS version %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
3276 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
3277 pos += 1;
3278 break;
3279
3280 case HDD_WPS_ELEM_WPS_STATE:
3281 pos +=4;
3282 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
3283 hddLog(LOG1, "WPS State %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
3284 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
3285 pos += 1;
3286 break;
3287 case HDD_WPS_ELEM_APSETUPLOCK:
3288 pos += 4;
3289 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
3290 hddLog(LOG1, "AP setup lock %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
3291 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
3292 pos += 1;
3293 break;
3294 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3295 pos += 4;
3296 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
3297 hddLog(LOG1, "Selected Registra %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
3298 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
3299 pos += 1;
3300 break;
3301 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3302 pos += 4;
3303 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
3304 hddLog(LOG1, "Password ID: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
3305 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
3306 pos += 2;
3307 break;
3308 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3309 pos += 4;
3310 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
3311 hddLog(LOG1, "Select Registra Config Methods: %x\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
3312 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
3313 pos += 2;
3314 break;
3315 case HDD_WPS_ELEM_RSP_TYPE:
3316 pos += 4;
3317 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
3318 hddLog(LOG1, "Config Methods: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
3319 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
3320 pos += 1;
3321 break;
3322 case HDD_WPS_ELEM_UUID_E:
3323 pos += 2;
3324 length = *pos<<8 | *(pos+1);
3325 pos += 2;
3326 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
3327 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
3328 pos += length;
3329 break;
3330
3331 case HDD_WPS_ELEM_MANUFACTURER:
3332 pos += 2;
3333 length = *pos<<8 | *(pos+1);
3334 pos += 2;
3335 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
3336 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
3337 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
3338 pos += length;
3339 break;
3340
3341 case HDD_WPS_ELEM_MODEL_NAME:
3342 pos += 2;
3343 length = *pos<<8 | *(pos+1);
3344 pos += 2;
3345 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
3346 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
3347 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
3348 pos += length;
3349 break;
3350 case HDD_WPS_ELEM_MODEL_NUM:
3351 pos += 2;
3352 length = *pos<<8 | *(pos+1);
3353 pos += 2;
3354 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
3355 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
3356 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
3357 pos += length;
3358 break;
3359 case HDD_WPS_ELEM_SERIAL_NUM:
3360 pos += 2;
3361 length = *pos<<8 | *(pos+1);
3362 pos += 2;
3363 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
3364 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
3365 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
3366 pos += length;
3367 break;
3368 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
3369 pos += 4;
3370 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
3371 hddLog(LOG1, "primary dev category: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
3372 pos += 2;
3373
3374 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
3375 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x\n", pos[0], pos[1], pos[2], pos[3]);
3376 pos += 4;
3377 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
3378 hddLog(LOG1, "primary dev sub category: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
3379 pos += 2;
3380 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
3381 break;
3382 case HDD_WPS_ELEM_DEVICE_NAME:
3383 pos += 2;
3384 length = *pos<<8 | *(pos+1);
3385 pos += 2;
3386 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
3387 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
3388 pos += length;
3389 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
3390 break;
3391 case HDD_WPS_ELEM_CONFIG_METHODS:
3392 pos += 4;
3393 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
3394 hddLog(LOG1, "Config Methods: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
3395 pos += 2;
3396 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
3397 break;
3398
3399 case HDD_WPS_ELEM_RF_BANDS:
3400 pos += 4;
3401 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
3402 hddLog(LOG1, "RF band: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
3403 pos += 1;
3404 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
3405 break;
3406 } // switch
3407 }
3408 }
3409 else
3410 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003411 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 }
3413
3414 } // switch
3415 }
3416 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
3417 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3418 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
3419 {
3420 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3421 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
3422 WLANSAP_Update_WpsIe ( pVosContext );
3423 }
3424
3425 vos_mem_free(pSap_WPSIe);
3426 EXIT();
3427 return halStatus;
3428}
3429
3430static int iw_softap_stopbss(struct net_device *dev,
3431 struct iw_request_info *info,
3432 union iwreq_data *wrqu,
3433 char *extra)
3434{
3435 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3436 VOS_STATUS status = VOS_STATUS_SUCCESS;
3437 ENTER();
3438 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
3439 {
3440 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
3441 {
3442 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3443
3444 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
3445
3446 if (!VOS_IS_STATUS_SUCCESS(status))
3447 {
3448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3449 ("ERROR: HDD vos wait for single_event failed!!\n"));
3450 VOS_ASSERT(0);
3451 }
3452 }
3453 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
3454 }
3455 EXIT();
3456 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
3457}
3458
3459static int iw_softap_version(struct net_device *dev,
3460 struct iw_request_info *info,
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003461 union iwreq_data *wrqu,
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 char *extra)
3463{
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003465
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 ENTER();
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003467 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 return 0;
3470}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003471
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003472VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003473{
3474 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003475 int len = 0;
3476 const char sta_info_header[] = "staId staAddress\n";
3477
3478 len = snprintf(pBuf, buf_len, sta_info_header);
3479 pBuf += len;
3480 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003481
3482 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
3483 {
3484 if(pAdapter->aStaInfo[i].isUsed)
3485 {
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003486 len = snprintf(pBuf, buf_len, "%*d .%02x:%02x:%02x:%02x:%02x:%02x\n",
3487 strlen("staId"),
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003488 pAdapter->aStaInfo[i].ucSTAId,
3489 pAdapter->aStaInfo[i].macAddrSTA.bytes[0],
3490 pAdapter->aStaInfo[i].macAddrSTA.bytes[1],
3491 pAdapter->aStaInfo[i].macAddrSTA.bytes[2],
3492 pAdapter->aStaInfo[i].macAddrSTA.bytes[3],
3493 pAdapter->aStaInfo[i].macAddrSTA.bytes[4],
3494 pAdapter->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003495 pBuf += len;
3496 buf_len -= len;
3497 }
3498 if(WE_GET_STA_INFO_SIZE > buf_len)
3499 {
3500 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003501 }
3502 }
3503 return VOS_STATUS_SUCCESS;
3504}
3505
3506static int iw_softap_get_sta_info(struct net_device *dev,
3507 struct iw_request_info *info,
3508 union iwreq_data *wrqu,
3509 char *extra)
3510{
3511 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3512 VOS_STATUS status;
3513 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07003514 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003515 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
3516 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!\n",__func__);
3517 return -EINVAL;
3518 }
3519 wrqu->data.length = strlen(extra);
3520 EXIT();
3521 return 0;
3522}
3523
Jeff Johnson295189b2012-06-20 16:38:30 -07003524static int iw_set_ap_genie(struct net_device *dev,
3525 struct iw_request_info *info,
3526 union iwreq_data *wrqu,
3527 char *extra)
3528{
3529
3530 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3531 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3532 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3533 u_int8_t *genie = wrqu->data.pointer;
3534
3535 ENTER();
3536
3537 if(!wrqu->data.length)
3538 {
3539 EXIT();
3540 return 0;
3541 }
3542
3543 switch (genie[0])
3544 {
3545 case DOT11F_EID_WPA:
3546 case DOT11F_EID_RSN:
3547 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
3548 {
3549 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
3550 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
3551 }
3552 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
3553 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, wrqu->data.pointer, wrqu->data.length);
3554 break;
3555
3556 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003557 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 halStatus = 0;
3559 }
3560
3561 EXIT();
3562 return halStatus;
3563}
3564
3565static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
3566{
3567 eHalStatus hstatus;
3568 long lrc;
3569 struct statsContext context;
3570
3571 if (NULL == pAdapter)
3572 {
3573 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Padapter is NULL", __func__);
3574 return VOS_STATUS_E_FAULT;
3575 }
3576
3577 init_completion(&context.completion);
3578 context.pAdapter = pAdapter;
3579 context.magic = STATS_CONTEXT_MAGIC;
3580 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3581 eCSR_HDD,
3582 SME_GLOBAL_CLASSA_STATS,
3583 hdd_GetClassA_statisticsCB,
3584 0, // not periodic
3585 FALSE, //non-cached results
3586 staid,
3587 &context);
3588 if (eHAL_STATUS_SUCCESS != hstatus)
3589 {
3590 hddLog(VOS_TRACE_LEVEL_ERROR,
3591 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003592 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 }
3594 else
3595 {
3596 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3597 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3598 context.magic = 0;
3599 if (lrc <= 0)
3600 {
3601 hddLog(VOS_TRACE_LEVEL_ERROR,
3602 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003603 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 msleep(50);
3605 }
3606 }
3607 return VOS_STATUS_SUCCESS;
3608}
3609
3610int iw_get_softap_linkspeed(struct net_device *dev,
3611 struct iw_request_info *info,
3612 union iwreq_data *wrqu,
3613 char *extra)
3614
3615{
3616 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303617 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303619 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303621 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
3623 VOS_STATUS status;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303624 int rc, valid;
3625
3626 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3627
3628 valid = wlan_hdd_validate_context(pHddCtx);
3629
3630 if (0 != valid)
3631 {
3632 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context not valid"));
3633 return valid;
3634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003635
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05303636 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d\n", __func__, wrqu->data.length);
3637 status = hdd_string_to_hex ((char *)wrqu->data.pointer, wrqu->data.length, macAddress );
3638
3639 if (!VOS_IS_STATUS_SUCCESS(status ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 {
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05303641 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 }
3643
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05303644 /* If no mac address is passed and/or its length is less than 18,
3645 * link speed for first connected client will be returned.
3646 */
3647 if (!VOS_IS_STATUS_SUCCESS(status ) || wrqu->data.length < 18)
3648 {
3649 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
3650 }
3651 else
3652 {
3653 status = hdd_softap_GetStaId(pHostapdAdapter,
3654 (v_MACADDR_t *)macAddress, (void *)(&staId));
3655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003656
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303657 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 link_speed = 0;
3661 }
3662 else
3663 {
3664 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303665
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 if (!VOS_IS_STATUS_SUCCESS(status ))
3667 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303668 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 return -EINVAL;
3670 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303671
3672 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
3673 staId, &link_speed);
3674
3675 link_speed = link_speed / 10;
3676
3677 if (0 == link_speed)
3678 {
3679 /* The linkspeed returned by HAL is in units of 500kbps.
3680 * converting it to mbps.
3681 * This is required to support legacy firmware which does
3682 * not return link capacity.
3683 */
3684 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 }
3687
3688 wrqu->data.length = len;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303689 rc = snprintf(pLinkSpeed, len, "%lu", link_speed);
3690
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 if ((rc < 0) || (rc >= len))
3692 {
3693 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303694 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 return -EIO;
3696 }
3697
3698 return 0;
3699}
3700
3701static const iw_handler hostapd_handler[] =
3702{
3703 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3704 (iw_handler) NULL, /* SIOCGIWNAME */
3705 (iw_handler) NULL, /* SIOCSIWNWID */
3706 (iw_handler) NULL, /* SIOCGIWNWID */
3707 (iw_handler) NULL, /* SIOCSIWFREQ */
3708 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
3709 (iw_handler) NULL, /* SIOCSIWMODE */
3710 (iw_handler) NULL, /* SIOCGIWMODE */
3711 (iw_handler) NULL, /* SIOCSIWSENS */
3712 (iw_handler) NULL, /* SIOCGIWSENS */
3713 (iw_handler) NULL, /* SIOCSIWRANGE */
3714 (iw_handler) NULL, /* SIOCGIWRANGE */
3715 (iw_handler) NULL, /* SIOCSIWPRIV */
3716 (iw_handler) NULL, /* SIOCGIWPRIV */
3717 (iw_handler) NULL, /* SIOCSIWSTATS */
3718 (iw_handler) NULL, /* SIOCGIWSTATS */
3719 (iw_handler) NULL, /* SIOCSIWSPY */
3720 (iw_handler) NULL, /* SIOCGIWSPY */
3721 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3722 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3723 (iw_handler) NULL, /* SIOCSIWAP */
3724 (iw_handler) NULL, /* SIOCGIWAP */
3725 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
3726 (iw_handler) NULL, /* SIOCGIWAPLIST */
3727 (iw_handler) NULL, /* SIOCSIWSCAN */
3728 (iw_handler) NULL, /* SIOCGIWSCAN */
3729 (iw_handler) NULL, /* SIOCSIWESSID */
3730 (iw_handler) NULL, /* SIOCGIWESSID */
3731 (iw_handler) NULL, /* SIOCSIWNICKN */
3732 (iw_handler) NULL, /* SIOCGIWNICKN */
3733 (iw_handler) NULL, /* -- hole -- */
3734 (iw_handler) NULL, /* -- hole -- */
3735 (iw_handler) NULL, /* SIOCSIWRATE */
3736 (iw_handler) NULL, /* SIOCGIWRATE */
3737 (iw_handler) NULL, /* SIOCSIWRTS */
3738 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
3739 (iw_handler) NULL, /* SIOCSIWFRAG */
3740 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
3741 (iw_handler) NULL, /* SIOCSIWTXPOW */
3742 (iw_handler) NULL, /* SIOCGIWTXPOW */
3743 (iw_handler) NULL, /* SIOCSIWRETRY */
3744 (iw_handler) NULL, /* SIOCGIWRETRY */
3745 (iw_handler) NULL, /* SIOCSIWENCODE */
3746 (iw_handler) NULL, /* SIOCGIWENCODE */
3747 (iw_handler) NULL, /* SIOCSIWPOWER */
3748 (iw_handler) NULL, /* SIOCGIWPOWER */
3749 (iw_handler) NULL, /* -- hole -- */
3750 (iw_handler) NULL, /* -- hole -- */
3751 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
3752 (iw_handler) NULL, /* SIOCGIWGENIE */
3753 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
3754 (iw_handler) NULL, /* SIOCGIWAUTH */
3755 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
3756 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
3757 (iw_handler) NULL, /* SIOCSIWPMKSA */
3758};
3759
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -08003760#define IW_PRIV_TYPE_OPTIE (IW_PRIV_TYPE_BYTE | QCSAP_MAX_OPT_IE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003761#define IW_PRIV_TYPE_MLME \
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -08003762 (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_mlme))
Jeff Johnson295189b2012-06-20 16:38:30 -07003763
3764static const struct iw_priv_args hostapd_private_args[] = {
3765 { QCSAP_IOCTL_SETPARAM,
3766 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
3767 { QCSAP_IOCTL_SETPARAM,
3768 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
3769 { QCSAP_PARAM_MAX_ASSOC,
3770 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
3771 { QCSAP_PARAM_HIDE_SSID,
3772 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07003773 { QCSAP_PARAM_SET_MC_RATE,
3774 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 { QCSAP_IOCTL_GETPARAM,
3776 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3777 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
3778 { QCSAP_IOCTL_GETPARAM, 0,
3779 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
3780 { QCSAP_PARAM_MAX_ASSOC, 0,
3781 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07003782 { QCSAP_PARAM_GET_WLAN_DBG, 0,
3783 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
3784 { QCSAP_PARAM_AUTO_CHANNEL, 0,
3785 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 { QCSAP_PARAM_MODULE_DOWN_IND, 0,
3787 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "moduleDownInd" },
3788 { QCSAP_PARAM_CLR_ACL, 0,
3789 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
3790 { QCSAP_PARAM_ACL_MODE,
3791 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
3792 { QCSAP_IOCTL_COMMIT,
3793 IW_PRIV_TYPE_BYTE | sizeof(struct s_CommitConfig) | IW_PRIV_SIZE_FIXED, 0, "commit" },
3794 { QCSAP_IOCTL_SETMLME,
3795 IW_PRIV_TYPE_BYTE | sizeof(struct sQcSapreq_mlme)| IW_PRIV_SIZE_FIXED, 0, "setmlme" },
3796 { QCSAP_IOCTL_GET_STAWPAIE,
3797 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
3798 { QCSAP_IOCTL_SETWPAIE,
3799 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
3800 { QCSAP_IOCTL_STOPBSS,
3801 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
3802 { QCSAP_IOCTL_VERSION, 0,
3803 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003804 { QCSAP_IOCTL_GET_STA_INFO, 0,
3805 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
3807 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED | 1, 0, "getProbeReqIEs" },
3808 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07003809 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 { QCSAP_IOCTL_ASSOC_STA_MACADDR, 0,
3811 IW_PRIV_TYPE_BYTE | /*((WLAN_MAX_STA_COUNT*6)+100)*/1 , "get_assoc_stamac" },
3812 { QCSAP_IOCTL_DISASSOC_STA,
3813 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
3814 { QCSAP_IOCTL_AP_STATS,
3815 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE, 0, "ap_stats" },
3816 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
3817 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303818 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003819
3820 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
3821 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
3822 /* handlers for sub-ioctl */
3823 { WE_SET_WLAN_DBG,
3824 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
3825 0,
3826 "setwlandbg" },
3827
3828 /* handlers for main ioctl */
3829 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
3830 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3831 0,
3832 "" },
3833
3834 /* handlers for sub-ioctl */
3835 { WE_LOG_DUMP_CMD,
3836 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3837 0,
3838 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 { WE_P2P_NOA_CMD,
3840 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3841 0,
3842 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08003843 /* handlers for sub ioctl */
3844 {
3845 WE_MCC_CONFIG_CREDENTIAL,
3846 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3847 0,
3848 "setMccCrdnl" },
3849
3850 /* handlers for sub ioctl */
3851 {
3852 WE_MCC_CONFIG_PARAMS,
3853 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3854 0,
3855 "setMccConfig" },
3856
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 /* handlers for main ioctl */
3858 { QCSAP_IOCTL_MODIFY_ACL,
3859 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
3860 0,
3861 "modify_acl" },
3862
3863 /* handlers for main ioctl */
3864 { QCSAP_IOCTL_GET_CHANNEL_LIST,
3865 0,
3866 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
3867 "getChannelList" },
3868
Jeff Johnsone7245742012-09-05 17:12:55 -07003869 /* handlers for main ioctl */
3870 { QCSAP_IOCTL_SET_TX_POWER,
3871 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3872 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05303873 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07003874
3875 /* handlers for main ioctl */
3876 { QCSAP_IOCTL_SET_MAX_TX_POWER,
3877 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3878 0,
3879 "setTxMaxPower" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303880 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
3881 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE, 0, "dataSnapshot" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003882};
Jeff Johnsone7245742012-09-05 17:12:55 -07003883
Jeff Johnson295189b2012-06-20 16:38:30 -07003884static const iw_handler hostapd_private[] = {
3885 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
3886 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
3887 [QCSAP_IOCTL_COMMIT - SIOCIWFIRSTPRIV] = iw_softap_commit, //get priv ioctl
3888 [QCSAP_IOCTL_SETMLME - SIOCIWFIRSTPRIV] = iw_softap_setmlme,
3889 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
3890 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
3891 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
3892 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
3893 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
3894 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
3895 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
3896 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
3897 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
3898 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
3899 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
3900 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
3901 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
3902 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003903 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07003904 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
3905 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07003906 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303907 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Jeff Johnson295189b2012-06-20 16:38:30 -07003908};
3909const struct iw_handler_def hostapd_handler_def = {
3910 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
3911 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
3912 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
3913 .standard = (iw_handler *)hostapd_handler,
3914 .private = (iw_handler *)hostapd_private,
3915 .private_args = hostapd_private_args,
3916 .get_wireless_stats = NULL,
3917};
3918#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
3919struct net_device_ops net_ops_struct = {
3920 .ndo_open = hdd_hostapd_open,
3921 .ndo_stop = hdd_hostapd_stop,
3922 .ndo_uninit = hdd_hostapd_uninit,
3923 .ndo_start_xmit = hdd_softap_hard_start_xmit,
3924 .ndo_tx_timeout = hdd_softap_tx_timeout,
3925 .ndo_get_stats = hdd_softap_stats,
3926 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
3927 .ndo_do_ioctl = hdd_hostapd_ioctl,
3928 .ndo_change_mtu = hdd_hostapd_change_mtu,
3929 .ndo_select_queue = hdd_hostapd_select_queue,
3930 };
3931#endif
3932
3933int hdd_set_hostapd(hdd_adapter_t *pAdapter)
3934{
3935 return VOS_STATUS_SUCCESS;
3936}
3937
3938void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
3939{
3940#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
3941 pWlanHostapdDev->netdev_ops = &net_ops_struct;
3942#else
3943 pWlanHostapdDev->open = hdd_hostapd_open;
3944 pWlanHostapdDev->stop = hdd_hostapd_stop;
3945 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
3946 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
3947 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
3948 pWlanHostapdDev->get_stats = hdd_softap_stats;
3949 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
3950 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
3951#endif
3952}
3953
3954VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
3955{
3956 hdd_hostapd_state_t * phostapdBuf;
3957 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07003958 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 VOS_STATUS status;
3960 ENTER();
3961 // Allocate the Wireless Extensions state structure
3962 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
3963
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07003964 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
3965
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 // Zero the memory. This zeros the profile structure.
3967 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
3968
3969 // Set up the pointer to the Wireless Extensions state structure
3970 // NOP
3971 status = hdd_set_hostapd(pAdapter);
3972 if(!VOS_IS_STATUS_SUCCESS(status)) {
3973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!\n"));
3974 return status;
3975 }
3976
3977 status = vos_event_init(&phostapdBuf->vosEvent);
3978 if (!VOS_IS_STATUS_SUCCESS(status))
3979 {
3980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!\n"));
3981 return status;
3982 }
3983
3984 init_completion(&pAdapter->session_close_comp_var);
3985 init_completion(&pAdapter->session_open_comp_var);
3986
3987 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
3988
3989 // Register as a wireless device
3990 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
3991
3992 //Initialize the data path module
3993 status = hdd_softap_init_tx_rx(pAdapter);
3994 if ( !VOS_IS_STATUS_SUCCESS( status ))
3995 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003996 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 }
3998
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 EXIT();
4001 return status;
4002}
4003
4004hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
4005{
4006 struct net_device *pWlanHostapdDev = NULL;
4007 hdd_adapter_t *pHostapdAdapter = NULL;
4008 v_CONTEXT_t pVosContext= NULL;
4009
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07004011
4012 if (pWlanHostapdDev != NULL)
4013 {
4014 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
4015
4016 //Init the net_device structure
4017 ether_setup(pWlanHostapdDev);
4018
4019 //Initialize the adapter context to zeros.
4020 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
4021 pHostapdAdapter->dev = pWlanHostapdDev;
4022 pHostapdAdapter->pHddCtx = pHddCtx;
4023 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
4024
4025 //Get the Global VOSS context.
4026 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
4027 //Save the adapter context in global context for future.
4028 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
4029
4030 //Init the net_device structure
4031 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
4032
4033 hdd_set_ap_ops( pHostapdAdapter->dev );
4034
4035 pWlanHostapdDev->tx_queue_len = NET_DEV_TX_QUEUE_LEN;
4036 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
4037 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
4038
4039 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
4040 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
4041
4042 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
4044 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
4045 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
4046 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
4048 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
4049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4050 init_completion(&pHostapdAdapter->offchannel_tx_event);
4051#endif
4052
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
4054 }
4055 return pHostapdAdapter;
4056}
4057
4058VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
4059{
4060 struct net_device *dev = pAdapter->dev;
4061 VOS_STATUS status = VOS_STATUS_SUCCESS;
4062
4063 ENTER();
4064
4065 if( rtnl_lock_held )
4066 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08004067 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 if( dev_alloc_name(dev, dev->name) < 0 )
4069 {
4070 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
4071 return VOS_STATUS_E_FAILURE;
4072 }
4073 }
4074 if (register_netdevice(dev))
4075 {
4076 hddLog(VOS_TRACE_LEVEL_FATAL,
4077 "%s:Failed:register_netdevice", __func__);
4078 return VOS_STATUS_E_FAILURE;
4079 }
4080 }
4081 else
4082 {
4083 if (register_netdev(dev))
4084 {
4085 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
4086 return VOS_STATUS_E_FAILURE;
4087 }
4088 }
4089 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
4090
4091 EXIT();
4092 return status;
4093}
4094
4095VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter)
4096{
4097 ENTER();
4098
4099 hdd_softap_deinit_tx_rx(pAdapter);
4100
4101 /* if we are being called during driver unload, then the dev has already
4102 been invalidated. if we are being called at other times, then we can
4103 detatch the wireless device handlers */
4104 if (pAdapter->dev)
4105 {
4106 pAdapter->dev->wireless_handlers = NULL;
4107 }
4108 EXIT();
4109 return 0;
4110}