1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 26 Feb 2018 22:09:29 +0100
3 Subject: [PATCH] mac80211: support A-MSDU in fast-rx
5 Only works if the IV was stripped from packets. Create a smaller
6 variant of ieee80211_rx_h_amsdu, which bypasses checks already done
7 within the fast-rx context.
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 --- a/net/mac80211/rx.c
13 +++ b/net/mac80211/rx.c
14 @@ -2358,39 +2358,17 @@ ieee80211_deliver_skb(struct ieee80211_r
17 static ieee80211_rx_result debug_noinline
18 -ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
19 +__ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
21 struct net_device *dev = rx->sdata->dev;
22 struct sk_buff *skb = rx->skb;
23 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
24 __le16 fc = hdr->frame_control;
25 struct sk_buff_head frame_list;
26 - struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
28 const u8 *check_da = ethhdr.h_dest, *check_sa = ethhdr.h_source;
30 - if (unlikely(!ieee80211_is_data(fc)))
33 - if (unlikely(!ieee80211_is_data_present(fc)))
34 - return RX_DROP_MONITOR;
36 - if (!(status->rx_flags & IEEE80211_RX_AMSDU))
39 if (unlikely(ieee80211_has_a4(hdr->frame_control))) {
40 - switch (rx->sdata->vif.type) {
41 - case NL80211_IFTYPE_AP_VLAN:
42 - if (!rx->sdata->u.vlan.sta)
43 - return RX_DROP_UNUSABLE;
45 - case NL80211_IFTYPE_STATION:
46 - if (!rx->sdata->u.mgd.use_4addr)
47 - return RX_DROP_UNUSABLE;
50 - return RX_DROP_UNUSABLE;
54 } else switch (rx->sdata->vif.type) {
55 @@ -2410,9 +2388,6 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx
59 - if (is_multicast_ether_addr(hdr->addr1))
60 - return RX_DROP_UNUSABLE;
63 __skb_queue_head_init(&frame_list);
65 @@ -2440,6 +2415,44 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx
69 +static ieee80211_rx_result debug_noinline
70 +ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
72 + struct sk_buff *skb = rx->skb;
73 + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
74 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
75 + __le16 fc = hdr->frame_control;
77 + if (!(status->rx_flags & IEEE80211_RX_AMSDU))
80 + if (unlikely(!ieee80211_is_data(fc)))
83 + if (unlikely(!ieee80211_is_data_present(fc)))
84 + return RX_DROP_MONITOR;
86 + if (unlikely(ieee80211_has_a4(hdr->frame_control))) {
87 + switch (rx->sdata->vif.type) {
88 + case NL80211_IFTYPE_AP_VLAN:
89 + if (!rx->sdata->u.vlan.sta)
90 + return RX_DROP_UNUSABLE;
92 + case NL80211_IFTYPE_STATION:
93 + if (!rx->sdata->u.mgd.use_4addr)
94 + return RX_DROP_UNUSABLE;
97 + return RX_DROP_UNUSABLE;
101 + if (is_multicast_ether_addr(hdr->addr1))
102 + return RX_DROP_UNUSABLE;
104 + return __ieee80211_rx_h_amsdu(rx);
107 #ifdef CPTCFG_MAC80211_MESH
108 static ieee80211_rx_result
109 ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
110 @@ -3899,6 +3912,7 @@ static bool ieee80211_invoke_fast_rx(str
112 } addrs __aligned(2);
113 struct ieee80211_sta_rx_stats *stats = &sta->rx_stats;
116 if (fast_rx->uses_rss)
117 stats = this_cpu_ptr(sta->pcpu_rx_stats);
118 @@ -3920,10 +3934,6 @@ static bool ieee80211_invoke_fast_rx(str
119 (status->flag & FAST_RX_CRYPT_FLAGS) != FAST_RX_CRYPT_FLAGS)
122 - /* we don't deal with A-MSDU deaggregation here */
123 - if (status->rx_flags & IEEE80211_RX_AMSDU)
126 if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
129 @@ -3951,25 +3961,31 @@ static bool ieee80211_invoke_fast_rx(str
130 * and strip the IV/MIC if necessary
132 if (fast_rx->key && !(status->flag & RX_FLAG_IV_STRIPPED)) {
133 + if (status->rx_flags & IEEE80211_RX_AMSDU)
136 /* GCMP header length is the same */
137 snap_offs += IEEE80211_CCMP_HDR_LEN;
140 - if (!pskb_may_pull(skb, snap_offs + sizeof(*payload)))
142 - payload = (void *)(skb->data + snap_offs);
143 + if (!(status->rx_flags & IEEE80211_RX_AMSDU)) {
144 + if (!pskb_may_pull(skb, snap_offs + sizeof(*payload)))
147 - if (!ether_addr_equal(payload->snap, fast_rx->rfc1042_hdr))
149 + payload = (void *)(skb->data + snap_offs);
151 - /* Don't handle these here since they require special code.
152 - * Accept AARP and IPX even though they should come with a
153 - * bridge-tunnel header - but if we get them this way then
154 - * there's little point in discarding them.
156 - if (unlikely(payload->proto == cpu_to_be16(ETH_P_TDLS) ||
157 - payload->proto == fast_rx->control_port_protocol))
159 + if (!ether_addr_equal(payload->snap, fast_rx->rfc1042_hdr))
162 + /* Don't handle these here since they require special code.
163 + * Accept AARP and IPX even though they should come with a
164 + * bridge-tunnel header - but if we get them this way then
165 + * there's little point in discarding them.
167 + if (unlikely(payload->proto == cpu_to_be16(ETH_P_TDLS) ||
168 + payload->proto == fast_rx->control_port_protocol))
172 /* after this point, don't punt to the slowpath! */
174 @@ -3983,12 +3999,6 @@ static bool ieee80211_invoke_fast_rx(str
177 /* statistics part of ieee80211_rx_h_sta_process() */
178 - stats->last_rx = jiffies;
179 - stats->last_rate = sta_stats_encode_rate(status);
181 - stats->fragments++;
184 if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
185 stats->last_signal = status->signal;
186 if (!fast_rx->uses_rss)
187 @@ -4017,6 +4027,20 @@ static bool ieee80211_invoke_fast_rx(str
188 if (rx->key && !ieee80211_has_protected(hdr->frame_control))
191 + if (status->rx_flags & IEEE80211_RX_AMSDU) {
192 + res = __ieee80211_rx_h_amsdu(rx);
193 + if (res != RX_QUEUED)
199 + stats->last_rx = jiffies;
200 + stats->last_rate = sta_stats_encode_rate(status);
202 + stats->fragments++;
205 /* do the header conversion - first grab the addresses */
206 ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs);
207 ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs);