From: Peter Seiderer <ps.report@gmx.net>
To: "Toke Høiland-Jørgensen" <toke@toke.dk>
Cc: Kalle Valo <kvalo@codeaurora.org>,
linux-wireless@vger.kernel.org,
Bagas Sanjaya <bagasdotme@gmail.com>
Subject: Re: [PATCH v5.18] ath9k: Properly clear TX status area before reporting to mac80211
Date: Fri, 1 Apr 2022 19:26:57 +0200 [thread overview]
Message-ID: <20220401192657.16674bf7@gmx.net> (raw)
In-Reply-To: <20220330164409.16645-1-toke@toke.dk>
Hello Toke,
On Wed, 30 Mar 2022 18:44:09 +0200, Toke Høiland-Jørgensen <toke@toke.dk> wrote:
> The ath9k driver was not properly clearing the status area in the
> ieee80211_tx_info struct before reporting TX status to mac80211. Instead,
> it was manually filling in fields, which meant that fields introduced later
> were left as-is.
>
> Conveniently, mac80211 actually provides a helper to zero out the status
> area, so use that to make sure we zero everything.
>
> The last commit touching the driver function writing the status information
> seems to have actually been fixing an issue that was also caused by the
> area being uninitialised; but it only added clearing of a single field
> instead of the whole struct. That is now redundant, though, so revert that
> commit and use it as a convenient Fixes tag.
>
> Fixes: cc591d77aba1 ("ath9k: Make sure to zero status.tx_time before reporting TX status")
> Reported-by: Bagas Sanjaya <bagasdotme@gmail.com>
> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
> ---
> drivers/net/wireless/ath/ath9k/xmit.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
> index d0caf1de2bde..cbcf96ac303e 100644
> --- a/drivers/net/wireless/ath/ath9k/xmit.c
> +++ b/drivers/net/wireless/ath/ath9k/xmit.c
> @@ -2553,6 +2553,8 @@ static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,
> struct ath_hw *ah = sc->sc_ah;
> u8 i, tx_rateindex;
>
> + ieee80211_tx_info_clear_status(tx_info);
> +
As this also clears the status.rates[].count, see include/net/mac80211.h:
1195 static inline void
1196 ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
1197 {
1198 int i;
1199
1200 BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
1201 offsetof(struct ieee80211_tx_info, control.rates));
1202 BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
1203 offsetof(struct ieee80211_tx_info, driver_rates));
1204 BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != 8) ;
1205 /* clear the rate counts */
1206 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
1207 info->status.rates[i].count = 0;
1208 memset_after(&info->status, 0, rates);
1209 }
I would have expected some lines added to restore the count (for the
rates with index < tx_rateindex), e.g. as done in
drivers/net/wireless/ath/ath5k/base.c:
1731 ieee80211_tx_info_clear_status(info);
1732
1733 for (i = 0; i < ts->ts_final_idx; i++) {
1734 struct ieee80211_tx_rate *r =
1735 &info->status.rates[i];
1736
1737 r->count = tries[i];
1738 }
In drivers/net/wireless/ath/ath9k/xmit.c this is only done/changed for
the tx_rateindex index (which is often zero in case the first suggested rate
succeeds, but in noisy environment is sometimes > 0)...
> if (txok)
> tx_info->status.ack_signal = ts->ts_rssi;
>
> @@ -2595,9 +2597,6 @@ static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,
> }
>
> tx_info->status.rates[)].count = ts->ts_longretry + 1;
> -
> - /* we report airtime in ath_tx_count_airtime(), don't report twice */
> - tx_info->status.tx_time = 0;
> }
>
> static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
And from drivers/net/wireless/ath/ath9k/xmit.c:
2592 for (i = tx_rateindex + 1; i < hw->max_rates; i++) {
2593 tx_info->status.rates[i].count = 0;
2594 tx_info->status.rates[i].idx = -1;
2595 }
Line 2593 can be deleted as status.rates[].count is already zeroed through the
ieee80211_tx_info_clear_status() call...
And it should be sufficient to do:
if (tx_rateindex + 1 < hw->max_rates)
tx_info->status.rates[tx_rateindex + 1].idx = -1;
Regards,
Peter
next prev parent reply other threads:[~2022-04-01 17:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 16:44 [PATCH v5.18] ath9k: Properly clear TX status area before reporting to mac80211 Toke Høiland-Jørgensen
2022-03-31 5:06 ` Bagas Sanjaya
2022-03-31 5:18 ` Bagas Sanjaya
2022-03-31 5:36 ` Kalle Valo
2022-03-31 8:35 ` Toke Høiland-Jørgensen
2022-03-31 9:31 ` Kalle Valo
2022-04-01 6:37 ` [v5.18] " Kalle Valo
2022-04-01 17:26 ` Peter Seiderer [this message]
2022-04-02 12:00 ` [PATCH v5.18] " Toke Høiland-Jørgensen
2022-04-02 14:33 ` Peter Seiderer
2022-04-02 15:11 ` Toke Høiland-Jørgensen
2022-04-02 16:19 ` Peter Seiderer
2022-04-04 11:04 ` Peter Seiderer
2022-04-04 16:03 ` Toke Høiland-Jørgensen
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=20220401192657.16674bf7@gmx.net \
--to=ps.report@gmx.net \
--cc=bagasdotme@gmail.com \
--cc=kvalo@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
--cc=toke@toke.dk \
/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;
as well as URLs for NNTP newsgroup(s).