diff --git a/clock.c b/clock.c index 112d0a2..320a84c 100644 --- a/clock.c +++ b/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]; diff --git a/clock.h b/clock.h index ce83996..9a1151f 100644 --- a/clock.h +++ b/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. diff --git a/config.c b/config.c index 673f218..3f92daf 100644 --- a/config.c +++ b/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; diff --git a/config.h b/config.h index 948f792..c4bf875 100644 --- a/config.h +++ b/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; diff --git a/ptp4l.c b/ptp4l.c index 0acc63d..8ca49c0 100644 --- a/ptp4l.c +++ b/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;