config: convert 'network_transport' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
5d184839d0
commit
3d1d93bcb2
5
clock.c
5
clock.c
|
@ -819,7 +819,10 @@ struct clock *clock_create(struct config *config, int phc_index,
|
||||||
clock_destroy(c);
|
clock_destroy(c);
|
||||||
|
|
||||||
snprintf(udsif->name, sizeof(udsif->name), "%s", uds_path);
|
snprintf(udsif->name, sizeof(udsif->name), "%s", uds_path);
|
||||||
udsif->transport = TRANS_UDS;
|
if (config_set_section_int(config, udsif->name,
|
||||||
|
"network_transport", TRANS_UDS)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (config_set_section_int(config, udsif->name, "delay_filter_length", 1)) {
|
if (config_set_section_int(config, udsif->name, "delay_filter_length", 1)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
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 nw_trans_enu[] = {
|
||||||
|
{ "L2", TRANS_IEEE_802_3 },
|
||||||
|
{ "UDPv4", TRANS_UDP_IPV4 },
|
||||||
|
{ "UDPv6", TRANS_UDP_IPV6 },
|
||||||
|
{ NULL, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
struct config_item config_tab[] = {
|
struct config_item config_tab[] = {
|
||||||
PORT_ITEM_INT("announceReceiptTimeout", 3, 2, UINT8_MAX),
|
PORT_ITEM_INT("announceReceiptTimeout", 3, 2, UINT8_MAX),
|
||||||
GLOB_ITEM_INT("assume_two_step", 0, 0, 1),
|
GLOB_ITEM_INT("assume_two_step", 0, 0, 1),
|
||||||
|
@ -138,6 +145,7 @@ struct config_item config_tab[] = {
|
||||||
GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX),
|
GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX),
|
||||||
PORT_ITEM_INT("min_neighbor_prop_delay", -20000000, INT_MIN, -1),
|
PORT_ITEM_INT("min_neighbor_prop_delay", -20000000, INT_MIN, -1),
|
||||||
PORT_ITEM_INT("neighborPropDelayThresh", 20000000, 0, INT_MAX),
|
PORT_ITEM_INT("neighborPropDelayThresh", 20000000, 0, INT_MAX),
|
||||||
|
PORT_ITEM_ENU("network_transport", TRANS_UDP_IPV4, nw_trans_enu),
|
||||||
GLOB_ITEM_INT("ntpshm_segment", 0, INT_MIN, INT_MAX),
|
GLOB_ITEM_INT("ntpshm_segment", 0, INT_MIN, INT_MAX),
|
||||||
GLOB_ITEM_INT("offsetScaledLogVariance", 0xffff, 0, UINT16_MAX),
|
GLOB_ITEM_INT("offsetScaledLogVariance", 0xffff, 0, UINT16_MAX),
|
||||||
PORT_ITEM_INT("path_trace_enabled", 0, 0, 1),
|
PORT_ITEM_INT("path_trace_enabled", 0, 0, 1),
|
||||||
|
@ -359,17 +367,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, "network_transport")) {
|
if (!strcmp(option, "delay_mechanism")) {
|
||||||
if (!strcasecmp("L2", value))
|
|
||||||
iface->transport = TRANS_IEEE_802_3;
|
|
||||||
else if (!strcasecmp("UDPv4", value))
|
|
||||||
iface->transport = TRANS_UDP_IPV4;
|
|
||||||
else if (!strcasecmp("UDPv6", value))
|
|
||||||
iface->transport = TRANS_UDP_IPV6;
|
|
||||||
else
|
|
||||||
return BAD_VALUE;
|
|
||||||
|
|
||||||
} else if (!strcmp(option, "delay_mechanism")) {
|
|
||||||
if (!strcasecmp("Auto", value))
|
if (!strcasecmp("Auto", value))
|
||||||
iface->dm = DM_AUTO;
|
iface->dm = DM_AUTO;
|
||||||
else if (!strcasecmp("E2E", value))
|
else if (!strcasecmp("E2E", value))
|
||||||
|
@ -472,18 +470,6 @@ static enum parser_result parse_global_setting(const char *option,
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!strcmp(option, "network_transport")) {
|
|
||||||
if (!(cfg_ignore & CFG_IGNORE_TRANSPORT)) {
|
|
||||||
if (!strcasecmp("UDPv4", value))
|
|
||||||
cfg->transport = TRANS_UDP_IPV4;
|
|
||||||
else if (!strcasecmp("UDPv6", value))
|
|
||||||
cfg->transport = TRANS_UDP_IPV6;
|
|
||||||
else if (!strcasecmp("L2", value))
|
|
||||||
cfg->transport = TRANS_IEEE_802_3;
|
|
||||||
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;
|
||||||
|
@ -720,7 +706,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;
|
iface->dm = cfg->dm;
|
||||||
iface->transport = cfg->transport;
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
3
config.h
3
config.h
|
@ -36,14 +36,12 @@ 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;
|
enum delay_mechanism dm;
|
||||||
enum transport_type transport;
|
|
||||||
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_DM (1 << 0)
|
||||||
#define CFG_IGNORE_TRANSPORT (1 << 1)
|
|
||||||
#define CFG_IGNORE_TIMESTAMPING (1 << 2)
|
#define CFG_IGNORE_TIMESTAMPING (1 << 2)
|
||||||
|
|
||||||
struct config {
|
struct config {
|
||||||
|
@ -58,7 +56,6 @@ struct config {
|
||||||
|
|
||||||
/* the rest are legacy fields */
|
/* the rest are legacy fields */
|
||||||
enum timestamp_type timestamping;
|
enum timestamp_type timestamping;
|
||||||
enum transport_type transport;
|
|
||||||
enum delay_mechanism dm;
|
enum delay_mechanism dm;
|
||||||
|
|
||||||
struct default_ds dds;
|
struct default_ds dds;
|
||||||
|
|
6
port.c
6
port.c
|
@ -2506,6 +2506,7 @@ struct port *port_open(int phc_index,
|
||||||
{
|
{
|
||||||
struct config *cfg = clock_config(clock);
|
struct config *cfg = clock_config(clock);
|
||||||
struct port *p = malloc(sizeof(*p));
|
struct port *p = malloc(sizeof(*p));
|
||||||
|
enum transport_type transport;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!p)
|
if (!p)
|
||||||
|
@ -2515,8 +2516,9 @@ struct port *port_open(int phc_index,
|
||||||
|
|
||||||
p->phc_index = phc_index;
|
p->phc_index = phc_index;
|
||||||
p->jbod = config_get_int(cfg, interface->name, "boundary_clock_jbod");
|
p->jbod = config_get_int(cfg, interface->name, "boundary_clock_jbod");
|
||||||
|
transport = config_get_int(cfg, interface->name, "network_transport");
|
||||||
|
|
||||||
if (interface->transport == TRANS_UDS)
|
if (transport == TRANS_UDS)
|
||||||
; /* UDS cannot have a PHC. */
|
; /* UDS cannot have a PHC. */
|
||||||
else if (!interface->ts_info.valid)
|
else if (!interface->ts_info.valid)
|
||||||
pr_warning("port %d: get_ts_info not supported", number);
|
pr_warning("port %d: get_ts_info not supported", number);
|
||||||
|
@ -2541,7 +2543,7 @@ struct port *port_open(int phc_index,
|
||||||
p->rx_timestamp_offset = config_get_int(cfg, p->name, "ingressLatency");
|
p->rx_timestamp_offset = config_get_int(cfg, p->name, "ingressLatency");
|
||||||
p->tx_timestamp_offset = config_get_int(cfg, p->name, "egressLatency");
|
p->tx_timestamp_offset = config_get_int(cfg, p->name, "egressLatency");
|
||||||
p->clock = clock;
|
p->clock = clock;
|
||||||
p->trp = transport_create(cfg, interface->transport);
|
p->trp = transport_create(cfg, transport);
|
||||||
if (!p->trp)
|
if (!p->trp)
|
||||||
goto err_port;
|
goto err_port;
|
||||||
p->timestamping = timestamping;
|
p->timestamping = timestamping;
|
||||||
|
|
17
ptp4l.c
17
ptp4l.c
|
@ -63,7 +63,6 @@ static struct config cfg_settings = {
|
||||||
|
|
||||||
.timestamping = TS_HARDWARE,
|
.timestamping = TS_HARDWARE,
|
||||||
.dm = DM_E2E,
|
.dm = DM_E2E,
|
||||||
.transport = TRANS_UDP_IPV4,
|
|
||||||
.clock_servo = CLOCK_SERVO_PI,
|
.clock_servo = CLOCK_SERVO_PI,
|
||||||
|
|
||||||
.ptp_dst_mac = ptp_dst_mac,
|
.ptp_dst_mac = ptp_dst_mac,
|
||||||
|
@ -112,7 +111,6 @@ int main(int argc, char *argv[])
|
||||||
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 delay_mechanism *dm = &cfg_settings.dm;
|
||||||
enum transport_type *transport = &cfg_settings.transport;
|
|
||||||
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;
|
||||||
|
@ -144,16 +142,19 @@ int main(int argc, char *argv[])
|
||||||
*cfg_ignore |= CFG_IGNORE_DM;
|
*cfg_ignore |= CFG_IGNORE_DM;
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
*transport = TRANS_IEEE_802_3;
|
if (config_set_int(cfg, "network_transport",
|
||||||
*cfg_ignore |= CFG_IGNORE_TRANSPORT;
|
TRANS_IEEE_802_3))
|
||||||
|
return -1;
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
*transport = TRANS_UDP_IPV4;
|
if (config_set_int(cfg, "network_transport",
|
||||||
*cfg_ignore |= CFG_IGNORE_TRANSPORT;
|
TRANS_UDP_IPV4))
|
||||||
|
return -1;
|
||||||
break;
|
break;
|
||||||
case '6':
|
case '6':
|
||||||
*transport = TRANS_UDP_IPV6;
|
if (config_set_int(cfg, "network_transport",
|
||||||
*cfg_ignore |= CFG_IGNORE_TRANSPORT;
|
TRANS_UDP_IPV6))
|
||||||
|
return -1;
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
*timestamping = TS_HARDWARE;
|
*timestamping = TS_HARDWARE;
|
||||||
|
|
Loading…
Reference in New Issue