From b6a91303a909862a47d3f1fa6fcd2a6e30dbcede Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 15 Aug 2015 21:25:47 +0200 Subject: [PATCH] config: convert 'delay_filter' to the new scheme. Signed-off-by: Richard Cochran --- clock.c | 2 +- config.c | 29 ++++++++--------------------- config.h | 1 - ds.h | 1 - port.c | 2 +- ptp4l.c | 1 - 6 files changed, 10 insertions(+), 26 deletions(-) diff --git a/clock.c b/clock.c index a923915..91ed78d 100644 --- a/clock.c +++ b/clock.c @@ -880,7 +880,7 @@ struct clock *clock_create(struct config *config, int phc_index, c->servo_state = SERVO_UNLOCKED; c->servo_type = servo; c->tsproc = tsproc_create(config_get_int(config, NULL, "tsproc_mode"), - dds->delay_filter, + config_get_int(config, NULL, "delay_filter"), config_get_int(config, NULL, "delay_filter_length")); if (!c->tsproc) { pr_err("Failed to create time stamp processor"); diff --git a/config.c b/config.c index 4701e92..3b6fdc8 100644 --- a/config.c +++ b/config.c @@ -110,6 +110,12 @@ struct config_item { #define PORT_ITEM_INT(label, _default, min, max) \ CONFIG_ITEM_INT(label, 1, _default, min, max) +static struct config_enum delay_filter_enu[] = { + { "moving_average", FILTER_MOVING_AVERAGE }, + { "moving_median", FILTER_MOVING_MEDIAN }, + { NULL, 0 }, +}; + static struct config_enum delay_mech_enu[] = { { "Auto", DM_AUTO }, { "E2E", DM_E2E }, @@ -140,6 +146,7 @@ struct config_item config_tab[] = { GLOB_ITEM_INT("clockAccuracy", 0xfe, 0, UINT8_MAX), GLOB_ITEM_INT("clockClass", 248, 0, UINT8_MAX), 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), PORT_ITEM_ENU("delay_mechanism", DM_E2E, delay_mech_enu), GLOB_ITEM_INT("domainNumber", 0, 0, 127), @@ -384,18 +391,7 @@ static enum parser_result parse_port_setting(struct config *cfg, if (r != NOT_PARSED) return r; - if (!strcmp(option, "delay_filter")) { - if (!strcasecmp("moving_average", value)) - iface->delay_filter = FILTER_MOVING_AVERAGE; - else if (!strcasecmp("moving_median", value)) - iface->delay_filter = FILTER_MOVING_MEDIAN; - else - return BAD_VALUE; - - } else - return parse_item(cfg, iface->name, option, value); - - return PARSED_OK; + return parse_item(cfg, iface->name, option, value); } static int count_char(const char *str, char c) @@ -488,14 +484,6 @@ static enum parser_result parse_global_setting(const char *option, for (i = 0; i < OUI_LEN; i++) cfg->dds.clock_desc.manufacturerIdentity[i] = oui[i]; - } else if (!strcmp(option, "delay_filter")) { - if (!strcasecmp("moving_average", value)) - cfg->dds.delay_filter = FILTER_MOVING_AVERAGE; - else if (!strcasecmp("moving_median", value)) - cfg->dds.delay_filter = FILTER_MOVING_MEDIAN; - else - return BAD_VALUE; - } else return parse_item(cfg, NULL, option, value); @@ -677,7 +665,6 @@ struct interface *config_create_interface(char *name, struct config *cfg) void config_init_interface(struct interface *iface, struct config *cfg) { sk_get_ts_info(iface->name, &iface->ts_info); - iface->delay_filter = cfg->dds.delay_filter; } int config_init(struct config *cfg) diff --git a/config.h b/config.h index 2e60706..46767d8 100644 --- a/config.h +++ b/config.h @@ -36,7 +36,6 @@ struct interface { STAILQ_ENTRY(interface) list; char name[MAX_IFNAME_SIZE + 1]; struct sk_ts_info ts_info; - enum filter_type delay_filter; }; #define CFG_IGNORE_TIMESTAMPING (1 << 2) diff --git a/ds.h b/ds.h index 3a175a9..06286a8 100644 --- a/ds.h +++ b/ds.h @@ -53,7 +53,6 @@ struct clock_description { struct default_ds { struct defaultDS dds; struct clock_description clock_desc; - enum filter_type delay_filter; }; struct dataset { diff --git a/port.c b/port.c index 624a070..3984b78 100644 --- a/port.c +++ b/port.c @@ -2566,7 +2566,7 @@ struct port *port_open(int phc_index, config_get_int(cfg, p->name, "fault_reset_interval"); p->tsproc = tsproc_create(config_get_int(cfg, p->name, "tsproc_mode"), - interface->delay_filter, + config_get_int(cfg, p->name, "delay_filter"), config_get_int(cfg, p->name, "delay_filter_length")); if (!p->tsproc) { pr_err("Failed to create time stamp processor"); diff --git a/ptp4l.c b/ptp4l.c index 2e954d6..3888e71 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -57,7 +57,6 @@ static struct config cfg_settings = { .userDescription = { .max_symbols = 128 }, .manufacturerIdentity = { 0, 0, 0 }, }, - .delay_filter = FILTER_MOVING_MEDIAN, }, .timestamping = TS_HARDWARE,