diff options
author | David S. Miller <davem@davemloft.net> | 2009-11-24 18:01:29 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-24 18:01:29 -0500 |
commit | 4ba3eb034fb6fd1990ccc5a6d71d5abcda37b905 (patch) | |
tree | 0789ba36d96dba330416a1e6a9a68e891a78802a /net/mac80211/rx.c | |
parent | 35700212b45ea9f98fa682cfc1bc1a67c9ccc34b (diff) | |
parent | 18b6c9a2213d3b6e0212e8b225abf95f7564206a (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r-- | net/mac80211/rx.c | 334 |
1 files changed, 171 insertions, 163 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 6bce97ee2534..96f13ad05d3c 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -27,11 +27,10 @@ | |||
27 | #include "tkip.h" | 27 | #include "tkip.h" |
28 | #include "wme.h" | 28 | #include "wme.h" |
29 | 29 | ||
30 | static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | 30 | static void ieee80211_release_reorder_frames(struct ieee80211_hw *hw, |
31 | struct tid_ampdu_rx *tid_agg_rx, | 31 | struct tid_ampdu_rx *tid_agg_rx, |
32 | struct sk_buff *skb, | 32 | u16 head_seq_num); |
33 | u16 mpdu_seq_num, | 33 | |
34 | int bar_req); | ||
35 | /* | 34 | /* |
36 | * monitor mode reception | 35 | * monitor mode reception |
37 | * | 36 | * |
@@ -164,6 +163,9 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, | |||
164 | if (status->band == IEEE80211_BAND_5GHZ) | 163 | if (status->band == IEEE80211_BAND_5GHZ) |
165 | put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ, | 164 | put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ, |
166 | pos); | 165 | pos); |
166 | else if (status->flag & RX_FLAG_HT) | ||
167 | put_unaligned_le16(IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ, | ||
168 | pos); | ||
167 | else if (rate->flags & IEEE80211_RATE_ERP_G) | 169 | else if (rate->flags & IEEE80211_RATE_ERP_G) |
168 | put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ, | 170 | put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ, |
169 | pos); | 171 | pos); |
@@ -478,7 +480,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
478 | { | 480 | { |
479 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 481 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
480 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); | 482 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); |
481 | char *dev_addr = rx->dev->dev_addr; | 483 | char *dev_addr = rx->sdata->dev->dev_addr; |
482 | 484 | ||
483 | if (ieee80211_is_data(hdr->frame_control)) { | 485 | if (ieee80211_is_data(hdr->frame_control)) { |
484 | if (is_multicast_ether_addr(hdr->addr1)) { | 486 | if (is_multicast_ether_addr(hdr->addr1)) { |
@@ -592,7 +594,9 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) | |||
592 | static ieee80211_rx_result debug_noinline | 594 | static ieee80211_rx_result debug_noinline |
593 | ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | 595 | ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) |
594 | { | 596 | { |
595 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 597 | struct sk_buff *skb = rx->skb; |
598 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | ||
599 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
596 | int keyidx; | 600 | int keyidx; |
597 | int hdrlen; | 601 | int hdrlen; |
598 | ieee80211_rx_result result = RX_DROP_UNUSABLE; | 602 | ieee80211_rx_result result = RX_DROP_UNUSABLE; |
@@ -646,8 +650,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
646 | return RX_CONTINUE; | 650 | return RX_CONTINUE; |
647 | } else if (mmie_keyidx >= 0) { | 651 | } else if (mmie_keyidx >= 0) { |
648 | /* Broadcast/multicast robust management frame / BIP */ | 652 | /* Broadcast/multicast robust management frame / BIP */ |
649 | if ((rx->status->flag & RX_FLAG_DECRYPTED) && | 653 | if ((status->flag & RX_FLAG_DECRYPTED) && |
650 | (rx->status->flag & RX_FLAG_IV_STRIPPED)) | 654 | (status->flag & RX_FLAG_IV_STRIPPED)) |
651 | return RX_CONTINUE; | 655 | return RX_CONTINUE; |
652 | 656 | ||
653 | if (mmie_keyidx < NUM_DEFAULT_KEYS || | 657 | if (mmie_keyidx < NUM_DEFAULT_KEYS || |
@@ -679,8 +683,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
679 | * we somehow allow the driver to tell us which key | 683 | * we somehow allow the driver to tell us which key |
680 | * the hardware used if this flag is set? | 684 | * the hardware used if this flag is set? |
681 | */ | 685 | */ |
682 | if ((rx->status->flag & RX_FLAG_DECRYPTED) && | 686 | if ((status->flag & RX_FLAG_DECRYPTED) && |
683 | (rx->status->flag & RX_FLAG_IV_STRIPPED)) | 687 | (status->flag & RX_FLAG_IV_STRIPPED)) |
684 | return RX_CONTINUE; | 688 | return RX_CONTINUE; |
685 | 689 | ||
686 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 690 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
@@ -716,8 +720,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
716 | /* Check for weak IVs if possible */ | 720 | /* Check for weak IVs if possible */ |
717 | if (rx->sta && rx->key->conf.alg == ALG_WEP && | 721 | if (rx->sta && rx->key->conf.alg == ALG_WEP && |
718 | ieee80211_is_data(hdr->frame_control) && | 722 | ieee80211_is_data(hdr->frame_control) && |
719 | (!(rx->status->flag & RX_FLAG_IV_STRIPPED) || | 723 | (!(status->flag & RX_FLAG_IV_STRIPPED) || |
720 | !(rx->status->flag & RX_FLAG_DECRYPTED)) && | 724 | !(status->flag & RX_FLAG_DECRYPTED)) && |
721 | ieee80211_wep_is_weak_iv(rx->skb, rx->key)) | 725 | ieee80211_wep_is_weak_iv(rx->skb, rx->key)) |
722 | rx->sta->wep_weak_iv_count++; | 726 | rx->sta->wep_weak_iv_count++; |
723 | 727 | ||
@@ -737,7 +741,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
737 | } | 741 | } |
738 | 742 | ||
739 | /* either the frame has been decrypted or will be dropped */ | 743 | /* either the frame has been decrypted or will be dropped */ |
740 | rx->status->flag |= RX_FLAG_DECRYPTED; | 744 | status->flag |= RX_FLAG_DECRYPTED; |
741 | 745 | ||
742 | return result; | 746 | return result; |
743 | } | 747 | } |
@@ -817,7 +821,9 @@ static ieee80211_rx_result debug_noinline | |||
817 | ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | 821 | ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) |
818 | { | 822 | { |
819 | struct sta_info *sta = rx->sta; | 823 | struct sta_info *sta = rx->sta; |
820 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 824 | struct sk_buff *skb = rx->skb; |
825 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | ||
826 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
821 | 827 | ||
822 | if (!sta) | 828 | if (!sta) |
823 | return RX_CONTINUE; | 829 | return RX_CONTINUE; |
@@ -848,8 +854,8 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
848 | 854 | ||
849 | sta->rx_fragments++; | 855 | sta->rx_fragments++; |
850 | sta->rx_bytes += rx->skb->len; | 856 | sta->rx_bytes += rx->skb->len; |
851 | sta->last_signal = rx->status->signal; | 857 | sta->last_signal = status->signal; |
852 | sta->last_noise = rx->status->noise; | 858 | sta->last_noise = status->noise; |
853 | 859 | ||
854 | /* | 860 | /* |
855 | * Change STA power saving mode only at the end of a frame | 861 | * Change STA power saving mode only at the end of a frame |
@@ -1141,11 +1147,14 @@ ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) | |||
1141 | static int | 1147 | static int |
1142 | ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) | 1148 | ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) |
1143 | { | 1149 | { |
1150 | struct sk_buff *skb = rx->skb; | ||
1151 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | ||
1152 | |||
1144 | /* | 1153 | /* |
1145 | * Pass through unencrypted frames if the hardware has | 1154 | * Pass through unencrypted frames if the hardware has |
1146 | * decrypted them already. | 1155 | * decrypted them already. |
1147 | */ | 1156 | */ |
1148 | if (rx->status->flag & RX_FLAG_DECRYPTED) | 1157 | if (status->flag & RX_FLAG_DECRYPTED) |
1149 | return 0; | 1158 | return 0; |
1150 | 1159 | ||
1151 | /* Drop unencrypted frames if key is set. */ | 1160 | /* Drop unencrypted frames if key is set. */ |
@@ -1179,14 +1188,17 @@ ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) | |||
1179 | static int | 1188 | static int |
1180 | __ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | 1189 | __ieee80211_data_to_8023(struct ieee80211_rx_data *rx) |
1181 | { | 1190 | { |
1182 | struct net_device *dev = rx->dev; | 1191 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1183 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1192 | struct net_device *dev = sdata->dev; |
1184 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 1193 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
1185 | 1194 | ||
1186 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->use_4addr && | 1195 | if (ieee80211_has_a4(hdr->frame_control) && |
1187 | ieee80211_has_a4(hdr->frame_control)) | 1196 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta) |
1188 | return -1; | 1197 | return -1; |
1189 | if (sdata->use_4addr && is_multicast_ether_addr(hdr->addr1)) | 1198 | |
1199 | if (is_multicast_ether_addr(hdr->addr1) && | ||
1200 | ((sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta) || | ||
1201 | (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr))) | ||
1190 | return -1; | 1202 | return -1; |
1191 | 1203 | ||
1192 | return ieee80211_data_to_8023(rx->skb, dev->dev_addr, sdata->vif.type); | 1204 | return ieee80211_data_to_8023(rx->skb, dev->dev_addr, sdata->vif.type); |
@@ -1206,7 +1218,7 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc) | |||
1206 | * of whether the frame was encrypted or not. | 1218 | * of whether the frame was encrypted or not. |
1207 | */ | 1219 | */ |
1208 | if (ehdr->h_proto == htons(ETH_P_PAE) && | 1220 | if (ehdr->h_proto == htons(ETH_P_PAE) && |
1209 | (compare_ether_addr(ehdr->h_dest, rx->dev->dev_addr) == 0 || | 1221 | (compare_ether_addr(ehdr->h_dest, rx->sdata->dev->dev_addr) == 0 || |
1210 | compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) | 1222 | compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) |
1211 | return true; | 1223 | return true; |
1212 | 1224 | ||
@@ -1223,10 +1235,10 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc) | |||
1223 | static void | 1235 | static void |
1224 | ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | 1236 | ieee80211_deliver_skb(struct ieee80211_rx_data *rx) |
1225 | { | 1237 | { |
1226 | struct net_device *dev = rx->dev; | 1238 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1239 | struct net_device *dev = sdata->dev; | ||
1227 | struct ieee80211_local *local = rx->local; | 1240 | struct ieee80211_local *local = rx->local; |
1228 | struct sk_buff *skb, *xmit_skb; | 1241 | struct sk_buff *skb, *xmit_skb; |
1229 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1230 | struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; | 1242 | struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; |
1231 | struct sta_info *dsta; | 1243 | struct sta_info *dsta; |
1232 | 1244 | ||
@@ -1236,7 +1248,8 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1236 | if ((sdata->vif.type == NL80211_IFTYPE_AP || | 1248 | if ((sdata->vif.type == NL80211_IFTYPE_AP || |
1237 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && | 1249 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && |
1238 | !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) && | 1250 | !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) && |
1239 | (rx->flags & IEEE80211_RX_RA_MATCH) && !rx->sdata->use_4addr) { | 1251 | (rx->flags & IEEE80211_RX_RA_MATCH) && |
1252 | (sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) { | ||
1240 | if (is_multicast_ether_addr(ehdr->h_dest)) { | 1253 | if (is_multicast_ether_addr(ehdr->h_dest)) { |
1241 | /* | 1254 | /* |
1242 | * send multicast frames both to higher layers in | 1255 | * send multicast frames both to higher layers in |
@@ -1307,7 +1320,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1307 | static ieee80211_rx_result debug_noinline | 1320 | static ieee80211_rx_result debug_noinline |
1308 | ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | 1321 | ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) |
1309 | { | 1322 | { |
1310 | struct net_device *dev = rx->dev; | 1323 | struct net_device *dev = rx->sdata->dev; |
1311 | struct ieee80211_local *local = rx->local; | 1324 | struct ieee80211_local *local = rx->local; |
1312 | u16 ethertype; | 1325 | u16 ethertype; |
1313 | u8 *payload; | 1326 | u8 *payload; |
@@ -1432,12 +1445,11 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1432 | unsigned int hdrlen; | 1445 | unsigned int hdrlen; |
1433 | struct sk_buff *skb = rx->skb, *fwd_skb; | 1446 | struct sk_buff *skb = rx->skb, *fwd_skb; |
1434 | struct ieee80211_local *local = rx->local; | 1447 | struct ieee80211_local *local = rx->local; |
1435 | struct ieee80211_sub_if_data *sdata; | 1448 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1436 | 1449 | ||
1437 | hdr = (struct ieee80211_hdr *) skb->data; | 1450 | hdr = (struct ieee80211_hdr *) skb->data; |
1438 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 1451 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
1439 | mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); | 1452 | mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); |
1440 | sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | ||
1441 | 1453 | ||
1442 | if (!ieee80211_is_data(hdr->frame_control)) | 1454 | if (!ieee80211_is_data(hdr->frame_control)) |
1443 | return RX_CONTINUE; | 1455 | return RX_CONTINUE; |
@@ -1475,7 +1487,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1475 | 1487 | ||
1476 | /* Frame has reached destination. Don't forward */ | 1488 | /* Frame has reached destination. Don't forward */ |
1477 | if (!is_multicast_ether_addr(hdr->addr1) && | 1489 | if (!is_multicast_ether_addr(hdr->addr1) && |
1478 | compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0) | 1490 | compare_ether_addr(sdata->dev->dev_addr, hdr->addr3) == 0) |
1479 | return RX_CONTINUE; | 1491 | return RX_CONTINUE; |
1480 | 1492 | ||
1481 | mesh_hdr->ttl--; | 1493 | mesh_hdr->ttl--; |
@@ -1492,10 +1504,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1492 | 1504 | ||
1493 | if (!fwd_skb && net_ratelimit()) | 1505 | if (!fwd_skb && net_ratelimit()) |
1494 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", | 1506 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", |
1495 | rx->dev->name); | 1507 | sdata->dev->name); |
1496 | 1508 | ||
1497 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; | 1509 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; |
1498 | memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN); | 1510 | memcpy(fwd_hdr->addr2, sdata->dev->dev_addr, ETH_ALEN); |
1499 | info = IEEE80211_SKB_CB(fwd_skb); | 1511 | info = IEEE80211_SKB_CB(fwd_skb); |
1500 | memset(info, 0, sizeof(*info)); | 1512 | memset(info, 0, sizeof(*info)); |
1501 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 1513 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
@@ -1529,7 +1541,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1529 | } | 1541 | } |
1530 | 1542 | ||
1531 | if (is_multicast_ether_addr(hdr->addr1) || | 1543 | if (is_multicast_ether_addr(hdr->addr1) || |
1532 | rx->dev->flags & IFF_PROMISC) | 1544 | sdata->dev->flags & IFF_PROMISC) |
1533 | return RX_CONTINUE; | 1545 | return RX_CONTINUE; |
1534 | else | 1546 | else |
1535 | return RX_DROP_MONITOR; | 1547 | return RX_DROP_MONITOR; |
@@ -1539,9 +1551,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1539 | static ieee80211_rx_result debug_noinline | 1551 | static ieee80211_rx_result debug_noinline |
1540 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) | 1552 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) |
1541 | { | 1553 | { |
1542 | struct net_device *dev = rx->dev; | 1554 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1555 | struct net_device *dev = sdata->dev; | ||
1543 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 1556 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
1544 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1545 | __le16 fc = hdr->frame_control; | 1557 | __le16 fc = hdr->frame_control; |
1546 | int err; | 1558 | int err; |
1547 | 1559 | ||
@@ -1592,11 +1604,11 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx) | |||
1592 | 1604 | ||
1593 | if (ieee80211_is_back_req(bar->frame_control)) { | 1605 | if (ieee80211_is_back_req(bar->frame_control)) { |
1594 | if (!rx->sta) | 1606 | if (!rx->sta) |
1595 | return RX_CONTINUE; | 1607 | return RX_DROP_MONITOR; |
1596 | tid = le16_to_cpu(bar->control) >> 12; | 1608 | tid = le16_to_cpu(bar->control) >> 12; |
1597 | if (rx->sta->ampdu_mlme.tid_state_rx[tid] | 1609 | if (rx->sta->ampdu_mlme.tid_state_rx[tid] |
1598 | != HT_AGG_STATE_OPERATIONAL) | 1610 | != HT_AGG_STATE_OPERATIONAL) |
1599 | return RX_CONTINUE; | 1611 | return RX_DROP_MONITOR; |
1600 | tid_agg_rx = rx->sta->ampdu_mlme.tid_rx[tid]; | 1612 | tid_agg_rx = rx->sta->ampdu_mlme.tid_rx[tid]; |
1601 | 1613 | ||
1602 | start_seq_num = le16_to_cpu(bar->start_seq_num) >> 4; | 1614 | start_seq_num = le16_to_cpu(bar->start_seq_num) >> 4; |
@@ -1606,13 +1618,10 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx) | |||
1606 | mod_timer(&tid_agg_rx->session_timer, | 1618 | mod_timer(&tid_agg_rx->session_timer, |
1607 | TU_TO_EXP_TIME(tid_agg_rx->timeout)); | 1619 | TU_TO_EXP_TIME(tid_agg_rx->timeout)); |
1608 | 1620 | ||
1609 | /* manage reordering buffer according to requested */ | 1621 | /* release stored frames up to start of BAR */ |
1610 | /* sequence number */ | 1622 | ieee80211_release_reorder_frames(hw, tid_agg_rx, start_seq_num); |
1611 | rcu_read_lock(); | 1623 | kfree_skb(skb); |
1612 | ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL, | 1624 | return RX_QUEUED; |
1613 | start_seq_num, 1); | ||
1614 | rcu_read_unlock(); | ||
1615 | return RX_DROP_UNUSABLE; | ||
1616 | } | 1625 | } |
1617 | 1626 | ||
1618 | return RX_CONTINUE; | 1627 | return RX_CONTINUE; |
@@ -1661,14 +1670,14 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, | |||
1661 | mgmt->u.action.u.sa_query.trans_id, | 1670 | mgmt->u.action.u.sa_query.trans_id, |
1662 | WLAN_SA_QUERY_TR_ID_LEN); | 1671 | WLAN_SA_QUERY_TR_ID_LEN); |
1663 | 1672 | ||
1664 | ieee80211_tx_skb(sdata, skb, 1); | 1673 | ieee80211_tx_skb(sdata, skb); |
1665 | } | 1674 | } |
1666 | 1675 | ||
1667 | static ieee80211_rx_result debug_noinline | 1676 | static ieee80211_rx_result debug_noinline |
1668 | ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | 1677 | ieee80211_rx_h_action(struct ieee80211_rx_data *rx) |
1669 | { | 1678 | { |
1670 | struct ieee80211_local *local = rx->local; | 1679 | struct ieee80211_local *local = rx->local; |
1671 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | 1680 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1672 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | 1681 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; |
1673 | int len = rx->skb->len; | 1682 | int len = rx->skb->len; |
1674 | 1683 | ||
@@ -1780,7 +1789,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
1780 | static ieee80211_rx_result debug_noinline | 1789 | static ieee80211_rx_result debug_noinline |
1781 | ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | 1790 | ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) |
1782 | { | 1791 | { |
1783 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | 1792 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1784 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | 1793 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; |
1785 | 1794 | ||
1786 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | 1795 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) |
@@ -1818,11 +1827,11 @@ static void ieee80211_rx_michael_mic_report(struct ieee80211_hdr *hdr, | |||
1818 | * Some hardware seem to generate incorrect Michael MIC | 1827 | * Some hardware seem to generate incorrect Michael MIC |
1819 | * reports; ignore them to avoid triggering countermeasures. | 1828 | * reports; ignore them to avoid triggering countermeasures. |
1820 | */ | 1829 | */ |
1821 | goto ignore; | 1830 | return; |
1822 | } | 1831 | } |
1823 | 1832 | ||
1824 | if (!ieee80211_has_protected(hdr->frame_control)) | 1833 | if (!ieee80211_has_protected(hdr->frame_control)) |
1825 | goto ignore; | 1834 | return; |
1826 | 1835 | ||
1827 | if (rx->sdata->vif.type == NL80211_IFTYPE_AP && keyidx) { | 1836 | if (rx->sdata->vif.type == NL80211_IFTYPE_AP && keyidx) { |
1828 | /* | 1837 | /* |
@@ -1831,35 +1840,33 @@ static void ieee80211_rx_michael_mic_report(struct ieee80211_hdr *hdr, | |||
1831 | * group keys and only the AP is sending real multicast | 1840 | * group keys and only the AP is sending real multicast |
1832 | * frames in the BSS. | 1841 | * frames in the BSS. |
1833 | */ | 1842 | */ |
1834 | goto ignore; | 1843 | return; |
1835 | } | 1844 | } |
1836 | 1845 | ||
1837 | if (!ieee80211_is_data(hdr->frame_control) && | 1846 | if (!ieee80211_is_data(hdr->frame_control) && |
1838 | !ieee80211_is_auth(hdr->frame_control)) | 1847 | !ieee80211_is_auth(hdr->frame_control)) |
1839 | goto ignore; | 1848 | return; |
1840 | 1849 | ||
1841 | mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr, NULL, | 1850 | mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr, NULL, |
1842 | GFP_ATOMIC); | 1851 | GFP_ATOMIC); |
1843 | ignore: | ||
1844 | dev_kfree_skb(rx->skb); | ||
1845 | rx->skb = NULL; | ||
1846 | } | 1852 | } |
1847 | 1853 | ||
1848 | /* TODO: use IEEE80211_RX_FRAGMENTED */ | 1854 | /* TODO: use IEEE80211_RX_FRAGMENTED */ |
1849 | static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx) | 1855 | static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, |
1856 | struct ieee80211_rate *rate) | ||
1850 | { | 1857 | { |
1851 | struct ieee80211_sub_if_data *sdata; | 1858 | struct ieee80211_sub_if_data *sdata; |
1852 | struct ieee80211_local *local = rx->local; | 1859 | struct ieee80211_local *local = rx->local; |
1853 | struct ieee80211_rtap_hdr { | 1860 | struct ieee80211_rtap_hdr { |
1854 | struct ieee80211_radiotap_header hdr; | 1861 | struct ieee80211_radiotap_header hdr; |
1855 | u8 flags; | 1862 | u8 flags; |
1856 | u8 rate; | 1863 | u8 rate_or_pad; |
1857 | __le16 chan_freq; | 1864 | __le16 chan_freq; |
1858 | __le16 chan_flags; | 1865 | __le16 chan_flags; |
1859 | } __attribute__ ((packed)) *rthdr; | 1866 | } __attribute__ ((packed)) *rthdr; |
1860 | struct sk_buff *skb = rx->skb, *skb2; | 1867 | struct sk_buff *skb = rx->skb, *skb2; |
1861 | struct net_device *prev_dev = NULL; | 1868 | struct net_device *prev_dev = NULL; |
1862 | struct ieee80211_rx_status *status = rx->status; | 1869 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
1863 | 1870 | ||
1864 | if (rx->flags & IEEE80211_RX_CMNTR_REPORTED) | 1871 | if (rx->flags & IEEE80211_RX_CMNTR_REPORTED) |
1865 | goto out_free_skb; | 1872 | goto out_free_skb; |
@@ -1873,10 +1880,13 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx) | |||
1873 | rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr)); | 1880 | rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr)); |
1874 | rthdr->hdr.it_present = | 1881 | rthdr->hdr.it_present = |
1875 | cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | | 1882 | cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | |
1876 | (1 << IEEE80211_RADIOTAP_RATE) | | ||
1877 | (1 << IEEE80211_RADIOTAP_CHANNEL)); | 1883 | (1 << IEEE80211_RADIOTAP_CHANNEL)); |
1878 | 1884 | ||
1879 | rthdr->rate = rx->rate->bitrate / 5; | 1885 | if (rate) { |
1886 | rthdr->rate_or_pad = rate->bitrate / 5; | ||
1887 | rthdr->hdr.it_present |= | ||
1888 | cpu_to_le32(1 << IEEE80211_RADIOTAP_RATE); | ||
1889 | } | ||
1880 | rthdr->chan_freq = cpu_to_le16(status->freq); | 1890 | rthdr->chan_freq = cpu_to_le16(status->freq); |
1881 | 1891 | ||
1882 | if (status->band == IEEE80211_BAND_5GHZ) | 1892 | if (status->band == IEEE80211_BAND_5GHZ) |
@@ -1929,13 +1939,13 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx) | |||
1929 | 1939 | ||
1930 | static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | 1940 | static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, |
1931 | struct ieee80211_rx_data *rx, | 1941 | struct ieee80211_rx_data *rx, |
1932 | struct sk_buff *skb) | 1942 | struct sk_buff *skb, |
1943 | struct ieee80211_rate *rate) | ||
1933 | { | 1944 | { |
1934 | ieee80211_rx_result res = RX_DROP_MONITOR; | 1945 | ieee80211_rx_result res = RX_DROP_MONITOR; |
1935 | 1946 | ||
1936 | rx->skb = skb; | 1947 | rx->skb = skb; |
1937 | rx->sdata = sdata; | 1948 | rx->sdata = sdata; |
1938 | rx->dev = sdata->dev; | ||
1939 | 1949 | ||
1940 | #define CALL_RXH(rxh) \ | 1950 | #define CALL_RXH(rxh) \ |
1941 | do { \ | 1951 | do { \ |
@@ -1974,7 +1984,7 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | |||
1974 | rx->sta->rx_dropped++; | 1984 | rx->sta->rx_dropped++; |
1975 | /* fall through */ | 1985 | /* fall through */ |
1976 | case RX_CONTINUE: | 1986 | case RX_CONTINUE: |
1977 | ieee80211_rx_cooked_monitor(rx); | 1987 | ieee80211_rx_cooked_monitor(rx, rate); |
1978 | break; | 1988 | break; |
1979 | case RX_DROP_UNUSABLE: | 1989 | case RX_DROP_UNUSABLE: |
1980 | I802_DEBUG_INC(sdata->local->rx_handlers_drop); | 1990 | I802_DEBUG_INC(sdata->local->rx_handlers_drop); |
@@ -1994,12 +2004,14 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1994 | struct ieee80211_rx_data *rx, | 2004 | struct ieee80211_rx_data *rx, |
1995 | struct ieee80211_hdr *hdr) | 2005 | struct ieee80211_hdr *hdr) |
1996 | { | 2006 | { |
1997 | u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, sdata->vif.type); | 2007 | struct sk_buff *skb = rx->skb; |
2008 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | ||
2009 | u8 *bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type); | ||
1998 | int multicast = is_multicast_ether_addr(hdr->addr1); | 2010 | int multicast = is_multicast_ether_addr(hdr->addr1); |
1999 | 2011 | ||
2000 | switch (sdata->vif.type) { | 2012 | switch (sdata->vif.type) { |
2001 | case NL80211_IFTYPE_STATION: | 2013 | case NL80211_IFTYPE_STATION: |
2002 | if (!bssid && !sdata->use_4addr) | 2014 | if (!bssid && !sdata->u.mgd.use_4addr) |
2003 | return 0; | 2015 | return 0; |
2004 | if (!multicast && | 2016 | if (!multicast && |
2005 | compare_ether_addr(sdata->dev->dev_addr, hdr->addr1) != 0) { | 2017 | compare_ether_addr(sdata->dev->dev_addr, hdr->addr1) != 0) { |
@@ -2026,10 +2038,10 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2026 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 2038 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
2027 | } else if (!rx->sta) { | 2039 | } else if (!rx->sta) { |
2028 | int rate_idx; | 2040 | int rate_idx; |
2029 | if (rx->status->flag & RX_FLAG_HT) | 2041 | if (status->flag & RX_FLAG_HT) |
2030 | rate_idx = 0; /* TODO: HT rates */ | 2042 | rate_idx = 0; /* TODO: HT rates */ |
2031 | else | 2043 | else |
2032 | rate_idx = rx->status->rate_idx; | 2044 | rate_idx = status->rate_idx; |
2033 | rx->sta = ieee80211_ibss_add_sta(sdata, bssid, hdr->addr2, | 2045 | rx->sta = ieee80211_ibss_add_sta(sdata, bssid, hdr->addr2, |
2034 | BIT(rate_idx)); | 2046 | BIT(rate_idx)); |
2035 | } | 2047 | } |
@@ -2064,8 +2076,6 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2064 | return 0; | 2076 | return 0; |
2065 | break; | 2077 | break; |
2066 | case NL80211_IFTYPE_MONITOR: | 2078 | case NL80211_IFTYPE_MONITOR: |
2067 | /* take everything */ | ||
2068 | break; | ||
2069 | case NL80211_IFTYPE_UNSPECIFIED: | 2079 | case NL80211_IFTYPE_UNSPECIFIED: |
2070 | case __NL80211_IFTYPE_AFTER_LAST: | 2080 | case __NL80211_IFTYPE_AFTER_LAST: |
2071 | /* should never get here */ | 2081 | /* should never get here */ |
@@ -2098,23 +2108,9 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2098 | rx.skb = skb; | 2108 | rx.skb = skb; |
2099 | rx.local = local; | 2109 | rx.local = local; |
2100 | 2110 | ||
2101 | rx.status = status; | ||
2102 | rx.rate = rate; | ||
2103 | |||
2104 | if (ieee80211_is_data(hdr->frame_control) || ieee80211_is_mgmt(hdr->frame_control)) | 2111 | if (ieee80211_is_data(hdr->frame_control) || ieee80211_is_mgmt(hdr->frame_control)) |
2105 | local->dot11ReceivedFragmentCount++; | 2112 | local->dot11ReceivedFragmentCount++; |
2106 | 2113 | ||
2107 | rx.sta = sta_info_get(local, hdr->addr2); | ||
2108 | if (rx.sta) { | ||
2109 | rx.sdata = rx.sta->sdata; | ||
2110 | rx.dev = rx.sta->sdata->dev; | ||
2111 | } | ||
2112 | |||
2113 | if ((status->flag & RX_FLAG_MMIC_ERROR)) { | ||
2114 | ieee80211_rx_michael_mic_report(hdr, &rx); | ||
2115 | return; | ||
2116 | } | ||
2117 | |||
2118 | if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning) || | 2114 | if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning) || |
2119 | test_bit(SCAN_OFF_CHANNEL, &local->scanning))) | 2115 | test_bit(SCAN_OFF_CHANNEL, &local->scanning))) |
2120 | rx.flags |= IEEE80211_RX_IN_SCAN; | 2116 | rx.flags |= IEEE80211_RX_IN_SCAN; |
@@ -2122,13 +2118,20 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2122 | ieee80211_parse_qos(&rx); | 2118 | ieee80211_parse_qos(&rx); |
2123 | ieee80211_verify_alignment(&rx); | 2119 | ieee80211_verify_alignment(&rx); |
2124 | 2120 | ||
2125 | skb = rx.skb; | 2121 | rx.sta = sta_info_get(local, hdr->addr2); |
2122 | if (rx.sta) | ||
2123 | rx.sdata = rx.sta->sdata; | ||
2126 | 2124 | ||
2127 | if (rx.sdata && ieee80211_is_data(hdr->frame_control)) { | 2125 | if (rx.sdata && ieee80211_is_data(hdr->frame_control)) { |
2128 | rx.flags |= IEEE80211_RX_RA_MATCH; | 2126 | rx.flags |= IEEE80211_RX_RA_MATCH; |
2129 | prepares = prepare_for_handlers(rx.sdata, &rx, hdr); | 2127 | prepares = prepare_for_handlers(rx.sdata, &rx, hdr); |
2130 | if (prepares) | 2128 | if (prepares) { |
2131 | prev = rx.sdata; | 2129 | if (status->flag & RX_FLAG_MMIC_ERROR) { |
2130 | if (rx.flags & IEEE80211_RX_RA_MATCH) | ||
2131 | ieee80211_rx_michael_mic_report(hdr, &rx); | ||
2132 | } else | ||
2133 | prev = rx.sdata; | ||
2134 | } | ||
2132 | } else list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 2135 | } else list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
2133 | if (!netif_running(sdata->dev)) | 2136 | if (!netif_running(sdata->dev)) |
2134 | continue; | 2137 | continue; |
@@ -2143,6 +2146,13 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2143 | if (!prepares) | 2146 | if (!prepares) |
2144 | continue; | 2147 | continue; |
2145 | 2148 | ||
2149 | if (status->flag & RX_FLAG_MMIC_ERROR) { | ||
2150 | rx.sdata = sdata; | ||
2151 | if (rx.flags & IEEE80211_RX_RA_MATCH) | ||
2152 | ieee80211_rx_michael_mic_report(hdr, &rx); | ||
2153 | continue; | ||
2154 | } | ||
2155 | |||
2146 | /* | 2156 | /* |
2147 | * frame is destined for this interface, but if it's not | 2157 | * frame is destined for this interface, but if it's not |
2148 | * also for the previous one we handle that after the | 2158 | * also for the previous one we handle that after the |
@@ -2168,11 +2178,11 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2168 | prev->dev->name); | 2178 | prev->dev->name); |
2169 | continue; | 2179 | continue; |
2170 | } | 2180 | } |
2171 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new); | 2181 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate); |
2172 | prev = sdata; | 2182 | prev = sdata; |
2173 | } | 2183 | } |
2174 | if (prev) | 2184 | if (prev) |
2175 | ieee80211_invoke_rx_handlers(prev, &rx, skb); | 2185 | ieee80211_invoke_rx_handlers(prev, &rx, skb, rate); |
2176 | else | 2186 | else |
2177 | dev_kfree_skb(skb); | 2187 | dev_kfree_skb(skb); |
2178 | } | 2188 | } |
@@ -2201,7 +2211,7 @@ static void ieee80211_release_reorder_frame(struct ieee80211_hw *hw, | |||
2201 | int index) | 2211 | int index) |
2202 | { | 2212 | { |
2203 | struct ieee80211_supported_band *sband; | 2213 | struct ieee80211_supported_band *sband; |
2204 | struct ieee80211_rate *rate; | 2214 | struct ieee80211_rate *rate = NULL; |
2205 | struct sk_buff *skb = tid_agg_rx->reorder_buf[index]; | 2215 | struct sk_buff *skb = tid_agg_rx->reorder_buf[index]; |
2206 | struct ieee80211_rx_status *status; | 2216 | struct ieee80211_rx_status *status; |
2207 | 2217 | ||
@@ -2212,9 +2222,7 @@ static void ieee80211_release_reorder_frame(struct ieee80211_hw *hw, | |||
2212 | 2222 | ||
2213 | /* release the reordered frames to stack */ | 2223 | /* release the reordered frames to stack */ |
2214 | sband = hw->wiphy->bands[status->band]; | 2224 | sband = hw->wiphy->bands[status->band]; |
2215 | if (status->flag & RX_FLAG_HT) | 2225 | if (!(status->flag & RX_FLAG_HT)) |
2216 | rate = sband->bitrates; /* TODO: HT rates */ | ||
2217 | else | ||
2218 | rate = &sband->bitrates[status->rate_idx]; | 2226 | rate = &sband->bitrates[status->rate_idx]; |
2219 | __ieee80211_rx_handle_packet(hw, skb, rate); | 2227 | __ieee80211_rx_handle_packet(hw, skb, rate); |
2220 | tid_agg_rx->stored_mpdu_num--; | 2228 | tid_agg_rx->stored_mpdu_num--; |
@@ -2224,6 +2232,18 @@ no_frame: | |||
2224 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); | 2232 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); |
2225 | } | 2233 | } |
2226 | 2234 | ||
2235 | static void ieee80211_release_reorder_frames(struct ieee80211_hw *hw, | ||
2236 | struct tid_ampdu_rx *tid_agg_rx, | ||
2237 | u16 head_seq_num) | ||
2238 | { | ||
2239 | int index; | ||
2240 | |||
2241 | while (seq_less(tid_agg_rx->head_seq_num, head_seq_num)) { | ||
2242 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % | ||
2243 | tid_agg_rx->buf_size; | ||
2244 | ieee80211_release_reorder_frame(hw, tid_agg_rx, index); | ||
2245 | } | ||
2246 | } | ||
2227 | 2247 | ||
2228 | /* | 2248 | /* |
2229 | * Timeout (in jiffies) for skb's that are waiting in the RX reorder buffer. If | 2249 | * Timeout (in jiffies) for skb's that are waiting in the RX reorder buffer. If |
@@ -2235,15 +2255,17 @@ no_frame: | |||
2235 | #define HT_RX_REORDER_BUF_TIMEOUT (HZ / 10) | 2255 | #define HT_RX_REORDER_BUF_TIMEOUT (HZ / 10) |
2236 | 2256 | ||
2237 | /* | 2257 | /* |
2238 | * As it function blongs to Rx path it must be called with | 2258 | * As this function belongs to the RX path it must be under |
2239 | * the proper rcu_read_lock protection for its flow. | 2259 | * rcu_read_lock protection. It returns false if the frame |
2260 | * can be processed immediately, true if it was consumed. | ||
2240 | */ | 2261 | */ |
2241 | static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | 2262 | static bool ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, |
2242 | struct tid_ampdu_rx *tid_agg_rx, | 2263 | struct tid_ampdu_rx *tid_agg_rx, |
2243 | struct sk_buff *skb, | 2264 | struct sk_buff *skb) |
2244 | u16 mpdu_seq_num, | ||
2245 | int bar_req) | ||
2246 | { | 2265 | { |
2266 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
2267 | u16 sc = le16_to_cpu(hdr->seq_ctrl); | ||
2268 | u16 mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4; | ||
2247 | u16 head_seq_num, buf_size; | 2269 | u16 head_seq_num, buf_size; |
2248 | int index; | 2270 | int index; |
2249 | 2271 | ||
@@ -2253,47 +2275,37 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2253 | /* frame with out of date sequence number */ | 2275 | /* frame with out of date sequence number */ |
2254 | if (seq_less(mpdu_seq_num, head_seq_num)) { | 2276 | if (seq_less(mpdu_seq_num, head_seq_num)) { |
2255 | dev_kfree_skb(skb); | 2277 | dev_kfree_skb(skb); |
2256 | return 1; | 2278 | return true; |
2257 | } | 2279 | } |
2258 | 2280 | ||
2259 | /* if frame sequence number exceeds our buffering window size or | 2281 | /* |
2260 | * block Ack Request arrived - release stored frames */ | 2282 | * If frame the sequence number exceeds our buffering window |
2261 | if ((!seq_less(mpdu_seq_num, head_seq_num + buf_size)) || (bar_req)) { | 2283 | * size release some previous frames to make room for this one. |
2262 | /* new head to the ordering buffer */ | 2284 | */ |
2263 | if (bar_req) | 2285 | if (!seq_less(mpdu_seq_num, head_seq_num + buf_size)) { |
2264 | head_seq_num = mpdu_seq_num; | 2286 | head_seq_num = seq_inc(seq_sub(mpdu_seq_num, buf_size)); |
2265 | else | ||
2266 | head_seq_num = | ||
2267 | seq_inc(seq_sub(mpdu_seq_num, buf_size)); | ||
2268 | /* release stored frames up to new head to stack */ | 2287 | /* release stored frames up to new head to stack */ |
2269 | while (seq_less(tid_agg_rx->head_seq_num, head_seq_num)) { | 2288 | ieee80211_release_reorder_frames(hw, tid_agg_rx, head_seq_num); |
2270 | index = seq_sub(tid_agg_rx->head_seq_num, | ||
2271 | tid_agg_rx->ssn) | ||
2272 | % tid_agg_rx->buf_size; | ||
2273 | ieee80211_release_reorder_frame(hw, tid_agg_rx, | ||
2274 | index); | ||
2275 | } | ||
2276 | if (bar_req) | ||
2277 | return 1; | ||
2278 | } | 2289 | } |
2279 | 2290 | ||
2280 | /* now the new frame is always in the range of the reordering */ | 2291 | /* Now the new frame is always in the range of the reordering buffer */ |
2281 | /* buffer window */ | 2292 | |
2282 | index = seq_sub(mpdu_seq_num, tid_agg_rx->ssn) | 2293 | index = seq_sub(mpdu_seq_num, tid_agg_rx->ssn) % tid_agg_rx->buf_size; |
2283 | % tid_agg_rx->buf_size; | 2294 | |
2284 | /* check if we already stored this frame */ | 2295 | /* check if we already stored this frame */ |
2285 | if (tid_agg_rx->reorder_buf[index]) { | 2296 | if (tid_agg_rx->reorder_buf[index]) { |
2286 | dev_kfree_skb(skb); | 2297 | dev_kfree_skb(skb); |
2287 | return 1; | 2298 | return true; |
2288 | } | 2299 | } |
2289 | 2300 | ||
2290 | /* if arrived mpdu is in the right order and nothing else stored */ | 2301 | /* |
2291 | /* release it immediately */ | 2302 | * If the current MPDU is in the right order and nothing else |
2303 | * is stored we can process it directly, no need to buffer it. | ||
2304 | */ | ||
2292 | if (mpdu_seq_num == tid_agg_rx->head_seq_num && | 2305 | if (mpdu_seq_num == tid_agg_rx->head_seq_num && |
2293 | tid_agg_rx->stored_mpdu_num == 0) { | 2306 | tid_agg_rx->stored_mpdu_num == 0) { |
2294 | tid_agg_rx->head_seq_num = | 2307 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); |
2295 | seq_inc(tid_agg_rx->head_seq_num); | 2308 | return false; |
2296 | return 0; | ||
2297 | } | 2309 | } |
2298 | 2310 | ||
2299 | /* put the frame in the reordering buffer */ | 2311 | /* put the frame in the reordering buffer */ |
@@ -2301,8 +2313,8 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2301 | tid_agg_rx->reorder_time[index] = jiffies; | 2313 | tid_agg_rx->reorder_time[index] = jiffies; |
2302 | tid_agg_rx->stored_mpdu_num++; | 2314 | tid_agg_rx->stored_mpdu_num++; |
2303 | /* release the buffer until next missing frame */ | 2315 | /* release the buffer until next missing frame */ |
2304 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) | 2316 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % |
2305 | % tid_agg_rx->buf_size; | 2317 | tid_agg_rx->buf_size; |
2306 | if (!tid_agg_rx->reorder_buf[index] && | 2318 | if (!tid_agg_rx->reorder_buf[index] && |
2307 | tid_agg_rx->stored_mpdu_num > 1) { | 2319 | tid_agg_rx->stored_mpdu_num > 1) { |
2308 | /* | 2320 | /* |
@@ -2313,12 +2325,12 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2313 | int skipped = 1; | 2325 | int skipped = 1; |
2314 | for (j = (index + 1) % tid_agg_rx->buf_size; j != index; | 2326 | for (j = (index + 1) % tid_agg_rx->buf_size; j != index; |
2315 | j = (j + 1) % tid_agg_rx->buf_size) { | 2327 | j = (j + 1) % tid_agg_rx->buf_size) { |
2316 | if (tid_agg_rx->reorder_buf[j] == NULL) { | 2328 | if (!tid_agg_rx->reorder_buf[j]) { |
2317 | skipped++; | 2329 | skipped++; |
2318 | continue; | 2330 | continue; |
2319 | } | 2331 | } |
2320 | if (!time_after(jiffies, tid_agg_rx->reorder_time[j] + | 2332 | if (!time_after(jiffies, tid_agg_rx->reorder_time[j] + |
2321 | HZ / 10)) | 2333 | HT_RX_REORDER_BUF_TIMEOUT)) |
2322 | break; | 2334 | break; |
2323 | 2335 | ||
2324 | #ifdef CONFIG_MAC80211_HT_DEBUG | 2336 | #ifdef CONFIG_MAC80211_HT_DEBUG |
@@ -2334,51 +2346,56 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2334 | * Increment the head seq# also for the skipped slots. | 2346 | * Increment the head seq# also for the skipped slots. |
2335 | */ | 2347 | */ |
2336 | tid_agg_rx->head_seq_num = | 2348 | tid_agg_rx->head_seq_num = |
2337 | (tid_agg_rx->head_seq_num + skipped) & | 2349 | (tid_agg_rx->head_seq_num + skipped) & SEQ_MASK; |
2338 | SEQ_MASK; | ||
2339 | skipped = 0; | 2350 | skipped = 0; |
2340 | } | 2351 | } |
2341 | } else while (tid_agg_rx->reorder_buf[index]) { | 2352 | } else while (tid_agg_rx->reorder_buf[index]) { |
2342 | ieee80211_release_reorder_frame(hw, tid_agg_rx, index); | 2353 | ieee80211_release_reorder_frame(hw, tid_agg_rx, index); |
2343 | index = seq_sub(tid_agg_rx->head_seq_num, | 2354 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % |
2344 | tid_agg_rx->ssn) % tid_agg_rx->buf_size; | 2355 | tid_agg_rx->buf_size; |
2345 | } | 2356 | } |
2346 | return 1; | 2357 | |
2358 | return true; | ||
2347 | } | 2359 | } |
2348 | 2360 | ||
2349 | static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, | 2361 | /* |
2350 | struct sk_buff *skb) | 2362 | * Reorder MPDUs from A-MPDUs, keeping them on a buffer. Returns |
2363 | * true if the MPDU was buffered, false if it should be processed. | ||
2364 | */ | ||
2365 | static bool ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, | ||
2366 | struct sk_buff *skb) | ||
2351 | { | 2367 | { |
2352 | struct ieee80211_hw *hw = &local->hw; | 2368 | struct ieee80211_hw *hw = &local->hw; |
2353 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 2369 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
2354 | struct sta_info *sta; | 2370 | struct sta_info *sta; |
2355 | struct tid_ampdu_rx *tid_agg_rx; | 2371 | struct tid_ampdu_rx *tid_agg_rx; |
2356 | u16 sc; | 2372 | u16 sc; |
2357 | u16 mpdu_seq_num; | ||
2358 | u8 ret = 0; | ||
2359 | int tid; | 2373 | int tid; |
2360 | 2374 | ||
2375 | if (!ieee80211_is_data_qos(hdr->frame_control)) | ||
2376 | return false; | ||
2377 | |||
2378 | /* | ||
2379 | * filter the QoS data rx stream according to | ||
2380 | * STA/TID and check if this STA/TID is on aggregation | ||
2381 | */ | ||
2382 | |||
2361 | sta = sta_info_get(local, hdr->addr2); | 2383 | sta = sta_info_get(local, hdr->addr2); |
2362 | if (!sta) | 2384 | if (!sta) |
2363 | return ret; | 2385 | return false; |
2364 | |||
2365 | /* filter the QoS data rx stream according to | ||
2366 | * STA/TID and check if this STA/TID is on aggregation */ | ||
2367 | if (!ieee80211_is_data_qos(hdr->frame_control)) | ||
2368 | goto end_reorder; | ||
2369 | 2386 | ||
2370 | tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK; | 2387 | tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK; |
2371 | 2388 | ||
2372 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_OPERATIONAL) | 2389 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_OPERATIONAL) |
2373 | goto end_reorder; | 2390 | return false; |
2374 | 2391 | ||
2375 | tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; | 2392 | tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; |
2376 | 2393 | ||
2377 | /* qos null data frames are excluded */ | 2394 | /* qos null data frames are excluded */ |
2378 | if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC))) | 2395 | if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC))) |
2379 | goto end_reorder; | 2396 | return false; |
2380 | 2397 | ||
2381 | /* new un-ordered ampdu frame - process it */ | 2398 | /* new, potentially un-ordered, ampdu frame - process it */ |
2382 | 2399 | ||
2383 | /* reset session timer */ | 2400 | /* reset session timer */ |
2384 | if (tid_agg_rx->timeout) | 2401 | if (tid_agg_rx->timeout) |
@@ -2390,16 +2407,11 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, | |||
2390 | if (sc & IEEE80211_SCTL_FRAG) { | 2407 | if (sc & IEEE80211_SCTL_FRAG) { |
2391 | ieee80211_sta_stop_rx_ba_session(sta->sdata, sta->sta.addr, | 2408 | ieee80211_sta_stop_rx_ba_session(sta->sdata, sta->sta.addr, |
2392 | tid, 0, WLAN_REASON_QSTA_REQUIRE_SETUP); | 2409 | tid, 0, WLAN_REASON_QSTA_REQUIRE_SETUP); |
2393 | ret = 1; | 2410 | dev_kfree_skb(skb); |
2394 | goto end_reorder; | 2411 | return true; |
2395 | } | 2412 | } |
2396 | 2413 | ||
2397 | /* according to mpdu sequence number deal with reordering buffer */ | 2414 | return ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb); |
2398 | mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4; | ||
2399 | ret = ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb, | ||
2400 | mpdu_seq_num, 0); | ||
2401 | end_reorder: | ||
2402 | return ret; | ||
2403 | } | 2415 | } |
2404 | 2416 | ||
2405 | /* | 2417 | /* |
@@ -2457,10 +2469,6 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
2457 | status->rate_idx, | 2469 | status->rate_idx, |
2458 | status->rate_idx)) | 2470 | status->rate_idx)) |
2459 | goto drop; | 2471 | goto drop; |
2460 | /* HT rates are not in the table - use the highest legacy rate | ||
2461 | * for now since other parts of mac80211 may not yet be fully | ||
2462 | * MCS aware. */ | ||
2463 | rate = &sband->bitrates[sband->n_bitrates - 1]; | ||
2464 | } else { | 2472 | } else { |
2465 | if (WARN_ON(status->rate_idx < 0 || | 2473 | if (WARN_ON(status->rate_idx < 0 || |
2466 | status->rate_idx >= sband->n_bitrates)) | 2474 | status->rate_idx >= sband->n_bitrates)) |