Commit | Line | Data |
---|---|---|
40d07030 AP |
1 | /* |
2 | * Marvell Wireless LAN device driver: AP specific command handling | |
3 | * | |
65da33f5 | 4 | * Copyright (C) 2012-2014, Marvell International Ltd. |
40d07030 AP |
5 | * |
6 | * This software file (the "File") is distributed by Marvell International | |
7 | * Ltd. under the terms of the GNU General Public License Version 2, June 1991 | |
8 | * (the "License"). You may use, redistribute and/or modify this File in | |
9 | * accordance with the terms and conditions of the License, a copy of which | |
10 | * is available by writing to the Free Software Foundation, Inc., | |
11 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the | |
12 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | |
13 | * | |
14 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE | |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE | |
16 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about | |
17 | * this warranty disclaimer. | |
18 | */ | |
19 | ||
20 | #include "main.h" | |
83c78da9 | 21 | #include "11ac.h" |
40d07030 | 22 | |
f752dcd5 AP |
23 | /* This function parses security related parameters from cfg80211_ap_settings |
24 | * and sets into FW understandable bss_config structure. | |
25 | */ | |
26 | int mwifiex_set_secure_params(struct mwifiex_private *priv, | |
27 | struct mwifiex_uap_bss_param *bss_config, | |
28 | struct cfg80211_ap_settings *params) { | |
29 | int i; | |
96893538 | 30 | struct mwifiex_wep_key wep_key; |
f752dcd5 | 31 | |
6ddcd464 AP |
32 | if (!params->privacy) { |
33 | bss_config->protocol = PROTOCOL_NO_SECURITY; | |
34 | bss_config->key_mgmt = KEY_MGMT_NONE; | |
35 | bss_config->wpa_cfg.length = 0; | |
36 | priv->sec_info.wep_enabled = 0; | |
37 | priv->sec_info.wpa_enabled = 0; | |
38 | priv->sec_info.wpa2_enabled = 0; | |
39 | ||
40 | return 0; | |
41 | } | |
42 | ||
f752dcd5 AP |
43 | switch (params->auth_type) { |
44 | case NL80211_AUTHTYPE_OPEN_SYSTEM: | |
45 | bss_config->auth_mode = WLAN_AUTH_OPEN; | |
46 | break; | |
47 | case NL80211_AUTHTYPE_SHARED_KEY: | |
48 | bss_config->auth_mode = WLAN_AUTH_SHARED_KEY; | |
49 | break; | |
50 | case NL80211_AUTHTYPE_NETWORK_EAP: | |
51 | bss_config->auth_mode = WLAN_AUTH_LEAP; | |
52 | break; | |
53 | default: | |
54 | bss_config->auth_mode = MWIFIEX_AUTH_MODE_AUTO; | |
55 | break; | |
56 | } | |
57 | ||
58 | bss_config->key_mgmt_operation |= KEY_MGMT_ON_HOST; | |
59 | ||
60 | for (i = 0; i < params->crypto.n_akm_suites; i++) { | |
61 | switch (params->crypto.akm_suites[i]) { | |
62 | case WLAN_AKM_SUITE_8021X: | |
63 | if (params->crypto.wpa_versions & | |
64 | NL80211_WPA_VERSION_1) { | |
65 | bss_config->protocol = PROTOCOL_WPA; | |
66 | bss_config->key_mgmt = KEY_MGMT_EAP; | |
67 | } | |
68 | if (params->crypto.wpa_versions & | |
69 | NL80211_WPA_VERSION_2) { | |
0fd66be4 | 70 | bss_config->protocol |= PROTOCOL_WPA2; |
f752dcd5 AP |
71 | bss_config->key_mgmt = KEY_MGMT_EAP; |
72 | } | |
73 | break; | |
74 | case WLAN_AKM_SUITE_PSK: | |
75 | if (params->crypto.wpa_versions & | |
76 | NL80211_WPA_VERSION_1) { | |
77 | bss_config->protocol = PROTOCOL_WPA; | |
78 | bss_config->key_mgmt = KEY_MGMT_PSK; | |
79 | } | |
80 | if (params->crypto.wpa_versions & | |
81 | NL80211_WPA_VERSION_2) { | |
0fd66be4 | 82 | bss_config->protocol |= PROTOCOL_WPA2; |
f752dcd5 AP |
83 | bss_config->key_mgmt = KEY_MGMT_PSK; |
84 | } | |
85 | break; | |
86 | default: | |
87 | break; | |
88 | } | |
89 | } | |
90 | for (i = 0; i < params->crypto.n_ciphers_pairwise; i++) { | |
91 | switch (params->crypto.ciphers_pairwise[i]) { | |
92 | case WLAN_CIPHER_SUITE_WEP40: | |
93 | case WLAN_CIPHER_SUITE_WEP104: | |
94 | break; | |
95 | case WLAN_CIPHER_SUITE_TKIP: | |
0fd66be4 AP |
96 | if (params->crypto.wpa_versions & NL80211_WPA_VERSION_1) |
97 | bss_config->wpa_cfg.pairwise_cipher_wpa |= | |
98 | CIPHER_TKIP; | |
99 | if (params->crypto.wpa_versions & NL80211_WPA_VERSION_2) | |
100 | bss_config->wpa_cfg.pairwise_cipher_wpa2 |= | |
101 | CIPHER_TKIP; | |
f752dcd5 AP |
102 | break; |
103 | case WLAN_CIPHER_SUITE_CCMP: | |
0fd66be4 AP |
104 | if (params->crypto.wpa_versions & NL80211_WPA_VERSION_1) |
105 | bss_config->wpa_cfg.pairwise_cipher_wpa |= | |
106 | CIPHER_AES_CCMP; | |
107 | if (params->crypto.wpa_versions & NL80211_WPA_VERSION_2) | |
108 | bss_config->wpa_cfg.pairwise_cipher_wpa2 |= | |
f752dcd5 AP |
109 | CIPHER_AES_CCMP; |
110 | default: | |
111 | break; | |
112 | } | |
113 | } | |
114 | ||
115 | switch (params->crypto.cipher_group) { | |
116 | case WLAN_CIPHER_SUITE_WEP40: | |
117 | case WLAN_CIPHER_SUITE_WEP104: | |
96893538 AP |
118 | if (priv->sec_info.wep_enabled) { |
119 | bss_config->protocol = PROTOCOL_STATIC_WEP; | |
120 | bss_config->key_mgmt = KEY_MGMT_NONE; | |
121 | bss_config->wpa_cfg.length = 0; | |
122 | ||
123 | for (i = 0; i < NUM_WEP_KEYS; i++) { | |
124 | wep_key = priv->wep_key[i]; | |
125 | bss_config->wep_cfg[i].key_index = i; | |
126 | ||
127 | if (priv->wep_key_curr_index == i) | |
128 | bss_config->wep_cfg[i].is_default = 1; | |
129 | else | |
130 | bss_config->wep_cfg[i].is_default = 0; | |
131 | ||
132 | bss_config->wep_cfg[i].length = | |
133 | wep_key.key_length; | |
134 | memcpy(&bss_config->wep_cfg[i].key, | |
135 | &wep_key.key_material, | |
136 | wep_key.key_length); | |
137 | } | |
138 | } | |
f752dcd5 AP |
139 | break; |
140 | case WLAN_CIPHER_SUITE_TKIP: | |
141 | bss_config->wpa_cfg.group_cipher = CIPHER_TKIP; | |
142 | break; | |
143 | case WLAN_CIPHER_SUITE_CCMP: | |
144 | bss_config->wpa_cfg.group_cipher = CIPHER_AES_CCMP; | |
145 | break; | |
146 | default: | |
147 | break; | |
148 | } | |
149 | ||
150 | return 0; | |
151 | } | |
152 | ||
22281256 AP |
153 | /* This function updates 11n related parameters from IE and sets them into |
154 | * bss_config structure. | |
155 | */ | |
156 | void | |
157 | mwifiex_set_ht_params(struct mwifiex_private *priv, | |
158 | struct mwifiex_uap_bss_param *bss_cfg, | |
159 | struct cfg80211_ap_settings *params) | |
160 | { | |
161 | const u8 *ht_ie; | |
474a41e9 | 162 | u16 cap_info; |
22281256 AP |
163 | |
164 | if (!ISSUPP_11NENABLED(priv->adapter->fw_cap_info)) | |
165 | return; | |
166 | ||
167 | ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, params->beacon.tail, | |
168 | params->beacon.tail_len); | |
169 | if (ht_ie) { | |
9ab7b5b9 | 170 | memcpy(&bss_cfg->ht_cap, ht_ie + 2, |
22281256 | 171 | sizeof(struct ieee80211_ht_cap)); |
474a41e9 MH |
172 | cap_info = le16_to_cpu(bss_cfg->ht_cap.cap_info); |
173 | memset(&bss_cfg->ht_cap.mcs, 0, | |
174 | priv->adapter->number_of_antenna); | |
175 | switch (GET_RXSTBC(cap_info)) { | |
176 | case MWIFIEX_RX_STBC1: | |
177 | /* HT_CAP 1X1 mode */ | |
16cf6b80 | 178 | bss_cfg->ht_cap.mcs.rx_mask[0] = 0xff; |
474a41e9 MH |
179 | break; |
180 | case MWIFIEX_RX_STBC12: /* fall through */ | |
181 | case MWIFIEX_RX_STBC123: | |
182 | /* HT_CAP 2X2 mode */ | |
16cf6b80 MH |
183 | bss_cfg->ht_cap.mcs.rx_mask[0] = 0xff; |
184 | bss_cfg->ht_cap.mcs.rx_mask[1] = 0xff; | |
474a41e9 MH |
185 | break; |
186 | default: | |
acebe8c1 ZL |
187 | mwifiex_dbg(priv->adapter, WARN, |
188 | "Unsupported RX-STBC, default to 2x2\n"); | |
16cf6b80 MH |
189 | bss_cfg->ht_cap.mcs.rx_mask[0] = 0xff; |
190 | bss_cfg->ht_cap.mcs.rx_mask[1] = 0xff; | |
474a41e9 MH |
191 | break; |
192 | } | |
c8258913 | 193 | priv->ap_11n_enabled = 1; |
22281256 | 194 | } else { |
3a968d76 | 195 | memset(&bss_cfg->ht_cap, 0, sizeof(struct ieee80211_ht_cap)); |
22281256 AP |
196 | bss_cfg->ht_cap.cap_info = cpu_to_le16(MWIFIEX_DEF_HT_CAP); |
197 | bss_cfg->ht_cap.ampdu_params_info = MWIFIEX_DEF_AMPDU; | |
198 | } | |
199 | ||
200 | return; | |
201 | } | |
202 | ||
83c78da9 YAP |
203 | /* This function updates 11ac related parameters from IE |
204 | * and sets them into bss_config structure. | |
205 | */ | |
206 | void mwifiex_set_vht_params(struct mwifiex_private *priv, | |
207 | struct mwifiex_uap_bss_param *bss_cfg, | |
208 | struct cfg80211_ap_settings *params) | |
209 | { | |
210 | const u8 *vht_ie; | |
211 | ||
212 | vht_ie = cfg80211_find_ie(WLAN_EID_VHT_CAPABILITY, params->beacon.tail, | |
213 | params->beacon.tail_len); | |
214 | if (vht_ie) { | |
215 | memcpy(&bss_cfg->vht_cap, vht_ie + 2, | |
216 | sizeof(struct ieee80211_vht_cap)); | |
217 | priv->ap_11ac_enabled = 1; | |
218 | } else { | |
219 | priv->ap_11ac_enabled = 0; | |
220 | } | |
221 | ||
222 | return; | |
223 | } | |
224 | ||
8a73dd63 AP |
225 | /* This function updates 11ac related parameters from IE |
226 | * and sets them into bss_config structure. | |
227 | */ | |
228 | void mwifiex_set_tpc_params(struct mwifiex_private *priv, | |
229 | struct mwifiex_uap_bss_param *bss_cfg, | |
230 | struct cfg80211_ap_settings *params) | |
231 | { | |
232 | const u8 *tpc_ie; | |
233 | ||
234 | tpc_ie = cfg80211_find_ie(WLAN_EID_TPC_REQUEST, params->beacon.tail, | |
235 | params->beacon.tail_len); | |
236 | if (tpc_ie) | |
237 | bss_cfg->power_constraint = *(tpc_ie + 2); | |
238 | else | |
239 | bss_cfg->power_constraint = 0; | |
240 | } | |
241 | ||
83c78da9 YAP |
242 | /* Enable VHT only when cfg80211_ap_settings has VHT IE. |
243 | * Otherwise disable VHT. | |
244 | */ | |
245 | void mwifiex_set_vht_width(struct mwifiex_private *priv, | |
246 | enum nl80211_chan_width width, | |
247 | bool ap_11ac_enable) | |
248 | { | |
249 | struct mwifiex_adapter *adapter = priv->adapter; | |
250 | struct mwifiex_11ac_vht_cfg vht_cfg; | |
251 | ||
252 | vht_cfg.band_config = VHT_CFG_5GHZ; | |
253 | vht_cfg.cap_info = adapter->hw_dot_11ac_dev_cap; | |
254 | ||
255 | if (!ap_11ac_enable) { | |
256 | vht_cfg.mcs_tx_set = DISABLE_VHT_MCS_SET; | |
257 | vht_cfg.mcs_rx_set = DISABLE_VHT_MCS_SET; | |
258 | } else { | |
259 | vht_cfg.mcs_tx_set = DEFAULT_VHT_MCS_SET; | |
260 | vht_cfg.mcs_rx_set = DEFAULT_VHT_MCS_SET; | |
261 | } | |
262 | ||
263 | vht_cfg.misc_config = VHT_CAP_UAP_ONLY; | |
264 | ||
265 | if (ap_11ac_enable && width >= NL80211_CHAN_WIDTH_80) | |
266 | vht_cfg.misc_config |= VHT_BW_80_160_80P80; | |
267 | ||
fa0ecbb9 BZ |
268 | mwifiex_send_cmd(priv, HostCmd_CMD_11AC_CFG, |
269 | HostCmd_ACT_GEN_SET, 0, &vht_cfg, true); | |
83c78da9 YAP |
270 | |
271 | return; | |
272 | } | |
273 | ||
a3c2c4f6 AP |
274 | /* This function finds supported rates IE from beacon parameter and sets |
275 | * these rates into bss_config structure. | |
276 | */ | |
277 | void | |
278 | mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg, | |
279 | struct cfg80211_ap_settings *params) | |
280 | { | |
281 | struct ieee_types_header *rate_ie; | |
282 | int var_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); | |
283 | const u8 *var_pos = params->beacon.head + var_offset; | |
284 | int len = params->beacon.head_len - var_offset; | |
3a5b8a16 | 285 | u8 rate_len = 0; |
a3c2c4f6 AP |
286 | |
287 | rate_ie = (void *)cfg80211_find_ie(WLAN_EID_SUPP_RATES, var_pos, len); | |
3a5b8a16 | 288 | if (rate_ie) { |
a3c2c4f6 | 289 | memcpy(bss_cfg->rates, rate_ie + 1, rate_ie->len); |
3a5b8a16 AP |
290 | rate_len = rate_ie->len; |
291 | } | |
292 | ||
293 | rate_ie = (void *)cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, | |
294 | params->beacon.tail, | |
295 | params->beacon.tail_len); | |
296 | if (rate_ie) | |
297 | memcpy(bss_cfg->rates + rate_len, rate_ie + 1, rate_ie->len); | |
a3c2c4f6 AP |
298 | |
299 | return; | |
300 | } | |
301 | ||
9b930eae AP |
302 | /* This function initializes some of mwifiex_uap_bss_param variables. |
303 | * This helps FW in ignoring invalid values. These values may or may not | |
304 | * be get updated to valid ones at later stage. | |
305 | */ | |
306 | void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config) | |
307 | { | |
f752dcd5 AP |
308 | config->bcast_ssid_ctl = 0x7F; |
309 | config->radio_ctl = 0x7F; | |
310 | config->dtim_period = 0x7F; | |
311 | config->beacon_period = 0x7FFF; | |
312 | config->auth_mode = 0x7F; | |
9b930eae AP |
313 | config->rts_threshold = 0x7FFF; |
314 | config->frag_threshold = 0x7FFF; | |
315 | config->retry_limit = 0x7F; | |
54428c57 | 316 | config->qos_info = 0xFF; |
9b930eae AP |
317 | } |
318 | ||
5d66cb62 AP |
319 | /* This function parses BSS related parameters from structure |
320 | * and prepares TLVs specific to WPA/WPA2 security. | |
321 | * These TLVs are appended to command buffer. | |
322 | */ | |
323 | static void | |
324 | mwifiex_uap_bss_wpa(u8 **tlv_buf, void *cmd_buf, u16 *param_size) | |
325 | { | |
326 | struct host_cmd_tlv_pwk_cipher *pwk_cipher; | |
327 | struct host_cmd_tlv_gwk_cipher *gwk_cipher; | |
328 | struct host_cmd_tlv_passphrase *passphrase; | |
329 | struct host_cmd_tlv_akmp *tlv_akmp; | |
330 | struct mwifiex_uap_bss_param *bss_cfg = cmd_buf; | |
331 | u16 cmd_size = *param_size; | |
332 | u8 *tlv = *tlv_buf; | |
333 | ||
334 | tlv_akmp = (struct host_cmd_tlv_akmp *)tlv; | |
6b21a69f AK |
335 | tlv_akmp->header.type = cpu_to_le16(TLV_TYPE_UAP_AKMP); |
336 | tlv_akmp->header.len = cpu_to_le16(sizeof(struct host_cmd_tlv_akmp) - | |
337 | sizeof(struct mwifiex_ie_types_header)); | |
5d66cb62 AP |
338 | tlv_akmp->key_mgmt_operation = cpu_to_le16(bss_cfg->key_mgmt_operation); |
339 | tlv_akmp->key_mgmt = cpu_to_le16(bss_cfg->key_mgmt); | |
340 | cmd_size += sizeof(struct host_cmd_tlv_akmp); | |
341 | tlv += sizeof(struct host_cmd_tlv_akmp); | |
342 | ||
343 | if (bss_cfg->wpa_cfg.pairwise_cipher_wpa & VALID_CIPHER_BITMAP) { | |
344 | pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv; | |
6b21a69f AK |
345 | pwk_cipher->header.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER); |
346 | pwk_cipher->header.len = | |
5d66cb62 | 347 | cpu_to_le16(sizeof(struct host_cmd_tlv_pwk_cipher) - |
6b21a69f | 348 | sizeof(struct mwifiex_ie_types_header)); |
5d66cb62 AP |
349 | pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA); |
350 | pwk_cipher->cipher = bss_cfg->wpa_cfg.pairwise_cipher_wpa; | |
351 | cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher); | |
352 | tlv += sizeof(struct host_cmd_tlv_pwk_cipher); | |
353 | } | |
354 | ||
355 | if (bss_cfg->wpa_cfg.pairwise_cipher_wpa2 & VALID_CIPHER_BITMAP) { | |
356 | pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv; | |
6b21a69f AK |
357 | pwk_cipher->header.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER); |
358 | pwk_cipher->header.len = | |
5d66cb62 | 359 | cpu_to_le16(sizeof(struct host_cmd_tlv_pwk_cipher) - |
6b21a69f | 360 | sizeof(struct mwifiex_ie_types_header)); |
5d66cb62 AP |
361 | pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA2); |
362 | pwk_cipher->cipher = bss_cfg->wpa_cfg.pairwise_cipher_wpa2; | |
363 | cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher); | |
364 | tlv += sizeof(struct host_cmd_tlv_pwk_cipher); | |
365 | } | |
366 | ||
367 | if (bss_cfg->wpa_cfg.group_cipher & VALID_CIPHER_BITMAP) { | |
368 | gwk_cipher = (struct host_cmd_tlv_gwk_cipher *)tlv; | |
6b21a69f AK |
369 | gwk_cipher->header.type = cpu_to_le16(TLV_TYPE_GWK_CIPHER); |
370 | gwk_cipher->header.len = | |
5d66cb62 | 371 | cpu_to_le16(sizeof(struct host_cmd_tlv_gwk_cipher) - |
6b21a69f | 372 | sizeof(struct mwifiex_ie_types_header)); |
5d66cb62 AP |
373 | gwk_cipher->cipher = bss_cfg->wpa_cfg.group_cipher; |
374 | cmd_size += sizeof(struct host_cmd_tlv_gwk_cipher); | |
375 | tlv += sizeof(struct host_cmd_tlv_gwk_cipher); | |
376 | } | |
377 | ||
378 | if (bss_cfg->wpa_cfg.length) { | |
379 | passphrase = (struct host_cmd_tlv_passphrase *)tlv; | |
6b21a69f AK |
380 | passphrase->header.type = |
381 | cpu_to_le16(TLV_TYPE_UAP_WPA_PASSPHRASE); | |
382 | passphrase->header.len = cpu_to_le16(bss_cfg->wpa_cfg.length); | |
5d66cb62 AP |
383 | memcpy(passphrase->passphrase, bss_cfg->wpa_cfg.passphrase, |
384 | bss_cfg->wpa_cfg.length); | |
6b21a69f | 385 | cmd_size += sizeof(struct mwifiex_ie_types_header) + |
5d66cb62 | 386 | bss_cfg->wpa_cfg.length; |
6b21a69f AK |
387 | tlv += sizeof(struct mwifiex_ie_types_header) + |
388 | bss_cfg->wpa_cfg.length; | |
5d66cb62 AP |
389 | } |
390 | ||
391 | *param_size = cmd_size; | |
392 | *tlv_buf = tlv; | |
393 | ||
394 | return; | |
395 | } | |
396 | ||
54428c57 AP |
397 | /* This function parses WMM related parameters from cfg80211_ap_settings |
398 | * structure and updates bss_config structure. | |
399 | */ | |
400 | void | |
401 | mwifiex_set_wmm_params(struct mwifiex_private *priv, | |
402 | struct mwifiex_uap_bss_param *bss_cfg, | |
403 | struct cfg80211_ap_settings *params) | |
404 | { | |
405 | const u8 *vendor_ie; | |
406 | struct ieee_types_header *wmm_ie; | |
407 | u8 wmm_oui[] = {0x00, 0x50, 0xf2, 0x02}; | |
408 | ||
409 | vendor_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, | |
410 | WLAN_OUI_TYPE_MICROSOFT_WMM, | |
411 | params->beacon.tail, | |
412 | params->beacon.tail_len); | |
413 | if (vendor_ie) { | |
414 | wmm_ie = (struct ieee_types_header *)vendor_ie; | |
415 | memcpy(&bss_cfg->wmm_info, wmm_ie + 1, | |
416 | sizeof(bss_cfg->wmm_info)); | |
417 | priv->wmm_enabled = 1; | |
418 | } else { | |
419 | memset(&bss_cfg->wmm_info, 0, sizeof(bss_cfg->wmm_info)); | |
420 | memcpy(&bss_cfg->wmm_info.oui, wmm_oui, sizeof(wmm_oui)); | |
421 | bss_cfg->wmm_info.subtype = MWIFIEX_WMM_SUBTYPE; | |
422 | bss_cfg->wmm_info.version = MWIFIEX_WMM_VERSION; | |
423 | priv->wmm_enabled = 0; | |
424 | } | |
425 | ||
426 | bss_cfg->qos_info = 0x00; | |
427 | return; | |
428 | } | |
96893538 AP |
429 | /* This function parses BSS related parameters from structure |
430 | * and prepares TLVs specific to WEP encryption. | |
431 | * These TLVs are appended to command buffer. | |
432 | */ | |
433 | static void | |
434 | mwifiex_uap_bss_wep(u8 **tlv_buf, void *cmd_buf, u16 *param_size) | |
435 | { | |
436 | struct host_cmd_tlv_wep_key *wep_key; | |
437 | u16 cmd_size = *param_size; | |
438 | int i; | |
439 | u8 *tlv = *tlv_buf; | |
440 | struct mwifiex_uap_bss_param *bss_cfg = cmd_buf; | |
441 | ||
442 | for (i = 0; i < NUM_WEP_KEYS; i++) { | |
443 | if (bss_cfg->wep_cfg[i].length && | |
444 | (bss_cfg->wep_cfg[i].length == WLAN_KEY_LEN_WEP40 || | |
445 | bss_cfg->wep_cfg[i].length == WLAN_KEY_LEN_WEP104)) { | |
446 | wep_key = (struct host_cmd_tlv_wep_key *)tlv; | |
6b21a69f AK |
447 | wep_key->header.type = |
448 | cpu_to_le16(TLV_TYPE_UAP_WEP_KEY); | |
449 | wep_key->header.len = | |
96893538 AP |
450 | cpu_to_le16(bss_cfg->wep_cfg[i].length + 2); |
451 | wep_key->key_index = bss_cfg->wep_cfg[i].key_index; | |
452 | wep_key->is_default = bss_cfg->wep_cfg[i].is_default; | |
453 | memcpy(wep_key->key, bss_cfg->wep_cfg[i].key, | |
454 | bss_cfg->wep_cfg[i].length); | |
6b21a69f | 455 | cmd_size += sizeof(struct mwifiex_ie_types_header) + 2 + |
96893538 | 456 | bss_cfg->wep_cfg[i].length; |
6b21a69f | 457 | tlv += sizeof(struct mwifiex_ie_types_header) + 2 + |
96893538 AP |
458 | bss_cfg->wep_cfg[i].length; |
459 | } | |
460 | } | |
461 | ||
462 | *param_size = cmd_size; | |
463 | *tlv_buf = tlv; | |
464 | ||
465 | return; | |
466 | } | |
467 | ||
e76268da AP |
468 | /* This function parses BSS related parameters from structure |
469 | * and prepares TLVs. These TLVs are appended to command buffer. | |
470 | */ | |
471 | static int | |
472 | mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) | |
4db16a18 | 473 | { |
12190c5d AP |
474 | struct host_cmd_tlv_dtim_period *dtim_period; |
475 | struct host_cmd_tlv_beacon_period *beacon_period; | |
476 | struct host_cmd_tlv_ssid *ssid; | |
7a1c9934 | 477 | struct host_cmd_tlv_bcast_ssid *bcast_ssid; |
4db16a18 | 478 | struct host_cmd_tlv_channel_band *chan_band; |
9b930eae AP |
479 | struct host_cmd_tlv_frag_threshold *frag_threshold; |
480 | struct host_cmd_tlv_rts_threshold *rts_threshold; | |
481 | struct host_cmd_tlv_retry_limit *retry_limit; | |
f752dcd5 AP |
482 | struct host_cmd_tlv_encrypt_protocol *encrypt_protocol; |
483 | struct host_cmd_tlv_auth_type *auth_type; | |
a3c2c4f6 | 484 | struct host_cmd_tlv_rates *tlv_rates; |
8b4509f6 | 485 | struct host_cmd_tlv_ageout_timer *ao_timer, *ps_ao_timer; |
8a73dd63 | 486 | struct host_cmd_tlv_power_constraint *pwr_ct; |
22281256 | 487 | struct mwifiex_ie_types_htcap *htcap; |
54428c57 | 488 | struct mwifiex_ie_types_wmmcap *wmm_cap; |
4db16a18 | 489 | struct mwifiex_uap_bss_param *bss_cfg = cmd_buf; |
a3c2c4f6 | 490 | int i; |
e76268da | 491 | u16 cmd_size = *param_size; |
4db16a18 | 492 | |
12190c5d AP |
493 | if (bss_cfg->ssid.ssid_len) { |
494 | ssid = (struct host_cmd_tlv_ssid *)tlv; | |
6b21a69f AK |
495 | ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_SSID); |
496 | ssid->header.len = cpu_to_le16((u16)bss_cfg->ssid.ssid_len); | |
12190c5d | 497 | memcpy(ssid->ssid, bss_cfg->ssid.ssid, bss_cfg->ssid.ssid_len); |
6b21a69f | 498 | cmd_size += sizeof(struct mwifiex_ie_types_header) + |
12190c5d | 499 | bss_cfg->ssid.ssid_len; |
6b21a69f AK |
500 | tlv += sizeof(struct mwifiex_ie_types_header) + |
501 | bss_cfg->ssid.ssid_len; | |
7a1c9934 AP |
502 | |
503 | bcast_ssid = (struct host_cmd_tlv_bcast_ssid *)tlv; | |
6b21a69f AK |
504 | bcast_ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_BCAST_SSID); |
505 | bcast_ssid->header.len = | |
7a1c9934 AP |
506 | cpu_to_le16(sizeof(bcast_ssid->bcast_ctl)); |
507 | bcast_ssid->bcast_ctl = bss_cfg->bcast_ssid_ctl; | |
508 | cmd_size += sizeof(struct host_cmd_tlv_bcast_ssid); | |
509 | tlv += sizeof(struct host_cmd_tlv_bcast_ssid); | |
12190c5d | 510 | } |
a3c2c4f6 AP |
511 | if (bss_cfg->rates[0]) { |
512 | tlv_rates = (struct host_cmd_tlv_rates *)tlv; | |
6b21a69f | 513 | tlv_rates->header.type = cpu_to_le16(TLV_TYPE_UAP_RATES); |
a3c2c4f6 AP |
514 | |
515 | for (i = 0; i < MWIFIEX_SUPPORTED_RATES && bss_cfg->rates[i]; | |
516 | i++) | |
517 | tlv_rates->rates[i] = bss_cfg->rates[i]; | |
518 | ||
6b21a69f | 519 | tlv_rates->header.len = cpu_to_le16(i); |
a3c2c4f6 AP |
520 | cmd_size += sizeof(struct host_cmd_tlv_rates) + i; |
521 | tlv += sizeof(struct host_cmd_tlv_rates) + i; | |
522 | } | |
523 | if (bss_cfg->channel && | |
524 | ((bss_cfg->band_cfg == BAND_CONFIG_BG && | |
525 | bss_cfg->channel <= MAX_CHANNEL_BAND_BG) || | |
526 | (bss_cfg->band_cfg == BAND_CONFIG_A && | |
527 | bss_cfg->channel <= MAX_CHANNEL_BAND_A))) { | |
4db16a18 | 528 | chan_band = (struct host_cmd_tlv_channel_band *)tlv; |
6b21a69f AK |
529 | chan_band->header.type = cpu_to_le16(TLV_TYPE_CHANNELBANDLIST); |
530 | chan_band->header.len = | |
4db16a18 | 531 | cpu_to_le16(sizeof(struct host_cmd_tlv_channel_band) - |
6b21a69f | 532 | sizeof(struct mwifiex_ie_types_header)); |
4db16a18 AP |
533 | chan_band->band_config = bss_cfg->band_cfg; |
534 | chan_band->channel = bss_cfg->channel; | |
535 | cmd_size += sizeof(struct host_cmd_tlv_channel_band); | |
536 | tlv += sizeof(struct host_cmd_tlv_channel_band); | |
537 | } | |
12190c5d AP |
538 | if (bss_cfg->beacon_period >= MIN_BEACON_PERIOD && |
539 | bss_cfg->beacon_period <= MAX_BEACON_PERIOD) { | |
540 | beacon_period = (struct host_cmd_tlv_beacon_period *)tlv; | |
6b21a69f | 541 | beacon_period->header.type = |
12190c5d | 542 | cpu_to_le16(TLV_TYPE_UAP_BEACON_PERIOD); |
6b21a69f | 543 | beacon_period->header.len = |
12190c5d | 544 | cpu_to_le16(sizeof(struct host_cmd_tlv_beacon_period) - |
6b21a69f | 545 | sizeof(struct mwifiex_ie_types_header)); |
12190c5d AP |
546 | beacon_period->period = cpu_to_le16(bss_cfg->beacon_period); |
547 | cmd_size += sizeof(struct host_cmd_tlv_beacon_period); | |
548 | tlv += sizeof(struct host_cmd_tlv_beacon_period); | |
549 | } | |
550 | if (bss_cfg->dtim_period >= MIN_DTIM_PERIOD && | |
551 | bss_cfg->dtim_period <= MAX_DTIM_PERIOD) { | |
552 | dtim_period = (struct host_cmd_tlv_dtim_period *)tlv; | |
6b21a69f AK |
553 | dtim_period->header.type = |
554 | cpu_to_le16(TLV_TYPE_UAP_DTIM_PERIOD); | |
555 | dtim_period->header.len = | |
12190c5d | 556 | cpu_to_le16(sizeof(struct host_cmd_tlv_dtim_period) - |
6b21a69f | 557 | sizeof(struct mwifiex_ie_types_header)); |
12190c5d AP |
558 | dtim_period->period = bss_cfg->dtim_period; |
559 | cmd_size += sizeof(struct host_cmd_tlv_dtim_period); | |
560 | tlv += sizeof(struct host_cmd_tlv_dtim_period); | |
561 | } | |
9b930eae AP |
562 | if (bss_cfg->rts_threshold <= MWIFIEX_RTS_MAX_VALUE) { |
563 | rts_threshold = (struct host_cmd_tlv_rts_threshold *)tlv; | |
6b21a69f | 564 | rts_threshold->header.type = |
9b930eae | 565 | cpu_to_le16(TLV_TYPE_UAP_RTS_THRESHOLD); |
6b21a69f | 566 | rts_threshold->header.len = |
9b930eae | 567 | cpu_to_le16(sizeof(struct host_cmd_tlv_rts_threshold) - |
6b21a69f | 568 | sizeof(struct mwifiex_ie_types_header)); |
9b930eae AP |
569 | rts_threshold->rts_thr = cpu_to_le16(bss_cfg->rts_threshold); |
570 | cmd_size += sizeof(struct host_cmd_tlv_frag_threshold); | |
571 | tlv += sizeof(struct host_cmd_tlv_frag_threshold); | |
572 | } | |
573 | if ((bss_cfg->frag_threshold >= MWIFIEX_FRAG_MIN_VALUE) && | |
574 | (bss_cfg->frag_threshold <= MWIFIEX_FRAG_MAX_VALUE)) { | |
575 | frag_threshold = (struct host_cmd_tlv_frag_threshold *)tlv; | |
6b21a69f | 576 | frag_threshold->header.type = |
9b930eae | 577 | cpu_to_le16(TLV_TYPE_UAP_FRAG_THRESHOLD); |
6b21a69f | 578 | frag_threshold->header.len = |
9b930eae | 579 | cpu_to_le16(sizeof(struct host_cmd_tlv_frag_threshold) - |
6b21a69f | 580 | sizeof(struct mwifiex_ie_types_header)); |
9b930eae AP |
581 | frag_threshold->frag_thr = cpu_to_le16(bss_cfg->frag_threshold); |
582 | cmd_size += sizeof(struct host_cmd_tlv_frag_threshold); | |
583 | tlv += sizeof(struct host_cmd_tlv_frag_threshold); | |
584 | } | |
585 | if (bss_cfg->retry_limit <= MWIFIEX_RETRY_LIMIT) { | |
586 | retry_limit = (struct host_cmd_tlv_retry_limit *)tlv; | |
6b21a69f AK |
587 | retry_limit->header.type = |
588 | cpu_to_le16(TLV_TYPE_UAP_RETRY_LIMIT); | |
589 | retry_limit->header.len = | |
9b930eae | 590 | cpu_to_le16(sizeof(struct host_cmd_tlv_retry_limit) - |
6b21a69f | 591 | sizeof(struct mwifiex_ie_types_header)); |
9b930eae AP |
592 | retry_limit->limit = (u8)bss_cfg->retry_limit; |
593 | cmd_size += sizeof(struct host_cmd_tlv_retry_limit); | |
594 | tlv += sizeof(struct host_cmd_tlv_retry_limit); | |
595 | } | |
f752dcd5 AP |
596 | if ((bss_cfg->protocol & PROTOCOL_WPA) || |
597 | (bss_cfg->protocol & PROTOCOL_WPA2) || | |
5d66cb62 AP |
598 | (bss_cfg->protocol & PROTOCOL_EAP)) |
599 | mwifiex_uap_bss_wpa(&tlv, cmd_buf, &cmd_size); | |
96893538 AP |
600 | else |
601 | mwifiex_uap_bss_wep(&tlv, cmd_buf, &cmd_size); | |
f752dcd5 | 602 | |
f752dcd5 AP |
603 | if ((bss_cfg->auth_mode <= WLAN_AUTH_SHARED_KEY) || |
604 | (bss_cfg->auth_mode == MWIFIEX_AUTH_MODE_AUTO)) { | |
605 | auth_type = (struct host_cmd_tlv_auth_type *)tlv; | |
6b21a69f AK |
606 | auth_type->header.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE); |
607 | auth_type->header.len = | |
f752dcd5 | 608 | cpu_to_le16(sizeof(struct host_cmd_tlv_auth_type) - |
6b21a69f | 609 | sizeof(struct mwifiex_ie_types_header)); |
f752dcd5 AP |
610 | auth_type->auth_type = (u8)bss_cfg->auth_mode; |
611 | cmd_size += sizeof(struct host_cmd_tlv_auth_type); | |
612 | tlv += sizeof(struct host_cmd_tlv_auth_type); | |
613 | } | |
614 | if (bss_cfg->protocol) { | |
615 | encrypt_protocol = (struct host_cmd_tlv_encrypt_protocol *)tlv; | |
6b21a69f | 616 | encrypt_protocol->header.type = |
f752dcd5 | 617 | cpu_to_le16(TLV_TYPE_UAP_ENCRY_PROTOCOL); |
6b21a69f | 618 | encrypt_protocol->header.len = |
f752dcd5 | 619 | cpu_to_le16(sizeof(struct host_cmd_tlv_encrypt_protocol) |
6b21a69f | 620 | - sizeof(struct mwifiex_ie_types_header)); |
f752dcd5 AP |
621 | encrypt_protocol->proto = cpu_to_le16(bss_cfg->protocol); |
622 | cmd_size += sizeof(struct host_cmd_tlv_encrypt_protocol); | |
623 | tlv += sizeof(struct host_cmd_tlv_encrypt_protocol); | |
624 | } | |
4db16a18 | 625 | |
22281256 AP |
626 | if (bss_cfg->ht_cap.cap_info) { |
627 | htcap = (struct mwifiex_ie_types_htcap *)tlv; | |
628 | htcap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); | |
629 | htcap->header.len = | |
630 | cpu_to_le16(sizeof(struct ieee80211_ht_cap)); | |
631 | htcap->ht_cap.cap_info = bss_cfg->ht_cap.cap_info; | |
632 | htcap->ht_cap.ampdu_params_info = | |
633 | bss_cfg->ht_cap.ampdu_params_info; | |
634 | memcpy(&htcap->ht_cap.mcs, &bss_cfg->ht_cap.mcs, | |
635 | sizeof(struct ieee80211_mcs_info)); | |
636 | htcap->ht_cap.extended_ht_cap_info = | |
637 | bss_cfg->ht_cap.extended_ht_cap_info; | |
638 | htcap->ht_cap.tx_BF_cap_info = bss_cfg->ht_cap.tx_BF_cap_info; | |
639 | htcap->ht_cap.antenna_selection_info = | |
640 | bss_cfg->ht_cap.antenna_selection_info; | |
641 | cmd_size += sizeof(struct mwifiex_ie_types_htcap); | |
642 | tlv += sizeof(struct mwifiex_ie_types_htcap); | |
643 | } | |
644 | ||
54428c57 AP |
645 | if (bss_cfg->wmm_info.qos_info != 0xFF) { |
646 | wmm_cap = (struct mwifiex_ie_types_wmmcap *)tlv; | |
647 | wmm_cap->header.type = cpu_to_le16(WLAN_EID_VENDOR_SPECIFIC); | |
648 | wmm_cap->header.len = cpu_to_le16(sizeof(wmm_cap->wmm_info)); | |
649 | memcpy(&wmm_cap->wmm_info, &bss_cfg->wmm_info, | |
650 | sizeof(wmm_cap->wmm_info)); | |
651 | cmd_size += sizeof(struct mwifiex_ie_types_wmmcap); | |
652 | tlv += sizeof(struct mwifiex_ie_types_wmmcap); | |
653 | } | |
654 | ||
8b4509f6 KG |
655 | if (bss_cfg->sta_ao_timer) { |
656 | ao_timer = (struct host_cmd_tlv_ageout_timer *)tlv; | |
6b21a69f AK |
657 | ao_timer->header.type = cpu_to_le16(TLV_TYPE_UAP_AO_TIMER); |
658 | ao_timer->header.len = cpu_to_le16(sizeof(*ao_timer) - | |
659 | sizeof(struct mwifiex_ie_types_header)); | |
8b4509f6 KG |
660 | ao_timer->sta_ao_timer = cpu_to_le32(bss_cfg->sta_ao_timer); |
661 | cmd_size += sizeof(*ao_timer); | |
662 | tlv += sizeof(*ao_timer); | |
663 | } | |
664 | ||
8a73dd63 AP |
665 | if (bss_cfg->power_constraint) { |
666 | pwr_ct = (void *)tlv; | |
667 | pwr_ct->header.type = cpu_to_le16(TLV_TYPE_PWR_CONSTRAINT); | |
668 | pwr_ct->header.len = cpu_to_le16(sizeof(u8)); | |
669 | pwr_ct->constraint = bss_cfg->power_constraint; | |
670 | cmd_size += sizeof(*pwr_ct); | |
671 | tlv += sizeof(*pwr_ct); | |
672 | } | |
673 | ||
8b4509f6 KG |
674 | if (bss_cfg->ps_sta_ao_timer) { |
675 | ps_ao_timer = (struct host_cmd_tlv_ageout_timer *)tlv; | |
6b21a69f AK |
676 | ps_ao_timer->header.type = |
677 | cpu_to_le16(TLV_TYPE_UAP_PS_AO_TIMER); | |
678 | ps_ao_timer->header.len = cpu_to_le16(sizeof(*ps_ao_timer) - | |
679 | sizeof(struct mwifiex_ie_types_header)); | |
8b4509f6 KG |
680 | ps_ao_timer->sta_ao_timer = |
681 | cpu_to_le32(bss_cfg->ps_sta_ao_timer); | |
682 | cmd_size += sizeof(*ps_ao_timer); | |
683 | tlv += sizeof(*ps_ao_timer); | |
684 | } | |
685 | ||
e76268da AP |
686 | *param_size = cmd_size; |
687 | ||
688 | return 0; | |
689 | } | |
690 | ||
ede98bfa AP |
691 | /* This function parses custom IEs from IE list and prepares command buffer */ |
692 | static int mwifiex_uap_custom_ie_prepare(u8 *tlv, void *cmd_buf, u16 *ie_size) | |
693 | { | |
694 | struct mwifiex_ie_list *ap_ie = cmd_buf; | |
6b21a69f | 695 | struct mwifiex_ie_types_header *tlv_ie = (void *)tlv; |
ede98bfa | 696 | |
00135188 | 697 | if (!ap_ie || !ap_ie->len) |
ede98bfa AP |
698 | return -1; |
699 | ||
6b21a69f AK |
700 | *ie_size += le16_to_cpu(ap_ie->len) + |
701 | sizeof(struct mwifiex_ie_types_header); | |
ede98bfa AP |
702 | |
703 | tlv_ie->type = cpu_to_le16(TLV_TYPE_MGMT_IE); | |
704 | tlv_ie->len = ap_ie->len; | |
6b21a69f | 705 | tlv += sizeof(struct mwifiex_ie_types_header); |
ede98bfa AP |
706 | |
707 | memcpy(tlv, ap_ie->ie_list, le16_to_cpu(ap_ie->len)); | |
708 | ||
709 | return 0; | |
710 | } | |
711 | ||
e76268da AP |
712 | /* Parse AP config structure and prepare TLV based command structure |
713 | * to be sent to FW for uAP configuration | |
714 | */ | |
715 | static int | |
716 | mwifiex_cmd_uap_sys_config(struct host_cmd_ds_command *cmd, u16 cmd_action, | |
717 | u32 type, void *cmd_buf) | |
718 | { | |
719 | u8 *tlv; | |
ede98bfa | 720 | u16 cmd_size, param_size, ie_size; |
e76268da AP |
721 | struct host_cmd_ds_sys_config *sys_cfg; |
722 | ||
723 | cmd->command = cpu_to_le16(HostCmd_CMD_UAP_SYS_CONFIG); | |
724 | cmd_size = (u16)(sizeof(struct host_cmd_ds_sys_config) + S_DS_GEN); | |
725 | sys_cfg = (struct host_cmd_ds_sys_config *)&cmd->params.uap_sys_config; | |
726 | sys_cfg->action = cpu_to_le16(cmd_action); | |
727 | tlv = sys_cfg->tlv; | |
728 | ||
729 | switch (type) { | |
730 | case UAP_BSS_PARAMS_I: | |
731 | param_size = cmd_size; | |
732 | if (mwifiex_uap_bss_param_prepare(tlv, cmd_buf, ¶m_size)) | |
733 | return -1; | |
734 | cmd->size = cpu_to_le16(param_size); | |
735 | break; | |
ede98bfa AP |
736 | case UAP_CUSTOM_IE_I: |
737 | ie_size = cmd_size; | |
738 | if (mwifiex_uap_custom_ie_prepare(tlv, cmd_buf, &ie_size)) | |
739 | return -1; | |
740 | cmd->size = cpu_to_le16(ie_size); | |
741 | break; | |
e76268da AP |
742 | default: |
743 | return -1; | |
744 | } | |
745 | ||
4db16a18 AP |
746 | return 0; |
747 | } | |
748 | ||
0f9e9b8b AP |
749 | /* This function prepares AP specific deauth command with mac supplied in |
750 | * function parameter. | |
751 | */ | |
752 | static int mwifiex_cmd_uap_sta_deauth(struct mwifiex_private *priv, | |
753 | struct host_cmd_ds_command *cmd, u8 *mac) | |
754 | { | |
755 | struct host_cmd_ds_sta_deauth *sta_deauth = &cmd->params.sta_deauth; | |
756 | ||
757 | cmd->command = cpu_to_le16(HostCmd_CMD_UAP_STA_DEAUTH); | |
758 | memcpy(sta_deauth->mac, mac, ETH_ALEN); | |
759 | sta_deauth->reason = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING); | |
760 | ||
761 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_sta_deauth) + | |
762 | S_DS_GEN); | |
763 | return 0; | |
764 | } | |
765 | ||
40d07030 AP |
766 | /* This function prepares the AP specific commands before sending them |
767 | * to the firmware. | |
768 | * This is a generic function which calls specific command preparation | |
769 | * routines based upon the command number. | |
770 | */ | |
771 | int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, u16 cmd_no, | |
e76268da | 772 | u16 cmd_action, u32 type, |
40d07030 AP |
773 | void *data_buf, void *cmd_buf) |
774 | { | |
775 | struct host_cmd_ds_command *cmd = cmd_buf; | |
776 | ||
777 | switch (cmd_no) { | |
4db16a18 | 778 | case HostCmd_CMD_UAP_SYS_CONFIG: |
e76268da | 779 | if (mwifiex_cmd_uap_sys_config(cmd, cmd_action, type, data_buf)) |
4db16a18 AP |
780 | return -1; |
781 | break; | |
40d07030 AP |
782 | case HostCmd_CMD_UAP_BSS_START: |
783 | case HostCmd_CMD_UAP_BSS_STOP: | |
ed5cfbe6 | 784 | case HOST_CMD_APCMD_SYS_RESET: |
b21783e9 | 785 | case HOST_CMD_APCMD_STA_LIST: |
40d07030 AP |
786 | cmd->command = cpu_to_le16(cmd_no); |
787 | cmd->size = cpu_to_le16(S_DS_GEN); | |
788 | break; | |
0f9e9b8b AP |
789 | case HostCmd_CMD_UAP_STA_DEAUTH: |
790 | if (mwifiex_cmd_uap_sta_deauth(priv, cmd, data_buf)) | |
791 | return -1; | |
792 | break; | |
85afb186 AP |
793 | case HostCmd_CMD_CHAN_REPORT_REQUEST: |
794 | if (mwifiex_cmd_issue_chan_report_request(priv, cmd_buf, | |
795 | data_buf)) | |
796 | return -1; | |
797 | break; | |
40d07030 | 798 | default: |
acebe8c1 ZL |
799 | mwifiex_dbg(priv->adapter, ERROR, |
800 | "PREP_CMD: unknown cmd %#x\n", cmd_no); | |
40d07030 AP |
801 | return -1; |
802 | } | |
803 | ||
804 | return 0; | |
805 | } | |
b654ca18 | 806 | |
7ee38bf4 XH |
807 | void mwifiex_uap_set_channel(struct mwifiex_private *priv, |
808 | struct mwifiex_uap_bss_param *bss_cfg, | |
b654ca18 AP |
809 | struct cfg80211_chan_def chandef) |
810 | { | |
65d48e59 | 811 | u8 config_bands = 0, old_bands = priv->adapter->config_bands; |
b654ca18 | 812 | |
7ee38bf4 XH |
813 | priv->bss_chandef = chandef; |
814 | ||
b654ca18 AP |
815 | bss_cfg->channel = ieee80211_frequency_to_channel( |
816 | chandef.chan->center_freq); | |
817 | ||
818 | /* Set appropriate bands */ | |
57fbcce3 | 819 | if (chandef.chan->band == NL80211_BAND_2GHZ) { |
b654ca18 AP |
820 | bss_cfg->band_cfg = BAND_CONFIG_BG; |
821 | config_bands = BAND_B | BAND_G; | |
822 | ||
823 | if (chandef.width > NL80211_CHAN_WIDTH_20_NOHT) | |
824 | config_bands |= BAND_GN; | |
825 | } else { | |
826 | bss_cfg->band_cfg = BAND_CONFIG_A; | |
827 | config_bands = BAND_A; | |
828 | ||
829 | if (chandef.width > NL80211_CHAN_WIDTH_20_NOHT) | |
830 | config_bands |= BAND_AN; | |
831 | ||
832 | if (chandef.width > NL80211_CHAN_WIDTH_40) | |
833 | config_bands |= BAND_AAC; | |
834 | } | |
39d94eaa AP |
835 | |
836 | priv->adapter->config_bands = config_bands; | |
65d48e59 AP |
837 | |
838 | if (old_bands != config_bands) { | |
839 | mwifiex_send_domain_info_cmd_fw(priv->adapter->wiphy); | |
840 | mwifiex_dnld_txpwr_table(priv); | |
841 | } | |
b654ca18 AP |
842 | } |
843 | ||
844 | int mwifiex_config_start_uap(struct mwifiex_private *priv, | |
845 | struct mwifiex_uap_bss_param *bss_cfg) | |
846 | { | |
88af6f05 AP |
847 | enum state_11d_t state_11d; |
848 | ||
b654ca18 AP |
849 | if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_SYS_CONFIG, |
850 | HostCmd_ACT_GEN_SET, | |
d2b0c735 | 851 | UAP_BSS_PARAMS_I, bss_cfg, true)) { |
acebe8c1 | 852 | mwifiex_dbg(priv->adapter, ERROR, |
d2b0c735 | 853 | "Failed to set AP configuration\n"); |
b654ca18 AP |
854 | return -1; |
855 | } | |
856 | ||
88af6f05 AP |
857 | /* Send cmd to FW to enable 11D function */ |
858 | state_11d = ENABLE_11D; | |
859 | if (mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB, | |
860 | HostCmd_ACT_GEN_SET, DOT11D_I, | |
861 | &state_11d, true)) { | |
862 | mwifiex_dbg(priv->adapter, ERROR, | |
863 | "11D: failed to enable 11D\n"); | |
864 | return -1; | |
865 | } | |
866 | ||
b654ca18 | 867 | if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_BSS_START, |
d2b0c735 | 868 | HostCmd_ACT_GEN_SET, 0, NULL, true)) { |
acebe8c1 ZL |
869 | mwifiex_dbg(priv->adapter, ERROR, |
870 | "Failed to start the BSS\n"); | |
b654ca18 AP |
871 | return -1; |
872 | } | |
873 | ||
874 | if (priv->sec_info.wep_enabled) | |
875 | priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE; | |
876 | else | |
877 | priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE; | |
878 | ||
879 | if (mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL, | |
880 | HostCmd_ACT_GEN_SET, 0, | |
881 | &priv->curr_pkt_filter, true)) | |
882 | return -1; | |
883 | ||
884 | return 0; | |
885 | } |