blob: 46006a54a6566ee1c744220926bc198159aac0dd [file] [log] [blame]
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001/*
2 * Marvell Wireless LAN device driver: 802.11n
3 *
4 * Copyright (C) 2011, Marvell International Ltd.
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#ifndef _MWIFIEX_11N_H_
21#define _MWIFIEX_11N_H_
22
23#include "11n_aggr.h"
24#include "11n_rxreorder.h"
25#include "wmm.h"
26
Bing Zhao5e6e3a92011-03-21 18:00:50 -070027int mwifiex_ret_11n_delba(struct mwifiex_private *priv,
28 struct host_cmd_ds_command *resp);
29int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
30 struct host_cmd_ds_command *resp);
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -070031int mwifiex_cmd_11n_cfg(struct host_cmd_ds_command *cmd, u16 cmd_action,
32 struct mwifiex_ds_11n_tx_cfg *txcfg);
Bing Zhao5e6e3a92011-03-21 18:00:50 -070033
34int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
35 struct mwifiex_bssdescriptor *bss_desc,
36 u8 **buffer);
37void mwifiex_cfg_tx_buf(struct mwifiex_private *priv,
38 struct mwifiex_bssdescriptor *bss_desc);
Amitkumar Karwara46b7b52011-04-27 19:13:12 -070039void mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
Bing Zhao5e6e3a92011-03-21 18:00:50 -070040 struct mwifiex_ie_types_htcap *);
41int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
42 u16 action, int *htcap_cfg);
43void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
44 struct mwifiex_tx_ba_stream_tbl
45 *tx_tbl);
46void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv);
Yogesh Ashok Powar3e822632012-03-12 19:35:08 -070047struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct
Bing Zhao5e6e3a92011-03-21 18:00:50 -070048 mwifiex_private
49 *priv, int tid,
50 u8 *ra);
Yogesh Ashok Powar3e822632012-03-12 19:35:08 -070051void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid,
52 enum mwifiex_ba_status ba_status);
Bing Zhao5e6e3a92011-03-21 18:00:50 -070053int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac);
54int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
55 int initiator);
56void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba);
57int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
58 struct mwifiex_ds_rx_reorder_tbl *buf);
59int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
60 struct mwifiex_ds_tx_ba_stream_tbl *buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -070061int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
62 struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -070063 int cmd_action, u16 *buf_size);
Amitkumar Karwar572e8f32011-04-13 17:27:08 -070064int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -070065 int cmd_action,
66 struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl);
Avinash Patil3e238a12012-08-03 18:06:11 -070067void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra);
Bing Zhao5e6e3a92011-03-21 18:00:50 -070068
69/*
70 * This function checks whether AMPDU is allowed or not for a particular TID.
71 */
72static inline u8
Amitkumar Karwar572e8f32011-04-13 17:27:08 -070073mwifiex_is_ampdu_allowed(struct mwifiex_private *priv, int tid)
Bing Zhao5e6e3a92011-03-21 18:00:50 -070074{
75 return ((priv->aggr_prio_tbl[tid].ampdu_ap != BA_STREAM_NOT_ALLOWED)
76 ? true : false);
77}
78
79/*
80 * This function checks whether AMSDU is allowed or not for a particular TID.
81 */
82static inline u8
Amitkumar Karwar572e8f32011-04-13 17:27:08 -070083mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid)
Bing Zhao5e6e3a92011-03-21 18:00:50 -070084{
Yogesh Ashok Powar84266842012-03-13 19:22:34 -070085 return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) &&
86 (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03)))
Bing Zhao5e6e3a92011-03-21 18:00:50 -070087 ? true : false);
88}
89
90/*
Bing Zhao53d79382011-04-13 17:27:09 -070091 * This function checks whether a space is available for new BA stream or not.
Bing Zhao5e6e3a92011-03-21 18:00:50 -070092 */
Bing Zhao53d79382011-04-13 17:27:09 -070093static inline u8 mwifiex_space_avail_for_new_ba_stream(
94 struct mwifiex_adapter *adapter)
Bing Zhao5e6e3a92011-03-21 18:00:50 -070095{
Amitkumar Karwar572e8f32011-04-13 17:27:08 -070096 struct mwifiex_private *priv;
97 u8 i;
Bing Zhao5e6e3a92011-03-21 18:00:50 -070098 u32 ba_stream_num = 0;
99
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700100 for (i = 0; i < adapter->priv_num; i++) {
101 priv = adapter->priv[i];
102 if (priv)
103 ba_stream_num += mwifiex_wmm_list_len(
Joe Perches2c208892012-06-04 12:44:17 +0000104 &priv->tx_ba_stream_tbl_ptr);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700105 }
106
107 return ((ba_stream_num <
108 MWIFIEX_MAX_TX_BASTREAM_SUPPORTED) ? true : false);
109}
110
111/*
112 * This function finds the correct Tx BA stream to delete.
113 *
114 * Upon successfully locating, both the TID and the RA are returned.
115 */
116static inline u8
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700117mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid,
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700118 int *ptid, u8 *ra)
119{
120 int tid;
121 u8 ret = false;
122 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
123 unsigned long flags;
124
125 tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
126
127 spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags);
128 list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
129 if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) {
130 tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user;
131 *ptid = tx_tbl->tid;
132 memcpy(ra, tx_tbl->ra, ETH_ALEN);
133 ret = true;
134 }
135 }
136 spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags);
137
138 return ret;
139}
140
141/*
142 * This function checks whether BA stream is set up or not.
143 */
144static inline int
145mwifiex_is_ba_stream_setup(struct mwifiex_private *priv,
Yogesh Ashok Powar84266842012-03-13 19:22:34 -0700146 struct mwifiex_ra_list_tbl *ptr, int tid)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700147{
148 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
149
Yogesh Ashok Powar3e822632012-03-12 19:35:08 -0700150 tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700151 if (tx_tbl && IS_BASTREAM_SETUP(tx_tbl))
152 return true;
153
154 return false;
155}
Avinash Patil5a009ad2012-08-03 18:06:10 -0700156
157/*
158 * This function checks whether associated station is 11n enabled
159 */
160static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv,
161 struct mwifiex_sta_node *node)
162{
163
164 if (!node || (priv->bss_role != MWIFIEX_BSS_ROLE_UAP) ||
165 !priv->ap_11n_enabled)
166 return 0;
167
168 return node->is_11n_enabled;
169}
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700170#endif /* !_MWIFIEX_11N_H_ */