linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 net-next 0/1] net: ethernet: ocelot: remove num_stats initializer requirement
@ 2022-04-29 21:30 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 12:40 ` [PATCH v1 net-next 0/1] net: ethernet: ocelot: remove num_stats initializer requirement patchwork-bot+netdevbpf
  0 siblings, 2 replies; 7+ messages in thread
From: Colin Foster @ 2022-04-29 21:30 UTC (permalink / raw)
  To: linux-kernel, netdev
  Cc: aolo Abeni, Jakub Kicinski, Eric Dumazet, David S. Miller,
	Florian Fainelli, Vivien Didelot, Andrew Lunn, UNGLinuxDriver,
	Alexandre Belloni, Claudiu Manoil, Vladimir Oltean

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-30 22:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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