mac80211: add A-MSDU tx support
PATCH 1/2 mac80211: add A-MSDU tx support
Requires software tx queueing support. frag_list support (for zero-copy) is optional.
--- include/net/mac80211.h | 15 ++++ net/mac80211/agg-tx.c | 5 ++ net/mac80211/debugfs.c | 2 + net/mac80211/ieee80211_i.h | 1 + net/mac80211/tx.c | 167 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 190 insertions(+)
include/net/mac80211.h +15 -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), };/*
@@ -1731,6 +1733,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 {
@@ -1751,6 +1754,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 ];
@@ -1964,6 +1968,12 @@ 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 support. +* +* @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 {
@@ -2001,6 +2011,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
@@ -2073,6 +2085,8 @@ 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 fragments per (A-)MSDU. +* * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX * (if %IEEE80211_HW_QUEUE_CONTROL is set) *
@@ -2127,6 +2141,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
@@ -799,6 +799,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 +167 -0
185 lines not on this page · raw message
Signature · 1 line
2.2.2
PATCH 2/2 mac80211: minstrel_ht: set A-MSDU tx limits based on selected max_prob_rate
Prevents 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
Johannes Berg
maintainerQuoted 2 lines · Felix Fietkau
Requires software tx queueing support.
frag_listsupport (for zero- copy) is optional.
"optional" ;-)
include/net/mac80211.h struct ieee80211_sta { · line 1757
Quoted 5 lines
include/net/mac80211.h +1
-0@@ -1751,6 +1754,7 @@ struct ieee80211_sta { bool mfp; u8 max_amsdu_subframes; u16 max_amsdu_len; +u16 max_rc_amsdu_len;
I may have missed this, but I didn't see you initialize this to something. I think that's probably a bad idea, since you've now created a situation in which a driver wanting to use txq support needs to also use minstrel or update this field...
Apart from that, I'm not sure that having a field here that works like this is a good idea at all - all the other fields in the vicinity kinda go from mac80211 to the driver, where here you have something that potentially goes from the driver to mac80211. Perhaps we can find a better way of doing this?
Quoted 3 lines
(quoted diff) +1
-0+ * @IEEE80211_HW_TX_AMSDU: Hardware (or driver) supports softwareaggregated
+ * A-MSDU frames. Requires software tx queueing support.
Or at least document that it also requires integration with the max_rc_amsdu_len thing.
Quoted 1 line
+ * @max_tx_fragments: maximum fragments per (A-)MSDU.
"fragments" is a bit unclear - I guess this should refer to fraglist length only? Or is it meant to apply as a limit to the sum of pieces in the fraglist? I think that should be clarified.
Quoted 4 lines
net/mac80211/agg-tx.c +3
-0+ txq = sta->sta.txq[tid]; +if (!amsdu && txq) + set_bit(IEEE80211_TXQ_NO_AMSDU, &to_txq_info(txq)-Quoted 1 line
flags);
Did you intentionally not clear this on aggregation stop?
Quoted 6 lines
(quoted diff) +1
-0+ if (skb_headroom(skb) < sizeof(amsdu_hdr) ||
skb_tailroom(skb)< 3) {net/mac80211/tx.c +3
-0+I802_DEBUG_INC (local->tx_expand_skb_head); + + if (pskb_expand_head(skb, sizeof(amsdu_hdr), 3,
GFP_ATOMIC)) {
You should be able to precalculate the amount of padding needed based on the length of the skb, so why statically use 3 here?
net/mac80211/tx.c void ieee80211_clear_fast_xmit(struct sta_info *sta) · line 2904
Quoted 4 lines
net/mac80211/tx.c +4
-0+if (skb_headroom (skb) <8 ||skb_tailroom (skb) <3 ) { +I802_DEBUG_INC (local->tx_expand_skb_head); + +if (pskb_expand_head (skb,8 ,3 ,GFP_ATOMIC )) {
similarly here? Where does the 8 come from?
net/mac80211/tx.c static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, · line 2988
Quoted 9 lines
(quoted diff) +0
-0@@ -2820,6 +2983,10 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
ieee80211_tx_stats(dev, skb->len + extra_head);(quoted diff) +1
-0+ if ((hdr->frame_control &
cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) &&net/mac80211/tx.c +2
-0+ ieee80211_amsdu_aggregate(sdata, sta, fast_tx, skb)) +return true;
Only on xmit_fast?
johannes
Quoted 6 lines · Johannes Berg
Quoted 2 lines · Felix Fietkau
Requires software tx queueing support.
frag_listsupport (for zero- copy) is optional."optional" ;-)
Quoted 10 lines
include/net/mac80211.h struct ieee80211_sta { · line 1757
Quoted 5 lines
include/net/mac80211.h +1
-0@@ -1751,6 +1754,7 @@ struct ieee80211_sta {bool mfp;u8 max_amsdu_subframes;u16 max_amsdu_len; +u16 max_rc_amsdu_len;I may have missed this, but I didn't see you initialize this to something. I think that's probably a bad idea, since you've now created a situation in which a driver wanting to use txq support needs to also use minstrel or update this field...
It's initialized to 0 by default, in which case it does not limit the A-MSDU size. The driver does not need to set it, but it really should.
Quoted 5 lines
Apart from that, I'm not sure that having a field here that works like this is a good idea at all - all the other fields in the vicinity kinda go from mac80211 to the driver, where here you have something that potentially goes from the driver to mac80211. Perhaps we can find a better way of doing this?
Didn't find a better place to put it. Got any ideas?
Quoted 6 lines
Quoted 3 lines
(quoted diff) +1
-0+ * @IEEE80211_HW_TX_AMSDU: Hardware (or driver) supports softwareaggregated
+ * A-MSDU frames. Requires software tx queueing support.Or at least document that it also requires integration with the
max_rc_amsdu_lenthing.
Will do.
Quoted 5 lines
Quoted 1 line
+ * @max_tx_fragments: maximum fragments per (A-)MSDU.
"fragments" is a bit unclear - I guess this should refer to fraglist length only? Or is it meant to apply as a limit to the sum of pieces in the fraglist? I think that should be clarified.
Sum of 1 (head) + n_frags for each skb in the fraglist.
Quoted 6 lines
Quoted 4 lines
net/mac80211/agg-tx.c +3
-0+ txq = sta->sta.txq[tid]; +if (!amsdu && txq) + set_bit(IEEE80211_TXQ_NO_AMSDU, &to_txq_info(txq)-Quoted 1 line
flags);
Did you intentionally not clear this on aggregation stop?
Yes. If A-MSDU in A-MPDU is not supported, dealing with starting and stopping of A-MPDU sessions leaves all kinds of nasty corner cases (since the txq is not flushed between sessions). In that case it's better to just leave it disabled from that point on.
Quoted 9 lines
Quoted 6 lines
(quoted diff) +1
-0+ if (skb_headroom(skb) < sizeof(amsdu_hdr) ||
skb_tailroom(skb)< 3) {net/mac80211/tx.c +3
-0+I802_DEBUG_INC (local->tx_expand_skb_head); + + if (pskb_expand_head(skb, sizeof(amsdu_hdr), 3,
GFP_ATOMIC)) {You should be able to precalculate the amount of padding needed based on the length of the skb, so why statically use 3 here?
I guess I forgot to change that after I got the code working.
Quoted 6 lines
net/mac80211/tx.c void ieee80211_clear_fast_xmit(struct sta_info *sta) · line 2904
Quoted 4 lines
net/mac80211/tx.c +4
-0+if (skb_headroom (skb) <8 ||skb_tailroom (skb) <3 ) { +I802_DEBUG_INC (local->tx_expand_skb_head); + +if (pskb_expand_head (skb,8 ,3 ,GFP_ATOMIC )) {similarly here? Where does the 8 come from?
rfc1042_header + A-MSDU length field.
Quoted 11 lines
net/mac80211/tx.c static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, · line 2988
Quoted 9 lines
net/mac80211/tx.c +1
-0@@ -2820,6 +2983,10 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,ieee80211_tx_stats (dev, skb->len + extra_head); + if ((hdr->frame_control &
cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) &&net/mac80211/tx.c +2
-0+ ieee80211_amsdu_aggregate(sdata, sta, fast_tx, skb)) +return true;Only on
xmit_fast?
Yes. I'm relying on fast_tx fields to simplify dealing with headers and to avoid adding extra checks for all kinds of stuff like no software crypto, which ieee80211_check_fast_xmit already handles.
- Felix
Johannes Berg
maintainerQuoted 4 lines · Felix Fietkau
It's initialized to 0 by default, in which case it does not limit the A-MSDU size. The driver does not need to set it, but it really should.
Right, but this is problematic as Emmanuel had pointed out, when scaling down you run into problems. Not sure we want that as the default when the driver doesn't do anything?
Documenting it as we discussed should be good enough though I guess.
Quoted 8 lines
Quoted 7 lines
Apart from that, I'm not sure that having a field here that works like
this is a good idea at all - all the other fields in the vicinity kinda
go from mac80211 to the driver, where here you have something that potentially goes from the driver to mac80211. Perhaps we can find a better way of doing this?Didn't find a better place to put it. Got any ideas?
Not off the top of my head, sorry.
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
+ * @max_tx_fragments: maximum fragments per (A-)MSDU.
"fragments" is a bit unclear - I guess this should refer to fraglist
length only? Or is it meant to apply as a limit to the sum of pieces in
the fraglist? I think that should be clarified.Sum of 1 (head) +
n_fragsfor each skb in the fraglist.
Clarify the comment? :)
Quoted 4 lines
Yes. If A-MSDU in A-MPDU is not supported, dealing with starting and stopping of A-MPDU sessions leaves all kinds of nasty corner cases (since the txq is not flushed between sessions). In that case it's better to just leave it disabled from that point on.
Fair enough. You should be able to deal with it with the SSN, but that might be difficult.
Actually, mac80211 on its own assigns the seqno so frames already on the txq would not become part of the session, so we should be OK without much effort?
Quoted 4 lines
Yes. I'm relying on
fast_txfields to simplify dealing with headers and to avoid adding extra checks for all kinds of stuff like no software crypto, whichieee80211_check_fast_xmitalready handles.
Ok, makes sense.
johannes
Quoted 11 lines · Johannes Berg
Quoted 4 lines
Yes. If A-MSDU in A-MPDU is not supported, dealing with starting and stopping of A-MPDU sessions leaves all kinds of nasty corner cases (since the txq is not flushed between sessions). In that case it's better to just leave it disabled from that point on.
Fair enough. You should be able to deal with it with the SSN, but that might be difficult.
Actually, mac80211 on its own assigns the seqno so frames already on the txq would not become part of the session, so we should be OK without much effort?
seqno is assigned on txq dequeue, not enqueue.
- Felix
Johannes Berg
maintainerQuoted 4 lines · Felix Fietkau
Requires software tx queueing support.
frag_listsupport (for zero- copy)
is optional.
Come to think of it, a commit message that explains what it does and how it works would be nice :)
johannes