Allow the PHC index to be configured for each port. The default value is -1, which enables the original behavior using the PHC specified by -p or the index from ETHTOOL_GET_TS_INFO.
Signed-off-by: Miroslav Lichvar <mlich...@redhat.com> --- clock.c | 6 +++++- config.c | 1 + configs/default.cfg | 1 + port.c | 8 +++++--- ptp4l.8 | 5 +++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/clock.c b/clock.c index bbfd1a8..36ce4d8 100644 --- a/clock.c +++ b/clock.c @@ -898,7 +898,7 @@ struct clock *clock_create(enum clock_type type, struct config *config, char ts_label[IF_NAMESIZE], phc[32], *tmp; enum timestamp_type timestamping; int fadj = 0, max_adj = 0, sw_ts; - int phc_index, required_modes = 0; + int phc_index, conf_phc_index, required_modes = 0; struct clock *c = &the_clock; const char *uds_ifname; struct port *p; @@ -1016,6 +1016,8 @@ struct clock *clock_create(enum clock_type type, struct config *config, iface = STAILQ_FIRST(&config->interfaces); + conf_phc_index = config_get_int(config, interface_name(iface), "phc_index"); + /* determine PHC Clock index */ if (config_get_int(config, NULL, "free_running")) { phc_index = -1; @@ -1025,6 +1027,8 @@ struct clock *clock_create(enum clock_type type, struct config *config, if (1 != sscanf(phc_device, "/dev/ptp%d", &phc_index)) { phc_index = -1; } + } else if (conf_phc_index >= 0) { + phc_index = conf_phc_index; } else if (interface_tsinfo_valid(iface)) { phc_index = interface_phc_index(iface); } else { diff --git a/config.c b/config.c index f3c52ba..4f3ceb8 100644 --- a/config.c +++ b/config.c @@ -284,6 +284,7 @@ struct config_item config_tab[] = { PORT_ITEM_INT("operLogPdelayReqInterval", 0, INT8_MIN, INT8_MAX), PORT_ITEM_INT("operLogSyncInterval", 0, INT8_MIN, INT8_MAX), PORT_ITEM_INT("path_trace_enabled", 0, 0, 1), + PORT_ITEM_INT("phc_index", -1, -1, INT_MAX), GLOB_ITEM_DBL("pi_integral_const", 0.0, 0.0, DBL_MAX), GLOB_ITEM_DBL("pi_integral_exponent", 0.4, -DBL_MAX, DBL_MAX), GLOB_ITEM_DBL("pi_integral_norm_max", 0.3, DBL_MIN, 2.0), diff --git a/configs/default.cfg b/configs/default.cfg index cd383b5..26817de 100644 --- a/configs/default.cfg +++ b/configs/default.cfg @@ -106,6 +106,7 @@ delay_filter_length 10 egressLatency 0 ingressLatency 0 boundary_clock_jbod 0 +phc_index -1 # # Clock description # diff --git a/port.c b/port.c index 85b6575..cfa57b8 100644 --- a/port.c +++ b/port.c @@ -3173,7 +3173,9 @@ struct port *port_open(const char *phc_device, goto err_log_name; } - p->phc_index = phc_index; + p->phc_index = config_get_int(cfg, interface_name(interface), "phc_index"); + if (p->phc_index < 0) + p->phc_index = phc_index; p->jbod = config_get_int(cfg, interface_name(interface), "boundary_clock_jbod"); p->master_only = config_get_int(cfg, interface_name(interface), "serverOnly"); p->bmca = config_get_int(cfg, interface_name(interface), "BMCA"); @@ -3200,8 +3202,8 @@ struct port *port_open(const char *phc_device, ; /* UDS cannot have a PHC. */ } else if (!interface_tsinfo_valid(interface)) { pr_warning("%s: get_ts_info not supported", p->log_name); - } else if (phc_index >= 0 && - phc_index != interface_phc_index(interface)) { + } else if (p->phc_index >= 0 && + p->phc_index != interface_phc_index(interface)) { if (p->jbod) { pr_warning("%s: just a bunch of devices", p->log_name); p->phc_index = interface_phc_index(interface); diff --git a/ptp4l.8 b/ptp4l.8 index 8c2969f..5ef471b 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -375,6 +375,11 @@ collection of clocks must be synchronized by an external program, for example phc2sys(8) in "automatic" mode. The default is 0 (disabled). .TP +.B phc_index +Specifies the index of the PHC to be used for synchronization with hardware +timestamping. The default is -1, which means the index will be set to the PHC +associated with the interface, or the device specified by the \fB-p\fP option. +.TP .B udp_ttl Specifies the Time to live (TTL) value for IPv4 multicast messages and the hop limit for IPv6 multicast messages. This option is only relevant with the IPv4 -- 2.35.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel