mac80211: backport airtime queue limits support
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / subsys / 306-mac80211-move-store-skb-ack-code-to-its-own-function.patch
1 From: John Crispin <john@phrozen.org>
2 Date: Tue, 29 Oct 2019 10:13:02 +0100
3 Subject: [PATCH] mac80211: move store skb ack code to its own function
4
5 This patch moves the code handling SKBTX_WIFI_STATUS inside the TX path
6 into an extra function. This allows us to reuse it inside the 802.11 encap
7 offloading datapath.
8
9 Signed-off-by: John Crispin <john@phrozen.org>
10 Link: https://lore.kernel.org/r/20191029091304.7330-2-john@phrozen.org
11 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
12 ---
13
14 --- a/net/mac80211/tx.c
15 +++ b/net/mac80211/tx.c
16 @@ -2430,6 +2430,33 @@ static int ieee80211_lookup_ra_sta(struc
17 return 0;
18 }
19
20 +static int ieee80211_store_ack_skb(struct ieee80211_local *local,
21 + struct sk_buff *skb,
22 + u32 *info_flags)
23 +{
24 + struct sk_buff *ack_skb = skb_clone_sk(skb);
25 + u16 info_id = 0;
26 +
27 + if (ack_skb) {
28 + unsigned long flags;
29 + int id;
30 +
31 + spin_lock_irqsave(&local->ack_status_lock, flags);
32 + id = idr_alloc(&local->ack_status_frames, ack_skb,
33 + 1, 0x10000, GFP_ATOMIC);
34 + spin_unlock_irqrestore(&local->ack_status_lock, flags);
35 +
36 + if (id >= 0) {
37 + info_id = id;
38 + *info_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
39 + } else {
40 + kfree_skb(ack_skb);
41 + }
42 + }
43 +
44 + return info_id;
45 +}
46 +
47 /**
48 * ieee80211_build_hdr - build 802.11 header in the given frame
49 * @sdata: virtual interface to build the header for
50 @@ -2723,26 +2750,8 @@ static struct sk_buff *ieee80211_build_h
51 }
52
53 if (unlikely(!multicast && skb->sk &&
54 - skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) {
55 - struct sk_buff *ack_skb = skb_clone_sk(skb);
56 -
57 - if (ack_skb) {
58 - unsigned long flags;
59 - int id;
60 -
61 - spin_lock_irqsave(&local->ack_status_lock, flags);
62 - id = idr_alloc(&local->ack_status_frames, ack_skb,
63 - 1, 0x10000, GFP_ATOMIC);
64 - spin_unlock_irqrestore(&local->ack_status_lock, flags);
65 -
66 - if (id >= 0) {
67 - info_id = id;
68 - info_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
69 - } else {
70 - kfree_skb(ack_skb);
71 - }
72 - }
73 - }
74 + skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS))
75 + info_id = ieee80211_store_ack_skb(local, skb, &info_flags);
76
77 /*
78 * If the skb is shared we need to obtain our own copy.