| 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 | #include "decl.h" | 
|  | 21 | #include "ioctl.h" | 
|  | 22 | #include "util.h" | 
|  | 23 | #include "fw.h" | 
|  | 24 | #include "main.h" | 
|  | 25 | #include "wmm.h" | 
|  | 26 | #include "11n.h" | 
|  | 27 |  | 
|  | 28 | /* | 
|  | 29 | * Fills HT capability information field, AMPDU Parameters field, HT extended | 
|  | 30 | * capability field, and supported MCS set fields. | 
|  | 31 | * | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 32 | * HT capability information field, AMPDU Parameters field, supported MCS set | 
|  | 33 | * fields are retrieved from cfg80211 stack | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 34 | * | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 35 | * RD responder bit to set to clear in the extended capability header. | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 36 | */ | 
|  | 37 | void | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 38 | mwifiex_fill_cap_info(struct mwifiex_private *priv, u8 radio_type, | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 39 | struct mwifiex_ie_types_htcap *ht_cap) | 
|  | 40 | { | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 41 | uint16_t ht_ext_cap = le16_to_cpu(ht_cap->ht_cap.extended_ht_cap_info); | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 42 | struct ieee80211_supported_band *sband = | 
|  | 43 | priv->wdev->wiphy->bands[radio_type]; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 44 |  | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 45 | ht_cap->ht_cap.ampdu_params_info = | 
|  | 46 | (sband->ht_cap.ampdu_factor & | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 47 | IEEE80211_HT_AMPDU_PARM_FACTOR) | | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 48 | ((sband->ht_cap.ampdu_density << | 
|  | 49 | IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT) & | 
|  | 50 | IEEE80211_HT_AMPDU_PARM_DENSITY); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 51 |  | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 52 | memcpy((u8 *) &ht_cap->ht_cap.mcs, &sband->ht_cap.mcs, | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 53 | sizeof(sband->ht_cap.mcs)); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 54 |  | 
| Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 55 | if (priv->bss_mode == NL80211_IFTYPE_STATION || | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 56 | sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 57 | /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */ | 
|  | 58 | SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask); | 
|  | 59 |  | 
|  | 60 | /* Clear RD responder bit */ | 
| Amitkumar Karwar | a373165 | 2011-04-15 20:50:41 -0700 | [diff] [blame] | 61 | ht_ext_cap &= ~IEEE80211_HT_EXT_CAP_RD_RESPONDER; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 62 |  | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 63 | ht_cap->ht_cap.cap_info = cpu_to_le16(sband->ht_cap.cap); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 64 | ht_cap->ht_cap.extended_ht_cap_info = cpu_to_le16(ht_ext_cap); | 
|  | 65 | } | 
|  | 66 |  | 
|  | 67 | /* | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 68 | * This function returns the pointer to an entry in BA Stream | 
|  | 69 | * table which matches the requested BA status. | 
|  | 70 | */ | 
|  | 71 | static struct mwifiex_tx_ba_stream_tbl * | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 72 | mwifiex_get_ba_status(struct mwifiex_private *priv, | 
|  | 73 | enum mwifiex_ba_status ba_status) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 74 | { | 
|  | 75 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; | 
|  | 76 | unsigned long flags; | 
|  | 77 |  | 
|  | 78 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 79 | list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { | 
|  | 80 | if (tx_ba_tsr_tbl->ba_status == ba_status) { | 
|  | 81 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, | 
|  | 82 | flags); | 
|  | 83 | return tx_ba_tsr_tbl; | 
|  | 84 | } | 
|  | 85 | } | 
|  | 86 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 87 | return NULL; | 
|  | 88 | } | 
|  | 89 |  | 
|  | 90 | /* | 
|  | 91 | * This function handles the command response of delete a block | 
|  | 92 | * ack request. | 
|  | 93 | * | 
|  | 94 | * The function checks the response success status and takes action | 
|  | 95 | * accordingly (send an add BA request in case of success, or recreate | 
|  | 96 | * the deleted stream in case of failure, if the add BA was also | 
|  | 97 | * initiated by us). | 
|  | 98 | */ | 
|  | 99 | int mwifiex_ret_11n_delba(struct mwifiex_private *priv, | 
|  | 100 | struct host_cmd_ds_command *resp) | 
|  | 101 | { | 
|  | 102 | int tid; | 
|  | 103 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tbl; | 
| Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 104 | struct host_cmd_ds_11n_delba *del_ba = &resp->params.del_ba; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 105 | uint16_t del_ba_param_set = le16_to_cpu(del_ba->del_ba_param_set); | 
|  | 106 |  | 
|  | 107 | tid = del_ba_param_set >> DELBA_TID_POS; | 
|  | 108 | if (del_ba->del_result == BA_RESULT_SUCCESS) { | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 109 | mwifiex_del_ba_tbl(priv, tid, del_ba->peer_mac_addr, | 
|  | 110 | TYPE_DELBA_SENT, | 
|  | 111 | INITIATOR_BIT(del_ba_param_set)); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 112 |  | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 113 | tx_ba_tbl = mwifiex_get_ba_status(priv, BA_SETUP_INPROGRESS); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 114 | if (tx_ba_tbl) | 
|  | 115 | mwifiex_send_addba(priv, tx_ba_tbl->tid, | 
|  | 116 | tx_ba_tbl->ra); | 
|  | 117 | } else { /* | 
|  | 118 | * In case of failure, recreate the deleted stream in case | 
|  | 119 | * we initiated the ADDBA | 
|  | 120 | */ | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 121 | if (!INITIATOR_BIT(del_ba_param_set)) | 
|  | 122 | return 0; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 123 |  | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 124 | mwifiex_create_ba_tbl(priv, del_ba->peer_mac_addr, tid, | 
|  | 125 | BA_SETUP_INPROGRESS); | 
|  | 126 |  | 
|  | 127 | tx_ba_tbl = mwifiex_get_ba_status(priv, BA_SETUP_INPROGRESS); | 
|  | 128 |  | 
|  | 129 | if (tx_ba_tbl) | 
|  | 130 | mwifiex_del_ba_tbl(priv, tx_ba_tbl->tid, tx_ba_tbl->ra, | 
|  | 131 | TYPE_DELBA_SENT, true); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 132 | } | 
|  | 133 |  | 
|  | 134 | return 0; | 
|  | 135 | } | 
|  | 136 |  | 
|  | 137 | /* | 
|  | 138 | * This function handles the command response of add a block | 
|  | 139 | * ack request. | 
|  | 140 | * | 
|  | 141 | * Handling includes changing the header fields to CPU formats, checking | 
|  | 142 | * the response success status and taking actions accordingly (delete the | 
|  | 143 | * BA stream table in case of failure). | 
|  | 144 | */ | 
|  | 145 | int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv, | 
|  | 146 | struct host_cmd_ds_command *resp) | 
|  | 147 | { | 
|  | 148 | int tid; | 
| Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 149 | struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &resp->params.add_ba_rsp; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 150 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tbl; | 
|  | 151 |  | 
|  | 152 | add_ba_rsp->ssn = cpu_to_le16((le16_to_cpu(add_ba_rsp->ssn)) | 
|  | 153 | & SSN_MASK); | 
|  | 154 |  | 
|  | 155 | tid = (le16_to_cpu(add_ba_rsp->block_ack_param_set) | 
|  | 156 | & IEEE80211_ADDBA_PARAM_TID_MASK) | 
|  | 157 | >> BLOCKACKPARAM_TID_POS; | 
|  | 158 | if (le16_to_cpu(add_ba_rsp->status_code) == BA_RESULT_SUCCESS) { | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 159 | tx_ba_tbl = mwifiex_get_ba_tbl(priv, tid, | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 160 | add_ba_rsp->peer_mac_addr); | 
|  | 161 | if (tx_ba_tbl) { | 
|  | 162 | dev_dbg(priv->adapter->dev, "info: BA stream complete\n"); | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 163 | tx_ba_tbl->ba_status = BA_SETUP_COMPLETE; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 164 | } else { | 
|  | 165 | dev_err(priv->adapter->dev, "BA stream not created\n"); | 
|  | 166 | } | 
|  | 167 | } else { | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 168 | mwifiex_del_ba_tbl(priv, tid, add_ba_rsp->peer_mac_addr, | 
|  | 169 | TYPE_DELBA_SENT, true); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 170 | if (add_ba_rsp->add_rsp_result != BA_RESULT_TIMEOUT) | 
|  | 171 | priv->aggr_prio_tbl[tid].ampdu_ap = | 
|  | 172 | BA_STREAM_NOT_ALLOWED; | 
|  | 173 | } | 
|  | 174 |  | 
|  | 175 | return 0; | 
|  | 176 | } | 
|  | 177 |  | 
|  | 178 | /* | 
|  | 179 | * This function handles the command response of 11n configuration request. | 
|  | 180 | * | 
|  | 181 | * Handling includes changing the header fields into CPU format. | 
|  | 182 | */ | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 183 | int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, | 
|  | 184 | struct mwifiex_ds_11n_tx_cfg *tx_cfg) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 185 | { | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 186 | struct host_cmd_ds_11n_cfg *htcfg = &resp->params.htcfg; | 
|  | 187 |  | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 188 | if (tx_cfg) { | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 189 | tx_cfg->tx_htcap = le16_to_cpu(htcfg->ht_tx_cap); | 
|  | 190 | tx_cfg->tx_htinfo = le16_to_cpu(htcfg->ht_tx_info); | 
|  | 191 | } | 
|  | 192 | return 0; | 
|  | 193 | } | 
|  | 194 |  | 
|  | 195 | /* | 
|  | 196 | * This function prepares command of reconfigure Tx buffer. | 
|  | 197 | * | 
|  | 198 | * Preparation includes - | 
|  | 199 | *      - Setting command ID, action and proper size | 
|  | 200 | *      - Setting Tx buffer size (for SET only) | 
|  | 201 | *      - Ensuring correct endian-ness | 
|  | 202 | */ | 
|  | 203 | int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv, | 
|  | 204 | struct host_cmd_ds_command *cmd, int cmd_action, | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 205 | u16 *buf_size) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 206 | { | 
|  | 207 | struct host_cmd_ds_txbuf_cfg *tx_buf = &cmd->params.tx_buf; | 
|  | 208 | u16 action = (u16) cmd_action; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 209 |  | 
|  | 210 | cmd->command = cpu_to_le16(HostCmd_CMD_RECONFIGURE_TX_BUFF); | 
|  | 211 | cmd->size = | 
|  | 212 | cpu_to_le16(sizeof(struct host_cmd_ds_txbuf_cfg) + S_DS_GEN); | 
|  | 213 | tx_buf->action = cpu_to_le16(action); | 
|  | 214 | switch (action) { | 
|  | 215 | case HostCmd_ACT_GEN_SET: | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 216 | dev_dbg(priv->adapter->dev, "cmd: set tx_buf=%d\n", *buf_size); | 
|  | 217 | tx_buf->buff_size = cpu_to_le16(*buf_size); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 218 | break; | 
|  | 219 | case HostCmd_ACT_GEN_GET: | 
|  | 220 | default: | 
|  | 221 | tx_buf->buff_size = 0; | 
|  | 222 | break; | 
|  | 223 | } | 
|  | 224 | return 0; | 
|  | 225 | } | 
|  | 226 |  | 
|  | 227 | /* | 
|  | 228 | * This function prepares command of AMSDU aggregation control. | 
|  | 229 | * | 
|  | 230 | * Preparation includes - | 
|  | 231 | *      - Setting command ID, action and proper size | 
|  | 232 | *      - Setting AMSDU control parameters (for SET only) | 
|  | 233 | *      - Ensuring correct endian-ness | 
|  | 234 | */ | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 235 | int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd, | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 236 | int cmd_action, | 
|  | 237 | struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 238 | { | 
|  | 239 | struct host_cmd_ds_amsdu_aggr_ctrl *amsdu_ctrl = | 
|  | 240 | &cmd->params.amsdu_aggr_ctrl; | 
|  | 241 | u16 action = (u16) cmd_action; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 242 |  | 
|  | 243 | cmd->command = cpu_to_le16(HostCmd_CMD_AMSDU_AGGR_CTRL); | 
|  | 244 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_amsdu_aggr_ctrl) | 
|  | 245 | + S_DS_GEN); | 
|  | 246 | amsdu_ctrl->action = cpu_to_le16(action); | 
|  | 247 | switch (action) { | 
|  | 248 | case HostCmd_ACT_GEN_SET: | 
|  | 249 | amsdu_ctrl->enable = cpu_to_le16(aa_ctrl->enable); | 
|  | 250 | amsdu_ctrl->curr_buf_size = 0; | 
|  | 251 | break; | 
|  | 252 | case HostCmd_ACT_GEN_GET: | 
|  | 253 | default: | 
|  | 254 | amsdu_ctrl->curr_buf_size = 0; | 
|  | 255 | break; | 
|  | 256 | } | 
|  | 257 | return 0; | 
|  | 258 | } | 
|  | 259 |  | 
|  | 260 | /* | 
|  | 261 | * This function handles the command response of AMSDU aggregation | 
|  | 262 | * control request. | 
|  | 263 | * | 
|  | 264 | * Handling includes changing the header fields into CPU format. | 
|  | 265 | */ | 
| Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 266 | int mwifiex_ret_amsdu_aggr_ctrl(struct host_cmd_ds_command *resp, | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 267 | struct mwifiex_ds_11n_amsdu_aggr_ctrl | 
|  | 268 | *amsdu_aggr_ctrl) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 269 | { | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 270 | struct host_cmd_ds_amsdu_aggr_ctrl *amsdu_ctrl = | 
|  | 271 | &resp->params.amsdu_aggr_ctrl; | 
|  | 272 |  | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 273 | if (amsdu_aggr_ctrl) { | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 274 | amsdu_aggr_ctrl->enable = le16_to_cpu(amsdu_ctrl->enable); | 
|  | 275 | amsdu_aggr_ctrl->curr_buf_size = | 
|  | 276 | le16_to_cpu(amsdu_ctrl->curr_buf_size); | 
|  | 277 | } | 
|  | 278 | return 0; | 
|  | 279 | } | 
|  | 280 |  | 
|  | 281 | /* | 
|  | 282 | * This function prepares 11n configuration command. | 
|  | 283 | * | 
|  | 284 | * Preparation includes - | 
|  | 285 | *      - Setting command ID, action and proper size | 
|  | 286 | *      - Setting HT Tx capability and HT Tx information fields | 
|  | 287 | *      - Ensuring correct endian-ness | 
|  | 288 | */ | 
| Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 289 | int mwifiex_cmd_11n_cfg(struct host_cmd_ds_command *cmd, u16 cmd_action, | 
|  | 290 | struct mwifiex_ds_11n_tx_cfg *txcfg) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 291 | { | 
|  | 292 | struct host_cmd_ds_11n_cfg *htcfg = &cmd->params.htcfg; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 293 |  | 
|  | 294 | cmd->command = cpu_to_le16(HostCmd_CMD_11N_CFG); | 
|  | 295 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_11n_cfg) + S_DS_GEN); | 
|  | 296 | htcfg->action = cpu_to_le16(cmd_action); | 
|  | 297 | htcfg->ht_tx_cap = cpu_to_le16(txcfg->tx_htcap); | 
|  | 298 | htcfg->ht_tx_info = cpu_to_le16(txcfg->tx_htinfo); | 
|  | 299 | return 0; | 
|  | 300 | } | 
|  | 301 |  | 
|  | 302 | /* | 
|  | 303 | * This function appends an 11n TLV to a buffer. | 
|  | 304 | * | 
|  | 305 | * Buffer allocation is responsibility of the calling | 
|  | 306 | * function. No size validation is made here. | 
|  | 307 | * | 
|  | 308 | * The function fills up the following sections, if applicable - | 
|  | 309 | *      - HT capability IE | 
|  | 310 | *      - HT information IE (with channel list) | 
|  | 311 | *      - 20/40 BSS Coexistence IE | 
|  | 312 | *      - HT Extended Capabilities IE | 
|  | 313 | */ | 
|  | 314 | int | 
|  | 315 | mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv, | 
|  | 316 | struct mwifiex_bssdescriptor *bss_desc, | 
|  | 317 | u8 **buffer) | 
|  | 318 | { | 
|  | 319 | struct mwifiex_ie_types_htcap *ht_cap; | 
|  | 320 | struct mwifiex_ie_types_htinfo *ht_info; | 
|  | 321 | struct mwifiex_ie_types_chan_list_param_set *chan_list; | 
|  | 322 | struct mwifiex_ie_types_2040bssco *bss_co_2040; | 
|  | 323 | struct mwifiex_ie_types_extcap *ext_cap; | 
|  | 324 | int ret_len = 0; | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 325 | struct ieee80211_supported_band *sband; | 
|  | 326 | u8 radio_type; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 327 |  | 
|  | 328 | if (!buffer || !*buffer) | 
|  | 329 | return ret_len; | 
|  | 330 |  | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 331 | radio_type = mwifiex_band_to_radio_type((u8) bss_desc->bss_band); | 
|  | 332 | sband = priv->wdev->wiphy->bands[radio_type]; | 
|  | 333 |  | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 334 | if (bss_desc->bcn_ht_cap) { | 
|  | 335 | ht_cap = (struct mwifiex_ie_types_htcap *) *buffer; | 
|  | 336 | memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap)); | 
|  | 337 | ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); | 
|  | 338 | ht_cap->header.len = | 
|  | 339 | cpu_to_le16(sizeof(struct ieee80211_ht_cap)); | 
|  | 340 | memcpy((u8 *) ht_cap + sizeof(struct mwifiex_ie_types_header), | 
|  | 341 | (u8 *) bss_desc->bcn_ht_cap + | 
|  | 342 | sizeof(struct ieee_types_header), | 
|  | 343 | le16_to_cpu(ht_cap->header.len)); | 
|  | 344 |  | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 345 | mwifiex_fill_cap_info(priv, radio_type, ht_cap); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 346 |  | 
|  | 347 | *buffer += sizeof(struct mwifiex_ie_types_htcap); | 
|  | 348 | ret_len += sizeof(struct mwifiex_ie_types_htcap); | 
|  | 349 | } | 
|  | 350 |  | 
| Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 351 | if (bss_desc->bcn_ht_oper) { | 
| Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 352 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 353 | ht_info = (struct mwifiex_ie_types_htinfo *) *buffer; | 
|  | 354 | memset(ht_info, 0, | 
|  | 355 | sizeof(struct mwifiex_ie_types_htinfo)); | 
|  | 356 | ht_info->header.type = | 
| Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 357 | cpu_to_le16(WLAN_EID_HT_OPERATION); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 358 | ht_info->header.len = | 
| Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 359 | cpu_to_le16( | 
|  | 360 | sizeof(struct ieee80211_ht_operation)); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 361 |  | 
|  | 362 | memcpy((u8 *) ht_info + | 
|  | 363 | sizeof(struct mwifiex_ie_types_header), | 
| Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 364 | (u8 *) bss_desc->bcn_ht_oper + | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 365 | sizeof(struct ieee_types_header), | 
|  | 366 | le16_to_cpu(ht_info->header.len)); | 
|  | 367 |  | 
| Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 368 | if (!(sband->ht_cap.cap & | 
|  | 369 | IEEE80211_HT_CAP_SUP_WIDTH_20_40)) | 
| Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 370 | ht_info->ht_oper.ht_param &= | 
| Marc Yang | 6d2bd91 | 2011-03-25 19:47:02 -0700 | [diff] [blame] | 371 | ~(IEEE80211_HT_PARAM_CHAN_WIDTH_ANY | | 
|  | 372 | IEEE80211_HT_PARAM_CHA_SEC_OFFSET); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 373 |  | 
|  | 374 | *buffer += sizeof(struct mwifiex_ie_types_htinfo); | 
|  | 375 | ret_len += sizeof(struct mwifiex_ie_types_htinfo); | 
|  | 376 | } | 
|  | 377 |  | 
|  | 378 | chan_list = | 
|  | 379 | (struct mwifiex_ie_types_chan_list_param_set *) *buffer; | 
|  | 380 | memset(chan_list, 0, | 
|  | 381 | sizeof(struct mwifiex_ie_types_chan_list_param_set)); | 
|  | 382 | chan_list->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); | 
|  | 383 | chan_list->header.len = cpu_to_le16( | 
|  | 384 | sizeof(struct mwifiex_ie_types_chan_list_param_set) - | 
|  | 385 | sizeof(struct mwifiex_ie_types_header)); | 
|  | 386 | chan_list->chan_scan_param[0].chan_number = | 
| Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 387 | bss_desc->bcn_ht_oper->primary_chan; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 388 | chan_list->chan_scan_param[0].radio_type = | 
|  | 389 | mwifiex_band_to_radio_type((u8) bss_desc->bss_band); | 
|  | 390 |  | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 391 | if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && | 
| Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 392 | bss_desc->bcn_ht_oper->ht_param & | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 393 | IEEE80211_HT_PARAM_CHAN_WIDTH_ANY) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 394 | SET_SECONDARYCHAN(chan_list->chan_scan_param[0]. | 
|  | 395 | radio_type, | 
| Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 396 | (bss_desc->bcn_ht_oper->ht_param & | 
| Marc Yang | 6d2bd91 | 2011-03-25 19:47:02 -0700 | [diff] [blame] | 397 | IEEE80211_HT_PARAM_CHA_SEC_OFFSET)); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 398 |  | 
|  | 399 | *buffer += sizeof(struct mwifiex_ie_types_chan_list_param_set); | 
|  | 400 | ret_len += sizeof(struct mwifiex_ie_types_chan_list_param_set); | 
|  | 401 | } | 
|  | 402 |  | 
|  | 403 | if (bss_desc->bcn_bss_co_2040) { | 
|  | 404 | bss_co_2040 = (struct mwifiex_ie_types_2040bssco *) *buffer; | 
|  | 405 | memset(bss_co_2040, 0, | 
|  | 406 | sizeof(struct mwifiex_ie_types_2040bssco)); | 
|  | 407 | bss_co_2040->header.type = cpu_to_le16(WLAN_EID_BSS_COEX_2040); | 
|  | 408 | bss_co_2040->header.len = | 
|  | 409 | cpu_to_le16(sizeof(bss_co_2040->bss_co_2040)); | 
|  | 410 |  | 
|  | 411 | memcpy((u8 *) bss_co_2040 + | 
|  | 412 | sizeof(struct mwifiex_ie_types_header), | 
| Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 413 | bss_desc->bcn_bss_co_2040 + | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 414 | sizeof(struct ieee_types_header), | 
|  | 415 | le16_to_cpu(bss_co_2040->header.len)); | 
|  | 416 |  | 
|  | 417 | *buffer += sizeof(struct mwifiex_ie_types_2040bssco); | 
|  | 418 | ret_len += sizeof(struct mwifiex_ie_types_2040bssco); | 
|  | 419 | } | 
|  | 420 |  | 
|  | 421 | if (bss_desc->bcn_ext_cap) { | 
|  | 422 | ext_cap = (struct mwifiex_ie_types_extcap *) *buffer; | 
|  | 423 | memset(ext_cap, 0, sizeof(struct mwifiex_ie_types_extcap)); | 
|  | 424 | ext_cap->header.type = cpu_to_le16(WLAN_EID_EXT_CAPABILITY); | 
|  | 425 | ext_cap->header.len = cpu_to_le16(sizeof(ext_cap->ext_cap)); | 
|  | 426 |  | 
| Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 427 | memcpy((u8 *)ext_cap + sizeof(struct mwifiex_ie_types_header), | 
|  | 428 | bss_desc->bcn_ext_cap + sizeof(struct ieee_types_header), | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 429 | le16_to_cpu(ext_cap->header.len)); | 
|  | 430 |  | 
|  | 431 | *buffer += sizeof(struct mwifiex_ie_types_extcap); | 
|  | 432 | ret_len += sizeof(struct mwifiex_ie_types_extcap); | 
|  | 433 | } | 
|  | 434 |  | 
|  | 435 | return ret_len; | 
|  | 436 | } | 
|  | 437 |  | 
|  | 438 | /* | 
|  | 439 | * This function reconfigures the Tx buffer size in firmware. | 
|  | 440 | * | 
|  | 441 | * This function prepares a firmware command and issues it, if | 
|  | 442 | * the current Tx buffer size is different from the one requested. | 
|  | 443 | * Maximum configurable Tx buffer size is limited by the HT capability | 
|  | 444 | * field value. | 
|  | 445 | */ | 
|  | 446 | void | 
|  | 447 | mwifiex_cfg_tx_buf(struct mwifiex_private *priv, | 
|  | 448 | struct mwifiex_bssdescriptor *bss_desc) | 
|  | 449 | { | 
|  | 450 | u16 max_amsdu = MWIFIEX_TX_DATA_BUF_SIZE_2K; | 
| Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 451 | u16 tx_buf, curr_tx_buf_size = 0; | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 452 |  | 
|  | 453 | if (bss_desc->bcn_ht_cap) { | 
| Marc Yang | 6d2bd91 | 2011-03-25 19:47:02 -0700 | [diff] [blame] | 454 | if (le16_to_cpu(bss_desc->bcn_ht_cap->cap_info) & | 
|  | 455 | IEEE80211_HT_CAP_MAX_AMSDU) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 456 | max_amsdu = MWIFIEX_TX_DATA_BUF_SIZE_8K; | 
|  | 457 | else | 
|  | 458 | max_amsdu = MWIFIEX_TX_DATA_BUF_SIZE_4K; | 
|  | 459 | } | 
|  | 460 |  | 
|  | 461 | tx_buf = min(priv->adapter->max_tx_buf_size, max_amsdu); | 
|  | 462 |  | 
|  | 463 | dev_dbg(priv->adapter->dev, "info: max_amsdu=%d, max_tx_buf=%d\n", | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 464 | max_amsdu, priv->adapter->max_tx_buf_size); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 465 |  | 
|  | 466 | if (priv->adapter->curr_tx_buf_size <= MWIFIEX_TX_DATA_BUF_SIZE_2K) | 
|  | 467 | curr_tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K; | 
|  | 468 | else if (priv->adapter->curr_tx_buf_size <= MWIFIEX_TX_DATA_BUF_SIZE_4K) | 
|  | 469 | curr_tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K; | 
|  | 470 | else if (priv->adapter->curr_tx_buf_size <= MWIFIEX_TX_DATA_BUF_SIZE_8K) | 
|  | 471 | curr_tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_8K; | 
|  | 472 | if (curr_tx_buf_size != tx_buf) | 
| Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 473 | mwifiex_send_cmd_async(priv, HostCmd_CMD_RECONFIGURE_TX_BUFF, | 
|  | 474 | HostCmd_ACT_GEN_SET, 0, &tx_buf); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 475 | } | 
|  | 476 |  | 
|  | 477 | /* | 
|  | 478 | * This function checks if the given pointer is valid entry of | 
|  | 479 | * Tx BA Stream table. | 
|  | 480 | */ | 
|  | 481 | static int mwifiex_is_tx_ba_stream_ptr_valid(struct mwifiex_private *priv, | 
|  | 482 | struct mwifiex_tx_ba_stream_tbl *tx_tbl_ptr) | 
|  | 483 | { | 
|  | 484 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; | 
|  | 485 |  | 
|  | 486 | list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { | 
|  | 487 | if (tx_ba_tsr_tbl == tx_tbl_ptr) | 
|  | 488 | return true; | 
|  | 489 | } | 
|  | 490 |  | 
|  | 491 | return false; | 
|  | 492 | } | 
|  | 493 |  | 
|  | 494 | /* | 
|  | 495 | * This function deletes the given entry in Tx BA Stream table. | 
|  | 496 | * | 
|  | 497 | * The function also performs a validity check on the supplied | 
|  | 498 | * pointer before trying to delete. | 
|  | 499 | */ | 
|  | 500 | void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv, | 
|  | 501 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl) | 
|  | 502 | { | 
|  | 503 | if (!tx_ba_tsr_tbl && | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 504 | mwifiex_is_tx_ba_stream_ptr_valid(priv, tx_ba_tsr_tbl)) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 505 | return; | 
|  | 506 |  | 
|  | 507 | dev_dbg(priv->adapter->dev, "info: tx_ba_tsr_tbl %p\n", tx_ba_tsr_tbl); | 
|  | 508 |  | 
|  | 509 | list_del(&tx_ba_tsr_tbl->list); | 
|  | 510 |  | 
|  | 511 | kfree(tx_ba_tsr_tbl); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 512 | } | 
|  | 513 |  | 
|  | 514 | /* | 
|  | 515 | * This function deletes all the entries in Tx BA Stream table. | 
|  | 516 | */ | 
|  | 517 | void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv) | 
|  | 518 | { | 
|  | 519 | int i; | 
|  | 520 | struct mwifiex_tx_ba_stream_tbl *del_tbl_ptr, *tmp_node; | 
|  | 521 | unsigned long flags; | 
|  | 522 |  | 
|  | 523 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 524 | list_for_each_entry_safe(del_tbl_ptr, tmp_node, | 
|  | 525 | &priv->tx_ba_stream_tbl_ptr, list) | 
|  | 526 | mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv, del_tbl_ptr); | 
|  | 527 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 528 |  | 
|  | 529 | INIT_LIST_HEAD(&priv->tx_ba_stream_tbl_ptr); | 
|  | 530 |  | 
|  | 531 | for (i = 0; i < MAX_NUM_TID; ++i) | 
|  | 532 | priv->aggr_prio_tbl[i].ampdu_ap = | 
|  | 533 | priv->aggr_prio_tbl[i].ampdu_user; | 
|  | 534 | } | 
|  | 535 |  | 
|  | 536 | /* | 
|  | 537 | * This function returns the pointer to an entry in BA Stream | 
|  | 538 | * table which matches the given RA/TID pair. | 
|  | 539 | */ | 
|  | 540 | struct mwifiex_tx_ba_stream_tbl * | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 541 | mwifiex_get_ba_tbl(struct mwifiex_private *priv, int tid, u8 *ra) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 542 | { | 
|  | 543 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; | 
|  | 544 | unsigned long flags; | 
|  | 545 |  | 
|  | 546 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 547 | list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 548 | if (!memcmp(tx_ba_tsr_tbl->ra, ra, ETH_ALEN) && | 
|  | 549 | tx_ba_tsr_tbl->tid == tid) { | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 550 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, | 
|  | 551 | flags); | 
|  | 552 | return tx_ba_tsr_tbl; | 
|  | 553 | } | 
|  | 554 | } | 
|  | 555 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 556 | return NULL; | 
|  | 557 | } | 
|  | 558 |  | 
|  | 559 | /* | 
|  | 560 | * This function creates an entry in Tx BA stream table for the | 
|  | 561 | * given RA/TID pair. | 
|  | 562 | */ | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 563 | void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid, | 
|  | 564 | enum mwifiex_ba_status ba_status) | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 565 | { | 
|  | 566 | struct mwifiex_tx_ba_stream_tbl *new_node; | 
|  | 567 | unsigned long flags; | 
|  | 568 |  | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 569 | if (!mwifiex_get_ba_tbl(priv, tid, ra)) { | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 570 | new_node = kzalloc(sizeof(struct mwifiex_tx_ba_stream_tbl), | 
|  | 571 | GFP_ATOMIC); | 
|  | 572 | if (!new_node) { | 
|  | 573 | dev_err(priv->adapter->dev, | 
|  | 574 | "%s: failed to alloc new_node\n", __func__); | 
|  | 575 | return; | 
|  | 576 | } | 
|  | 577 |  | 
|  | 578 | INIT_LIST_HEAD(&new_node->list); | 
|  | 579 |  | 
|  | 580 | new_node->tid = tid; | 
|  | 581 | new_node->ba_status = ba_status; | 
|  | 582 | memcpy(new_node->ra, ra, ETH_ALEN); | 
|  | 583 |  | 
|  | 584 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 585 | list_add_tail(&new_node->list, &priv->tx_ba_stream_tbl_ptr); | 
|  | 586 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 587 | } | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 588 | } | 
|  | 589 |  | 
|  | 590 | /* | 
|  | 591 | * This function sends an add BA request to the given TID/RA pair. | 
|  | 592 | */ | 
|  | 593 | int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac) | 
|  | 594 | { | 
|  | 595 | struct host_cmd_ds_11n_addba_req add_ba_req; | 
|  | 596 | static u8 dialog_tok; | 
|  | 597 | int ret; | 
|  | 598 |  | 
|  | 599 | dev_dbg(priv->adapter->dev, "cmd: %s: tid %d\n", __func__, tid); | 
|  | 600 |  | 
|  | 601 | add_ba_req.block_ack_param_set = cpu_to_le16( | 
|  | 602 | (u16) ((tid << BLOCKACKPARAM_TID_POS) | | 
|  | 603 | (priv->add_ba_param. | 
|  | 604 | tx_win_size << BLOCKACKPARAM_WINSIZE_POS) | | 
|  | 605 | IMMEDIATE_BLOCK_ACK)); | 
|  | 606 | add_ba_req.block_ack_tmo = cpu_to_le16((u16)priv->add_ba_param.timeout); | 
|  | 607 |  | 
|  | 608 | ++dialog_tok; | 
|  | 609 |  | 
|  | 610 | if (dialog_tok == 0) | 
|  | 611 | dialog_tok = 1; | 
|  | 612 |  | 
|  | 613 | add_ba_req.dialog_token = dialog_tok; | 
|  | 614 | memcpy(&add_ba_req.peer_mac_addr, peer_mac, ETH_ALEN); | 
|  | 615 |  | 
|  | 616 | /* We don't wait for the response of this command */ | 
| Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 617 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_ADDBA_REQ, | 
|  | 618 | 0, 0, &add_ba_req); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 619 |  | 
|  | 620 | return ret; | 
|  | 621 | } | 
|  | 622 |  | 
|  | 623 | /* | 
|  | 624 | * This function sends a delete BA request to the given TID/RA pair. | 
|  | 625 | */ | 
|  | 626 | int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac, | 
|  | 627 | int initiator) | 
|  | 628 | { | 
|  | 629 | struct host_cmd_ds_11n_delba delba; | 
|  | 630 | int ret; | 
|  | 631 | uint16_t del_ba_param_set; | 
|  | 632 |  | 
|  | 633 | memset(&delba, 0, sizeof(delba)); | 
|  | 634 | delba.del_ba_param_set = cpu_to_le16(tid << DELBA_TID_POS); | 
|  | 635 |  | 
|  | 636 | del_ba_param_set = le16_to_cpu(delba.del_ba_param_set); | 
|  | 637 | if (initiator) | 
|  | 638 | del_ba_param_set |= IEEE80211_DELBA_PARAM_INITIATOR_MASK; | 
|  | 639 | else | 
|  | 640 | del_ba_param_set &= ~IEEE80211_DELBA_PARAM_INITIATOR_MASK; | 
|  | 641 |  | 
|  | 642 | memcpy(&delba.peer_mac_addr, peer_mac, ETH_ALEN); | 
|  | 643 |  | 
|  | 644 | /* We don't wait for the response of this command */ | 
| Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 645 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_DELBA, | 
|  | 646 | HostCmd_ACT_GEN_SET, 0, &delba); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 647 |  | 
|  | 648 | return ret; | 
|  | 649 | } | 
|  | 650 |  | 
|  | 651 | /* | 
|  | 652 | * This function handles the command response of a delete BA request. | 
|  | 653 | */ | 
|  | 654 | void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba) | 
|  | 655 | { | 
|  | 656 | struct host_cmd_ds_11n_delba *cmd_del_ba = | 
|  | 657 | (struct host_cmd_ds_11n_delba *) del_ba; | 
|  | 658 | uint16_t del_ba_param_set = le16_to_cpu(cmd_del_ba->del_ba_param_set); | 
|  | 659 | int tid; | 
|  | 660 |  | 
|  | 661 | tid = del_ba_param_set >> DELBA_TID_POS; | 
|  | 662 |  | 
| Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 663 | mwifiex_del_ba_tbl(priv, tid, cmd_del_ba->peer_mac_addr, | 
|  | 664 | TYPE_DELBA_RECEIVE, INITIATOR_BIT(del_ba_param_set)); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 665 | } | 
|  | 666 |  | 
|  | 667 | /* | 
|  | 668 | * This function retrieves the Rx reordering table. | 
|  | 669 | */ | 
|  | 670 | int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv, | 
|  | 671 | struct mwifiex_ds_rx_reorder_tbl *buf) | 
|  | 672 | { | 
|  | 673 | int i; | 
|  | 674 | struct mwifiex_ds_rx_reorder_tbl *rx_reo_tbl = buf; | 
|  | 675 | struct mwifiex_rx_reorder_tbl *rx_reorder_tbl_ptr; | 
|  | 676 | int count = 0; | 
|  | 677 | unsigned long flags; | 
|  | 678 |  | 
|  | 679 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); | 
|  | 680 | list_for_each_entry(rx_reorder_tbl_ptr, &priv->rx_reorder_tbl_ptr, | 
|  | 681 | list) { | 
|  | 682 | rx_reo_tbl->tid = (u16) rx_reorder_tbl_ptr->tid; | 
|  | 683 | memcpy(rx_reo_tbl->ta, rx_reorder_tbl_ptr->ta, ETH_ALEN); | 
|  | 684 | rx_reo_tbl->start_win = rx_reorder_tbl_ptr->start_win; | 
|  | 685 | rx_reo_tbl->win_size = rx_reorder_tbl_ptr->win_size; | 
|  | 686 | for (i = 0; i < rx_reorder_tbl_ptr->win_size; ++i) { | 
|  | 687 | if (rx_reorder_tbl_ptr->rx_reorder_ptr[i]) | 
|  | 688 | rx_reo_tbl->buffer[i] = true; | 
|  | 689 | else | 
|  | 690 | rx_reo_tbl->buffer[i] = false; | 
|  | 691 | } | 
|  | 692 | rx_reo_tbl++; | 
|  | 693 | count++; | 
|  | 694 |  | 
|  | 695 | if (count >= MWIFIEX_MAX_RX_BASTREAM_SUPPORTED) | 
|  | 696 | break; | 
|  | 697 | } | 
|  | 698 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); | 
|  | 699 |  | 
|  | 700 | return count; | 
|  | 701 | } | 
|  | 702 |  | 
|  | 703 | /* | 
|  | 704 | * This function retrieves the Tx BA stream table. | 
|  | 705 | */ | 
|  | 706 | int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv, | 
|  | 707 | struct mwifiex_ds_tx_ba_stream_tbl *buf) | 
|  | 708 | { | 
|  | 709 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; | 
|  | 710 | struct mwifiex_ds_tx_ba_stream_tbl *rx_reo_tbl = buf; | 
|  | 711 | int count = 0; | 
|  | 712 | unsigned long flags; | 
|  | 713 |  | 
|  | 714 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 715 | list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { | 
|  | 716 | rx_reo_tbl->tid = (u16) tx_ba_tsr_tbl->tid; | 
|  | 717 | dev_dbg(priv->adapter->dev, "data: %s tid=%d\n", | 
| Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 718 | __func__, rx_reo_tbl->tid); | 
| Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 719 | memcpy(rx_reo_tbl->ra, tx_ba_tsr_tbl->ra, ETH_ALEN); | 
|  | 720 | rx_reo_tbl++; | 
|  | 721 | count++; | 
|  | 722 | if (count >= MWIFIEX_MAX_TX_BASTREAM_SUPPORTED) | 
|  | 723 | break; | 
|  | 724 | } | 
|  | 725 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); | 
|  | 726 |  | 
|  | 727 | return count; | 
|  | 728 | } |