Add option to set maximum frequency adjustment.

The option sets an additional limit to the hardware limit. It's disabled
if set to zero. The default is 900000000 ppb.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2013-04-10 20:07:48 +02:00 committed by Richard Cochran
parent 4929d50a3f
commit 3012cf0540
8 changed files with 27 additions and 1 deletions

View File

@ -290,6 +290,11 @@ static enum parser_result parse_global_setting(const char *option,
return BAD_VALUE;
*cfg->pi_offset_const = df;
} else if (!strcmp(option, "pi_max_frequency")) {
if (1 != sscanf(value, "%d", &val) || !(val >= 0))
return BAD_VALUE;
*cfg->pi_max_frequency = val;
} else if (!strcmp(option, "ptp_dst_mac")) {
if (MAC_LEN != sscanf(value, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]))

View File

@ -68,6 +68,7 @@ struct config {
double *pi_proportional_const;
double *pi_integral_const;
double *pi_offset_const;
int *pi_max_frequency;
unsigned char *ptp_dst_mac;
unsigned char *p2p_dst_mac;

View File

@ -41,6 +41,7 @@ kernel_leap 1
pi_proportional_const 0.0
pi_integral_const 0.0
pi_offset_const 0.0
pi_max_frequency 900000000
clock_servo pi
#
# Transport options

View File

@ -40,6 +40,7 @@ kernel_leap 1
pi_proportional_const 0.0
pi_integral_const 0.0
pi_offset_const 0.0
pi_max_frequency 900000000
clock_servo pi
#
# Transport options

7
pi.c
View File

@ -31,10 +31,11 @@
#define NSEC_PER_SEC 1000000000
/* These two take their values from the configuration file. (see ptp4l.c) */
/* These take their values from the configuration file. (see ptp4l.c) */
double configured_pi_kp = 0.0;
double configured_pi_ki = 0.0;
double configured_pi_offset = 0.0;
int configured_pi_max_freq = 900000000;
struct pi_servo {
struct servo servo;
@ -150,5 +151,9 @@ struct servo *pi_servo_create(int fadj, int max_ppb, int sw_ts)
s->max_offset = 0.0;
}
if (configured_pi_max_freq && s->maxppb > configured_pi_max_freq) {
s->maxppb = configured_pi_max_freq;
}
return &s->servo;
}

6
pi.h
View File

@ -42,6 +42,12 @@ extern double configured_pi_ki;
*/
extern double configured_pi_offset;
/**
* When set to a non-zero value, this variable sets an additional limit for
* the frequency adjustment of the clock. It's in ppb.
*/
extern int configured_pi_max_freq;
struct servo *pi_servo_create(int fadj, int max_ppb, int sw_ts);
#endif

View File

@ -292,6 +292,12 @@ frequency instead of stepping the clock. When set to 0.0, the controller will
never step the clock.
The default is 0.0.
.TP
.B pi_max_frequency
The maximum allowed frequency adjustment of the clock in parts per billion
(ppb). This is an additional limit to the maximum allowed by the hardware. When
set to 0, the hardware limit will be used.
The default is 900000000 (90%).
.TP
.B ptp_dst_mac
The MAC address where should be PTP messages sent.
Relevant only with L2 transport. The default is 01:1B:19:00:00:00.

View File

@ -96,6 +96,7 @@ static struct config cfg_settings = {
.pi_proportional_const = &configured_pi_kp,
.pi_integral_const = &configured_pi_ki,
.pi_offset_const = &configured_pi_offset,
.pi_max_frequency = &configured_pi_max_freq,
.ptp_dst_mac = ptp_dst_mac,
.p2p_dst_mac = p2p_dst_mac,