From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Simon Horman <horms@kernel.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH net-next 03/12] net: airoha: Add airoha_ppe_get_num_stats_entries() and airoha_ppe_get_num_total_stats_entries()
Date: Thu, 16 Oct 2025 10:10:28 +0200 [thread overview]
Message-ID: <aPCodE0_u94s-w73@lore-desk> (raw)
In-Reply-To: <aO-ZCqsvPQ6Pqjpg@horms.kernel.org>
[-- Attachment #1: Type: text/plain, Size: 3678 bytes --]
> On Wed, Oct 15, 2025 at 09:15:03AM +0200, Lorenzo Bianconi wrote:
> > Introduce airoha_ppe_get_num_stats_entries and
> > airoha_ppe_get_num_total_stats_entries routines in order to make the
> > code more readable controlling if CONFIG_NET_AIROHA_FLOW_STATS is
> > enabled or disabled.
> > Modify airoha_ppe_foe_get_flow_stats_index routine signature relying on
> > airoha_ppe_get_num_total_stats_entries().
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > drivers/net/ethernet/airoha/airoha_eth.h | 10 +--
> > drivers/net/ethernet/airoha/airoha_ppe.c | 103 +++++++++++++++++++++++++------
> > 2 files changed, 86 insertions(+), 27 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h
> > index 4330b672d99e1e190efa5ad75d13fb35e77d070e..1f7e34a5f457ca2200e9c81dd05dc03cd7c5eb77 100644
> > --- a/drivers/net/ethernet/airoha/airoha_eth.h
> > +++ b/drivers/net/ethernet/airoha/airoha_eth.h
> > @@ -50,15 +50,9 @@
> >
> > #define PPE_NUM 2
> > #define PPE1_SRAM_NUM_ENTRIES (8 * 1024)
> > -#define PPE_SRAM_NUM_ENTRIES (2 * PPE1_SRAM_NUM_ENTRIES)
> > -#ifdef CONFIG_NET_AIROHA_FLOW_STATS
> > +#define PPE_SRAM_NUM_ENTRIES (PPE_NUM * PPE1_SRAM_NUM_ENTRIES)
> > #define PPE1_STATS_NUM_ENTRIES (4 * 1024)
> > -#else
> > -#define PPE1_STATS_NUM_ENTRIES 0
> > -#endif /* CONFIG_NET_AIROHA_FLOW_STATS */
> > -#define PPE_STATS_NUM_ENTRIES (2 * PPE1_STATS_NUM_ENTRIES)
> > -#define PPE1_SRAM_NUM_DATA_ENTRIES (PPE1_SRAM_NUM_ENTRIES - PPE1_STATS_NUM_ENTRIES)
> > -#define PPE_SRAM_NUM_DATA_ENTRIES (2 * PPE1_SRAM_NUM_DATA_ENTRIES)
> > +#define PPE_STATS_NUM_ENTRIES (PPE_NUM * PPE1_STATS_NUM_ENTRIES)
> > #define PPE_DRAM_NUM_ENTRIES (16 * 1024)
> > #define PPE_NUM_ENTRIES (PPE_SRAM_NUM_ENTRIES + PPE_DRAM_NUM_ENTRIES)
> > #define PPE_HASH_MASK (PPE_NUM_ENTRIES - 1)
> > diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
> > index 8d1dceadce0becb2b1ce656d64ab77bd3c2f914a..303d31e1da4b723023ee0cc1ca5f6038c16966cd 100644
> > --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> > +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> > @@ -32,6 +32,30 @@ static const struct rhashtable_params airoha_l2_flow_table_params = {
> > .automatic_shrinking = true,
> > };
> >
> > +static int airoha_ppe_get_num_stats_entries(struct airoha_ppe *ppe,
> > + u32 *num_stats)
> > +{
> > +#ifdef CONFIG_NET_AIROHA_FLOW_STATS
> > + *num_stats = PPE1_STATS_NUM_ENTRIES;
> > + return 0;
> > +#else
> > + return -EOPNOTSUPP;
> > +#endif /* CONFIG_NET_AIROHA_FLOW_STATS */
> > +}
>
> Hi Lorenzo,
Hi Simon,
>
> I think that in general using IS_ENABLED is preferred over #ifdef
> in cases where the former can be used. For one thing it improves compile
> coverage.
>
> That does seem applicable here, so I'm wondering if
> we can do something like the following.
> (Compile tested only!)
>
> static int airoha_ppe_get_num_stats_entries(struct airoha_ppe *ppe,
> u32 *num_stats)
> {
> if (!IS_ENABLED(CONFIG_NET_AIROHA_FLOW_STATS))
> return -EOPNOTSUPP;
>
> *num_stats = PPE1_STATS_NUM_ENTRIES;
> return 0;
> }
ack, fine. I will fix it in v2.
>
> Also, very subjectively, I might have returned num_stats as
> a positive return value. I'm assuming it's value will never overflow an int.
> Likewise elsewhere.
>
> But that's just my idea. Feel free to stick with the current scheme.
I guess it is fine. I will fix it in v2.
Regards,
Lorenzo
>
> ...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-10-16 8:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 7:15 [PATCH net-next 00/12] net: airoha: Add AN7583 ethernet controller support Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 01/12] dt-bindings: net: airoha: Add AN7583 support Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 02/12] net: airoha: ppe: Dynamically allocate foe_check_time array in airoha_ppe struct Lorenzo Bianconi
2025-10-15 16:06 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 03/12] net: airoha: Add airoha_ppe_get_num_stats_entries() and airoha_ppe_get_num_total_stats_entries() Lorenzo Bianconi
2025-10-15 12:52 ` Simon Horman
2025-10-16 8:10 ` Lorenzo Bianconi [this message]
2025-10-15 7:15 ` [PATCH net-next 04/12] net: airoha: Add airoha_eth_soc_data struct Lorenzo Bianconi
2025-10-15 16:06 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 05/12] net: airoha: Generalize airoha_ppe2_is_enabled routine Lorenzo Bianconi
2025-10-15 16:07 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 06/12] net: airoha: ppe: Move PPE memory info in airoha_eth_soc_data struct Lorenzo Bianconi
2025-10-15 16:07 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 07/12] net: airoha: ppe: Remove airoha_ppe_is_enabled() where not necessary Lorenzo Bianconi
2025-10-15 16:07 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 08/12] net: airoha: ppe: Configure SRAM PPE entries via the cpu Lorenzo Bianconi
2025-10-15 15:47 ` Simon Horman
2025-10-16 8:13 ` Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 09/12] net: airoha: ppe: Flush PPE SRAM table during PPE setup Lorenzo Bianconi
2025-10-15 16:08 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 10/12] net: airoha: Select default ppe cpu port in airoha_dev_init() Lorenzo Bianconi
2025-10-15 15:54 ` Simon Horman
2025-10-16 8:51 ` Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 11/12] net: airoha: Refactor src port configuration in airhoha_set_gdm2_loopback Lorenzo Bianconi
2025-10-15 16:05 ` Simon Horman
2025-10-16 8:36 ` Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 12/12] net: airoha: Add AN7583 SoC support Lorenzo Bianconi
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=aPCodE0_u94s-w73@lore-desk \
--to=lorenzo@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/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).