2 * Marvell Wireless LAN device driver: association and ad-hoc start/join
4 * Copyright (C) 2011, Marvell International Ltd.
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.
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.
28 #define CAPINFO_MASK (~(BIT(15) | BIT(14) | BIT(12) | BIT(11) | BIT(9)))
31 * Append a generic IE as a pass through TLV to a TLV buffer.
33 * This function is called from the network join command preparation routine.
35 * If the IE buffer has been setup by the application, this routine appends
36 * the buffer as a pass through TLV type to the request.
39 mwifiex_cmd_append_generic_ie(struct mwifiex_private
*priv
, u8
**buffer
)
42 struct mwifiex_ie_types_header ie_header
;
51 * If there is a generic ie buffer setup, append it to the return
52 * parameter buffer pointer.
54 if (priv
->gen_ie_buf_len
) {
55 dev_dbg(priv
->adapter
->dev
, "info: %s: append generic %d to %p\n",
56 __func__
, priv
->gen_ie_buf_len
, *buffer
);
58 /* Wrap the generic IE buffer with a pass through TLV type */
59 ie_header
.type
= cpu_to_le16(TLV_TYPE_PASSTHROUGH
);
60 ie_header
.len
= cpu_to_le16(priv
->gen_ie_buf_len
);
61 memcpy(*buffer
, &ie_header
, sizeof(ie_header
));
63 /* Increment the return size and the return buffer pointer
65 *buffer
+= sizeof(ie_header
);
66 ret_len
+= sizeof(ie_header
);
68 /* Copy the generic IE buffer to the output buffer, advance
70 memcpy(*buffer
, priv
->gen_ie_buf
, priv
->gen_ie_buf_len
);
72 /* Increment the return size and the return buffer pointer
74 *buffer
+= priv
->gen_ie_buf_len
;
75 ret_len
+= priv
->gen_ie_buf_len
;
77 /* Reset the generic IE buffer */
78 priv
->gen_ie_buf_len
= 0;
81 /* return the length appended to the buffer */
86 * Append TSF tracking info from the scan table for the target AP.
88 * This function is called from the network join command preparation routine.
90 * The TSF table TSF sent to the firmware contains two TSF values:
91 * - The TSF of the target AP from its previous beacon/probe response
92 * - The TSF timestamp of our local MAC at the time we observed the
93 * beacon/probe response.
95 * The firmware uses the timestamp values to set an initial TSF value
96 * in the MAC for the new association after a reassociation attempt.
99 mwifiex_cmd_append_tsf_tlv(struct mwifiex_private
*priv
, u8
**buffer
,
100 struct mwifiex_bssdescriptor
*bss_desc
)
102 struct mwifiex_ie_types_tsf_timestamp tsf_tlv
;
111 memset(&tsf_tlv
, 0x00, sizeof(struct mwifiex_ie_types_tsf_timestamp
));
113 tsf_tlv
.header
.type
= cpu_to_le16(TLV_TYPE_TSFTIMESTAMP
);
114 tsf_tlv
.header
.len
= cpu_to_le16(2 * sizeof(tsf_val
));
116 memcpy(*buffer
, &tsf_tlv
, sizeof(tsf_tlv
.header
));
117 *buffer
+= sizeof(tsf_tlv
.header
);
119 /* TSF at the time when beacon/probe_response was received */
120 tsf_val
= cpu_to_le64(bss_desc
->network_tsf
);
121 memcpy(*buffer
, &tsf_val
, sizeof(tsf_val
));
122 *buffer
+= sizeof(tsf_val
);
124 memcpy(&tsf_val
, bss_desc
->time_stamp
, sizeof(tsf_val
));
126 dev_dbg(priv
->adapter
->dev
, "info: %s: TSF offset calc: %016llx - "
127 "%016llx\n", __func__
, tsf_val
, bss_desc
->network_tsf
);
129 memcpy(*buffer
, &tsf_val
, sizeof(tsf_val
));
130 *buffer
+= sizeof(tsf_val
);
132 return sizeof(tsf_tlv
.header
) + (2 * sizeof(tsf_val
));
136 * This function finds out the common rates between rate1 and rate2.
138 * It will fill common rates in rate1 as output if found.
140 * NOTE: Setting the MSB of the basic rates needs to be taken
141 * care of, either before or after calling this function.
143 static int mwifiex_get_common_rates(struct mwifiex_private
*priv
, u8
*rate1
,
144 u32 rate1_size
, u8
*rate2
, u32 rate2_size
)
147 u8
*ptr
= rate1
, *tmp
;
150 tmp
= kmemdup(rate1
, rate1_size
, GFP_KERNEL
);
152 dev_err(priv
->adapter
->dev
, "failed to alloc tmp buf\n");
156 memset(rate1
, 0, rate1_size
);
158 for (i
= 0; rate2
[i
] && i
< rate2_size
; i
++) {
159 for (j
= 0; tmp
[j
] && j
< rate1_size
; j
++) {
160 /* Check common rate, excluding the bit for
162 if ((rate2
[i
] & 0x7F) == (tmp
[j
] & 0x7F)) {
169 dev_dbg(priv
->adapter
->dev
, "info: Tx data rate set to %#x\n",
172 if (!priv
->is_data_rate_auto
) {
174 if ((*ptr
& 0x7f) == priv
->data_rate
) {
180 dev_err(priv
->adapter
->dev
, "previously set fixed data rate %#x"
181 " is not compatible with the network\n",
195 * This function creates the intersection of the rates supported by a
196 * target BSS and our adapter settings for use in an assoc/join command.
199 mwifiex_setup_rates_from_bssdesc(struct mwifiex_private
*priv
,
200 struct mwifiex_bssdescriptor
*bss_desc
,
201 u8
*out_rates
, u32
*out_rates_size
)
203 u8 card_rates
[MWIFIEX_SUPPORTED_RATES
];
206 /* Copy AP supported rates */
207 memcpy(out_rates
, bss_desc
->supported_rates
, MWIFIEX_SUPPORTED_RATES
);
208 /* Get the STA supported rates */
209 card_rates_size
= mwifiex_get_active_data_rates(priv
, card_rates
);
210 /* Get the common rates between AP and STA supported rates */
211 if (mwifiex_get_common_rates(priv
, out_rates
, MWIFIEX_SUPPORTED_RATES
,
212 card_rates
, card_rates_size
)) {
214 dev_err(priv
->adapter
->dev
, "%s: cannot get common rates\n",
220 min_t(size_t, strlen(out_rates
), MWIFIEX_SUPPORTED_RATES
);
226 * This function appends a WAPI IE.
228 * This function is called from the network join command preparation routine.
230 * If the IE buffer has been setup by the application, this routine appends
231 * the buffer as a WAPI TLV type to the request.
234 mwifiex_cmd_append_wapi_ie(struct mwifiex_private
*priv
, u8
**buffer
)
237 struct mwifiex_ie_types_header ie_header
;
246 * If there is a wapi ie buffer setup, append it to the return
247 * parameter buffer pointer.
249 if (priv
->wapi_ie_len
) {
250 dev_dbg(priv
->adapter
->dev
, "cmd: append wapi ie %d to %p\n",
251 priv
->wapi_ie_len
, *buffer
);
253 /* Wrap the generic IE buffer with a pass through TLV type */
254 ie_header
.type
= cpu_to_le16(TLV_TYPE_WAPI_IE
);
255 ie_header
.len
= cpu_to_le16(priv
->wapi_ie_len
);
256 memcpy(*buffer
, &ie_header
, sizeof(ie_header
));
258 /* Increment the return size and the return buffer pointer
260 *buffer
+= sizeof(ie_header
);
261 retLen
+= sizeof(ie_header
);
263 /* Copy the wapi IE buffer to the output buffer, advance
265 memcpy(*buffer
, priv
->wapi_ie
, priv
->wapi_ie_len
);
267 /* Increment the return size and the return buffer pointer
269 *buffer
+= priv
->wapi_ie_len
;
270 retLen
+= priv
->wapi_ie_len
;
273 /* return the length appended to the buffer */
278 * This function appends rsn ie tlv for wpa/wpa2 security modes.
279 * It is called from the network join command preparation routine.
281 static int mwifiex_append_rsn_ie_wpa_wpa2(struct mwifiex_private
*priv
,
284 struct mwifiex_ie_types_rsn_param_set
*rsn_ie_tlv
;
287 if (!buffer
|| !(*buffer
))
290 rsn_ie_tlv
= (struct mwifiex_ie_types_rsn_param_set
*) (*buffer
);
291 rsn_ie_tlv
->header
.type
= cpu_to_le16((u16
) priv
->wpa_ie
[0]);
292 rsn_ie_tlv
->header
.type
= cpu_to_le16(
293 le16_to_cpu(rsn_ie_tlv
->header
.type
) & 0x00FF);
294 rsn_ie_tlv
->header
.len
= cpu_to_le16((u16
) priv
->wpa_ie
[1]);
295 rsn_ie_tlv
->header
.len
= cpu_to_le16(le16_to_cpu(rsn_ie_tlv
->header
.len
)
297 if (le16_to_cpu(rsn_ie_tlv
->header
.len
) <= (sizeof(priv
->wpa_ie
) - 2))
298 memcpy(rsn_ie_tlv
->rsn_ie
, &priv
->wpa_ie
[2],
299 le16_to_cpu(rsn_ie_tlv
->header
.len
));
303 rsn_ie_len
= sizeof(rsn_ie_tlv
->header
) +
304 le16_to_cpu(rsn_ie_tlv
->header
.len
);
305 *buffer
+= rsn_ie_len
;
311 * This function prepares command for association.
313 * This sets the following parameters -
317 * - Capability information
319 * ...and the following TLVs, as required -
324 * - Authentication TLV
328 * - Vendor specific TLV
334 * Preparation also includes -
335 * - Setting command ID and proper size
336 * - Ensuring correct endian-ness
338 int mwifiex_cmd_802_11_associate(struct mwifiex_private
*priv
,
339 struct host_cmd_ds_command
*cmd
,
340 struct mwifiex_bssdescriptor
*bss_desc
)
342 struct host_cmd_ds_802_11_associate
*assoc
= &cmd
->params
.associate
;
343 struct mwifiex_ie_types_ssid_param_set
*ssid_tlv
;
344 struct mwifiex_ie_types_phy_param_set
*phy_tlv
;
345 struct mwifiex_ie_types_ss_param_set
*ss_tlv
;
346 struct mwifiex_ie_types_rates_param_set
*rates_tlv
;
347 struct mwifiex_ie_types_auth_type
*auth_tlv
;
348 struct mwifiex_ie_types_chan_list_param_set
*chan_tlv
;
349 u8 rates
[MWIFIEX_SUPPORTED_RATES
];
357 mwifiex_cfg_tx_buf(priv
, bss_desc
);
359 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_ASSOCIATE
);
361 /* Save so we know which BSS Desc to use in the response handler */
362 priv
->attempted_bss_desc
= bss_desc
;
364 memcpy(assoc
->peer_sta_addr
,
365 bss_desc
->mac_address
, sizeof(assoc
->peer_sta_addr
));
366 pos
+= sizeof(assoc
->peer_sta_addr
);
368 /* Set the listen interval */
369 assoc
->listen_interval
= cpu_to_le16(priv
->listen_interval
);
370 /* Set the beacon period */
371 assoc
->beacon_period
= cpu_to_le16(bss_desc
->beacon_period
);
373 pos
+= sizeof(assoc
->cap_info_bitmap
);
374 pos
+= sizeof(assoc
->listen_interval
);
375 pos
+= sizeof(assoc
->beacon_period
);
376 pos
+= sizeof(assoc
->dtim_period
);
378 ssid_tlv
= (struct mwifiex_ie_types_ssid_param_set
*) pos
;
379 ssid_tlv
->header
.type
= cpu_to_le16(WLAN_EID_SSID
);
380 ssid_tlv
->header
.len
= cpu_to_le16((u16
) bss_desc
->ssid
.ssid_len
);
381 memcpy(ssid_tlv
->ssid
, bss_desc
->ssid
.ssid
,
382 le16_to_cpu(ssid_tlv
->header
.len
));
383 pos
+= sizeof(ssid_tlv
->header
) + le16_to_cpu(ssid_tlv
->header
.len
);
385 phy_tlv
= (struct mwifiex_ie_types_phy_param_set
*) pos
;
386 phy_tlv
->header
.type
= cpu_to_le16(WLAN_EID_DS_PARAMS
);
387 phy_tlv
->header
.len
= cpu_to_le16(sizeof(phy_tlv
->fh_ds
.ds_param_set
));
388 memcpy(&phy_tlv
->fh_ds
.ds_param_set
,
389 &bss_desc
->phy_param_set
.ds_param_set
.current_chan
,
390 sizeof(phy_tlv
->fh_ds
.ds_param_set
));
391 pos
+= sizeof(phy_tlv
->header
) + le16_to_cpu(phy_tlv
->header
.len
);
393 ss_tlv
= (struct mwifiex_ie_types_ss_param_set
*) pos
;
394 ss_tlv
->header
.type
= cpu_to_le16(WLAN_EID_CF_PARAMS
);
395 ss_tlv
->header
.len
= cpu_to_le16(sizeof(ss_tlv
->cf_ibss
.cf_param_set
));
396 pos
+= sizeof(ss_tlv
->header
) + le16_to_cpu(ss_tlv
->header
.len
);
398 /* Get the common rates supported between the driver and the BSS Desc */
399 if (mwifiex_setup_rates_from_bssdesc
400 (priv
, bss_desc
, rates
, &rates_size
))
403 /* Save the data rates into Current BSS state structure */
404 priv
->curr_bss_params
.num_of_rates
= rates_size
;
405 memcpy(&priv
->curr_bss_params
.data_rates
, rates
, rates_size
);
407 /* Setup the Rates TLV in the association command */
408 rates_tlv
= (struct mwifiex_ie_types_rates_param_set
*) pos
;
409 rates_tlv
->header
.type
= cpu_to_le16(WLAN_EID_SUPP_RATES
);
410 rates_tlv
->header
.len
= cpu_to_le16((u16
) rates_size
);
411 memcpy(rates_tlv
->rates
, rates
, rates_size
);
412 pos
+= sizeof(rates_tlv
->header
) + rates_size
;
413 dev_dbg(priv
->adapter
->dev
, "info: ASSOC_CMD: rates size = %d\n",
416 /* Add the Authentication type to be used for Auth frames */
417 auth_tlv
= (struct mwifiex_ie_types_auth_type
*) pos
;
418 auth_tlv
->header
.type
= cpu_to_le16(TLV_TYPE_AUTH_TYPE
);
419 auth_tlv
->header
.len
= cpu_to_le16(sizeof(auth_tlv
->auth_type
));
420 if (priv
->sec_info
.wep_status
== MWIFIEX_802_11_WEP_ENABLED
)
421 auth_tlv
->auth_type
= cpu_to_le16(
422 (u16
) priv
->sec_info
.authentication_mode
);
424 auth_tlv
->auth_type
= cpu_to_le16(NL80211_AUTHTYPE_OPEN_SYSTEM
);
426 pos
+= sizeof(auth_tlv
->header
) + le16_to_cpu(auth_tlv
->header
.len
);
428 if (IS_SUPPORT_MULTI_BANDS(priv
->adapter
)
429 && !(ISSUPP_11NENABLED(priv
->adapter
->fw_cap_info
)
430 && (!bss_desc
->disable_11n
)
431 && (priv
->adapter
->config_bands
& BAND_GN
432 || priv
->adapter
->config_bands
& BAND_AN
)
433 && (bss_desc
->bcn_ht_cap
)
436 /* Append a channel TLV for the channel the attempted AP was
438 chan_tlv
= (struct mwifiex_ie_types_chan_list_param_set
*) pos
;
439 chan_tlv
->header
.type
= cpu_to_le16(TLV_TYPE_CHANLIST
);
440 chan_tlv
->header
.len
=
441 cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set
));
443 memset(chan_tlv
->chan_scan_param
, 0x00,
444 sizeof(struct mwifiex_chan_scan_param_set
));
445 chan_tlv
->chan_scan_param
[0].chan_number
=
446 (bss_desc
->phy_param_set
.ds_param_set
.current_chan
);
447 dev_dbg(priv
->adapter
->dev
, "info: Assoc: TLV Chan = %d\n",
448 chan_tlv
->chan_scan_param
[0].chan_number
);
450 chan_tlv
->chan_scan_param
[0].radio_type
=
451 mwifiex_band_to_radio_type((u8
) bss_desc
->bss_band
);
453 dev_dbg(priv
->adapter
->dev
, "info: Assoc: TLV Band = %d\n",
454 chan_tlv
->chan_scan_param
[0].radio_type
);
455 pos
+= sizeof(chan_tlv
->header
) +
456 sizeof(struct mwifiex_chan_scan_param_set
);
459 if (!priv
->wps
.session_enable
) {
460 if (priv
->sec_info
.wpa_enabled
|| priv
->sec_info
.wpa2_enabled
)
461 rsn_ie_len
= mwifiex_append_rsn_ie_wpa_wpa2(priv
, &pos
);
463 if (rsn_ie_len
== -1)
467 if (ISSUPP_11NENABLED(priv
->adapter
->fw_cap_info
)
468 && (!bss_desc
->disable_11n
)
469 && (priv
->adapter
->config_bands
& BAND_GN
470 || priv
->adapter
->config_bands
& BAND_AN
))
471 mwifiex_cmd_append_11n_tlv(priv
, bss_desc
, &pos
);
473 /* Append vendor specific IE TLV */
474 mwifiex_cmd_append_vsie_tlv(priv
, MWIFIEX_VSIE_MASK_ASSOC
, &pos
);
476 mwifiex_wmm_process_association_req(priv
, &pos
, &bss_desc
->wmm_ie
,
477 bss_desc
->bcn_ht_cap
);
478 if (priv
->sec_info
.wapi_enabled
&& priv
->wapi_ie_len
)
479 mwifiex_cmd_append_wapi_ie(priv
, &pos
);
482 mwifiex_cmd_append_generic_ie(priv
, &pos
);
484 mwifiex_cmd_append_tsf_tlv(priv
, &pos
, bss_desc
);
486 cmd
->size
= cpu_to_le16((u16
) (pos
- (u8
*) assoc
) + S_DS_GEN
);
488 /* Set the Capability info at last */
489 tmp_cap
= bss_desc
->cap_info_bitmap
;
491 if (priv
->adapter
->config_bands
== BAND_B
)
492 tmp_cap
&= ~WLAN_CAPABILITY_SHORT_SLOT_TIME
;
494 tmp_cap
&= CAPINFO_MASK
;
495 dev_dbg(priv
->adapter
->dev
, "info: ASSOC_CMD: tmp_cap=%4X CAPINFO_MASK=%4lX\n",
496 tmp_cap
, CAPINFO_MASK
);
497 assoc
->cap_info_bitmap
= cpu_to_le16(tmp_cap
);
503 * Association firmware command response handler
505 * The response buffer for the association command has the following
508 * For cases where an association response was not received (indicated
509 * by the CapInfo and AId field):
511 * .------------------------------------------------------------.
512 * | Header(4 * sizeof(t_u16)): Standard command response hdr |
513 * .------------------------------------------------------------.
514 * | cap_info/Error Return(t_u16): |
515 * | 0xFFFF(-1): Internal error |
516 * | 0xFFFE(-2): Authentication unhandled message |
517 * | 0xFFFD(-3): Authentication refused |
518 * | 0xFFFC(-4): Timeout waiting for AP response |
519 * .------------------------------------------------------------.
520 * | status_code(t_u16): |
521 * | If cap_info is -1: |
522 * | An internal firmware failure prevented the |
523 * | command from being processed. The status_code |
524 * | will be set to 1. |
526 * | If cap_info is -2: |
527 * | An authentication frame was received but was |
528 * | not handled by the firmware. IEEE Status |
529 * | code for the failure is returned. |
531 * | If cap_info is -3: |
532 * | An authentication frame was received and the |
533 * | status_code is the IEEE Status reported in the |
536 * | If cap_info is -4: |
537 * | (1) Association response timeout |
538 * | (2) Authentication response timeout |
539 * .------------------------------------------------------------.
540 * | a_id(t_u16): 0xFFFF |
541 * .------------------------------------------------------------.
544 * For cases where an association response was received, the IEEE
545 * standard association response frame is returned:
547 * .------------------------------------------------------------.
548 * | Header(4 * sizeof(t_u16)): Standard command response hdr |
549 * .------------------------------------------------------------.
550 * | cap_info(t_u16): IEEE Capability |
551 * .------------------------------------------------------------.
552 * | status_code(t_u16): IEEE Status Code |
553 * .------------------------------------------------------------.
554 * | a_id(t_u16): IEEE Association ID |
555 * .------------------------------------------------------------.
556 * | IEEE IEs(variable): Any received IEs comprising the |
557 * | remaining portion of a received |
558 * | association response frame. |
559 * .------------------------------------------------------------.
561 * For simplistic handling, the status_code field can be used to determine
562 * an association success (0) or failure (non-zero).
564 int mwifiex_ret_802_11_associate(struct mwifiex_private
*priv
,
565 struct host_cmd_ds_command
*resp
)
567 struct mwifiex_adapter
*adapter
= priv
->adapter
;
569 struct ieee_types_assoc_rsp
*assoc_rsp
;
570 struct mwifiex_bssdescriptor
*bss_desc
;
571 u8 enable_data
= true;
573 assoc_rsp
= (struct ieee_types_assoc_rsp
*) &resp
->params
;
575 priv
->assoc_rsp_size
= min(le16_to_cpu(resp
->size
) - S_DS_GEN
,
576 sizeof(priv
->assoc_rsp_buf
));
578 memcpy(priv
->assoc_rsp_buf
, &resp
->params
, priv
->assoc_rsp_size
);
580 if (le16_to_cpu(assoc_rsp
->status_code
)) {
581 priv
->adapter
->dbg
.num_cmd_assoc_failure
++;
582 dev_err(priv
->adapter
->dev
, "ASSOC_RESP: association failed, "
583 "status code = %d, error = 0x%x, a_id = 0x%x\n",
584 le16_to_cpu(assoc_rsp
->status_code
),
585 le16_to_cpu(assoc_rsp
->cap_info_bitmap
),
586 le16_to_cpu(assoc_rsp
->a_id
));
592 /* Send a Media Connected event, according to the Spec */
593 priv
->media_connected
= true;
595 priv
->adapter
->ps_state
= PS_STATE_AWAKE
;
596 priv
->adapter
->pps_uapsd_mode
= false;
597 priv
->adapter
->tx_lock_flag
= false;
599 /* Set the attempted BSSID Index to current */
600 bss_desc
= priv
->attempted_bss_desc
;
602 dev_dbg(priv
->adapter
->dev
, "info: ASSOC_RESP: %s\n",
603 bss_desc
->ssid
.ssid
);
605 /* Make a copy of current BSSID descriptor */
606 memcpy(&priv
->curr_bss_params
.bss_descriptor
,
607 bss_desc
, sizeof(struct mwifiex_bssdescriptor
));
609 /* Update curr_bss_params */
610 priv
->curr_bss_params
.bss_descriptor
.channel
611 = bss_desc
->phy_param_set
.ds_param_set
.current_chan
;
613 priv
->curr_bss_params
.band
= (u8
) bss_desc
->bss_band
;
615 if (bss_desc
->wmm_ie
.vend_hdr
.element_id
== WLAN_EID_VENDOR_SPECIFIC
)
616 priv
->curr_bss_params
.wmm_enabled
= true;
618 priv
->curr_bss_params
.wmm_enabled
= false;
620 if ((priv
->wmm_required
|| bss_desc
->bcn_ht_cap
)
621 && priv
->curr_bss_params
.wmm_enabled
)
622 priv
->wmm_enabled
= true;
624 priv
->wmm_enabled
= false;
626 priv
->curr_bss_params
.wmm_uapsd_enabled
= false;
628 if (priv
->wmm_enabled
)
629 priv
->curr_bss_params
.wmm_uapsd_enabled
630 = ((bss_desc
->wmm_ie
.qos_info_bitmap
&
631 IEEE80211_WMM_IE_AP_QOSINFO_UAPSD
) ? 1 : 0);
633 dev_dbg(priv
->adapter
->dev
, "info: ASSOC_RESP: curr_pkt_filter is %#x\n",
634 priv
->curr_pkt_filter
);
635 if (priv
->sec_info
.wpa_enabled
|| priv
->sec_info
.wpa2_enabled
)
636 priv
->wpa_is_gtk_set
= false;
638 if (priv
->wmm_enabled
) {
639 /* Don't re-enable carrier until we get the WMM_GET_STATUS
643 /* Since WMM is not enabled, setup the queues with the
645 mwifiex_wmm_setup_queue_priorities(priv
, NULL
);
646 mwifiex_wmm_setup_ac_downgrade(priv
);
650 dev_dbg(priv
->adapter
->dev
,
651 "info: post association, re-enabling data flow\n");
653 /* Reset SNR/NF/RSSI values */
654 priv
->data_rssi_last
= 0;
655 priv
->data_nf_last
= 0;
656 priv
->data_rssi_avg
= 0;
657 priv
->data_nf_avg
= 0;
658 priv
->bcn_rssi_last
= 0;
659 priv
->bcn_nf_last
= 0;
660 priv
->bcn_rssi_avg
= 0;
661 priv
->bcn_nf_avg
= 0;
663 priv
->rxpd_htinfo
= 0;
665 mwifiex_save_curr_bcn(priv
);
667 priv
->adapter
->dbg
.num_cmd_assoc_success
++;
669 dev_dbg(priv
->adapter
->dev
, "info: ASSOC_RESP: associated\n");
671 /* Add the ra_list here for infra mode as there will be only 1 ra
673 mwifiex_ralist_add(priv
,
674 priv
->curr_bss_params
.bss_descriptor
.mac_address
);
676 if (!netif_carrier_ok(priv
->netdev
))
677 netif_carrier_on(priv
->netdev
);
678 if (netif_queue_stopped(priv
->netdev
))
679 netif_wake_queue(priv
->netdev
);
681 if (priv
->sec_info
.wpa_enabled
|| priv
->sec_info
.wpa2_enabled
)
682 priv
->scan_block
= true;
685 /* Need to indicate IOCTL complete */
686 if (adapter
->curr_cmd
->wait_q_enabled
) {
688 adapter
->cmd_wait_q
.status
= -1;
690 adapter
->cmd_wait_q
.status
= 0;
697 * This function prepares command for ad-hoc start.
699 * Driver will fill up SSID, BSS mode, IBSS parameters, physical
700 * parameters, probe delay, and capability information. Firmware
701 * will fill up beacon period, basic rates and operational rates.
703 * In addition, the following TLVs are added -
705 * - Vendor specific IE
707 * - HT Capabilities IE
708 * - HT Information IE
710 * Preparation also includes -
711 * - Setting command ID and proper size
712 * - Ensuring correct endian-ness
715 mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private
*priv
,
716 struct host_cmd_ds_command
*cmd
,
717 struct mwifiex_802_11_ssid
*req_ssid
)
720 struct mwifiex_adapter
*adapter
= priv
->adapter
;
721 struct host_cmd_ds_802_11_ad_hoc_start
*adhoc_start
=
722 &cmd
->params
.adhoc_start
;
723 struct mwifiex_bssdescriptor
*bss_desc
;
724 u32 cmd_append_size
= 0;
727 uint16_t ht_cap_info
;
728 struct mwifiex_ie_types_chan_list_param_set
*chan_tlv
;
730 struct mwifiex_ie_types_htcap
*ht_cap
;
731 struct mwifiex_ie_types_htinfo
*ht_info
;
732 u8
*pos
= (u8
*) adhoc_start
+
733 sizeof(struct host_cmd_ds_802_11_ad_hoc_start
);
738 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_START
);
740 bss_desc
= &priv
->curr_bss_params
.bss_descriptor
;
741 priv
->attempted_bss_desc
= bss_desc
;
744 * Fill in the parameters for 2 data structures:
745 * 1. struct host_cmd_ds_802_11_ad_hoc_start command
747 * Driver will fill up SSID, bss_mode,IBSS param, Physical Param,
748 * probe delay, and Cap info.
749 * Firmware will fill up beacon period, Basic rates
750 * and operational rates.
753 memset(adhoc_start
->ssid
, 0, IEEE80211_MAX_SSID_LEN
);
755 memcpy(adhoc_start
->ssid
, req_ssid
->ssid
, req_ssid
->ssid_len
);
757 dev_dbg(adapter
->dev
, "info: ADHOC_S_CMD: SSID = %s\n",
760 memset(bss_desc
->ssid
.ssid
, 0, IEEE80211_MAX_SSID_LEN
);
761 memcpy(bss_desc
->ssid
.ssid
, req_ssid
->ssid
, req_ssid
->ssid_len
);
763 bss_desc
->ssid
.ssid_len
= req_ssid
->ssid_len
;
765 /* Set the BSS mode */
766 adhoc_start
->bss_mode
= HostCmd_BSS_MODE_IBSS
;
767 bss_desc
->bss_mode
= NL80211_IFTYPE_ADHOC
;
768 adhoc_start
->beacon_period
= cpu_to_le16(priv
->beacon_period
);
769 bss_desc
->beacon_period
= priv
->beacon_period
;
771 /* Set Physical param set */
772 /* Parameter IE Id */
773 #define DS_PARA_IE_ID 3
774 /* Parameter IE length */
775 #define DS_PARA_IE_LEN 1
777 adhoc_start
->phy_param_set
.ds_param_set
.element_id
= DS_PARA_IE_ID
;
778 adhoc_start
->phy_param_set
.ds_param_set
.len
= DS_PARA_IE_LEN
;
780 if (!mwifiex_get_cfp_by_band_and_channel_from_cfg80211
781 (priv
, adapter
->adhoc_start_band
, (u16
)
782 priv
->adhoc_channel
)) {
783 struct mwifiex_chan_freq_power
*cfp
;
784 cfp
= mwifiex_get_cfp_by_band_and_channel_from_cfg80211(priv
,
785 adapter
->adhoc_start_band
, FIRST_VALID_CHANNEL
);
787 priv
->adhoc_channel
= (u8
) cfp
->channel
;
790 if (!priv
->adhoc_channel
) {
791 dev_err(adapter
->dev
, "ADHOC_S_CMD: adhoc_channel cannot be 0\n");
795 dev_dbg(adapter
->dev
, "info: ADHOC_S_CMD: creating ADHOC on channel %d\n",
796 priv
->adhoc_channel
);
798 priv
->curr_bss_params
.bss_descriptor
.channel
= priv
->adhoc_channel
;
799 priv
->curr_bss_params
.band
= adapter
->adhoc_start_band
;
801 bss_desc
->channel
= priv
->adhoc_channel
;
802 adhoc_start
->phy_param_set
.ds_param_set
.current_chan
=
805 memcpy(&bss_desc
->phy_param_set
, &adhoc_start
->phy_param_set
,
806 sizeof(union ieee_types_phy_param_set
));
808 /* Set IBSS param set */
809 /* IBSS parameter IE Id */
810 #define IBSS_PARA_IE_ID 6
811 /* IBSS parameter IE length */
812 #define IBSS_PARA_IE_LEN 2
814 adhoc_start
->ss_param_set
.ibss_param_set
.element_id
= IBSS_PARA_IE_ID
;
815 adhoc_start
->ss_param_set
.ibss_param_set
.len
= IBSS_PARA_IE_LEN
;
816 adhoc_start
->ss_param_set
.ibss_param_set
.atim_window
817 = cpu_to_le16(priv
->atim_window
);
818 memcpy(&bss_desc
->ss_param_set
, &adhoc_start
->ss_param_set
,
819 sizeof(union ieee_types_ss_param_set
));
821 /* Set Capability info */
822 bss_desc
->cap_info_bitmap
|= WLAN_CAPABILITY_IBSS
;
823 tmp_cap
= le16_to_cpu(adhoc_start
->cap_info_bitmap
);
824 tmp_cap
&= ~WLAN_CAPABILITY_ESS
;
825 tmp_cap
|= WLAN_CAPABILITY_IBSS
;
827 /* Set up privacy in bss_desc */
828 if (priv
->sec_info
.encryption_mode
) {
829 /* Ad-Hoc capability privacy on */
830 dev_dbg(adapter
->dev
,
831 "info: ADHOC_S_CMD: wep_status set privacy to WEP\n");
832 bss_desc
->privacy
= MWIFIEX_802_11_PRIV_FILTER_8021X_WEP
;
833 tmp_cap
|= WLAN_CAPABILITY_PRIVACY
;
835 dev_dbg(adapter
->dev
, "info: ADHOC_S_CMD: wep_status NOT set,"
836 " setting privacy to ACCEPT ALL\n");
837 bss_desc
->privacy
= MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL
;
840 memset(adhoc_start
->DataRate
, 0, sizeof(adhoc_start
->DataRate
));
841 mwifiex_get_active_data_rates(priv
, adhoc_start
->DataRate
);
842 if ((adapter
->adhoc_start_band
& BAND_G
) &&
843 (priv
->curr_pkt_filter
& HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON
)) {
844 if (mwifiex_send_cmd_async(priv
, HostCmd_CMD_MAC_CONTROL
,
845 HostCmd_ACT_GEN_SET
, 0,
846 &priv
->curr_pkt_filter
)) {
847 dev_err(adapter
->dev
,
848 "ADHOC_S_CMD: G Protection config failed\n");
852 /* Find the last non zero */
853 for (i
= 0; i
< sizeof(adhoc_start
->DataRate
) &&
854 adhoc_start
->DataRate
[i
];
858 priv
->curr_bss_params
.num_of_rates
= i
;
860 /* Copy the ad-hoc creating rates into Current BSS rate structure */
861 memcpy(&priv
->curr_bss_params
.data_rates
,
862 &adhoc_start
->DataRate
, priv
->curr_bss_params
.num_of_rates
);
864 dev_dbg(adapter
->dev
, "info: ADHOC_S_CMD: rates=%02x %02x %02x %02x\n",
865 adhoc_start
->DataRate
[0], adhoc_start
->DataRate
[1],
866 adhoc_start
->DataRate
[2], adhoc_start
->DataRate
[3]);
868 dev_dbg(adapter
->dev
, "info: ADHOC_S_CMD: AD-HOC Start command is ready\n");
870 if (IS_SUPPORT_MULTI_BANDS(adapter
)) {
871 /* Append a channel TLV */
872 chan_tlv
= (struct mwifiex_ie_types_chan_list_param_set
*) pos
;
873 chan_tlv
->header
.type
= cpu_to_le16(TLV_TYPE_CHANLIST
);
874 chan_tlv
->header
.len
=
875 cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set
));
877 memset(chan_tlv
->chan_scan_param
, 0x00,
878 sizeof(struct mwifiex_chan_scan_param_set
));
879 chan_tlv
->chan_scan_param
[0].chan_number
=
880 (u8
) priv
->curr_bss_params
.bss_descriptor
.channel
;
882 dev_dbg(adapter
->dev
, "info: ADHOC_S_CMD: TLV Chan = %d\n",
883 chan_tlv
->chan_scan_param
[0].chan_number
);
885 chan_tlv
->chan_scan_param
[0].radio_type
886 = mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
887 if (adapter
->adhoc_start_band
& BAND_GN
888 || adapter
->adhoc_start_band
& BAND_AN
) {
889 if (adapter
->chan_offset
== SEC_CHANNEL_ABOVE
)
890 chan_tlv
->chan_scan_param
[0].radio_type
|=
891 SECOND_CHANNEL_ABOVE
;
892 else if (adapter
->chan_offset
== SEC_CHANNEL_BELOW
)
893 chan_tlv
->chan_scan_param
[0].radio_type
|=
894 SECOND_CHANNEL_BELOW
;
896 dev_dbg(adapter
->dev
, "info: ADHOC_S_CMD: TLV Band = %d\n",
897 chan_tlv
->chan_scan_param
[0].radio_type
);
898 pos
+= sizeof(chan_tlv
->header
) +
899 sizeof(struct mwifiex_chan_scan_param_set
);
901 sizeof(chan_tlv
->header
) +
902 sizeof(struct mwifiex_chan_scan_param_set
);
905 /* Append vendor specific IE TLV */
906 cmd_append_size
+= mwifiex_cmd_append_vsie_tlv(priv
,
907 MWIFIEX_VSIE_MASK_ADHOC
, &pos
);
909 if (priv
->sec_info
.wpa_enabled
) {
910 rsn_ie_len
= mwifiex_append_rsn_ie_wpa_wpa2(priv
, &pos
);
911 if (rsn_ie_len
== -1)
913 cmd_append_size
+= rsn_ie_len
;
916 if (adapter
->adhoc_11n_enabled
) {
918 ht_cap
= (struct mwifiex_ie_types_htcap
*) pos
;
920 sizeof(struct mwifiex_ie_types_htcap
));
921 ht_cap
->header
.type
=
922 cpu_to_le16(WLAN_EID_HT_CAPABILITY
);
924 cpu_to_le16(sizeof(struct ieee80211_ht_cap
));
925 ht_cap_info
= le16_to_cpu(ht_cap
->ht_cap
.cap_info
);
927 ht_cap_info
|= IEEE80211_HT_CAP_SGI_20
;
928 if (adapter
->chan_offset
) {
929 ht_cap_info
|= IEEE80211_HT_CAP_SGI_40
;
930 ht_cap_info
|= IEEE80211_HT_CAP_DSSSCCK40
;
931 ht_cap_info
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
932 SETHT_MCS32(ht_cap
->ht_cap
.mcs
.rx_mask
);
935 ht_cap
->ht_cap
.ampdu_params_info
936 = IEEE80211_HT_MAX_AMPDU_64K
;
937 ht_cap
->ht_cap
.mcs
.rx_mask
[0] = 0xff;
938 pos
+= sizeof(struct mwifiex_ie_types_htcap
);
940 sizeof(struct mwifiex_ie_types_htcap
);
943 ht_info
= (struct mwifiex_ie_types_htinfo
*) pos
;
945 sizeof(struct mwifiex_ie_types_htinfo
));
946 ht_info
->header
.type
=
947 cpu_to_le16(WLAN_EID_HT_INFORMATION
);
948 ht_info
->header
.len
=
949 cpu_to_le16(sizeof(struct ieee80211_ht_info
));
950 ht_info
->ht_info
.control_chan
=
951 (u8
) priv
->curr_bss_params
.bss_descriptor
.
953 if (adapter
->chan_offset
) {
954 ht_info
->ht_info
.ht_param
=
955 adapter
->chan_offset
;
956 ht_info
->ht_info
.ht_param
|=
957 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY
;
959 ht_info
->ht_info
.operation_mode
=
960 cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT
);
961 ht_info
->ht_info
.basic_set
[0] = 0xff;
962 pos
+= sizeof(struct mwifiex_ie_types_htinfo
);
964 sizeof(struct mwifiex_ie_types_htinfo
);
968 cmd
->size
= cpu_to_le16((u16
)
969 (sizeof(struct host_cmd_ds_802_11_ad_hoc_start
)
970 + S_DS_GEN
+ cmd_append_size
));
972 if (adapter
->adhoc_start_band
== BAND_B
)
973 tmp_cap
&= ~WLAN_CAPABILITY_SHORT_SLOT_TIME
;
975 tmp_cap
|= WLAN_CAPABILITY_SHORT_SLOT_TIME
;
977 adhoc_start
->cap_info_bitmap
= cpu_to_le16(tmp_cap
);
983 * This function prepares command for ad-hoc join.
985 * Most of the parameters are set up by copying from the target BSS descriptor
986 * from the scan response.
988 * In addition, the following TLVs are added -
990 * - Vendor specific IE
994 * Preparation also includes -
995 * - Setting command ID and proper size
996 * - Ensuring correct endian-ness
999 mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private
*priv
,
1000 struct host_cmd_ds_command
*cmd
,
1001 struct mwifiex_bssdescriptor
*bss_desc
)
1004 struct host_cmd_ds_802_11_ad_hoc_join
*adhoc_join
=
1005 &cmd
->params
.adhoc_join
;
1006 struct mwifiex_ie_types_chan_list_param_set
*chan_tlv
;
1007 u32 cmd_append_size
= 0;
1009 u32 i
, rates_size
= 0;
1010 u16 curr_pkt_filter
;
1013 sizeof(struct host_cmd_ds_802_11_ad_hoc_join
);
1015 /* Use G protection */
1016 #define USE_G_PROTECTION 0x02
1017 if (bss_desc
->erp_flags
& USE_G_PROTECTION
) {
1020 curr_pkt_filter
| HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON
;
1022 if (mwifiex_send_cmd_async(priv
, HostCmd_CMD_MAC_CONTROL
,
1023 HostCmd_ACT_GEN_SET
, 0,
1024 &curr_pkt_filter
)) {
1025 dev_err(priv
->adapter
->dev
,
1026 "ADHOC_J_CMD: G Protection config failed\n");
1031 priv
->attempted_bss_desc
= bss_desc
;
1033 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_JOIN
);
1035 adhoc_join
->bss_descriptor
.bss_mode
= HostCmd_BSS_MODE_IBSS
;
1037 adhoc_join
->bss_descriptor
.beacon_period
1038 = cpu_to_le16(bss_desc
->beacon_period
);
1040 memcpy(&adhoc_join
->bss_descriptor
.bssid
,
1041 &bss_desc
->mac_address
, ETH_ALEN
);
1043 memcpy(&adhoc_join
->bss_descriptor
.ssid
,
1044 &bss_desc
->ssid
.ssid
, bss_desc
->ssid
.ssid_len
);
1046 memcpy(&adhoc_join
->bss_descriptor
.phy_param_set
,
1047 &bss_desc
->phy_param_set
,
1048 sizeof(union ieee_types_phy_param_set
));
1050 memcpy(&adhoc_join
->bss_descriptor
.ss_param_set
,
1051 &bss_desc
->ss_param_set
, sizeof(union ieee_types_ss_param_set
));
1053 tmp_cap
= bss_desc
->cap_info_bitmap
;
1055 tmp_cap
&= CAPINFO_MASK
;
1057 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_J_CMD: tmp_cap=%4X"
1058 " CAPINFO_MASK=%4lX\n", tmp_cap
, CAPINFO_MASK
);
1060 /* Information on BSSID descriptor passed to FW */
1061 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_J_CMD: BSSID = %pM, SSID = %s\n",
1062 adhoc_join
->bss_descriptor
.bssid
,
1063 adhoc_join
->bss_descriptor
.ssid
);
1065 for (i
= 0; bss_desc
->supported_rates
[i
] &&
1066 i
< MWIFIEX_SUPPORTED_RATES
;
1071 /* Copy Data Rates from the Rates recorded in scan response */
1072 memset(adhoc_join
->bss_descriptor
.data_rates
, 0,
1073 sizeof(adhoc_join
->bss_descriptor
.data_rates
));
1074 memcpy(adhoc_join
->bss_descriptor
.data_rates
,
1075 bss_desc
->supported_rates
, rates_size
);
1077 /* Copy the adhoc join rates into Current BSS state structure */
1078 priv
->curr_bss_params
.num_of_rates
= rates_size
;
1079 memcpy(&priv
->curr_bss_params
.data_rates
, bss_desc
->supported_rates
,
1082 /* Copy the channel information */
1083 priv
->curr_bss_params
.bss_descriptor
.channel
= bss_desc
->channel
;
1084 priv
->curr_bss_params
.band
= (u8
) bss_desc
->bss_band
;
1086 if (priv
->sec_info
.wep_status
== MWIFIEX_802_11_WEP_ENABLED
1087 || priv
->sec_info
.wpa_enabled
)
1088 tmp_cap
|= WLAN_CAPABILITY_PRIVACY
;
1090 if (IS_SUPPORT_MULTI_BANDS(priv
->adapter
)) {
1091 /* Append a channel TLV */
1092 chan_tlv
= (struct mwifiex_ie_types_chan_list_param_set
*) pos
;
1093 chan_tlv
->header
.type
= cpu_to_le16(TLV_TYPE_CHANLIST
);
1094 chan_tlv
->header
.len
=
1095 cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set
));
1097 memset(chan_tlv
->chan_scan_param
, 0x00,
1098 sizeof(struct mwifiex_chan_scan_param_set
));
1099 chan_tlv
->chan_scan_param
[0].chan_number
=
1100 (bss_desc
->phy_param_set
.ds_param_set
.current_chan
);
1101 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_J_CMD: TLV Chan = %d\n",
1102 chan_tlv
->chan_scan_param
[0].chan_number
);
1104 chan_tlv
->chan_scan_param
[0].radio_type
=
1105 mwifiex_band_to_radio_type((u8
) bss_desc
->bss_band
);
1107 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_J_CMD: TLV Band = %d\n",
1108 chan_tlv
->chan_scan_param
[0].radio_type
);
1109 pos
+= sizeof(chan_tlv
->header
) +
1110 sizeof(struct mwifiex_chan_scan_param_set
);
1111 cmd_append_size
+= sizeof(chan_tlv
->header
) +
1112 sizeof(struct mwifiex_chan_scan_param_set
);
1115 if (priv
->sec_info
.wpa_enabled
)
1116 rsn_ie_len
= mwifiex_append_rsn_ie_wpa_wpa2(priv
, &pos
);
1117 if (rsn_ie_len
== -1)
1119 cmd_append_size
+= rsn_ie_len
;
1121 if (ISSUPP_11NENABLED(priv
->adapter
->fw_cap_info
))
1122 cmd_append_size
+= mwifiex_cmd_append_11n_tlv(priv
,
1125 /* Append vendor specific IE TLV */
1126 cmd_append_size
+= mwifiex_cmd_append_vsie_tlv(priv
,
1127 MWIFIEX_VSIE_MASK_ADHOC
, &pos
);
1129 cmd
->size
= cpu_to_le16((u16
)
1130 (sizeof(struct host_cmd_ds_802_11_ad_hoc_join
)
1131 + S_DS_GEN
+ cmd_append_size
));
1133 adhoc_join
->bss_descriptor
.cap_info_bitmap
= cpu_to_le16(tmp_cap
);
1139 * This function handles the command response of ad-hoc start and
1142 * The function generates a device-connected event to notify
1143 * the applications, in case of successful ad-hoc start/join, and
1144 * saves the beacon buffer.
1146 int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private
*priv
,
1147 struct host_cmd_ds_command
*resp
)
1150 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1151 struct host_cmd_ds_802_11_ad_hoc_result
*adhoc_result
;
1152 struct mwifiex_bssdescriptor
*bss_desc
;
1154 adhoc_result
= &resp
->params
.adhoc_result
;
1156 bss_desc
= priv
->attempted_bss_desc
;
1158 /* Join result code 0 --> SUCCESS */
1159 if (le16_to_cpu(resp
->result
)) {
1160 dev_err(priv
->adapter
->dev
, "ADHOC_RESP: failed\n");
1161 if (priv
->media_connected
)
1162 mwifiex_reset_connect_state(priv
);
1164 memset(&priv
->curr_bss_params
.bss_descriptor
,
1165 0x00, sizeof(struct mwifiex_bssdescriptor
));
1171 /* Send a Media Connected event, according to the Spec */
1172 priv
->media_connected
= true;
1174 if (le16_to_cpu(resp
->command
) == HostCmd_CMD_802_11_AD_HOC_START
) {
1175 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_S_RESP %s\n",
1176 bss_desc
->ssid
.ssid
);
1178 /* Update the created network descriptor with the new BSSID */
1179 memcpy(bss_desc
->mac_address
,
1180 adhoc_result
->bssid
, ETH_ALEN
);
1182 priv
->adhoc_state
= ADHOC_STARTED
;
1185 * Now the join cmd should be successful.
1186 * If BSSID has changed use SSID to compare instead of BSSID
1188 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_J_RESP %s\n",
1189 bss_desc
->ssid
.ssid
);
1192 * Make a copy of current BSSID descriptor, only needed for
1193 * join since the current descriptor is already being used
1196 memcpy(&priv
->curr_bss_params
.bss_descriptor
,
1197 bss_desc
, sizeof(struct mwifiex_bssdescriptor
));
1199 priv
->adhoc_state
= ADHOC_JOINED
;
1202 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_RESP: channel = %d\n",
1203 priv
->adhoc_channel
);
1204 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_RESP: BSSID = %pM\n",
1205 priv
->curr_bss_params
.bss_descriptor
.mac_address
);
1207 if (!netif_carrier_ok(priv
->netdev
))
1208 netif_carrier_on(priv
->netdev
);
1209 if (netif_queue_stopped(priv
->netdev
))
1210 netif_wake_queue(priv
->netdev
);
1212 mwifiex_save_curr_bcn(priv
);
1215 /* Need to indicate IOCTL complete */
1216 if (adapter
->curr_cmd
->wait_q_enabled
) {
1218 adapter
->cmd_wait_q
.status
= -1;
1220 adapter
->cmd_wait_q
.status
= 0;
1228 * This function associates to a specific BSS discovered in a scan.
1230 * It clears any past association response stored for application
1231 * retrieval and calls the command preparation routine to send the
1232 * command to firmware.
1234 int mwifiex_associate(struct mwifiex_private
*priv
,
1235 struct mwifiex_bssdescriptor
*bss_desc
)
1237 u8 current_bssid
[ETH_ALEN
];
1239 /* Return error if the adapter or table entry is not marked as infra */
1240 if ((priv
->bss_mode
!= NL80211_IFTYPE_STATION
) ||
1241 (bss_desc
->bss_mode
!= NL80211_IFTYPE_STATION
))
1244 memcpy(¤t_bssid
,
1245 &priv
->curr_bss_params
.bss_descriptor
.mac_address
,
1246 sizeof(current_bssid
));
1248 /* Clear any past association response stored for application
1250 priv
->assoc_rsp_size
= 0;
1252 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_ASSOCIATE
,
1253 HostCmd_ACT_GEN_SET
, 0, bss_desc
);
1257 * This function starts an ad-hoc network.
1259 * It calls the command preparation routine to send the command to firmware.
1262 mwifiex_adhoc_start(struct mwifiex_private
*priv
,
1263 struct mwifiex_802_11_ssid
*adhoc_ssid
)
1265 dev_dbg(priv
->adapter
->dev
, "info: Adhoc Channel = %d\n",
1266 priv
->adhoc_channel
);
1267 dev_dbg(priv
->adapter
->dev
, "info: curr_bss_params.channel = %d\n",
1268 priv
->curr_bss_params
.bss_descriptor
.channel
);
1269 dev_dbg(priv
->adapter
->dev
, "info: curr_bss_params.band = %d\n",
1270 priv
->curr_bss_params
.band
);
1272 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_AD_HOC_START
,
1273 HostCmd_ACT_GEN_SET
, 0, adhoc_ssid
);
1277 * This function joins an ad-hoc network found in a previous scan.
1279 * It calls the command preparation routine to send the command to firmware,
1280 * if already not connected to the requested SSID.
1282 int mwifiex_adhoc_join(struct mwifiex_private
*priv
,
1283 struct mwifiex_bssdescriptor
*bss_desc
)
1285 dev_dbg(priv
->adapter
->dev
, "info: adhoc join: curr_bss ssid =%s\n",
1286 priv
->curr_bss_params
.bss_descriptor
.ssid
.ssid
);
1287 dev_dbg(priv
->adapter
->dev
, "info: adhoc join: curr_bss ssid_len =%u\n",
1288 priv
->curr_bss_params
.bss_descriptor
.ssid
.ssid_len
);
1289 dev_dbg(priv
->adapter
->dev
, "info: adhoc join: ssid =%s\n",
1290 bss_desc
->ssid
.ssid
);
1291 dev_dbg(priv
->adapter
->dev
, "info: adhoc join: ssid_len =%u\n",
1292 bss_desc
->ssid
.ssid_len
);
1294 /* Check if the requested SSID is already joined */
1295 if (priv
->curr_bss_params
.bss_descriptor
.ssid
.ssid_len
&&
1296 !mwifiex_ssid_cmp(&bss_desc
->ssid
,
1297 &priv
->curr_bss_params
.bss_descriptor
.ssid
) &&
1298 (priv
->curr_bss_params
.bss_descriptor
.bss_mode
==
1299 NL80211_IFTYPE_ADHOC
)) {
1300 dev_dbg(priv
->adapter
->dev
, "info: ADHOC_J_CMD: new ad-hoc SSID"
1301 " is the same as current; not attempting to re-join\n");
1305 dev_dbg(priv
->adapter
->dev
, "info: curr_bss_params.channel = %d\n",
1306 priv
->curr_bss_params
.bss_descriptor
.channel
);
1307 dev_dbg(priv
->adapter
->dev
, "info: curr_bss_params.band = %c\n",
1308 priv
->curr_bss_params
.band
);
1310 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_AD_HOC_JOIN
,
1311 HostCmd_ACT_GEN_SET
, 0, bss_desc
);
1315 * This function deauthenticates/disconnects from infra network by sending
1316 * deauthentication request.
1318 static int mwifiex_deauthenticate_infra(struct mwifiex_private
*priv
, u8
*mac
)
1320 u8 mac_address
[ETH_ALEN
];
1322 u8 zero_mac
[ETH_ALEN
] = { 0, 0, 0, 0, 0, 0 };
1325 if (!memcmp(mac
, zero_mac
, sizeof(zero_mac
)))
1326 memcpy((u8
*) &mac_address
,
1327 (u8
*) &priv
->curr_bss_params
.bss_descriptor
.
1328 mac_address
, ETH_ALEN
);
1330 memcpy((u8
*) &mac_address
, (u8
*) mac
, ETH_ALEN
);
1332 memcpy((u8
*) &mac_address
, (u8
*) &priv
->curr_bss_params
.
1333 bss_descriptor
.mac_address
, ETH_ALEN
);
1336 ret
= mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_DEAUTHENTICATE
,
1337 HostCmd_ACT_GEN_SET
, 0, &mac_address
);
1343 * This function deauthenticates/disconnects from a BSS.
1345 * In case of infra made, it sends deauthentication request, and
1346 * in case of ad-hoc mode, a stop network request is sent to the firmware.
1348 int mwifiex_deauthenticate(struct mwifiex_private
*priv
, u8
*mac
)
1352 if (priv
->media_connected
) {
1353 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1354 ret
= mwifiex_deauthenticate_infra(priv
, mac
);
1355 } else if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
) {
1356 ret
= mwifiex_send_cmd_sync(priv
,
1357 HostCmd_CMD_802_11_AD_HOC_STOP
,
1358 HostCmd_ACT_GEN_SET
, 0, NULL
);
1364 EXPORT_SYMBOL_GPL(mwifiex_deauthenticate
);
1367 * This function converts band to radio type used in channel TLV.
1370 mwifiex_band_to_radio_type(u8 band
)
1375 case BAND_A
| BAND_AN
:
1376 return HostCmd_SCAN_RADIO_TYPE_A
;
1379 case BAND_B
| BAND_G
:
1381 return HostCmd_SCAN_RADIO_TYPE_BG
;