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-next>] [day] [month] [year] [list]
Date:   Fri, 29 Apr 2022 14:30:35 -0700
From:   Colin Foster <colin.foster@...advantage.com>
To:     linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Cc:     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,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Claudiu Manoil <claudiu.manoil@....com>,
        Vladimir Oltean <vladimir.oltean@....com>
Subject: [PATCH v1 net-next 0/1] net: ethernet: ocelot: remove num_stats initializer requirement

The ocelot_stats_layout structure array is common with other chips,
specifically the VSC7512. It can only be controlled externally (SPI,
PCIe...)

During the VSC7512 / Felix driver development, it was noticed that
this array can be shared with the Ocelot driver. As with other arrays
shared between the VSC7514 and VSC7512, it makes sense to define them in
drivers/net/ethernet/mscc/vsc7514_regs.c, while declaring them in
include/soc/mscc/vsc7514_regs.h

The thing that makes the stats_layout unique is that it is not accessed
indirectly by way of a shared enumeration index, but instead is looped
over. As such, the num_stats parameter has been used as the loop bounds.

Since the array size isn't necessarily fixed-length, the size has to be
determined. This was done locally in the C file with ARRAY_SIZE, but
that isn't possible if the array is declared via:
extern const struct ocelot_stat_layout ocelot_stats_layout[];

Instead, determine the size by the elemenets of the structure itself.
This way stats can be added / removed as needed (though they rarely
should) without the requirement of dragging a size variable around.

I don't have felix / seville / vsc7514 hardware to test, so I'd
appreciate if someone could give it a test. I've verified functionality
on my in-development kernel, but wouldn't mind feedback from the
existing users who have had the misfortune of having to find my mistakes
when it was too late.

Colin Foster (1):
  net: ethernet: ocelot: remove the need for num_stats initializer

 drivers/net/dsa/ocelot/felix.c             |  1 -
 drivers/net/dsa/ocelot/felix.h             |  1 -
 drivers/net/dsa/ocelot/felix_vsc9959.c     |  2 +-
 drivers/net/dsa/ocelot/seville_vsc9953.c   |  2 +-
 drivers/net/ethernet/mscc/ocelot.c         |  5 +++++
 drivers/net/ethernet/mscc/ocelot_vsc7514.c |  2 +-
 include/soc/mscc/ocelot.h                  | 10 ++++++++++
 7 files changed, 18 insertions(+), 5 deletions(-)

-- 
2.25.1

Powered by blists - more mailing lists