[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <27df679a1307131b8f515435f0991f185d72c4fa.camel@kernel.org>
Date: Thu, 15 Apr 2021 16:52:44 -0700
From: Saeed Mahameed <saeed@...nel.org>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, davem@...emloft.net, andrew@...n.ch,
mkubecek@...e.cz, idosch@...dia.com
Subject: Re: [RFC net-next 4/6] ethtool: add interface to read standard MAC
stats
On Thu, 2021-04-15 at 16:05 -0700, Jakub Kicinski wrote:
> On Thu, 15 Apr 2021 15:46:52 -0700 Saeed Mahameed wrote:
> > > > best practice here is to centralize all the data structures and
> > > > information definitions in one place, you define the stat id,
> > > > string,
> > > > and value offset, then a generic loop can generate the strset
> > > > and
> > > > fill
> > > > up values in the correct offset.
> > > >
> > > > similar implementation is already in mlx5:
> > > >
> > > > see pport_802_3_stats_desc:
> > > >
> > > > https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c#L682
> > > >
> > > > the "pport_802_3_stats_desc" has a description of the strings
> > > > and
> > > > offsets of all stats in this stats group
> > > > and the fill/put functions are very simple and they just
> > > > iterate
> > > > over
> > > > the array/group and fill up according to the descriptor.
> > >
> > > We can maybe save 60 lines if we generate stats_eth_mac_names
> > > in a initcall, is it really worth it? I prefer the readability
> > > / grepability.
> >
> > I don't think readability will be an issue if the infrastructure is
> > generic enough..
> >
> > This just a preference, of course you can go with the current code.
> > My point is that someone doesn't need to change multiple places and
> > possibly files every time they need to expose a new stat, you just
> > update some central database of the new data you want to expose.
>
> Understood, I've written those table-based generators for ethtool
> stats
> in the drivers in the past as well, but here we can only generate the
> dumping and the names. We'll need to manually fill in defines/enums
> in
> uAPI, struct members and the generator table. I'd rather stick to
> real struct members in the core<->driver API than indexing an array
> with an enums. So the savings are 4 places => 3 places?
>
> Unless I'm missing some clever, yet robust and readable ways of
> coding
> this up..
>
> Can we leave as is as starting point and see where we go from here?
> So far MAC stats are the only sizable ones were we'd see noticeable
> gain.
Sure ! if we see it is exploding with stats and long if conditions, we
can reconsider :) ..
Powered by blists - more mailing lists