config: convert 'clock_servo' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
ed566513e0
commit
8836f3cc67
3
clock.c
3
clock.c
|
@ -800,11 +800,12 @@ static void clock_remove_port(struct clock *c, struct port *p)
|
|||
|
||||
struct clock *clock_create(struct config *config, int phc_index,
|
||||
struct interfaces_head *ifaces,
|
||||
struct default_ds *dds, enum servo_type servo)
|
||||
struct default_ds *dds)
|
||||
{
|
||||
enum timestamp_type timestamping =
|
||||
config_get_int(config, NULL, "time_stamping");
|
||||
int fadj = 0, max_adj = 0, sw_ts = timestamping == TS_SOFTWARE ? 1 : 0;
|
||||
enum servo_type servo = config_get_int(config, NULL, "clock_servo");
|
||||
struct clock *c = &the_clock;
|
||||
struct port *p;
|
||||
char phc[32];
|
||||
|
|
3
clock.h
3
clock.h
|
@ -73,12 +73,11 @@ struct config *clock_config(struct clock *c);
|
|||
* Pass -1 to select CLOCK_REALTIME.
|
||||
* @param ifaces A queue of network interfaces.
|
||||
* @param dds A pointer to a default data set for the clock.
|
||||
* @param servo The servo that this clock will use.
|
||||
* @return A pointer to the single global clock instance.
|
||||
*/
|
||||
struct clock *clock_create(struct config *config, int phc_index,
|
||||
struct interfaces_head *ifaces,
|
||||
struct default_ds *dds, enum servo_type servo);
|
||||
struct default_ds *dds);
|
||||
|
||||
/**
|
||||
* Obtains a clock's default data set.
|
||||
|
|
21
config.c
21
config.c
|
@ -110,6 +110,14 @@ struct config_item {
|
|||
#define PORT_ITEM_INT(label, _default, min, max) \
|
||||
CONFIG_ITEM_INT(label, 1, _default, min, max)
|
||||
|
||||
static struct config_enum clock_servo_enu[] = {
|
||||
{ "pi", CLOCK_SERVO_PI },
|
||||
{ "linreg", CLOCK_SERVO_LINREG },
|
||||
{ "ntpshm", CLOCK_SERVO_NTPSHM },
|
||||
{ "nullf", CLOCK_SERVO_NULLF },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
static struct config_enum delay_filter_enu[] = {
|
||||
{ "moving_average", FILTER_MOVING_AVERAGE },
|
||||
{ "moving_median", FILTER_MOVING_MEDIAN },
|
||||
|
@ -152,6 +160,7 @@ struct config_item config_tab[] = {
|
|||
GLOB_ITEM_INT("check_fup_sync", 0, 0, 1),
|
||||
GLOB_ITEM_INT("clockAccuracy", 0xfe, 0, UINT8_MAX),
|
||||
GLOB_ITEM_INT("clockClass", 248, 0, UINT8_MAX),
|
||||
GLOB_ITEM_ENU("clock_servo", CLOCK_SERVO_PI, clock_servo_enu),
|
||||
PORT_ITEM_INT("delayAsymmetry", 0, INT_MIN, INT_MAX),
|
||||
PORT_ITEM_ENU("delay_filter", FILTER_MOVING_MEDIAN, delay_filter_enu),
|
||||
PORT_ITEM_INT("delay_filter_length", 10, 1, INT_MAX),
|
||||
|
@ -445,18 +454,6 @@ static enum parser_result parse_global_setting(const char *option,
|
|||
return OUT_OF_RANGE;
|
||||
strncpy(cfg->uds_address, value, MAX_IFNAME_SIZE);
|
||||
|
||||
} else if (!strcmp(option, "clock_servo")) {
|
||||
if (!strcasecmp("pi", value))
|
||||
cfg->clock_servo = CLOCK_SERVO_PI;
|
||||
else if (!strcasecmp("linreg", value))
|
||||
cfg->clock_servo = CLOCK_SERVO_LINREG;
|
||||
else if (!strcasecmp("ntpshm", value))
|
||||
cfg->clock_servo = CLOCK_SERVO_NTPSHM;
|
||||
else if (!strcasecmp("nullf", value))
|
||||
cfg->clock_servo = CLOCK_SERVO_NULLF;
|
||||
else
|
||||
return BAD_VALUE;
|
||||
|
||||
} else if (!strcmp(option, "productDescription")) {
|
||||
if (count_char(value, ';') != 2)
|
||||
return BAD_VALUE;
|
||||
|
|
2
config.h
2
config.h
|
@ -47,8 +47,6 @@ struct config {
|
|||
|
||||
/* the rest are legacy fields */
|
||||
struct default_ds dds;
|
||||
enum servo_type clock_servo;
|
||||
|
||||
unsigned char *ptp_dst_mac;
|
||||
unsigned char *p2p_dst_mac;
|
||||
char *uds_address;
|
||||
|
|
7
ptp4l.c
7
ptp4l.c
|
@ -59,8 +59,6 @@ static struct config cfg_settings = {
|
|||
},
|
||||
},
|
||||
|
||||
.clock_servo = CLOCK_SERVO_PI,
|
||||
|
||||
.ptp_dst_mac = ptp_dst_mac,
|
||||
.p2p_dst_mac = p2p_dst_mac,
|
||||
.uds_address = uds_path,
|
||||
|
@ -236,7 +234,7 @@ int main(int argc, char *argv[])
|
|||
ds->flags & DDS_SLAVE_ONLY) {
|
||||
ds->clockQuality.clockClass = 255;
|
||||
}
|
||||
if (cfg_settings.clock_servo == CLOCK_SERVO_NTPSHM) {
|
||||
if (config_get_int(cfg, NULL, "clock_servo") == CLOCK_SERVO_NTPSHM) {
|
||||
config_set_int(cfg, "kernel_leap", 0);
|
||||
config_set_int(cfg, "sanity_freq_limit", 0);
|
||||
}
|
||||
|
@ -332,8 +330,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
clock = clock_create(&cfg_settings,
|
||||
phc_index, &cfg_settings.interfaces,
|
||||
&cfg_settings.dds,
|
||||
cfg_settings.clock_servo);
|
||||
&cfg_settings.dds);
|
||||
if (!clock) {
|
||||
fprintf(stderr, "failed to create a clock\n");
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue