lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220430174735.GD3846867@euler>
Date:   Sat, 30 Apr 2022 10:47:35 -0700
From:   Colin Foster <colin.foster@...advantage.com>
To:     Vladimir Oltean <vladimir.oltean@....com>
Cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        aolo Abeni <pabeni@...hat.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        "UNGLinuxDriver@...rochip.com" <UNGLinuxDriver@...rochip.com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Claudiu Manoil <claudiu.manoil@....com>
Subject: Re: [PATCH v1 net-next 1/1] net: ethernet: ocelot: remove the need
 for num_stats initializer

Hi Vladimir,

On Sat, Apr 30, 2022 at 03:15:31PM +0000, Vladimir Oltean wrote:
> 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@...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?

I considered this as well. I could either have explicitly added the
flags field, as I did, or implicitly looked for .name == NULL (or
name[0] == '\0' as you suggest).

I figured it might be better to make this an explicit relationship by
way of flags - but I'm happy to change OCELOT_STAT_END and for_each_stat
to rely on .name if you prefer.

> 
> >  	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
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ