| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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 |  | 
| 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); | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 31 | int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 32 | struct mwifiex_ds_11n_tx_cfg *tx_cfg); | 
|  | 33 | int mwifiex_cmd_11n_cfg(struct host_cmd_ds_command *cmd, u16 cmd_action, | 
|  | 34 | struct mwifiex_ds_11n_tx_cfg *txcfg); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 35 |  | 
|  | 36 | int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv, | 
|  | 37 | struct mwifiex_bssdescriptor *bss_desc, | 
|  | 38 | u8 **buffer); | 
|  | 39 | void mwifiex_cfg_tx_buf(struct mwifiex_private *priv, | 
|  | 40 | struct mwifiex_bssdescriptor *bss_desc); | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 41 | void mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type, | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 42 | struct mwifiex_ie_types_htcap *); | 
|  | 43 | int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv, | 
|  | 44 | u16 action, int *htcap_cfg); | 
|  | 45 | void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv, | 
|  | 46 | struct mwifiex_tx_ba_stream_tbl | 
|  | 47 | *tx_tbl); | 
|  | 48 | 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] | 49 | struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 50 | mwifiex_private | 
|  | 51 | *priv, int tid, | 
|  | 52 | u8 *ra); | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 53 | void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid, | 
|  | 54 | enum mwifiex_ba_status ba_status); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 55 | int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac); | 
|  | 56 | int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac, | 
|  | 57 | int initiator); | 
|  | 58 | void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba); | 
|  | 59 | int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv, | 
|  | 60 | struct mwifiex_ds_rx_reorder_tbl *buf); | 
|  | 61 | int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv, | 
|  | 62 | struct mwifiex_ds_tx_ba_stream_tbl *buf); | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 63 | int mwifiex_ret_amsdu_aggr_ctrl(struct host_cmd_ds_command *resp, | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 64 | struct mwifiex_ds_11n_amsdu_aggr_ctrl | 
|  | 65 | *amsdu_aggr_ctrl); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 66 | int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv, | 
|  | 67 | struct host_cmd_ds_command *cmd, | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 68 | int cmd_action, u16 *buf_size); | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 69 | int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd, | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 70 | int cmd_action, | 
|  | 71 | struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 72 |  | 
|  | 73 | /* | 
|  | 74 | * This function checks whether AMPDU is allowed or not for a particular TID. | 
|  | 75 | */ | 
|  | 76 | static inline u8 | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 77 | mwifiex_is_ampdu_allowed(struct mwifiex_private *priv, int tid) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 78 | { | 
|  | 79 | return ((priv->aggr_prio_tbl[tid].ampdu_ap != BA_STREAM_NOT_ALLOWED) | 
|  | 80 | ? true : false); | 
|  | 81 | } | 
|  | 82 |  | 
|  | 83 | /* | 
|  | 84 | * This function checks whether AMSDU is allowed or not for a particular TID. | 
|  | 85 | */ | 
|  | 86 | static inline u8 | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 87 | mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 88 | { | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 89 | return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) && | 
|  | 90 | (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03))) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 91 | ? true : false); | 
|  | 92 | } | 
|  | 93 |  | 
|  | 94 | /* | 
| Bing Zhao | 53d7938 | 2011-04-13 17:27:09 -0700 | [diff] [blame] | 95 | * 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] | 96 | */ | 
| Bing Zhao | 53d7938 | 2011-04-13 17:27:09 -0700 | [diff] [blame] | 97 | static inline u8 mwifiex_space_avail_for_new_ba_stream( | 
|  | 98 | struct mwifiex_adapter *adapter) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 99 | { | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 100 | struct mwifiex_private *priv; | 
|  | 101 | u8 i; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 102 | u32 ba_stream_num = 0; | 
|  | 103 |  | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 104 | for (i = 0; i < adapter->priv_num; i++) { | 
|  | 105 | priv = adapter->priv[i]; | 
|  | 106 | if (priv) | 
|  | 107 | ba_stream_num += mwifiex_wmm_list_len( | 
| Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 108 | &priv->tx_ba_stream_tbl_ptr); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 109 | } | 
|  | 110 |  | 
|  | 111 | return ((ba_stream_num < | 
|  | 112 | MWIFIEX_MAX_TX_BASTREAM_SUPPORTED) ? true : false); | 
|  | 113 | } | 
|  | 114 |  | 
|  | 115 | /* | 
|  | 116 | * This function finds the correct Tx BA stream to delete. | 
|  | 117 | * | 
|  | 118 | * Upon successfully locating, both the TID and the RA are returned. | 
|  | 119 | */ | 
|  | 120 | static inline u8 | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 121 | mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid, | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 122 | int *ptid, u8 *ra) | 
|  | 123 | { | 
|  | 124 | int tid; | 
|  | 125 | u8 ret = false; | 
|  | 126 | struct mwifiex_tx_ba_stream_tbl *tx_tbl; | 
|  | 127 | unsigned long flags; | 
|  | 128 |  | 
|  | 129 | tid = priv->aggr_prio_tbl[ptr_tid].ampdu_user; | 
|  | 130 |  | 
|  | 131 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 132 | list_for_each_entry(tx_tbl, &priv->tx_ba_stream_tbl_ptr, list) { | 
|  | 133 | if (tid > priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user) { | 
|  | 134 | tid = priv->aggr_prio_tbl[tx_tbl->tid].ampdu_user; | 
|  | 135 | *ptid = tx_tbl->tid; | 
|  | 136 | memcpy(ra, tx_tbl->ra, ETH_ALEN); | 
|  | 137 | ret = true; | 
|  | 138 | } | 
|  | 139 | } | 
|  | 140 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 141 |  | 
|  | 142 | return ret; | 
|  | 143 | } | 
|  | 144 |  | 
|  | 145 | /* | 
|  | 146 | * This function checks whether BA stream is set up or not. | 
|  | 147 | */ | 
|  | 148 | static inline int | 
|  | 149 | mwifiex_is_ba_stream_setup(struct mwifiex_private *priv, | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 150 | struct mwifiex_ra_list_tbl *ptr, int tid) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 151 | { | 
|  | 152 | struct mwifiex_tx_ba_stream_tbl *tx_tbl; | 
|  | 153 |  | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 154 | tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 155 | if (tx_tbl && IS_BASTREAM_SETUP(tx_tbl)) | 
|  | 156 | return true; | 
|  | 157 |  | 
|  | 158 | return false; | 
|  | 159 | } | 
|  | 160 | #endif /* !_MWIFIEX_11N_H_ */ |