07f5bb52639375b497a171a2d03bf2f1972fb6a6
[openwrt/openwrt.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 17 Jun 2021 17:56:54 +0200
3 Subject: [PATCH] mac80211: move A-MPDU session check from minstrel_ht to
4 mac80211
5
6 This avoids calling back into tx handlers from within the rate control module.
7 Preparation for deferring rate control until tx dequeue
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11
12 --- a/include/net/mac80211.h
13 +++ b/include/net/mac80211.h
14 @@ -6160,6 +6160,11 @@ enum rate_control_capabilities {
15 * otherwise the NSS difference doesn't bother us.
16 */
17 RATE_CTRL_CAPA_VHT_EXT_NSS_BW = BIT(0),
18 + /**
19 + * @RATE_CTRL_CAPA_AMPDU_TRIGGER:
20 + * mac80211 should start A-MPDU sessions on tx
21 + */
22 + RATE_CTRL_CAPA_AMPDU_TRIGGER = BIT(1),
23 };
24
25 struct rate_control_ops {
26 --- a/net/mac80211/rc80211_minstrel_ht.c
27 +++ b/net/mac80211/rc80211_minstrel_ht.c
28 @@ -1144,29 +1144,6 @@ minstrel_downgrade_prob_rate(struct mins
29 }
30
31 static void
32 -minstrel_aggr_check(struct ieee80211_sta *pubsta, struct sk_buff *skb)
33 -{
34 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
35 - struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
36 - u16 tid;
37 -
38 - if (skb_get_queue_mapping(skb) == IEEE80211_AC_VO)
39 - return;
40 -
41 - if (unlikely(!ieee80211_is_data_qos(hdr->frame_control)))
42 - return;
43 -
44 - if (unlikely(skb->protocol == cpu_to_be16(ETH_P_PAE)))
45 - return;
46 -
47 - tid = ieee80211_get_tid(hdr);
48 - if (likely(sta->ampdu_mlme.tid_tx[tid]))
49 - return;
50 -
51 - ieee80211_start_tx_ba_session(pubsta, tid, 0);
52 -}
53 -
54 -static void
55 minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
56 void *priv_sta, struct ieee80211_tx_status *st)
57 {
58 @@ -1461,10 +1438,6 @@ minstrel_ht_get_rate(void *priv, struct
59 struct minstrel_priv *mp = priv;
60 u16 sample_idx;
61
62 - if (!(info->flags & IEEE80211_TX_CTL_AMPDU) &&
63 - !minstrel_ht_is_legacy_group(MI_RATE_GROUP(mi->max_prob_rate)))
64 - minstrel_aggr_check(sta, txrc->skb);
65 -
66 info->flags |= mi->tx_flags;
67
68 #ifdef CPTCFG_MAC80211_DEBUGFS
69 @@ -1870,6 +1843,7 @@ static u32 minstrel_ht_get_expected_thro
70
71 static const struct rate_control_ops mac80211_minstrel_ht = {
72 .name = "minstrel_ht",
73 + .capa = RATE_CTRL_CAPA_AMPDU_TRIGGER,
74 .tx_status_ext = minstrel_ht_tx_status,
75 .get_rate = minstrel_ht_get_rate,
76 .rate_init = minstrel_ht_rate_init,
77 --- a/net/mac80211/tx.c
78 +++ b/net/mac80211/tx.c
79 @@ -3953,6 +3953,29 @@ void ieee80211_txq_schedule_start(struct
80 }
81 EXPORT_SYMBOL(ieee80211_txq_schedule_start);
82
83 +static void
84 +ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata,
85 + struct sta_info *sta,
86 + struct sk_buff *skb)
87 +{
88 + struct rate_control_ref *ref = sdata->local->rate_ctrl;
89 + u16 tid;
90 +
91 + if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER))
92 + return;
93 +
94 + if (!sta || !sta->sta.ht_cap.ht_supported ||
95 + !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO ||
96 + skb->protocol == sdata->control_port_protocol)
97 + return;
98 +
99 + tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
100 + if (likely(sta->ampdu_mlme.tid_tx[tid]))
101 + return;
102 +
103 + ieee80211_start_tx_ba_session(&sta->sta, tid, 0);
104 +}
105 +
106 void __ieee80211_subif_start_xmit(struct sk_buff *skb,
107 struct net_device *dev,
108 u32 info_flags,
109 @@ -3983,6 +4006,8 @@ void __ieee80211_subif_start_xmit(struct
110 skb_get_hash(skb);
111 }
112
113 + ieee80211_aggr_check(sdata, sta, skb);
114 +
115 if (sta) {
116 struct ieee80211_fast_tx *fast_tx;
117
118 @@ -4246,6 +4271,8 @@ static void ieee80211_8023_xmit(struct i
119
120 memset(info, 0, sizeof(*info));
121
122 + ieee80211_aggr_check(sdata, sta, skb);
123 +
124 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
125 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
126 if (tid_tx) {