Merge branch 'for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/mason...
[deliverable/linux.git] / drivers / net / wireless / marvell / mwifiex / join.c
CommitLineData
5e6e3a92
BZ
1/*
2 * Marvell Wireless LAN device driver: association and ad-hoc start/join
3 *
65da33f5 4 * Copyright (C) 2011-2014, Marvell International Ltd.
5e6e3a92
BZ
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 "decl.h"
21#include "ioctl.h"
22#include "util.h"
23#include "fw.h"
24#include "main.h"
25#include "wmm.h"
26#include "11n.h"
a5f39056 27#include "11ac.h"
5e6e3a92
BZ
28
29#define CAPINFO_MASK (~(BIT(15) | BIT(14) | BIT(12) | BIT(11) | BIT(9)))
30
31/*
32 * Append a generic IE as a pass through TLV to a TLV buffer.
33 *
34 * This function is called from the network join command preparation routine.
35 *
36 * If the IE buffer has been setup by the application, this routine appends
37 * the buffer as a pass through TLV type to the request.
38 */
39static int
40mwifiex_cmd_append_generic_ie(struct mwifiex_private *priv, u8 **buffer)
41{
42 int ret_len = 0;
43 struct mwifiex_ie_types_header ie_header;
44
45 /* Null Checks */
46 if (!buffer)
47 return 0;
48 if (!(*buffer))
49 return 0;
50
51 /*
52 * If there is a generic ie buffer setup, append it to the return
53 * parameter buffer pointer.
54 */
55 if (priv->gen_ie_buf_len) {
acebe8c1
ZL
56 mwifiex_dbg(priv->adapter, INFO,
57 "info: %s: append generic ie len %d to %p\n",
58 __func__, priv->gen_ie_buf_len, *buffer);
5e6e3a92
BZ
59
60 /* Wrap the generic IE buffer with a pass through TLV type */
61 ie_header.type = cpu_to_le16(TLV_TYPE_PASSTHROUGH);
62 ie_header.len = cpu_to_le16(priv->gen_ie_buf_len);
63 memcpy(*buffer, &ie_header, sizeof(ie_header));
64
65 /* Increment the return size and the return buffer pointer
66 param */
67 *buffer += sizeof(ie_header);
68 ret_len += sizeof(ie_header);
69
70 /* Copy the generic IE buffer to the output buffer, advance
71 pointer */
72 memcpy(*buffer, priv->gen_ie_buf, priv->gen_ie_buf_len);
73
74 /* Increment the return size and the return buffer pointer
75 param */
76 *buffer += priv->gen_ie_buf_len;
77 ret_len += priv->gen_ie_buf_len;
78
79 /* Reset the generic IE buffer */
80 priv->gen_ie_buf_len = 0;
81 }
82
83 /* return the length appended to the buffer */
84 return ret_len;
85}
86
87/*
88 * Append TSF tracking info from the scan table for the target AP.
89 *
90 * This function is called from the network join command preparation routine.
91 *
92 * The TSF table TSF sent to the firmware contains two TSF values:
93 * - The TSF of the target AP from its previous beacon/probe response
94 * - The TSF timestamp of our local MAC at the time we observed the
95 * beacon/probe response.
96 *
97 * The firmware uses the timestamp values to set an initial TSF value
98 * in the MAC for the new association after a reassociation attempt.
99 */
100static int
101mwifiex_cmd_append_tsf_tlv(struct mwifiex_private *priv, u8 **buffer,
102 struct mwifiex_bssdescriptor *bss_desc)
103{
104 struct mwifiex_ie_types_tsf_timestamp tsf_tlv;
1a5b306f 105 __le64 tsf_val;
5e6e3a92
BZ
106
107 /* Null Checks */
108 if (buffer == NULL)
109 return 0;
110 if (*buffer == NULL)
111 return 0;
112
113 memset(&tsf_tlv, 0x00, sizeof(struct mwifiex_ie_types_tsf_timestamp));
114
115 tsf_tlv.header.type = cpu_to_le16(TLV_TYPE_TSFTIMESTAMP);
116 tsf_tlv.header.len = cpu_to_le16(2 * sizeof(tsf_val));
117
118 memcpy(*buffer, &tsf_tlv, sizeof(tsf_tlv.header));
119 *buffer += sizeof(tsf_tlv.header);
120
1a5b306f 121 /* TSF at the time when beacon/probe_response was received */
b5abcf02 122 tsf_val = cpu_to_le64(bss_desc->fw_tsf);
1a5b306f
BZ
123 memcpy(*buffer, &tsf_val, sizeof(tsf_val));
124 *buffer += sizeof(tsf_val);
125
b5abcf02 126 tsf_val = cpu_to_le64(bss_desc->timestamp);
5e6e3a92 127
acebe8c1
ZL
128 mwifiex_dbg(priv->adapter, INFO,
129 "info: %s: TSF offset calc: %016llx - %016llx\n",
130 __func__, bss_desc->timestamp, bss_desc->fw_tsf);
5e6e3a92
BZ
131
132 memcpy(*buffer, &tsf_val, sizeof(tsf_val));
133 *buffer += sizeof(tsf_val);
134
135 return sizeof(tsf_tlv.header) + (2 * sizeof(tsf_val));
136}
137
138/*
139 * This function finds out the common rates between rate1 and rate2.
140 *
141 * It will fill common rates in rate1 as output if found.
142 *
143 * NOTE: Setting the MSB of the basic rates needs to be taken
144 * care of, either before or after calling this function.
145 */
146static int mwifiex_get_common_rates(struct mwifiex_private *priv, u8 *rate1,
147 u32 rate1_size, u8 *rate2, u32 rate2_size)
148{
270e58e8
YAP
149 int ret;
150 u8 *ptr = rate1, *tmp;
5e6e3a92
BZ
151 u32 i, j;
152
5982b47a 153 tmp = kmemdup(rate1, rate1_size, GFP_KERNEL);
5e6e3a92 154 if (!tmp) {
acebe8c1 155 mwifiex_dbg(priv->adapter, ERROR, "failed to alloc tmp buf\n");
5e6e3a92
BZ
156 return -ENOMEM;
157 }
158
5e6e3a92
BZ
159 memset(rate1, 0, rate1_size);
160
485f107d
CR
161 for (i = 0; i < rate2_size && rate2[i]; i++) {
162 for (j = 0; j < rate1_size && tmp[j]; j++) {
5e6e3a92
BZ
163 /* Check common rate, excluding the bit for
164 basic rate */
165 if ((rate2[i] & 0x7F) == (tmp[j] & 0x7F)) {
166 *rate1++ = tmp[j];
167 break;
168 }
169 }
170 }
171
acebe8c1
ZL
172 mwifiex_dbg(priv->adapter, INFO, "info: Tx data rate set to %#x\n",
173 priv->data_rate);
5e6e3a92
BZ
174
175 if (!priv->is_data_rate_auto) {
176 while (*ptr) {
177 if ((*ptr & 0x7f) == priv->data_rate) {
178 ret = 0;
179 goto done;
180 }
181 ptr++;
182 }
acebe8c1
ZL
183 mwifiex_dbg(priv->adapter, ERROR,
184 "previously set fixed data rate %#x\t"
185 "is not compatible with the network\n",
186 priv->data_rate);
5e6e3a92
BZ
187
188 ret = -1;
189 goto done;
190 }
191
192 ret = 0;
193done:
194 kfree(tmp);
195 return ret;
196}
197
198/*
199 * This function creates the intersection of the rates supported by a
200 * target BSS and our adapter settings for use in an assoc/join command.
201 */
202static int
203mwifiex_setup_rates_from_bssdesc(struct mwifiex_private *priv,
204 struct mwifiex_bssdescriptor *bss_desc,
205 u8 *out_rates, u32 *out_rates_size)
206{
207 u8 card_rates[MWIFIEX_SUPPORTED_RATES];
270e58e8 208 u32 card_rates_size;
5e6e3a92
BZ
209
210 /* Copy AP supported rates */
211 memcpy(out_rates, bss_desc->supported_rates, MWIFIEX_SUPPORTED_RATES);
212 /* Get the STA supported rates */
213 card_rates_size = mwifiex_get_active_data_rates(priv, card_rates);
214 /* Get the common rates between AP and STA supported rates */
215 if (mwifiex_get_common_rates(priv, out_rates, MWIFIEX_SUPPORTED_RATES,
216 card_rates, card_rates_size)) {
217 *out_rates_size = 0;
acebe8c1
ZL
218 mwifiex_dbg(priv->adapter, ERROR,
219 "%s: cannot get common rates\n",
220 __func__);
5e6e3a92
BZ
221 return -1;
222 }
223
224 *out_rates_size =
225 min_t(size_t, strlen(out_rates), MWIFIEX_SUPPORTED_RATES);
226
227 return 0;
228}
229
13d7ba78
AP
230/*
231 * This function appends a WPS IE. It is called from the network join command
232 * preparation routine.
233 *
234 * If the IE buffer has been setup by the application, this routine appends
235 * the buffer as a WPS TLV type to the request.
236 */
237static int
238mwifiex_cmd_append_wps_ie(struct mwifiex_private *priv, u8 **buffer)
239{
240 int retLen = 0;
241 struct mwifiex_ie_types_header ie_header;
242
243 if (!buffer || !*buffer)
244 return 0;
245
246 /*
247 * If there is a wps ie buffer setup, append it to the return
248 * parameter buffer pointer.
249 */
250 if (priv->wps_ie_len) {
acebe8c1
ZL
251 mwifiex_dbg(priv->adapter, CMD,
252 "cmd: append wps ie %d to %p\n",
253 priv->wps_ie_len, *buffer);
13d7ba78
AP
254
255 /* Wrap the generic IE buffer with a pass through TLV type */
256 ie_header.type = cpu_to_le16(TLV_TYPE_MGMT_IE);
257 ie_header.len = cpu_to_le16(priv->wps_ie_len);
258 memcpy(*buffer, &ie_header, sizeof(ie_header));
259 *buffer += sizeof(ie_header);
260 retLen += sizeof(ie_header);
261
262 memcpy(*buffer, priv->wps_ie, priv->wps_ie_len);
263 *buffer += priv->wps_ie_len;
264 retLen += priv->wps_ie_len;
265
266 }
267
268 kfree(priv->wps_ie);
269 priv->wps_ie_len = 0;
270 return retLen;
271}
272
5e6e3a92
BZ
273/*
274 * This function appends a WAPI IE.
275 *
276 * This function is called from the network join command preparation routine.
277 *
278 * If the IE buffer has been setup by the application, this routine appends
279 * the buffer as a WAPI TLV type to the request.
280 */
281static int
282mwifiex_cmd_append_wapi_ie(struct mwifiex_private *priv, u8 **buffer)
283{
284 int retLen = 0;
285 struct mwifiex_ie_types_header ie_header;
286
287 /* Null Checks */
288 if (buffer == NULL)
289 return 0;
290 if (*buffer == NULL)
291 return 0;
292
293 /*
294 * If there is a wapi ie buffer setup, append it to the return
295 * parameter buffer pointer.
296 */
297 if (priv->wapi_ie_len) {
acebe8c1
ZL
298 mwifiex_dbg(priv->adapter, CMD,
299 "cmd: append wapi ie %d to %p\n",
300 priv->wapi_ie_len, *buffer);
5e6e3a92
BZ
301
302 /* Wrap the generic IE buffer with a pass through TLV type */
303 ie_header.type = cpu_to_le16(TLV_TYPE_WAPI_IE);
304 ie_header.len = cpu_to_le16(priv->wapi_ie_len);
305 memcpy(*buffer, &ie_header, sizeof(ie_header));
306
307 /* Increment the return size and the return buffer pointer
308 param */
309 *buffer += sizeof(ie_header);
310 retLen += sizeof(ie_header);
311
312 /* Copy the wapi IE buffer to the output buffer, advance
313 pointer */
314 memcpy(*buffer, priv->wapi_ie, priv->wapi_ie_len);
315
316 /* Increment the return size and the return buffer pointer
317 param */
318 *buffer += priv->wapi_ie_len;
319 retLen += priv->wapi_ie_len;
320
321 }
322 /* return the length appended to the buffer */
323 return retLen;
324}
325
326/*
327 * This function appends rsn ie tlv for wpa/wpa2 security modes.
328 * It is called from the network join command preparation routine.
329 */
330static int mwifiex_append_rsn_ie_wpa_wpa2(struct mwifiex_private *priv,
331 u8 **buffer)
332{
333 struct mwifiex_ie_types_rsn_param_set *rsn_ie_tlv;
334 int rsn_ie_len;
335
336 if (!buffer || !(*buffer))
337 return 0;
338
339 rsn_ie_tlv = (struct mwifiex_ie_types_rsn_param_set *) (*buffer);
340 rsn_ie_tlv->header.type = cpu_to_le16((u16) priv->wpa_ie[0]);
341 rsn_ie_tlv->header.type = cpu_to_le16(
342 le16_to_cpu(rsn_ie_tlv->header.type) & 0x00FF);
343 rsn_ie_tlv->header.len = cpu_to_le16((u16) priv->wpa_ie[1]);
344 rsn_ie_tlv->header.len = cpu_to_le16(le16_to_cpu(rsn_ie_tlv->header.len)
931f1584 345 & 0x00FF);
5e6e3a92
BZ
346 if (le16_to_cpu(rsn_ie_tlv->header.len) <= (sizeof(priv->wpa_ie) - 2))
347 memcpy(rsn_ie_tlv->rsn_ie, &priv->wpa_ie[2],
931f1584 348 le16_to_cpu(rsn_ie_tlv->header.len));
5e6e3a92
BZ
349 else
350 return -1;
351
352 rsn_ie_len = sizeof(rsn_ie_tlv->header) +
353 le16_to_cpu(rsn_ie_tlv->header.len);
354 *buffer += rsn_ie_len;
355
356 return rsn_ie_len;
357}
358
359/*
360 * This function prepares command for association.
361 *
362 * This sets the following parameters -
363 * - Peer MAC address
364 * - Listen interval
365 * - Beacon interval
366 * - Capability information
367 *
368 * ...and the following TLVs, as required -
369 * - SSID TLV
370 * - PHY TLV
371 * - SS TLV
372 * - Rates TLV
373 * - Authentication TLV
374 * - Channel TLV
375 * - WPA/WPA2 IE
376 * - 11n TLV
377 * - Vendor specific TLV
378 * - WMM TLV
379 * - WAPI IE
380 * - Generic IE
381 * - TSF TLV
382 *
383 * Preparation also includes -
384 * - Setting command ID and proper size
385 * - Ensuring correct endian-ness
386 */
387int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
388 struct host_cmd_ds_command *cmd,
a5ffddb7 389 struct mwifiex_bssdescriptor *bss_desc)
5e6e3a92
BZ
390{
391 struct host_cmd_ds_802_11_associate *assoc = &cmd->params.associate;
5e6e3a92
BZ
392 struct mwifiex_ie_types_ssid_param_set *ssid_tlv;
393 struct mwifiex_ie_types_phy_param_set *phy_tlv;
394 struct mwifiex_ie_types_ss_param_set *ss_tlv;
395 struct mwifiex_ie_types_rates_param_set *rates_tlv;
396 struct mwifiex_ie_types_auth_type *auth_tlv;
397 struct mwifiex_ie_types_chan_list_param_set *chan_tlv;
398 u8 rates[MWIFIEX_SUPPORTED_RATES];
399 u32 rates_size;
400 u16 tmp_cap;
401 u8 *pos;
402 int rsn_ie_len = 0;
403
5e6e3a92
BZ
404 pos = (u8 *) assoc;
405
5e6e3a92
BZ
406 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_ASSOCIATE);
407
408 /* Save so we know which BSS Desc to use in the response handler */
409 priv->attempted_bss_desc = bss_desc;
410
411 memcpy(assoc->peer_sta_addr,
412 bss_desc->mac_address, sizeof(assoc->peer_sta_addr));
413 pos += sizeof(assoc->peer_sta_addr);
414
415 /* Set the listen interval */
416 assoc->listen_interval = cpu_to_le16(priv->listen_interval);
417 /* Set the beacon period */
418 assoc->beacon_period = cpu_to_le16(bss_desc->beacon_period);
419
420 pos += sizeof(assoc->cap_info_bitmap);
421 pos += sizeof(assoc->listen_interval);
422 pos += sizeof(assoc->beacon_period);
423 pos += sizeof(assoc->dtim_period);
424
425 ssid_tlv = (struct mwifiex_ie_types_ssid_param_set *) pos;
426 ssid_tlv->header.type = cpu_to_le16(WLAN_EID_SSID);
427 ssid_tlv->header.len = cpu_to_le16((u16) bss_desc->ssid.ssid_len);
428 memcpy(ssid_tlv->ssid, bss_desc->ssid.ssid,
931f1584 429 le16_to_cpu(ssid_tlv->header.len));
5e6e3a92
BZ
430 pos += sizeof(ssid_tlv->header) + le16_to_cpu(ssid_tlv->header.len);
431
432 phy_tlv = (struct mwifiex_ie_types_phy_param_set *) pos;
433 phy_tlv->header.type = cpu_to_le16(WLAN_EID_DS_PARAMS);
434 phy_tlv->header.len = cpu_to_le16(sizeof(phy_tlv->fh_ds.ds_param_set));
435 memcpy(&phy_tlv->fh_ds.ds_param_set,
436 &bss_desc->phy_param_set.ds_param_set.current_chan,
437 sizeof(phy_tlv->fh_ds.ds_param_set));
438 pos += sizeof(phy_tlv->header) + le16_to_cpu(phy_tlv->header.len);
439
440 ss_tlv = (struct mwifiex_ie_types_ss_param_set *) pos;
441 ss_tlv->header.type = cpu_to_le16(WLAN_EID_CF_PARAMS);
442 ss_tlv->header.len = cpu_to_le16(sizeof(ss_tlv->cf_ibss.cf_param_set));
443 pos += sizeof(ss_tlv->header) + le16_to_cpu(ss_tlv->header.len);
444
445 /* Get the common rates supported between the driver and the BSS Desc */
446 if (mwifiex_setup_rates_from_bssdesc
447 (priv, bss_desc, rates, &rates_size))
448 return -1;
449
450 /* Save the data rates into Current BSS state structure */
451 priv->curr_bss_params.num_of_rates = rates_size;
452 memcpy(&priv->curr_bss_params.data_rates, rates, rates_size);
453
454 /* Setup the Rates TLV in the association command */
455 rates_tlv = (struct mwifiex_ie_types_rates_param_set *) pos;
456 rates_tlv->header.type = cpu_to_le16(WLAN_EID_SUPP_RATES);
457 rates_tlv->header.len = cpu_to_le16((u16) rates_size);
458 memcpy(rates_tlv->rates, rates, rates_size);
459 pos += sizeof(rates_tlv->header) + rates_size;
acebe8c1
ZL
460 mwifiex_dbg(priv->adapter, INFO, "info: ASSOC_CMD: rates size = %d\n",
461 rates_size);
5e6e3a92 462
203afeca
MY
463 /* Add the Authentication type to be used for Auth frames */
464 auth_tlv = (struct mwifiex_ie_types_auth_type *) pos;
465 auth_tlv->header.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE);
466 auth_tlv->header.len = cpu_to_le16(sizeof(auth_tlv->auth_type));
5eb02e44 467 if (priv->sec_info.wep_enabled)
203afeca
MY
468 auth_tlv->auth_type = cpu_to_le16(
469 (u16) priv->sec_info.authentication_mode);
470 else
f986b6d5 471 auth_tlv->auth_type = cpu_to_le16(NL80211_AUTHTYPE_OPEN_SYSTEM);
203afeca
MY
472
473 pos += sizeof(auth_tlv->header) + le16_to_cpu(auth_tlv->header.len);
5e6e3a92 474
931f1584
YAP
475 if (IS_SUPPORT_MULTI_BANDS(priv->adapter) &&
476 !(ISSUPP_11NENABLED(priv->adapter->fw_cap_info) &&
477 (!bss_desc->disable_11n) &&
478 (priv->adapter->config_bands & BAND_GN ||
479 priv->adapter->config_bands & BAND_AN) &&
480 (bss_desc->bcn_ht_cap)
5e6e3a92
BZ
481 )
482 ) {
483 /* Append a channel TLV for the channel the attempted AP was
484 found on */
485 chan_tlv = (struct mwifiex_ie_types_chan_list_param_set *) pos;
486 chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
487 chan_tlv->header.len =
488 cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set));
489
490 memset(chan_tlv->chan_scan_param, 0x00,
491 sizeof(struct mwifiex_chan_scan_param_set));
492 chan_tlv->chan_scan_param[0].chan_number =
493 (bss_desc->phy_param_set.ds_param_set.current_chan);
acebe8c1
ZL
494 mwifiex_dbg(priv->adapter, INFO, "info: Assoc: TLV Chan = %d\n",
495 chan_tlv->chan_scan_param[0].chan_number);
5e6e3a92
BZ
496
497 chan_tlv->chan_scan_param[0].radio_type =
498 mwifiex_band_to_radio_type((u8) bss_desc->bss_band);
499
acebe8c1
ZL
500 mwifiex_dbg(priv->adapter, INFO, "info: Assoc: TLV Band = %d\n",
501 chan_tlv->chan_scan_param[0].radio_type);
5e6e3a92
BZ
502 pos += sizeof(chan_tlv->header) +
503 sizeof(struct mwifiex_chan_scan_param_set);
504 }
505
506 if (!priv->wps.session_enable) {
507 if (priv->sec_info.wpa_enabled || priv->sec_info.wpa2_enabled)
508 rsn_ie_len = mwifiex_append_rsn_ie_wpa_wpa2(priv, &pos);
509
510 if (rsn_ie_len == -1)
511 return -1;
512 }
513
931f1584
YAP
514 if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) &&
515 (!bss_desc->disable_11n) &&
516 (priv->adapter->config_bands & BAND_GN ||
517 priv->adapter->config_bands & BAND_AN))
5e6e3a92
BZ
518 mwifiex_cmd_append_11n_tlv(priv, bss_desc, &pos);
519
a5f39056
YAP
520 if (ISSUPP_11ACENABLED(priv->adapter->fw_cap_info) &&
521 !bss_desc->disable_11n && !bss_desc->disable_11ac &&
f25b1431 522 priv->adapter->config_bands & BAND_AAC)
a5f39056
YAP
523 mwifiex_cmd_append_11ac_tlv(priv, bss_desc, &pos);
524
5e6e3a92
BZ
525 /* Append vendor specific IE TLV */
526 mwifiex_cmd_append_vsie_tlv(priv, MWIFIEX_VSIE_MASK_ASSOC, &pos);
527
528 mwifiex_wmm_process_association_req(priv, &pos, &bss_desc->wmm_ie,
529 bss_desc->bcn_ht_cap);
530 if (priv->sec_info.wapi_enabled && priv->wapi_ie_len)
531 mwifiex_cmd_append_wapi_ie(priv, &pos);
532
13d7ba78
AP
533 if (priv->wps.session_enable && priv->wps_ie_len)
534 mwifiex_cmd_append_wps_ie(priv, &pos);
5e6e3a92
BZ
535
536 mwifiex_cmd_append_generic_ie(priv, &pos);
537
538 mwifiex_cmd_append_tsf_tlv(priv, &pos, bss_desc);
539
2a7305c8
AK
540 mwifiex_11h_process_join(priv, &pos, bss_desc);
541
5e6e3a92
BZ
542 cmd->size = cpu_to_le16((u16) (pos - (u8 *) assoc) + S_DS_GEN);
543
544 /* Set the Capability info at last */
545 tmp_cap = bss_desc->cap_info_bitmap;
546
547 if (priv->adapter->config_bands == BAND_B)
b93f85f0 548 tmp_cap &= ~WLAN_CAPABILITY_SHORT_SLOT_TIME;
5e6e3a92
BZ
549
550 tmp_cap &= CAPINFO_MASK;
acebe8c1
ZL
551 mwifiex_dbg(priv->adapter, INFO,
552 "info: ASSOC_CMD: tmp_cap=%4X CAPINFO_MASK=%4lX\n",
553 tmp_cap, CAPINFO_MASK);
5e6e3a92
BZ
554 assoc->cap_info_bitmap = cpu_to_le16(tmp_cap);
555
556 return 0;
557}
558
12d11109
AP
559static const char *assoc_failure_reason_to_str(u16 cap_info)
560{
561 switch (cap_info) {
562 case CONNECT_ERR_AUTH_ERR_STA_FAILURE:
563 return "CONNECT_ERR_AUTH_ERR_STA_FAILURE";
564 case CONNECT_ERR_AUTH_MSG_UNHANDLED:
565 return "CONNECT_ERR_AUTH_MSG_UNHANDLED";
566 case CONNECT_ERR_ASSOC_ERR_TIMEOUT:
567 return "CONNECT_ERR_ASSOC_ERR_TIMEOUT";
568 case CONNECT_ERR_ASSOC_ERR_AUTH_REFUSED:
569 return "CONNECT_ERR_ASSOC_ERR_AUTH_REFUSED";
570 case CONNECT_ERR_STA_FAILURE:
571 return "CONNECT_ERR_STA_FAILURE";
572 }
573
574 return "Unknown connect failure";
575}
5e6e3a92
BZ
576/*
577 * Association firmware command response handler
578 *
579 * The response buffer for the association command has the following
580 * memory layout.
581 *
582 * For cases where an association response was not received (indicated
583 * by the CapInfo and AId field):
584 *
585 * .------------------------------------------------------------.
586 * | Header(4 * sizeof(t_u16)): Standard command response hdr |
587 * .------------------------------------------------------------.
588 * | cap_info/Error Return(t_u16): |
589 * | 0xFFFF(-1): Internal error |
590 * | 0xFFFE(-2): Authentication unhandled message |
591 * | 0xFFFD(-3): Authentication refused |
592 * | 0xFFFC(-4): Timeout waiting for AP response |
593 * .------------------------------------------------------------.
594 * | status_code(t_u16): |
595 * | If cap_info is -1: |
596 * | An internal firmware failure prevented the |
597 * | command from being processed. The status_code |
598 * | will be set to 1. |
599 * | |
600 * | If cap_info is -2: |
601 * | An authentication frame was received but was |
602 * | not handled by the firmware. IEEE Status |
603 * | code for the failure is returned. |
604 * | |
605 * | If cap_info is -3: |
606 * | An authentication frame was received and the |
607 * | status_code is the IEEE Status reported in the |
608 * | response. |
609 * | |
610 * | If cap_info is -4: |
611 * | (1) Association response timeout |
612 * | (2) Authentication response timeout |
613 * .------------------------------------------------------------.
614 * | a_id(t_u16): 0xFFFF |
615 * .------------------------------------------------------------.
616 *
617 *
618 * For cases where an association response was received, the IEEE
619 * standard association response frame is returned:
620 *
621 * .------------------------------------------------------------.
622 * | Header(4 * sizeof(t_u16)): Standard command response hdr |
623 * .------------------------------------------------------------.
624 * | cap_info(t_u16): IEEE Capability |
625 * .------------------------------------------------------------.
626 * | status_code(t_u16): IEEE Status Code |
627 * .------------------------------------------------------------.
628 * | a_id(t_u16): IEEE Association ID |
629 * .------------------------------------------------------------.
630 * | IEEE IEs(variable): Any received IEs comprising the |
631 * | remaining portion of a received |
632 * | association response frame. |
633 * .------------------------------------------------------------.
634 *
635 * For simplistic handling, the status_code field can be used to determine
636 * an association success (0) or failure (non-zero).
637 */
638int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
600f5d90 639 struct host_cmd_ds_command *resp)
5e6e3a92 640{
600f5d90 641 struct mwifiex_adapter *adapter = priv->adapter;
5e6e3a92 642 int ret = 0;
5e6e3a92
BZ
643 struct ieee_types_assoc_rsp *assoc_rsp;
644 struct mwifiex_bssdescriptor *bss_desc;
c856197d 645 bool enable_data = true;
4aff53ef 646 u16 cap_info, status_code, aid;
5e6e3a92
BZ
647
648 assoc_rsp = (struct ieee_types_assoc_rsp *) &resp->params;
649
7532c7d0
AK
650 cap_info = le16_to_cpu(assoc_rsp->cap_info_bitmap);
651 status_code = le16_to_cpu(assoc_rsp->status_code);
4aff53ef
XH
652 aid = le16_to_cpu(assoc_rsp->a_id);
653
654 if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14)))
655 dev_err(priv->adapter->dev,
656 "invalid AID value 0x%x; bits 15:14 not set\n",
657 aid);
658
659 aid &= ~(BIT(15) | BIT(14));
7532c7d0 660
5e6e3a92 661 priv->assoc_rsp_size = min(le16_to_cpu(resp->size) - S_DS_GEN,
931f1584 662 sizeof(priv->assoc_rsp_buf));
5e6e3a92
BZ
663
664 memcpy(priv->assoc_rsp_buf, &resp->params, priv->assoc_rsp_size);
665
4aff53ef
XH
666 assoc_rsp->a_id = cpu_to_le16(aid);
667
7532c7d0 668 if (status_code) {
5e6e3a92 669 priv->adapter->dbg.num_cmd_assoc_failure++;
acebe8c1
ZL
670 mwifiex_dbg(priv->adapter, ERROR,
671 "ASSOC_RESP: failed,\t"
672 "status code=%d err=%#x a_id=%#x\n",
673 status_code, cap_info,
674 le16_to_cpu(assoc_rsp->a_id));
7532c7d0 675
12d11109
AP
676 mwifiex_dbg(priv->adapter, ERROR, "assoc failure: reason %s\n",
677 assoc_failure_reason_to_str(cap_info));
678 if (cap_info == CONNECT_ERR_ASSOC_ERR_TIMEOUT) {
679 if (status_code == MWIFIEX_ASSOC_CMD_FAILURE_AUTH) {
7532c7d0 680 ret = WLAN_STATUS_AUTH_TIMEOUT;
12d11109
AP
681 mwifiex_dbg(priv->adapter, ERROR,
682 "ASSOC_RESP: AUTH timeout\n");
683 } else {
7532c7d0 684 ret = WLAN_STATUS_UNSPECIFIED_FAILURE;
12d11109
AP
685 mwifiex_dbg(priv->adapter, ERROR,
686 "ASSOC_RESP: UNSPECIFIED failure\n");
687 }
7532c7d0
AK
688 } else {
689 ret = status_code;
690 }
5e6e3a92 691
5e6e3a92
BZ
692 goto done;
693 }
694
695 /* Send a Media Connected event, according to the Spec */
696 priv->media_connected = true;
697
698 priv->adapter->ps_state = PS_STATE_AWAKE;
699 priv->adapter->pps_uapsd_mode = false;
700 priv->adapter->tx_lock_flag = false;
701
702 /* Set the attempted BSSID Index to current */
703 bss_desc = priv->attempted_bss_desc;
704
acebe8c1
ZL
705 mwifiex_dbg(priv->adapter, INFO, "info: ASSOC_RESP: %s\n",
706 bss_desc->ssid.ssid);
5e6e3a92
BZ
707
708 /* Make a copy of current BSSID descriptor */
709 memcpy(&priv->curr_bss_params.bss_descriptor,
710 bss_desc, sizeof(struct mwifiex_bssdescriptor));
711
712 /* Update curr_bss_params */
713 priv->curr_bss_params.bss_descriptor.channel
714 = bss_desc->phy_param_set.ds_param_set.current_chan;
715
716 priv->curr_bss_params.band = (u8) bss_desc->bss_band;
717
5e6e3a92
BZ
718 if (bss_desc->wmm_ie.vend_hdr.element_id == WLAN_EID_VENDOR_SPECIFIC)
719 priv->curr_bss_params.wmm_enabled = true;
720 else
721 priv->curr_bss_params.wmm_enabled = false;
722
931f1584
YAP
723 if ((priv->wmm_required || bss_desc->bcn_ht_cap) &&
724 priv->curr_bss_params.wmm_enabled)
5e6e3a92
BZ
725 priv->wmm_enabled = true;
726 else
727 priv->wmm_enabled = false;
728
729 priv->curr_bss_params.wmm_uapsd_enabled = false;
730
731 if (priv->wmm_enabled)
732 priv->curr_bss_params.wmm_uapsd_enabled
733 = ((bss_desc->wmm_ie.qos_info_bitmap &
734 IEEE80211_WMM_IE_AP_QOSINFO_UAPSD) ? 1 : 0);
735
acebe8c1
ZL
736 mwifiex_dbg(priv->adapter, INFO,
737 "info: ASSOC_RESP: curr_pkt_filter is %#x\n",
738 priv->curr_pkt_filter);
5e6e3a92
BZ
739 if (priv->sec_info.wpa_enabled || priv->sec_info.wpa2_enabled)
740 priv->wpa_is_gtk_set = false;
741
742 if (priv->wmm_enabled) {
743 /* Don't re-enable carrier until we get the WMM_GET_STATUS
744 event */
745 enable_data = false;
746 } else {
747 /* Since WMM is not enabled, setup the queues with the
748 defaults */
749 mwifiex_wmm_setup_queue_priorities(priv, NULL);
750 mwifiex_wmm_setup_ac_downgrade(priv);
751 }
752
753 if (enable_data)
acebe8c1
ZL
754 mwifiex_dbg(priv->adapter, INFO,
755 "info: post association, re-enabling data flow\n");
5e6e3a92
BZ
756
757 /* Reset SNR/NF/RSSI values */
758 priv->data_rssi_last = 0;
759 priv->data_nf_last = 0;
760 priv->data_rssi_avg = 0;
761 priv->data_nf_avg = 0;
762 priv->bcn_rssi_last = 0;
763 priv->bcn_nf_last = 0;
764 priv->bcn_rssi_avg = 0;
765 priv->bcn_nf_avg = 0;
766 priv->rxpd_rate = 0;
767 priv->rxpd_htinfo = 0;
768
769 mwifiex_save_curr_bcn(priv);
770
771 priv->adapter->dbg.num_cmd_assoc_success++;
772
acebe8c1 773 mwifiex_dbg(priv->adapter, INFO, "info: ASSOC_RESP: associated\n");
5e6e3a92
BZ
774
775 /* Add the ra_list here for infra mode as there will be only 1 ra
776 always */
777 mwifiex_ralist_add(priv,
778 priv->curr_bss_params.bss_descriptor.mac_address);
779
780 if (!netif_carrier_ok(priv->netdev))
781 netif_carrier_on(priv->netdev);
47411a06 782 mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
5e6e3a92
BZ
783
784 if (priv->sec_info.wpa_enabled || priv->sec_info.wpa2_enabled)
785 priv->scan_block = true;
5c894633
AP
786 else
787 priv->port_open = true;
5e6e3a92
BZ
788
789done:
790 /* Need to indicate IOCTL complete */
600f5d90
AK
791 if (adapter->curr_cmd->wait_q_enabled) {
792 if (ret)
793 adapter->cmd_wait_q.status = -1;
794 else
795 adapter->cmd_wait_q.status = 0;
5e6e3a92
BZ
796 }
797
798 return ret;
799}
800
801/*
802 * This function prepares command for ad-hoc start.
803 *
804 * Driver will fill up SSID, BSS mode, IBSS parameters, physical
805 * parameters, probe delay, and capability information. Firmware
806 * will fill up beacon period, basic rates and operational rates.
807 *
808 * In addition, the following TLVs are added -
809 * - Channel TLV
810 * - Vendor specific IE
811 * - WPA/WPA2 IE
812 * - HT Capabilities IE
813 * - HT Information IE
814 *
815 * Preparation also includes -
816 * - Setting command ID and proper size
817 * - Ensuring correct endian-ness
818 */
819int
820mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
a5ffddb7 821 struct host_cmd_ds_command *cmd,
b9be5f39 822 struct cfg80211_ssid *req_ssid)
5e6e3a92 823{
636c4598 824 int rsn_ie_len = 0;
5e6e3a92
BZ
825 struct mwifiex_adapter *adapter = priv->adapter;
826 struct host_cmd_ds_802_11_ad_hoc_start *adhoc_start =
827 &cmd->params.adhoc_start;
828 struct mwifiex_bssdescriptor *bss_desc;
829 u32 cmd_append_size = 0;
830 u32 i;
831 u16 tmp_cap;
5e6e3a92 832 struct mwifiex_ie_types_chan_list_param_set *chan_tlv;
eedf15d3 833 u8 radio_type;
5e6e3a92
BZ
834
835 struct mwifiex_ie_types_htcap *ht_cap;
836 struct mwifiex_ie_types_htinfo *ht_info;
837 u8 *pos = (u8 *) adhoc_start +
838 sizeof(struct host_cmd_ds_802_11_ad_hoc_start);
839
840 if (!adapter)
841 return -1;
842
843 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_START);
844
845 bss_desc = &priv->curr_bss_params.bss_descriptor;
846 priv->attempted_bss_desc = bss_desc;
847
848 /*
849 * Fill in the parameters for 2 data structures:
850 * 1. struct host_cmd_ds_802_11_ad_hoc_start command
851 * 2. bss_desc
852 * Driver will fill up SSID, bss_mode,IBSS param, Physical Param,
853 * probe delay, and Cap info.
854 * Firmware will fill up beacon period, Basic rates
855 * and operational rates.
856 */
857
858 memset(adhoc_start->ssid, 0, IEEE80211_MAX_SSID_LEN);
859
a5ffddb7 860 memcpy(adhoc_start->ssid, req_ssid->ssid, req_ssid->ssid_len);
5e6e3a92 861
acebe8c1
ZL
862 mwifiex_dbg(adapter, INFO, "info: ADHOC_S_CMD: SSID = %s\n",
863 adhoc_start->ssid);
5e6e3a92
BZ
864
865 memset(bss_desc->ssid.ssid, 0, IEEE80211_MAX_SSID_LEN);
a5ffddb7 866 memcpy(bss_desc->ssid.ssid, req_ssid->ssid, req_ssid->ssid_len);
5e6e3a92 867
a5ffddb7 868 bss_desc->ssid.ssid_len = req_ssid->ssid_len;
5e6e3a92
BZ
869
870 /* Set the BSS mode */
871 adhoc_start->bss_mode = HostCmd_BSS_MODE_IBSS;
eecd8250 872 bss_desc->bss_mode = NL80211_IFTYPE_ADHOC;
5e6e3a92
BZ
873 adhoc_start->beacon_period = cpu_to_le16(priv->beacon_period);
874 bss_desc->beacon_period = priv->beacon_period;
875
876 /* Set Physical param set */
877/* Parameter IE Id */
878#define DS_PARA_IE_ID 3
879/* Parameter IE length */
880#define DS_PARA_IE_LEN 1
881
882 adhoc_start->phy_param_set.ds_param_set.element_id = DS_PARA_IE_ID;
883 adhoc_start->phy_param_set.ds_param_set.len = DS_PARA_IE_LEN;
884
6685d109
YAP
885 if (!mwifiex_get_cfp(priv, adapter->adhoc_start_band,
886 (u16) priv->adhoc_channel, 0)) {
5e6e3a92 887 struct mwifiex_chan_freq_power *cfp;
6685d109
YAP
888 cfp = mwifiex_get_cfp(priv, adapter->adhoc_start_band,
889 FIRST_VALID_CHANNEL, 0);
5e6e3a92
BZ
890 if (cfp)
891 priv->adhoc_channel = (u8) cfp->channel;
892 }
893
894 if (!priv->adhoc_channel) {
acebe8c1
ZL
895 mwifiex_dbg(adapter, ERROR,
896 "ADHOC_S_CMD: adhoc_channel cannot be 0\n");
5e6e3a92
BZ
897 return -1;
898 }
899
acebe8c1
ZL
900 mwifiex_dbg(adapter, INFO,
901 "info: ADHOC_S_CMD: creating ADHOC on channel %d\n",
902 priv->adhoc_channel);
5e6e3a92
BZ
903
904 priv->curr_bss_params.bss_descriptor.channel = priv->adhoc_channel;
905 priv->curr_bss_params.band = adapter->adhoc_start_band;
906
907 bss_desc->channel = priv->adhoc_channel;
908 adhoc_start->phy_param_set.ds_param_set.current_chan =
909 priv->adhoc_channel;
910
911 memcpy(&bss_desc->phy_param_set, &adhoc_start->phy_param_set,
912 sizeof(union ieee_types_phy_param_set));
913
914 /* Set IBSS param set */
915/* IBSS parameter IE Id */
916#define IBSS_PARA_IE_ID 6
917/* IBSS parameter IE length */
918#define IBSS_PARA_IE_LEN 2
919
920 adhoc_start->ss_param_set.ibss_param_set.element_id = IBSS_PARA_IE_ID;
921 adhoc_start->ss_param_set.ibss_param_set.len = IBSS_PARA_IE_LEN;
922 adhoc_start->ss_param_set.ibss_param_set.atim_window
931f1584 923 = cpu_to_le16(priv->atim_window);
5e6e3a92
BZ
924 memcpy(&bss_desc->ss_param_set, &adhoc_start->ss_param_set,
925 sizeof(union ieee_types_ss_param_set));
926
927 /* Set Capability info */
928 bss_desc->cap_info_bitmap |= WLAN_CAPABILITY_IBSS;
4eed83a2 929 tmp_cap = WLAN_CAPABILITY_IBSS;
5e6e3a92
BZ
930
931 /* Set up privacy in bss_desc */
2be50b8d 932 if (priv->sec_info.encryption_mode) {
5e6e3a92 933 /* Ad-Hoc capability privacy on */
acebe8c1
ZL
934 mwifiex_dbg(adapter, INFO,
935 "info: ADHOC_S_CMD: wep_status set privacy to WEP\n");
5e6e3a92
BZ
936 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP;
937 tmp_cap |= WLAN_CAPABILITY_PRIVACY;
938 } else {
acebe8c1
ZL
939 mwifiex_dbg(adapter, INFO,
940 "info: ADHOC_S_CMD: wep_status NOT set,\t"
941 "setting privacy to ACCEPT ALL\n");
5e6e3a92
BZ
942 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL;
943 }
944
63af6333
YAP
945 memset(adhoc_start->data_rate, 0, sizeof(adhoc_start->data_rate));
946 mwifiex_get_active_data_rates(priv, adhoc_start->data_rate);
5e6e3a92
BZ
947 if ((adapter->adhoc_start_band & BAND_G) &&
948 (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) {
fa0ecbb9
BZ
949 if (mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
950 HostCmd_ACT_GEN_SET, 0,
951 &priv->curr_pkt_filter, false)) {
acebe8c1
ZL
952 mwifiex_dbg(adapter, ERROR,
953 "ADHOC_S_CMD: G Protection config failed\n");
5e6e3a92
BZ
954 return -1;
955 }
956 }
957 /* Find the last non zero */
63af6333
YAP
958 for (i = 0; i < sizeof(adhoc_start->data_rate); i++)
959 if (!adhoc_start->data_rate[i])
960 break;
5e6e3a92
BZ
961
962 priv->curr_bss_params.num_of_rates = i;
963
964 /* Copy the ad-hoc creating rates into Current BSS rate structure */
965 memcpy(&priv->curr_bss_params.data_rates,
63af6333 966 &adhoc_start->data_rate, priv->curr_bss_params.num_of_rates);
5e6e3a92 967
acebe8c1
ZL
968 mwifiex_dbg(adapter, INFO, "info: ADHOC_S_CMD: rates=%4ph\n",
969 adhoc_start->data_rate);
5e6e3a92 970
acebe8c1 971 mwifiex_dbg(adapter, INFO, "info: ADHOC_S_CMD: AD-HOC Start command is ready\n");
5e6e3a92
BZ
972
973 if (IS_SUPPORT_MULTI_BANDS(adapter)) {
974 /* Append a channel TLV */
975 chan_tlv = (struct mwifiex_ie_types_chan_list_param_set *) pos;
976 chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
977 chan_tlv->header.len =
978 cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set));
979
980 memset(chan_tlv->chan_scan_param, 0x00,
981 sizeof(struct mwifiex_chan_scan_param_set));
982 chan_tlv->chan_scan_param[0].chan_number =
983 (u8) priv->curr_bss_params.bss_descriptor.channel;
984
acebe8c1
ZL
985 mwifiex_dbg(adapter, INFO, "info: ADHOC_S_CMD: TLV Chan = %d\n",
986 chan_tlv->chan_scan_param[0].chan_number);
5e6e3a92
BZ
987
988 chan_tlv->chan_scan_param[0].radio_type
989 = mwifiex_band_to_radio_type(priv->curr_bss_params.band);
931f1584
YAP
990 if (adapter->adhoc_start_band & BAND_GN ||
991 adapter->adhoc_start_band & BAND_AN) {
21c3ba34
AK
992 if (adapter->sec_chan_offset ==
993 IEEE80211_HT_PARAM_CHA_SEC_ABOVE)
5e6e3a92 994 chan_tlv->chan_scan_param[0].radio_type |=
21c3ba34
AK
995 (IEEE80211_HT_PARAM_CHA_SEC_ABOVE << 4);
996 else if (adapter->sec_chan_offset ==
2a317ad8 997 IEEE80211_HT_PARAM_CHA_SEC_BELOW)
5e6e3a92 998 chan_tlv->chan_scan_param[0].radio_type |=
21c3ba34 999 (IEEE80211_HT_PARAM_CHA_SEC_BELOW << 4);
5e6e3a92 1000 }
acebe8c1
ZL
1001 mwifiex_dbg(adapter, INFO, "info: ADHOC_S_CMD: TLV Band = %d\n",
1002 chan_tlv->chan_scan_param[0].radio_type);
5e6e3a92
BZ
1003 pos += sizeof(chan_tlv->header) +
1004 sizeof(struct mwifiex_chan_scan_param_set);
1005 cmd_append_size +=
1006 sizeof(chan_tlv->header) +
1007 sizeof(struct mwifiex_chan_scan_param_set);
1008 }
1009
1010 /* Append vendor specific IE TLV */
1011 cmd_append_size += mwifiex_cmd_append_vsie_tlv(priv,
1012 MWIFIEX_VSIE_MASK_ADHOC, &pos);
1013
1014 if (priv->sec_info.wpa_enabled) {
1015 rsn_ie_len = mwifiex_append_rsn_ie_wpa_wpa2(priv, &pos);
1016 if (rsn_ie_len == -1)
1017 return -1;
1018 cmd_append_size += rsn_ie_len;
1019 }
1020
1021 if (adapter->adhoc_11n_enabled) {
eedf15d3
YAP
1022 /* Fill HT CAPABILITY */
1023 ht_cap = (struct mwifiex_ie_types_htcap *) pos;
1024 memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap));
1025 ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY);
1026 ht_cap->header.len =
1027 cpu_to_le16(sizeof(struct ieee80211_ht_cap));
1028 radio_type = mwifiex_band_to_radio_type(
1029 priv->adapter->config_bands);
341b8800 1030 mwifiex_fill_cap_info(priv, radio_type, &ht_cap->ht_cap);
eedf15d3 1031
d35f1035
AK
1032 if (adapter->sec_chan_offset ==
1033 IEEE80211_HT_PARAM_CHA_SEC_NONE) {
1034 u16 tmp_ht_cap;
1035
1036 tmp_ht_cap = le16_to_cpu(ht_cap->ht_cap.cap_info);
1037 tmp_ht_cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
1038 tmp_ht_cap &= ~IEEE80211_HT_CAP_SGI_40;
1039 ht_cap->ht_cap.cap_info = cpu_to_le16(tmp_ht_cap);
1040 }
1041
eedf15d3 1042 pos += sizeof(struct mwifiex_ie_types_htcap);
931f1584 1043 cmd_append_size += sizeof(struct mwifiex_ie_types_htcap);
eedf15d3
YAP
1044
1045 /* Fill HT INFORMATION */
1046 ht_info = (struct mwifiex_ie_types_htinfo *) pos;
1047 memset(ht_info, 0, sizeof(struct mwifiex_ie_types_htinfo));
074d46d1 1048 ht_info->header.type = cpu_to_le16(WLAN_EID_HT_OPERATION);
eedf15d3 1049 ht_info->header.len =
074d46d1 1050 cpu_to_le16(sizeof(struct ieee80211_ht_operation));
eedf15d3 1051
074d46d1 1052 ht_info->ht_oper.primary_chan =
eedf15d3 1053 (u8) priv->curr_bss_params.bss_descriptor.channel;
21c3ba34 1054 if (adapter->sec_chan_offset) {
074d46d1
JB
1055 ht_info->ht_oper.ht_param = adapter->sec_chan_offset;
1056 ht_info->ht_oper.ht_param |=
6d2bd916 1057 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
5e6e3a92 1058 }
074d46d1 1059 ht_info->ht_oper.operation_mode =
eedf15d3 1060 cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
074d46d1 1061 ht_info->ht_oper.basic_set[0] = 0xff;
eedf15d3
YAP
1062 pos += sizeof(struct mwifiex_ie_types_htinfo);
1063 cmd_append_size +=
931f1584 1064 sizeof(struct mwifiex_ie_types_htinfo);
5e6e3a92
BZ
1065 }
1066
931f1584
YAP
1067 cmd->size =
1068 cpu_to_le16((u16)(sizeof(struct host_cmd_ds_802_11_ad_hoc_start)
1069 + S_DS_GEN + cmd_append_size));
5e6e3a92
BZ
1070
1071 if (adapter->adhoc_start_band == BAND_B)
b93f85f0 1072 tmp_cap &= ~WLAN_CAPABILITY_SHORT_SLOT_TIME;
5e6e3a92 1073 else
b93f85f0 1074 tmp_cap |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
5e6e3a92
BZ
1075
1076 adhoc_start->cap_info_bitmap = cpu_to_le16(tmp_cap);
1077
1078 return 0;
1079}
1080
1081/*
1082 * This function prepares command for ad-hoc join.
1083 *
1084 * Most of the parameters are set up by copying from the target BSS descriptor
1085 * from the scan response.
1086 *
1087 * In addition, the following TLVs are added -
1088 * - Channel TLV
1089 * - Vendor specific IE
1090 * - WPA/WPA2 IE
1091 * - 11n IE
1092 *
1093 * Preparation also includes -
1094 * - Setting command ID and proper size
1095 * - Ensuring correct endian-ness
1096 */
1097int
1098mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
a5ffddb7
AK
1099 struct host_cmd_ds_command *cmd,
1100 struct mwifiex_bssdescriptor *bss_desc)
5e6e3a92 1101{
636c4598 1102 int rsn_ie_len = 0;
5e6e3a92
BZ
1103 struct host_cmd_ds_802_11_ad_hoc_join *adhoc_join =
1104 &cmd->params.adhoc_join;
5e6e3a92
BZ
1105 struct mwifiex_ie_types_chan_list_param_set *chan_tlv;
1106 u32 cmd_append_size = 0;
1107 u16 tmp_cap;
1108 u32 i, rates_size = 0;
1109 u16 curr_pkt_filter;
1110 u8 *pos =
1111 (u8 *) adhoc_join +
1112 sizeof(struct host_cmd_ds_802_11_ad_hoc_join);
1113
1114/* Use G protection */
1115#define USE_G_PROTECTION 0x02
1116 if (bss_desc->erp_flags & USE_G_PROTECTION) {
1117 curr_pkt_filter =
1118 priv->
1119 curr_pkt_filter | HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON;
1120
fa0ecbb9
BZ
1121 if (mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
1122 HostCmd_ACT_GEN_SET, 0,
1123 &curr_pkt_filter, false)) {
acebe8c1
ZL
1124 mwifiex_dbg(priv->adapter, ERROR,
1125 "ADHOC_J_CMD: G Protection config failed\n");
5e6e3a92
BZ
1126 return -1;
1127 }
1128 }
1129
1130 priv->attempted_bss_desc = bss_desc;
1131
1132 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_JOIN);
1133
1134 adhoc_join->bss_descriptor.bss_mode = HostCmd_BSS_MODE_IBSS;
1135
1136 adhoc_join->bss_descriptor.beacon_period
1137 = cpu_to_le16(bss_desc->beacon_period);
1138
1139 memcpy(&adhoc_join->bss_descriptor.bssid,
1140 &bss_desc->mac_address, ETH_ALEN);
1141
1142 memcpy(&adhoc_join->bss_descriptor.ssid,
1143 &bss_desc->ssid.ssid, bss_desc->ssid.ssid_len);
1144
1145 memcpy(&adhoc_join->bss_descriptor.phy_param_set,
1146 &bss_desc->phy_param_set,
1147 sizeof(union ieee_types_phy_param_set));
1148
1149 memcpy(&adhoc_join->bss_descriptor.ss_param_set,
1150 &bss_desc->ss_param_set, sizeof(union ieee_types_ss_param_set));
1151
1152 tmp_cap = bss_desc->cap_info_bitmap;
1153
1154 tmp_cap &= CAPINFO_MASK;
1155
acebe8c1
ZL
1156 mwifiex_dbg(priv->adapter, INFO,
1157 "info: ADHOC_J_CMD: tmp_cap=%4X CAPINFO_MASK=%4lX\n",
1158 tmp_cap, CAPINFO_MASK);
5e6e3a92
BZ
1159
1160 /* Information on BSSID descriptor passed to FW */
acebe8c1
ZL
1161 mwifiex_dbg(priv->adapter, INFO,
1162 "info: ADHOC_J_CMD: BSSID=%pM, SSID='%s'\n",
1163 adhoc_join->bss_descriptor.bssid,
1164 adhoc_join->bss_descriptor.ssid);
5e6e3a92 1165
5f0fabf8
BZ
1166 for (i = 0; i < MWIFIEX_SUPPORTED_RATES &&
1167 bss_desc->supported_rates[i]; i++)
1168 ;
5e6e3a92
BZ
1169 rates_size = i;
1170
1171 /* Copy Data Rates from the Rates recorded in scan response */
1172 memset(adhoc_join->bss_descriptor.data_rates, 0,
1173 sizeof(adhoc_join->bss_descriptor.data_rates));
1174 memcpy(adhoc_join->bss_descriptor.data_rates,
1175 bss_desc->supported_rates, rates_size);
1176
1177 /* Copy the adhoc join rates into Current BSS state structure */
1178 priv->curr_bss_params.num_of_rates = rates_size;
1179 memcpy(&priv->curr_bss_params.data_rates, bss_desc->supported_rates,
1180 rates_size);
1181
1182 /* Copy the channel information */
1183 priv->curr_bss_params.bss_descriptor.channel = bss_desc->channel;
1184 priv->curr_bss_params.band = (u8) bss_desc->bss_band;
1185
5eb02e44 1186 if (priv->sec_info.wep_enabled || priv->sec_info.wpa_enabled)
5e6e3a92
BZ
1187 tmp_cap |= WLAN_CAPABILITY_PRIVACY;
1188
1189 if (IS_SUPPORT_MULTI_BANDS(priv->adapter)) {
1190 /* Append a channel TLV */
1191 chan_tlv = (struct mwifiex_ie_types_chan_list_param_set *) pos;
1192 chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
1193 chan_tlv->header.len =
1194 cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set));
1195
1196 memset(chan_tlv->chan_scan_param, 0x00,
1197 sizeof(struct mwifiex_chan_scan_param_set));
1198 chan_tlv->chan_scan_param[0].chan_number =
1199 (bss_desc->phy_param_set.ds_param_set.current_chan);
acebe8c1
ZL
1200 mwifiex_dbg(priv->adapter, INFO, "info: ADHOC_J_CMD: TLV Chan=%d\n",
1201 chan_tlv->chan_scan_param[0].chan_number);
5e6e3a92
BZ
1202
1203 chan_tlv->chan_scan_param[0].radio_type =
1204 mwifiex_band_to_radio_type((u8) bss_desc->bss_band);
1205
acebe8c1
ZL
1206 mwifiex_dbg(priv->adapter, INFO, "info: ADHOC_J_CMD: TLV Band=%d\n",
1207 chan_tlv->chan_scan_param[0].radio_type);
5e6e3a92 1208 pos += sizeof(chan_tlv->header) +
931f1584 1209 sizeof(struct mwifiex_chan_scan_param_set);
5e6e3a92 1210 cmd_append_size += sizeof(chan_tlv->header) +
931f1584 1211 sizeof(struct mwifiex_chan_scan_param_set);
5e6e3a92
BZ
1212 }
1213
1214 if (priv->sec_info.wpa_enabled)
1215 rsn_ie_len = mwifiex_append_rsn_ie_wpa_wpa2(priv, &pos);
1216 if (rsn_ie_len == -1)
1217 return -1;
1218 cmd_append_size += rsn_ie_len;
1219
1220 if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info))
1221 cmd_append_size += mwifiex_cmd_append_11n_tlv(priv,
1222 bss_desc, &pos);
1223
1224 /* Append vendor specific IE TLV */
1225 cmd_append_size += mwifiex_cmd_append_vsie_tlv(priv,
1226 MWIFIEX_VSIE_MASK_ADHOC, &pos);
1227
931f1584
YAP
1228 cmd->size = cpu_to_le16
1229 ((u16) (sizeof(struct host_cmd_ds_802_11_ad_hoc_join)
1230 + S_DS_GEN + cmd_append_size));
5e6e3a92
BZ
1231
1232 adhoc_join->bss_descriptor.cap_info_bitmap = cpu_to_le16(tmp_cap);
1233
636c4598 1234 return 0;
5e6e3a92
BZ
1235}
1236
1237/*
1238 * This function handles the command response of ad-hoc start and
1239 * ad-hoc join.
1240 *
1241 * The function generates a device-connected event to notify
1242 * the applications, in case of successful ad-hoc start/join, and
1243 * saves the beacon buffer.
1244 */
1245int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
600f5d90 1246 struct host_cmd_ds_command *resp)
5e6e3a92
BZ
1247{
1248 int ret = 0;
600f5d90 1249 struct mwifiex_adapter *adapter = priv->adapter;
d5556e87
AK
1250 struct host_cmd_ds_802_11_ad_hoc_start_result *start_result =
1251 &resp->params.start_result;
1252 struct host_cmd_ds_802_11_ad_hoc_join_result *join_result =
1253 &resp->params.join_result;
5e6e3a92 1254 struct mwifiex_bssdescriptor *bss_desc;
d5556e87
AK
1255 u16 cmd = le16_to_cpu(resp->command);
1256 u8 result;
5e6e3a92 1257
d5556e87
AK
1258 if (cmd == HostCmd_CMD_802_11_AD_HOC_START)
1259 result = start_result->result;
1260 else
1261 result = join_result->result;
5e6e3a92
BZ
1262
1263 bss_desc = priv->attempted_bss_desc;
1264
1265 /* Join result code 0 --> SUCCESS */
d5556e87 1266 if (result) {
acebe8c1 1267 mwifiex_dbg(priv->adapter, ERROR, "ADHOC_RESP: failed\n");
5e6e3a92 1268 if (priv->media_connected)
d5556e87 1269 mwifiex_reset_connect_state(priv, result);
5e6e3a92
BZ
1270
1271 memset(&priv->curr_bss_params.bss_descriptor,
1272 0x00, sizeof(struct mwifiex_bssdescriptor));
1273
1274 ret = -1;
1275 goto done;
1276 }
1277
1278 /* Send a Media Connected event, according to the Spec */
1279 priv->media_connected = true;
1280
636c4598 1281 if (le16_to_cpu(resp->command) == HostCmd_CMD_802_11_AD_HOC_START) {
acebe8c1
ZL
1282 mwifiex_dbg(priv->adapter, INFO, "info: ADHOC_S_RESP %s\n",
1283 bss_desc->ssid.ssid);
5e6e3a92
BZ
1284
1285 /* Update the created network descriptor with the new BSSID */
1286 memcpy(bss_desc->mac_address,
d5556e87 1287 start_result->bssid, ETH_ALEN);
5e6e3a92
BZ
1288
1289 priv->adhoc_state = ADHOC_STARTED;
1290 } else {
1291 /*
1292 * Now the join cmd should be successful.
1293 * If BSSID has changed use SSID to compare instead of BSSID
1294 */
acebe8c1
ZL
1295 mwifiex_dbg(priv->adapter, INFO,
1296 "info: ADHOC_J_RESP %s\n",
1297 bss_desc->ssid.ssid);
5e6e3a92
BZ
1298
1299 /*
1300 * Make a copy of current BSSID descriptor, only needed for
1301 * join since the current descriptor is already being used
1302 * for adhoc start
1303 */
1304 memcpy(&priv->curr_bss_params.bss_descriptor,
1305 bss_desc, sizeof(struct mwifiex_bssdescriptor));
1306
1307 priv->adhoc_state = ADHOC_JOINED;
1308 }
1309
acebe8c1
ZL
1310 mwifiex_dbg(priv->adapter, INFO, "info: ADHOC_RESP: channel = %d\n",
1311 priv->adhoc_channel);
1312 mwifiex_dbg(priv->adapter, INFO, "info: ADHOC_RESP: BSSID = %pM\n",
1313 priv->curr_bss_params.bss_descriptor.mac_address);
5e6e3a92
BZ
1314
1315 if (!netif_carrier_ok(priv->netdev))
1316 netif_carrier_on(priv->netdev);
47411a06 1317 mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
5e6e3a92
BZ
1318
1319 mwifiex_save_curr_bcn(priv);
1320
1321done:
1322 /* Need to indicate IOCTL complete */
600f5d90 1323 if (adapter->curr_cmd->wait_q_enabled) {
5e6e3a92 1324 if (ret)
600f5d90 1325 adapter->cmd_wait_q.status = -1;
5e6e3a92 1326 else
600f5d90 1327 adapter->cmd_wait_q.status = 0;
5e6e3a92
BZ
1328
1329 }
1330
1331 return ret;
1332}
1333
1334/*
1335 * This function associates to a specific BSS discovered in a scan.
1336 *
1337 * It clears any past association response stored for application
1338 * retrieval and calls the command preparation routine to send the
1339 * command to firmware.
1340 */
1341int mwifiex_associate(struct mwifiex_private *priv,
600f5d90 1342 struct mwifiex_bssdescriptor *bss_desc)
5e6e3a92 1343{
953b3539
AP
1344 /* Return error if the adapter is not STA role or table entry
1345 * is not marked as infra.
1346 */
1347 if ((GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_STA) ||
eecd8250 1348 (bss_desc->bss_mode != NL80211_IFTYPE_STATION))
5e6e3a92
BZ
1349 return -1;
1350
2b6254da
AP
1351 if (ISSUPP_11ACENABLED(priv->adapter->fw_cap_info) &&
1352 !bss_desc->disable_11n && !bss_desc->disable_11ac &&
f25b1431 1353 priv->adapter->config_bands & BAND_AAC)
2b6254da
AP
1354 mwifiex_set_11ac_ba_params(priv);
1355 else
1356 mwifiex_set_ba_params(priv);
1357
5e6e3a92
BZ
1358 /* Clear any past association response stored for application
1359 retrieval */
1360 priv->assoc_rsp_size = 0;
1361
fa0ecbb9
BZ
1362 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_ASSOCIATE,
1363 HostCmd_ACT_GEN_SET, 0, bss_desc, true);
5e6e3a92
BZ
1364}
1365
1366/*
1367 * This function starts an ad-hoc network.
1368 *
1369 * It calls the command preparation routine to send the command to firmware.
1370 */
1371int
1372mwifiex_adhoc_start(struct mwifiex_private *priv,
b9be5f39 1373 struct cfg80211_ssid *adhoc_ssid)
5e6e3a92 1374{
acebe8c1
ZL
1375 mwifiex_dbg(priv->adapter, INFO, "info: Adhoc Channel = %d\n",
1376 priv->adhoc_channel);
1377 mwifiex_dbg(priv->adapter, INFO, "info: curr_bss_params.channel = %d\n",
1378 priv->curr_bss_params.bss_descriptor.channel);
1379 mwifiex_dbg(priv->adapter, INFO, "info: curr_bss_params.band = %d\n",
1380 priv->curr_bss_params.band);
5e6e3a92 1381
2b6254da 1382 if (ISSUPP_11ACENABLED(priv->adapter->fw_cap_info) &&
f25b1431 1383 priv->adapter->config_bands & BAND_AAC)
2b6254da
AP
1384 mwifiex_set_11ac_ba_params(priv);
1385 else
1386 mwifiex_set_ba_params(priv);
1387
fa0ecbb9
BZ
1388 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_AD_HOC_START,
1389 HostCmd_ACT_GEN_SET, 0, adhoc_ssid, true);
5e6e3a92
BZ
1390}
1391
1392/*
1393 * This function joins an ad-hoc network found in a previous scan.
1394 *
1395 * It calls the command preparation routine to send the command to firmware,
1396 * if already not connected to the requested SSID.
1397 */
1398int mwifiex_adhoc_join(struct mwifiex_private *priv,
600f5d90 1399 struct mwifiex_bssdescriptor *bss_desc)
5e6e3a92 1400{
acebe8c1
ZL
1401 mwifiex_dbg(priv->adapter, INFO,
1402 "info: adhoc join: curr_bss ssid =%s\n",
1403 priv->curr_bss_params.bss_descriptor.ssid.ssid);
1404 mwifiex_dbg(priv->adapter, INFO,
1405 "info: adhoc join: curr_bss ssid_len =%u\n",
1406 priv->curr_bss_params.bss_descriptor.ssid.ssid_len);
1407 mwifiex_dbg(priv->adapter, INFO, "info: adhoc join: ssid =%s\n",
1408 bss_desc->ssid.ssid);
1409 mwifiex_dbg(priv->adapter, INFO, "info: adhoc join: ssid_len =%u\n",
1410 bss_desc->ssid.ssid_len);
5e6e3a92
BZ
1411
1412 /* Check if the requested SSID is already joined */
1413 if (priv->curr_bss_params.bss_descriptor.ssid.ssid_len &&
1414 !mwifiex_ssid_cmp(&bss_desc->ssid,
1415 &priv->curr_bss_params.bss_descriptor.ssid) &&
1416 (priv->curr_bss_params.bss_descriptor.bss_mode ==
eecd8250 1417 NL80211_IFTYPE_ADHOC)) {
acebe8c1
ZL
1418 mwifiex_dbg(priv->adapter, INFO,
1419 "info: ADHOC_J_CMD: new ad-hoc SSID\t"
1420 "is the same as current; not attempting to re-join\n");
5e6e3a92
BZ
1421 return -1;
1422 }
1423
2b6254da
AP
1424 if (ISSUPP_11ACENABLED(priv->adapter->fw_cap_info) &&
1425 !bss_desc->disable_11n && !bss_desc->disable_11ac &&
f25b1431 1426 priv->adapter->config_bands & BAND_AAC)
2b6254da
AP
1427 mwifiex_set_11ac_ba_params(priv);
1428 else
1429 mwifiex_set_ba_params(priv);
1430
acebe8c1
ZL
1431 mwifiex_dbg(priv->adapter, INFO,
1432 "info: curr_bss_params.channel = %d\n",
1433 priv->curr_bss_params.bss_descriptor.channel);
1434 mwifiex_dbg(priv->adapter, INFO,
1435 "info: curr_bss_params.band = %c\n",
1436 priv->curr_bss_params.band);
5e6e3a92 1437
fa0ecbb9
BZ
1438 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_AD_HOC_JOIN,
1439 HostCmd_ACT_GEN_SET, 0, bss_desc, true);
5e6e3a92
BZ
1440}
1441
1442/*
1443 * This function deauthenticates/disconnects from infra network by sending
1444 * deauthentication request.
1445 */
600f5d90 1446static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv, u8 *mac)
5e6e3a92
BZ
1447{
1448 u8 mac_address[ETH_ALEN];
270e58e8 1449 int ret;
5e6e3a92 1450
2c208890
JP
1451 if (!mac || is_zero_ether_addr(mac))
1452 memcpy(mac_address,
1453 priv->curr_bss_params.bss_descriptor.mac_address,
1454 ETH_ALEN);
1455 else
1456 memcpy(mac_address, mac, ETH_ALEN);
5e6e3a92 1457
fa0ecbb9
BZ
1458 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_DEAUTHENTICATE,
1459 HostCmd_ACT_GEN_SET, 0, mac_address, true);
5e6e3a92
BZ
1460
1461 return ret;
1462}
1463
1464/*
1465 * This function deauthenticates/disconnects from a BSS.
1466 *
1467 * In case of infra made, it sends deauthentication request, and
1468 * in case of ad-hoc mode, a stop network request is sent to the firmware.
26134e6e 1469 * In AP mode, a command to stop bss is sent to firmware.
5e6e3a92 1470 */
600f5d90 1471int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac)
5e6e3a92 1472{
e8041cee
AP
1473 int ret = 0;
1474
99e126fd
BZ
1475 if (!priv->media_connected)
1476 return 0;
5e6e3a92 1477
99e126fd
BZ
1478 switch (priv->bss_mode) {
1479 case NL80211_IFTYPE_STATION:
5e4c0798 1480 case NL80211_IFTYPE_P2P_CLIENT:
e8041cee
AP
1481 ret = mwifiex_deauthenticate_infra(priv, mac);
1482 if (ret)
1483 cfg80211_disconnected(priv->netdev, 0, NULL, 0,
80279fb7 1484 true, GFP_KERNEL);
e8041cee 1485 break;
99e126fd 1486 case NL80211_IFTYPE_ADHOC:
fa0ecbb9
BZ
1487 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_AD_HOC_STOP,
1488 HostCmd_ACT_GEN_SET, 0, NULL, true);
26134e6e 1489 case NL80211_IFTYPE_AP:
fa0ecbb9
BZ
1490 return mwifiex_send_cmd(priv, HostCmd_CMD_UAP_BSS_STOP,
1491 HostCmd_ACT_GEN_SET, 0, NULL, true);
99e126fd
BZ
1492 default:
1493 break;
5e6e3a92
BZ
1494 }
1495
e8041cee 1496 return ret;
5e6e3a92 1497}
848819f4
AK
1498
1499/* This function deauthenticates/disconnects from all BSS. */
1500void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter)
1501{
1502 struct mwifiex_private *priv;
1503 int i;
1504
1505 for (i = 0; i < adapter->priv_num; i++) {
1506 priv = adapter->priv[i];
1507 if (priv)
1508 mwifiex_deauthenticate(priv, NULL);
1509 }
1510}
1511EXPORT_SYMBOL_GPL(mwifiex_deauthenticate_all);
5e6e3a92
BZ
1512
1513/*
1514 * This function converts band to radio type used in channel TLV.
1515 */
1516u8
1517mwifiex_band_to_radio_type(u8 band)
1518{
5e6e3a92
BZ
1519 switch (band) {
1520 case BAND_A:
1521 case BAND_AN:
1522 case BAND_A | BAND_AN:
a5f39056 1523 case BAND_A | BAND_AN | BAND_AAC:
636c4598 1524 return HostCmd_SCAN_RADIO_TYPE_A;
5e6e3a92
BZ
1525 case BAND_B:
1526 case BAND_G:
1527 case BAND_B | BAND_G:
1528 default:
636c4598 1529 return HostCmd_SCAN_RADIO_TYPE_BG;
5e6e3a92 1530 }
5e6e3a92 1531}
This page took 0.45164 seconds and 5 git commands to generate.