From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, toke@kernel.org
Subject: [PATCH v2 2/4] mac80211: improve AQL tx time estimation
Date: Sat, 11 Jun 2022 22:01:04 +0200 [thread overview]
Message-ID: <20220611200106.34319-2-nbd@nbd.name> (raw)
In-Reply-To: <20220611200106.34319-1-nbd@nbd.name>
If airtime cannot be calculated because of missing or unsupported rate info,
use the smallest possible non-zero value for estimated tx time.
This improves handling of these cases by preventing queueing of as many packets
as the driver/hardware queue can hold for these stations.
Also slightly improve limiting queueing by explicitly rounding up small values.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
include/net/mac80211.h | 18 +++++++++++-------
net/mac80211/status.c | 2 ++
net/mac80211/tx.c | 13 ++++++-------
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ebadb2103968..d8c4d49bcc49 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1127,20 +1127,24 @@ struct ieee80211_tx_info {
};
};
+#define IEEE80211_TX_TIME_EST_UNIT 4
+
+static inline u16
+ieee80211_info_get_tx_time_est(struct ieee80211_tx_info *info)
+{
+ return info->tx_time_est * IEEE80211_TX_TIME_EST_UNIT;
+}
+
static inline u16
ieee80211_info_set_tx_time_est(struct ieee80211_tx_info *info, u16 tx_time_est)
{
/* We only have 10 bits in tx_time_est, so store airtime
* in increments of 4us and clamp the maximum to 2**12-1
*/
- info->tx_time_est = min_t(u16, tx_time_est, 4095) >> 2;
- return info->tx_time_est << 2;
-}
+ tx_time_est = DIV_ROUND_UP(tx_time_est, IEEE80211_TX_TIME_EST_UNIT);
+ info->tx_time_est = min_t(u16, tx_time_est, BIT(10) - 1);
-static inline u16
-ieee80211_info_get_tx_time_est(struct ieee80211_tx_info *info)
-{
- return info->tx_time_est << 2;
+ return ieee80211_info_get_tx_time_est(info);
}
/***
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index e69272139437..cea053d89dbb 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -1014,6 +1014,8 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
NULL,
skb->len,
false);
+ if (!airtime)
+ airtime = IEEE80211_TX_TIME_EST_UNIT;
ieee80211_register_airtime(txq, airtime, 0);
}
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 0e4efc08c762..ecb3975680bc 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3797,13 +3797,12 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta,
skb->len, ampdu);
- if (airtime) {
- airtime = ieee80211_info_set_tx_time_est(info, airtime);
- ieee80211_sta_update_pending_airtime(local, tx.sta,
- txq->ac,
- airtime,
- false);
- }
+ if (!airtime)
+ airtime = IEEE80211_TX_TIME_EST_UNIT;
+
+ airtime = ieee80211_info_set_tx_time_est(info, airtime);
+ ieee80211_sta_update_pending_airtime(local, tx.sta, txq->ac,
+ airtime, false);
}
return skb;
--
2.36.1
next prev parent reply other threads:[~2022-06-11 20:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-11 20:01 [PATCH v2 1/4] mac80211: fix overflow issues in airtime fairness code Felix Fietkau
2022-06-11 20:01 ` Felix Fietkau [this message]
2022-06-11 20:01 ` [PATCH v2 3/4] mac80211: fix ieee80211_txq_may_transmit regression Felix Fietkau
2022-06-11 20:01 ` [PATCH v2 4/4] mac80211: rework the airtime fairness implementation Felix Fietkau
2022-06-18 8:51 ` [PATCH v2 1/4] mac80211: fix overflow issues in airtime fairness code Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220611200106.34319-2-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=toke@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox