linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Colin Foster <colin.foster@in-advantage.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	aolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>
Subject: Re: [PATCH v1 net-next 1/1] net: ethernet: ocelot: remove the need for num_stats initializer
Date: Sat, 30 Apr 2022 15:15:31 +0000	[thread overview]
Message-ID: <20220430151530.zaf7hyagln5jqjyi@skbuf> (raw)
In-Reply-To: <20220429213036.3482333-2-colin.foster@in-advantage.com>

On Fri, Apr 29, 2022 at 02:30:36PM -0700, Colin Foster wrote:
> There is a desire to share the oclot_stats_layout struct outside of the
> current vsc7514 driver. In order to do so, the length of the array needs to
> be known at compile time, and defined in the struct ocelot and struct
> felix_info.
> 
> Since the array is defined in a .c file and would be declared in the header
> file via:
> extern struct ocelot_stat_layout[];
> the size of the array will not be known at compile time to outside modules.
> 
> To fix this, remove the need for defining the number of stats at compile
> time and allow this number to be determined at initialization.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
> diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h
> index 9b4e6c78d0f4..5c4f57cfa785 100644
> --- a/include/soc/mscc/ocelot.h
> +++ b/include/soc/mscc/ocelot.h
> @@ -105,6 +105,13 @@
>  #define REG_RESERVED_ADDR		0xffffffff
>  #define REG_RESERVED(reg)		REG(reg, REG_RESERVED_ADDR)
>  
> +#define OCELOT_STAT_FLAG_END		BIT(0)
> +
> +#define for_each_stat(ocelot, stat)				\
> +	for ((stat) = ocelot->stats_layout;			\
> +	     !((stat)->flags & OCELOT_STAT_FLAG_END);		\
> +	     (stat)++)
> +
>  enum ocelot_target {
>  	ANA = 1,
>  	QS,
> @@ -535,9 +542,12 @@ enum ocelot_ptp_pins {
>  
>  struct ocelot_stat_layout {
>  	u32 offset;
> +	u32 flags;

Was it really necessary to add an extra u32 to struct ocelot_stat_layout?
Couldn't you check for the end of stats by looking at stat->name[0] and
comparing against the null terminator, for an empty string?

>  	char name[ETH_GSTRING_LEN];
>  };
>  
> +#define OCELOT_STAT_END { .flags = OCELOT_STAT_FLAG_END }
> +
>  struct ocelot_stats_region {
>  	struct list_head node;
>  	u32 offset;
> -- 
> 2.25.1
>

  reply	other threads:[~2022-04-30 15:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29 21:30 [PATCH v1 net-next 0/1] net: ethernet: ocelot: remove num_stats initializer requirement Colin Foster
2022-04-29 21:30 ` [PATCH v1 net-next 1/1] net: ethernet: ocelot: remove the need for num_stats initializer Colin Foster
2022-04-30 15:15   ` Vladimir Oltean [this message]
2022-04-30 17:47     ` Colin Foster
2022-04-30 21:33       ` Vladimir Oltean
2022-04-30 22:31         ` Colin Foster
2022-04-30 12:40 ` [PATCH v1 net-next 0/1] net: ethernet: ocelot: remove num_stats initializer requirement patchwork-bot+netdevbpf

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=20220430151530.zaf7hyagln5jqjyi@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=colin.foster@in-advantage.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vivien.didelot@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;
as well as URLs for NNTP newsgroup(s).