Re: [PATCH net-next v1 1/7] net: ethtool: plumb PHY stats to PHY drivers
From: Russell King (Oracle)
Date: Fri Dec 06 2024 - 04:12:02 EST
On Thu, Dec 05, 2024 at 05:19:09PM -0800, Jakub Kicinski wrote:
> On Thu, 5 Dec 2024 11:57:33 +0000 Russell King (Oracle) wrote:
> > > + * The input structure is not zero-initialized and the implementation
> > > + * must only set statistics which are actually collected by the device.
> >
> > Eh what? This states to me that the structure is not initialised, but
> > drivers should not write to all members unless they support the
> > statistic.
> >
> > Doesn't this mean we end up returning uninitialised data to userspace?
> > If the structure is not initialised, how does core code know which
> > statistics the driver has set to avoid returning uninitialised data?
>
> It's not zero-initialized. Meaning it's initialized to a special magic
> value that the core then checks for to decide if the driver actually
> reported something.
>
> Maybe this:
>
> * Drivers must not zero out statistics which they don't report.
> * Core will initialize members to ETHTOOL_STAT_NOT_SET and check
> * for this value to report to user space only the stats actually
> * supported by the device.
>
> IDK how to phrase this better..
Maybe:
* The input structure is pre-initialised with ETHTOOL_STAT_NOT_SET and
* the implementation must only change implemented statistics.
?
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!