aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/mac80211
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2018-02-26 22:13:44 +0100
committerFelix Fietkau <nbd@nbd.name>2018-02-28 12:46:02 +0100
commitc4c64f5305199343e6fdb85c167b95170b0e12c1 (patch)
tree08f87732575e2ef6e46c25778045e7f5d2e6e429 /package/kernel/mac80211
parent916e33fa1e14b97daf8c9bf07a1b36f9767db679 (diff)
downloadupstream-c4c64f5305199343e6fdb85c167b95170b0e12c1.tar.gz
upstream-c4c64f5305199343e6fdb85c167b95170b0e12c1.tar.bz2
upstream-c4c64f5305199343e6fdb85c167b95170b0e12c1.zip
mac80211: add an optimization for fast-rx support
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'package/kernel/mac80211')
-rw-r--r--package/kernel/mac80211/patches/335-mac80211-support-A-MSDU-in-fast-rx.patch207
1 files changed, 207 insertions, 0 deletions
diff --git a/package/kernel/mac80211/patches/335-mac80211-support-A-MSDU-in-fast-rx.patch b/package/kernel/mac80211/patches/335-mac80211-support-A-MSDU-in-fast-rx.patch
new file mode 100644
index 0000000000..dce6d5c8f3
--- /dev/null
+++ b/package/kernel/mac80211/patches/335-mac80211-support-A-MSDU-in-fast-rx.patch
@@ -0,0 +1,207 @@
+From: Felix Fietkau <nbd@nbd.name>
+Date: Mon, 26 Feb 2018 22:09:29 +0100
+Subject: [PATCH] mac80211: support A-MSDU in fast-rx
+
+Only works if the IV was stripped from packets. Create a smaller
+variant of ieee80211_rx_h_amsdu, which bypasses checks already done
+within the fast-rx context.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -2358,39 +2358,17 @@ ieee80211_deliver_skb(struct ieee80211_r
+ }
+
+ static ieee80211_rx_result debug_noinline
+-ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
++__ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
+ {
+ struct net_device *dev = rx->sdata->dev;
+ struct sk_buff *skb = rx->skb;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ __le16 fc = hdr->frame_control;
+ struct sk_buff_head frame_list;
+- struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
+ struct ethhdr ethhdr;
+ const u8 *check_da = ethhdr.h_dest, *check_sa = ethhdr.h_source;
+
+- if (unlikely(!ieee80211_is_data(fc)))
+- return RX_CONTINUE;
+-
+- if (unlikely(!ieee80211_is_data_present(fc)))
+- return RX_DROP_MONITOR;
+-
+- if (!(status->rx_flags & IEEE80211_RX_AMSDU))
+- return RX_CONTINUE;
+-
+ if (unlikely(ieee80211_has_a4(hdr->frame_control))) {
+- switch (rx->sdata->vif.type) {
+- case NL80211_IFTYPE_AP_VLAN:
+- if (!rx->sdata->u.vlan.sta)
+- return RX_DROP_UNUSABLE;
+- break;
+- case NL80211_IFTYPE_STATION:
+- if (!rx->sdata->u.mgd.use_4addr)
+- return RX_DROP_UNUSABLE;
+- break;
+- default:
+- return RX_DROP_UNUSABLE;
+- }
+ check_da = NULL;
+ check_sa = NULL;
+ } else switch (rx->sdata->vif.type) {
+@@ -2410,9 +2388,6 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx
+ break;
+ }
+
+- if (is_multicast_ether_addr(hdr->addr1))
+- return RX_DROP_UNUSABLE;
+-
+ skb->dev = dev;
+ __skb_queue_head_init(&frame_list);
+
+@@ -2440,6 +2415,44 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx
+ return RX_QUEUED;
+ }
+
++static ieee80211_rx_result debug_noinline
++ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
++{
++ struct sk_buff *skb = rx->skb;
++ struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
++ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
++ __le16 fc = hdr->frame_control;
++
++ if (!(status->rx_flags & IEEE80211_RX_AMSDU))
++ return RX_CONTINUE;
++
++ if (unlikely(!ieee80211_is_data(fc)))
++ return RX_CONTINUE;
++
++ if (unlikely(!ieee80211_is_data_present(fc)))
++ return RX_DROP_MONITOR;
++
++ if (unlikely(ieee80211_has_a4(hdr->frame_control))) {
++ switch (rx->sdata->vif.type) {
++ case NL80211_IFTYPE_AP_VLAN:
++ if (!rx->sdata->u.vlan.sta)
++ return RX_DROP_UNUSABLE;
++ break;
++ case NL80211_IFTYPE_STATION:
++ if (!rx->sdata->u.mgd.use_4addr)
++ return RX_DROP_UNUSABLE;
++ break;
++ default:
++ return RX_DROP_UNUSABLE;
++ }
++ }
++
++ if (is_multicast_ether_addr(hdr->addr1))
++ return RX_DROP_UNUSABLE;
++
++ return __ieee80211_rx_h_amsdu(rx);
++}
++
+ #ifdef CPTCFG_MAC80211_MESH
+ static ieee80211_rx_result
+ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
+@@ -3899,6 +3912,7 @@ static bool ieee80211_invoke_fast_rx(str
+ u8 sa[ETH_ALEN];
+ } addrs __aligned(2);
+ struct ieee80211_sta_rx_stats *stats = &sta->rx_stats;
++ int res;
+
+ if (fast_rx->uses_rss)
+ stats = this_cpu_ptr(sta->pcpu_rx_stats);
+@@ -3920,10 +3934,6 @@ static bool ieee80211_invoke_fast_rx(str
+ (status->flag & FAST_RX_CRYPT_FLAGS) != FAST_RX_CRYPT_FLAGS)
+ return false;
+
+- /* we don't deal with A-MSDU deaggregation here */
+- if (status->rx_flags & IEEE80211_RX_AMSDU)
+- return false;
+-
+ if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
+ return false;
+
+@@ -3951,25 +3961,31 @@ static bool ieee80211_invoke_fast_rx(str
+ * and strip the IV/MIC if necessary
+ */
+ if (fast_rx->key && !(status->flag & RX_FLAG_IV_STRIPPED)) {
++ if (status->rx_flags & IEEE80211_RX_AMSDU)
++ return false;
++
+ /* GCMP header length is the same */
+ snap_offs += IEEE80211_CCMP_HDR_LEN;
+ }
+
+- if (!pskb_may_pull(skb, snap_offs + sizeof(*payload)))
+- goto drop;
+- payload = (void *)(skb->data + snap_offs);
++ if (!(status->rx_flags & IEEE80211_RX_AMSDU)) {
++ if (!pskb_may_pull(skb, snap_offs + sizeof(*payload)))
++ goto drop;
+
+- if (!ether_addr_equal(payload->snap, fast_rx->rfc1042_hdr))
+- return false;
++ payload = (void *)(skb->data + snap_offs);
+
+- /* Don't handle these here since they require special code.
+- * Accept AARP and IPX even though they should come with a
+- * bridge-tunnel header - but if we get them this way then
+- * there's little point in discarding them.
+- */
+- if (unlikely(payload->proto == cpu_to_be16(ETH_P_TDLS) ||
+- payload->proto == fast_rx->control_port_protocol))
+- return false;
++ if (!ether_addr_equal(payload->snap, fast_rx->rfc1042_hdr))
++ return false;
++
++ /* Don't handle these here since they require special code.
++ * Accept AARP and IPX even though they should come with a
++ * bridge-tunnel header - but if we get them this way then
++ * there's little point in discarding them.
++ */
++ if (unlikely(payload->proto == cpu_to_be16(ETH_P_TDLS) ||
++ payload->proto == fast_rx->control_port_protocol))
++ return false;
++ }
+
+ /* after this point, don't punt to the slowpath! */
+
+@@ -3983,12 +3999,6 @@ static bool ieee80211_invoke_fast_rx(str
+ }
+
+ /* statistics part of ieee80211_rx_h_sta_process() */
+- stats->last_rx = jiffies;
+- stats->last_rate = sta_stats_encode_rate(status);
+-
+- stats->fragments++;
+- stats->packets++;
+-
+ if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
+ stats->last_signal = status->signal;
+ if (!fast_rx->uses_rss)
+@@ -4017,6 +4027,20 @@ static bool ieee80211_invoke_fast_rx(str
+ if (rx->key && !ieee80211_has_protected(hdr->frame_control))
+ goto drop;
+
++ if (status->rx_flags & IEEE80211_RX_AMSDU) {
++ res = __ieee80211_rx_h_amsdu(rx);
++ if (res != RX_QUEUED)
++ goto drop;
++
++ return true;
++ }
++
++ stats->last_rx = jiffies;
++ stats->last_rate = sta_stats_encode_rate(status);
++
++ stats->fragments++;
++ stats->packets++;
++
+ /* do the header conversion - first grab the addresses */
+ ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs);
+ ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs);