mac80211: add A-MSDU tx support
PATCH v2 2/2 mac80211: minstrel_ht: set A-MSDU tx limits based on selected max_prob_rate
In reply to Felix FietkauPrevents excessive A-MSDU aggregation at low data rates or bad conditions.
--- net/mac80211/rc80211_minstrel_ht.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
net/mac80211/rc80211_minstrel_ht.c +34 -0
@@ -882,6 +882,39 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, ratetbl->rate[offset].flags = flags; } +static int +minstrel_ht_get_max_amsdu_len (struct minstrel_ht_sta *mi) +{ +int group = mi->max_prob_rate /MCS_GROUP_RATES ; +const struct mcs_group *g = &minstrel_mcs_groups[group]; +int rate = mi->max_prob_rate %MCS_GROUP_RATES ; + +/* Disable A-MSDU if max_prob_rate is bad */ +if (mi->groups[group].rates[rate].prob_ewma <MINSTREL_FRAC (50 ,100 )) +return 1 ; + +/* If the rate is slower than single-stream MCS1, make A-MSDU limit small */ +if (g->duration[rate] >MCS_DURATION (1 ,0 ,52 )) +return 500 ; + +/* +* If the rate is slower than single-stream MCS4, limit A-MSDU to usual +* data packet size +*/ +if (g->duration[rate] >MCS_DURATION (1 ,0 ,104 )) +return 1500 ; + +/* +* If the rate is slower than single-stream MCS7, limit A-MSDU to twice +* the usual data packet size +*/ +if (g->duration[rate] >MCS_DURATION (1 ,0 ,260 )) +return 3000 ; + +/* unlimited */ +return 0 ; +} +static void minstrel_ht_update_rates (struct minstrel_priv *mp,struct minstrel_ht_sta *mi) {
@@ -906,6 +939,7 @@ minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)minstrel_ht_set_rate (mp, mi, rates, i++, mi->max_prob_rate); } + mi->sta->max_rc_amsdu_len =minstrel_ht_get_max_amsdu_len (mi); rates->rate[i].idx =-1 ;rate_control_set_rates (mp->hw, mi->sta, rates); }
Signature · 1 line
2.2.2
PATCH v2 1/2 mac80211: add A-MSDU tx support
Requires software tx queueing and fast-xmit support. For good performance, drivers need frag_list support as well. This avoids the need for copying data of aggregated frames. Running without it is only supported for debugging purposes.
To avoid performance and packet size issues, the rate control module or driver needs to limit the maximum A-MSDU size by setting max_rc_amsdu_len in struct ieee80211_sta.
--- include/net/mac80211.h | 19 ++++++ net/mac80211/agg-tx.c | 5 ++ net/mac80211/debugfs.c | 2 + net/mac80211/ieee80211_i.h | 1 + net/mac80211/tx.c | 165 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 192 insertions(+)
include/net/mac80211.h +19 -0
@@ -709,6 +709,7 @@ enum mac80211_tx_info_flags {* @IEEE80211_TX_CTRL_PS_RESPONSE: This frame is a response to a poll * frame (PS-Poll or uAPSD). * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information +* @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame * * These flags are used in tx_info->control.flags. */
@@ -716,6 +717,7 @@ enum mac80211_tx_control_flags {IEEE80211_TX_CTRL_PORT_CTRL_PROTO =BIT (0 ),IEEE80211_TX_CTRL_PS_RESPONSE =BIT (1 ),IEEE80211_TX_CTRL_RATE_INJECT =BIT (2 ), + IEEE80211_TX_CTRL_AMSDU = BIT(3), };/*
@@ -1735,6 +1737,7 @@ struct ieee80211_sta_rates {* size is min(max_amsdu_len, 7935) bytes. * Both additional HT limits must be enforced by the low level driver. * This is defined by the spec (IEEE 802.11-2012 section 8.3.2.2 NOTE 2). +* @max_rc_amsdu_len: Maximum A-MSDU size in bytes recommended by rate control. * @txq: per-TID data TX queues (if driver uses the TXQ abstraction) */ struct ieee80211_sta {
@@ -1755,6 +1758,7 @@ struct ieee80211_sta {bool mfp;u8 max_amsdu_subframes;u16 max_amsdu_len; +u16 max_rc_amsdu_len;struct ieee80211_txq *txq[IEEE80211_NUM_TIDS ];
@@ -1968,6 +1972,15 @@ struct ieee80211_txq {* order and does not need to manage its own reorder buffer or BA session * timeout. * +* @IEEE80211_HW_TX_AMSDU: Hardware (or driver) supports software aggregated +* A-MSDU frames. Requires software tx queueing and fast-xmit support. +* When not using minstrel/minstrel_ht rate control, the driver should +* limit the maximum A-MSDU size based on the current tx rate by setting +* max_rc_amsdu_len in struct ieee80211_sta. +* +* @IEEE80211_HW_TX_FRAG_LIST: Hardware (or driver) supports sending frag_list +* skbs, needed for zero-copy software A-MSDU. +* * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays */ enum ieee80211_hw_flags {
@@ -2005,6 +2018,8 @@ enum ieee80211_hw_flags {IEEE80211_HW_BEACON_TX_STATUS ,IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR ,IEEE80211_HW_SUPPORTS_REORDERING_BUFFER , +IEEE80211_HW_TX_AMSDU , +IEEE80211_HW_TX_FRAG_LIST ,/* keep last, obviously */ NUM_IEEE80211_HW_FLAGS
@@ -2077,6 +2092,9 @@ enum ieee80211_hw_flags {* size is smaller (an example is LinkSys WRT120N with FW v1.0.07 * build 002 Jun 18 2012). * +* @max_tx_fragments: maximum number of tx buffers per (A)-MSDU, sum +* of 1 + skb_shinfo(skb)->nr_frags for each skb in the frag_list. +* * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX * (if %IEEE80211_HW_QUEUE_CONTROL is set) *
@@ -2131,6 +2149,7 @@ struct ieee80211_hw {u8 max_rate_tries;u8 max_rx_aggregation_subframes;u8 max_tx_aggregation_subframes; +u8 max_tx_fragments;u8 offchannel_tx_hw_queue;u8 radiotap_mcs_details;u16 radiotap_vht_details;
net/mac80211/agg-tx.c +5 -0
@@ -935,6 +935,7 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local, size_t len) {struct tid_ampdu_tx *tid_tx; +struct ieee80211_txq *txq;u16 capab, tid;u8 buf_size;bool amsdu;
@@ -945,6 +946,10 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local, buf_size = (capab &IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK ) >>6 ; buf_size =min (buf_size, local->hw.max_tx_aggregation_subframes); + txq = sta->sta.txq[tid]; +if (!amsdu && txq) +set_bit (IEEE80211_TXQ_NO_AMSDU , &to_txq_info (txq)->flags); +mutex_lock (&sta->ampdu_mlme.mtx); tid_tx =rcu_dereference_protected_tid_tx (sta, tid);
net/mac80211/debugfs.c +2 -0
@@ -127,6 +127,8 @@ static const char *hw_flag_names[NUM_IEEE80211_HW_FLAGS + 1] = {FLAG (BEACON_TX_STATUS ),FLAG (NEEDS_UNIQUE_STA_ADDR ),FLAG (SUPPORTS_REORDERING_BUFFER ), +FLAG (TX_AMSDU ), +FLAG (TX_FRAG_LIST ),/* keep last for the build bug below */ (void *)0x1
net/mac80211/ieee80211_i.h +1 -0
@@ -797,6 +797,7 @@ struct mac80211_qos_map {enum txq_info_flags {IEEE80211_TXQ_STOP ,IEEE80211_TXQ_AMPDU , +IEEE80211_TXQ_NO_AMSDU , };struct txq_info {
net/mac80211/tx.c +165 -0
183 lines not on this page · raw message
Signature · 1 line
2.2.2
Johannes Berg
maintainernet/mac80211/tx.c void ieee80211_clear_fast_xmit(struct sta_info *sta) · line 2888
Quoted 9 lines · Felix Fietkau
net/mac80211/tx.c +8
-0+/* +* HT A-MPDU limits maximum MPDU size to 4095 bytes. Since aggregation +* sessions are started/stopped without txq flush, use the limit here +* to avoid having to de-aggregate later. +*/ +if (skb->len + head->len >4095 && + !sta->sta.vht_cap.vht_supported) + goto out;
I'm not entirely happy with this. You're silently assuming that when VHT is supported, HT MCSes will never be used.
This is (I think) true for minstrel_ht, but at the very least you should also document it along with the max_rc_amsdu_len then, which btw I was going to reword to:
+ * @IEEE80211_HW_TX_AMSDU: Hardware (or driver) supports software aggregated
+ * A-MSDU frames. Requires software tx queueing and fast-xmit support.
+ * When not using minstrel/minstrel_ht rate control, the driver needs to
+ * limit the maximum A-MSDU size based on the current tx rate by setting
+ * max_rc_amsdu_len in struct ieee80211_sta to avoid mac80211 building
+ * A-MSDUs that require too much airtime (are too long for a TXOP.)
All that said, I'm not sure how much value there really is in aggregating that much? I'd think the value of A-MSDU really is more for lots of small frames like TCP ACKs, since the PER goes up exponentially with the BER for A-MSDU (unlike A-MPDU.)
johannes
Johannes Berg
maintainerRe: [PATCH v2 2/2] mac80211: minstrel_ht: set A-MSDU tx limits based on selected max_prob_rate
In reply to Felix Fietkaunet/mac80211/rc80211_minstrel_ht.c minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, · line 912
Quoted 13 lines · Felix Fietkau
net/mac80211/rc80211_minstrel_ht.c +13
-0+/* +* If the rate is slower than single-stream MCS4, limit A-MSDU to usual +* data packet size +*/ +if (g->duration[rate] >MCS_DURATION (1 ,0 ,104 )) +return 1500 ; + +/* +* If the rate is slower than single-stream MCS7, limit A-MSDU to twice +* the usual data packet size +*/ +if (g->duration[rate] >MCS_DURATION (1 ,0 ,260 )) +return 3000 ;
This isn't *quite* right, since you have to take an 802.11 header (vs. an ethernet header) into account, I think?
johannes
Re: [PATCH v2 2/2] mac80211: minstrel_ht: set A-MSDU tx limits based on selected max_prob_rate
Quoted 18 lines · Johannes Berg
net/mac80211/rc80211_minstrel_ht.c minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, · line 912
Quoted 13 lines · Felix Fietkau
net/mac80211/rc80211_minstrel_ht.c +13
-0+/* +* If the rate is slower than single-stream MCS4, limit A-MSDU to usual +* data packet size +*/ +if (g->duration[rate] >MCS_DURATION (1 ,0 ,104 )) +return 1500 ; + +/* +* If the rate is slower than single-stream MCS7, limit A-MSDU to twice +* the usual data packet size +*/ +if (g->duration[rate] >MCS_DURATION (1 ,0 ,260 )) +return 3000 ;This isn't *quite* right, since you have to take an 802.11 header (vs. an ethernet header) into account, I think?
It's only a rough approximation anyway to prevent very large A-MSDUs from being created with low rates.
- Felix
Johannes Berg
maintainerRe: [PATCH v2 2/2] mac80211: minstrel_ht: set A-MSDU tx limits based on selected max_prob_rate
Quoted 7 lines · Felix Fietkau
Quoted 3 lines
This isn't *quite* right, since you have to take an 802.11 header (vs.
an ethernet header) into account, I think?It's only a rough approximation anyway to prevent very large A-MSDUs from being created with low rates.
Right, but it seemed like the intent was to allow two full-MTU sized frames to be combined, which this doesn't.
johannes
Quoted 26 lines · Johannes Berg
net/mac80211/tx.c void ieee80211_clear_fast_xmit(struct sta_info *sta) · line 2888
Quoted 9 lines · Felix Fietkau
net/mac80211/tx.c +8
-0+/* +* HT A-MPDU limits maximum MPDU size to 4095 bytes. Since aggregation +* sessions are started/stopped without txq flush, use the limit here +* to avoid having to de-aggregate later. +*/ +if (skb->len + head->len >4095 && + !sta->sta.vht_cap.vht_supported) + goto out;I'm not entirely happy with this. You're silently assuming that when VHT is supported, HT MCSes will never be used.
This is (I think) true for
minstrel_ht, but at the very least you should also document it along with themax_rc_amsdu_lenthen, which btw I was going to reword to:+ * @IEEE80211_HW_TX_AMSDU: Hardware (or driver) supports software aggregated
+ * A-MSDU frames. Requires software tx queueing and fast-xmit support. + * When not using minstrel/minstrel_ht rate control, the driver needs to + * limit the maximum A-MSDU size based on the current tx rate by setting + * max_rc_amsdu_len in struct ieee80211_sta to avoid mac80211 building + * A-MSDUs that require too much airtime (are too long for a TXOP.)
Quoted 4 lines
All that said, I'm not sure how much value there really is in aggregating that much? I'd think the value of A-MSDU really is more for lots of small frames like TCP ACKs, since the PER goes up exponentially with the BER for A-MSDU (unlike A-MPDU.)
For my own uses, I'd be perfectly fine with limiting A-MSDU size to HT limits even when using VHT - in fact I did that in an early RFC patch. I mainly relaxed the limit for VHT based on Emmanuel's feedback. I also have doubts about the value of A-MSDU size beyond 4095 bytes.
Just let me know which way you'd like it, and I'll send v3 accordingly.
- Felix
Re: [PATCH v2 2/2] mac80211: minstrel_ht: set A-MSDU tx limits based on selected max_prob_rate
In reply to Johannes BergQuoted 11 lines · Johannes Berg
Quoted 7 lines · Felix Fietkau
Quoted 4 lines
This isn't *quite* right, since you have to take an 802.11 header (vs.
an ethernet header) into account, I think?It's only a rough approximation anyway to prevent very large A-MSDUs from being created with low rates.
Right, but it seemed like the intent was to allow two full-MTU sized frames to be combined, which this doesn't.
I'll look into it some more to see if it's better to change the comment or the code in this case.
- Felix
Johannes Berg
maintainerQuoted 10 lines · Felix Fietkau
For my own uses, I'd be perfectly fine with limiting A-MSDU size to HT limits even when using VHT - in fact I did that in an early RFC patch. I mainly relaxed the limit for VHT based on Emmanuel's feedback. I also have doubts about the value of A-MSDU size beyond 4095 bytes.Just let me know which way you'd like it, and I'll send v3 accordingly.
I don't really know, I can live with both ways. I'm just a bit worried that we make enabling this feature so complex that nobody will get it right.
Perhaps we could also just remove this, make the default for max_rc_amsdu_len be 4095 (or so) and leave the rest to the rate control? We could entirely remove this check here, and let minstrel only use higher values if VHT is supported (and consequently will be used)?
johannes
Quoted 16 lines · Johannes Berg
Quoted 10 lines · Felix Fietkau
For my own uses, I'd be perfectly fine with limiting A-MSDU size to HT limits even when using VHT - in fact I did that in an early RFC patch. I mainly relaxed the limit for VHT based on Emmanuel's feedback. I also have doubts about the value of A-MSDU size beyond 4095 bytes.
Just let me know which way you'd like it, and I'll send v3 accordingly.
I don't really know, I can live with both ways. I'm just a bit worried that we make enabling this feature so complex that nobody will get it right.
Quoted 5 lines
Perhaps we could also just remove this, make the default for
max_rc_amsdu_lenbe 4095 (or so) and leave the rest to the rate control? We could entirely remove this check here, and let minstrel only use higher values if VHT is supported (and consequently will be used)?
Yeah, that makes sense.
- Felix