From: Richard Cochran <richardcochran@gmail.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next 2/3] ptp: igb: Use the high resolution frequency method.
Date: Wed, 9 Nov 2016 14:11:46 +0100 [thread overview]
Message-ID: <20161109131146.GA6491@localhost.localdomain> (raw)
In-Reply-To: <1478642533.7545.38.camel@intel.com>
On Tue, Nov 08, 2016 at 10:02:22PM +0000, Keller, Jacob E wrote:
> On Tue, 2016-11-08 at 22:49 +0100, Richard Cochran wrote:
> > - rate = ppb;
> > - rate <<= 26;
> > - rate = div_u64(rate, 1953125);
> > + rate = scaled_ppm;
> > + rate <<= 13;
> > + rate = div_u64(rate, 15625);
>
> I'm curious how you generate the new math here, since this can be
> tricky, and I could use more examples in order to port to some of the
> other drivers implementations. I'm not quit sure how to handle the
> value when the lower 16 bits are fractional.
TL;DR version:
In ptp_clock.c we convert scaled_ppm to ppb like this.
ppb = scaled_ppm * 10^3 * 2^-16
If you already have a working driver that does
regval = ppb * SOMEMATH;
then just substitute
regval = (scaled_ppm * 10^3 * 2^-16) * SOMEMATH;
= (scaled_ppm * 5^3 * 2^-13) * SOMEMATH;
and simplify by combining the 5^3 and 2^-13 constants into SOMEMATH.
Longer explanation:
You have to consider how the frequency adjustment HW works, case by
case. Both the i210 and the phyter have an adjustment register that
holds units of 2^-32 nanoseconds per 8 nanosecond clock period, and so
the rate from adjustment value 1 is (2^-32 / 8).
Then with the old interface, the conversion from "adjustment unit" to
ppb was (2^-32 / 8 * 10^9) or (2^-26 * 5^9). The conversion the other
way needs the inverse, and so the code did (ppb << 26) / 5^9.
With the new interface, the conversion from "adjustment unit" to
scaled_ppm is (2^-32 / 8 * 10^6 * 2^16) or (2^-13 * 5^6). The code
converts the other direction using the inverse, (s_ppm << 13) / 5^6.
HTH,
Richard
WARNING: multiple messages have this Message-ID (diff)
From: Richard Cochran <richardcochran@gmail.com>
To: "Keller, Jacob E" <jacob.e.keller@intel.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"Manfred.Rudigier@omicron.at" <Manfred.Rudigier@omicron.at>,
"ulrik.debie-os@e2big.org" <ulrik.debie-os@e2big.org>,
"stefan.sorensen@spectralink.com"
<stefan.sorensen@spectralink.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"Kirsher, Jeffrey T" <jeffrey.t.kirsher@intel.com>,
"john.stultz@linaro.org" <john.stultz@linaro.org>,
"intel-wired-lan@lists.osuosl.org"
<intel-wired-lan@lists.osuosl.org>
Subject: Re: [PATCH net-next 2/3] ptp: igb: Use the high resolution frequency method.
Date: Wed, 9 Nov 2016 14:11:46 +0100 [thread overview]
Message-ID: <20161109131146.GA6491@localhost.localdomain> (raw)
In-Reply-To: <1478642533.7545.38.camel@intel.com>
On Tue, Nov 08, 2016 at 10:02:22PM +0000, Keller, Jacob E wrote:
> On Tue, 2016-11-08 at 22:49 +0100, Richard Cochran wrote:
> > - rate = ppb;
> > - rate <<= 26;
> > - rate = div_u64(rate, 1953125);
> > + rate = scaled_ppm;
> > + rate <<= 13;
> > + rate = div_u64(rate, 15625);
>
> I'm curious how you generate the new math here, since this can be
> tricky, and I could use more examples in order to port to some of the
> other drivers implementations. I'm not quit sure how to handle the
> value when the lower 16 bits are fractional.
TL;DR version:
In ptp_clock.c we convert scaled_ppm to ppb like this.
ppb = scaled_ppm * 10^3 * 2^-16
If you already have a working driver that does
regval = ppb * SOMEMATH;
then just substitute
regval = (scaled_ppm * 10^3 * 2^-16) * SOMEMATH;
= (scaled_ppm * 5^3 * 2^-13) * SOMEMATH;
and simplify by combining the 5^3 and 2^-13 constants into SOMEMATH.
Longer explanation:
You have to consider how the frequency adjustment HW works, case by
case. Both the i210 and the phyter have an adjustment register that
holds units of 2^-32 nanoseconds per 8 nanosecond clock period, and so
the rate from adjustment value 1 is (2^-32 / 8).
Then with the old interface, the conversion from "adjustment unit" to
ppb was (2^-32 / 8 * 10^9) or (2^-26 * 5^9). The conversion the other
way needs the inverse, and so the code did (ppb << 26) / 5^9.
With the new interface, the conversion from "adjustment unit" to
scaled_ppm is (2^-32 / 8 * 10^6 * 2^16) or (2^-13 * 5^6). The code
converts the other direction using the inverse, (s_ppm << 13) / 5^6.
HTH,
Richard
next prev parent reply other threads:[~2016-11-09 13:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-08 21:49 [Intel-wired-lan] [PATCH net-next 0/3] PHC frequency fine tuning Richard Cochran
2016-11-08 21:49 ` Richard Cochran
2016-11-08 21:49 ` [Intel-wired-lan] [PATCH net-next 1/3] ptp: Introduce a high resolution frequency adjustment method Richard Cochran
2016-11-08 21:49 ` Richard Cochran
2016-11-08 21:49 ` [Intel-wired-lan] [PATCH net-next 2/3] ptp: igb: Use the high resolution frequency method Richard Cochran
2016-11-08 21:49 ` Richard Cochran
2016-11-08 22:02 ` [Intel-wired-lan] " Keller, Jacob E
2016-11-08 22:02 ` Keller, Jacob E
2016-11-09 13:11 ` Richard Cochran [this message]
2016-11-09 13:11 ` Richard Cochran
2016-11-09 21:40 ` [Intel-wired-lan] " Keller, Jacob E
2016-11-09 21:40 ` Keller, Jacob E
2016-11-08 22:04 ` [Intel-wired-lan] " Keller, Jacob E
2016-11-08 22:04 ` Keller, Jacob E
2016-11-09 13:15 ` [Intel-wired-lan] " Richard Cochran
2016-11-09 13:15 ` Richard Cochran
2016-11-08 21:49 ` [Intel-wired-lan] [PATCH net-next 3/3] ptp: dp83640: " Richard Cochran
2016-11-08 21:49 ` Richard Cochran
2016-11-08 21:56 ` [Intel-wired-lan] [PATCH net-next 0/3] PHC frequency fine tuning Keller, Jacob E
2016-11-08 21:56 ` Keller, Jacob E
2016-11-10 2:20 ` [Intel-wired-lan] " David Miller
2016-11-10 2:20 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161109131146.GA6491@localhost.localdomain \
--to=richardcochran@gmail.com \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.