net: airoha: MT7996 NPU firmware does not implement flow stats setup
Zhaowei Wang
march_happy at outlook.com
Thu Dec 3 03:27:55 PST 2026
Hi Lorenzo,
I'm trying to get per-flow packet/byte counters for hardware-offloaded
traffic on a Gemtek W1700K (AN7581 + MT7996), so that nlbwmon can
account for it. With CONFIG_NET_AIROHA_FLOW_STATS=y, the NPU rejects
PPE_FUNC_SET_WAIT_FLOW_STATS_SETUP, airoha_npu_ppe_stats_setup()
returns -EINVAL and airoha_ppe_offload_setup() gives up, so PPE offload
never starts.
It then keeps retrying. eth->npu is only set when setup succeeds, so
airoha_ppe_setup_tc_block_cb() runs the whole setup again for every
flow command it gets, FLOW_CLS_STATS included. nf_flowtable leaves
NF_FLOW_HW set on flows whose offload failed, so its gc sends a stats
request for each of them every second, and flow_offload_refresh()
requeues FLOW_CLS_REPLACE while packets are flowing. So every active
flow re-runs HWNAT init and the stats request on the NPU about once a
second. The unpatched driver does this silently. I added a dev_warn()
at the failure point, and dmesg filled up with this warning from
airoha-npu 1e900000.npu:
NPU flow statistics setup failed: -22; PPE offload setup aborted
The firmware is the unmodified MT7996 pair from linux-firmware
(SHA-256):
airoha/en7581_MT7996_npu_rv32.bin
e743d1b59a9ca6d043e38ff71075e8d28702a104b94abb17a4035514efda4643
airoha/en7581_MT7996_npu_data.bin
61a75afb052feed2ceb2f3023e16f50317c05c78f9c8e564bf01924ce39c7ec1
Neither file has changed since commit 1043c0303910 ("linux-firmware:
Add firmware for airoha-npu-7581 driver used for MT7990 offloading"),
so this is the current MT7996 firmware, not an old one.
To find out why the request is rejected, I disassembled the firmware.
The PPE set dispatcher (rv32 offset 0x60a8) sends command 4 to
0x84005df2, and this is the whole handler:
5df2: 4501 li a0, 0
5df4: 8082 ret
The dispatcher treats a zero return as failure, so this command fails
whatever the request contains. I also checked whether stats setup had
moved to another command ID. It hasn't: the dispatcher only accepts
IDs 1-5 (1 and 2 are HWNAT init/deinit, 3 is the SRAM entry API, 5
only prints "L4S not support!!!"), and none of them takes a counter
buffer.
The generic EN7581 firmware (the one used with MT7992) does have a
real command 4 handler. It stores the host counter buffer address,
writes the NPU counter address into the reply and returns success. (I
haven't tried that firmware on the MT7996 board.) So it looks like
flow stats were left out of the MT7996 build.
Is that intentional? If so, is an MT7996 firmware with flow stats
support planned, and would it need driver or ABI changes?
In the v4 thread for "net: airoha: keep PPE offload when NPU refuses
flow stats" [1], the question came up whether firmware without flow
stats is just old firmware or something Airoha ships. The MT7996
firmware is the second case: it is the newest file for this chip, and
its flow stats setup is a stub. I've Cc'd Chad and Sayantan, who
wrote that patch.
That patch would let setup carry on past the refusal and set eth->npu,
which would also end the retry loop. But the offloaded traffic would
still have no counters, and counters are what I need. Separately, any
other setup error that doesn't go away would still cause the same
per-flow retries, so some kind of backoff might be worth having.
For now I've rebuilt without CONFIG_NET_AIROHA_FLOW_STATS, and I keep
hardware flow offload disabled when I need accurate accounting.
Setup:
- Gemtek W1700K, AN7581 + MT7996
- self-built ImmortalWrt snapshot r38159-4765b65762, Linux 6.18.60
- mt76 at 0936617dc529
- local patches: the debug patch above (the dev_warn() plus a
zero-address check, both after the mailbox call returns) and a
port of MediaTek's CSI vendor command for mt7996
I haven't tried a mainline kernel. The firmware handler ignores the
request fields, so I'd expect the same result there. I can send the
kernel config and the local patches if they would help.
[1] https://lore.kernel.org/r/20261021100423.9159-1-sayantann11@gmail.com
Thanks,
Zhaowei Wang
More information about the linux-arm-kernel
mailing list