config: convert 'delay_filter' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This commit is contained in:
		
							parent
							
								
									a8b550887d
								
							
						
					
					
						commit
						b6a91303a9
					
				
							
								
								
									
										2
									
								
								clock.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								clock.c
									
									
									
									
									
								
							| @ -880,7 +880,7 @@ struct clock *clock_create(struct config *config, int phc_index, | |||||||
| 	c->servo_state = SERVO_UNLOCKED; | 	c->servo_state = SERVO_UNLOCKED; | ||||||
| 	c->servo_type = servo; | 	c->servo_type = servo; | ||||||
| 	c->tsproc = tsproc_create(config_get_int(config, NULL, "tsproc_mode"), | 	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")); | 				  config_get_int(config, NULL, "delay_filter_length")); | ||||||
| 	if (!c->tsproc) { | 	if (!c->tsproc) { | ||||||
| 		pr_err("Failed to create time stamp processor"); | 		pr_err("Failed to create time stamp processor"); | ||||||
|  | |||||||
							
								
								
									
										29
									
								
								config.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								config.c
									
									
									
									
									
								
							| @ -110,6 +110,12 @@ struct config_item { | |||||||
| #define PORT_ITEM_INT(label, _default, min, max) \ | #define PORT_ITEM_INT(label, _default, min, max) \ | ||||||
| 	CONFIG_ITEM_INT(label, 1, _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[] = { | static struct config_enum delay_mech_enu[] = { | ||||||
| 	{ "Auto", DM_AUTO }, | 	{ "Auto", DM_AUTO }, | ||||||
| 	{ "E2E",  DM_E2E }, | 	{ "E2E",  DM_E2E }, | ||||||
| @ -140,6 +146,7 @@ struct config_item config_tab[] = { | |||||||
| 	GLOB_ITEM_INT("clockAccuracy", 0xfe, 0, UINT8_MAX), | 	GLOB_ITEM_INT("clockAccuracy", 0xfe, 0, UINT8_MAX), | ||||||
| 	GLOB_ITEM_INT("clockClass", 248, 0, UINT8_MAX), | 	GLOB_ITEM_INT("clockClass", 248, 0, UINT8_MAX), | ||||||
| 	PORT_ITEM_INT("delayAsymmetry", 0, INT_MIN, INT_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_INT("delay_filter_length", 10, 1, INT_MAX), | ||||||
| 	PORT_ITEM_ENU("delay_mechanism", DM_E2E, delay_mech_enu), | 	PORT_ITEM_ENU("delay_mechanism", DM_E2E, delay_mech_enu), | ||||||
| 	GLOB_ITEM_INT("domainNumber", 0, 0, 127), | 	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) | 	if (r != NOT_PARSED) | ||||||
| 		return r; | 		return r; | ||||||
| 
 | 
 | ||||||
| 	if (!strcmp(option, "delay_filter")) { | 	return parse_item(cfg, iface->name, option, value); | ||||||
| 		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; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int count_char(const char *str, char c) | 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++) | 		for (i = 0; i < OUI_LEN; i++) | ||||||
| 			cfg->dds.clock_desc.manufacturerIdentity[i] = oui[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 | 	} else | ||||||
| 		return parse_item(cfg, NULL, option, value); | 		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) | void config_init_interface(struct interface *iface, struct config *cfg) | ||||||
| { | { | ||||||
| 	sk_get_ts_info(iface->name, &iface->ts_info); | 	sk_get_ts_info(iface->name, &iface->ts_info); | ||||||
| 	iface->delay_filter = cfg->dds.delay_filter; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int config_init(struct config *cfg) | int config_init(struct config *cfg) | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								config.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								config.h
									
									
									
									
									
								
							| @ -36,7 +36,6 @@ struct interface { | |||||||
| 	STAILQ_ENTRY(interface) list; | 	STAILQ_ENTRY(interface) list; | ||||||
| 	char name[MAX_IFNAME_SIZE + 1]; | 	char name[MAX_IFNAME_SIZE + 1]; | ||||||
| 	struct sk_ts_info ts_info; | 	struct sk_ts_info ts_info; | ||||||
| 	enum filter_type delay_filter; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #define CFG_IGNORE_TIMESTAMPING (1 << 2) | #define CFG_IGNORE_TIMESTAMPING (1 << 2) | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								ds.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								ds.h
									
									
									
									
									
								
							| @ -53,7 +53,6 @@ struct clock_description { | |||||||
| struct default_ds { | struct default_ds { | ||||||
| 	struct defaultDS dds; | 	struct defaultDS dds; | ||||||
| 	struct clock_description clock_desc; | 	struct clock_description clock_desc; | ||||||
| 	enum filter_type delay_filter; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct dataset { | struct dataset { | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								port.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								port.c
									
									
									
									
									
								
							| @ -2566,7 +2566,7 @@ struct port *port_open(int phc_index, | |||||||
| 		config_get_int(cfg, p->name, "fault_reset_interval"); | 		config_get_int(cfg, p->name, "fault_reset_interval"); | ||||||
| 
 | 
 | ||||||
| 	p->tsproc = tsproc_create(config_get_int(cfg, p->name, "tsproc_mode"), | 	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")); | 				  config_get_int(cfg, p->name, "delay_filter_length")); | ||||||
| 	if (!p->tsproc) { | 	if (!p->tsproc) { | ||||||
| 		pr_err("Failed to create time stamp processor"); | 		pr_err("Failed to create time stamp processor"); | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								ptp4l.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								ptp4l.c
									
									
									
									
									
								
							| @ -57,7 +57,6 @@ static struct config cfg_settings = { | |||||||
| 			.userDescription      = { .max_symbols = 128 }, | 			.userDescription      = { .max_symbols = 128 }, | ||||||
| 			.manufacturerIdentity = { 0, 0, 0 }, | 			.manufacturerIdentity = { 0, 0, 0 }, | ||||||
| 		}, | 		}, | ||||||
| 		.delay_filter = FILTER_MOVING_MEDIAN, |  | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	.timestamping = TS_HARDWARE, | 	.timestamping = TS_HARDWARE, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user