From: Richard Cochran <richardcochran@gmail.com>
To: Sudarsana Kalluru <Sudarsana.Kalluru@cavium.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, Yuval.Mintz@cavium.com
Subject: Re: [PATCH net-next v4 1/2] qed: Add infrastructure for PTP support.
Date: Sat, 11 Feb 2017 12:16:38 +0100 [thread overview]
Message-ID: <20170211111638.GA6564@localhost.localdomain> (raw)
In-Reply-To: <20170211085810.GA4006@localhost.localdomain>
On Sat, Feb 11, 2017 at 09:58:10AM +0100, Richard Cochran wrote:
> If I am not mistaken, then you can skip the cases val==2 and val==3,
> because they are equivalent to val==4 and 6.
I took a stab at this, and you can see the result, below. My version
has lower average error than yours in the interval 1 < ppb < 60000,
and it uses only 8 64-bit divisions. Outside of that interval, your
version has lower error.
So, at the very least, you should introduce a threshold and use this
algorithm for adjustments under 60 ppm. Better yet, find a way to use
fewer divisions for adjustments greater and 60 ppm...
Thanks,
Richard
---
#include <stdint.h>
#define TEN9 (1000000000UL)
unsigned int calc_min_integer(uint64_t ppb, uint64_t *M)
{
uint64_t err, m, min, n, N, p2, reg;
min = TEN9;
for (n = 4; n <= 7; n++) {
m = n * TEN9;
m = (m + ppb/2) / ppb;
/*truncate to HW resolution*/
reg = (m + 8) / 16;
m = reg * 16;
p2 = (n * TEN9 + m/2) / m;
err = ppb > p2 ? ppb - p2 : p2 - ppb;
if (min >= err) {
min = err;
N = n;
*M = m;
}
}
return N;
}
next prev parent reply other threads:[~2017-02-11 11:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-08 6:43 [PATCH net-next v4 0/2] qed*: Add support for PTP Sudarsana Kalluru
2017-02-08 6:43 ` [PATCH net-next v4 1/2] qed: Add infrastructure for PTP support Sudarsana Kalluru
2017-02-11 8:58 ` Richard Cochran
2017-02-11 11:16 ` Richard Cochran [this message]
2017-02-12 11:27 ` Mintz, Yuval
2017-02-12 11:52 ` Mintz, Yuval
2017-02-12 18:47 ` Richard Cochran
2017-02-12 14:02 ` Richard Cochran
2017-02-12 15:07 ` Mintz, Yuval
2017-02-12 15:53 ` Mintz, Yuval
2017-02-12 19:50 ` Richard Cochran
2017-02-13 9:48 ` FW: " Mintz, Yuval
2017-02-08 6:43 ` [PATCH net-next v4 2/2] qede: Add driver support for PTP Sudarsana Kalluru
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=20170211111638.GA6564@localhost.localdomain \
--to=richardcochran@gmail.com \
--cc=Sudarsana.Kalluru@cavium.com \
--cc=Yuval.Mintz@cavium.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).