aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r--net/mac80211/rx.c137
1 files changed, 96 insertions, 41 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index a6701ed87f0d..c5d4530d8284 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -77,7 +77,7 @@ ieee80211_rx_radiotap_len(struct ieee80211_local *local,
77 /* always present fields */ 77 /* always present fields */
78 len = sizeof(struct ieee80211_radiotap_header) + 9; 78 len = sizeof(struct ieee80211_radiotap_header) + 9;
79 79
80 if (status->flag & RX_FLAG_TSFT) 80 if (status->flag & RX_FLAG_MACTIME_MPDU)
81 len += 8; 81 len += 8;
82 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) 82 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
83 len += 1; 83 len += 1;
@@ -85,6 +85,9 @@ ieee80211_rx_radiotap_len(struct ieee80211_local *local,
85 if (len & 1) /* padding for RX_FLAGS if necessary */ 85 if (len & 1) /* padding for RX_FLAGS if necessary */
86 len++; 86 len++;
87 87
88 if (status->flag & RX_FLAG_HT) /* HT info */
89 len += 3;
90
88 return len; 91 return len;
89} 92}
90 93
@@ -120,7 +123,7 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
120 /* the order of the following fields is important */ 123 /* the order of the following fields is important */
121 124
122 /* IEEE80211_RADIOTAP_TSFT */ 125 /* IEEE80211_RADIOTAP_TSFT */
123 if (status->flag & RX_FLAG_TSFT) { 126 if (status->flag & RX_FLAG_MACTIME_MPDU) {
124 put_unaligned_le64(status->mactime, pos); 127 put_unaligned_le64(status->mactime, pos);
125 rthdr->it_present |= 128 rthdr->it_present |=
126 cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT); 129 cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT);
@@ -139,11 +142,8 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
139 /* IEEE80211_RADIOTAP_RATE */ 142 /* IEEE80211_RADIOTAP_RATE */
140 if (status->flag & RX_FLAG_HT) { 143 if (status->flag & RX_FLAG_HT) {
141 /* 144 /*
142 * TODO: add following information into radiotap header once 145 * MCS information is a separate field in radiotap,
143 * suitable fields are defined for it: 146 * added below.
144 * - MCS index (status->rate_idx)
145 * - HT40 (status->flag & RX_FLAG_40MHZ)
146 * - short-GI (status->flag & RX_FLAG_SHORT_GI)
147 */ 147 */
148 *pos = 0; 148 *pos = 0;
149 } else { 149 } else {
@@ -193,6 +193,20 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
193 rx_flags |= IEEE80211_RADIOTAP_F_RX_BADPLCP; 193 rx_flags |= IEEE80211_RADIOTAP_F_RX_BADPLCP;
194 put_unaligned_le16(rx_flags, pos); 194 put_unaligned_le16(rx_flags, pos);
195 pos += 2; 195 pos += 2;
196
197 if (status->flag & RX_FLAG_HT) {
198 rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_MCS);
199 *pos++ = IEEE80211_RADIOTAP_MCS_HAVE_MCS |
200 IEEE80211_RADIOTAP_MCS_HAVE_GI |
201 IEEE80211_RADIOTAP_MCS_HAVE_BW;
202 *pos = 0;
203 if (status->flag & RX_FLAG_SHORT_GI)
204 *pos |= IEEE80211_RADIOTAP_MCS_SGI;
205 if (status->flag & RX_FLAG_40MHZ)
206 *pos |= IEEE80211_RADIOTAP_MCS_BW_40;
207 pos++;
208 *pos++ = status->rate_idx;
209 }
196} 210}
197 211
198/* 212/*
@@ -367,7 +381,7 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx)
367 * specs were sane enough this time around to require padding each A-MSDU 381 * specs were sane enough this time around to require padding each A-MSDU
368 * subframe to a length that is a multiple of four. 382 * subframe to a length that is a multiple of four.
369 * 383 *
370 * Padding like Atheros hardware adds which is inbetween the 802.11 header and 384 * Padding like Atheros hardware adds which is between the 802.11 header and
371 * the payload is not supported, the driver is required to move the 802.11 385 * the payload is not supported, the driver is required to move the 802.11
372 * header to be directly in front of the payload in that case. 386 * header to be directly in front of the payload in that case.
373 */ 387 */
@@ -392,16 +406,10 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
392 if (likely(!(status->rx_flags & IEEE80211_RX_IN_SCAN))) 406 if (likely(!(status->rx_flags & IEEE80211_RX_IN_SCAN)))
393 return RX_CONTINUE; 407 return RX_CONTINUE;
394 408
395 if (test_bit(SCAN_HW_SCANNING, &local->scanning)) 409 if (test_bit(SCAN_HW_SCANNING, &local->scanning) ||
410 test_bit(SCAN_SW_SCANNING, &local->scanning))
396 return ieee80211_scan_rx(rx->sdata, skb); 411 return ieee80211_scan_rx(rx->sdata, skb);
397 412
398 if (test_bit(SCAN_SW_SCANNING, &local->scanning)) {
399 /* drop all the other packets during a software scan anyway */
400 if (ieee80211_scan_rx(rx->sdata, skb) != RX_QUEUED)
401 dev_kfree_skb(skb);
402 return RX_QUEUED;
403 }
404
405 /* scanning finished during invoking of handlers */ 413 /* scanning finished during invoking of handlers */
406 I802_DEBUG_INC(local->rx_handlers_drop_passive_scan); 414 I802_DEBUG_INC(local->rx_handlers_drop_passive_scan);
407 return RX_DROP_UNUSABLE; 415 return RX_DROP_UNUSABLE;
@@ -604,7 +612,8 @@ static void ieee80211_sta_reorder_release(struct ieee80211_hw *hw,
604 skipped++; 612 skipped++;
605 continue; 613 continue;
606 } 614 }
607 if (!time_after(jiffies, tid_agg_rx->reorder_time[j] + 615 if (skipped &&
616 !time_after(jiffies, tid_agg_rx->reorder_time[j] +
608 HT_RX_REORDER_BUF_TIMEOUT)) 617 HT_RX_REORDER_BUF_TIMEOUT))
609 goto set_release_timer; 618 goto set_release_timer;
610 619
@@ -798,7 +807,7 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
798 rx->local->dot11FrameDuplicateCount++; 807 rx->local->dot11FrameDuplicateCount++;
799 rx->sta->num_duplicates++; 808 rx->sta->num_duplicates++;
800 } 809 }
801 return RX_DROP_MONITOR; 810 return RX_DROP_UNUSABLE;
802 } else 811 } else
803 rx->sta->last_seq_ctrl[rx->queue] = hdr->seq_ctrl; 812 rx->sta->last_seq_ctrl[rx->queue] = hdr->seq_ctrl;
804 } 813 }
@@ -824,18 +833,8 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
824 ieee80211_is_pspoll(hdr->frame_control)) && 833 ieee80211_is_pspoll(hdr->frame_control)) &&
825 rx->sdata->vif.type != NL80211_IFTYPE_ADHOC && 834 rx->sdata->vif.type != NL80211_IFTYPE_ADHOC &&
826 rx->sdata->vif.type != NL80211_IFTYPE_WDS && 835 rx->sdata->vif.type != NL80211_IFTYPE_WDS &&
827 (!rx->sta || !test_sta_flags(rx->sta, WLAN_STA_ASSOC)))) { 836 (!rx->sta || !test_sta_flags(rx->sta, WLAN_STA_ASSOC))))
828 if ((!ieee80211_has_fromds(hdr->frame_control) &&
829 !ieee80211_has_tods(hdr->frame_control) &&
830 ieee80211_is_data(hdr->frame_control)) ||
831 !(status->rx_flags & IEEE80211_RX_RA_MATCH)) {
832 /* Drop IBSS frames and frames for other hosts
833 * silently. */
834 return RX_DROP_MONITOR;
835 }
836
837 return RX_DROP_MONITOR; 837 return RX_DROP_MONITOR;
838 }
839 838
840 return RX_CONTINUE; 839 return RX_CONTINUE;
841} 840}
@@ -1088,7 +1087,8 @@ static void ap_sta_ps_start(struct sta_info *sta)
1088 1087
1089 atomic_inc(&sdata->bss->num_sta_ps); 1088 atomic_inc(&sdata->bss->num_sta_ps);
1090 set_sta_flags(sta, WLAN_STA_PS_STA); 1089 set_sta_flags(sta, WLAN_STA_PS_STA);
1091 drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta); 1090 if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS))
1091 drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta);
1092#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1092#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1093 printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", 1093 printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n",
1094 sdata->name, sta->sta.addr, sta->sta.aid); 1094 sdata->name, sta->sta.addr, sta->sta.aid);
@@ -1117,6 +1117,27 @@ static void ap_sta_ps_end(struct sta_info *sta)
1117 ieee80211_sta_ps_deliver_wakeup(sta); 1117 ieee80211_sta_ps_deliver_wakeup(sta);
1118} 1118}
1119 1119
1120int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start)
1121{
1122 struct sta_info *sta_inf = container_of(sta, struct sta_info, sta);
1123 bool in_ps;
1124
1125 WARN_ON(!(sta_inf->local->hw.flags & IEEE80211_HW_AP_LINK_PS));
1126
1127 /* Don't let the same PS state be set twice */
1128 in_ps = test_sta_flags(sta_inf, WLAN_STA_PS_STA);
1129 if ((start && in_ps) || (!start && !in_ps))
1130 return -EINVAL;
1131
1132 if (start)
1133 ap_sta_ps_start(sta_inf);
1134 else
1135 ap_sta_ps_end(sta_inf);
1136
1137 return 0;
1138}
1139EXPORT_SYMBOL(ieee80211_sta_ps_transition);
1140
1120static ieee80211_rx_result debug_noinline 1141static ieee80211_rx_result debug_noinline
1121ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) 1142ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1122{ 1143{
@@ -1136,14 +1157,23 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1136 if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { 1157 if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) {
1137 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, 1158 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len,
1138 NL80211_IFTYPE_ADHOC); 1159 NL80211_IFTYPE_ADHOC);
1139 if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) 1160 if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) {
1140 sta->last_rx = jiffies; 1161 sta->last_rx = jiffies;
1162 if (ieee80211_is_data(hdr->frame_control)) {
1163 sta->last_rx_rate_idx = status->rate_idx;
1164 sta->last_rx_rate_flag = status->flag;
1165 }
1166 }
1141 } else if (!is_multicast_ether_addr(hdr->addr1)) { 1167 } else if (!is_multicast_ether_addr(hdr->addr1)) {
1142 /* 1168 /*
1143 * Mesh beacons will update last_rx when if they are found to 1169 * Mesh beacons will update last_rx when if they are found to
1144 * match the current local configuration when processed. 1170 * match the current local configuration when processed.
1145 */ 1171 */
1146 sta->last_rx = jiffies; 1172 sta->last_rx = jiffies;
1173 if (ieee80211_is_data(hdr->frame_control)) {
1174 sta->last_rx_rate_idx = status->rate_idx;
1175 sta->last_rx_rate_flag = status->flag;
1176 }
1147 } 1177 }
1148 1178
1149 if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) 1179 if (!(status->rx_flags & IEEE80211_RX_RA_MATCH))
@@ -1161,7 +1191,8 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1161 * Change STA power saving mode only at the end of a frame 1191 * Change STA power saving mode only at the end of a frame
1162 * exchange sequence. 1192 * exchange sequence.
1163 */ 1193 */
1164 if (!ieee80211_has_morefrags(hdr->frame_control) && 1194 if (!(sta->local->hw.flags & IEEE80211_HW_AP_LINK_PS) &&
1195 !ieee80211_has_morefrags(hdr->frame_control) &&
1165 !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) && 1196 !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) &&
1166 (rx->sdata->vif.type == NL80211_IFTYPE_AP || 1197 (rx->sdata->vif.type == NL80211_IFTYPE_AP ||
1167 rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) { 1198 rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) {
@@ -1556,17 +1587,36 @@ __ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
1556{ 1587{
1557 struct ieee80211_sub_if_data *sdata = rx->sdata; 1588 struct ieee80211_sub_if_data *sdata = rx->sdata;
1558 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 1589 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
1590 bool check_port_control = false;
1591 struct ethhdr *ehdr;
1592 int ret;
1559 1593
1560 if (ieee80211_has_a4(hdr->frame_control) && 1594 if (ieee80211_has_a4(hdr->frame_control) &&
1561 sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta) 1595 sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
1562 return -1; 1596 return -1;
1563 1597
1598 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1599 !!sdata->u.mgd.use_4addr != !!ieee80211_has_a4(hdr->frame_control)) {
1600
1601 if (!sdata->u.mgd.use_4addr)
1602 return -1;
1603 else
1604 check_port_control = true;
1605 }
1606
1564 if (is_multicast_ether_addr(hdr->addr1) && 1607 if (is_multicast_ether_addr(hdr->addr1) &&
1565 ((sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta) || 1608 sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta)
1566 (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr)))
1567 return -1; 1609 return -1;
1568 1610
1569 return ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type); 1611 ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
1612 if (ret < 0 || !check_port_control)
1613 return ret;
1614
1615 ehdr = (struct ethhdr *) rx->skb->data;
1616 if (ehdr->h_proto != rx->sdata->control_port_protocol)
1617 return -1;
1618
1619 return 0;
1570} 1620}
1571 1621
1572/* 1622/*
@@ -1893,7 +1943,10 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
1893 dev->stats.rx_bytes += rx->skb->len; 1943 dev->stats.rx_bytes += rx->skb->len;
1894 1944
1895 if (local->ps_sdata && local->hw.conf.dynamic_ps_timeout > 0 && 1945 if (local->ps_sdata && local->hw.conf.dynamic_ps_timeout > 0 &&
1896 !is_multicast_ether_addr(((struct ethhdr *)rx->skb->data)->h_dest)) { 1946 !is_multicast_ether_addr(
1947 ((struct ethhdr *)rx->skb->data)->h_dest) &&
1948 (!local->scanning &&
1949 !test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))) {
1897 mod_timer(&local->dynamic_ps_timer, jiffies + 1950 mod_timer(&local->dynamic_ps_timer, jiffies +
1898 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); 1951 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
1899 } 1952 }
@@ -2488,7 +2541,6 @@ static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx)
2488 * same TID from the same station 2541 * same TID from the same station
2489 */ 2542 */
2490 rx->skb = skb; 2543 rx->skb = skb;
2491 rx->flags = 0;
2492 2544
2493 CALL_RXH(ieee80211_rx_h_decrypt) 2545 CALL_RXH(ieee80211_rx_h_decrypt)
2494 CALL_RXH(ieee80211_rx_h_check_more_data) 2546 CALL_RXH(ieee80211_rx_h_check_more_data)
@@ -2559,6 +2611,7 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
2559 .sdata = sta->sdata, 2611 .sdata = sta->sdata,
2560 .local = sta->local, 2612 .local = sta->local,
2561 .queue = tid, 2613 .queue = tid,
2614 .flags = 0,
2562 }; 2615 };
2563 struct tid_ampdu_rx *tid_agg_rx; 2616 struct tid_ampdu_rx *tid_agg_rx;
2564 2617
@@ -2590,7 +2643,8 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
2590 return 0; 2643 return 0;
2591 if (!multicast && 2644 if (!multicast &&
2592 compare_ether_addr(sdata->vif.addr, hdr->addr1) != 0) { 2645 compare_ether_addr(sdata->vif.addr, hdr->addr1) != 0) {
2593 if (!(sdata->dev->flags & IFF_PROMISC)) 2646 if (!(sdata->dev->flags & IFF_PROMISC) ||
2647 sdata->u.mgd.use_4addr)
2594 return 0; 2648 return 0;
2595 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 2649 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
2596 } 2650 }
@@ -2639,7 +2693,8 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
2639 return 0; 2693 return 0;
2640 } else if (!ieee80211_bssid_match(bssid, 2694 } else if (!ieee80211_bssid_match(bssid,
2641 sdata->vif.addr)) { 2695 sdata->vif.addr)) {
2642 if (!(status->rx_flags & IEEE80211_RX_IN_SCAN)) 2696 if (!(status->rx_flags & IEEE80211_RX_IN_SCAN) &&
2697 !ieee80211_is_beacon(hdr->frame_control))
2643 return 0; 2698 return 0;
2644 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 2699 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
2645 } 2700 }
@@ -2692,7 +2747,7 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
2692 if (!skb) { 2747 if (!skb) {
2693 if (net_ratelimit()) 2748 if (net_ratelimit())
2694 wiphy_debug(local->hw.wiphy, 2749 wiphy_debug(local->hw.wiphy,
2695 "failed to copy multicast frame for %s\n", 2750 "failed to copy skb for %s\n",
2696 sdata->name); 2751 sdata->name);
2697 return true; 2752 return true;
2698 } 2753 }
@@ -2730,7 +2785,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2730 local->dot11ReceivedFragmentCount++; 2785 local->dot11ReceivedFragmentCount++;
2731 2786
2732 if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning) || 2787 if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning) ||
2733 test_bit(SCAN_OFF_CHANNEL, &local->scanning))) 2788 test_bit(SCAN_SW_SCANNING, &local->scanning)))
2734 status->rx_flags |= IEEE80211_RX_IN_SCAN; 2789 status->rx_flags |= IEEE80211_RX_IN_SCAN;
2735 2790
2736 if (ieee80211_is_mgmt(fc)) 2791 if (ieee80211_is_mgmt(fc))