From: Miroslav Lichvar Date: Wed, 8 Aug 2018 12:03:35 +0000 (+0200) Subject: ntp: add options to set minsamples/maxsamples of hwclock X-Git-Tag: 3.4-pre1~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afff06c88cb83cbd824488a72477115d9246fcb4;p=thirdparty%2Fchrony.git ntp: add options to set minsamples/maxsamples of hwclock --- diff --git a/conf.c b/conf.c index ef6db084..85a7f2e9 100644 --- a/conf.c +++ b/conf.c @@ -1291,6 +1291,8 @@ parse_hwtimestamp(char *line) iface = ARR_GetNewElement(hwts_interfaces); iface->name = Strdup(p); iface->minpoll = 0; + iface->min_samples = 2; + iface->max_samples = 16; iface->nocrossts = 0; iface->rxfilter = CNF_HWTS_RXFILTER_ANY; iface->precision = 100.0e-9; @@ -1300,9 +1302,15 @@ parse_hwtimestamp(char *line) for (p = line; *p; line += n, p = line) { line = CPS_SplitWord(line); - if (!strcasecmp(p, "minpoll")) { + if (!strcasecmp(p, "maxsamples")) { + if (sscanf(line, "%d%n", &iface->max_samples, &n) != 1) + break; + } else if (!strcasecmp(p, "minpoll")) { if (sscanf(line, "%d%n", &iface->minpoll, &n) != 1) break; + } else if (!strcasecmp(p, "minsamples")) { + if (sscanf(line, "%d%n", &iface->min_samples, &n) != 1) + break; } else if (!strcasecmp(p, "precision")) { if (sscanf(line, "%lf%n", &iface->precision, &n) != 1) break; diff --git a/conf.h b/conf.h index 25c98e1e..43217fc6 100644 --- a/conf.h +++ b/conf.h @@ -128,6 +128,8 @@ typedef enum { typedef struct { char *name; int minpoll; + int min_samples; + int max_samples; int nocrossts; CNF_HwTs_RxFilter rxfilter; double precision; diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc index 864990db..4a39c21b 100644 --- a/doc/chrony.conf.adoc +++ b/doc/chrony.conf.adoc @@ -1945,6 +1945,12 @@ It's defined as a power of two. It should correspond to the minimum polling interval of all NTP sources and the minimum expected polling interval of NTP clients. The default value is 0 (1 second) and the minimum value is -6 (1/64th of a second). +*minsamples* _samples_::: +This option specifies the minimum number of readings kept for tracking of the +NIC clock. The default value is 2. +*maxsamples* _samples_::: +This option specifies the maximum number of readings kept for tracking of the +NIC clock. The default value is 16. *precision* _precision_::: This option specifies the assumed precision of reading of the NIC clock. The default value is 100e-9 (100 nanoseconds). diff --git a/ntp_io_linux.c b/ntp_io_linux.c index ad7b6eeb..819792aa 100644 --- a/ntp_io_linux.c +++ b/ntp_io_linux.c @@ -236,8 +236,8 @@ add_interface(CNF_HwTsInterface *conf_iface) iface->tx_comp = conf_iface->tx_comp; iface->rx_comp = conf_iface->rx_comp; - iface->clock = HCL_CreateInstance(0, 16, UTI_Log2ToDouble(MAX(conf_iface->minpoll, - MIN_PHC_POLL))); + iface->clock = HCL_CreateInstance(conf_iface->min_samples, conf_iface->max_samples, + UTI_Log2ToDouble(MAX(conf_iface->minpoll, MIN_PHC_POLL))); LOG(LOGS_INFO, "Enabled HW timestamping %son %s", ts_config.rx_filter == HWTSTAMP_FILTER_NONE ? "(TX only) " : "", iface->name);