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
6 This avoids calling back into tx handlers from within the rate control module.
7 Preparation for deferring rate control until tx dequeue
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
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.
17 RATE_CTRL_CAPA_VHT_EXT_NSS_BW = BIT(0),
19 + * @RATE_CTRL_CAPA_AMPDU_TRIGGER:
20 + * mac80211 should start A-MPDU sessions on tx
22 + RATE_CTRL_CAPA_AMPDU_TRIGGER = BIT(1),
25 struct rate_control_ops {
26 --- a/net/mac80211/rc80211_minstrel_ht.c
27 +++ b/net/mac80211/rc80211_minstrel_ht.c
28 @@ -1153,29 +1153,6 @@ minstrel_downgrade_prob_rate(struct mins
32 -minstrel_aggr_check(struct ieee80211_sta *pubsta, struct sk_buff *skb)
34 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
35 - struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
38 - if (skb_get_queue_mapping(skb) == IEEE80211_AC_VO)
41 - if (unlikely(!ieee80211_is_data_qos(hdr->frame_control)))
44 - if (unlikely(skb->protocol == cpu_to_be16(ETH_P_PAE)))
47 - tid = ieee80211_get_tid(hdr);
48 - if (likely(sta->ampdu_mlme.tid_tx[tid]))
51 - ieee80211_start_tx_ba_session(pubsta, tid, 0);
55 minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
56 void *priv_sta, struct ieee80211_tx_status *st)
58 @@ -1477,10 +1454,6 @@ minstrel_ht_get_rate(void *priv, struct
59 struct minstrel_priv *mp = priv;
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);
66 info->flags |= mi->tx_flags;
68 #ifdef CPTCFG_MAC80211_DEBUGFS
69 @@ -1894,6 +1867,7 @@ static u32 minstrel_ht_get_expected_thro
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 @@ -3933,6 +3933,29 @@ void ieee80211_txq_schedule_start(struct
81 EXPORT_SYMBOL(ieee80211_txq_schedule_start);
84 +ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata,
85 + struct sta_info *sta,
86 + struct sk_buff *skb)
88 + struct rate_control_ref *ref = sdata->local->rate_ctrl;
91 + if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER))
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)
99 + tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
100 + if (likely(sta->ampdu_mlme.tid_tx[tid]))
103 + ieee80211_start_tx_ba_session(&sta->sta, tid, 0);
106 void __ieee80211_subif_start_xmit(struct sk_buff *skb,
107 struct net_device *dev,
109 @@ -3963,6 +3986,8 @@ void __ieee80211_subif_start_xmit(struct
113 + ieee80211_aggr_check(sdata, sta, skb);
116 struct ieee80211_fast_tx *fast_tx;
118 @@ -4226,6 +4251,8 @@ static void ieee80211_8023_xmit(struct i
120 memset(info, 0, sizeof(*info));
122 + ieee80211_aggr_check(sdata, sta, skb);
124 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
125 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);