2 * Marvell Wireless LAN device driver: 802.11n
4 * Copyright (C) 2011-2014, 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.
29 * Fills HT capability information field, AMPDU Parameters field, HT extended
30 * capability field, and supported MCS set fields.
32 * HT capability information field, AMPDU Parameters field, supported MCS set
33 * fields are retrieved from cfg80211 stack
35 * RD responder bit to set to clear in the extended capability header.
37 int mwifiex_fill_cap_info(struct mwifiex_private
*priv
, u8 radio_type
,
38 struct ieee80211_ht_cap
*ht_cap
)
40 uint16_t ht_ext_cap
= le16_to_cpu(ht_cap
->extended_ht_cap_info
);
41 struct ieee80211_supported_band
*sband
=
42 priv
->wdev
.wiphy
->bands
[radio_type
];
44 if (WARN_ON_ONCE(!sband
)) {
45 mwifiex_dbg(priv
->adapter
, ERROR
, "Invalid radio type!\n");
49 ht_cap
->ampdu_params_info
=
50 (sband
->ht_cap
.ampdu_factor
&
51 IEEE80211_HT_AMPDU_PARM_FACTOR
) |
52 ((sband
->ht_cap
.ampdu_density
<<
53 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT
) &
54 IEEE80211_HT_AMPDU_PARM_DENSITY
);
56 memcpy((u8
*)&ht_cap
->mcs
, &sband
->ht_cap
.mcs
,
57 sizeof(sband
->ht_cap
.mcs
));
59 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
60 (sband
->ht_cap
.cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
&&
61 (priv
->adapter
->sec_chan_offset
!=
62 IEEE80211_HT_PARAM_CHA_SEC_NONE
)))
63 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
64 SETHT_MCS32(ht_cap
->mcs
.rx_mask
);
66 /* Clear RD responder bit */
67 ht_ext_cap
&= ~IEEE80211_HT_EXT_CAP_RD_RESPONDER
;
69 ht_cap
->cap_info
= cpu_to_le16(sband
->ht_cap
.cap
);
70 ht_cap
->extended_ht_cap_info
= cpu_to_le16(ht_ext_cap
);
72 if (ISSUPP_BEAMFORMING(priv
->adapter
->hw_dot_11n_dev_cap
))
73 ht_cap
->tx_BF_cap_info
= cpu_to_le32(MWIFIEX_DEF_11N_TX_BF_CAP
);
79 * This function returns the pointer to an entry in BA Stream
80 * table which matches the requested BA status.
82 static struct mwifiex_tx_ba_stream_tbl
*
83 mwifiex_get_ba_status(struct mwifiex_private
*priv
,
84 enum mwifiex_ba_status ba_status
)
86 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
;
89 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
90 list_for_each_entry(tx_ba_tsr_tbl
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
91 if (tx_ba_tsr_tbl
->ba_status
== ba_status
) {
92 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
,
97 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
102 * This function handles the command response of delete a block
105 * The function checks the response success status and takes action
106 * accordingly (send an add BA request in case of success, or recreate
107 * the deleted stream in case of failure, if the add BA was also
110 int mwifiex_ret_11n_delba(struct mwifiex_private
*priv
,
111 struct host_cmd_ds_command
*resp
)
114 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tbl
;
115 struct host_cmd_ds_11n_delba
*del_ba
= &resp
->params
.del_ba
;
116 uint16_t del_ba_param_set
= le16_to_cpu(del_ba
->del_ba_param_set
);
118 tid
= del_ba_param_set
>> DELBA_TID_POS
;
119 if (del_ba
->del_result
== BA_RESULT_SUCCESS
) {
120 mwifiex_del_ba_tbl(priv
, tid
, del_ba
->peer_mac_addr
,
122 INITIATOR_BIT(del_ba_param_set
));
124 tx_ba_tbl
= mwifiex_get_ba_status(priv
, BA_SETUP_INPROGRESS
);
126 mwifiex_send_addba(priv
, tx_ba_tbl
->tid
,
129 * In case of failure, recreate the deleted stream in case
130 * we initiated the ADDBA
132 if (!INITIATOR_BIT(del_ba_param_set
))
135 mwifiex_create_ba_tbl(priv
, del_ba
->peer_mac_addr
, tid
,
136 BA_SETUP_INPROGRESS
);
138 tx_ba_tbl
= mwifiex_get_ba_status(priv
, BA_SETUP_INPROGRESS
);
141 mwifiex_del_ba_tbl(priv
, tx_ba_tbl
->tid
, tx_ba_tbl
->ra
,
142 TYPE_DELBA_SENT
, true);
149 * This function handles the command response of add a block
152 * Handling includes changing the header fields to CPU formats, checking
153 * the response success status and taking actions accordingly (delete the
154 * BA stream table in case of failure).
156 int mwifiex_ret_11n_addba_req(struct mwifiex_private
*priv
,
157 struct host_cmd_ds_command
*resp
)
160 struct host_cmd_ds_11n_addba_rsp
*add_ba_rsp
= &resp
->params
.add_ba_rsp
;
161 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tbl
;
162 struct mwifiex_ra_list_tbl
*ra_list
;
163 u16 block_ack_param_set
= le16_to_cpu(add_ba_rsp
->block_ack_param_set
);
165 add_ba_rsp
->ssn
= cpu_to_le16((le16_to_cpu(add_ba_rsp
->ssn
))
168 tid
= (block_ack_param_set
& IEEE80211_ADDBA_PARAM_TID_MASK
)
169 >> BLOCKACKPARAM_TID_POS
;
171 tid_down
= mwifiex_wmm_downgrade_tid(priv
, tid
);
172 ra_list
= mwifiex_wmm_get_ralist_node(priv
, tid_down
, add_ba_rsp
->
174 if (le16_to_cpu(add_ba_rsp
->status_code
) != BA_RESULT_SUCCESS
) {
176 ra_list
->ba_status
= BA_SETUP_NONE
;
177 ra_list
->amsdu_in_ampdu
= false;
179 mwifiex_del_ba_tbl(priv
, tid
, add_ba_rsp
->peer_mac_addr
,
180 TYPE_DELBA_SENT
, true);
181 if (add_ba_rsp
->add_rsp_result
!= BA_RESULT_TIMEOUT
)
182 priv
->aggr_prio_tbl
[tid
].ampdu_ap
=
183 BA_STREAM_NOT_ALLOWED
;
187 tx_ba_tbl
= mwifiex_get_ba_tbl(priv
, tid
, add_ba_rsp
->peer_mac_addr
);
189 mwifiex_dbg(priv
->adapter
, EVENT
, "info: BA stream complete\n");
190 tx_ba_tbl
->ba_status
= BA_SETUP_COMPLETE
;
191 if ((block_ack_param_set
& BLOCKACKPARAM_AMSDU_SUPP_MASK
) &&
192 priv
->add_ba_param
.tx_amsdu
&&
193 (priv
->aggr_prio_tbl
[tid
].amsdu
!= BA_STREAM_NOT_ALLOWED
))
194 tx_ba_tbl
->amsdu
= true;
196 tx_ba_tbl
->amsdu
= false;
198 ra_list
->amsdu_in_ampdu
= tx_ba_tbl
->amsdu
;
199 ra_list
->ba_status
= BA_SETUP_COMPLETE
;
202 mwifiex_dbg(priv
->adapter
, ERROR
, "BA stream not created\n");
209 * This function prepares command of reconfigure Tx buffer.
211 * Preparation includes -
212 * - Setting command ID, action and proper size
213 * - Setting Tx buffer size (for SET only)
214 * - Ensuring correct endian-ness
216 int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private
*priv
,
217 struct host_cmd_ds_command
*cmd
, int cmd_action
,
220 struct host_cmd_ds_txbuf_cfg
*tx_buf
= &cmd
->params
.tx_buf
;
221 u16 action
= (u16
) cmd_action
;
223 cmd
->command
= cpu_to_le16(HostCmd_CMD_RECONFIGURE_TX_BUFF
);
225 cpu_to_le16(sizeof(struct host_cmd_ds_txbuf_cfg
) + S_DS_GEN
);
226 tx_buf
->action
= cpu_to_le16(action
);
228 case HostCmd_ACT_GEN_SET
:
229 mwifiex_dbg(priv
->adapter
, CMD
,
230 "cmd: set tx_buf=%d\n", *buf_size
);
231 tx_buf
->buff_size
= cpu_to_le16(*buf_size
);
233 case HostCmd_ACT_GEN_GET
:
235 tx_buf
->buff_size
= 0;
242 * This function prepares command of AMSDU aggregation control.
244 * Preparation includes -
245 * - Setting command ID, action and proper size
246 * - Setting AMSDU control parameters (for SET only)
247 * - Ensuring correct endian-ness
249 int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command
*cmd
,
251 struct mwifiex_ds_11n_amsdu_aggr_ctrl
*aa_ctrl
)
253 struct host_cmd_ds_amsdu_aggr_ctrl
*amsdu_ctrl
=
254 &cmd
->params
.amsdu_aggr_ctrl
;
255 u16 action
= (u16
) cmd_action
;
257 cmd
->command
= cpu_to_le16(HostCmd_CMD_AMSDU_AGGR_CTRL
);
258 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_amsdu_aggr_ctrl
)
260 amsdu_ctrl
->action
= cpu_to_le16(action
);
262 case HostCmd_ACT_GEN_SET
:
263 amsdu_ctrl
->enable
= cpu_to_le16(aa_ctrl
->enable
);
264 amsdu_ctrl
->curr_buf_size
= 0;
266 case HostCmd_ACT_GEN_GET
:
268 amsdu_ctrl
->curr_buf_size
= 0;
275 * This function prepares 11n configuration command.
277 * Preparation includes -
278 * - Setting command ID, action and proper size
279 * - Setting HT Tx capability and HT Tx information fields
280 * - Ensuring correct endian-ness
282 int mwifiex_cmd_11n_cfg(struct mwifiex_private
*priv
,
283 struct host_cmd_ds_command
*cmd
, u16 cmd_action
,
284 struct mwifiex_ds_11n_tx_cfg
*txcfg
)
286 struct host_cmd_ds_11n_cfg
*htcfg
= &cmd
->params
.htcfg
;
288 cmd
->command
= cpu_to_le16(HostCmd_CMD_11N_CFG
);
289 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_11n_cfg
) + S_DS_GEN
);
290 htcfg
->action
= cpu_to_le16(cmd_action
);
291 htcfg
->ht_tx_cap
= cpu_to_le16(txcfg
->tx_htcap
);
292 htcfg
->ht_tx_info
= cpu_to_le16(txcfg
->tx_htinfo
);
294 if (priv
->adapter
->is_hw_11ac_capable
)
295 htcfg
->misc_config
= cpu_to_le16(txcfg
->misc_config
);
301 * This function appends an 11n TLV to a buffer.
303 * Buffer allocation is responsibility of the calling
304 * function. No size validation is made here.
306 * The function fills up the following sections, if applicable -
308 * - HT information IE (with channel list)
309 * - 20/40 BSS Coexistence IE
310 * - HT Extended Capabilities IE
313 mwifiex_cmd_append_11n_tlv(struct mwifiex_private
*priv
,
314 struct mwifiex_bssdescriptor
*bss_desc
,
317 struct mwifiex_ie_types_htcap
*ht_cap
;
318 struct mwifiex_ie_types_htinfo
*ht_info
;
319 struct mwifiex_ie_types_chan_list_param_set
*chan_list
;
320 struct mwifiex_ie_types_2040bssco
*bss_co_2040
;
321 struct mwifiex_ie_types_extcap
*ext_cap
;
323 struct ieee80211_supported_band
*sband
;
324 struct ieee_types_header
*hdr
;
327 if (!buffer
|| !*buffer
)
330 radio_type
= mwifiex_band_to_radio_type((u8
) bss_desc
->bss_band
);
331 sband
= priv
->wdev
.wiphy
->bands
[radio_type
];
333 if (bss_desc
->bcn_ht_cap
) {
334 ht_cap
= (struct mwifiex_ie_types_htcap
*) *buffer
;
335 memset(ht_cap
, 0, sizeof(struct mwifiex_ie_types_htcap
));
336 ht_cap
->header
.type
= cpu_to_le16(WLAN_EID_HT_CAPABILITY
);
338 cpu_to_le16(sizeof(struct ieee80211_ht_cap
));
339 memcpy((u8
*) ht_cap
+ sizeof(struct mwifiex_ie_types_header
),
340 (u8
*)bss_desc
->bcn_ht_cap
,
341 le16_to_cpu(ht_cap
->header
.len
));
343 mwifiex_fill_cap_info(priv
, radio_type
, &ht_cap
->ht_cap
);
344 /* Update HT40 capability from current channel information */
345 if (bss_desc
->bcn_ht_oper
) {
346 u8 ht_param
= bss_desc
->bcn_ht_oper
->ht_param
;
348 mwifiex_band_to_radio_type(bss_desc
->bss_band
);
350 ieee80211_channel_to_frequency(bss_desc
->channel
,
352 struct ieee80211_channel
*chan
=
353 ieee80211_get_channel(priv
->adapter
->wiphy
, freq
);
355 switch (ht_param
& IEEE80211_HT_PARAM_CHA_SEC_OFFSET
) {
356 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
357 if (chan
->flags
& IEEE80211_CHAN_NO_HT40PLUS
) {
358 ht_cap
->ht_cap
.cap_info
&=
359 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
360 ht_cap
->ht_cap
.cap_info
&=
361 ~IEEE80211_HT_CAP_SGI_40
;
364 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
365 if (chan
->flags
& IEEE80211_CHAN_NO_HT40MINUS
) {
366 ht_cap
->ht_cap
.cap_info
&=
367 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
368 ht_cap
->ht_cap
.cap_info
&=
369 ~IEEE80211_HT_CAP_SGI_40
;
375 *buffer
+= sizeof(struct mwifiex_ie_types_htcap
);
376 ret_len
+= sizeof(struct mwifiex_ie_types_htcap
);
379 if (bss_desc
->bcn_ht_oper
) {
380 if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
) {
381 ht_info
= (struct mwifiex_ie_types_htinfo
*) *buffer
;
383 sizeof(struct mwifiex_ie_types_htinfo
));
384 ht_info
->header
.type
=
385 cpu_to_le16(WLAN_EID_HT_OPERATION
);
386 ht_info
->header
.len
=
388 sizeof(struct ieee80211_ht_operation
));
390 memcpy((u8
*) ht_info
+
391 sizeof(struct mwifiex_ie_types_header
),
392 (u8
*)bss_desc
->bcn_ht_oper
,
393 le16_to_cpu(ht_info
->header
.len
));
395 if (!(sband
->ht_cap
.cap
&
396 IEEE80211_HT_CAP_SUP_WIDTH_20_40
))
397 ht_info
->ht_oper
.ht_param
&=
398 ~(IEEE80211_HT_PARAM_CHAN_WIDTH_ANY
|
399 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
);
401 *buffer
+= sizeof(struct mwifiex_ie_types_htinfo
);
402 ret_len
+= sizeof(struct mwifiex_ie_types_htinfo
);
406 (struct mwifiex_ie_types_chan_list_param_set
*) *buffer
;
408 sizeof(struct mwifiex_ie_types_chan_list_param_set
));
409 chan_list
->header
.type
= cpu_to_le16(TLV_TYPE_CHANLIST
);
410 chan_list
->header
.len
= cpu_to_le16(
411 sizeof(struct mwifiex_ie_types_chan_list_param_set
) -
412 sizeof(struct mwifiex_ie_types_header
));
413 chan_list
->chan_scan_param
[0].chan_number
=
414 bss_desc
->bcn_ht_oper
->primary_chan
;
415 chan_list
->chan_scan_param
[0].radio_type
=
416 mwifiex_band_to_radio_type((u8
) bss_desc
->bss_band
);
418 if (sband
->ht_cap
.cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
&&
419 bss_desc
->bcn_ht_oper
->ht_param
&
420 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY
)
421 SET_SECONDARYCHAN(chan_list
->chan_scan_param
[0].
423 (bss_desc
->bcn_ht_oper
->ht_param
&
424 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
));
426 *buffer
+= sizeof(struct mwifiex_ie_types_chan_list_param_set
);
427 ret_len
+= sizeof(struct mwifiex_ie_types_chan_list_param_set
);
430 if (bss_desc
->bcn_bss_co_2040
) {
431 bss_co_2040
= (struct mwifiex_ie_types_2040bssco
*) *buffer
;
432 memset(bss_co_2040
, 0,
433 sizeof(struct mwifiex_ie_types_2040bssco
));
434 bss_co_2040
->header
.type
= cpu_to_le16(WLAN_EID_BSS_COEX_2040
);
435 bss_co_2040
->header
.len
=
436 cpu_to_le16(sizeof(bss_co_2040
->bss_co_2040
));
438 memcpy((u8
*) bss_co_2040
+
439 sizeof(struct mwifiex_ie_types_header
),
440 bss_desc
->bcn_bss_co_2040
+
441 sizeof(struct ieee_types_header
),
442 le16_to_cpu(bss_co_2040
->header
.len
));
444 *buffer
+= sizeof(struct mwifiex_ie_types_2040bssco
);
445 ret_len
+= sizeof(struct mwifiex_ie_types_2040bssco
);
448 if (bss_desc
->bcn_ext_cap
) {
449 hdr
= (void *)bss_desc
->bcn_ext_cap
;
450 ext_cap
= (struct mwifiex_ie_types_extcap
*) *buffer
;
451 memset(ext_cap
, 0, sizeof(struct mwifiex_ie_types_extcap
));
452 ext_cap
->header
.type
= cpu_to_le16(WLAN_EID_EXT_CAPABILITY
);
453 ext_cap
->header
.len
= cpu_to_le16(hdr
->len
);
455 memcpy((u8
*)ext_cap
->ext_capab
,
456 bss_desc
->bcn_ext_cap
+ sizeof(struct ieee_types_header
),
457 le16_to_cpu(ext_cap
->header
.len
));
460 ext_cap
->ext_capab
[3] & WLAN_EXT_CAPA4_INTERWORKING_ENABLED
)
461 priv
->hs2_enabled
= true;
463 priv
->hs2_enabled
= false;
465 *buffer
+= sizeof(struct mwifiex_ie_types_extcap
) + hdr
->len
;
466 ret_len
+= sizeof(struct mwifiex_ie_types_extcap
) + hdr
->len
;
473 * This function checks if the given pointer is valid entry of
474 * Tx BA Stream table.
476 static int mwifiex_is_tx_ba_stream_ptr_valid(struct mwifiex_private
*priv
,
477 struct mwifiex_tx_ba_stream_tbl
*tx_tbl_ptr
)
479 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
;
481 list_for_each_entry(tx_ba_tsr_tbl
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
482 if (tx_ba_tsr_tbl
== tx_tbl_ptr
)
490 * This function deletes the given entry in Tx BA Stream table.
492 * The function also performs a validity check on the supplied
493 * pointer before trying to delete.
495 void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private
*priv
,
496 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
)
498 if (!tx_ba_tsr_tbl
&&
499 mwifiex_is_tx_ba_stream_ptr_valid(priv
, tx_ba_tsr_tbl
))
502 mwifiex_dbg(priv
->adapter
, INFO
,
503 "info: tx_ba_tsr_tbl %p\n", tx_ba_tsr_tbl
);
505 list_del(&tx_ba_tsr_tbl
->list
);
507 kfree(tx_ba_tsr_tbl
);
511 * This function deletes all the entries in Tx BA Stream table.
513 void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private
*priv
)
516 struct mwifiex_tx_ba_stream_tbl
*del_tbl_ptr
, *tmp_node
;
519 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
520 list_for_each_entry_safe(del_tbl_ptr
, tmp_node
,
521 &priv
->tx_ba_stream_tbl_ptr
, list
)
522 mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv
, del_tbl_ptr
);
523 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
525 INIT_LIST_HEAD(&priv
->tx_ba_stream_tbl_ptr
);
527 for (i
= 0; i
< MAX_NUM_TID
; ++i
)
528 priv
->aggr_prio_tbl
[i
].ampdu_ap
=
529 priv
->aggr_prio_tbl
[i
].ampdu_user
;
533 * This function returns the pointer to an entry in BA Stream
534 * table which matches the given RA/TID pair.
536 struct mwifiex_tx_ba_stream_tbl
*
537 mwifiex_get_ba_tbl(struct mwifiex_private
*priv
, int tid
, u8
*ra
)
539 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
;
542 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
543 list_for_each_entry(tx_ba_tsr_tbl
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
544 if (ether_addr_equal_unaligned(tx_ba_tsr_tbl
->ra
, ra
) &&
545 tx_ba_tsr_tbl
->tid
== tid
) {
546 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
,
548 return tx_ba_tsr_tbl
;
551 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
556 * This function creates an entry in Tx BA stream table for the
559 void mwifiex_create_ba_tbl(struct mwifiex_private
*priv
, u8
*ra
, int tid
,
560 enum mwifiex_ba_status ba_status
)
562 struct mwifiex_tx_ba_stream_tbl
*new_node
;
563 struct mwifiex_ra_list_tbl
*ra_list
;
567 if (!mwifiex_get_ba_tbl(priv
, tid
, ra
)) {
568 new_node
= kzalloc(sizeof(struct mwifiex_tx_ba_stream_tbl
),
573 tid_down
= mwifiex_wmm_downgrade_tid(priv
, tid
);
574 ra_list
= mwifiex_wmm_get_ralist_node(priv
, tid_down
, ra
);
576 ra_list
->ba_status
= ba_status
;
577 ra_list
->amsdu_in_ampdu
= false;
579 INIT_LIST_HEAD(&new_node
->list
);
582 new_node
->ba_status
= ba_status
;
583 memcpy(new_node
->ra
, ra
, ETH_ALEN
);
585 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
586 list_add_tail(&new_node
->list
, &priv
->tx_ba_stream_tbl_ptr
);
587 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
592 * This function sends an add BA request to the given TID/RA pair.
594 int mwifiex_send_addba(struct mwifiex_private
*priv
, int tid
, u8
*peer_mac
)
596 struct host_cmd_ds_11n_addba_req add_ba_req
;
597 u32 tx_win_size
= priv
->add_ba_param
.tx_win_size
;
598 static u8 dialog_tok
;
601 u16 block_ack_param_set
;
603 mwifiex_dbg(priv
->adapter
, CMD
, "cmd: %s: tid %d\n", __func__
, tid
);
605 memset(&add_ba_req
, 0, sizeof(add_ba_req
));
607 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
608 ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
609 priv
->adapter
->is_hw_11ac_capable
&&
610 memcmp(priv
->cfg_bssid
, peer_mac
, ETH_ALEN
)) {
611 struct mwifiex_sta_node
*sta_ptr
;
613 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
614 sta_ptr
= mwifiex_get_sta_entry(priv
, peer_mac
);
616 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
617 mwifiex_dbg(priv
->adapter
, ERROR
,
618 "BA setup with unknown TDLS peer %pM!\n",
622 if (sta_ptr
->is_11ac_enabled
)
623 tx_win_size
= MWIFIEX_11AC_STA_AMPDU_DEF_TXWINSIZE
;
624 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
627 block_ack_param_set
= (u16
)((tid
<< BLOCKACKPARAM_TID_POS
) |
628 tx_win_size
<< BLOCKACKPARAM_WINSIZE_POS
|
629 IMMEDIATE_BLOCK_ACK
);
631 /* enable AMSDU inside AMPDU */
632 if (priv
->add_ba_param
.tx_amsdu
&&
633 (priv
->aggr_prio_tbl
[tid
].amsdu
!= BA_STREAM_NOT_ALLOWED
))
634 block_ack_param_set
|= BLOCKACKPARAM_AMSDU_SUPP_MASK
;
636 add_ba_req
.block_ack_param_set
= cpu_to_le16(block_ack_param_set
);
637 add_ba_req
.block_ack_tmo
= cpu_to_le16((u16
)priv
->add_ba_param
.timeout
);
644 add_ba_req
.dialog_token
= dialog_tok
;
645 memcpy(&add_ba_req
.peer_mac_addr
, peer_mac
, ETH_ALEN
);
647 /* We don't wait for the response of this command */
648 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_11N_ADDBA_REQ
,
649 0, 0, &add_ba_req
, false);
655 * This function sends a delete BA request to the given TID/RA pair.
657 int mwifiex_send_delba(struct mwifiex_private
*priv
, int tid
, u8
*peer_mac
,
660 struct host_cmd_ds_11n_delba delba
;
662 uint16_t del_ba_param_set
;
664 memset(&delba
, 0, sizeof(delba
));
665 delba
.del_ba_param_set
= cpu_to_le16(tid
<< DELBA_TID_POS
);
667 del_ba_param_set
= le16_to_cpu(delba
.del_ba_param_set
);
669 del_ba_param_set
|= IEEE80211_DELBA_PARAM_INITIATOR_MASK
;
671 del_ba_param_set
&= ~IEEE80211_DELBA_PARAM_INITIATOR_MASK
;
673 memcpy(&delba
.peer_mac_addr
, peer_mac
, ETH_ALEN
);
675 /* We don't wait for the response of this command */
676 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_11N_DELBA
,
677 HostCmd_ACT_GEN_SET
, 0, &delba
, false);
683 * This function sends delba to specific tid
685 void mwifiex_11n_delba(struct mwifiex_private
*priv
, int tid
)
687 struct mwifiex_rx_reorder_tbl
*rx_reor_tbl_ptr
;
690 spin_lock_irqsave(&priv
->rx_reorder_tbl_lock
, flags
);
691 list_for_each_entry(rx_reor_tbl_ptr
, &priv
->rx_reorder_tbl_ptr
, list
) {
692 if (rx_reor_tbl_ptr
->tid
== tid
) {
693 dev_dbg(priv
->adapter
->dev
,
694 "Send delba to tid=%d, %pM\n",
695 tid
, rx_reor_tbl_ptr
->ta
);
696 mwifiex_send_delba(priv
, tid
, rx_reor_tbl_ptr
->ta
, 0);
701 spin_unlock_irqrestore(&priv
->rx_reorder_tbl_lock
, flags
);
705 * This function handles the command response of a delete BA request.
707 void mwifiex_11n_delete_ba_stream(struct mwifiex_private
*priv
, u8
*del_ba
)
709 struct host_cmd_ds_11n_delba
*cmd_del_ba
=
710 (struct host_cmd_ds_11n_delba
*) del_ba
;
711 uint16_t del_ba_param_set
= le16_to_cpu(cmd_del_ba
->del_ba_param_set
);
714 tid
= del_ba_param_set
>> DELBA_TID_POS
;
716 mwifiex_del_ba_tbl(priv
, tid
, cmd_del_ba
->peer_mac_addr
,
717 TYPE_DELBA_RECEIVE
, INITIATOR_BIT(del_ba_param_set
));
721 * This function retrieves the Rx reordering table.
723 int mwifiex_get_rx_reorder_tbl(struct mwifiex_private
*priv
,
724 struct mwifiex_ds_rx_reorder_tbl
*buf
)
727 struct mwifiex_ds_rx_reorder_tbl
*rx_reo_tbl
= buf
;
728 struct mwifiex_rx_reorder_tbl
*rx_reorder_tbl_ptr
;
732 spin_lock_irqsave(&priv
->rx_reorder_tbl_lock
, flags
);
733 list_for_each_entry(rx_reorder_tbl_ptr
, &priv
->rx_reorder_tbl_ptr
,
735 rx_reo_tbl
->tid
= (u16
) rx_reorder_tbl_ptr
->tid
;
736 memcpy(rx_reo_tbl
->ta
, rx_reorder_tbl_ptr
->ta
, ETH_ALEN
);
737 rx_reo_tbl
->start_win
= rx_reorder_tbl_ptr
->start_win
;
738 rx_reo_tbl
->win_size
= rx_reorder_tbl_ptr
->win_size
;
739 for (i
= 0; i
< rx_reorder_tbl_ptr
->win_size
; ++i
) {
740 if (rx_reorder_tbl_ptr
->rx_reorder_ptr
[i
])
741 rx_reo_tbl
->buffer
[i
] = true;
743 rx_reo_tbl
->buffer
[i
] = false;
748 if (count
>= MWIFIEX_MAX_RX_BASTREAM_SUPPORTED
)
751 spin_unlock_irqrestore(&priv
->rx_reorder_tbl_lock
, flags
);
757 * This function retrieves the Tx BA stream table.
759 int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private
*priv
,
760 struct mwifiex_ds_tx_ba_stream_tbl
*buf
)
762 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
;
763 struct mwifiex_ds_tx_ba_stream_tbl
*rx_reo_tbl
= buf
;
767 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
768 list_for_each_entry(tx_ba_tsr_tbl
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
769 rx_reo_tbl
->tid
= (u16
) tx_ba_tsr_tbl
->tid
;
770 mwifiex_dbg(priv
->adapter
, DATA
, "data: %s tid=%d\n",
771 __func__
, rx_reo_tbl
->tid
);
772 memcpy(rx_reo_tbl
->ra
, tx_ba_tsr_tbl
->ra
, ETH_ALEN
);
773 rx_reo_tbl
->amsdu
= tx_ba_tsr_tbl
->amsdu
;
776 if (count
>= MWIFIEX_MAX_TX_BASTREAM_SUPPORTED
)
779 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
785 * This function retrieves the entry for specific tx BA stream table by RA and
788 void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private
*priv
, u8
*ra
)
790 struct mwifiex_tx_ba_stream_tbl
*tbl
, *tmp
;
796 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
797 list_for_each_entry_safe(tbl
, tmp
, &priv
->tx_ba_stream_tbl_ptr
, list
)
798 if (!memcmp(tbl
->ra
, ra
, ETH_ALEN
))
799 mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv
, tbl
);
800 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
805 /* This function initializes the BlockACK setup information for given
806 * mwifiex_private structure.
808 void mwifiex_set_ba_params(struct mwifiex_private
*priv
)
810 priv
->add_ba_param
.timeout
= MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT
;
812 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
813 priv
->add_ba_param
.tx_win_size
=
814 MWIFIEX_UAP_AMPDU_DEF_TXWINSIZE
;
815 priv
->add_ba_param
.rx_win_size
=
816 MWIFIEX_UAP_AMPDU_DEF_RXWINSIZE
;
818 priv
->add_ba_param
.tx_win_size
=
819 MWIFIEX_STA_AMPDU_DEF_TXWINSIZE
;
820 priv
->add_ba_param
.rx_win_size
=
821 MWIFIEX_STA_AMPDU_DEF_RXWINSIZE
;
824 priv
->add_ba_param
.tx_amsdu
= true;
825 priv
->add_ba_param
.rx_amsdu
= true;
830 u8
mwifiex_get_sec_chan_offset(int chan
)
847 sec_offset
= IEEE80211_HT_PARAM_CHA_SEC_ABOVE
;
861 sec_offset
= IEEE80211_HT_PARAM_CHA_SEC_BELOW
;
865 sec_offset
= IEEE80211_HT_PARAM_CHA_SEC_NONE
;
872 /* This function will send DELBA to entries in the priv's
876 mwifiex_send_delba_txbastream_tbl(struct mwifiex_private
*priv
, u8 tid
)
878 struct mwifiex_adapter
*adapter
= priv
->adapter
;
879 struct mwifiex_tx_ba_stream_tbl
*tx_ba_stream_tbl_ptr
;
881 list_for_each_entry(tx_ba_stream_tbl_ptr
,
882 &priv
->tx_ba_stream_tbl_ptr
, list
) {
883 if (tx_ba_stream_tbl_ptr
->ba_status
== BA_SETUP_COMPLETE
) {
884 if (tid
== tx_ba_stream_tbl_ptr
->tid
) {
885 dev_dbg(adapter
->dev
,
886 "Tx:Send delba to tid=%d, %pM\n", tid
,
887 tx_ba_stream_tbl_ptr
->ra
);
888 mwifiex_send_delba(priv
,
889 tx_ba_stream_tbl_ptr
->tid
,
890 tx_ba_stream_tbl_ptr
->ra
, 1);
897 /* This function updates all the tx_win_size
899 void mwifiex_update_ampdu_txwinsize(struct mwifiex_adapter
*adapter
)
903 struct mwifiex_private
*priv
;
905 for (i
= 0; i
< adapter
->priv_num
; i
++) {
906 if (!adapter
->priv
[i
])
908 priv
= adapter
->priv
[i
];
909 tx_win_size
= priv
->add_ba_param
.tx_win_size
;
911 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
912 priv
->add_ba_param
.tx_win_size
=
913 MWIFIEX_STA_AMPDU_DEF_TXWINSIZE
;
915 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_P2P
)
916 priv
->add_ba_param
.tx_win_size
=
917 MWIFIEX_STA_AMPDU_DEF_TXWINSIZE
;
919 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
)
920 priv
->add_ba_param
.tx_win_size
=
921 MWIFIEX_UAP_AMPDU_DEF_TXWINSIZE
;
923 if (adapter
->coex_win_size
) {
924 if (adapter
->coex_tx_win_size
)
925 priv
->add_ba_param
.tx_win_size
=
926 adapter
->coex_tx_win_size
;
929 if (tx_win_size
!= priv
->add_ba_param
.tx_win_size
) {
930 if (!priv
->media_connected
)
932 for (i
= 0; i
< MAX_NUM_TID
; i
++)
933 mwifiex_send_delba_txbastream_tbl(priv
, i
);