Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * HT handling |
| 3 | * |
| 4 | * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi> |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 5 | * Copyright 2002-2005, Instant802 Networks, Inc. |
| 6 | * Copyright 2005-2006, Devicescape Software, Inc. |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 7 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> |
| 8 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> |
| 9 | * Copyright 2007-2008, Intel Corporation |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Software Foundation. |
| 14 | */ |
| 15 | |
| 16 | #include <linux/ieee80211.h> |
| 17 | #include <net/wireless.h> |
| 18 | #include <net/mac80211.h> |
| 19 | #include "ieee80211_i.h" |
| 20 | #include "sta_info.h" |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 21 | #include "wme.h" |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 22 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 23 | void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband, |
| 24 | struct ieee80211_ht_cap *ht_cap_ie, |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 25 | struct ieee80211_sta_ht_cap *ht_cap) |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 26 | { |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 27 | u8 ampdu_info, tx_mcs_set_cap; |
| 28 | int i, max_tx_streams; |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 29 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 30 | BUG_ON(!ht_cap); |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 31 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 32 | memset(ht_cap, 0, sizeof(*ht_cap)); |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 33 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 34 | if (!ht_cap_ie) |
| 35 | return; |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 36 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 37 | ht_cap->ht_supported = true; |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 38 | |
Sujith | f16f33d | 2008-11-14 16:27:53 +0530 | [diff] [blame] | 39 | ht_cap->cap = le16_to_cpu(ht_cap_ie->cap_info) & sband->ht_cap.cap; |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 40 | ht_cap->cap &= ~IEEE80211_HT_CAP_SM_PS; |
| 41 | ht_cap->cap |= sband->ht_cap.cap & IEEE80211_HT_CAP_SM_PS; |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 42 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 43 | ampdu_info = ht_cap_ie->ampdu_params_info; |
| 44 | ht_cap->ampdu_factor = |
| 45 | ampdu_info & IEEE80211_HT_AMPDU_PARM_FACTOR; |
| 46 | ht_cap->ampdu_density = |
| 47 | (ampdu_info & IEEE80211_HT_AMPDU_PARM_DENSITY) >> 2; |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 48 | |
| 49 | /* own MCS TX capabilities */ |
| 50 | tx_mcs_set_cap = sband->ht_cap.mcs.tx_params; |
| 51 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 52 | /* can we TX with MCS rates? */ |
| 53 | if (!(tx_mcs_set_cap & IEEE80211_HT_MCS_TX_DEFINED)) |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 54 | return; |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 55 | |
| 56 | /* Counting from 0, therefore +1 */ |
| 57 | if (tx_mcs_set_cap & IEEE80211_HT_MCS_TX_RX_DIFF) |
| 58 | max_tx_streams = |
| 59 | ((tx_mcs_set_cap & IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) |
| 60 | >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT) + 1; |
| 61 | else |
| 62 | max_tx_streams = IEEE80211_HT_MCS_TX_MAX_STREAMS; |
| 63 | |
| 64 | /* |
| 65 | * 802.11n D5.0 20.3.5 / 20.6 says: |
| 66 | * - indices 0 to 7 and 32 are single spatial stream |
| 67 | * - 8 to 31 are multiple spatial streams using equal modulation |
| 68 | * [8..15 for two streams, 16..23 for three and 24..31 for four] |
| 69 | * - remainder are multiple spatial streams using unequal modulation |
| 70 | */ |
| 71 | for (i = 0; i < max_tx_streams; i++) |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 72 | ht_cap->mcs.rx_mask[i] = |
| 73 | sband->ht_cap.mcs.rx_mask[i] & ht_cap_ie->mcs.rx_mask[i]; |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 74 | |
| 75 | if (tx_mcs_set_cap & IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION) |
| 76 | for (i = IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE; |
| 77 | i < IEEE80211_HT_MCS_MASK_LEN; i++) |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 78 | ht_cap->mcs.rx_mask[i] = |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 79 | sband->ht_cap.mcs.rx_mask[i] & |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 80 | ht_cap_ie->mcs.rx_mask[i]; |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 81 | |
| 82 | /* handle MCS rate 32 too */ |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 83 | if (sband->ht_cap.mcs.rx_mask[32/8] & ht_cap_ie->mcs.rx_mask[32/8] & 1) |
| 84 | ht_cap->mcs.rx_mask[32/8] |= 1; |
| 85 | } |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 86 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 87 | /* |
| 88 | * ieee80211_enable_ht should be called only after the operating band |
| 89 | * has been determined as ht configuration depends on the hw's |
| 90 | * HT abilities for a specific band. |
| 91 | */ |
| 92 | u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, |
| 93 | struct ieee80211_ht_info *hti, |
| 94 | u16 ap_ht_cap_flags) |
| 95 | { |
| 96 | struct ieee80211_local *local = sdata->local; |
| 97 | struct ieee80211_supported_band *sband; |
| 98 | struct ieee80211_bss_ht_conf ht; |
| 99 | u32 changed = 0; |
| 100 | bool enable_ht = true, ht_changed; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 101 | enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 102 | |
| 103 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
| 104 | |
| 105 | memset(&ht, 0, sizeof(ht)); |
| 106 | |
| 107 | /* HT is not supported */ |
| 108 | if (!sband->ht_cap.ht_supported) |
| 109 | enable_ht = false; |
| 110 | |
| 111 | /* check that channel matches the right operating channel */ |
| 112 | if (local->hw.conf.channel->center_freq != |
| 113 | ieee80211_channel_to_frequency(hti->control_chan)) |
| 114 | enable_ht = false; |
| 115 | |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 116 | if (enable_ht) { |
| 117 | channel_type = NL80211_CHAN_HT20; |
| 118 | |
| 119 | if (!(ap_ht_cap_flags & IEEE80211_HT_CAP_40MHZ_INTOLERANT) && |
| 120 | (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) && |
| 121 | (hti->ht_param & IEEE80211_HT_PARAM_CHAN_WIDTH_ANY)) { |
| 122 | switch(hti->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { |
| 123 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
| 124 | channel_type = NL80211_CHAN_HT40PLUS; |
| 125 | break; |
| 126 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
| 127 | channel_type = NL80211_CHAN_HT40MINUS; |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
Luis R. Rodriguez | 285256a | 2008-12-23 15:58:45 -0800 | [diff] [blame^] | 133 | ht_changed = conf_is_ht(&local->hw.conf) != enable_ht || |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 134 | channel_type != local->hw.conf.ht.channel_type; |
| 135 | |
| 136 | local->oper_channel_type = channel_type; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 137 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 138 | if (ht_changed) |
| 139 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_HT); |
| 140 | |
| 141 | /* disable HT */ |
| 142 | if (!enable_ht) |
| 143 | return 0; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 144 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 145 | ht.operation_mode = le16_to_cpu(hti->operation_mode); |
| 146 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 147 | /* if bss configuration changed store the new one */ |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 148 | if (memcmp(&sdata->vif.bss_conf.ht, &ht, sizeof(ht))) { |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 149 | changed |= BSS_CHANGED_HT; |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 150 | sdata->vif.bss_conf.ht = ht; |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | return changed; |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 154 | } |
| 155 | |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 156 | static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, |
| 157 | const u8 *da, u16 tid, |
| 158 | u8 dialog_token, u16 start_seq_num, |
| 159 | u16 agg_size, u16 timeout) |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 160 | { |
| 161 | struct ieee80211_local *local = sdata->local; |
| 162 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
| 163 | struct sk_buff *skb; |
| 164 | struct ieee80211_mgmt *mgmt; |
| 165 | u16 capab; |
| 166 | |
| 167 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
| 168 | |
| 169 | if (!skb) { |
| 170 | printk(KERN_ERR "%s: failed to allocate buffer " |
| 171 | "for addba request frame\n", sdata->dev->name); |
| 172 | return; |
| 173 | } |
| 174 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 175 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
| 176 | memset(mgmt, 0, 24); |
| 177 | memcpy(mgmt->da, da, ETH_ALEN); |
| 178 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 179 | if (sdata->vif.type == NL80211_IFTYPE_AP) |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 180 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); |
| 181 | else |
| 182 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); |
| 183 | |
| 184 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 185 | IEEE80211_STYPE_ACTION); |
| 186 | |
| 187 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_req)); |
| 188 | |
| 189 | mgmt->u.action.category = WLAN_CATEGORY_BACK; |
| 190 | mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ; |
| 191 | |
| 192 | mgmt->u.action.u.addba_req.dialog_token = dialog_token; |
| 193 | capab = (u16)(1 << 1); /* bit 1 aggregation policy */ |
| 194 | capab |= (u16)(tid << 2); /* bit 5:2 TID number */ |
| 195 | capab |= (u16)(agg_size << 6); /* bit 15:6 max size of aggergation */ |
| 196 | |
| 197 | mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab); |
| 198 | |
| 199 | mgmt->u.action.u.addba_req.timeout = cpu_to_le16(timeout); |
| 200 | mgmt->u.action.u.addba_req.start_seq_num = |
| 201 | cpu_to_le16(start_seq_num << 4); |
| 202 | |
Johannes Berg | e50db65 | 2008-09-09 15:07:09 +0200 | [diff] [blame] | 203 | ieee80211_tx_skb(sdata, skb, 0); |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 204 | } |
| 205 | |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 206 | static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid, |
| 207 | u8 dialog_token, u16 status, u16 policy, |
| 208 | u16 buf_size, u16 timeout) |
| 209 | { |
| 210 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
| 211 | struct ieee80211_local *local = sdata->local; |
| 212 | struct sk_buff *skb; |
| 213 | struct ieee80211_mgmt *mgmt; |
| 214 | u16 capab; |
| 215 | |
| 216 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
| 217 | |
| 218 | if (!skb) { |
| 219 | printk(KERN_DEBUG "%s: failed to allocate buffer " |
| 220 | "for addba resp frame\n", sdata->dev->name); |
| 221 | return; |
| 222 | } |
| 223 | |
| 224 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 225 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
| 226 | memset(mgmt, 0, 24); |
| 227 | memcpy(mgmt->da, da, ETH_ALEN); |
| 228 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 229 | if (sdata->vif.type == NL80211_IFTYPE_AP) |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 230 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); |
| 231 | else |
| 232 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); |
| 233 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 234 | IEEE80211_STYPE_ACTION); |
| 235 | |
| 236 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_resp)); |
| 237 | mgmt->u.action.category = WLAN_CATEGORY_BACK; |
| 238 | mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP; |
| 239 | mgmt->u.action.u.addba_resp.dialog_token = dialog_token; |
| 240 | |
| 241 | capab = (u16)(policy << 1); /* bit 1 aggregation policy */ |
| 242 | capab |= (u16)(tid << 2); /* bit 5:2 TID number */ |
| 243 | capab |= (u16)(buf_size << 6); /* bit 15:6 max size of aggregation */ |
| 244 | |
| 245 | mgmt->u.action.u.addba_resp.capab = cpu_to_le16(capab); |
| 246 | mgmt->u.action.u.addba_resp.timeout = cpu_to_le16(timeout); |
| 247 | mgmt->u.action.u.addba_resp.status = cpu_to_le16(status); |
| 248 | |
Johannes Berg | e50db65 | 2008-09-09 15:07:09 +0200 | [diff] [blame] | 249 | ieee80211_tx_skb(sdata, skb, 0); |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | static void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, |
| 253 | const u8 *da, u16 tid, |
| 254 | u16 initiator, u16 reason_code) |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 255 | { |
| 256 | struct ieee80211_local *local = sdata->local; |
| 257 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
| 258 | struct sk_buff *skb; |
| 259 | struct ieee80211_mgmt *mgmt; |
| 260 | u16 params; |
| 261 | |
| 262 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); |
| 263 | |
| 264 | if (!skb) { |
| 265 | printk(KERN_ERR "%s: failed to allocate buffer " |
| 266 | "for delba frame\n", sdata->dev->name); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 271 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
| 272 | memset(mgmt, 0, 24); |
| 273 | memcpy(mgmt->da, da, ETH_ALEN); |
| 274 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 275 | if (sdata->vif.type == NL80211_IFTYPE_AP) |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 276 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); |
| 277 | else |
| 278 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); |
| 279 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 280 | IEEE80211_STYPE_ACTION); |
| 281 | |
| 282 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.delba)); |
| 283 | |
| 284 | mgmt->u.action.category = WLAN_CATEGORY_BACK; |
| 285 | mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA; |
| 286 | params = (u16)(initiator << 11); /* bit 11 initiator */ |
| 287 | params |= (u16)(tid << 12); /* bit 15:12 TID number */ |
| 288 | |
| 289 | mgmt->u.action.u.delba.params = cpu_to_le16(params); |
| 290 | mgmt->u.action.u.delba.reason_code = cpu_to_le16(reason_code); |
| 291 | |
Johannes Berg | e50db65 | 2008-09-09 15:07:09 +0200 | [diff] [blame] | 292 | ieee80211_tx_skb(sdata, skb, 0); |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn) |
| 296 | { |
| 297 | struct ieee80211_local *local = sdata->local; |
| 298 | struct sk_buff *skb; |
| 299 | struct ieee80211_bar *bar; |
| 300 | u16 bar_control = 0; |
| 301 | |
| 302 | skb = dev_alloc_skb(sizeof(*bar) + local->hw.extra_tx_headroom); |
| 303 | if (!skb) { |
| 304 | printk(KERN_ERR "%s: failed to allocate buffer for " |
| 305 | "bar frame\n", sdata->dev->name); |
| 306 | return; |
| 307 | } |
| 308 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 309 | bar = (struct ieee80211_bar *)skb_put(skb, sizeof(*bar)); |
| 310 | memset(bar, 0, sizeof(*bar)); |
| 311 | bar->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 312 | IEEE80211_STYPE_BACK_REQ); |
| 313 | memcpy(bar->ra, ra, ETH_ALEN); |
| 314 | memcpy(bar->ta, sdata->dev->dev_addr, ETH_ALEN); |
| 315 | bar_control |= (u16)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL; |
| 316 | bar_control |= (u16)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA; |
| 317 | bar_control |= (u16)(tid << 12); |
| 318 | bar->control = cpu_to_le16(bar_control); |
| 319 | bar->start_seq_num = cpu_to_le16(ssn); |
| 320 | |
Johannes Berg | e50db65 | 2008-09-09 15:07:09 +0200 | [diff] [blame] | 321 | ieee80211_tx_skb(sdata, skb, 0); |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, |
| 325 | u16 initiator, u16 reason) |
| 326 | { |
| 327 | struct ieee80211_local *local = sdata->local; |
| 328 | struct ieee80211_hw *hw = &local->hw; |
| 329 | struct sta_info *sta; |
| 330 | int ret, i; |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 331 | |
| 332 | rcu_read_lock(); |
| 333 | |
| 334 | sta = sta_info_get(local, ra); |
| 335 | if (!sta) { |
| 336 | rcu_read_unlock(); |
| 337 | return; |
| 338 | } |
| 339 | |
| 340 | /* check if TID is in operational state */ |
| 341 | spin_lock_bh(&sta->lock); |
| 342 | if (sta->ampdu_mlme.tid_state_rx[tid] |
| 343 | != HT_AGG_STATE_OPERATIONAL) { |
| 344 | spin_unlock_bh(&sta->lock); |
| 345 | rcu_read_unlock(); |
| 346 | return; |
| 347 | } |
| 348 | sta->ampdu_mlme.tid_state_rx[tid] = |
| 349 | HT_AGG_STATE_REQ_STOP_BA_MSK | |
| 350 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); |
| 351 | spin_unlock_bh(&sta->lock); |
| 352 | |
| 353 | /* stop HW Rx aggregation. ampdu_action existence |
| 354 | * already verified in session init so we add the BUG_ON */ |
| 355 | BUG_ON(!local->ops->ampdu_action); |
| 356 | |
| 357 | #ifdef CONFIG_MAC80211_HT_DEBUG |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 358 | printk(KERN_DEBUG "Rx BA session stop requested for %pM tid %u\n", |
| 359 | ra, tid); |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 360 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 361 | |
| 362 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_STOP, |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 363 | &sta->sta, tid, NULL); |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 364 | if (ret) |
| 365 | printk(KERN_DEBUG "HW problem - can not stop rx " |
| 366 | "aggregation for tid %d\n", tid); |
| 367 | |
| 368 | /* shutdown timer has not expired */ |
| 369 | if (initiator != WLAN_BACK_TIMER) |
| 370 | del_timer_sync(&sta->ampdu_mlme.tid_rx[tid]->session_timer); |
| 371 | |
| 372 | /* check if this is a self generated aggregation halt */ |
| 373 | if (initiator == WLAN_BACK_RECIPIENT || initiator == WLAN_BACK_TIMER) |
| 374 | ieee80211_send_delba(sdata, ra, tid, 0, reason); |
| 375 | |
| 376 | /* free the reordering buffer */ |
| 377 | for (i = 0; i < sta->ampdu_mlme.tid_rx[tid]->buf_size; i++) { |
| 378 | if (sta->ampdu_mlme.tid_rx[tid]->reorder_buf[i]) { |
| 379 | /* release the reordered frames */ |
| 380 | dev_kfree_skb(sta->ampdu_mlme.tid_rx[tid]->reorder_buf[i]); |
| 381 | sta->ampdu_mlme.tid_rx[tid]->stored_mpdu_num--; |
| 382 | sta->ampdu_mlme.tid_rx[tid]->reorder_buf[i] = NULL; |
| 383 | } |
| 384 | } |
| 385 | /* free resources */ |
| 386 | kfree(sta->ampdu_mlme.tid_rx[tid]->reorder_buf); |
| 387 | kfree(sta->ampdu_mlme.tid_rx[tid]); |
| 388 | sta->ampdu_mlme.tid_rx[tid] = NULL; |
| 389 | sta->ampdu_mlme.tid_state_rx[tid] = HT_AGG_STATE_IDLE; |
| 390 | |
| 391 | rcu_read_unlock(); |
| 392 | } |
| 393 | |
| 394 | |
| 395 | /* |
| 396 | * After sending add Block Ack request we activated a timer until |
| 397 | * add Block Ack response will arrive from the recipient. |
| 398 | * If this timer expires sta_addba_resp_timer_expired will be executed. |
| 399 | */ |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 400 | static void sta_addba_resp_timer_expired(unsigned long data) |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 401 | { |
| 402 | /* not an elegant detour, but there is no choice as the timer passes |
| 403 | * only one argument, and both sta_info and TID are needed, so init |
| 404 | * flow in sta_info_create gives the TID as data, while the timer_to_id |
| 405 | * array gives the sta through container_of */ |
| 406 | u16 tid = *(u8 *)data; |
| 407 | struct sta_info *temp_sta = container_of((void *)data, |
| 408 | struct sta_info, timer_to_tid[tid]); |
| 409 | |
| 410 | struct ieee80211_local *local = temp_sta->local; |
| 411 | struct ieee80211_hw *hw = &local->hw; |
| 412 | struct sta_info *sta; |
| 413 | u8 *state; |
| 414 | |
| 415 | rcu_read_lock(); |
| 416 | |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 417 | sta = sta_info_get(local, temp_sta->sta.addr); |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 418 | if (!sta) { |
| 419 | rcu_read_unlock(); |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
| 424 | /* check if the TID waits for addBA response */ |
| 425 | spin_lock_bh(&sta->lock); |
| 426 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { |
| 427 | spin_unlock_bh(&sta->lock); |
| 428 | *state = HT_AGG_STATE_IDLE; |
| 429 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 430 | printk(KERN_DEBUG "timer expired on tid %d but we are not " |
| 431 | "expecting addBA response there", tid); |
| 432 | #endif |
| 433 | goto timer_expired_exit; |
| 434 | } |
| 435 | |
| 436 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 437 | printk(KERN_DEBUG "addBA response timer expired on tid %d\n", tid); |
| 438 | #endif |
| 439 | |
| 440 | /* go through the state check in stop_BA_session */ |
| 441 | *state = HT_AGG_STATE_OPERATIONAL; |
| 442 | spin_unlock_bh(&sta->lock); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 443 | ieee80211_stop_tx_ba_session(hw, temp_sta->sta.addr, tid, |
Johannes Berg | 44d414d | 2008-09-08 17:44:28 +0200 | [diff] [blame] | 444 | WLAN_BACK_INITIATOR); |
| 445 | |
| 446 | timer_expired_exit: |
| 447 | rcu_read_unlock(); |
| 448 | } |
| 449 | |
| 450 | void ieee80211_sta_tear_down_BA_sessions(struct ieee80211_sub_if_data *sdata, u8 *addr) |
| 451 | { |
| 452 | struct ieee80211_local *local = sdata->local; |
| 453 | int i; |
| 454 | |
| 455 | for (i = 0; i < STA_TID_NUM; i++) { |
| 456 | ieee80211_stop_tx_ba_session(&local->hw, addr, i, |
| 457 | WLAN_BACK_INITIATOR); |
| 458 | ieee80211_sta_stop_rx_ba_session(sdata, addr, i, |
| 459 | WLAN_BACK_RECIPIENT, |
| 460 | WLAN_REASON_QSTA_LEAVE_QBSS); |
| 461 | } |
| 462 | } |
| 463 | |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 464 | int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid) |
| 465 | { |
| 466 | struct ieee80211_local *local = hw_to_local(hw); |
| 467 | struct sta_info *sta; |
| 468 | struct ieee80211_sub_if_data *sdata; |
| 469 | u16 start_seq_num; |
| 470 | u8 *state; |
John W. Linville | 85b9e4f | 2009-01-12 14:37:44 -0500 | [diff] [blame] | 471 | int ret = 0; |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 472 | |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 473 | if ((tid >= STA_TID_NUM) || !(hw->flags & IEEE80211_HW_AMPDU_AGGREGATION)) |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 474 | return -EINVAL; |
| 475 | |
| 476 | #ifdef CONFIG_MAC80211_HT_DEBUG |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 477 | printk(KERN_DEBUG "Open BA session requested for %pM tid %u\n", |
| 478 | ra, tid); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 479 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 480 | |
| 481 | rcu_read_lock(); |
| 482 | |
| 483 | sta = sta_info_get(local, ra); |
| 484 | if (!sta) { |
| 485 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 486 | printk(KERN_DEBUG "Could not find the station\n"); |
| 487 | #endif |
| 488 | ret = -ENOENT; |
| 489 | goto exit; |
| 490 | } |
| 491 | |
| 492 | spin_lock_bh(&sta->lock); |
| 493 | |
| 494 | /* we have tried too many times, receiver does not want A-MPDU */ |
| 495 | if (sta->ampdu_mlme.addba_req_num[tid] > HT_AGG_MAX_RETRIES) { |
| 496 | ret = -EBUSY; |
| 497 | goto err_unlock_sta; |
| 498 | } |
| 499 | |
| 500 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
| 501 | /* check if the TID is not in aggregation flow already */ |
| 502 | if (*state != HT_AGG_STATE_IDLE) { |
| 503 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 504 | printk(KERN_DEBUG "BA request denied - session is not " |
| 505 | "idle on tid %u\n", tid); |
| 506 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 507 | ret = -EAGAIN; |
| 508 | goto err_unlock_sta; |
| 509 | } |
| 510 | |
| 511 | /* prepare A-MPDU MLME for Tx aggregation */ |
| 512 | sta->ampdu_mlme.tid_tx[tid] = |
| 513 | kmalloc(sizeof(struct tid_ampdu_tx), GFP_ATOMIC); |
| 514 | if (!sta->ampdu_mlme.tid_tx[tid]) { |
| 515 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 516 | if (net_ratelimit()) |
| 517 | printk(KERN_ERR "allocate tx mlme to tid %d failed\n", |
| 518 | tid); |
| 519 | #endif |
| 520 | ret = -ENOMEM; |
| 521 | goto err_unlock_sta; |
| 522 | } |
| 523 | /* Tx timer */ |
| 524 | sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.function = |
| 525 | sta_addba_resp_timer_expired; |
| 526 | sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.data = |
| 527 | (unsigned long)&sta->timer_to_tid[tid]; |
| 528 | init_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); |
| 529 | |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 530 | if (hw->ampdu_queues) { |
| 531 | /* create a new queue for this aggregation */ |
| 532 | ret = ieee80211_ht_agg_queue_add(local, sta, tid); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 533 | |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 534 | /* case no queue is available to aggregation |
| 535 | * don't switch to aggregation */ |
| 536 | if (ret) { |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 537 | #ifdef CONFIG_MAC80211_HT_DEBUG |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 538 | printk(KERN_DEBUG "BA request denied - " |
| 539 | "queue unavailable for tid %d\n", tid); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 540 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 541 | goto err_unlock_queue; |
| 542 | } |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 543 | } |
| 544 | sdata = sta->sdata; |
| 545 | |
| 546 | /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the |
| 547 | * call back right away, it must see that the flow has begun */ |
| 548 | *state |= HT_ADDBA_REQUESTED_MSK; |
| 549 | |
| 550 | /* This is slightly racy because the queue isn't stopped */ |
| 551 | start_seq_num = sta->tid_seq[tid]; |
| 552 | |
| 553 | if (local->ops->ampdu_action) |
| 554 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START, |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 555 | &sta->sta, tid, &start_seq_num); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 556 | |
| 557 | if (ret) { |
| 558 | /* No need to requeue the packets in the agg queue, since we |
| 559 | * held the tx lock: no packet could be enqueued to the newly |
| 560 | * allocated queue */ |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 561 | if (hw->ampdu_queues) |
| 562 | ieee80211_ht_agg_queue_remove(local, sta, tid, 0); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 563 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 564 | printk(KERN_DEBUG "BA request denied - HW unavailable for" |
| 565 | " tid %d\n", tid); |
| 566 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 567 | *state = HT_AGG_STATE_IDLE; |
| 568 | goto err_unlock_queue; |
| 569 | } |
| 570 | |
| 571 | /* Will put all the packets in the new SW queue */ |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 572 | if (hw->ampdu_queues) |
| 573 | ieee80211_requeue(local, ieee802_1d_to_ac[tid]); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 574 | spin_unlock_bh(&sta->lock); |
| 575 | |
| 576 | /* send an addBA request */ |
| 577 | sta->ampdu_mlme.dialog_token_allocator++; |
| 578 | sta->ampdu_mlme.tid_tx[tid]->dialog_token = |
| 579 | sta->ampdu_mlme.dialog_token_allocator; |
| 580 | sta->ampdu_mlme.tid_tx[tid]->ssn = start_seq_num; |
| 581 | |
| 582 | |
| 583 | ieee80211_send_addba_request(sta->sdata, ra, tid, |
| 584 | sta->ampdu_mlme.tid_tx[tid]->dialog_token, |
| 585 | sta->ampdu_mlme.tid_tx[tid]->ssn, |
| 586 | 0x40, 5000); |
| 587 | /* activate the timer for the recipient's addBA response */ |
| 588 | sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.expires = |
| 589 | jiffies + ADDBA_RESP_INTERVAL; |
| 590 | add_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); |
| 591 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 592 | printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid); |
| 593 | #endif |
| 594 | goto exit; |
| 595 | |
| 596 | err_unlock_queue: |
| 597 | kfree(sta->ampdu_mlme.tid_tx[tid]); |
| 598 | sta->ampdu_mlme.tid_tx[tid] = NULL; |
| 599 | ret = -EBUSY; |
| 600 | err_unlock_sta: |
| 601 | spin_unlock_bh(&sta->lock); |
| 602 | exit: |
| 603 | rcu_read_unlock(); |
| 604 | return ret; |
| 605 | } |
| 606 | EXPORT_SYMBOL(ieee80211_start_tx_ba_session); |
| 607 | |
| 608 | int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw, |
| 609 | u8 *ra, u16 tid, |
| 610 | enum ieee80211_back_parties initiator) |
| 611 | { |
| 612 | struct ieee80211_local *local = hw_to_local(hw); |
| 613 | struct sta_info *sta; |
| 614 | u8 *state; |
| 615 | int ret = 0; |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 616 | |
| 617 | if (tid >= STA_TID_NUM) |
| 618 | return -EINVAL; |
| 619 | |
| 620 | rcu_read_lock(); |
| 621 | sta = sta_info_get(local, ra); |
| 622 | if (!sta) { |
| 623 | rcu_read_unlock(); |
| 624 | return -ENOENT; |
| 625 | } |
| 626 | |
| 627 | /* check if the TID is in aggregation */ |
| 628 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
| 629 | spin_lock_bh(&sta->lock); |
| 630 | |
| 631 | if (*state != HT_AGG_STATE_OPERATIONAL) { |
| 632 | ret = -ENOENT; |
| 633 | goto stop_BA_exit; |
| 634 | } |
| 635 | |
| 636 | #ifdef CONFIG_MAC80211_HT_DEBUG |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 637 | printk(KERN_DEBUG "Tx BA session stop requested for %pM tid %u\n", |
| 638 | ra, tid); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 639 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 640 | |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 641 | if (hw->ampdu_queues) |
| 642 | ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 643 | |
| 644 | *state = HT_AGG_STATE_REQ_STOP_BA_MSK | |
| 645 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); |
| 646 | |
| 647 | if (local->ops->ampdu_action) |
| 648 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_STOP, |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 649 | &sta->sta, tid, NULL); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 650 | |
| 651 | /* case HW denied going back to legacy */ |
| 652 | if (ret) { |
| 653 | WARN_ON(ret != -EBUSY); |
| 654 | *state = HT_AGG_STATE_OPERATIONAL; |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 655 | if (hw->ampdu_queues) |
| 656 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 657 | goto stop_BA_exit; |
| 658 | } |
| 659 | |
| 660 | stop_BA_exit: |
| 661 | spin_unlock_bh(&sta->lock); |
| 662 | rcu_read_unlock(); |
| 663 | return ret; |
| 664 | } |
| 665 | EXPORT_SYMBOL(ieee80211_stop_tx_ba_session); |
| 666 | |
| 667 | void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid) |
| 668 | { |
| 669 | struct ieee80211_local *local = hw_to_local(hw); |
| 670 | struct sta_info *sta; |
| 671 | u8 *state; |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 672 | |
| 673 | if (tid >= STA_TID_NUM) { |
| 674 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 675 | printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n", |
| 676 | tid, STA_TID_NUM); |
| 677 | #endif |
| 678 | return; |
| 679 | } |
| 680 | |
| 681 | rcu_read_lock(); |
| 682 | sta = sta_info_get(local, ra); |
| 683 | if (!sta) { |
| 684 | rcu_read_unlock(); |
| 685 | #ifdef CONFIG_MAC80211_HT_DEBUG |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 686 | printk(KERN_DEBUG "Could not find station: %pM\n", ra); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 687 | #endif |
| 688 | return; |
| 689 | } |
| 690 | |
| 691 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
| 692 | spin_lock_bh(&sta->lock); |
| 693 | |
| 694 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { |
| 695 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 696 | printk(KERN_DEBUG "addBA was not requested yet, state is %d\n", |
| 697 | *state); |
| 698 | #endif |
| 699 | spin_unlock_bh(&sta->lock); |
| 700 | rcu_read_unlock(); |
| 701 | return; |
| 702 | } |
| 703 | |
| 704 | WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK); |
| 705 | |
| 706 | *state |= HT_ADDBA_DRV_READY_MSK; |
| 707 | |
| 708 | if (*state == HT_AGG_STATE_OPERATIONAL) { |
| 709 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 710 | printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid); |
| 711 | #endif |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 712 | if (hw->ampdu_queues) |
| 713 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 714 | } |
| 715 | spin_unlock_bh(&sta->lock); |
| 716 | rcu_read_unlock(); |
| 717 | } |
| 718 | EXPORT_SYMBOL(ieee80211_start_tx_ba_cb); |
| 719 | |
| 720 | void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid) |
| 721 | { |
| 722 | struct ieee80211_local *local = hw_to_local(hw); |
| 723 | struct sta_info *sta; |
| 724 | u8 *state; |
| 725 | int agg_queue; |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 726 | |
| 727 | if (tid >= STA_TID_NUM) { |
| 728 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 729 | printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n", |
| 730 | tid, STA_TID_NUM); |
| 731 | #endif |
| 732 | return; |
| 733 | } |
| 734 | |
| 735 | #ifdef CONFIG_MAC80211_HT_DEBUG |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 736 | printk(KERN_DEBUG "Stopping Tx BA session for %pM tid %d\n", |
| 737 | ra, tid); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 738 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 739 | |
| 740 | rcu_read_lock(); |
| 741 | sta = sta_info_get(local, ra); |
| 742 | if (!sta) { |
| 743 | #ifdef CONFIG_MAC80211_HT_DEBUG |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 744 | printk(KERN_DEBUG "Could not find station: %pM\n", ra); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 745 | #endif |
| 746 | rcu_read_unlock(); |
| 747 | return; |
| 748 | } |
| 749 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
| 750 | |
| 751 | /* NOTE: no need to use sta->lock in this state check, as |
| 752 | * ieee80211_stop_tx_ba_session will let only one stop call to |
| 753 | * pass through per sta/tid |
| 754 | */ |
| 755 | if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) { |
| 756 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 757 | printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n"); |
| 758 | #endif |
| 759 | rcu_read_unlock(); |
| 760 | return; |
| 761 | } |
| 762 | |
| 763 | if (*state & HT_AGG_STATE_INITIATOR_MSK) |
| 764 | ieee80211_send_delba(sta->sdata, ra, tid, |
| 765 | WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE); |
| 766 | |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 767 | if (hw->ampdu_queues) { |
| 768 | agg_queue = sta->tid_to_tx_q[tid]; |
| 769 | ieee80211_ht_agg_queue_remove(local, sta, tid, 1); |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 770 | |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 771 | /* We just requeued the all the frames that were in the |
| 772 | * removed queue, and since we might miss a softirq we do |
| 773 | * netif_schedule_queue. ieee80211_wake_queue is not used |
| 774 | * here as this queue is not necessarily stopped |
| 775 | */ |
| 776 | netif_schedule_queue(netdev_get_tx_queue(local->mdev, |
| 777 | agg_queue)); |
| 778 | } |
Johannes Berg | bacac54 | 2008-09-08 17:44:29 +0200 | [diff] [blame] | 779 | spin_lock_bh(&sta->lock); |
| 780 | *state = HT_AGG_STATE_IDLE; |
| 781 | sta->ampdu_mlme.addba_req_num[tid] = 0; |
| 782 | kfree(sta->ampdu_mlme.tid_tx[tid]); |
| 783 | sta->ampdu_mlme.tid_tx[tid] = NULL; |
| 784 | spin_unlock_bh(&sta->lock); |
| 785 | |
| 786 | rcu_read_unlock(); |
| 787 | } |
| 788 | EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb); |
| 789 | |
| 790 | void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, |
| 791 | const u8 *ra, u16 tid) |
| 792 | { |
| 793 | struct ieee80211_local *local = hw_to_local(hw); |
| 794 | struct ieee80211_ra_tid *ra_tid; |
| 795 | struct sk_buff *skb = dev_alloc_skb(0); |
| 796 | |
| 797 | if (unlikely(!skb)) { |
| 798 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 799 | if (net_ratelimit()) |
| 800 | printk(KERN_WARNING "%s: Not enough memory, " |
| 801 | "dropping start BA session", skb->dev->name); |
| 802 | #endif |
| 803 | return; |
| 804 | } |
| 805 | ra_tid = (struct ieee80211_ra_tid *) &skb->cb; |
| 806 | memcpy(&ra_tid->ra, ra, ETH_ALEN); |
| 807 | ra_tid->tid = tid; |
| 808 | |
| 809 | skb->pkt_type = IEEE80211_ADDBA_MSG; |
| 810 | skb_queue_tail(&local->skb_queue, skb); |
| 811 | tasklet_schedule(&local->tasklet); |
| 812 | } |
| 813 | EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe); |
| 814 | |
| 815 | void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, |
| 816 | const u8 *ra, u16 tid) |
| 817 | { |
| 818 | struct ieee80211_local *local = hw_to_local(hw); |
| 819 | struct ieee80211_ra_tid *ra_tid; |
| 820 | struct sk_buff *skb = dev_alloc_skb(0); |
| 821 | |
| 822 | if (unlikely(!skb)) { |
| 823 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 824 | if (net_ratelimit()) |
| 825 | printk(KERN_WARNING "%s: Not enough memory, " |
| 826 | "dropping stop BA session", skb->dev->name); |
| 827 | #endif |
| 828 | return; |
| 829 | } |
| 830 | ra_tid = (struct ieee80211_ra_tid *) &skb->cb; |
| 831 | memcpy(&ra_tid->ra, ra, ETH_ALEN); |
| 832 | ra_tid->tid = tid; |
| 833 | |
| 834 | skb->pkt_type = IEEE80211_DELBA_MSG; |
| 835 | skb_queue_tail(&local->skb_queue, skb); |
| 836 | tasklet_schedule(&local->tasklet); |
| 837 | } |
| 838 | EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe); |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 839 | |
| 840 | /* |
| 841 | * After accepting the AddBA Request we activated a timer, |
| 842 | * resetting it after each frame that arrives from the originator. |
| 843 | * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. |
| 844 | */ |
| 845 | static void sta_rx_agg_session_timer_expired(unsigned long data) |
| 846 | { |
| 847 | /* not an elegant detour, but there is no choice as the timer passes |
| 848 | * only one argument, and various sta_info are needed here, so init |
| 849 | * flow in sta_info_create gives the TID as data, while the timer_to_id |
| 850 | * array gives the sta through container_of */ |
| 851 | u8 *ptid = (u8 *)data; |
| 852 | u8 *timer_to_id = ptid - *ptid; |
| 853 | struct sta_info *sta = container_of(timer_to_id, struct sta_info, |
| 854 | timer_to_tid[0]); |
| 855 | |
| 856 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 857 | printk(KERN_DEBUG "rx session timer expired on tid %d\n", (u16)*ptid); |
| 858 | #endif |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 859 | ieee80211_sta_stop_rx_ba_session(sta->sdata, sta->sta.addr, |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 860 | (u16)*ptid, WLAN_BACK_TIMER, |
| 861 | WLAN_REASON_QSTA_TIMEOUT); |
| 862 | } |
| 863 | |
| 864 | void ieee80211_process_addba_request(struct ieee80211_local *local, |
| 865 | struct sta_info *sta, |
| 866 | struct ieee80211_mgmt *mgmt, |
| 867 | size_t len) |
| 868 | { |
| 869 | struct ieee80211_hw *hw = &local->hw; |
| 870 | struct ieee80211_conf *conf = &hw->conf; |
| 871 | struct tid_ampdu_rx *tid_agg_rx; |
| 872 | u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num, status; |
| 873 | u8 dialog_token; |
| 874 | int ret = -EOPNOTSUPP; |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 875 | |
| 876 | /* extract session parameters from addba request frame */ |
| 877 | dialog_token = mgmt->u.action.u.addba_req.dialog_token; |
| 878 | timeout = le16_to_cpu(mgmt->u.action.u.addba_req.timeout); |
| 879 | start_seq_num = |
| 880 | le16_to_cpu(mgmt->u.action.u.addba_req.start_seq_num) >> 4; |
| 881 | |
| 882 | capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab); |
| 883 | ba_policy = (capab & IEEE80211_ADDBA_PARAM_POLICY_MASK) >> 1; |
| 884 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; |
| 885 | buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6; |
| 886 | |
| 887 | status = WLAN_STATUS_REQUEST_DECLINED; |
| 888 | |
| 889 | /* sanity check for incoming parameters: |
| 890 | * check if configuration can support the BA policy |
| 891 | * and if buffer size does not exceeds max value */ |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 892 | /* XXX: check own ht delayed BA capability?? */ |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 893 | if (((ba_policy != 1) |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 894 | && (!(sta->sta.ht_cap.cap & IEEE80211_HT_CAP_DELAY_BA))) |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 895 | || (buf_size > IEEE80211_MAX_AMPDU_BUF)) { |
| 896 | status = WLAN_STATUS_INVALID_QOS_PARAM; |
| 897 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 898 | if (net_ratelimit()) |
| 899 | printk(KERN_DEBUG "AddBA Req with bad params from " |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 900 | "%pM on tid %u. policy %d, buffer size %d\n", |
| 901 | mgmt->sa, tid, ba_policy, |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 902 | buf_size); |
| 903 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 904 | goto end_no_lock; |
| 905 | } |
| 906 | /* determine default buffer size */ |
| 907 | if (buf_size == 0) { |
| 908 | struct ieee80211_supported_band *sband; |
| 909 | |
| 910 | sband = local->hw.wiphy->bands[conf->channel->band]; |
| 911 | buf_size = IEEE80211_MIN_AMPDU_BUF; |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 912 | buf_size = buf_size << sband->ht_cap.ampdu_factor; |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | |
| 916 | /* examine state machine */ |
| 917 | spin_lock_bh(&sta->lock); |
| 918 | |
| 919 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_IDLE) { |
| 920 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 921 | if (net_ratelimit()) |
| 922 | printk(KERN_DEBUG "unexpected AddBA Req from " |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 923 | "%pM on tid %u\n", |
| 924 | mgmt->sa, tid); |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 925 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 926 | goto end; |
| 927 | } |
| 928 | |
| 929 | /* prepare A-MPDU MLME for Rx aggregation */ |
| 930 | sta->ampdu_mlme.tid_rx[tid] = |
| 931 | kmalloc(sizeof(struct tid_ampdu_rx), GFP_ATOMIC); |
| 932 | if (!sta->ampdu_mlme.tid_rx[tid]) { |
| 933 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 934 | if (net_ratelimit()) |
| 935 | printk(KERN_ERR "allocate rx mlme to tid %d failed\n", |
| 936 | tid); |
| 937 | #endif |
| 938 | goto end; |
| 939 | } |
| 940 | /* rx timer */ |
| 941 | sta->ampdu_mlme.tid_rx[tid]->session_timer.function = |
| 942 | sta_rx_agg_session_timer_expired; |
| 943 | sta->ampdu_mlme.tid_rx[tid]->session_timer.data = |
| 944 | (unsigned long)&sta->timer_to_tid[tid]; |
| 945 | init_timer(&sta->ampdu_mlme.tid_rx[tid]->session_timer); |
| 946 | |
| 947 | tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; |
| 948 | |
| 949 | /* prepare reordering buffer */ |
| 950 | tid_agg_rx->reorder_buf = |
| 951 | kmalloc(buf_size * sizeof(struct sk_buff *), GFP_ATOMIC); |
| 952 | if (!tid_agg_rx->reorder_buf) { |
| 953 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 954 | if (net_ratelimit()) |
| 955 | printk(KERN_ERR "can not allocate reordering buffer " |
| 956 | "to tid %d\n", tid); |
| 957 | #endif |
| 958 | kfree(sta->ampdu_mlme.tid_rx[tid]); |
| 959 | goto end; |
| 960 | } |
| 961 | memset(tid_agg_rx->reorder_buf, 0, |
| 962 | buf_size * sizeof(struct sk_buff *)); |
| 963 | |
| 964 | if (local->ops->ampdu_action) |
| 965 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_START, |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 966 | &sta->sta, tid, &start_seq_num); |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 967 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 968 | printk(KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n", tid, ret); |
| 969 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 970 | |
| 971 | if (ret) { |
| 972 | kfree(tid_agg_rx->reorder_buf); |
| 973 | kfree(tid_agg_rx); |
| 974 | sta->ampdu_mlme.tid_rx[tid] = NULL; |
| 975 | goto end; |
| 976 | } |
| 977 | |
| 978 | /* change state and send addba resp */ |
| 979 | sta->ampdu_mlme.tid_state_rx[tid] = HT_AGG_STATE_OPERATIONAL; |
| 980 | tid_agg_rx->dialog_token = dialog_token; |
| 981 | tid_agg_rx->ssn = start_seq_num; |
| 982 | tid_agg_rx->head_seq_num = start_seq_num; |
| 983 | tid_agg_rx->buf_size = buf_size; |
| 984 | tid_agg_rx->timeout = timeout; |
| 985 | tid_agg_rx->stored_mpdu_num = 0; |
| 986 | status = WLAN_STATUS_SUCCESS; |
| 987 | end: |
| 988 | spin_unlock_bh(&sta->lock); |
| 989 | |
| 990 | end_no_lock: |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 991 | ieee80211_send_addba_resp(sta->sdata, sta->sta.addr, tid, |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 992 | dialog_token, status, 1, buf_size, timeout); |
| 993 | } |
| 994 | |
| 995 | void ieee80211_process_addba_resp(struct ieee80211_local *local, |
| 996 | struct sta_info *sta, |
| 997 | struct ieee80211_mgmt *mgmt, |
| 998 | size_t len) |
| 999 | { |
| 1000 | struct ieee80211_hw *hw = &local->hw; |
| 1001 | u16 capab; |
Sujith | 8469cde | 2008-10-29 10:19:28 +0530 | [diff] [blame] | 1002 | u16 tid, start_seq_num; |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 1003 | u8 *state; |
| 1004 | |
| 1005 | capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab); |
| 1006 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; |
| 1007 | |
| 1008 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
| 1009 | |
| 1010 | spin_lock_bh(&sta->lock); |
| 1011 | |
| 1012 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { |
| 1013 | spin_unlock_bh(&sta->lock); |
| 1014 | return; |
| 1015 | } |
| 1016 | |
| 1017 | if (mgmt->u.action.u.addba_resp.dialog_token != |
| 1018 | sta->ampdu_mlme.tid_tx[tid]->dialog_token) { |
| 1019 | spin_unlock_bh(&sta->lock); |
| 1020 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 1021 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); |
| 1022 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 1023 | return; |
| 1024 | } |
| 1025 | |
| 1026 | del_timer_sync(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); |
| 1027 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 1028 | printk(KERN_DEBUG "switched off addBA timer for tid %d \n", tid); |
| 1029 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 1030 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) |
| 1031 | == WLAN_STATUS_SUCCESS) { |
| 1032 | *state |= HT_ADDBA_RECEIVED_MSK; |
| 1033 | sta->ampdu_mlme.addba_req_num[tid] = 0; |
| 1034 | |
Sujith | 8b30b1f | 2008-10-24 09:55:27 +0530 | [diff] [blame] | 1035 | if (*state == HT_AGG_STATE_OPERATIONAL && |
| 1036 | local->hw.ampdu_queues) |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 1037 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); |
| 1038 | |
Sujith | 8469cde | 2008-10-29 10:19:28 +0530 | [diff] [blame] | 1039 | if (local->ops->ampdu_action) { |
| 1040 | (void)local->ops->ampdu_action(hw, |
| 1041 | IEEE80211_AMPDU_TX_RESUME, |
| 1042 | &sta->sta, tid, &start_seq_num); |
| 1043 | } |
| 1044 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 1045 | printk(KERN_DEBUG "Resuming TX aggregation for tid %d\n", tid); |
| 1046 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 1047 | spin_unlock_bh(&sta->lock); |
| 1048 | } else { |
| 1049 | sta->ampdu_mlme.addba_req_num[tid]++; |
| 1050 | /* this will allow the state check in stop_BA_session */ |
| 1051 | *state = HT_AGG_STATE_OPERATIONAL; |
| 1052 | spin_unlock_bh(&sta->lock); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1053 | ieee80211_stop_tx_ba_session(hw, sta->sta.addr, tid, |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 1054 | WLAN_BACK_INITIATOR); |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, |
| 1059 | struct sta_info *sta, |
| 1060 | struct ieee80211_mgmt *mgmt, size_t len) |
| 1061 | { |
| 1062 | struct ieee80211_local *local = sdata->local; |
| 1063 | u16 tid, params; |
| 1064 | u16 initiator; |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 1065 | |
| 1066 | params = le16_to_cpu(mgmt->u.action.u.delba.params); |
| 1067 | tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12; |
| 1068 | initiator = (params & IEEE80211_DELBA_PARAM_INITIATOR_MASK) >> 11; |
| 1069 | |
| 1070 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 1071 | if (net_ratelimit()) |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 1072 | printk(KERN_DEBUG "delba from %pM (%s) tid %d reason code %d\n", |
| 1073 | mgmt->sa, initiator ? "initiator" : "recipient", tid, |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 1074 | mgmt->u.action.u.delba.reason_code); |
| 1075 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 1076 | |
| 1077 | if (initiator == WLAN_BACK_INITIATOR) |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1078 | ieee80211_sta_stop_rx_ba_session(sdata, sta->sta.addr, tid, |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 1079 | WLAN_BACK_INITIATOR, 0); |
| 1080 | else { /* WLAN_BACK_RECIPIENT */ |
| 1081 | spin_lock_bh(&sta->lock); |
| 1082 | sta->ampdu_mlme.tid_state_tx[tid] = |
| 1083 | HT_AGG_STATE_OPERATIONAL; |
| 1084 | spin_unlock_bh(&sta->lock); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1085 | ieee80211_stop_tx_ba_session(&local->hw, sta->sta.addr, tid, |
Johannes Berg | de1ede7 | 2008-09-09 14:42:50 +0200 | [diff] [blame] | 1086 | WLAN_BACK_RECIPIENT); |
| 1087 | } |
| 1088 | } |