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 | #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 | */ |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 37 | int mwifiex_fill_cap_info(struct mwifiex_private *priv, u8 radio_type, |
| 38 | struct ieee80211_ht_cap *ht_cap) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 39 | { |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 40 | uint16_t ht_ext_cap = le16_to_cpu(ht_cap->extended_ht_cap_info); |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 41 | struct ieee80211_supported_band *sband = |
| 42 | priv->wdev->wiphy->bands[radio_type]; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 43 | |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 44 | if (WARN_ON_ONCE(!sband)) { |
| 45 | dev_err(priv->adapter->dev, "Invalid radio type!\n"); |
| 46 | return -EINVAL; |
| 47 | } |
| 48 | |
| 49 | ht_cap->ampdu_params_info = |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 50 | (sband->ht_cap.ampdu_factor & |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 51 | IEEE80211_HT_AMPDU_PARM_FACTOR) | |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 52 | ((sband->ht_cap.ampdu_density << |
| 53 | IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT) & |
| 54 | IEEE80211_HT_AMPDU_PARM_DENSITY); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 55 | |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 56 | memcpy((u8 *)&ht_cap->mcs, &sband->ht_cap.mcs, |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 57 | sizeof(sband->ht_cap.mcs)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 58 | |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 59 | if (priv->bss_mode == NL80211_IFTYPE_STATION || |
Amitkumar Karwar | d35f103 | 2013-01-02 16:56:00 -0800 | [diff] [blame] | 60 | (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && |
| 61 | (priv->adapter->sec_chan_offset != |
| 62 | IEEE80211_HT_PARAM_CHA_SEC_NONE))) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 63 | /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */ |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 64 | SETHT_MCS32(ht_cap->mcs.rx_mask); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 65 | |
| 66 | /* Clear RD responder bit */ |
Amitkumar Karwar | a373165 | 2011-04-15 20:50:41 -0700 | [diff] [blame] | 67 | ht_ext_cap &= ~IEEE80211_HT_EXT_CAP_RD_RESPONDER; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 68 | |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 69 | ht_cap->cap_info = cpu_to_le16(sband->ht_cap.cap); |
| 70 | ht_cap->extended_ht_cap_info = cpu_to_le16(ht_ext_cap); |
Amitkumar Karwar | 645097c | 2014-02-07 16:27:26 -0800 | [diff] [blame] | 71 | |
| 72 | if (ISSUPP_BEAMFORMING(priv->adapter->hw_dot_11n_dev_cap)) |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 73 | ht_cap->tx_BF_cap_info = cpu_to_le32(MWIFIEX_DEF_11N_TX_BF_CAP); |
| 74 | |
| 75 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 79 | * This function returns the pointer to an entry in BA Stream |
| 80 | * table which matches the requested BA status. |
| 81 | */ |
| 82 | static struct mwifiex_tx_ba_stream_tbl * |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 83 | mwifiex_get_ba_status(struct mwifiex_private *priv, |
| 84 | enum mwifiex_ba_status ba_status) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 85 | { |
| 86 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; |
| 87 | unsigned long flags; |
| 88 | |
| 89 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 90 | list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { |
| 91 | if (tx_ba_tsr_tbl->ba_status == ba_status) { |
| 92 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, |
| 93 | flags); |
| 94 | return tx_ba_tsr_tbl; |
| 95 | } |
| 96 | } |
| 97 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); |
| 98 | return NULL; |
| 99 | } |
| 100 | |
| 101 | /* |
| 102 | * This function handles the command response of delete a block |
| 103 | * ack request. |
| 104 | * |
| 105 | * The function checks the response success status and takes action |
| 106 | * accordingly (send an add BA request in case of success, or recreate |
| 107 | * the deleted stream in case of failure, if the add BA was also |
| 108 | * initiated by us). |
| 109 | */ |
| 110 | int mwifiex_ret_11n_delba(struct mwifiex_private *priv, |
| 111 | struct host_cmd_ds_command *resp) |
| 112 | { |
| 113 | int tid; |
| 114 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tbl; |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 115 | struct host_cmd_ds_11n_delba *del_ba = &resp->params.del_ba; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 116 | uint16_t del_ba_param_set = le16_to_cpu(del_ba->del_ba_param_set); |
| 117 | |
| 118 | tid = del_ba_param_set >> DELBA_TID_POS; |
| 119 | if (del_ba->del_result == BA_RESULT_SUCCESS) { |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 120 | mwifiex_del_ba_tbl(priv, tid, del_ba->peer_mac_addr, |
| 121 | TYPE_DELBA_SENT, |
| 122 | INITIATOR_BIT(del_ba_param_set)); |
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 | tx_ba_tbl = mwifiex_get_ba_status(priv, BA_SETUP_INPROGRESS); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 125 | if (tx_ba_tbl) |
| 126 | mwifiex_send_addba(priv, tx_ba_tbl->tid, |
| 127 | tx_ba_tbl->ra); |
| 128 | } else { /* |
| 129 | * In case of failure, recreate the deleted stream in case |
| 130 | * we initiated the ADDBA |
| 131 | */ |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 132 | if (!INITIATOR_BIT(del_ba_param_set)) |
| 133 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 134 | |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 135 | mwifiex_create_ba_tbl(priv, del_ba->peer_mac_addr, tid, |
| 136 | BA_SETUP_INPROGRESS); |
| 137 | |
| 138 | tx_ba_tbl = mwifiex_get_ba_status(priv, BA_SETUP_INPROGRESS); |
| 139 | |
| 140 | if (tx_ba_tbl) |
| 141 | mwifiex_del_ba_tbl(priv, tx_ba_tbl->tid, tx_ba_tbl->ra, |
| 142 | TYPE_DELBA_SENT, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | /* |
| 149 | * This function handles the command response of add a block |
| 150 | * ack request. |
| 151 | * |
| 152 | * Handling includes changing the header fields to CPU formats, checking |
| 153 | * the response success status and taking actions accordingly (delete the |
| 154 | * BA stream table in case of failure). |
| 155 | */ |
| 156 | int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv, |
| 157 | struct host_cmd_ds_command *resp) |
| 158 | { |
| 159 | int tid; |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 160 | 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] | 161 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tbl; |
Amitkumar Karwar | 4c9f9fb | 2014-03-07 19:41:31 -0800 | [diff] [blame] | 162 | u16 block_ack_param_set = le16_to_cpu(add_ba_rsp->block_ack_param_set); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 163 | |
| 164 | add_ba_rsp->ssn = cpu_to_le16((le16_to_cpu(add_ba_rsp->ssn)) |
| 165 | & SSN_MASK); |
| 166 | |
Amitkumar Karwar | 4c9f9fb | 2014-03-07 19:41:31 -0800 | [diff] [blame] | 167 | tid = (block_ack_param_set & IEEE80211_ADDBA_PARAM_TID_MASK) |
| 168 | >> BLOCKACKPARAM_TID_POS; |
Amitkumar Karwar | 63410c3 | 2014-03-07 19:41:29 -0800 | [diff] [blame] | 169 | 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] | 170 | mwifiex_del_ba_tbl(priv, tid, add_ba_rsp->peer_mac_addr, |
| 171 | TYPE_DELBA_SENT, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 172 | if (add_ba_rsp->add_rsp_result != BA_RESULT_TIMEOUT) |
| 173 | priv->aggr_prio_tbl[tid].ampdu_ap = |
| 174 | BA_STREAM_NOT_ALLOWED; |
Amitkumar Karwar | 63410c3 | 2014-03-07 19:41:29 -0800 | [diff] [blame] | 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | tx_ba_tbl = mwifiex_get_ba_tbl(priv, tid, add_ba_rsp->peer_mac_addr); |
| 179 | if (tx_ba_tbl) { |
| 180 | dev_dbg(priv->adapter->dev, "info: BA stream complete\n"); |
| 181 | tx_ba_tbl->ba_status = BA_SETUP_COMPLETE; |
Amitkumar Karwar | 4c9f9fb | 2014-03-07 19:41:31 -0800 | [diff] [blame] | 182 | if ((block_ack_param_set & BLOCKACKPARAM_AMSDU_SUPP_MASK) && |
| 183 | priv->add_ba_param.tx_amsdu && |
| 184 | (priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED)) |
| 185 | tx_ba_tbl->amsdu = true; |
| 186 | else |
| 187 | tx_ba_tbl->amsdu = false; |
Amitkumar Karwar | 63410c3 | 2014-03-07 19:41:29 -0800 | [diff] [blame] | 188 | } else { |
| 189 | dev_err(priv->adapter->dev, "BA stream not created\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 261 | * This function prepares 11n configuration command. |
| 262 | * |
| 263 | * Preparation includes - |
| 264 | * - Setting command ID, action and proper size |
| 265 | * - Setting HT Tx capability and HT Tx information fields |
| 266 | * - Ensuring correct endian-ness |
| 267 | */ |
Yogesh Ashok Powar | a5f3905 | 2013-02-15 21:44:30 -0800 | [diff] [blame] | 268 | int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv, |
| 269 | struct host_cmd_ds_command *cmd, u16 cmd_action, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 270 | struct mwifiex_ds_11n_tx_cfg *txcfg) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 271 | { |
| 272 | struct host_cmd_ds_11n_cfg *htcfg = &cmd->params.htcfg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 273 | |
| 274 | cmd->command = cpu_to_le16(HostCmd_CMD_11N_CFG); |
| 275 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_11n_cfg) + S_DS_GEN); |
| 276 | htcfg->action = cpu_to_le16(cmd_action); |
| 277 | htcfg->ht_tx_cap = cpu_to_le16(txcfg->tx_htcap); |
| 278 | htcfg->ht_tx_info = cpu_to_le16(txcfg->tx_htinfo); |
Yogesh Ashok Powar | a5f3905 | 2013-02-15 21:44:30 -0800 | [diff] [blame] | 279 | |
| 280 | if (priv->adapter->is_hw_11ac_capable) |
| 281 | htcfg->misc_config = cpu_to_le16(txcfg->misc_config); |
| 282 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | /* |
| 287 | * This function appends an 11n TLV to a buffer. |
| 288 | * |
| 289 | * Buffer allocation is responsibility of the calling |
| 290 | * function. No size validation is made here. |
| 291 | * |
| 292 | * The function fills up the following sections, if applicable - |
| 293 | * - HT capability IE |
| 294 | * - HT information IE (with channel list) |
| 295 | * - 20/40 BSS Coexistence IE |
| 296 | * - HT Extended Capabilities IE |
| 297 | */ |
| 298 | int |
| 299 | mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv, |
| 300 | struct mwifiex_bssdescriptor *bss_desc, |
| 301 | u8 **buffer) |
| 302 | { |
| 303 | struct mwifiex_ie_types_htcap *ht_cap; |
| 304 | struct mwifiex_ie_types_htinfo *ht_info; |
| 305 | struct mwifiex_ie_types_chan_list_param_set *chan_list; |
| 306 | struct mwifiex_ie_types_2040bssco *bss_co_2040; |
| 307 | struct mwifiex_ie_types_extcap *ext_cap; |
| 308 | int ret_len = 0; |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 309 | struct ieee80211_supported_band *sband; |
Avinash Patil | 68f95b09 | 2013-08-23 16:48:22 -0700 | [diff] [blame] | 310 | struct ieee_types_header *hdr; |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 311 | u8 radio_type; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 312 | |
| 313 | if (!buffer || !*buffer) |
| 314 | return ret_len; |
| 315 | |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 316 | radio_type = mwifiex_band_to_radio_type((u8) bss_desc->bss_band); |
| 317 | sband = priv->wdev->wiphy->bands[radio_type]; |
| 318 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 319 | if (bss_desc->bcn_ht_cap) { |
| 320 | ht_cap = (struct mwifiex_ie_types_htcap *) *buffer; |
| 321 | memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap)); |
| 322 | ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); |
| 323 | ht_cap->header.len = |
| 324 | cpu_to_le16(sizeof(struct ieee80211_ht_cap)); |
| 325 | memcpy((u8 *) ht_cap + sizeof(struct mwifiex_ie_types_header), |
Amitkumar Karwar | c99b186 | 2014-03-04 18:43:13 -0800 | [diff] [blame] | 326 | (u8 *)bss_desc->bcn_ht_cap, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 327 | le16_to_cpu(ht_cap->header.len)); |
| 328 | |
Amitkumar Karwar | 341b880 | 2014-02-07 16:27:31 -0800 | [diff] [blame] | 329 | mwifiex_fill_cap_info(priv, radio_type, &ht_cap->ht_cap); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 330 | |
| 331 | *buffer += sizeof(struct mwifiex_ie_types_htcap); |
| 332 | ret_len += sizeof(struct mwifiex_ie_types_htcap); |
| 333 | } |
| 334 | |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 335 | if (bss_desc->bcn_ht_oper) { |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 336 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 337 | ht_info = (struct mwifiex_ie_types_htinfo *) *buffer; |
| 338 | memset(ht_info, 0, |
| 339 | sizeof(struct mwifiex_ie_types_htinfo)); |
| 340 | ht_info->header.type = |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 341 | cpu_to_le16(WLAN_EID_HT_OPERATION); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 342 | ht_info->header.len = |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 343 | cpu_to_le16( |
| 344 | sizeof(struct ieee80211_ht_operation)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 345 | |
| 346 | memcpy((u8 *) ht_info + |
| 347 | sizeof(struct mwifiex_ie_types_header), |
Amitkumar Karwar | cf831ff | 2014-04-16 22:01:53 -0700 | [diff] [blame] | 348 | (u8 *)bss_desc->bcn_ht_oper, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 349 | le16_to_cpu(ht_info->header.len)); |
| 350 | |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 351 | if (!(sband->ht_cap.cap & |
| 352 | IEEE80211_HT_CAP_SUP_WIDTH_20_40)) |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 353 | ht_info->ht_oper.ht_param &= |
Marc Yang | 6d2bd91 | 2011-03-25 19:47:02 -0700 | [diff] [blame] | 354 | ~(IEEE80211_HT_PARAM_CHAN_WIDTH_ANY | |
| 355 | IEEE80211_HT_PARAM_CHA_SEC_OFFSET); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 356 | |
| 357 | *buffer += sizeof(struct mwifiex_ie_types_htinfo); |
| 358 | ret_len += sizeof(struct mwifiex_ie_types_htinfo); |
| 359 | } |
| 360 | |
| 361 | chan_list = |
| 362 | (struct mwifiex_ie_types_chan_list_param_set *) *buffer; |
| 363 | memset(chan_list, 0, |
| 364 | sizeof(struct mwifiex_ie_types_chan_list_param_set)); |
| 365 | chan_list->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); |
| 366 | chan_list->header.len = cpu_to_le16( |
| 367 | sizeof(struct mwifiex_ie_types_chan_list_param_set) - |
| 368 | sizeof(struct mwifiex_ie_types_header)); |
| 369 | chan_list->chan_scan_param[0].chan_number = |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 370 | bss_desc->bcn_ht_oper->primary_chan; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 371 | chan_list->chan_scan_param[0].radio_type = |
| 372 | mwifiex_band_to_radio_type((u8) bss_desc->bss_band); |
| 373 | |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 374 | if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 375 | bss_desc->bcn_ht_oper->ht_param & |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 376 | IEEE80211_HT_PARAM_CHAN_WIDTH_ANY) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 377 | SET_SECONDARYCHAN(chan_list->chan_scan_param[0]. |
| 378 | radio_type, |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 379 | (bss_desc->bcn_ht_oper->ht_param & |
Marc Yang | 6d2bd91 | 2011-03-25 19:47:02 -0700 | [diff] [blame] | 380 | IEEE80211_HT_PARAM_CHA_SEC_OFFSET)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 381 | |
| 382 | *buffer += sizeof(struct mwifiex_ie_types_chan_list_param_set); |
| 383 | ret_len += sizeof(struct mwifiex_ie_types_chan_list_param_set); |
| 384 | } |
| 385 | |
| 386 | if (bss_desc->bcn_bss_co_2040) { |
| 387 | bss_co_2040 = (struct mwifiex_ie_types_2040bssco *) *buffer; |
| 388 | memset(bss_co_2040, 0, |
| 389 | sizeof(struct mwifiex_ie_types_2040bssco)); |
| 390 | bss_co_2040->header.type = cpu_to_le16(WLAN_EID_BSS_COEX_2040); |
| 391 | bss_co_2040->header.len = |
| 392 | cpu_to_le16(sizeof(bss_co_2040->bss_co_2040)); |
| 393 | |
| 394 | memcpy((u8 *) bss_co_2040 + |
| 395 | sizeof(struct mwifiex_ie_types_header), |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 396 | bss_desc->bcn_bss_co_2040 + |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 397 | sizeof(struct ieee_types_header), |
| 398 | le16_to_cpu(bss_co_2040->header.len)); |
| 399 | |
| 400 | *buffer += sizeof(struct mwifiex_ie_types_2040bssco); |
| 401 | ret_len += sizeof(struct mwifiex_ie_types_2040bssco); |
| 402 | } |
| 403 | |
| 404 | if (bss_desc->bcn_ext_cap) { |
Avinash Patil | 68f95b09 | 2013-08-23 16:48:22 -0700 | [diff] [blame] | 405 | hdr = (void *)bss_desc->bcn_ext_cap; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 406 | ext_cap = (struct mwifiex_ie_types_extcap *) *buffer; |
| 407 | memset(ext_cap, 0, sizeof(struct mwifiex_ie_types_extcap)); |
| 408 | ext_cap->header.type = cpu_to_le16(WLAN_EID_EXT_CAPABILITY); |
Avinash Patil | 68f95b09 | 2013-08-23 16:48:22 -0700 | [diff] [blame] | 409 | ext_cap->header.len = cpu_to_le16(hdr->len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 410 | |
Avinash Patil | 68f95b09 | 2013-08-23 16:48:22 -0700 | [diff] [blame] | 411 | memcpy((u8 *)ext_cap->ext_capab, |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 412 | bss_desc->bcn_ext_cap + sizeof(struct ieee_types_header), |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 413 | le16_to_cpu(ext_cap->header.len)); |
| 414 | |
Avinash Patil | 587b36d | 2013-08-23 16:48:23 -0700 | [diff] [blame] | 415 | if (hdr->len > 3 && |
| 416 | ext_cap->ext_capab[3] & WLAN_EXT_CAPA4_INTERWORKING_ENABLED) |
| 417 | priv->hs2_enabled = true; |
| 418 | else |
| 419 | priv->hs2_enabled = false; |
| 420 | |
Avinash Patil | 68f95b09 | 2013-08-23 16:48:22 -0700 | [diff] [blame] | 421 | *buffer += sizeof(struct mwifiex_ie_types_extcap) + hdr->len; |
| 422 | ret_len += sizeof(struct mwifiex_ie_types_extcap) + hdr->len; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | return ret_len; |
| 426 | } |
| 427 | |
| 428 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 429 | * This function checks if the given pointer is valid entry of |
| 430 | * Tx BA Stream table. |
| 431 | */ |
| 432 | static int mwifiex_is_tx_ba_stream_ptr_valid(struct mwifiex_private *priv, |
| 433 | struct mwifiex_tx_ba_stream_tbl *tx_tbl_ptr) |
| 434 | { |
| 435 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; |
| 436 | |
| 437 | list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { |
| 438 | if (tx_ba_tsr_tbl == tx_tbl_ptr) |
| 439 | return true; |
| 440 | } |
| 441 | |
| 442 | return false; |
| 443 | } |
| 444 | |
| 445 | /* |
| 446 | * This function deletes the given entry in Tx BA Stream table. |
| 447 | * |
| 448 | * The function also performs a validity check on the supplied |
| 449 | * pointer before trying to delete. |
| 450 | */ |
| 451 | void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv, |
| 452 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl) |
| 453 | { |
| 454 | if (!tx_ba_tsr_tbl && |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 455 | mwifiex_is_tx_ba_stream_ptr_valid(priv, tx_ba_tsr_tbl)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 456 | return; |
| 457 | |
| 458 | dev_dbg(priv->adapter->dev, "info: tx_ba_tsr_tbl %p\n", tx_ba_tsr_tbl); |
| 459 | |
| 460 | list_del(&tx_ba_tsr_tbl->list); |
| 461 | |
| 462 | kfree(tx_ba_tsr_tbl); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | /* |
| 466 | * This function deletes all the entries in Tx BA Stream table. |
| 467 | */ |
| 468 | void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv) |
| 469 | { |
| 470 | int i; |
| 471 | struct mwifiex_tx_ba_stream_tbl *del_tbl_ptr, *tmp_node; |
| 472 | unsigned long flags; |
| 473 | |
| 474 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 475 | list_for_each_entry_safe(del_tbl_ptr, tmp_node, |
| 476 | &priv->tx_ba_stream_tbl_ptr, list) |
| 477 | mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv, del_tbl_ptr); |
| 478 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); |
| 479 | |
| 480 | INIT_LIST_HEAD(&priv->tx_ba_stream_tbl_ptr); |
| 481 | |
| 482 | for (i = 0; i < MAX_NUM_TID; ++i) |
| 483 | priv->aggr_prio_tbl[i].ampdu_ap = |
| 484 | priv->aggr_prio_tbl[i].ampdu_user; |
| 485 | } |
| 486 | |
| 487 | /* |
| 488 | * This function returns the pointer to an entry in BA Stream |
| 489 | * table which matches the given RA/TID pair. |
| 490 | */ |
| 491 | struct mwifiex_tx_ba_stream_tbl * |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 492 | mwifiex_get_ba_tbl(struct mwifiex_private *priv, int tid, u8 *ra) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 493 | { |
| 494 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; |
| 495 | unsigned long flags; |
| 496 | |
| 497 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 498 | list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { |
dingtianhong | fcad766 | 2013-12-26 19:41:27 +0800 | [diff] [blame] | 499 | if (ether_addr_equal_unaligned(tx_ba_tsr_tbl->ra, ra) && |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 500 | tx_ba_tsr_tbl->tid == tid) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 501 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, |
| 502 | flags); |
| 503 | return tx_ba_tsr_tbl; |
| 504 | } |
| 505 | } |
| 506 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); |
| 507 | return NULL; |
| 508 | } |
| 509 | |
| 510 | /* |
| 511 | * This function creates an entry in Tx BA stream table for the |
| 512 | * given RA/TID pair. |
| 513 | */ |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 514 | void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid, |
| 515 | enum mwifiex_ba_status ba_status) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 516 | { |
| 517 | struct mwifiex_tx_ba_stream_tbl *new_node; |
| 518 | unsigned long flags; |
| 519 | |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 520 | if (!mwifiex_get_ba_tbl(priv, tid, ra)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 521 | new_node = kzalloc(sizeof(struct mwifiex_tx_ba_stream_tbl), |
| 522 | GFP_ATOMIC); |
Joe Perches | 0d2e7a5 | 2013-02-03 17:28:14 +0000 | [diff] [blame] | 523 | if (!new_node) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 524 | return; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 525 | |
| 526 | INIT_LIST_HEAD(&new_node->list); |
| 527 | |
| 528 | new_node->tid = tid; |
| 529 | new_node->ba_status = ba_status; |
| 530 | memcpy(new_node->ra, ra, ETH_ALEN); |
| 531 | |
| 532 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 533 | list_add_tail(&new_node->list, &priv->tx_ba_stream_tbl_ptr); |
| 534 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); |
| 535 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | /* |
| 539 | * This function sends an add BA request to the given TID/RA pair. |
| 540 | */ |
| 541 | int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac) |
| 542 | { |
| 543 | struct host_cmd_ds_11n_addba_req add_ba_req; |
Avinash Patil | b06c5321 | 2014-02-07 16:30:40 -0800 | [diff] [blame] | 544 | u32 tx_win_size = priv->add_ba_param.tx_win_size; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 545 | static u8 dialog_tok; |
| 546 | int ret; |
Avinash Patil | c11fb98 | 2014-12-05 23:23:41 +0530 | [diff] [blame^] | 547 | unsigned long flags; |
Amitkumar Karwar | 4c9f9fb | 2014-03-07 19:41:31 -0800 | [diff] [blame] | 548 | u16 block_ack_param_set; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 549 | |
| 550 | dev_dbg(priv->adapter->dev, "cmd: %s: tid %d\n", __func__, tid); |
| 551 | |
Avinash Patil | b06c5321 | 2014-02-07 16:30:40 -0800 | [diff] [blame] | 552 | if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && |
| 553 | ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && |
| 554 | priv->adapter->is_hw_11ac_capable && |
| 555 | memcmp(priv->cfg_bssid, peer_mac, ETH_ALEN)) { |
Bing Zhao | ea4eb7f | 2014-07-11 20:57:14 -0700 | [diff] [blame] | 556 | struct mwifiex_sta_node *sta_ptr; |
| 557 | |
Avinash Patil | c11fb98 | 2014-12-05 23:23:41 +0530 | [diff] [blame^] | 558 | spin_lock_irqsave(&priv->sta_list_spinlock, flags); |
Avinash Patil | b06c5321 | 2014-02-07 16:30:40 -0800 | [diff] [blame] | 559 | sta_ptr = mwifiex_get_sta_entry(priv, peer_mac); |
| 560 | if (!sta_ptr) { |
| 561 | dev_warn(priv->adapter->dev, |
| 562 | "BA setup with unknown TDLS peer %pM!\n", |
| 563 | peer_mac); |
Avinash Patil | c11fb98 | 2014-12-05 23:23:41 +0530 | [diff] [blame^] | 564 | spin_unlock_irqrestore(&priv->sta_list_spinlock, flags); |
Avinash Patil | b06c5321 | 2014-02-07 16:30:40 -0800 | [diff] [blame] | 565 | return -1; |
| 566 | } |
| 567 | if (sta_ptr->is_11ac_enabled) |
| 568 | tx_win_size = MWIFIEX_11AC_STA_AMPDU_DEF_TXWINSIZE; |
Avinash Patil | c11fb98 | 2014-12-05 23:23:41 +0530 | [diff] [blame^] | 569 | spin_unlock_irqrestore(&priv->sta_list_spinlock, flags); |
Avinash Patil | b06c5321 | 2014-02-07 16:30:40 -0800 | [diff] [blame] | 570 | } |
| 571 | |
Amitkumar Karwar | 4c9f9fb | 2014-03-07 19:41:31 -0800 | [diff] [blame] | 572 | block_ack_param_set = (u16)((tid << BLOCKACKPARAM_TID_POS) | |
| 573 | tx_win_size << BLOCKACKPARAM_WINSIZE_POS | |
| 574 | IMMEDIATE_BLOCK_ACK); |
| 575 | |
| 576 | /* enable AMSDU inside AMPDU */ |
| 577 | if (priv->add_ba_param.tx_amsdu && |
| 578 | (priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED)) |
| 579 | block_ack_param_set |= BLOCKACKPARAM_AMSDU_SUPP_MASK; |
| 580 | |
| 581 | add_ba_req.block_ack_param_set = cpu_to_le16(block_ack_param_set); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 582 | add_ba_req.block_ack_tmo = cpu_to_le16((u16)priv->add_ba_param.timeout); |
| 583 | |
| 584 | ++dialog_tok; |
| 585 | |
| 586 | if (dialog_tok == 0) |
| 587 | dialog_tok = 1; |
| 588 | |
| 589 | add_ba_req.dialog_token = dialog_tok; |
| 590 | memcpy(&add_ba_req.peer_mac_addr, peer_mac, ETH_ALEN); |
| 591 | |
| 592 | /* We don't wait for the response of this command */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 593 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_REQ, |
| 594 | 0, 0, &add_ba_req, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 595 | |
| 596 | return ret; |
| 597 | } |
| 598 | |
| 599 | /* |
| 600 | * This function sends a delete BA request to the given TID/RA pair. |
| 601 | */ |
| 602 | int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac, |
| 603 | int initiator) |
| 604 | { |
| 605 | struct host_cmd_ds_11n_delba delba; |
| 606 | int ret; |
| 607 | uint16_t del_ba_param_set; |
| 608 | |
| 609 | memset(&delba, 0, sizeof(delba)); |
| 610 | delba.del_ba_param_set = cpu_to_le16(tid << DELBA_TID_POS); |
| 611 | |
| 612 | del_ba_param_set = le16_to_cpu(delba.del_ba_param_set); |
| 613 | if (initiator) |
| 614 | del_ba_param_set |= IEEE80211_DELBA_PARAM_INITIATOR_MASK; |
| 615 | else |
| 616 | del_ba_param_set &= ~IEEE80211_DELBA_PARAM_INITIATOR_MASK; |
| 617 | |
| 618 | memcpy(&delba.peer_mac_addr, peer_mac, ETH_ALEN); |
| 619 | |
| 620 | /* We don't wait for the response of this command */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 621 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_11N_DELBA, |
| 622 | HostCmd_ACT_GEN_SET, 0, &delba, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 623 | |
| 624 | return ret; |
| 625 | } |
| 626 | |
| 627 | /* |
| 628 | * This function handles the command response of a delete BA request. |
| 629 | */ |
| 630 | void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba) |
| 631 | { |
| 632 | struct host_cmd_ds_11n_delba *cmd_del_ba = |
| 633 | (struct host_cmd_ds_11n_delba *) del_ba; |
| 634 | uint16_t del_ba_param_set = le16_to_cpu(cmd_del_ba->del_ba_param_set); |
| 635 | int tid; |
| 636 | |
| 637 | tid = del_ba_param_set >> DELBA_TID_POS; |
| 638 | |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 639 | mwifiex_del_ba_tbl(priv, tid, cmd_del_ba->peer_mac_addr, |
| 640 | TYPE_DELBA_RECEIVE, INITIATOR_BIT(del_ba_param_set)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | /* |
| 644 | * This function retrieves the Rx reordering table. |
| 645 | */ |
| 646 | int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv, |
| 647 | struct mwifiex_ds_rx_reorder_tbl *buf) |
| 648 | { |
| 649 | int i; |
| 650 | struct mwifiex_ds_rx_reorder_tbl *rx_reo_tbl = buf; |
| 651 | struct mwifiex_rx_reorder_tbl *rx_reorder_tbl_ptr; |
| 652 | int count = 0; |
| 653 | unsigned long flags; |
| 654 | |
| 655 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
| 656 | list_for_each_entry(rx_reorder_tbl_ptr, &priv->rx_reorder_tbl_ptr, |
| 657 | list) { |
| 658 | rx_reo_tbl->tid = (u16) rx_reorder_tbl_ptr->tid; |
| 659 | memcpy(rx_reo_tbl->ta, rx_reorder_tbl_ptr->ta, ETH_ALEN); |
| 660 | rx_reo_tbl->start_win = rx_reorder_tbl_ptr->start_win; |
| 661 | rx_reo_tbl->win_size = rx_reorder_tbl_ptr->win_size; |
| 662 | for (i = 0; i < rx_reorder_tbl_ptr->win_size; ++i) { |
| 663 | if (rx_reorder_tbl_ptr->rx_reorder_ptr[i]) |
| 664 | rx_reo_tbl->buffer[i] = true; |
| 665 | else |
| 666 | rx_reo_tbl->buffer[i] = false; |
| 667 | } |
| 668 | rx_reo_tbl++; |
| 669 | count++; |
| 670 | |
| 671 | if (count >= MWIFIEX_MAX_RX_BASTREAM_SUPPORTED) |
| 672 | break; |
| 673 | } |
| 674 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
| 675 | |
| 676 | return count; |
| 677 | } |
| 678 | |
| 679 | /* |
| 680 | * This function retrieves the Tx BA stream table. |
| 681 | */ |
| 682 | int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv, |
| 683 | struct mwifiex_ds_tx_ba_stream_tbl *buf) |
| 684 | { |
| 685 | struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; |
| 686 | struct mwifiex_ds_tx_ba_stream_tbl *rx_reo_tbl = buf; |
| 687 | int count = 0; |
| 688 | unsigned long flags; |
| 689 | |
| 690 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 691 | list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { |
| 692 | rx_reo_tbl->tid = (u16) tx_ba_tsr_tbl->tid; |
| 693 | dev_dbg(priv->adapter->dev, "data: %s tid=%d\n", |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 694 | __func__, rx_reo_tbl->tid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 695 | memcpy(rx_reo_tbl->ra, tx_ba_tsr_tbl->ra, ETH_ALEN); |
Amitkumar Karwar | 4c9f9fb | 2014-03-07 19:41:31 -0800 | [diff] [blame] | 696 | rx_reo_tbl->amsdu = tx_ba_tsr_tbl->amsdu; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 697 | rx_reo_tbl++; |
| 698 | count++; |
| 699 | if (count >= MWIFIEX_MAX_TX_BASTREAM_SUPPORTED) |
| 700 | break; |
| 701 | } |
| 702 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); |
| 703 | |
| 704 | return count; |
| 705 | } |
Avinash Patil | 3e238a1 | 2012-08-03 18:06:11 -0700 | [diff] [blame] | 706 | |
| 707 | /* |
| 708 | * This function retrieves the entry for specific tx BA stream table by RA and |
| 709 | * deletes it. |
| 710 | */ |
| 711 | void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra) |
| 712 | { |
| 713 | struct mwifiex_tx_ba_stream_tbl *tbl, *tmp; |
| 714 | unsigned long flags; |
| 715 | |
| 716 | if (!ra) |
| 717 | return; |
| 718 | |
| 719 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 720 | list_for_each_entry_safe(tbl, tmp, &priv->tx_ba_stream_tbl_ptr, list) { |
| 721 | if (!memcmp(tbl->ra, ra, ETH_ALEN)) { |
| 722 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, |
| 723 | flags); |
| 724 | mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv, tbl); |
| 725 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 726 | } |
| 727 | } |
| 728 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); |
| 729 | |
| 730 | return; |
| 731 | } |
Avinash Patil | 04abc0a | 2013-03-27 19:10:31 -0700 | [diff] [blame] | 732 | |
| 733 | /* This function initializes the BlockACK setup information for given |
| 734 | * mwifiex_private structure. |
| 735 | */ |
| 736 | void mwifiex_set_ba_params(struct mwifiex_private *priv) |
| 737 | { |
| 738 | priv->add_ba_param.timeout = MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT; |
| 739 | |
| 740 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) { |
| 741 | priv->add_ba_param.tx_win_size = |
| 742 | MWIFIEX_UAP_AMPDU_DEF_TXWINSIZE; |
| 743 | priv->add_ba_param.rx_win_size = |
| 744 | MWIFIEX_UAP_AMPDU_DEF_RXWINSIZE; |
| 745 | } else { |
| 746 | priv->add_ba_param.tx_win_size = |
| 747 | MWIFIEX_STA_AMPDU_DEF_TXWINSIZE; |
| 748 | priv->add_ba_param.rx_win_size = |
| 749 | MWIFIEX_STA_AMPDU_DEF_RXWINSIZE; |
| 750 | } |
| 751 | |
Amitkumar Karwar | 4c9f9fb | 2014-03-07 19:41:31 -0800 | [diff] [blame] | 752 | priv->add_ba_param.tx_amsdu = true; |
| 753 | priv->add_ba_param.rx_amsdu = true; |
| 754 | |
Avinash Patil | 04abc0a | 2013-03-27 19:10:31 -0700 | [diff] [blame] | 755 | return; |
| 756 | } |
Avinash Patil | 396939f | 2014-05-06 22:02:45 -0700 | [diff] [blame] | 757 | |
| 758 | u8 mwifiex_get_sec_chan_offset(int chan) |
| 759 | { |
| 760 | u8 sec_offset; |
| 761 | |
| 762 | switch (chan) { |
| 763 | case 36: |
| 764 | case 44: |
| 765 | case 52: |
| 766 | case 60: |
| 767 | case 100: |
| 768 | case 108: |
| 769 | case 116: |
| 770 | case 124: |
| 771 | case 132: |
| 772 | case 140: |
| 773 | case 149: |
| 774 | case 157: |
| 775 | sec_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; |
| 776 | break; |
| 777 | case 40: |
| 778 | case 48: |
| 779 | case 56: |
| 780 | case 64: |
| 781 | case 104: |
| 782 | case 112: |
| 783 | case 120: |
| 784 | case 128: |
| 785 | case 136: |
| 786 | case 144: |
| 787 | case 153: |
| 788 | case 161: |
| 789 | sec_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW; |
| 790 | break; |
| 791 | case 165: |
| 792 | default: |
| 793 | sec_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE; |
| 794 | break; |
| 795 | } |
| 796 | |
| 797 | return sec_offset; |
| 798 | } |