diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-09-09 08:42:50 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-11 15:53:39 -0400 |
commit | de1ede7ac3bd300f9aa565d0f93f6cf9ba74bb1a (patch) | |
tree | 82e48b4140e9444104639a97aa55be03c5020466 /net/mac80211/mlme.c | |
parent | 5825fe100d654fff89aa67a1e202af1f8a7f0ad0 (diff) |
mac80211: make BA session handling independent of STA mode
The aggregation handling isn't dependent on anything related to our
STA-mode implementation, and doesn't need to depend on it for frame
processing. This patch moves the relevant code to ht.c and adds a
hook in rx.c. For now, the relevant action frames are only processed
in STA/IBSS modes, but that's now something we can easily change.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r-- | net/mac80211/mlme.c | 340 |
1 files changed, 0 insertions, 340 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index c22dcd605e48..25f90f7ccf3e 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -445,52 +445,6 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | |||
445 | ieee80211_sta_tx(sdata, skb, 0); | 445 | ieee80211_sta_tx(sdata, skb, 0); |
446 | } | 446 | } |
447 | 447 | ||
448 | static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid, | ||
449 | u8 dialog_token, u16 status, u16 policy, | ||
450 | u16 buf_size, u16 timeout) | ||
451 | { | ||
452 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | ||
453 | struct ieee80211_local *local = sdata->local; | ||
454 | struct sk_buff *skb; | ||
455 | struct ieee80211_mgmt *mgmt; | ||
456 | u16 capab; | ||
457 | |||
458 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); | ||
459 | |||
460 | if (!skb) { | ||
461 | printk(KERN_DEBUG "%s: failed to allocate buffer " | ||
462 | "for addba resp frame\n", sdata->dev->name); | ||
463 | return; | ||
464 | } | ||
465 | |||
466 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
467 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | ||
468 | memset(mgmt, 0, 24); | ||
469 | memcpy(mgmt->da, da, ETH_ALEN); | ||
470 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | ||
471 | if (sdata->vif.type == IEEE80211_IF_TYPE_AP) | ||
472 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | ||
473 | else | ||
474 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
475 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
476 | IEEE80211_STYPE_ACTION); | ||
477 | |||
478 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_resp)); | ||
479 | mgmt->u.action.category = WLAN_CATEGORY_BACK; | ||
480 | mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP; | ||
481 | mgmt->u.action.u.addba_resp.dialog_token = dialog_token; | ||
482 | |||
483 | capab = (u16)(policy << 1); /* bit 1 aggregation policy */ | ||
484 | capab |= (u16)(tid << 2); /* bit 5:2 TID number */ | ||
485 | capab |= (u16)(buf_size << 6); /* bit 15:6 max size of aggregation */ | ||
486 | |||
487 | mgmt->u.action.u.addba_resp.capab = cpu_to_le16(capab); | ||
488 | mgmt->u.action.u.addba_resp.timeout = cpu_to_le16(timeout); | ||
489 | mgmt->u.action.u.addba_resp.status = cpu_to_le16(status); | ||
490 | |||
491 | ieee80211_sta_tx(sdata, skb, 0); | ||
492 | } | ||
493 | |||
494 | static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata, | 448 | static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata, |
495 | struct ieee80211_msrment_ie *request_ie, | 449 | struct ieee80211_msrment_ie *request_ie, |
496 | const u8 *da, const u8 *bssid, | 450 | const u8 *da, const u8 *bssid, |
@@ -1057,278 +1011,6 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, | |||
1057 | elems.challenge_len + 2, 1); | 1011 | elems.challenge_len + 2, 1); |
1058 | } | 1012 | } |
1059 | 1013 | ||
1060 | /* | ||
1061 | * After accepting the AddBA Request we activated a timer, | ||
1062 | * resetting it after each frame that arrives from the originator. | ||
1063 | * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. | ||
1064 | */ | ||
1065 | static void sta_rx_agg_session_timer_expired(unsigned long data) | ||
1066 | { | ||
1067 | /* not an elegant detour, but there is no choice as the timer passes | ||
1068 | * only one argument, and various sta_info are needed here, so init | ||
1069 | * flow in sta_info_create gives the TID as data, while the timer_to_id | ||
1070 | * array gives the sta through container_of */ | ||
1071 | u8 *ptid = (u8 *)data; | ||
1072 | u8 *timer_to_id = ptid - *ptid; | ||
1073 | struct sta_info *sta = container_of(timer_to_id, struct sta_info, | ||
1074 | timer_to_tid[0]); | ||
1075 | |||
1076 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1077 | printk(KERN_DEBUG "rx session timer expired on tid %d\n", (u16)*ptid); | ||
1078 | #endif | ||
1079 | ieee80211_sta_stop_rx_ba_session(sta->sdata, sta->addr, | ||
1080 | (u16)*ptid, WLAN_BACK_TIMER, | ||
1081 | WLAN_REASON_QSTA_TIMEOUT); | ||
1082 | } | ||
1083 | |||
1084 | static void ieee80211_sta_process_addba_request(struct ieee80211_local *local, | ||
1085 | struct ieee80211_mgmt *mgmt, | ||
1086 | size_t len) | ||
1087 | { | ||
1088 | struct ieee80211_hw *hw = &local->hw; | ||
1089 | struct ieee80211_conf *conf = &hw->conf; | ||
1090 | struct sta_info *sta; | ||
1091 | struct tid_ampdu_rx *tid_agg_rx; | ||
1092 | u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num, status; | ||
1093 | u8 dialog_token; | ||
1094 | int ret = -EOPNOTSUPP; | ||
1095 | DECLARE_MAC_BUF(mac); | ||
1096 | |||
1097 | rcu_read_lock(); | ||
1098 | |||
1099 | sta = sta_info_get(local, mgmt->sa); | ||
1100 | if (!sta) { | ||
1101 | rcu_read_unlock(); | ||
1102 | return; | ||
1103 | } | ||
1104 | |||
1105 | /* extract session parameters from addba request frame */ | ||
1106 | dialog_token = mgmt->u.action.u.addba_req.dialog_token; | ||
1107 | timeout = le16_to_cpu(mgmt->u.action.u.addba_req.timeout); | ||
1108 | start_seq_num = | ||
1109 | le16_to_cpu(mgmt->u.action.u.addba_req.start_seq_num) >> 4; | ||
1110 | |||
1111 | capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab); | ||
1112 | ba_policy = (capab & IEEE80211_ADDBA_PARAM_POLICY_MASK) >> 1; | ||
1113 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; | ||
1114 | buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6; | ||
1115 | |||
1116 | status = WLAN_STATUS_REQUEST_DECLINED; | ||
1117 | |||
1118 | /* sanity check for incoming parameters: | ||
1119 | * check if configuration can support the BA policy | ||
1120 | * and if buffer size does not exceeds max value */ | ||
1121 | if (((ba_policy != 1) | ||
1122 | && (!(conf->ht_conf.cap & IEEE80211_HT_CAP_DELAY_BA))) | ||
1123 | || (buf_size > IEEE80211_MAX_AMPDU_BUF)) { | ||
1124 | status = WLAN_STATUS_INVALID_QOS_PARAM; | ||
1125 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1126 | if (net_ratelimit()) | ||
1127 | printk(KERN_DEBUG "AddBA Req with bad params from " | ||
1128 | "%s on tid %u. policy %d, buffer size %d\n", | ||
1129 | print_mac(mac, mgmt->sa), tid, ba_policy, | ||
1130 | buf_size); | ||
1131 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1132 | goto end_no_lock; | ||
1133 | } | ||
1134 | /* determine default buffer size */ | ||
1135 | if (buf_size == 0) { | ||
1136 | struct ieee80211_supported_band *sband; | ||
1137 | |||
1138 | sband = local->hw.wiphy->bands[conf->channel->band]; | ||
1139 | buf_size = IEEE80211_MIN_AMPDU_BUF; | ||
1140 | buf_size = buf_size << sband->ht_info.ampdu_factor; | ||
1141 | } | ||
1142 | |||
1143 | |||
1144 | /* examine state machine */ | ||
1145 | spin_lock_bh(&sta->lock); | ||
1146 | |||
1147 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_IDLE) { | ||
1148 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1149 | if (net_ratelimit()) | ||
1150 | printk(KERN_DEBUG "unexpected AddBA Req from " | ||
1151 | "%s on tid %u\n", | ||
1152 | print_mac(mac, mgmt->sa), tid); | ||
1153 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1154 | goto end; | ||
1155 | } | ||
1156 | |||
1157 | /* prepare A-MPDU MLME for Rx aggregation */ | ||
1158 | sta->ampdu_mlme.tid_rx[tid] = | ||
1159 | kmalloc(sizeof(struct tid_ampdu_rx), GFP_ATOMIC); | ||
1160 | if (!sta->ampdu_mlme.tid_rx[tid]) { | ||
1161 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1162 | if (net_ratelimit()) | ||
1163 | printk(KERN_ERR "allocate rx mlme to tid %d failed\n", | ||
1164 | tid); | ||
1165 | #endif | ||
1166 | goto end; | ||
1167 | } | ||
1168 | /* rx timer */ | ||
1169 | sta->ampdu_mlme.tid_rx[tid]->session_timer.function = | ||
1170 | sta_rx_agg_session_timer_expired; | ||
1171 | sta->ampdu_mlme.tid_rx[tid]->session_timer.data = | ||
1172 | (unsigned long)&sta->timer_to_tid[tid]; | ||
1173 | init_timer(&sta->ampdu_mlme.tid_rx[tid]->session_timer); | ||
1174 | |||
1175 | tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; | ||
1176 | |||
1177 | /* prepare reordering buffer */ | ||
1178 | tid_agg_rx->reorder_buf = | ||
1179 | kmalloc(buf_size * sizeof(struct sk_buff *), GFP_ATOMIC); | ||
1180 | if (!tid_agg_rx->reorder_buf) { | ||
1181 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1182 | if (net_ratelimit()) | ||
1183 | printk(KERN_ERR "can not allocate reordering buffer " | ||
1184 | "to tid %d\n", tid); | ||
1185 | #endif | ||
1186 | kfree(sta->ampdu_mlme.tid_rx[tid]); | ||
1187 | goto end; | ||
1188 | } | ||
1189 | memset(tid_agg_rx->reorder_buf, 0, | ||
1190 | buf_size * sizeof(struct sk_buff *)); | ||
1191 | |||
1192 | if (local->ops->ampdu_action) | ||
1193 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_START, | ||
1194 | sta->addr, tid, &start_seq_num); | ||
1195 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1196 | printk(KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n", tid, ret); | ||
1197 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1198 | |||
1199 | if (ret) { | ||
1200 | kfree(tid_agg_rx->reorder_buf); | ||
1201 | kfree(tid_agg_rx); | ||
1202 | sta->ampdu_mlme.tid_rx[tid] = NULL; | ||
1203 | goto end; | ||
1204 | } | ||
1205 | |||
1206 | /* change state and send addba resp */ | ||
1207 | sta->ampdu_mlme.tid_state_rx[tid] = HT_AGG_STATE_OPERATIONAL; | ||
1208 | tid_agg_rx->dialog_token = dialog_token; | ||
1209 | tid_agg_rx->ssn = start_seq_num; | ||
1210 | tid_agg_rx->head_seq_num = start_seq_num; | ||
1211 | tid_agg_rx->buf_size = buf_size; | ||
1212 | tid_agg_rx->timeout = timeout; | ||
1213 | tid_agg_rx->stored_mpdu_num = 0; | ||
1214 | status = WLAN_STATUS_SUCCESS; | ||
1215 | end: | ||
1216 | spin_unlock_bh(&sta->lock); | ||
1217 | |||
1218 | end_no_lock: | ||
1219 | ieee80211_send_addba_resp(sta->sdata, sta->addr, tid, | ||
1220 | dialog_token, status, 1, buf_size, timeout); | ||
1221 | rcu_read_unlock(); | ||
1222 | } | ||
1223 | |||
1224 | static void ieee80211_sta_process_addba_resp(struct ieee80211_local *local, | ||
1225 | struct ieee80211_mgmt *mgmt, | ||
1226 | size_t len) | ||
1227 | { | ||
1228 | struct ieee80211_hw *hw = &local->hw; | ||
1229 | struct sta_info *sta; | ||
1230 | u16 capab; | ||
1231 | u16 tid; | ||
1232 | u8 *state; | ||
1233 | |||
1234 | rcu_read_lock(); | ||
1235 | |||
1236 | sta = sta_info_get(local, mgmt->sa); | ||
1237 | if (!sta) { | ||
1238 | rcu_read_unlock(); | ||
1239 | return; | ||
1240 | } | ||
1241 | |||
1242 | capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab); | ||
1243 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; | ||
1244 | |||
1245 | state = &sta->ampdu_mlme.tid_state_tx[tid]; | ||
1246 | |||
1247 | spin_lock_bh(&sta->lock); | ||
1248 | |||
1249 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | ||
1250 | spin_unlock_bh(&sta->lock); | ||
1251 | goto addba_resp_exit; | ||
1252 | } | ||
1253 | |||
1254 | if (mgmt->u.action.u.addba_resp.dialog_token != | ||
1255 | sta->ampdu_mlme.tid_tx[tid]->dialog_token) { | ||
1256 | spin_unlock_bh(&sta->lock); | ||
1257 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1258 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); | ||
1259 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1260 | goto addba_resp_exit; | ||
1261 | } | ||
1262 | |||
1263 | del_timer_sync(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); | ||
1264 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1265 | printk(KERN_DEBUG "switched off addBA timer for tid %d \n", tid); | ||
1266 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1267 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) | ||
1268 | == WLAN_STATUS_SUCCESS) { | ||
1269 | *state |= HT_ADDBA_RECEIVED_MSK; | ||
1270 | sta->ampdu_mlme.addba_req_num[tid] = 0; | ||
1271 | |||
1272 | if (*state == HT_AGG_STATE_OPERATIONAL) | ||
1273 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); | ||
1274 | |||
1275 | spin_unlock_bh(&sta->lock); | ||
1276 | } else { | ||
1277 | sta->ampdu_mlme.addba_req_num[tid]++; | ||
1278 | /* this will allow the state check in stop_BA_session */ | ||
1279 | *state = HT_AGG_STATE_OPERATIONAL; | ||
1280 | spin_unlock_bh(&sta->lock); | ||
1281 | ieee80211_stop_tx_ba_session(hw, sta->addr, tid, | ||
1282 | WLAN_BACK_INITIATOR); | ||
1283 | } | ||
1284 | |||
1285 | addba_resp_exit: | ||
1286 | rcu_read_unlock(); | ||
1287 | } | ||
1288 | |||
1289 | static void ieee80211_sta_process_delba(struct ieee80211_sub_if_data *sdata, | ||
1290 | struct ieee80211_mgmt *mgmt, size_t len) | ||
1291 | { | ||
1292 | struct ieee80211_local *local = sdata->local; | ||
1293 | struct sta_info *sta; | ||
1294 | u16 tid, params; | ||
1295 | u16 initiator; | ||
1296 | DECLARE_MAC_BUF(mac); | ||
1297 | |||
1298 | rcu_read_lock(); | ||
1299 | |||
1300 | sta = sta_info_get(local, mgmt->sa); | ||
1301 | if (!sta) { | ||
1302 | rcu_read_unlock(); | ||
1303 | return; | ||
1304 | } | ||
1305 | |||
1306 | params = le16_to_cpu(mgmt->u.action.u.delba.params); | ||
1307 | tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12; | ||
1308 | initiator = (params & IEEE80211_DELBA_PARAM_INITIATOR_MASK) >> 11; | ||
1309 | |||
1310 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1311 | if (net_ratelimit()) | ||
1312 | printk(KERN_DEBUG "delba from %s (%s) tid %d reason code %d\n", | ||
1313 | print_mac(mac, mgmt->sa), | ||
1314 | initiator ? "initiator" : "recipient", tid, | ||
1315 | mgmt->u.action.u.delba.reason_code); | ||
1316 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1317 | |||
1318 | if (initiator == WLAN_BACK_INITIATOR) | ||
1319 | ieee80211_sta_stop_rx_ba_session(sdata, sta->addr, tid, | ||
1320 | WLAN_BACK_INITIATOR, 0); | ||
1321 | else { /* WLAN_BACK_RECIPIENT */ | ||
1322 | spin_lock_bh(&sta->lock); | ||
1323 | sta->ampdu_mlme.tid_state_tx[tid] = | ||
1324 | HT_AGG_STATE_OPERATIONAL; | ||
1325 | spin_unlock_bh(&sta->lock); | ||
1326 | ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid, | ||
1327 | WLAN_BACK_RECIPIENT); | ||
1328 | } | ||
1329 | rcu_read_unlock(); | ||
1330 | } | ||
1331 | |||
1332 | static void ieee80211_sta_process_measurement_req(struct ieee80211_sub_if_data *sdata, | 1014 | static void ieee80211_sta_process_measurement_req(struct ieee80211_sub_if_data *sdata, |
1333 | struct ieee80211_mgmt *mgmt, | 1015 | struct ieee80211_mgmt *mgmt, |
1334 | size_t len) | 1016 | size_t len) |
@@ -2207,28 +1889,6 @@ static void ieee80211_rx_mgmt_action(struct ieee80211_sub_if_data *sdata, | |||
2207 | break; | 1889 | break; |
2208 | } | 1890 | } |
2209 | break; | 1891 | break; |
2210 | case WLAN_CATEGORY_BACK: | ||
2211 | switch (mgmt->u.action.u.addba_req.action_code) { | ||
2212 | case WLAN_ACTION_ADDBA_REQ: | ||
2213 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2214 | sizeof(mgmt->u.action.u.addba_req))) | ||
2215 | break; | ||
2216 | ieee80211_sta_process_addba_request(local, mgmt, len); | ||
2217 | break; | ||
2218 | case WLAN_ACTION_ADDBA_RESP: | ||
2219 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2220 | sizeof(mgmt->u.action.u.addba_resp))) | ||
2221 | break; | ||
2222 | ieee80211_sta_process_addba_resp(local, mgmt, len); | ||
2223 | break; | ||
2224 | case WLAN_ACTION_DELBA: | ||
2225 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2226 | sizeof(mgmt->u.action.u.delba))) | ||
2227 | break; | ||
2228 | ieee80211_sta_process_delba(sdata, mgmt, len); | ||
2229 | break; | ||
2230 | } | ||
2231 | break; | ||
2232 | case PLINK_CATEGORY: | 1892 | case PLINK_CATEGORY: |
2233 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 1893 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
2234 | mesh_rx_plink_frame(sdata, mgmt, len, rx_status); | 1894 | mesh_rx_plink_frame(sdata, mgmt, len, rx_status); |