Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: 802.11n |
| 3 | * |
Xinming Hu | 65da33f | 2014-06-19 21:38:57 -0700 | [diff] [blame] | 4 | * Copyright (C) 2011-2014, Marvell International Ltd. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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 Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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); |
Yogesh Ashok Powar | a5f3905 | 2013-02-15 21:44:30 -0800 | [diff] [blame] | 31 | int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv, |
| 32 | struct host_cmd_ds_command *cmd, u16 cmd_action, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 33 | struct mwifiex_ds_11n_tx_cfg *txcfg); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 34 | int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv, |
| 35 | struct mwifiex_bssdescriptor *bss_desc, |
| 36 | u8 **buffer); |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 37 | int mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type, |
| 38 | struct ieee80211_ht_cap *); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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); |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 45 | struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 46 | mwifiex_private |
| 47 | *priv, int tid, |
| 48 | u8 *ra); |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 49 | void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid, |
| 50 | enum mwifiex_ba_status ba_status); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 59 | int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv, |
| 60 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 61 | int cmd_action, u16 *buf_size); |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 62 | int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 63 | int cmd_action, |
| 64 | struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl); |
Avinash Patil | 3e238a1 | 2012-08-03 18:06:11 -0700 | [diff] [blame] | 65 | void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra); |
Avinash Patil | 396939f | 2014-05-06 22:02:45 -0700 | [diff] [blame] | 66 | u8 mwifiex_get_sec_chan_offset(int chan); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 67 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 68 | static inline u8 |
Avinash Patil | eac4322 | 2014-02-07 16:27:28 -0800 | [diff] [blame] | 69 | mwifiex_is_station_ampdu_allowed(struct mwifiex_private *priv, |
| 70 | struct mwifiex_ra_list_tbl *ptr, int tid) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 71 | { |
Avinash Patil | eac4322 | 2014-02-07 16:27:28 -0800 | [diff] [blame] | 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 AMPDU is allowed or not for a particular TID. */ |
| 81 | static inline u8 |
| 82 | mwifiex_is_ampdu_allowed(struct mwifiex_private *priv, |
| 83 | struct mwifiex_ra_list_tbl *ptr, int tid) |
| 84 | { |
Avinash Patil | bfd713b | 2014-11-05 17:04:30 +0530 | [diff] [blame] | 85 | if (is_broadcast_ether_addr(ptr->ra)) |
| 86 | return false; |
Avinash Patil | daeb5bb | 2014-02-07 16:30:37 -0800 | [diff] [blame] | 87 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) { |
Avinash Patil | eac4322 | 2014-02-07 16:27:28 -0800 | [diff] [blame] | 88 | return mwifiex_is_station_ampdu_allowed(priv, ptr, tid); |
Avinash Patil | daeb5bb | 2014-02-07 16:30:37 -0800 | [diff] [blame] | 89 | } else { |
| 90 | if (ptr->tdls_link) |
| 91 | return mwifiex_is_station_ampdu_allowed(priv, ptr, tid); |
| 92 | |
Avinash Patil | eac4322 | 2014-02-07 16:27:28 -0800 | [diff] [blame] | 93 | return (priv->aggr_prio_tbl[tid].ampdu_ap != |
| 94 | BA_STREAM_NOT_ALLOWED) ? true : false; |
Avinash Patil | daeb5bb | 2014-02-07 16:30:37 -0800 | [diff] [blame] | 95 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | /* |
| 99 | * This function checks whether AMSDU is allowed or not for a particular TID. |
| 100 | */ |
| 101 | static inline u8 |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 102 | mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 103 | { |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 104 | return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) && |
| 105 | (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03))) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 106 | ? true : false); |
| 107 | } |
| 108 | |
| 109 | /* |
Bing Zhao | 53d7938 | 2011-04-13 17:27:09 -0700 | [diff] [blame] | 110 | * This function checks whether a space is available for new BA stream or not. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 111 | */ |
Bing Zhao | 53d7938 | 2011-04-13 17:27:09 -0700 | [diff] [blame] | 112 | static inline u8 mwifiex_space_avail_for_new_ba_stream( |
| 113 | struct mwifiex_adapter *adapter) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 114 | { |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 115 | struct mwifiex_private *priv; |
| 116 | u8 i; |
Avinash Patil | 4f3dfdf | 2014-12-26 03:02:34 -0800 | [diff] [blame] | 117 | u32 ba_stream_num = 0, ba_stream_max; |
| 118 | |
| 119 | ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 120 | |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 121 | for (i = 0; i < adapter->priv_num; i++) { |
| 122 | priv = adapter->priv[i]; |
| 123 | if (priv) |
| 124 | ba_stream_num += mwifiex_wmm_list_len( |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 125 | &priv->tx_ba_stream_tbl_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Avinash Patil | 4f3dfdf | 2014-12-26 03:02:34 -0800 | [diff] [blame] | 128 | if (adapter->fw_api_ver == MWIFIEX_FW_V15) { |
| 129 | ba_stream_max = |
| 130 | GETSUPP_TXBASTREAMS(adapter->hw_dot_11n_dev_cap); |
| 131 | if (!ba_stream_max) |
| 132 | ba_stream_max = MWIFIEX_MAX_TX_BASTREAM_SUPPORTED; |
| 133 | } |
| 134 | |
| 135 | return ((ba_stream_num < ba_stream_max) ? true : false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | /* |
| 139 | * This function finds the correct Tx BA stream to delete. |
| 140 | * |
| 141 | * Upon successfully locating, both the TID and the RA are returned. |
| 142 | */ |
| 143 | static inline u8 |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 144 | mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 145 | int *ptid, u8 *ra) |
| 146 | { |
| 147 | int tid; |
| 148 | u8 ret = false; |
| 149 | struct mwifiex_tx_ba_stream_tbl *tx_tbl; |
| 150 | unsigned long flags; |
| 151 | |
| 152 | tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user; |
| 153 | |
| 154 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 155 | list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) { |
| 156 | if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) { |
| 157 | tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user; |
| 158 | *ptid = tx_tbl->tid; |
| 159 | memcpy(ra, tx_tbl->ra, ETH_ALEN); |
| 160 | ret = true; |
| 161 | } |
| 162 | } |
| 163 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); |
| 164 | |
| 165 | return ret; |
| 166 | } |
| 167 | |
| 168 | /* |
Avinash Patil | 5a009ad | 2012-08-03 18:06:10 -0700 | [diff] [blame] | 169 | * This function checks whether associated station is 11n enabled |
| 170 | */ |
| 171 | static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv, |
| 172 | struct mwifiex_sta_node *node) |
| 173 | { |
Xinming Hu | 432da7d | 2016-07-25 21:21:10 +0530 | [diff] [blame] | 174 | if (!node || ((priv->bss_role == MWIFIEX_BSS_ROLE_UAP) && |
| 175 | !priv->ap_11n_enabled) || |
| 176 | ((priv->bss_mode == NL80211_IFTYPE_ADHOC) && |
| 177 | !priv->adapter->adhoc_11n_enabled)) |
Avinash Patil | 5a009ad | 2012-08-03 18:06:10 -0700 | [diff] [blame] | 178 | return 0; |
| 179 | |
| 180 | return node->is_11n_enabled; |
| 181 | } |
Avinash Patil | daeb5bb | 2014-02-07 16:30:37 -0800 | [diff] [blame] | 182 | |
| 183 | static inline u8 |
Johannes Berg | 3b3a016 | 2014-05-19 17:19:31 +0200 | [diff] [blame] | 184 | mwifiex_tdls_peer_11n_enabled(struct mwifiex_private *priv, const u8 *ra) |
Avinash Patil | daeb5bb | 2014-02-07 16:30:37 -0800 | [diff] [blame] | 185 | { |
| 186 | struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ra); |
| 187 | if (node) |
| 188 | return node->is_11n_enabled; |
| 189 | |
| 190 | return false; |
| 191 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 192 | #endif /* !_MWIFIEX_11N_H_ */ |