config: convert 'delay_mechanism' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
3d1d93bcb2
commit
bf29022005
33
config.c
33
config.c
|
@ -110,6 +110,13 @@ 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_mech_enu[] = {
|
||||||
|
{ "Auto", DM_AUTO },
|
||||||
|
{ "E2E", DM_E2E },
|
||||||
|
{ "P2P", DM_P2P },
|
||||||
|
{ NULL, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
static struct config_enum nw_trans_enu[] = {
|
static struct config_enum nw_trans_enu[] = {
|
||||||
{ "L2", TRANS_IEEE_802_3 },
|
{ "L2", TRANS_IEEE_802_3 },
|
||||||
{ "UDPv4", TRANS_UDP_IPV4 },
|
{ "UDPv4", TRANS_UDP_IPV4 },
|
||||||
|
@ -126,6 +133,7 @@ struct config_item config_tab[] = {
|
||||||
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_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),
|
||||||
GLOB_ITEM_INT("domainNumber", 0, 0, 127),
|
GLOB_ITEM_INT("domainNumber", 0, 0, 127),
|
||||||
PORT_ITEM_INT("egressLatency", 0, INT_MIN, INT_MAX),
|
PORT_ITEM_INT("egressLatency", 0, INT_MIN, INT_MAX),
|
||||||
PORT_ITEM_INT("fault_badpeernet_interval", 16, INT32_MIN, INT32_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)
|
if (r != NOT_PARSED)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (!strcmp(option, "delay_mechanism")) {
|
if (!strcmp(option, "tsproc_mode")) {
|
||||||
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 (!strcasecmp("filter", value))
|
if (!strcasecmp("filter", value))
|
||||||
iface->tsproc_mode = TSPROC_FILTER;
|
iface->tsproc_mode = TSPROC_FILTER;
|
||||||
else if (!strcasecmp("raw", value))
|
else if (!strcasecmp("raw", value))
|
||||||
|
@ -458,18 +456,6 @@ static enum parser_result parse_global_setting(const char *option,
|
||||||
return BAD_VALUE;
|
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")) {
|
} else if (!strcmp(option, "clock_servo")) {
|
||||||
if (!strcasecmp("pi", value))
|
if (!strcasecmp("pi", value))
|
||||||
cfg->clock_servo = CLOCK_SERVO_PI;
|
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)
|
void config_init_interface(struct interface *iface, struct config *cfg)
|
||||||
{
|
{
|
||||||
iface->dm = cfg->dm;
|
|
||||||
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;
|
iface->delay_filter = cfg->dds.delay_filter;
|
||||||
}
|
}
|
||||||
|
|
4
config.h
4
config.h
|
@ -35,13 +35,11 @@
|
||||||
struct interface {
|
struct interface {
|
||||||
STAILQ_ENTRY(interface) list;
|
STAILQ_ENTRY(interface) list;
|
||||||
char name[MAX_IFNAME_SIZE + 1];
|
char name[MAX_IFNAME_SIZE + 1];
|
||||||
enum delay_mechanism dm;
|
|
||||||
struct sk_ts_info ts_info;
|
struct sk_ts_info ts_info;
|
||||||
enum tsproc_mode tsproc_mode;
|
enum tsproc_mode tsproc_mode;
|
||||||
enum filter_type delay_filter;
|
enum filter_type delay_filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CFG_IGNORE_DM (1 << 0)
|
|
||||||
#define CFG_IGNORE_TIMESTAMPING (1 << 2)
|
#define CFG_IGNORE_TIMESTAMPING (1 << 2)
|
||||||
|
|
||||||
struct config {
|
struct config {
|
||||||
|
@ -56,8 +54,6 @@ struct config {
|
||||||
|
|
||||||
/* the rest are legacy fields */
|
/* the rest are legacy fields */
|
||||||
enum timestamp_type timestamping;
|
enum timestamp_type timestamping;
|
||||||
enum delay_mechanism dm;
|
|
||||||
|
|
||||||
struct default_ds dds;
|
struct default_ds dds;
|
||||||
enum servo_type clock_servo;
|
enum servo_type clock_servo;
|
||||||
|
|
||||||
|
|
2
port.c
2
port.c
|
@ -2550,7 +2550,7 @@ struct port *port_open(int phc_index,
|
||||||
p->portIdentity.clockIdentity = clock_identity(clock);
|
p->portIdentity.clockIdentity = clock_identity(clock);
|
||||||
p->portIdentity.portNumber = number;
|
p->portIdentity.portNumber = number;
|
||||||
p->state = PS_INITIALIZING;
|
p->state = PS_INITIALIZING;
|
||||||
p->delayMechanism = interface->dm;
|
p->delayMechanism = config_get_int(cfg, p->name, "delay_mechanism");
|
||||||
p->versionNumber = PTP_VERSION;
|
p->versionNumber = PTP_VERSION;
|
||||||
|
|
||||||
/* Set fault timeouts to a default value */
|
/* Set fault timeouts to a default value */
|
||||||
|
|
14
ptp4l.c
14
ptp4l.c
|
@ -62,7 +62,6 @@ static struct config cfg_settings = {
|
||||||
},
|
},
|
||||||
|
|
||||||
.timestamping = TS_HARDWARE,
|
.timestamping = TS_HARDWARE,
|
||||||
.dm = DM_E2E,
|
|
||||||
.clock_servo = CLOCK_SERVO_PI,
|
.clock_servo = CLOCK_SERVO_PI,
|
||||||
|
|
||||||
.ptp_dst_mac = ptp_dst_mac,
|
.ptp_dst_mac = ptp_dst_mac,
|
||||||
|
@ -110,7 +109,6 @@ int main(int argc, char *argv[])
|
||||||
int c;
|
int c;
|
||||||
struct interface *iface;
|
struct interface *iface;
|
||||||
int *cfg_ignore = &cfg_settings.cfg_ignore;
|
int *cfg_ignore = &cfg_settings.cfg_ignore;
|
||||||
enum delay_mechanism *dm = &cfg_settings.dm;
|
|
||||||
enum timestamp_type *timestamping = &cfg_settings.timestamping;
|
enum timestamp_type *timestamping = &cfg_settings.timestamping;
|
||||||
struct clock *clock;
|
struct clock *clock;
|
||||||
struct config *cfg = &cfg_settings;
|
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"))) {
|
while (EOF != (c = getopt(argc, argv, "AEP246HSLf:i:p:sl:mqvh"))) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'A':
|
case 'A':
|
||||||
*dm = DM_AUTO;
|
if (config_set_int(cfg, "delay_mechanism", DM_AUTO))
|
||||||
*cfg_ignore |= CFG_IGNORE_DM;
|
return -1;
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
*dm = DM_E2E;
|
if (config_set_int(cfg, "delay_mechanism", DM_E2E))
|
||||||
*cfg_ignore |= CFG_IGNORE_DM;
|
return -1;
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
*dm = DM_P2P;
|
if (config_set_int(cfg, "delay_mechanism", DM_P2P))
|
||||||
*cfg_ignore |= CFG_IGNORE_DM;
|
return -1;
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if (config_set_int(cfg, "network_transport",
|
if (config_set_int(cfg, "network_transport",
|
||||||
|
|
Loading…
Reference in New Issue