conf: add minpoll option to hwtimestamp directive

This commit is contained in:
Miroslav Lichvar 2017-01-19 12:59:06 +01:00
parent 9800e397fb
commit 510784077f
4 changed files with 16 additions and 2 deletions

6
conf.c
View file

@ -1259,6 +1259,7 @@ parse_hwtimestamp(char *line)
iface = ARR_GetNewElement(hwts_interfaces);
iface->name = Strdup(p);
iface->minpoll = 0;
iface->precision = 100.0e-9;
iface->tx_comp = 0.0;
iface->rx_comp = 0.0;
@ -1266,7 +1267,10 @@ parse_hwtimestamp(char *line)
for (p = line; *p; line += n, p = line) {
line = CPS_SplitWord(line);
if (!strcasecmp(p, "precision")) {
if (!strcasecmp(p, "minpoll")) {
if (sscanf(line, "%d%n", &iface->minpoll, &n) != 1)
break;
} else if (!strcasecmp(p, "precision")) {
if (sscanf(line, "%lf%n", &iface->precision, &n) != 1)
break;
} else if (!strcasecmp(p, "rxcomp")) {

1
conf.h
View file

@ -121,6 +121,7 @@ extern double CNF_GetInitStepThreshold(void);
typedef struct {
char *name;
int minpoll;
double precision;
double tx_comp;
double rx_comp;

View file

@ -1818,6 +1818,12 @@ on all available interfaces.
+
The *hwtimestamp* directive has the following options:
+
*minpoll* _poll_:::
This option specifies the minimum interval between readings of the NIC clock.
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).
*precision* _precision_:::
This option specifies the assumed precision of reading of the NIC clock. The
default value is 100e-9 (100 nanoseconds).

View file

@ -77,6 +77,9 @@ struct Interface {
/* Number of PHC readings per HW clock sample */
#define PHC_READINGS 10
/* Minimum interval between PHC readings */
#define MIN_PHC_POLL -6
/* Maximum acceptable offset between HW and daemon/kernel timestamp */
#define MAX_TS_DELAY 1.0
@ -179,7 +182,7 @@ add_interface(CNF_HwTsInterface *conf_iface)
iface->tx_comp = conf_iface->tx_comp;
iface->rx_comp = conf_iface->rx_comp;
iface->clock = HCL_CreateInstance(1.0);
iface->clock = HCL_CreateInstance(UTI_Log2ToDouble(MAX(conf_iface->minpoll, MIN_PHC_POLL)));
DEBUG_LOG(LOGF_NtpIOLinux, "Enabled HW timestamping on %s", iface->name);