mac80211: update to v6.1.24
[openwrt/staging/dedeckeh.git] / package / kernel / mac80211 / patches / subsys / 326-wifi-mac80211-add-mesh-fast-rx-support.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 2 Mar 2023 13:52:29 +0100
3 Subject: [PATCH] wifi: mac80211: add mesh fast-rx support
4
5 This helps bring down rx CPU usage by avoiding calls to the rx handlers in
6 the slow path. Supports forwarding and local rx, including A-MSDU.
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10
11 --- a/net/mac80211/rx.c
12 +++ b/net/mac80211/rx.c
13 @@ -4564,6 +4564,12 @@ void ieee80211_check_fast_rx(struct sta_
14 }
15
16 break;
17 + case NL80211_IFTYPE_MESH_POINT:
18 + fastrx.expected_ds_bits = cpu_to_le16(IEEE80211_FCTL_FROMDS |
19 + IEEE80211_FCTL_TODS);
20 + fastrx.da_offs = offsetof(struct ieee80211_hdr, addr3);
21 + fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr4);
22 + break;
23 default:
24 goto clear;
25 }
26 @@ -4772,6 +4778,7 @@ static bool ieee80211_invoke_fast_rx(str
27 struct sk_buff *skb = rx->skb;
28 struct ieee80211_hdr *hdr = (void *)skb->data;
29 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
30 + static ieee80211_rx_result res;
31 int orig_len = skb->len;
32 int hdrlen = ieee80211_hdrlen(hdr->frame_control);
33 int snap_offs = hdrlen;
34 @@ -4833,7 +4840,8 @@ static bool ieee80211_invoke_fast_rx(str
35 snap_offs += IEEE80211_CCMP_HDR_LEN;
36 }
37
38 - if (!(status->rx_flags & IEEE80211_RX_AMSDU)) {
39 + if (!ieee80211_vif_is_mesh(&rx->sdata->vif) &&
40 + !(status->rx_flags & IEEE80211_RX_AMSDU)) {
41 if (!pskb_may_pull(skb, snap_offs + sizeof(*payload)))
42 return false;
43
44 @@ -4872,13 +4880,29 @@ static bool ieee80211_invoke_fast_rx(str
45 /* do the header conversion - first grab the addresses */
46 ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs);
47 ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs);
48 - skb_postpull_rcsum(skb, skb->data + snap_offs,
49 - sizeof(rfc1042_header) + 2);
50 - /* remove the SNAP but leave the ethertype */
51 - skb_pull(skb, snap_offs + sizeof(rfc1042_header));
52 + if (ieee80211_vif_is_mesh(&rx->sdata->vif)) {
53 + skb_pull(skb, snap_offs - 2);
54 + put_unaligned_be16(skb->len - 2, skb->data);
55 + } else {
56 + skb_postpull_rcsum(skb, skb->data + snap_offs,
57 + sizeof(rfc1042_header) + 2);
58 +
59 + /* remove the SNAP but leave the ethertype */
60 + skb_pull(skb, snap_offs + sizeof(rfc1042_header));
61 + }
62 /* push the addresses in front */
63 memcpy(skb_push(skb, sizeof(addrs)), &addrs, sizeof(addrs));
64
65 + res = ieee80211_rx_mesh_data(rx->sdata, rx->sta, rx->skb);
66 + switch (res) {
67 + case RX_QUEUED:
68 + return true;
69 + case RX_CONTINUE:
70 + break;
71 + default:
72 + goto drop;
73 + }
74 +
75 ieee80211_rx_8023(rx, fast_rx, orig_len);
76
77 return true;