0001
0002
0003
0004
0005
0006
0007
0008 #include "decl.h"
0009 #include "ioctl.h"
0010 #include "util.h"
0011 #include "fw.h"
0012 #include "main.h"
0013 #include "wmm.h"
0014 #include "11n.h"
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 int mwifiex_fill_cap_info(struct mwifiex_private *priv, u8 radio_type,
0026 struct ieee80211_ht_cap *ht_cap)
0027 {
0028 uint16_t ht_ext_cap = le16_to_cpu(ht_cap->extended_ht_cap_info);
0029 struct ieee80211_supported_band *sband =
0030 priv->wdev.wiphy->bands[radio_type];
0031
0032 if (WARN_ON_ONCE(!sband)) {
0033 mwifiex_dbg(priv->adapter, ERROR, "Invalid radio type!\n");
0034 return -EINVAL;
0035 }
0036
0037 ht_cap->ampdu_params_info =
0038 (sband->ht_cap.ampdu_factor &
0039 IEEE80211_HT_AMPDU_PARM_FACTOR) |
0040 ((sband->ht_cap.ampdu_density <<
0041 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT) &
0042 IEEE80211_HT_AMPDU_PARM_DENSITY);
0043
0044 memcpy((u8 *)&ht_cap->mcs, &sband->ht_cap.mcs,
0045 sizeof(sband->ht_cap.mcs));
0046
0047 if (priv->bss_mode == NL80211_IFTYPE_STATION ||
0048 (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 &&
0049 (priv->adapter->sec_chan_offset !=
0050 IEEE80211_HT_PARAM_CHA_SEC_NONE)))
0051
0052 SETHT_MCS32(ht_cap->mcs.rx_mask);
0053
0054
0055 ht_ext_cap &= ~IEEE80211_HT_EXT_CAP_RD_RESPONDER;
0056
0057 ht_cap->cap_info = cpu_to_le16(sband->ht_cap.cap);
0058 ht_cap->extended_ht_cap_info = cpu_to_le16(ht_ext_cap);
0059
0060 if (ISSUPP_BEAMFORMING(priv->adapter->hw_dot_11n_dev_cap))
0061 ht_cap->tx_BF_cap_info = cpu_to_le32(MWIFIEX_DEF_11N_TX_BF_CAP);
0062
0063 return 0;
0064 }
0065
0066
0067
0068
0069
0070 static struct mwifiex_tx_ba_stream_tbl *
0071 mwifiex_get_ba_status(struct mwifiex_private *priv,
0072 enum mwifiex_ba_status ba_status)
0073 {
0074 struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl;
0075
0076 spin_lock_bh(&priv->tx_ba_stream_tbl_lock);
0077 list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
0078 if (tx_ba_tsr_tbl->ba_status == ba_status) {
0079 spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0080 return tx_ba_tsr_tbl;
0081 }
0082 }
0083 spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0084 return NULL;
0085 }
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 int mwifiex_ret_11n_delba(struct mwifiex_private *priv,
0097 struct host_cmd_ds_command *resp)
0098 {
0099 int tid;
0100 struct mwifiex_tx_ba_stream_tbl *tx_ba_tbl;
0101 struct host_cmd_ds_11n_delba *del_ba = &resp->params.del_ba;
0102 uint16_t del_ba_param_set = le16_to_cpu(del_ba->del_ba_param_set);
0103
0104 tid = del_ba_param_set >> DELBA_TID_POS;
0105 if (del_ba->del_result == BA_RESULT_SUCCESS) {
0106 mwifiex_del_ba_tbl(priv, tid, del_ba->peer_mac_addr,
0107 TYPE_DELBA_SENT,
0108 INITIATOR_BIT(del_ba_param_set));
0109
0110 tx_ba_tbl = mwifiex_get_ba_status(priv, BA_SETUP_INPROGRESS);
0111 if (tx_ba_tbl)
0112 mwifiex_send_addba(priv, tx_ba_tbl->tid,
0113 tx_ba_tbl->ra);
0114 } else {
0115
0116
0117
0118 if (!INITIATOR_BIT(del_ba_param_set))
0119 return 0;
0120
0121 mwifiex_create_ba_tbl(priv, del_ba->peer_mac_addr, tid,
0122 BA_SETUP_INPROGRESS);
0123
0124 tx_ba_tbl = mwifiex_get_ba_status(priv, BA_SETUP_INPROGRESS);
0125
0126 if (tx_ba_tbl)
0127 mwifiex_del_ba_tbl(priv, tx_ba_tbl->tid, tx_ba_tbl->ra,
0128 TYPE_DELBA_SENT, true);
0129 }
0130
0131 return 0;
0132 }
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
0143 struct host_cmd_ds_command *resp)
0144 {
0145 int tid, tid_down;
0146 struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &resp->params.add_ba_rsp;
0147 struct mwifiex_tx_ba_stream_tbl *tx_ba_tbl;
0148 struct mwifiex_ra_list_tbl *ra_list;
0149 u16 block_ack_param_set = le16_to_cpu(add_ba_rsp->block_ack_param_set);
0150
0151 add_ba_rsp->ssn = cpu_to_le16((le16_to_cpu(add_ba_rsp->ssn))
0152 & SSN_MASK);
0153
0154 tid = (block_ack_param_set & IEEE80211_ADDBA_PARAM_TID_MASK)
0155 >> BLOCKACKPARAM_TID_POS;
0156
0157 tid_down = mwifiex_wmm_downgrade_tid(priv, tid);
0158 ra_list = mwifiex_wmm_get_ralist_node(priv, tid_down, add_ba_rsp->
0159 peer_mac_addr);
0160 if (le16_to_cpu(add_ba_rsp->status_code) != BA_RESULT_SUCCESS) {
0161 if (ra_list) {
0162 ra_list->ba_status = BA_SETUP_NONE;
0163 ra_list->amsdu_in_ampdu = false;
0164 }
0165 mwifiex_del_ba_tbl(priv, tid, add_ba_rsp->peer_mac_addr,
0166 TYPE_DELBA_SENT, true);
0167 if (add_ba_rsp->add_rsp_result != BA_RESULT_TIMEOUT)
0168 priv->aggr_prio_tbl[tid].ampdu_ap =
0169 BA_STREAM_NOT_ALLOWED;
0170 return 0;
0171 }
0172
0173 tx_ba_tbl = mwifiex_get_ba_tbl(priv, tid, add_ba_rsp->peer_mac_addr);
0174 if (tx_ba_tbl) {
0175 mwifiex_dbg(priv->adapter, EVENT, "info: BA stream complete\n");
0176 tx_ba_tbl->ba_status = BA_SETUP_COMPLETE;
0177 if ((block_ack_param_set & BLOCKACKPARAM_AMSDU_SUPP_MASK) &&
0178 priv->add_ba_param.tx_amsdu &&
0179 (priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED))
0180 tx_ba_tbl->amsdu = true;
0181 else
0182 tx_ba_tbl->amsdu = false;
0183 if (ra_list) {
0184 ra_list->amsdu_in_ampdu = tx_ba_tbl->amsdu;
0185 ra_list->ba_status = BA_SETUP_COMPLETE;
0186 }
0187 } else {
0188 mwifiex_dbg(priv->adapter, ERROR, "BA stream not created\n");
0189 }
0190
0191 return 0;
0192 }
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202 int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv,
0203 struct host_cmd_ds_command *cmd, int cmd_action,
0204 u16 *buf_size)
0205 {
0206 struct host_cmd_ds_txbuf_cfg *tx_buf = &cmd->params.tx_buf;
0207 u16 action = (u16) cmd_action;
0208
0209 cmd->command = cpu_to_le16(HostCmd_CMD_RECONFIGURE_TX_BUFF);
0210 cmd->size =
0211 cpu_to_le16(sizeof(struct host_cmd_ds_txbuf_cfg) + S_DS_GEN);
0212 tx_buf->action = cpu_to_le16(action);
0213 switch (action) {
0214 case HostCmd_ACT_GEN_SET:
0215 mwifiex_dbg(priv->adapter, CMD,
0216 "cmd: set tx_buf=%d\n", *buf_size);
0217 tx_buf->buff_size = cpu_to_le16(*buf_size);
0218 break;
0219 case HostCmd_ACT_GEN_GET:
0220 default:
0221 tx_buf->buff_size = 0;
0222 break;
0223 }
0224 return 0;
0225 }
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235 int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
0236 int cmd_action,
0237 struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl)
0238 {
0239 struct host_cmd_ds_amsdu_aggr_ctrl *amsdu_ctrl =
0240 &cmd->params.amsdu_aggr_ctrl;
0241 u16 action = (u16) cmd_action;
0242
0243 cmd->command = cpu_to_le16(HostCmd_CMD_AMSDU_AGGR_CTRL);
0244 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_amsdu_aggr_ctrl)
0245 + S_DS_GEN);
0246 amsdu_ctrl->action = cpu_to_le16(action);
0247 switch (action) {
0248 case HostCmd_ACT_GEN_SET:
0249 amsdu_ctrl->enable = cpu_to_le16(aa_ctrl->enable);
0250 amsdu_ctrl->curr_buf_size = 0;
0251 break;
0252 case HostCmd_ACT_GEN_GET:
0253 default:
0254 amsdu_ctrl->curr_buf_size = 0;
0255 break;
0256 }
0257 return 0;
0258 }
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268 int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
0269 struct host_cmd_ds_command *cmd, u16 cmd_action,
0270 struct mwifiex_ds_11n_tx_cfg *txcfg)
0271 {
0272 struct host_cmd_ds_11n_cfg *htcfg = &cmd->params.htcfg;
0273
0274 cmd->command = cpu_to_le16(HostCmd_CMD_11N_CFG);
0275 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_11n_cfg) + S_DS_GEN);
0276 htcfg->action = cpu_to_le16(cmd_action);
0277 htcfg->ht_tx_cap = cpu_to_le16(txcfg->tx_htcap);
0278 htcfg->ht_tx_info = cpu_to_le16(txcfg->tx_htinfo);
0279
0280 if (priv->adapter->is_hw_11ac_capable)
0281 htcfg->misc_config = cpu_to_le16(txcfg->misc_config);
0282
0283 return 0;
0284 }
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298 int
0299 mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
0300 struct mwifiex_bssdescriptor *bss_desc,
0301 u8 **buffer)
0302 {
0303 struct mwifiex_ie_types_htcap *ht_cap;
0304 struct mwifiex_ie_types_htinfo *ht_info;
0305 struct mwifiex_ie_types_chan_list_param_set *chan_list;
0306 struct mwifiex_ie_types_2040bssco *bss_co_2040;
0307 struct mwifiex_ie_types_extcap *ext_cap;
0308 int ret_len = 0;
0309 struct ieee80211_supported_band *sband;
0310 struct ieee_types_header *hdr;
0311 u8 radio_type;
0312
0313 if (!buffer || !*buffer)
0314 return ret_len;
0315
0316 radio_type = mwifiex_band_to_radio_type((u8) bss_desc->bss_band);
0317 sband = priv->wdev.wiphy->bands[radio_type];
0318
0319 if (bss_desc->bcn_ht_cap) {
0320 ht_cap = (struct mwifiex_ie_types_htcap *) *buffer;
0321 memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap));
0322 ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY);
0323 ht_cap->header.len =
0324 cpu_to_le16(sizeof(struct ieee80211_ht_cap));
0325 memcpy((u8 *) ht_cap + sizeof(struct mwifiex_ie_types_header),
0326 (u8 *)bss_desc->bcn_ht_cap,
0327 le16_to_cpu(ht_cap->header.len));
0328
0329 mwifiex_fill_cap_info(priv, radio_type, &ht_cap->ht_cap);
0330
0331 if (bss_desc->bcn_ht_oper) {
0332 u8 ht_param = bss_desc->bcn_ht_oper->ht_param;
0333 u8 radio =
0334 mwifiex_band_to_radio_type(bss_desc->bss_band);
0335 int freq =
0336 ieee80211_channel_to_frequency(bss_desc->channel,
0337 radio);
0338 struct ieee80211_channel *chan =
0339 ieee80211_get_channel(priv->adapter->wiphy, freq);
0340
0341 switch (ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
0342 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
0343 if (chan->flags & IEEE80211_CHAN_NO_HT40PLUS) {
0344 ht_cap->ht_cap.cap_info &=
0345 cpu_to_le16
0346 (~IEEE80211_HT_CAP_SUP_WIDTH_20_40);
0347 ht_cap->ht_cap.cap_info &=
0348 cpu_to_le16(~IEEE80211_HT_CAP_SGI_40);
0349 }
0350 break;
0351 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
0352 if (chan->flags & IEEE80211_CHAN_NO_HT40MINUS) {
0353 ht_cap->ht_cap.cap_info &=
0354 cpu_to_le16
0355 (~IEEE80211_HT_CAP_SUP_WIDTH_20_40);
0356 ht_cap->ht_cap.cap_info &=
0357 cpu_to_le16(~IEEE80211_HT_CAP_SGI_40);
0358 }
0359 break;
0360 }
0361 }
0362
0363 *buffer += sizeof(struct mwifiex_ie_types_htcap);
0364 ret_len += sizeof(struct mwifiex_ie_types_htcap);
0365 }
0366
0367 if (bss_desc->bcn_ht_oper) {
0368 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
0369 ht_info = (struct mwifiex_ie_types_htinfo *) *buffer;
0370 memset(ht_info, 0,
0371 sizeof(struct mwifiex_ie_types_htinfo));
0372 ht_info->header.type =
0373 cpu_to_le16(WLAN_EID_HT_OPERATION);
0374 ht_info->header.len =
0375 cpu_to_le16(
0376 sizeof(struct ieee80211_ht_operation));
0377
0378 memcpy((u8 *) ht_info +
0379 sizeof(struct mwifiex_ie_types_header),
0380 (u8 *)bss_desc->bcn_ht_oper,
0381 le16_to_cpu(ht_info->header.len));
0382
0383 if (!(sband->ht_cap.cap &
0384 IEEE80211_HT_CAP_SUP_WIDTH_20_40))
0385 ht_info->ht_oper.ht_param &=
0386 ~(IEEE80211_HT_PARAM_CHAN_WIDTH_ANY |
0387 IEEE80211_HT_PARAM_CHA_SEC_OFFSET);
0388
0389 *buffer += sizeof(struct mwifiex_ie_types_htinfo);
0390 ret_len += sizeof(struct mwifiex_ie_types_htinfo);
0391 }
0392
0393 chan_list =
0394 (struct mwifiex_ie_types_chan_list_param_set *) *buffer;
0395 memset(chan_list, 0,
0396 sizeof(struct mwifiex_ie_types_chan_list_param_set));
0397 chan_list->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
0398 chan_list->header.len = cpu_to_le16(
0399 sizeof(struct mwifiex_ie_types_chan_list_param_set) -
0400 sizeof(struct mwifiex_ie_types_header));
0401 chan_list->chan_scan_param[0].chan_number =
0402 bss_desc->bcn_ht_oper->primary_chan;
0403 chan_list->chan_scan_param[0].radio_type =
0404 mwifiex_band_to_radio_type((u8) bss_desc->bss_band);
0405
0406 if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 &&
0407 bss_desc->bcn_ht_oper->ht_param &
0408 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY)
0409 SET_SECONDARYCHAN(chan_list->chan_scan_param[0].
0410 radio_type,
0411 (bss_desc->bcn_ht_oper->ht_param &
0412 IEEE80211_HT_PARAM_CHA_SEC_OFFSET));
0413
0414 *buffer += sizeof(struct mwifiex_ie_types_chan_list_param_set);
0415 ret_len += sizeof(struct mwifiex_ie_types_chan_list_param_set);
0416 }
0417
0418 if (bss_desc->bcn_bss_co_2040) {
0419 bss_co_2040 = (struct mwifiex_ie_types_2040bssco *) *buffer;
0420 memset(bss_co_2040, 0,
0421 sizeof(struct mwifiex_ie_types_2040bssco));
0422 bss_co_2040->header.type = cpu_to_le16(WLAN_EID_BSS_COEX_2040);
0423 bss_co_2040->header.len =
0424 cpu_to_le16(sizeof(bss_co_2040->bss_co_2040));
0425
0426 memcpy((u8 *) bss_co_2040 +
0427 sizeof(struct mwifiex_ie_types_header),
0428 bss_desc->bcn_bss_co_2040 +
0429 sizeof(struct ieee_types_header),
0430 le16_to_cpu(bss_co_2040->header.len));
0431
0432 *buffer += sizeof(struct mwifiex_ie_types_2040bssco);
0433 ret_len += sizeof(struct mwifiex_ie_types_2040bssco);
0434 }
0435
0436 if (bss_desc->bcn_ext_cap) {
0437 hdr = (void *)bss_desc->bcn_ext_cap;
0438 ext_cap = (struct mwifiex_ie_types_extcap *) *buffer;
0439 memset(ext_cap, 0, sizeof(struct mwifiex_ie_types_extcap));
0440 ext_cap->header.type = cpu_to_le16(WLAN_EID_EXT_CAPABILITY);
0441 ext_cap->header.len = cpu_to_le16(hdr->len);
0442
0443 memcpy((u8 *)ext_cap->ext_capab,
0444 bss_desc->bcn_ext_cap + sizeof(struct ieee_types_header),
0445 le16_to_cpu(ext_cap->header.len));
0446
0447 if (hdr->len > 3 &&
0448 ext_cap->ext_capab[3] & WLAN_EXT_CAPA4_INTERWORKING_ENABLED)
0449 priv->hs2_enabled = true;
0450 else
0451 priv->hs2_enabled = false;
0452
0453 *buffer += sizeof(struct mwifiex_ie_types_extcap) + hdr->len;
0454 ret_len += sizeof(struct mwifiex_ie_types_extcap) + hdr->len;
0455 }
0456
0457 return ret_len;
0458 }
0459
0460
0461
0462
0463
0464 static int mwifiex_is_tx_ba_stream_ptr_valid(struct mwifiex_private *priv,
0465 struct mwifiex_tx_ba_stream_tbl *tx_tbl_ptr)
0466 {
0467 struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl;
0468
0469 list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
0470 if (tx_ba_tsr_tbl == tx_tbl_ptr)
0471 return true;
0472 }
0473
0474 return false;
0475 }
0476
0477
0478
0479
0480
0481
0482
0483 void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
0484 struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl)
0485 {
0486 if (!tx_ba_tsr_tbl &&
0487 mwifiex_is_tx_ba_stream_ptr_valid(priv, tx_ba_tsr_tbl))
0488 return;
0489
0490 mwifiex_dbg(priv->adapter, INFO,
0491 "info: tx_ba_tsr_tbl %p\n", tx_ba_tsr_tbl);
0492
0493 list_del(&tx_ba_tsr_tbl->list);
0494
0495 kfree(tx_ba_tsr_tbl);
0496 }
0497
0498
0499
0500
0501 void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv)
0502 {
0503 int i;
0504 struct mwifiex_tx_ba_stream_tbl *del_tbl_ptr, *tmp_node;
0505
0506 spin_lock_bh(&priv->tx_ba_stream_tbl_lock);
0507 list_for_each_entry_safe(del_tbl_ptr, tmp_node,
0508 &priv->tx_ba_stream_tbl_ptr, list)
0509 mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv, del_tbl_ptr);
0510 spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0511
0512 INIT_LIST_HEAD(&priv->tx_ba_stream_tbl_ptr);
0513
0514 for (i = 0; i < MAX_NUM_TID; ++i)
0515 priv->aggr_prio_tbl[i].ampdu_ap =
0516 priv->aggr_prio_tbl[i].ampdu_user;
0517 }
0518
0519
0520
0521
0522
0523 struct mwifiex_tx_ba_stream_tbl *
0524 mwifiex_get_ba_tbl(struct mwifiex_private *priv, int tid, u8 *ra)
0525 {
0526 struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl;
0527
0528 spin_lock_bh(&priv->tx_ba_stream_tbl_lock);
0529 list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
0530 if (ether_addr_equal_unaligned(tx_ba_tsr_tbl->ra, ra) &&
0531 tx_ba_tsr_tbl->tid == tid) {
0532 spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0533 return tx_ba_tsr_tbl;
0534 }
0535 }
0536 spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0537 return NULL;
0538 }
0539
0540
0541
0542
0543
0544 void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid,
0545 enum mwifiex_ba_status ba_status)
0546 {
0547 struct mwifiex_tx_ba_stream_tbl *new_node;
0548 struct mwifiex_ra_list_tbl *ra_list;
0549 int tid_down;
0550
0551 if (!mwifiex_get_ba_tbl(priv, tid, ra)) {
0552 new_node = kzalloc(sizeof(struct mwifiex_tx_ba_stream_tbl),
0553 GFP_ATOMIC);
0554 if (!new_node)
0555 return;
0556
0557 tid_down = mwifiex_wmm_downgrade_tid(priv, tid);
0558 ra_list = mwifiex_wmm_get_ralist_node(priv, tid_down, ra);
0559 if (ra_list) {
0560 ra_list->ba_status = ba_status;
0561 ra_list->amsdu_in_ampdu = false;
0562 }
0563 INIT_LIST_HEAD(&new_node->list);
0564
0565 new_node->tid = tid;
0566 new_node->ba_status = ba_status;
0567 memcpy(new_node->ra, ra, ETH_ALEN);
0568
0569 spin_lock_bh(&priv->tx_ba_stream_tbl_lock);
0570 list_add_tail(&new_node->list, &priv->tx_ba_stream_tbl_ptr);
0571 spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0572 }
0573 }
0574
0575
0576
0577
0578 int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac)
0579 {
0580 struct host_cmd_ds_11n_addba_req add_ba_req;
0581 u32 tx_win_size = priv->add_ba_param.tx_win_size;
0582 static u8 dialog_tok;
0583 int ret;
0584 u16 block_ack_param_set;
0585
0586 mwifiex_dbg(priv->adapter, CMD, "cmd: %s: tid %d\n", __func__, tid);
0587
0588 memset(&add_ba_req, 0, sizeof(add_ba_req));
0589
0590 if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
0591 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
0592 priv->adapter->is_hw_11ac_capable &&
0593 memcmp(priv->cfg_bssid, peer_mac, ETH_ALEN)) {
0594 struct mwifiex_sta_node *sta_ptr;
0595
0596 spin_lock_bh(&priv->sta_list_spinlock);
0597 sta_ptr = mwifiex_get_sta_entry(priv, peer_mac);
0598 if (!sta_ptr) {
0599 spin_unlock_bh(&priv->sta_list_spinlock);
0600 mwifiex_dbg(priv->adapter, ERROR,
0601 "BA setup with unknown TDLS peer %pM!\n",
0602 peer_mac);
0603 return -1;
0604 }
0605 if (sta_ptr->is_11ac_enabled)
0606 tx_win_size = MWIFIEX_11AC_STA_AMPDU_DEF_TXWINSIZE;
0607 spin_unlock_bh(&priv->sta_list_spinlock);
0608 }
0609
0610 block_ack_param_set = (u16)((tid << BLOCKACKPARAM_TID_POS) |
0611 tx_win_size << BLOCKACKPARAM_WINSIZE_POS |
0612 IMMEDIATE_BLOCK_ACK);
0613
0614
0615 if (priv->add_ba_param.tx_amsdu &&
0616 (priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED))
0617 block_ack_param_set |= BLOCKACKPARAM_AMSDU_SUPP_MASK;
0618
0619 add_ba_req.block_ack_param_set = cpu_to_le16(block_ack_param_set);
0620 add_ba_req.block_ack_tmo = cpu_to_le16((u16)priv->add_ba_param.timeout);
0621
0622 ++dialog_tok;
0623
0624 if (dialog_tok == 0)
0625 dialog_tok = 1;
0626
0627 add_ba_req.dialog_token = dialog_tok;
0628 memcpy(&add_ba_req.peer_mac_addr, peer_mac, ETH_ALEN);
0629
0630
0631 ret = mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_REQ,
0632 0, 0, &add_ba_req, false);
0633
0634 return ret;
0635 }
0636
0637
0638
0639
0640 int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
0641 int initiator)
0642 {
0643 struct host_cmd_ds_11n_delba delba;
0644 int ret;
0645 uint16_t del_ba_param_set;
0646
0647 memset(&delba, 0, sizeof(delba));
0648
0649 del_ba_param_set = tid << DELBA_TID_POS;
0650
0651 if (initiator)
0652 del_ba_param_set |= IEEE80211_DELBA_PARAM_INITIATOR_MASK;
0653 else
0654 del_ba_param_set &= ~IEEE80211_DELBA_PARAM_INITIATOR_MASK;
0655
0656 delba.del_ba_param_set = cpu_to_le16(del_ba_param_set);
0657 memcpy(&delba.peer_mac_addr, peer_mac, ETH_ALEN);
0658
0659
0660 ret = mwifiex_send_cmd(priv, HostCmd_CMD_11N_DELBA,
0661 HostCmd_ACT_GEN_SET, 0, &delba, false);
0662
0663 return ret;
0664 }
0665
0666
0667
0668
0669 void mwifiex_11n_delba(struct mwifiex_private *priv, int tid)
0670 {
0671 struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr;
0672
0673 spin_lock_bh(&priv->rx_reorder_tbl_lock);
0674 list_for_each_entry(rx_reor_tbl_ptr, &priv->rx_reorder_tbl_ptr, list) {
0675 if (rx_reor_tbl_ptr->tid == tid) {
0676 dev_dbg(priv->adapter->dev,
0677 "Send delba to tid=%d, %pM\n",
0678 tid, rx_reor_tbl_ptr->ta);
0679 mwifiex_send_delba(priv, tid, rx_reor_tbl_ptr->ta, 0);
0680 goto exit;
0681 }
0682 }
0683 exit:
0684 spin_unlock_bh(&priv->rx_reorder_tbl_lock);
0685 }
0686
0687
0688
0689
0690 void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba)
0691 {
0692 struct host_cmd_ds_11n_delba *cmd_del_ba =
0693 (struct host_cmd_ds_11n_delba *) del_ba;
0694 uint16_t del_ba_param_set = le16_to_cpu(cmd_del_ba->del_ba_param_set);
0695 int tid;
0696
0697 tid = del_ba_param_set >> DELBA_TID_POS;
0698
0699 mwifiex_del_ba_tbl(priv, tid, cmd_del_ba->peer_mac_addr,
0700 TYPE_DELBA_RECEIVE, INITIATOR_BIT(del_ba_param_set));
0701 }
0702
0703
0704
0705
0706 int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv,
0707 struct mwifiex_ds_rx_reorder_tbl *buf)
0708 {
0709 int i;
0710 struct mwifiex_ds_rx_reorder_tbl *rx_reo_tbl = buf;
0711 struct mwifiex_rx_reorder_tbl *rx_reorder_tbl_ptr;
0712 int count = 0;
0713
0714 spin_lock_bh(&priv->rx_reorder_tbl_lock);
0715 list_for_each_entry(rx_reorder_tbl_ptr, &priv->rx_reorder_tbl_ptr,
0716 list) {
0717 rx_reo_tbl->tid = (u16) rx_reorder_tbl_ptr->tid;
0718 memcpy(rx_reo_tbl->ta, rx_reorder_tbl_ptr->ta, ETH_ALEN);
0719 rx_reo_tbl->start_win = rx_reorder_tbl_ptr->start_win;
0720 rx_reo_tbl->win_size = rx_reorder_tbl_ptr->win_size;
0721 for (i = 0; i < rx_reorder_tbl_ptr->win_size; ++i) {
0722 if (rx_reorder_tbl_ptr->rx_reorder_ptr[i])
0723 rx_reo_tbl->buffer[i] = true;
0724 else
0725 rx_reo_tbl->buffer[i] = false;
0726 }
0727 rx_reo_tbl++;
0728 count++;
0729
0730 if (count >= MWIFIEX_MAX_RX_BASTREAM_SUPPORTED)
0731 break;
0732 }
0733 spin_unlock_bh(&priv->rx_reorder_tbl_lock);
0734
0735 return count;
0736 }
0737
0738
0739
0740
0741 int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv,
0742 struct mwifiex_ds_tx_ba_stream_tbl *buf)
0743 {
0744 struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl;
0745 struct mwifiex_ds_tx_ba_stream_tbl *rx_reo_tbl = buf;
0746 int count = 0;
0747
0748 spin_lock_bh(&priv->tx_ba_stream_tbl_lock);
0749 list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) {
0750 rx_reo_tbl->tid = (u16) tx_ba_tsr_tbl->tid;
0751 mwifiex_dbg(priv->adapter, DATA, "data: %s tid=%d\n",
0752 __func__, rx_reo_tbl->tid);
0753 memcpy(rx_reo_tbl->ra, tx_ba_tsr_tbl->ra, ETH_ALEN);
0754 rx_reo_tbl->amsdu = tx_ba_tsr_tbl->amsdu;
0755 rx_reo_tbl++;
0756 count++;
0757 if (count >= MWIFIEX_MAX_TX_BASTREAM_SUPPORTED)
0758 break;
0759 }
0760 spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0761
0762 return count;
0763 }
0764
0765
0766
0767
0768
0769 void mwifiex_del_tx_ba_stream_tbl_by_ra(struct mwifiex_private *priv, u8 *ra)
0770 {
0771 struct mwifiex_tx_ba_stream_tbl *tbl, *tmp;
0772
0773 if (!ra)
0774 return;
0775
0776 spin_lock_bh(&priv->tx_ba_stream_tbl_lock);
0777 list_for_each_entry_safe(tbl, tmp, &priv->tx_ba_stream_tbl_ptr, list)
0778 if (!memcmp(tbl->ra, ra, ETH_ALEN))
0779 mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv, tbl);
0780 spin_unlock_bh(&priv->tx_ba_stream_tbl_lock);
0781
0782 return;
0783 }
0784
0785
0786
0787
0788 void mwifiex_set_ba_params(struct mwifiex_private *priv)
0789 {
0790 priv->add_ba_param.timeout = MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT;
0791
0792 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
0793 priv->add_ba_param.tx_win_size =
0794 MWIFIEX_UAP_AMPDU_DEF_TXWINSIZE;
0795 priv->add_ba_param.rx_win_size =
0796 MWIFIEX_UAP_AMPDU_DEF_RXWINSIZE;
0797 } else {
0798 priv->add_ba_param.tx_win_size =
0799 MWIFIEX_STA_AMPDU_DEF_TXWINSIZE;
0800 priv->add_ba_param.rx_win_size =
0801 MWIFIEX_STA_AMPDU_DEF_RXWINSIZE;
0802 }
0803
0804 priv->add_ba_param.tx_amsdu = true;
0805 priv->add_ba_param.rx_amsdu = true;
0806
0807 return;
0808 }
0809
0810 u8 mwifiex_get_sec_chan_offset(int chan)
0811 {
0812 u8 sec_offset;
0813
0814 switch (chan) {
0815 case 36:
0816 case 44:
0817 case 52:
0818 case 60:
0819 case 100:
0820 case 108:
0821 case 116:
0822 case 124:
0823 case 132:
0824 case 140:
0825 case 149:
0826 case 157:
0827 sec_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
0828 break;
0829 case 40:
0830 case 48:
0831 case 56:
0832 case 64:
0833 case 104:
0834 case 112:
0835 case 120:
0836 case 128:
0837 case 136:
0838 case 144:
0839 case 153:
0840 case 161:
0841 sec_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
0842 break;
0843 case 165:
0844 default:
0845 sec_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
0846 break;
0847 }
0848
0849 return sec_offset;
0850 }
0851
0852
0853
0854
0855 static void
0856 mwifiex_send_delba_txbastream_tbl(struct mwifiex_private *priv, u8 tid)
0857 {
0858 struct mwifiex_adapter *adapter = priv->adapter;
0859 struct mwifiex_tx_ba_stream_tbl *tx_ba_stream_tbl_ptr;
0860
0861 list_for_each_entry(tx_ba_stream_tbl_ptr,
0862 &priv->tx_ba_stream_tbl_ptr, list) {
0863 if (tx_ba_stream_tbl_ptr->ba_status == BA_SETUP_COMPLETE) {
0864 if (tid == tx_ba_stream_tbl_ptr->tid) {
0865 dev_dbg(adapter->dev,
0866 "Tx:Send delba to tid=%d, %pM\n", tid,
0867 tx_ba_stream_tbl_ptr->ra);
0868 mwifiex_send_delba(priv,
0869 tx_ba_stream_tbl_ptr->tid,
0870 tx_ba_stream_tbl_ptr->ra, 1);
0871 return;
0872 }
0873 }
0874 }
0875 }
0876
0877
0878
0879 void mwifiex_update_ampdu_txwinsize(struct mwifiex_adapter *adapter)
0880 {
0881 u8 i;
0882 u32 tx_win_size;
0883 struct mwifiex_private *priv;
0884
0885 for (i = 0; i < adapter->priv_num; i++) {
0886 if (!adapter->priv[i])
0887 continue;
0888 priv = adapter->priv[i];
0889 tx_win_size = priv->add_ba_param.tx_win_size;
0890
0891 if (priv->bss_type == MWIFIEX_BSS_TYPE_STA)
0892 priv->add_ba_param.tx_win_size =
0893 MWIFIEX_STA_AMPDU_DEF_TXWINSIZE;
0894
0895 if (priv->bss_type == MWIFIEX_BSS_TYPE_P2P)
0896 priv->add_ba_param.tx_win_size =
0897 MWIFIEX_STA_AMPDU_DEF_TXWINSIZE;
0898
0899 if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP)
0900 priv->add_ba_param.tx_win_size =
0901 MWIFIEX_UAP_AMPDU_DEF_TXWINSIZE;
0902
0903 if (adapter->coex_win_size) {
0904 if (adapter->coex_tx_win_size)
0905 priv->add_ba_param.tx_win_size =
0906 adapter->coex_tx_win_size;
0907 }
0908
0909 if (tx_win_size != priv->add_ba_param.tx_win_size) {
0910 if (!priv->media_connected)
0911 continue;
0912 for (i = 0; i < MAX_NUM_TID; i++)
0913 mwifiex_send_delba_txbastream_tbl(priv, i);
0914 }
0915 }
0916 }