mbox series

[v1,net-next,0/1] net: ethernet: ocelot: remove num_stats initializer requirement

Message ID 20220429213036.3482333-1-colin.foster@in-advantage.com (mailing list archive)
Headers show
Series net: ethernet: ocelot: remove num_stats initializer requirement | expand

Message

Colin Foster April 29, 2022, 9:30 p.m. UTC
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(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 30, 2022, 12:40 p.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 29 Apr 2022 14:30:35 -0700 you wrote:
> 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
> 
> [...]

Here is the summary with links:
  - [v1,net-next,1/1] net: ethernet: ocelot: remove the need for num_stats initializer
    https://git.kernel.org/netdev/net-next/c/2f187bfa6f35

You are awesome, thank you!