wifi: mt76: mt7996: guard tx_retries against TXFREE count=0#1069
Open
rchen14b wants to merge 1 commit intoopenwrt:masterfrom
Open
wifi: mt76: mt7996: guard tx_retries against TXFREE count=0#1069rchen14b wants to merge 1 commit intoopenwrt:masterfrom
rchen14b wants to merge 1 commit intoopenwrt:masterfrom
Conversation
In mt7996_mac_tx_free(), the tx_retries calculation unconditionally subtracts 1 from the MT_TXFREE_INFO_COUNT field. When the count is 0, which occurs with NPU/WED WiFi offload (offloaded packets don't always generate TXFREE entries with valid counts), this causes an unsigned integer underflow producing bogus values like 4294967295. These corrupted counters accumulate in wcid->stats.tx_retries and propagate to userspace via iw station dump, making retry statistics meaningless when NPU offload is active. Fix by extracting the count into a local variable and checking it before the subtraction. Signed-off-by: Ryan Chen <rchen14b@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In mt7996_mac_tx_free(), tx_retries is calculated as
FIELD_GET(MT_TXFREE_INFO_COUNT, info) - 1. When count is 0 (which
happens with NPU/WED WiFi offload), this underflows to ~4 billion
and corrupts wcid->stats.tx_retries.
Fix by checking count before subtracting.
Seen on Airoha AN7581 with NPU WiFi offload active — iw station dump
shows bogus retry counts in the billions. Same issue would affect any
mt7996 device using WED offload where TXFREE entries arrive with
count=0.