2 * Marvell Wireless LAN device driver: 802.11n
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.
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.
38 mwifiex_fill_cap_info(struct mwifiex_private
*priv
, u8 radio_type
,
39 struct mwifiex_ie_types_htcap
*ht_cap
)
41 uint16_t ht_ext_cap
= le16_to_cpu(ht_cap
->ht_cap
.extended_ht_cap_info
);
42 struct ieee80211_supported_band
*sband
=
43 priv
->wdev
->wiphy
->bands
[radio_type
];
45 ht_cap
->ht_cap
.ampdu_params_info
=
46 (sband
->ht_cap
.ampdu_factor
&
47 IEEE80211_HT_AMPDU_PARM_FACTOR
) |
48 ((sband
->ht_cap
.ampdu_density
<<
49 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT
) &
50 IEEE80211_HT_AMPDU_PARM_DENSITY
);
52 memcpy((u8
*) &ht_cap
->ht_cap
.mcs
, &sband
->ht_cap
.mcs
,
53 sizeof(sband
->ht_cap
.mcs
));
55 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
56 (sband
->ht_cap
.cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
&&
57 (priv
->adapter
->sec_chan_offset
!=
58 IEEE80211_HT_PARAM_CHA_SEC_NONE
)))
59 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
60 SETHT_MCS32(ht_cap
->ht_cap
.mcs
.rx_mask
);
62 /* Clear RD responder bit */
63 ht_ext_cap
&= ~IEEE80211_HT_EXT_CAP_RD_RESPONDER
;
65 ht_cap
->ht_cap
.cap_info
= cpu_to_le16(sband
->ht_cap
.cap
);
66 ht_cap
->ht_cap
.extended_ht_cap_info
= cpu_to_le16(ht_ext_cap
);
68 if (ISSUPP_BEAMFORMING(priv
->adapter
->hw_dot_11n_dev_cap
))
69 ht_cap
->ht_cap
.tx_BF_cap_info
=
70 cpu_to_le32(MWIFIEX_DEF_11N_TX_BF_CAP
);
74 * This function returns the pointer to an entry in BA Stream
75 * table which matches the requested BA status.
77 static struct mwifiex_tx_ba_stream_tbl
*
78 mwifiex_get_ba_status(struct mwifiex_private
*priv
,
79 enum mwifiex_ba_status ba_status
)
81 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
;
84 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
85 list_for_each_entry(tx_ba_tsr_tbl
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
86 if (tx_ba_tsr_tbl
->ba_status
== ba_status
) {
87 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
,
92 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
97 * This function handles the command response of delete a block
100 * The function checks the response success status and takes action
101 * accordingly (send an add BA request in case of success, or recreate
102 * the deleted stream in case of failure, if the add BA was also
105 int mwifiex_ret_11n_delba(struct mwifiex_private
*priv
,
106 struct host_cmd_ds_command
*resp
)
109 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tbl
;
110 struct host_cmd_ds_11n_delba
*del_ba
= &resp
->params
.del_ba
;
111 uint16_t del_ba_param_set
= le16_to_cpu(del_ba
->del_ba_param_set
);
113 tid
= del_ba_param_set
>> DELBA_TID_POS
;
114 if (del_ba
->del_result
== BA_RESULT_SUCCESS
) {
115 mwifiex_del_ba_tbl(priv
, tid
, del_ba
->peer_mac_addr
,
117 INITIATOR_BIT(del_ba_param_set
));
119 tx_ba_tbl
= mwifiex_get_ba_status(priv
, BA_SETUP_INPROGRESS
);
121 mwifiex_send_addba(priv
, tx_ba_tbl
->tid
,
124 * In case of failure, recreate the deleted stream in case
125 * we initiated the ADDBA
127 if (!INITIATOR_BIT(del_ba_param_set
))
130 mwifiex_create_ba_tbl(priv
, del_ba
->peer_mac_addr
, tid
,
131 BA_SETUP_INPROGRESS
);
133 tx_ba_tbl
= mwifiex_get_ba_status(priv
, BA_SETUP_INPROGRESS
);
136 mwifiex_del_ba_tbl(priv
, tx_ba_tbl
->tid
, tx_ba_tbl
->ra
,
137 TYPE_DELBA_SENT
, true);
144 * This function handles the command response of add a block
147 * Handling includes changing the header fields to CPU formats, checking
148 * the response success status and taking actions accordingly (delete the
149 * BA stream table in case of failure).
151 int mwifiex_ret_11n_addba_req(struct mwifiex_private
*priv
,
152 struct host_cmd_ds_command
*resp
)
155 struct host_cmd_ds_11n_addba_rsp
*add_ba_rsp
= &resp
->params
.add_ba_rsp
;
156 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tbl
;
158 add_ba_rsp
->ssn
= cpu_to_le16((le16_to_cpu(add_ba_rsp
->ssn
))
161 tid
= (le16_to_cpu(add_ba_rsp
->block_ack_param_set
)
162 & IEEE80211_ADDBA_PARAM_TID_MASK
)
163 >> BLOCKACKPARAM_TID_POS
;
164 if (le16_to_cpu(add_ba_rsp
->status_code
) == BA_RESULT_SUCCESS
) {
165 tx_ba_tbl
= mwifiex_get_ba_tbl(priv
, tid
,
166 add_ba_rsp
->peer_mac_addr
);
168 dev_dbg(priv
->adapter
->dev
, "info: BA stream complete\n");
169 tx_ba_tbl
->ba_status
= BA_SETUP_COMPLETE
;
171 dev_err(priv
->adapter
->dev
, "BA stream not created\n");
174 mwifiex_del_ba_tbl(priv
, tid
, add_ba_rsp
->peer_mac_addr
,
175 TYPE_DELBA_SENT
, true);
176 if (add_ba_rsp
->add_rsp_result
!= BA_RESULT_TIMEOUT
)
177 priv
->aggr_prio_tbl
[tid
].ampdu_ap
=
178 BA_STREAM_NOT_ALLOWED
;
185 * This function prepares command of reconfigure Tx buffer.
187 * Preparation includes -
188 * - Setting command ID, action and proper size
189 * - Setting Tx buffer size (for SET only)
190 * - Ensuring correct endian-ness
192 int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private
*priv
,
193 struct host_cmd_ds_command
*cmd
, int cmd_action
,
196 struct host_cmd_ds_txbuf_cfg
*tx_buf
= &cmd
->params
.tx_buf
;
197 u16 action
= (u16
) cmd_action
;
199 cmd
->command
= cpu_to_le16(HostCmd_CMD_RECONFIGURE_TX_BUFF
);
201 cpu_to_le16(sizeof(struct host_cmd_ds_txbuf_cfg
) + S_DS_GEN
);
202 tx_buf
->action
= cpu_to_le16(action
);
204 case HostCmd_ACT_GEN_SET
:
205 dev_dbg(priv
->adapter
->dev
, "cmd: set tx_buf=%d\n", *buf_size
);
206 tx_buf
->buff_size
= cpu_to_le16(*buf_size
);
208 case HostCmd_ACT_GEN_GET
:
210 tx_buf
->buff_size
= 0;
217 * This function prepares command of AMSDU aggregation control.
219 * Preparation includes -
220 * - Setting command ID, action and proper size
221 * - Setting AMSDU control parameters (for SET only)
222 * - Ensuring correct endian-ness
224 int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command
*cmd
,
226 struct mwifiex_ds_11n_amsdu_aggr_ctrl
*aa_ctrl
)
228 struct host_cmd_ds_amsdu_aggr_ctrl
*amsdu_ctrl
=
229 &cmd
->params
.amsdu_aggr_ctrl
;
230 u16 action
= (u16
) cmd_action
;
232 cmd
->command
= cpu_to_le16(HostCmd_CMD_AMSDU_AGGR_CTRL
);
233 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_amsdu_aggr_ctrl
)
235 amsdu_ctrl
->action
= cpu_to_le16(action
);
237 case HostCmd_ACT_GEN_SET
:
238 amsdu_ctrl
->enable
= cpu_to_le16(aa_ctrl
->enable
);
239 amsdu_ctrl
->curr_buf_size
= 0;
241 case HostCmd_ACT_GEN_GET
:
243 amsdu_ctrl
->curr_buf_size
= 0;
250 * This function prepares 11n configuration command.
252 * Preparation includes -
253 * - Setting command ID, action and proper size
254 * - Setting HT Tx capability and HT Tx information fields
255 * - Ensuring correct endian-ness
257 int mwifiex_cmd_11n_cfg(struct mwifiex_private
*priv
,
258 struct host_cmd_ds_command
*cmd
, u16 cmd_action
,
259 struct mwifiex_ds_11n_tx_cfg
*txcfg
)
261 struct host_cmd_ds_11n_cfg
*htcfg
= &cmd
->params
.htcfg
;
263 cmd
->command
= cpu_to_le16(HostCmd_CMD_11N_CFG
);
264 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_11n_cfg
) + S_DS_GEN
);
265 htcfg
->action
= cpu_to_le16(cmd_action
);
266 htcfg
->ht_tx_cap
= cpu_to_le16(txcfg
->tx_htcap
);
267 htcfg
->ht_tx_info
= cpu_to_le16(txcfg
->tx_htinfo
);
269 if (priv
->adapter
->is_hw_11ac_capable
)
270 htcfg
->misc_config
= cpu_to_le16(txcfg
->misc_config
);
276 * This function appends an 11n TLV to a buffer.
278 * Buffer allocation is responsibility of the calling
279 * function. No size validation is made here.
281 * The function fills up the following sections, if applicable -
283 * - HT information IE (with channel list)
284 * - 20/40 BSS Coexistence IE
285 * - HT Extended Capabilities IE
288 mwifiex_cmd_append_11n_tlv(struct mwifiex_private
*priv
,
289 struct mwifiex_bssdescriptor
*bss_desc
,
292 struct mwifiex_ie_types_htcap
*ht_cap
;
293 struct mwifiex_ie_types_htinfo
*ht_info
;
294 struct mwifiex_ie_types_chan_list_param_set
*chan_list
;
295 struct mwifiex_ie_types_2040bssco
*bss_co_2040
;
296 struct mwifiex_ie_types_extcap
*ext_cap
;
298 struct ieee80211_supported_band
*sband
;
299 struct ieee_types_header
*hdr
;
302 if (!buffer
|| !*buffer
)
305 radio_type
= mwifiex_band_to_radio_type((u8
) bss_desc
->bss_band
);
306 sband
= priv
->wdev
->wiphy
->bands
[radio_type
];
308 if (bss_desc
->bcn_ht_cap
) {
309 ht_cap
= (struct mwifiex_ie_types_htcap
*) *buffer
;
310 memset(ht_cap
, 0, sizeof(struct mwifiex_ie_types_htcap
));
311 ht_cap
->header
.type
= cpu_to_le16(WLAN_EID_HT_CAPABILITY
);
313 cpu_to_le16(sizeof(struct ieee80211_ht_cap
));
314 memcpy((u8
*) ht_cap
+ sizeof(struct mwifiex_ie_types_header
),
315 (u8
*) bss_desc
->bcn_ht_cap
+
316 sizeof(struct ieee_types_header
),
317 le16_to_cpu(ht_cap
->header
.len
));
319 mwifiex_fill_cap_info(priv
, radio_type
, ht_cap
);
321 *buffer
+= sizeof(struct mwifiex_ie_types_htcap
);
322 ret_len
+= sizeof(struct mwifiex_ie_types_htcap
);
325 if (bss_desc
->bcn_ht_oper
) {
326 if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
) {
327 ht_info
= (struct mwifiex_ie_types_htinfo
*) *buffer
;
329 sizeof(struct mwifiex_ie_types_htinfo
));
330 ht_info
->header
.type
=
331 cpu_to_le16(WLAN_EID_HT_OPERATION
);
332 ht_info
->header
.len
=
334 sizeof(struct ieee80211_ht_operation
));
336 memcpy((u8
*) ht_info
+
337 sizeof(struct mwifiex_ie_types_header
),
338 (u8
*) bss_desc
->bcn_ht_oper
+
339 sizeof(struct ieee_types_header
),
340 le16_to_cpu(ht_info
->header
.len
));
342 if (!(sband
->ht_cap
.cap
&
343 IEEE80211_HT_CAP_SUP_WIDTH_20_40
))
344 ht_info
->ht_oper
.ht_param
&=
345 ~(IEEE80211_HT_PARAM_CHAN_WIDTH_ANY
|
346 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
);
348 *buffer
+= sizeof(struct mwifiex_ie_types_htinfo
);
349 ret_len
+= sizeof(struct mwifiex_ie_types_htinfo
);
353 (struct mwifiex_ie_types_chan_list_param_set
*) *buffer
;
355 sizeof(struct mwifiex_ie_types_chan_list_param_set
));
356 chan_list
->header
.type
= cpu_to_le16(TLV_TYPE_CHANLIST
);
357 chan_list
->header
.len
= cpu_to_le16(
358 sizeof(struct mwifiex_ie_types_chan_list_param_set
) -
359 sizeof(struct mwifiex_ie_types_header
));
360 chan_list
->chan_scan_param
[0].chan_number
=
361 bss_desc
->bcn_ht_oper
->primary_chan
;
362 chan_list
->chan_scan_param
[0].radio_type
=
363 mwifiex_band_to_radio_type((u8
) bss_desc
->bss_band
);
365 if (sband
->ht_cap
.cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
&&
366 bss_desc
->bcn_ht_oper
->ht_param
&
367 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY
)
368 SET_SECONDARYCHAN(chan_list
->chan_scan_param
[0].
370 (bss_desc
->bcn_ht_oper
->ht_param
&
371 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
));
373 *buffer
+= sizeof(struct mwifiex_ie_types_chan_list_param_set
);
374 ret_len
+= sizeof(struct mwifiex_ie_types_chan_list_param_set
);
377 if (bss_desc
->bcn_bss_co_2040
) {
378 bss_co_2040
= (struct mwifiex_ie_types_2040bssco
*) *buffer
;
379 memset(bss_co_2040
, 0,
380 sizeof(struct mwifiex_ie_types_2040bssco
));
381 bss_co_2040
->header
.type
= cpu_to_le16(WLAN_EID_BSS_COEX_2040
);
382 bss_co_2040
->header
.len
=
383 cpu_to_le16(sizeof(bss_co_2040
->bss_co_2040
));
385 memcpy((u8
*) bss_co_2040
+
386 sizeof(struct mwifiex_ie_types_header
),
387 bss_desc
->bcn_bss_co_2040
+
388 sizeof(struct ieee_types_header
),
389 le16_to_cpu(bss_co_2040
->header
.len
));
391 *buffer
+= sizeof(struct mwifiex_ie_types_2040bssco
);
392 ret_len
+= sizeof(struct mwifiex_ie_types_2040bssco
);
395 if (bss_desc
->bcn_ext_cap
) {
396 hdr
= (void *)bss_desc
->bcn_ext_cap
;
397 ext_cap
= (struct mwifiex_ie_types_extcap
*) *buffer
;
398 memset(ext_cap
, 0, sizeof(struct mwifiex_ie_types_extcap
));
399 ext_cap
->header
.type
= cpu_to_le16(WLAN_EID_EXT_CAPABILITY
);
400 ext_cap
->header
.len
= cpu_to_le16(hdr
->len
);
402 memcpy((u8
*)ext_cap
->ext_capab
,
403 bss_desc
->bcn_ext_cap
+ sizeof(struct ieee_types_header
),
404 le16_to_cpu(ext_cap
->header
.len
));
407 ext_cap
->ext_capab
[3] & WLAN_EXT_CAPA4_INTERWORKING_ENABLED
)
408 priv
->hs2_enabled
= true;
410 priv
->hs2_enabled
= false;
412 *buffer
+= sizeof(struct mwifiex_ie_types_extcap
) + hdr
->len
;
413 ret_len
+= sizeof(struct mwifiex_ie_types_extcap
) + hdr
->len
;
420 * This function checks if the given pointer is valid entry of
421 * Tx BA Stream table.
423 static int mwifiex_is_tx_ba_stream_ptr_valid(struct mwifiex_private
*priv
,
424 struct mwifiex_tx_ba_stream_tbl
*tx_tbl_ptr
)
426 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
;
428 list_for_each_entry(tx_ba_tsr_tbl
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
429 if (tx_ba_tsr_tbl
== tx_tbl_ptr
)
437 * This function deletes the given entry in Tx BA Stream table.
439 * The function also performs a validity check on the supplied
440 * pointer before trying to delete.
442 void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private
*priv
,
443 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
)
445 if (!tx_ba_tsr_tbl
&&
446 mwifiex_is_tx_ba_stream_ptr_valid(priv
, tx_ba_tsr_tbl
))
449 dev_dbg(priv
->adapter
->dev
, "info: tx_ba_tsr_tbl %p\n", tx_ba_tsr_tbl
);
451 list_del(&tx_ba_tsr_tbl
->list
);
453 kfree(tx_ba_tsr_tbl
);
457 * This function deletes all the entries in Tx BA Stream table.
459 void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private
*priv
)
462 struct mwifiex_tx_ba_stream_tbl
*del_tbl_ptr
, *tmp_node
;
465 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
466 list_for_each_entry_safe(del_tbl_ptr
, tmp_node
,
467 &priv
->tx_ba_stream_tbl_ptr
, list
)
468 mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv
, del_tbl_ptr
);
469 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
471 INIT_LIST_HEAD(&priv
->tx_ba_stream_tbl_ptr
);
473 for (i
= 0; i
< MAX_NUM_TID
; ++i
)
474 priv
->aggr_prio_tbl
[i
].ampdu_ap
=
475 priv
->aggr_prio_tbl
[i
].ampdu_user
;
479 * This function returns the pointer to an entry in BA Stream
480 * table which matches the given RA/TID pair.
482 struct mwifiex_tx_ba_stream_tbl
*
483 mwifiex_get_ba_tbl(struct mwifiex_private
*priv
, int tid
, u8
*ra
)
485 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
;
488 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
489 list_for_each_entry(tx_ba_tsr_tbl
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
490 if (ether_addr_equal_unaligned(tx_ba_tsr_tbl
->ra
, ra
) &&
491 tx_ba_tsr_tbl
->tid
== tid
) {
492 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
,
494 return tx_ba_tsr_tbl
;
497 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
502 * This function creates an entry in Tx BA stream table for the
505 void mwifiex_create_ba_tbl(struct mwifiex_private
*priv
, u8
*ra
, int tid
,
506 enum mwifiex_ba_status ba_status
)
508 struct mwifiex_tx_ba_stream_tbl
*new_node
;
511 if (!mwifiex_get_ba_tbl(priv
, tid
, ra
)) {
512 new_node
= kzalloc(sizeof(struct mwifiex_tx_ba_stream_tbl
),
517 INIT_LIST_HEAD(&new_node
->list
);
520 new_node
->ba_status
= ba_status
;
521 memcpy(new_node
->ra
, ra
, ETH_ALEN
);
523 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
524 list_add_tail(&new_node
->list
, &priv
->tx_ba_stream_tbl_ptr
);
525 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
530 * This function sends an add BA request to the given TID/RA pair.
532 int mwifiex_send_addba(struct mwifiex_private
*priv
, int tid
, u8
*peer_mac
)
534 struct host_cmd_ds_11n_addba_req add_ba_req
;
535 static u8 dialog_tok
;
538 dev_dbg(priv
->adapter
->dev
, "cmd: %s: tid %d\n", __func__
, tid
);
540 add_ba_req
.block_ack_param_set
= cpu_to_le16(
541 (u16
) ((tid
<< BLOCKACKPARAM_TID_POS
) |
543 tx_win_size
<< BLOCKACKPARAM_WINSIZE_POS
) |
544 IMMEDIATE_BLOCK_ACK
));
545 add_ba_req
.block_ack_tmo
= cpu_to_le16((u16
)priv
->add_ba_param
.timeout
);
552 add_ba_req
.dialog_token
= dialog_tok
;
553 memcpy(&add_ba_req
.peer_mac_addr
, peer_mac
, ETH_ALEN
);
555 /* We don't wait for the response of this command */
556 ret
= mwifiex_send_cmd_async(priv
, HostCmd_CMD_11N_ADDBA_REQ
,
563 * This function sends a delete BA request to the given TID/RA pair.
565 int mwifiex_send_delba(struct mwifiex_private
*priv
, int tid
, u8
*peer_mac
,
568 struct host_cmd_ds_11n_delba delba
;
570 uint16_t del_ba_param_set
;
572 memset(&delba
, 0, sizeof(delba
));
573 delba
.del_ba_param_set
= cpu_to_le16(tid
<< DELBA_TID_POS
);
575 del_ba_param_set
= le16_to_cpu(delba
.del_ba_param_set
);
577 del_ba_param_set
|= IEEE80211_DELBA_PARAM_INITIATOR_MASK
;
579 del_ba_param_set
&= ~IEEE80211_DELBA_PARAM_INITIATOR_MASK
;
581 memcpy(&delba
.peer_mac_addr
, peer_mac
, ETH_ALEN
);
583 /* We don't wait for the response of this command */
584 ret
= mwifiex_send_cmd_async(priv
, HostCmd_CMD_11N_DELBA
,
585 HostCmd_ACT_GEN_SET
, 0, &delba
);
591 * This function handles the command response of a delete BA request.
593 void mwifiex_11n_delete_ba_stream(struct mwifiex_private
*priv
, u8
*del_ba
)
595 struct host_cmd_ds_11n_delba
*cmd_del_ba
=
596 (struct host_cmd_ds_11n_delba
*) del_ba
;
597 uint16_t del_ba_param_set
= le16_to_cpu(cmd_del_ba
->del_ba_param_set
);
600 tid
= del_ba_param_set
>> DELBA_TID_POS
;
602 mwifiex_del_ba_tbl(priv
, tid
, cmd_del_ba
->peer_mac_addr
,
603 TYPE_DELBA_RECEIVE
, INITIATOR_BIT(del_ba_param_set
));
607 * This function retrieves the Rx reordering table.
609 int mwifiex_get_rx_reorder_tbl(struct mwifiex_private
*priv
,
610 struct mwifiex_ds_rx_reorder_tbl
*buf
)
613 struct mwifiex_ds_rx_reorder_tbl
*rx_reo_tbl
= buf
;
614 struct mwifiex_rx_reorder_tbl
*rx_reorder_tbl_ptr
;
618 spin_lock_irqsave(&priv
->rx_reorder_tbl_lock
, flags
);
619 list_for_each_entry(rx_reorder_tbl_ptr
, &priv
->rx_reorder_tbl_ptr
,
621 rx_reo_tbl
->tid
= (u16
) rx_reorder_tbl_ptr
->tid
;
622 memcpy(rx_reo_tbl
->ta
, rx_reorder_tbl_ptr
->ta
, ETH_ALEN
);
623 rx_reo_tbl
->start_win
= rx_reorder_tbl_ptr
->start_win
;
624 rx_reo_tbl
->win_size
= rx_reorder_tbl_ptr
->win_size
;
625 for (i
= 0; i
< rx_reorder_tbl_ptr
->win_size
; ++i
) {
626 if (rx_reorder_tbl_ptr
->rx_reorder_ptr
[i
])
627 rx_reo_tbl
->buffer
[i
] = true;
629 rx_reo_tbl
->buffer
[i
] = false;
634 if (count
>= MWIFIEX_MAX_RX_BASTREAM_SUPPORTED
)
637 spin_unlock_irqrestore(&priv
->rx_reorder_tbl_lock
, flags
);
643 * This function retrieves the Tx BA stream table.
645 int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private
*priv
,
646 struct mwifiex_ds_tx_ba_stream_tbl
*buf
)
648 struct mwifiex_tx_ba_stream_tbl
*tx_ba_tsr_tbl
;
649 struct mwifiex_ds_tx_ba_stream_tbl
*rx_reo_tbl
= buf
;
653 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
654 list_for_each_entry(tx_ba_tsr_tbl
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
655 rx_reo_tbl
->tid
= (u16
) tx_ba_tsr_tbl
->tid
;
656 dev_dbg(priv
->adapter
->dev
, "data: %s tid=%d\n",
657 __func__
, rx_reo_tbl
->tid
);
658 memcpy(rx_reo_tbl
->ra
, tx_ba_tsr_tbl
->ra
, ETH_ALEN
);
661 if (count
>= MWIFIEX_MAX_TX_BASTREAM_SUPPORTED
)
664 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
670 * This function retrieves the entry for specific tx BA stream table by RA and
673 void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private
*priv
, u8
*ra
)
675 struct mwifiex_tx_ba_stream_tbl
*tbl
, *tmp
;
681 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
682 list_for_each_entry_safe(tbl
, tmp
, &priv
->tx_ba_stream_tbl_ptr
, list
) {
683 if (!memcmp(tbl
->ra
, ra
, ETH_ALEN
)) {
684 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
,
686 mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv
, tbl
);
687 spin_lock_irqsave(&priv
->tx_ba_stream_tbl_lock
, flags
);
690 spin_unlock_irqrestore(&priv
->tx_ba_stream_tbl_lock
, flags
);
695 /* This function initializes the BlockACK setup information for given
696 * mwifiex_private structure.
698 void mwifiex_set_ba_params(struct mwifiex_private
*priv
)
700 priv
->add_ba_param
.timeout
= MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT
;
702 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
703 priv
->add_ba_param
.tx_win_size
=
704 MWIFIEX_UAP_AMPDU_DEF_TXWINSIZE
;
705 priv
->add_ba_param
.rx_win_size
=
706 MWIFIEX_UAP_AMPDU_DEF_RXWINSIZE
;
708 priv
->add_ba_param
.tx_win_size
=
709 MWIFIEX_STA_AMPDU_DEF_TXWINSIZE
;
710 priv
->add_ba_param
.rx_win_size
=
711 MWIFIEX_STA_AMPDU_DEF_RXWINSIZE
;