mwifiex: add rx histogram statistics support
[deliverable/linux.git] / drivers / net / wireless / mwifiex / 11n.h
1 /*
2 * Marvell Wireless LAN device driver: 802.11n
3 *
4 * Copyright (C) 2011-2014, 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
27 int mwifiex_ret_11n_delba(struct mwifiex_private *priv,
28 struct host_cmd_ds_command *resp);
29 int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
30 struct host_cmd_ds_command *resp);
31 int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
32 struct host_cmd_ds_command *cmd, u16 cmd_action,
33 struct mwifiex_ds_11n_tx_cfg *txcfg);
34 int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
35 struct mwifiex_bssdescriptor *bss_desc,
36 u8 **buffer);
37 int mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
38 struct ieee80211_ht_cap *);
39 int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
40 u16 action, int *htcap_cfg);
41 void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
42 struct mwifiex_tx_ba_stream_tbl
43 *tx_tbl);
44 void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv);
45 struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct
46 mwifiex_private
47 *priv, int tid,
48 u8 *ra);
49 void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid,
50 enum mwifiex_ba_status ba_status);
51 int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac);
52 int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
53 int initiator);
54 void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba);
55 int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
56 struct mwifiex_ds_rx_reorder_tbl *buf);
57 int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
58 struct mwifiex_ds_tx_ba_stream_tbl *buf);
59 int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
60 struct host_cmd_ds_command *cmd,
61 int cmd_action, u16 *buf_size);
62 int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
63 int cmd_action,
64 struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl);
65 void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra);
66 u8 mwifiex_get_sec_chan_offset(int chan);
67
68 static inline u8
69 mwifiex_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
80 /* This function checks whether AMSDU is allowed for BA stream. */
81 static inline u8
82 mwifiex_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
87 if (is_broadcast_ether_addr(ptr->ra))
88 return false;
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
96 /* This function checks whether AMPDU is allowed or not for a particular TID. */
97 static inline u8
98 mwifiex_is_ampdu_allowed(struct mwifiex_private *priv,
99 struct mwifiex_ra_list_tbl *ptr, int tid)
100 {
101 if (is_broadcast_ether_addr(ptr->ra))
102 return false;
103 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
104 return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
105 } else {
106 if (ptr->tdls_link)
107 return mwifiex_is_station_ampdu_allowed(priv, ptr, tid);
108
109 return (priv->aggr_prio_tbl[tid].ampdu_ap !=
110 BA_STREAM_NOT_ALLOWED) ? true : false;
111 }
112 }
113
114 /*
115 * This function checks whether AMSDU is allowed or not for a particular TID.
116 */
117 static inline u8
118 mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid)
119 {
120 return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) &&
121 (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03)))
122 ? true : false);
123 }
124
125 /*
126 * This function checks whether a space is available for new BA stream or not.
127 */
128 static inline u8 mwifiex_space_avail_for_new_ba_stream(
129 struct mwifiex_adapter *adapter)
130 {
131 struct mwifiex_private *priv;
132 u8 i;
133 u32 ba_stream_num = 0;
134
135 for (i = 0; i < adapter->priv_num; i++) {
136 priv = adapter->priv[i];
137 if (priv)
138 ba_stream_num += mwifiex_wmm_list_len(
139 &priv->tx_ba_stream_tbl_ptr);
140 }
141
142 return ((ba_stream_num <
143 MWIFIEX_MAX_TX_BASTREAM_SUPPORTED) ? true : false);
144 }
145
146 /*
147 * This function finds the correct Tx BA stream to delete.
148 *
149 * Upon successfully locating, both the TID and the RA are returned.
150 */
151 static inline u8
152 mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid,
153 int *ptid, u8 *ra)
154 {
155 int tid;
156 u8 ret = false;
157 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
158 unsigned long flags;
159
160 tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
161
162 spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags);
163 list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
164 if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) {
165 tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user;
166 *ptid = tx_tbl->tid;
167 memcpy(ra, tx_tbl->ra, ETH_ALEN);
168 ret = true;
169 }
170 }
171 spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags);
172
173 return ret;
174 }
175
176 /*
177 * This function checks whether BA stream is set up or not.
178 */
179 static inline int
180 mwifiex_is_ba_stream_setup(struct mwifiex_private *priv,
181 struct mwifiex_ra_list_tbl *ptr, int tid)
182 {
183 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
184
185 tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra);
186 if (tx_tbl && IS_BASTREAM_SETUP(tx_tbl))
187 return true;
188
189 return false;
190 }
191
192 /*
193 * This function checks whether associated station is 11n enabled
194 */
195 static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv,
196 struct mwifiex_sta_node *node)
197 {
198
199 if (!node || (priv->bss_role != MWIFIEX_BSS_ROLE_UAP) ||
200 !priv->ap_11n_enabled)
201 return 0;
202
203 return node->is_11n_enabled;
204 }
205
206 static inline u8
207 mwifiex_tdls_peer_11n_enabled(struct mwifiex_private *priv, const u8 *ra)
208 {
209 struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ra);
210 if (node)
211 return node->is_11n_enabled;
212
213 return false;
214 }
215 #endif /* !_MWIFIEX_11N_H_ */
This page took 0.049475 seconds and 5 git commands to generate.