From: Lorenzo Bianconi <lorenzo@kernel.org>
To: SAYANTAN NANDY <sayantann11@gmail.com>
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, bread.hsu@airoha.com,
sayantan.nandy@airoha.com
Subject: Re: [PATCH net v3] net: airoha: keep PPE offload when NPU refuses flow stats
Date: Thu, 15 Oct 2026 09:44:09 +0200 [thread overview]
Message-ID: <atCESCD8aDoR32nW@lore-desk> (raw)
In-Reply-To: <20261015045607.12999-1-sayantann11@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5349 bytes --]
> From: Chad Monroe <chad@monroe.io>
>
> With flow stats enabled, PPE offload setup requests flow statistics
> from the NPU. If the running NPU firmware does not support flow
> counters, the request fails and the current setup path aborts PPE
> offload.
>
> Treat flow statistics as an optional capability so that a failure to
> set up the counters does not prevent normal PPE offload. Continue PPE
> initialization when the NPU refuses the flow-statistics request.
>
> Also treat a zero NPU statistics address returned by the firmware as a
> refusal. The host-side DMA buffer (foe_stats_dma) is allocated by
> dmam_alloc_coherent() in airoha_ppe_init() from system memory. The NPU
> statistics address (npu_stats_addr) is a separate allocation from the
> NPU firmware's internal SRAM pool. When that pool is exhausted, the
> firmware replies with success and npu_stats_addr = 0. A zero address
> does not provide a usable counter region and must not be passed to
> devm_ioremap().
>
> When flow stats entries are available, clear PSE_PORT6_SHARE_DIS so
> that PSE port 6 (CDM3 path to the NPU) participates in shared-buffer
> flow control. PSE_FC_CFG bits 26:16 control per-port whether flow
> control considers the shared buffer pool. Bit 22 is port 6.
>
> When flow statistics are unavailable, PPE continues to operate without
> NPU flow counters while retaining normal offload functionality.
>
> This combines the original SmartRG/Airoha fixes for:
> - keeping PPE offload active when the NPU refuses flow statistics
> - treating a zero NPU statistics address as a flow-statistics refusal
>
> Based on the original SmartRG/Airoha work by Chad Monroe:
> 5ce96ab ("SDG-9458: keep PPE offload when NPU refuses flow stats")
> 0ad8528 ("SDG-9458: airoha: treat a zero NPU stats address as a refusal")
> Fixes: b81e0f2b58be ("net: airoha: Add FLOW_CLS_STATS callback support")
> Tested-on: AN7581 with MT7992
> Signed-off-by: Chad Monroe <chad@monroe.io>
> Signed-off-by: SAYANTAN NANDY <sayantann11@gmail.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>
> Changes since v2:
> - Drop flow_stats_cap entirely (Lorenzo).
> - Keep the original airoha_ppe_get_num_stats_entries() checks (Lorenzo).
> - Guard airoha_fe_clear() with sram_num_stats_entries > 0 (Lorenzo).
> - Replace the error assignment and goto with a direct if check and
> dev_warn() (Lorenzo).
>
> Changes since v1:
> - Explain the NPU SRAM allocation separately from the host-side DMA
> buffer (Lorenzo).
> - Use airoha_fe_clear() and shorten the warning message (Lorenzo).
> - Include hardware testing information requested by netdev-bot.
>
> drivers/net/ethernet/airoha/airoha_npu.c | 8 ++++++++
> drivers/net/ethernet/airoha/airoha_ppe.c | 10 ++++++----
> drivers/net/ethernet/airoha/airoha_regs.h | 2 ++
> 3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
> index 4d3195eb00f7..b32a01dbe06b 100644
> --- a/drivers/net/ethernet/airoha/airoha_npu.c
> +++ b/drivers/net/ethernet/airoha/airoha_npu.c
> @@ -450,6 +450,14 @@ static int airoha_npu_ppe_stats_setup(struct airoha_npu *npu,
> if (err)
> goto out;
>
> + /* The firmware reports success with a zero address when its SRAM
> + * pool has no room left for the counters.
> + */
> + if (!ppe_data->stats_info.npu_stats_addr) {
> + err = -ENOSPC;
> + goto out;
> + }
> +
> npu->stats = devm_ioremap(npu->dev,
> ppe_data->stats_info.npu_stats_addr,
> size);
> diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
> index 92611802801e..74ac3791cb63 100644
> --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> @@ -144,6 +144,9 @@ static void airoha_ppe_hw_init(struct airoha_ppe *ppe)
> sram_ppe_num_data_entries =
> PPE_RAM_NUM_ENTRIES_SHIFT(sram_ppe_num_data_entries);
>
> + if (sram_num_stats_entries > 0)
> + airoha_fe_clear(eth, PSE_FC_CFG, PSE_PORT6_SHARE_DIS);
> +
> for (i = 0; i < eth->soc->num_ppe; i++) {
> airoha_fe_wr(eth, REG_PPE_TB_BASE(i),
> ppe->foe_dma + sram_tb_size);
> @@ -1454,10 +1457,9 @@ static int airoha_ppe_offload_setup(struct airoha_eth *eth)
>
> ppe_num_stats_entries = airoha_ppe_get_total_num_stats_entries(ppe);
> if (ppe_num_stats_entries > 0) {
> - err = npu->ops.ppe_init_stats(npu, ppe->foe_stats_dma,
> - ppe_num_stats_entries);
> - if (err)
> - goto error_npu_put;
> + if (npu->ops.ppe_init_stats(npu, ppe->foe_stats_dma,
> + ppe_num_stats_entries))
> + dev_warn(eth->dev, "NPU refused flow stats\n");
> }
>
> airoha_ppe_hw_init(ppe);
> diff --git a/drivers/net/ethernet/airoha/airoha_regs.h b/drivers/net/ethernet/airoha/airoha_regs.h
> index 442b48c9b991..aee06c058586 100644
> --- a/drivers/net/ethernet/airoha/airoha_regs.h
> +++ b/drivers/net/ethernet/airoha/airoha_regs.h
> @@ -72,6 +72,8 @@
> #define PSE_CFG_OQ_RSV_MASK GENMASK(13, 0)
>
> #define PSE_FQ_CFG 0x008c
> +#define PSE_FC_CFG 0x0098
> +#define PSE_PORT6_SHARE_DIS BIT(22)
> #define PSE_FQ_LIMIT_MASK GENMASK(14, 0)
>
> #define REG_FE_PSE_BUF_SET 0x0090
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2026-10-15 7:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 9:48 [PATCH net] net: airoha: keep PPE offload when NPU refuses flow stats SAYANTAN NANDY
2026-10-08 9:55 ` netdev-bot+sinfo
2026-10-08 10:44 ` Lorenzo Bianconi
2026-10-09 5:03 ` [PATCH net v2] " SAYANTAN NANDY
2026-10-09 7:44 ` Lorenzo Bianconi
2026-10-10 5:33 ` netdev-bot+sashiko
2026-10-12 10:05 ` [PATCH net] " netdev-bot+sashiko
2026-10-15 4:56 ` [PATCH net v3] " SAYANTAN NANDY
2026-10-15 7:44 ` Lorenzo Bianconi [this message]
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=atCESCD8aDoR32nW@lore-desk \
--to=lorenzo@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bread.hsu@airoha.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=sayantan.nandy@airoha.com \
--cc=sayantann11@gmail.com \
/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