Skip to content

wifi: mt76: mt7996: guard tx_retries against TXFREE count=0#1069

Open
rchen14b wants to merge 1 commit intoopenwrt:masterfrom
rchen14b:fix-tx-retries-underflow
Open

wifi: mt76: mt7996: guard tx_retries against TXFREE count=0#1069
rchen14b wants to merge 1 commit intoopenwrt:masterfrom
rchen14b:fix-tx-retries-underflow

Conversation

@rchen14b
Copy link

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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant