config: convert 'delay_mechanism' to the new scheme.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-15 21:03:02 +02:00
parent 3d1d93bcb2
commit bf29022005
4 changed files with 16 additions and 37 deletions

View File

@ -110,6 +110,13 @@ struct config_item {
#define PORT_ITEM_INT(label, _default, min, max) \
CONFIG_ITEM_INT(label, 1, _default, min, max)
static struct config_enum delay_mech_enu[] = {
{ "Auto", DM_AUTO },
{ "E2E", DM_E2E },
{ "P2P", DM_P2P },
{ NULL, 0 },
};
static struct config_enum nw_trans_enu[] = {
{ "L2", TRANS_IEEE_802_3 },
{ "UDPv4", TRANS_UDP_IPV4 },
@ -126,6 +133,7 @@ struct config_item config_tab[] = {
GLOB_ITEM_INT("clockClass", 248, 0, UINT8_MAX),
PORT_ITEM_INT("delayAsymmetry", 0, INT_MIN, INT_MAX),
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),
PORT_ITEM_INT("egressLatency", 0, INT_MIN, INT_MAX),
PORT_ITEM_INT("fault_badpeernet_interval", 16, INT32_MIN, INT32_MAX),
@ -367,17 +375,7 @@ static enum parser_result parse_port_setting(struct config *cfg,
if (r != NOT_PARSED)
return r;
if (!strcmp(option, "delay_mechanism")) {
if (!strcasecmp("Auto", value))
iface->dm = DM_AUTO;
else if (!strcasecmp("E2E", value))
iface->dm = DM_E2E;
else if (!strcasecmp("P2P", value))
iface->dm = DM_P2P;
else
return BAD_VALUE;
} else if (!strcmp(option, "tsproc_mode")) {
if (!strcmp(option, "tsproc_mode")) {
if (!strcasecmp("filter", value))
iface->tsproc_mode = TSPROC_FILTER;
else if (!strcasecmp("raw", value))
@ -458,18 +456,6 @@ static enum parser_result parse_global_setting(const char *option,
return BAD_VALUE;
}
} else if (!strcmp(option, "delay_mechanism")) {
if (!(cfg_ignore & CFG_IGNORE_DM)) {
if (0 == strcasecmp("E2E", value))
cfg->dm = DM_E2E;
else if (0 == strcasecmp("P2P", value))
cfg->dm = DM_P2P;
else if (0 == strcasecmp("Auto", value))
cfg->dm = DM_AUTO;
else
return BAD_VALUE;
}
} else if (!strcmp(option, "clock_servo")) {
if (!strcasecmp("pi", value))
cfg->clock_servo = CLOCK_SERVO_PI;
@ -705,7 +691,6 @@ struct interface *config_create_interface(char *name, struct config *cfg)
void config_init_interface(struct interface *iface, struct config *cfg)
{
iface->dm = cfg->dm;
sk_get_ts_info(iface->name, &iface->ts_info);
iface->delay_filter = cfg->dds.delay_filter;
}

View File

@ -35,13 +35,11 @@
struct interface {
STAILQ_ENTRY(interface) list;
char name[MAX_IFNAME_SIZE + 1];
enum delay_mechanism dm;
struct sk_ts_info ts_info;
enum tsproc_mode tsproc_mode;
enum filter_type delay_filter;
};
#define CFG_IGNORE_DM (1 << 0)
#define CFG_IGNORE_TIMESTAMPING (1 << 2)
struct config {
@ -56,8 +54,6 @@ struct config {
/* the rest are legacy fields */
enum timestamp_type timestamping;
enum delay_mechanism dm;
struct default_ds dds;
enum servo_type clock_servo;

2
port.c
View File

@ -2550,7 +2550,7 @@ struct port *port_open(int phc_index,
p->portIdentity.clockIdentity = clock_identity(clock);
p->portIdentity.portNumber = number;
p->state = PS_INITIALIZING;
p->delayMechanism = interface->dm;
p->delayMechanism = config_get_int(cfg, p->name, "delay_mechanism");
p->versionNumber = PTP_VERSION;
/* Set fault timeouts to a default value */

14
ptp4l.c
View File

@ -62,7 +62,6 @@ static struct config cfg_settings = {
},
.timestamping = TS_HARDWARE,
.dm = DM_E2E,
.clock_servo = CLOCK_SERVO_PI,
.ptp_dst_mac = ptp_dst_mac,
@ -110,7 +109,6 @@ int main(int argc, char *argv[])
int c;
struct interface *iface;
int *cfg_ignore = &cfg_settings.cfg_ignore;
enum delay_mechanism *dm = &cfg_settings.dm;
enum timestamp_type *timestamping = &cfg_settings.timestamping;
struct clock *clock;
struct config *cfg = &cfg_settings;
@ -130,16 +128,16 @@ int main(int argc, char *argv[])
while (EOF != (c = getopt(argc, argv, "AEP246HSLf:i:p:sl:mqvh"))) {
switch (c) {
case 'A':
*dm = DM_AUTO;
*cfg_ignore |= CFG_IGNORE_DM;
if (config_set_int(cfg, "delay_mechanism", DM_AUTO))
return -1;
break;
case 'E':
*dm = DM_E2E;
*cfg_ignore |= CFG_IGNORE_DM;
if (config_set_int(cfg, "delay_mechanism", DM_E2E))
return -1;
break;
case 'P':
*dm = DM_P2P;
*cfg_ignore |= CFG_IGNORE_DM;
if (config_set_int(cfg, "delay_mechanism", DM_P2P))
return -1;
break;
case '2':
if (config_set_int(cfg, "network_transport",