From eb19154b866bff2bc4645cc133dd71952088f5ac Mon Sep 17 00:00:00 2001 From: adrian Date: Mon, 28 Sep 2015 00:17:51 +0000 Subject: [PATCH] Abstract out the ampdu TX pps initialisation code so it can be reused in the superg fast-frames code. This harks back to an earlier commit (r280349) where I found that initialising the pps code with ticks=0 would cause hilariously bad hz ticks wraparound failures, leading to never actually aggregating traffic. This is still true for the superg path and so I have to do the same thing there. This is a big no-op; a subsequent commit will flip this on so it works with the fast-frames transmit path. Tested: * AR9170, otus(4) - STA mode, 11bg operation * AR9331, AP mode --- sys/net80211/ieee80211_ht.c | 7 +++---- sys/net80211/ieee80211_ht.h | 12 ++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c index b43bc075472f..a850a334ea20 100644 --- a/sys/net80211/ieee80211_ht.c +++ b/sys/net80211/ieee80211_ht.c @@ -1081,7 +1081,7 @@ ieee80211_ht_node_init(struct ieee80211_node *ni) tap = &ni->ni_tx_ampdu[tid]; tap->txa_tid = tid; tap->txa_ni = ni; - tap->txa_lastsample = ticks; + ieee80211_txampdu_init_pps(tap); /* NB: further initialization deferred */ } ni->ni_flags |= IEEE80211_NODE_HT | IEEE80211_NODE_AMPDU; @@ -1251,7 +1251,7 @@ ieee80211_ht_wds_init(struct ieee80211_node *ni) for (tid = 0; tid < WME_NUM_TID; tid++) { tap = &ni->ni_tx_ampdu[tid]; tap->txa_tid = tid; - tap->txa_lastsample = ticks; + ieee80211_txampdu_init_pps(tap); } /* NB: AMPDU tx/rx governed by IEEE80211_FHT_AMPDU_{TX,RX} */ ni->ni_flags |= IEEE80211_NODE_HT | IEEE80211_NODE_AMPDU; @@ -1752,8 +1752,7 @@ ampdu_tx_stop(struct ieee80211_tx_ampdu *tap) /* * Reset packet estimate. */ - tap->txa_lastsample = ticks; - tap->txa_avgpps = 0; + ieee80211_txampdu_init_pps(tap); /* NB: clearing NAK means we may re-send ADDBA */ tap->txa_flags &= ~(IEEE80211_AGGR_SETUP | IEEE80211_AGGR_NAK); diff --git a/sys/net80211/ieee80211_ht.h b/sys/net80211/ieee80211_ht.h index f099ffe77464..e2b331854dff 100644 --- a/sys/net80211/ieee80211_ht.h +++ b/sys/net80211/ieee80211_ht.h @@ -83,9 +83,20 @@ struct ieee80211_tx_ampdu { * available and more streams are requested than available. */ +static __inline void +ieee80211_txampdu_init_pps(struct ieee80211_tx_ampdu *tap) +{ + /* + * Reset packet estimate. + */ + tap->txa_lastsample = ticks; + tap->txa_avgpps = 0; +} + static __inline void ieee80211_txampdu_update_pps(struct ieee80211_tx_ampdu *tap) { + /* NB: scale factor of 2 was picked heuristically */ tap->txa_avgpps = ((tap->txa_avgpps << 2) - tap->txa_avgpps + tap->txa_pkts) >> 2; @@ -97,6 +108,7 @@ ieee80211_txampdu_update_pps(struct ieee80211_tx_ampdu *tap) static __inline void ieee80211_txampdu_count_packet(struct ieee80211_tx_ampdu *tap) { + /* XXX bound loop/do more crude estimate? */ while (ticks - tap->txa_lastsample >= hz) { ieee80211_txampdu_update_pps(tap);