wireless: mwifiex: initial commit for Marvell mwifiex driver
[deliverable/linux.git] / drivers / net / wireless / mwifiex / 11n.h
1 /*
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
27 void mwifiex_show_dot_11n_dev_cap(struct mwifiex_adapter *adapter, u32 cap);
28 void mwifiex_show_dev_mcs_support(struct mwifiex_adapter *adapter, u8 support);
29 int mwifiex_ret_11n_delba(struct mwifiex_private *priv,
30 struct host_cmd_ds_command *resp);
31 int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
32 struct host_cmd_ds_command *resp);
33 int mwifiex_ret_11n_cfg(struct mwifiex_private *priv,
34 struct host_cmd_ds_command *resp,
35 void *data_buf);
36 int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
37 struct host_cmd_ds_command *cmd,
38 u16 cmd_action, void *data_buf);
39
40 int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
41 struct host_cmd_ds_command *cmd,
42 u16 cmd_action, void *data_buf);
43
44 int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
45 struct mwifiex_bssdescriptor *bss_desc,
46 u8 **buffer);
47 void mwifiex_cfg_tx_buf(struct mwifiex_private *priv,
48 struct mwifiex_bssdescriptor *bss_desc);
49 void mwifiex_fill_cap_info(struct mwifiex_private *,
50 struct mwifiex_ie_types_htcap *);
51 int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
52 u16 action, int *htcap_cfg);
53 void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
54 struct mwifiex_tx_ba_stream_tbl
55 *tx_tbl);
56 void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv);
57 struct mwifiex_tx_ba_stream_tbl *mwifiex_11n_get_tx_ba_stream_tbl(struct
58 mwifiex_private
59 *priv, int tid,
60 u8 *ra);
61 void mwifiex_11n_create_tx_ba_stream_tbl(struct mwifiex_private *priv, u8 *ra,
62 int tid,
63 enum mwifiex_ba_status ba_status);
64 int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac);
65 int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
66 int initiator);
67 void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba);
68 int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
69 struct mwifiex_ds_rx_reorder_tbl *buf);
70 int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
71 struct mwifiex_ds_tx_ba_stream_tbl *buf);
72 int mwifiex_ret_amsdu_aggr_ctrl(struct mwifiex_private *priv,
73 struct host_cmd_ds_command
74 *resp,
75 void *data_buf);
76 int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
77 struct host_cmd_ds_command *cmd,
78 int cmd_action, void *data_buf);
79 int mwifiex_cmd_amsdu_aggr_ctrl(struct mwifiex_private *priv,
80 struct host_cmd_ds_command *cmd,
81 int cmd_action,
82 void *data_buf);
83
84 /*
85 * This function checks whether AMPDU is allowed or not for a particular TID.
86 */
87 static inline u8
88 mwifiex_is_ampdu_allowed(struct mwifiex_private *priv,
89 struct mwifiex_ra_list_tbl *ptr, int tid)
90 {
91 return ((priv->aggr_prio_tbl[tid].ampdu_ap != BA_STREAM_NOT_ALLOWED)
92 ? true : false);
93 }
94
95 /*
96 * This function checks whether AMSDU is allowed or not for a particular TID.
97 */
98 static inline u8
99 mwifiex_is_amsdu_allowed(struct mwifiex_private *priv,
100 struct mwifiex_ra_list_tbl *ptr, int tid)
101 {
102 return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED)
103 && ((priv->is_data_rate_auto)
104 || !((priv->bitmap_rates[2]) & 0x03)))
105 ? true : false);
106 }
107
108 /*
109 * This function checks whether a BA stream is available or not.
110 */
111 static inline u8
112 mwifiex_is_ba_stream_avail(struct mwifiex_private *priv)
113 {
114 struct mwifiex_private *pmpriv = NULL;
115 u8 i = 0;
116 u32 ba_stream_num = 0;
117
118 for (i = 0; i < priv->adapter->priv_num; i++) {
119 pmpriv = priv->adapter->priv[i];
120 if (pmpriv)
121 ba_stream_num +=
122 mwifiex_wmm_list_len(priv->adapter,
123 (struct list_head
124 *) &pmpriv->
125 tx_ba_stream_tbl_ptr);
126 }
127
128 return ((ba_stream_num <
129 MWIFIEX_MAX_TX_BASTREAM_SUPPORTED) ? true : false);
130 }
131
132 /*
133 * This function finds the correct Tx BA stream to delete.
134 *
135 * Upon successfully locating, both the TID and the RA are returned.
136 */
137 static inline u8
138 mwifiex_find_stream_to_delete(struct mwifiex_private *priv,
139 struct mwifiex_ra_list_tbl *ptr, int ptr_tid,
140 int *ptid, u8 *ra)
141 {
142 int tid;
143 u8 ret = false;
144 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
145 unsigned long flags;
146
147 tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user;
148
149 spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags);
150 list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
151 if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) {
152 tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user;
153 *ptid = tx_tbl->tid;
154 memcpy(ra, tx_tbl->ra, ETH_ALEN);
155 ret = true;
156 }
157 }
158 spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags);
159
160 return ret;
161 }
162
163 /*
164 * This function checks whether BA stream is set up or not.
165 */
166 static inline int
167 mwifiex_is_ba_stream_setup(struct mwifiex_private *priv,
168 struct mwifiex_ra_list_tbl *ptr, int tid)
169 {
170 struct mwifiex_tx_ba_stream_tbl *tx_tbl;
171
172 tx_tbl = mwifiex_11n_get_tx_ba_stream_tbl(priv, tid, ptr->ra);
173 if (tx_tbl && IS_BASTREAM_SETUP(tx_tbl))
174 return true;
175
176 return false;
177 }
178 #endif /* !_MWIFIEX_11N_H_ */
This page took 0.038601 seconds and 5 git commands to generate.