Message ID | 156889576646.191202.14461472477971784776.stgit@alrua-x1 (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Johannes Berg |
Headers | show |
Series | Add Airtime Queue Limits (AQL) to mac80211 | expand |
On Thu, 2019-09-19 at 14:22 +0200, Toke Høiland-Jørgensen wrote: Given a ULL constant: > +/* constants for calculating reciprocals to avoid division in fast path */ > +#define IEEE80211_RECIPROCAL_DIVISOR 0x100000000ULL [...] > +void ieee80211_sta_set_last_tx_bitrate(struct ieee80211_sta *pubsta, > + u32 rate) > +{ > + struct sta_info *sta = container_of(pubsta, struct sta_info, sta); > + > + sta->last_tx_bitrate = rate; > + sta->last_tx_bitrate_reciprocal = ((u64)IEEE80211_RECIPROCAL_DIVISOR / rate); that cast seems unnecessary? johannes
Johannes Berg <johannes@sipsolutions.net> writes: > On Thu, 2019-09-19 at 14:22 +0200, Toke Høiland-Jørgensen wrote: > > Given a ULL constant: > >> +/* constants for calculating reciprocals to avoid division in fast path */ >> +#define IEEE80211_RECIPROCAL_DIVISOR 0x100000000ULL > > [...] > >> +void ieee80211_sta_set_last_tx_bitrate(struct ieee80211_sta *pubsta, >> + u32 rate) >> +{ >> + struct sta_info *sta = container_of(pubsta, struct sta_info, sta); >> + >> + sta->last_tx_bitrate = rate; >> + sta->last_tx_bitrate_reciprocal = ((u64)IEEE80211_RECIPROCAL_DIVISOR / rate); > > that cast seems unnecessary? Yeah. I only remembered to make it a ULL constant later, and forgot to remove the cast. But I guess this should be using do_div() anyway... -Toke
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index b12d378621b0..1b7f4a370122 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -4529,6 +4529,16 @@ void ieee80211_get_tx_rates(struct ieee80211_vif *vif, void ieee80211_sta_set_expected_throughput(struct ieee80211_sta *pubsta, u32 thr); +/** + * ieee80211_sta_set_last_tx_bitrate - set last tx rate for station + * + * This sets the last TX bitrate for a given station. + * + * @sta: Pointer to the station + * @bitrate: Bitrate in kbps + */ +void ieee80211_sta_set_last_tx_bitrate(struct ieee80211_sta *sta, u32 bitrate); + /** * ieee80211_tx_rate_update - transmit rate update callback * diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 05406e9c05b3..9de5390411ba 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -59,6 +59,10 @@ struct ieee80211_local; /* power level hasn't been configured (or set to automatic) */ #define IEEE80211_UNSET_POWER_LEVEL INT_MIN +/* constants for calculating reciprocals to avoid division in fast path */ +#define IEEE80211_RECIPROCAL_DIVISOR 0x100000000ULL +#define IEEE80211_RECIPROCAL_SHIFT 32 + /* * Some APs experience problems when working with U-APSD. Decreasing the * probability of that happening by using legacy mode for all ACs but VO isn't diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index df553070206c..aae878ffe94c 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2481,3 +2481,12 @@ void ieee80211_sta_set_expected_throughput(struct ieee80211_sta *pubsta, sta_update_codel_params(sta, thr); } + +void ieee80211_sta_set_last_tx_bitrate(struct ieee80211_sta *pubsta, + u32 rate) +{ + struct sta_info *sta = container_of(pubsta, struct sta_info, sta); + + sta->last_tx_bitrate = rate; + sta->last_tx_bitrate_reciprocal = ((u64)IEEE80211_RECIPROCAL_DIVISOR / rate); +} diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 369c2dddce52..dd1a0b87f234 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -617,6 +617,8 @@ struct sta_info { const struct ieee80211_cipher_scheme *cipher_scheme; struct codel_params cparams; + u32 last_tx_bitrate; + u64 last_tx_bitrate_reciprocal; u8 reserved_tid;