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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220307143440.GC29247@hoboy.vegasvil.org>
Date:   Mon, 7 Mar 2022 06:34:40 -0800
From:   Richard Cochran <richardcochran@...il.com>
To:     Gerhard Engleder <gerhard@...leder-embedded.com>
Cc:     yangbo.lu@....com, David Miller <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, mlichvar@...hat.com,
        Vinicius Costa Gomes <vinicius.gomes@...el.com>,
        netdev <netdev@...r.kernel.org>
Subject: Re: [RFC PATCH net-next 0/6] ptp: Support hardware clocks with
 additional free running time

On Sun, Mar 06, 2022 at 01:50:32PM -0800, Richard Cochran wrote:
> On Sun, Mar 06, 2022 at 07:38:55PM +0100, Gerhard Engleder wrote:
> > How can I cover my use case with the existing API? I had no idea so far.
> 
> Okay, so 2 PHCs doesn't help, but still all you need is:
> 
> 1. a different method to convert time stamps to vclock time base
> 
> 2. a different method for vclocks' gettime
> 
> So let me suggest a much smaller change to the phc/vclock api... stay tuned

For #1:

On the receive path, the stack calls ptp_convert_timestamp() if the
socket has the SOF_TIMESTAMPING_RAW_HARDWARE option.  In that method,
you need only get the raw cycle count if supported by the pclock.

So instead of:

	vclock = info_to_vclock(ptp->info);

	ns = ktime_to_ns(hwtstamps->hwtstamp);

	spin_lock_irqsave(&vclock->lock, flags);
	ns = timecounter_cyc2time(&vclock->tc, ns);
	spin_unlock_irqrestore(&vclock->lock, flags);

something like this:

	vclock = info_to_vclock(ptp->info);

	cycles = pclock->ktime_to_cycles(hwtstamps->hwtstamp);

	spin_lock_irqsave(&vclock->lock, flags);
	ns = timecounter_cyc2time(&vclock->tc, cycles);
	spin_unlock_irqrestore(&vclock->lock, flags);

This new class method, ktime_to_cycles, can simply do ktime_to_ns() by
default for all of the existing drivers, but your special driver can
look up the hwtstamp in a cache of {hwtstamp, cycles} pairs.

(No need to bloat skbuff by another eight bytes!)

For #2:

Similarly, add a new class method, say, pclock.get_cycles that does

	if (ptp->info->gettimex64)
		ptp->info->gettimex64(ptp->info, &ts, NULL);
	else
		ptp->info->gettime64(ptp->info, &ts);

by default, but in your driver will read the special counter.

Thanks,
Richard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ