Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux-2.6-block.git] / drivers / net / wireless / mwifiex / 11n.h
CommitLineData
5e6e3a92
BZ
1/*
2 * Marvell Wireless LAN device driver: 802.11n
3 *
65da33f5 4 * Copyright (C) 2011-2014, Marvell International Ltd.
5e6e3a92
BZ
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
18 */
19
20#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
5e6e3a92
BZ
27int 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);
a5f39056
YAP
31int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
32 struct host_cmd_ds_command *cmd, u16 cmd_action,
a5ffddb7 33 struct mwifiex_ds_11n_tx_cfg *txcfg);
5e6e3a92
BZ
34int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
35 struct mwifiex_bssdescriptor *bss_desc,
36 u8 **buffer);
341b8800
AK
37int mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
38 struct ieee80211_ht_cap *);
5e6e3a92
BZ
39int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
40 u16 action, int *htcap_cfg);
41void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
42 struct mwifiex_tx_ba_stream_tbl
43 *tx_tbl);
44void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv);
3e822635 45struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct
5e6e3a92
BZ
46 mwifiex_private
47 *priv, int tid,
48 u8 *ra);
3e822635
YAP
49void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid,
50 enum mwifiex_ba_status ba_status);
5e6e3a92
BZ
51int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac);
52int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
53 int initiator);
54void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba);
55int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
56 struct mwifiex_ds_rx_reorder_tbl *buf);
57int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
58 struct mwifiex_ds_tx_ba_stream_tbl *buf);
5e6e3a92
BZ
59int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
60 struct host_cmd_ds_command *cmd,
a5ffddb7 61 int cmd_action, u16 *buf_size);
572e8f3e 62int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
a5ffddb7
AK
63 int cmd_action,
64 struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl);
3e238a11 65void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra);
396939f9 66u8 mwifiex_get_sec_chan_offset(int chan);
5e6e3a92 67
5e6e3a92 68static inline u8
eac43227
AP
69mwifiex_is_station_ampdu_allowed(struct mwifiex_private *priv,
70 struct mwifiex_ra_list_tbl *ptr, int tid)
71{
72 struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ptr->ra);
73
74 if (unlikely(!node))
75 return false;
76
77 return (node->ampdu_sta[tid] != BA_STREAM_NOT_ALLOWED) ? true : false;
78}
79
4c9f9fb2
AK
80/* This function checks whether AMSDU is allowed for BA stream. */
81static inline u8
82mwifiex_is_amsdu_in_ampdu_allowed(struct mwifiex_private *priv,
83 struct mwifiex_ra_list_tbl *ptr, int tid)
84{
85 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
86
bfd713bc
AP
87 if (is_broadcast_ether_addr(ptr->ra))
88 return false;
4c9f9fb2
AK
89 tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra);
90 if (tx_tbl)
91 return tx_tbl->amsdu;
92
93 return false;
94}
95
eac43227
AP
96/* This function checks whether AMPDU is allowed or not for a particular TID. */
97static inline u8
98mwifiex_is_ampdu_allowed(struct mwifiex_private *priv,
99 struct mwifiex_ra_list_tbl *ptr, int tid)
5e6e3a92 100{
bfd713bc
AP
101 if (is_broadcast_ether_addr(ptr->ra))
102 return false;
daeb5bb4 103 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
eac43227 104 return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
daeb5bb4
AP
105 } else {
106 if (ptr->tdls_link)
107 return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
108
eac43227
AP
109 return (priv->aggr_prio_tbl[tid].ampdu_ap !=
110 BA_STREAM_NOT_ALLOWED) ? true : false;
daeb5bb4 111 }
5e6e3a92
BZ
112}
113
114/*
115 * This function checks whether AMSDU is allowed or not for a particular TID.
116 */
117static inline u8
572e8f3e 118mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid)
5e6e3a92 119{
84266841
YAP
120 return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) &&
121 (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03)))
5e6e3a92
BZ
122 ? true : false);
123}
124
125/*
53d7938e 126 * This function checks whether a space is available for new BA stream or not.
5e6e3a92 127 */
53d7938e
BZ
128static inline u8 mwifiex_space_avail_for_new_ba_stream(
129 struct mwifiex_adapter *adapter)
5e6e3a92 130{
572e8f3e
AK
131 struct mwifiex_private *priv;
132 u8 i;
4f3dfdfb
AP
133 u32 ba_stream_num = 0, ba_stream_max;
134
135 ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED;
5e6e3a92 136
572e8f3e
AK
137 for (i = 0; i < adapter->priv_num; i++) {
138 priv = adapter->priv[i];
139 if (priv)
140 ba_stream_num += mwifiex_wmm_list_len(
2c208890 141 &priv->tx_ba_stream_tbl_ptr);
5e6e3a92
BZ
142 }
143
4f3dfdfb
AP
144 if (adapter->fw_api_ver == MWIFIEX_FW_V15) {
145 ba_stream_max =
146 GETSUPP_TXBASTREAMS(adapter->hw_dot_11n_dev_cap);
147 if (!ba_stream_max)
148 ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED;
149 }
150
151 return ((ba_stream_num < ba_stream_max) ? true : false);
5e6e3a92
BZ
152}
153
154/*
155 * This function finds the correct Tx BA stream to delete.
156 *
157 * Upon successfully locating, both the TID and the RA are returned.
158 */
159static inline u8
572e8f3e 160mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid,
5e6e3a92
BZ
161 int *ptid, u8 *ra)
162{
163 int tid;
164 u8 ret = false;
165 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
166 unsigned long flags;
167
168 tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
169
170 spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags);
171 list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
172 if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) {
173 tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user;
174 *ptid = tx_tbl->tid;
175 memcpy(ra, tx_tbl->ra, ETH_ALEN);
176 ret = true;
177 }
178 }
179 spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags);
180
181 return ret;
182}
183
184/*
185 * This function checks whether BA stream is set up or not.
186 */
187static inline int
188mwifiex_is_ba_stream_setup(struct mwifiex_private *priv,
84266841 189 struct mwifiex_ra_list_tbl *ptr, int tid)
5e6e3a92
BZ
190{
191 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
192
3e822635 193 tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra);
5e6e3a92
BZ
194 if (tx_tbl && IS_BASTREAM_SETUP(tx_tbl))
195 return true;
196
197 return false;
198}
5a009adf
AP
199
200/*
201 * This function checks whether associated station is 11n enabled
202 */
203static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv,
204 struct mwifiex_sta_node *node)
205{
206
207 if (!node || (priv->bss_role != MWIFIEX_BSS_ROLE_UAP) ||
208 !priv->ap_11n_enabled)
209 return 0;
210
211 return node->is_11n_enabled;
212}
daeb5bb4
AP
213
214static inline u8
3b3a0162 215mwifiex_tdls_peer_11n_enabled(struct mwifiex_private *priv, const u8 *ra)
daeb5bb4
AP
216{
217 struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ra);
218 if (node)
219 return node->is_11n_enabled;
220
221 return false;
222}
5e6e3a92 223#endif /* !_MWIFIEX_11N_H_ */