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-prev] [day] [month] [year] [list]
Message-ID: <d40cbc17-22fa-4829-8eb0-e9fd26fc54b1@bootlin.com>
Date: Sat, 18 Oct 2025 09:42:57 +0200
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Alexandre Torgue <alexandre.torgue@...s.st.com>,
 Jose Abreu <joabreu@...opsys.com>, Andrew Lunn <andrew+netdev@...n.ch>,
 davem@...emloft.net, Eric Dumazet <edumazet@...gle.com>,
 Paolo Abeni <pabeni@...hat.com>, Maxime Coquelin
 <mcoquelin.stm32@...il.com>, Richard Cochran <richardcochran@...il.com>,
 Russell King <linux@...linux.org.uk>,
 Köry Maincent <kory.maincent@...tlin.com>,
 Alexis Lothoré <alexis.lothore@...tlin.com>,
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>, netdev@...r.kernel.org,
 linux-stm32@...md-mailman.stormreply.com,
 linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 2/3] net: stmmac: Allow supporting coarse
 adjustment mode

Hi Jakub,

On 18/10/2025 03:23, Jakub Kicinski wrote:
> On Wed, 15 Oct 2025 12:27:22 +0200 Maxime Chevallier wrote:
>> The DWMAC1000 supports 2 timestamping configurations to configure how
>> frequency adjustments are made to the ptp_clock, as well as the reported
>> timestamp values.
>>
>> There was a previous attempt at upstreaming support for configuring this
>> mode by Olivier Dautricourt and Julien Beraud a few years back [1]
>>
>> In a nutshell, the timestamping can be either set in fine mode or in
>> coarse mode.
>>
>> In fine mode, which is the default, we use the overflow of an accumulator to
>> trigger frequency adjustments, but by doing so we lose precision on the
>> timetamps that are produced by the timestamping unit. The main drawback
>> is that the sub-second increment value, used to generate timestamps, can't be
>> set to lower than (2 / ptp_clock_freq).
>>
>> The "fine" qualification comes from the frequent frequency adjustments we are
>> able to do, which is perfect for a PTP follower usecase.
>>
>> In Coarse mode, we don't do frequency adjustments based on an
>> accumulator overflow. We can therefore have very fine subsecond
>> increment values, allowing for better timestamping precision. However
>> this mode works best when the ptp clock frequency is adjusted based on
>> an external signal, such as a PPS input produced by a GPS clock. This
>> mode is therefore perfect for a Grand-master usecase.
>>
>> We therefore attempt to map these 2 modes with the newly introduced
>> hwtimestamp qualifiers (precise and approx).
>>
>> Precise mode is mapped to stmmac fine mode, and is the expected default,
>> suitable for all cases and perfect for follower mode
>>
>> Approx mode is mapped to coarse mode, suitable for Grand-master.
> 
> I failed to understand what this device does and what the problem is :(
> 
> What is your ptp_clock_freq? Isn't it around 50MHz typically? 
> So 2 / ptp_freq is 40nsec (?), not too bad?

That's not too bad indeed, but it makes a difference when acting as
Grand Master, especially in this case because you don't need to
perform clock adjustments (it's sync'd through PPS in), so we might
as well take this opportunity to improve the TS.

> 
> My recollection of the idea behind that timestamping providers
> was that you can configure different filters for different providers.
> IOW that you'd be able to say:
>  - [precise] Rx stamp PTP packets 
>  -  [approx] Rx stamp all packets
> not that you'd configure precision of one piece of HW..

So far it looks like only one provider is enabled at a given time, my
understanding was that the qualifier would be used in case there
are multiple timestampers on the data path, to select the better one
(e.g. a PHY that supports TS, a MAC that supports TS, we use the 
best out of the two).

However I agree with your comments, that's exactly the kind of feedback
I was looking for. This work has been tried several times now each
time with a different uAPI path, I'm OK to consider that this is out
of the scope of the hwprov feature.

> If the HW really needs it, just lob a devlink param at it?

I'm totally OK with that. I'm not well versed into devlink, working mostly with
embedded devices with simple-ish NICs, most of them don't use devlink. Let me
give it a try then :)

Thanks for taking a look at this,

Maxime



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ