From: Richard C. <ric...@gm...> - 2018-04-20 16:09:06
|
This series adds support for the alternate BMCA and custom attributes needed to support the various telecom profiles. Version 1 of the series was posted back on August 18, 2017. Changes in V2: ~~~~~~~~~~~~~~ - Address review comments regarding configuration variable naming - change "notSlave" attribute to "masterOnly" (the published profiles couldn't be bothered to keep the same name from one edition to the next) - Drop first four patches (as these are already merged) Richard Cochran (6): telecom: Introduce the local priority attribute into the data set. telecom: Add the data set comparison algorithm from the Telecom Profiles. telecom: Add a configuration option for G.8275.defaultDS.localPriority. telecom: Add a configuration option for G.8275.portDS.localPriority. telecom: Add a configuration option to use the alternate BMCA. telecom: Introduce the G.8275.masterOnly option. bmc.h | 17 ++++++++++++++ clock.c | 8 ++++++- config.c | 12 ++++++++++ default.cfg | 4 ++++ ds.h | 1 + gPTP.cfg | 4 ++++ makefile | 2 +- port.c | 12 +++++++++- port_private.h | 2 ++ ptp4l.8 | 36 +++++++++++++++++++++++++++++ telecom.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 168 insertions(+), 3 deletions(-) create mode 100644 telecom.c -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-25 05:03:21
|
This series adds support for the alternate BMCA and custom attributes needed to support the various telecom profiles. Changes in V3: ~~~~~~~~~~~~~~ - Refactor the duplication of the data set comparison function. - Drop the G.8275. prefix from the "masterOnly" option. - Document the "dataset_comparison" in the man page. Changes in V2: ~~~~~~~~~~~~~~ - Address review comments regarding configuration variable naming - change "notSlave" attribute to "masterOnly" (the published profiles couldn't be bothered to keep the same name from one edition to the next) - Drop first four patches (as these are already merged) Richard Cochran (7): Refactor the data set comparison function variable. telecom: Introduce the local priority attribute into the data set. telecom: Add the data set comparison algorithm from the Telecom Profiles. telecom: Add a configuration option for G.8275.defaultDS.localPriority. telecom: Add a configuration option for G.8275.portDS.localPriority. telecom: Add a configuration option to use the alternate BMCA. telecom: Introduce the masterOnly option. bmc.h | 17 ++++++++++++++ clock.c | 13 ++++++++++- clock.h | 7 ++++++ config.c | 12 ++++++++++ default.cfg | 4 ++++ ds.h | 1 + gPTP.cfg | 4 ++++ makefile | 2 +- port.c | 11 +++++++-- port_private.h | 3 ++- ptp4l.8 | 41 +++++++++++++++++++++++++++++++++ telecom.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 telecom.c -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-25 05:03:22
|
There is no need to keep two copies of the data set comparison function. This patch adds a method that allows the port code to obtain the function from the clock code. Signed-off-by: Richard Cochran <ric...@gm...> --- clock.c | 5 +++++ clock.h | 7 +++++++ port.c | 5 +++-- port_private.h | 1 - 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/clock.c b/clock.c index afee960..2cefd9f 100644 --- a/clock.c +++ b/clock.c @@ -758,6 +758,11 @@ struct config *clock_config(struct clock *c) return c->config; } +int (*clock_dscmp(struct clock *c))(struct dataset *a, struct dataset *b) +{ + return c->dscmp; +} + struct currentDS *clock_current_dataset(struct clock *c) { return &c->cur; diff --git a/clock.h b/clock.h index 3fa026d..d6a79bd 100644 --- a/clock.h +++ b/clock.h @@ -80,6 +80,13 @@ struct config *clock_config(struct clock *c); struct currentDS *clock_current_dataset(struct clock *c); /** + * Obtains the clock's data set comparison function. + * @param c The clock instance. + * @return A pointer to the data set comparison function, without fail. + */ +int (*clock_dscmp(struct clock *c))(struct dataset *a, struct dataset *b); + +/** * Obtains the required time stamping mode. * @param c The clock instance. * @return The value of required time stamping mode, which is a bit mask diff --git a/port.c b/port.c index 1757dfe..9afc06b 100644 --- a/port.c +++ b/port.c @@ -2191,9 +2191,11 @@ void port_close(struct port *p) struct foreign_clock *port_compute_best(struct port *p) { + int (*dscmp)(struct dataset *a, struct dataset *b); struct foreign_clock *fc; struct ptp_message *tmp; + dscmp = clock_dscmp(p->clock); p->best = NULL; LIST_FOREACH(fc, &p->foreign_masters, list) { @@ -2210,7 +2212,7 @@ struct foreign_clock *port_compute_best(struct port *p) if (!p->best) p->best = fc; - else if (p->dscmp(&fc->dataset, &p->best->dataset) > 0) + else if (dscmp(&fc->dataset, &p->best->dataset) > 0) p->best = fc; else fc_clear(fc); @@ -2784,7 +2786,6 @@ struct port *port_open(int phc_index, } p->state_machine = clock_slave_only(clock) ? ptp_slave_fsm : ptp_fsm; - p->dscmp = dscmp; p->phc_index = phc_index; p->jbod = config_get_int(cfg, interface->name, "boundary_clock_jbod"); transport = config_get_int(cfg, interface->name, "network_transport"); diff --git a/port_private.h b/port_private.h index 860a2bb..f8771c7 100644 --- a/port_private.h +++ b/port_private.h @@ -88,7 +88,6 @@ struct port { unsigned int multiple_pdr_detected; enum port_state (*state_machine)(enum port_state state, enum fsm_event event, int mdiff); - int (*dscmp)(struct dataset *a, struct dataset *b); /* portDS */ struct PortIdentity portIdentity; enum port_state state; /*portState*/ -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-25 05:03:23
|
The Telecom Profiles G.8275.1 and G.8275.2 have invented a new per-port and per-clock attribute, not in 1588, called "localPriority". The use of this attribute is a distinguishing feature of the telecom data set comparison algorithm. This patch adds the attribute, hard coded to its default value. Signed-off-by: Richard Cochran <ric...@gm...> --- clock.c | 1 + ds.h | 1 + port.c | 1 + 3 files changed, 3 insertions(+) diff --git a/clock.c b/clock.c index 2cefd9f..19ce805 100644 --- a/clock.c +++ b/clock.c @@ -931,6 +931,7 @@ struct clock *clock_create(enum clock_type type, struct config *config, c->dds.flags & DDS_SLAVE_ONLY) { c->dds.clockQuality.clockClass = 255; } + c->default_dataset.localPriority = 128; /* Harmonize the twoStepFlag with the time_stamping option. */ if (config_harmonize_onestep(config)) { diff --git a/ds.h b/ds.h index 0e48d05..9d9c417 100644 --- a/ds.h +++ b/ds.h @@ -55,6 +55,7 @@ struct dataset { struct ClockIdentity identity; struct ClockQuality quality; UInteger8 priority2; + UInteger8 localPriority; /* Telecom Profile only */ UInteger16 stepsRemoved; struct PortIdentity sender; struct PortIdentity receiver; diff --git a/port.c b/port.c index 9afc06b..fc65153 100644 --- a/port.c +++ b/port.c @@ -77,6 +77,7 @@ static void announce_to_dataset(struct ptp_message *m, struct port *p, out->identity = a->grandmasterIdentity; out->quality = a->grandmasterClockQuality; out->priority2 = a->grandmasterPriority2; + out->localPriority = 128; out->stepsRemoved = a->stepsRemoved; out->sender = m->header.sourcePortIdentity; out->receiver = p->portIdentity; -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-25 05:03:25
|
Signed-off-by: Richard Cochran <ric...@gm...> --- clock.c | 3 ++- config.c | 1 + default.cfg | 1 + gPTP.cfg | 1 + ptp4l.8 | 14 ++++++++++++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clock.c b/clock.c index 19ce805..90f5b0f 100644 --- a/clock.c +++ b/clock.c @@ -931,7 +931,8 @@ struct clock *clock_create(enum clock_type type, struct config *config, c->dds.flags & DDS_SLAVE_ONLY) { c->dds.clockQuality.clockClass = 255; } - c->default_dataset.localPriority = 128; + c->default_dataset.localPriority = + config_get_int(config, NULL, "G.8275.defaultDS.localPriority"); /* Harmonize the twoStepFlag with the time_stamping option. */ if (config_harmonize_onestep(config)) { diff --git a/config.c b/config.c index 320cc1b..9c26ccd 100644 --- a/config.c +++ b/config.c @@ -192,6 +192,7 @@ struct config_item config_tab[] = { PORT_ITEM_INT("follow_up_info", 0, 0, 1), GLOB_ITEM_INT("free_running", 0, 0, 1), PORT_ITEM_INT("freq_est_interval", 1, 0, INT_MAX), + GLOB_ITEM_INT("G.8275.defaultDS.localPriority", 128, 1, UINT8_MAX), GLOB_ITEM_INT("gmCapable", 1, 0, 1), PORT_ITEM_INT("hybrid_e2e", 0, 0, 1), PORT_ITEM_INT("ignore_transport_specific", 0, 0, 1), diff --git a/default.cfg b/default.cfg index e76aeae..9736568 100644 --- a/default.cfg +++ b/default.cfg @@ -15,6 +15,7 @@ free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 +G.8275.defaultDS.localPriority 128 # # Port Data Set # diff --git a/gPTP.cfg b/gPTP.cfg index 1e7a33e..02fd395 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -13,6 +13,7 @@ clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 +G.8275.defaultDS.localPriority 128 # # Port Data Set # diff --git a/ptp4l.8 b/ptp4l.8 index 950e07c..10f55f2 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -341,6 +341,20 @@ The offsetScaledLogVariance attribute of the local clock. It characterizes the stability of the clock. The default is 0xFFFF. .TP +.B G.8275.defaultDS.localPriority +The Telecom Profiles (ITU-T G.8275.1 and G.8275.2) specify an +alternate Best Master Clock Algorithm (BMCA) with a unique data set +comparison algorithm. The value of this option is associated with the +local clock and is used as a tie breaker whenever clockClass, +clockAccuracy, offsetScaledLogVariance, and priority2 are equal. This +option is only used when "dataset_comparison" is set to "telecom". +The default value is 128. + +Warning: the BMCA is guaranteed to produce a spanning tree (that is, a +timing network without loops) only when using the default values of +G.8275.defaultDS.localPriority and G.8275.portDS.localPriority. +Careful network engineering is needed when using non-default values. +.TP .B domainNumber The domain attribute of the local clock. The default is 0. -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-25 05:03:27
|
Signed-off-by: Richard Cochran <ric...@gm...> --- bmc.h | 5 +++++ clock.c | 6 +++++- config.c | 9 +++++++++ default.cfg | 1 + gPTP.cfg | 1 + ptp4l.8 | 5 +++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/bmc.h b/bmc.h index 3f4b5fa..2901cda 100644 --- a/bmc.h +++ b/bmc.h @@ -29,6 +29,11 @@ #define B_BETTER -1 #define B_BETTER_TOPO -2 +enum { + DS_CMP_IEEE1588, + DS_CMP_G8275, +}; + /** * BMC state decision algorithm. * @param c The local clock. diff --git a/clock.c b/clock.c index 90f5b0f..08f0c42 100644 --- a/clock.c +++ b/clock.c @@ -1064,7 +1064,11 @@ struct clock *clock_create(enum clock_type type, struct config *config, } c->servo_state = SERVO_UNLOCKED; c->servo_type = servo; - c->dscmp = dscmp; + if (config_get_int(config, NULL, "dataset_comparison") == DS_CMP_G8275) { + c->dscmp = telecom_dscmp; + } else { + c->dscmp = dscmp; + } c->tsproc = tsproc_create(config_get_int(config, NULL, "tsproc_mode"), config_get_int(config, NULL, "delay_filter"), config_get_int(config, NULL, "delay_filter_length")); diff --git a/config.c b/config.c index f75092e..0b656b7 100644 --- a/config.c +++ b/config.c @@ -22,6 +22,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> + +#include "bmc.h" #include "config.h" #include "ether.h" #include "hash.h" @@ -133,6 +135,12 @@ static struct config_enum clock_servo_enu[] = { { NULL, 0 }, }; +static struct config_enum dataset_comp_enu[] = { + { "ieee1588", DS_CMP_IEEE1588 }, + { "G.8275.x", DS_CMP_G8275 }, + { NULL, 0 }, +}; + static struct config_enum delay_filter_enu[] = { { "moving_average", FILTER_MOVING_AVERAGE }, { "moving_median", FILTER_MOVING_MEDIAN }, @@ -178,6 +186,7 @@ struct config_item config_tab[] = { GLOB_ITEM_INT("clockAccuracy", 0xfe, 0, UINT8_MAX), GLOB_ITEM_INT("clockClass", 248, 0, UINT8_MAX), GLOB_ITEM_ENU("clock_servo", CLOCK_SERVO_PI, clock_servo_enu), + GLOB_ITEM_ENU("dataset_comparison", DS_CMP_IEEE1588, dataset_comp_enu), 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), diff --git a/default.cfg b/default.cfg index 24836dd..d7b78f2 100644 --- a/default.cfg +++ b/default.cfg @@ -15,6 +15,7 @@ free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 +dataset_comparison ieee1588 G.8275.defaultDS.localPriority 128 # # Port Data Set diff --git a/gPTP.cfg b/gPTP.cfg index 095a444..14859e1 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -13,6 +13,7 @@ clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 +dataset_comparison ieee1588 G.8275.defaultDS.localPriority 128 # # Port Data Set diff --git a/ptp4l.8 b/ptp4l.8 index 11e3cc0..011bd02 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -534,6 +534,11 @@ streaming standards out there that recommend specific values for this option. For example 34 (AF41 PHB) in AES67 or 46 (EF PHB) in RAVENNA. The default is 0. .TP +.B dataset_comparison +Specifies the method to be used when comparing data sets during the +Best Master Clock Algorithm. The possible values are "ieee1588" and +"G.8275.x". The default is "ieee1588". +.TP .B logging_level The maximum logging level of messages which should be printed. The default is 6 (LOG_INFO). -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-25 05:03:26
|
The first half of the telecom algorithm from G.8275.1 and G.8275.2 differs from the one in 1588, making use of profile specific "localPriority" attributes. Signed-off-by: Richard Cochran <ric...@gm...> --- bmc.h | 12 +++++++++++ makefile | 2 +- telecom.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 telecom.c diff --git a/bmc.h b/bmc.h index 30fd443..3f4b5fa 100644 --- a/bmc.h +++ b/bmc.h @@ -55,4 +55,16 @@ int dscmp(struct dataset *a, struct dataset *b); */ int dscmp2(struct dataset *a, struct dataset *b); +/** + * Compare two data sets using the algorithm defined in the Telecom + * Profiles according to ITU-T G.8275.1 and G.8275.2. + * + * @param a A dataset to compare. + * @param b A dataset to compare. + * @return An integer less than, equal to, or greater than zero + * if the dataset @a a is found, respectively, to be + * less than, to match, or be greater than @a b. + */ +int telecom_dscmp(struct dataset *a, struct dataset *b); + #endif diff --git a/makefile b/makefile index 17189e6..d34eb6b 100644 --- a/makefile +++ b/makefile @@ -25,7 +25,7 @@ LDLIBS = -lm -lrt $(EXTRA_LDFLAGS) PRG = ptp4l hwstamp_ctl nsm phc2sys phc_ctl pmc timemaster OBJ = bmc.o clock.o clockadj.o clockcheck.o config.o fault.o \ filter.o fsm.o hash.o linreg.o mave.o mmedian.o msg.o ntpshm.o nullf.o phc.o \ - pi.o port.o print.o ptp4l.o raw.o rtnl.o servo.o sk.o stats.o tlv.o \ + pi.o port.o print.o ptp4l.o raw.o rtnl.o servo.o sk.o stats.o telecom.o tlv.o \ transport.o tsproc.o udp.o udp6.o uds.o util.o version.o OBJECTS = $(OBJ) hwstamp_ctl.o nsm.o phc2sys.o phc_ctl.o pmc.o pmc_common.o \ diff --git a/telecom.c b/telecom.c new file mode 100644 index 0000000..6119800 --- /dev/null +++ b/telecom.c @@ -0,0 +1,73 @@ +/** + * @file telecom.c + * @note Copyright (C) 2017 Richard Cochran <ric...@gm...> + * + * Derived from code in bmc.c. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. + */ +#include <string.h> + +#include "bmc.h" +#include "ds.h" + +int telecom_dscmp(struct dataset *a, struct dataset *b) +{ + int diff; + + if (a == b) + return 0; + if (a && !b) + return A_BETTER; + if (b && !a) + return B_BETTER; + + if (a->quality.clockClass < b->quality.clockClass) + return A_BETTER; + if (a->quality.clockClass > b->quality.clockClass) + return B_BETTER; + + if (a->quality.clockAccuracy < b->quality.clockAccuracy) + return A_BETTER; + if (a->quality.clockAccuracy > b->quality.clockAccuracy) + return B_BETTER; + + if (a->quality.offsetScaledLogVariance < + b->quality.offsetScaledLogVariance) + return A_BETTER; + if (a->quality.offsetScaledLogVariance > + b->quality.offsetScaledLogVariance) + return B_BETTER; + + if (a->priority2 < b->priority2) + return A_BETTER; + if (a->priority2 > b->priority2) + return B_BETTER; + + if (a->localPriority < b->localPriority) + return A_BETTER; + if (a->localPriority > b->localPriority) + return B_BETTER; + + if (a->quality.clockClass <= 127) + return dscmp2(a, b); + + diff = memcmp(&a->identity, &b->identity, sizeof(a->identity)); + + if (!diff) + return dscmp2(a, b); + + return diff < 0 ? A_BETTER : B_BETTER; +} -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-25 05:03:28
|
When masterOnly is true, the port always returns NULL when computing its best foreign master. As a result, the port will never enter the SLAVE state, and the clock will ignore Announce messages received on that port. This attribute is specifically called out in G.8275.1 and G.8275.2, and it is implied by the "master only" mode G.8265.1. In addition, this option will probably appear in the next revision of IEEE 1588. Signed-off-by: Richard Cochran <ric...@gm...> --- config.c | 1 + default.cfg | 1 + gPTP.cfg | 1 + port.c | 4 ++++ port_private.h | 1 + ptp4l.8 | 7 +++++++ 6 files changed, 15 insertions(+) diff --git a/config.c b/config.c index 0b656b7..acd5f45 100644 --- a/config.c +++ b/config.c @@ -214,6 +214,7 @@ struct config_item config_tab[] = { PORT_ITEM_INT("logMinPdelayReqInterval", 0, INT8_MIN, INT8_MAX), PORT_ITEM_INT("logSyncInterval", 0, INT8_MIN, INT8_MAX), GLOB_ITEM_INT("logging_level", LOG_INFO, PRINT_LEVEL_MIN, PRINT_LEVEL_MAX), + PORT_ITEM_INT("masterOnly", 0, 0, 1), GLOB_ITEM_STR("message_tag", NULL), GLOB_ITEM_STR("manufacturerIdentity", "00:00:00"), GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX), diff --git a/default.cfg b/default.cfg index d7b78f2..408022d 100644 --- a/default.cfg +++ b/default.cfg @@ -29,6 +29,7 @@ syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 +masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options diff --git a/gPTP.cfg b/gPTP.cfg index 14859e1..ed087fa 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -27,6 +27,7 @@ delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 800 min_neighbor_prop_delay -20000000 +masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options diff --git a/port.c b/port.c index 3279417..bc630b5 100644 --- a/port.c +++ b/port.c @@ -1568,6 +1568,7 @@ int port_initialize(struct port *p) p->transportSpecific = config_get_int(cfg, p->name, "transportSpecific"); p->transportSpecific <<= 4; p->match_transport_specific = !config_get_int(cfg, p->name, "ignore_transport_specific"); + p->master_only = config_get_int(cfg, p->name, "masterOnly"); p->localPriority = config_get_int(cfg, p->name, "G.8275.portDS.localPriority"); p->logSyncInterval = config_get_int(cfg, p->name, "logSyncInterval"); p->logMinPdelayReqInterval = config_get_int(cfg, p->name, "logMinPdelayReqInterval"); @@ -2200,6 +2201,9 @@ struct foreign_clock *port_compute_best(struct port *p) dscmp = clock_dscmp(p->clock); p->best = NULL; + if (p->master_only) + return p->best; + LIST_FOREACH(fc, &p->foreign_masters, list) { tmp = TAILQ_FIRST(&fc->messages); if (!tmp) diff --git a/port_private.h b/port_private.h index 436e7b7..806329d 100644 --- a/port_private.h +++ b/port_private.h @@ -108,6 +108,7 @@ struct port { int follow_up_info; int freq_est_interval; int hybrid_e2e; + int master_only; int match_transport_specific; int min_neighbor_prop_delay; int net_sync_monitor; diff --git a/ptp4l.8 b/ptp4l.8 index 011bd02..2aee03e 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -245,6 +245,13 @@ The default is UDPv4. Upper limit for peer delay in nanoseconds. If the estimated peer delay is greater than this value the port is marked as not 802.1AS capable. .TP +.B masterOnly +Setting this option to one (1) prevents the port from entering the +SLAVE state. In addition, the local clock will ignore Announce +messages received on this port. This option's intended use is to +support the Telecom Profiles according to ITU-T G.8265.1, G.8275.1, +and G.8275.2. The default value is zero or false. +.TP .B G.8275.portDS.localPriority The Telecom Profiles (ITU-T G.8275.1 and G.8275.2) specify an alternate Best Master Clock Algorithm (BMCA) with a unique data set -- 2.11.0 |
[Linuxptp-devel] [PATCH v3 5/7] telecom: Add a configuration option
for G.8275.portDS.localPriority.
From: Richard C. <ric...@gm...> - 2018-04-25 05:03:26
|
Signed-off-by: Richard Cochran <ric...@gm...> --- config.c | 1 + default.cfg | 1 + gPTP.cfg | 1 + port.c | 3 ++- port_private.h | 1 + ptp4l.8 | 15 +++++++++++++++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 9c26ccd..f75092e 100644 --- a/config.c +++ b/config.c @@ -193,6 +193,7 @@ struct config_item config_tab[] = { GLOB_ITEM_INT("free_running", 0, 0, 1), PORT_ITEM_INT("freq_est_interval", 1, 0, INT_MAX), GLOB_ITEM_INT("G.8275.defaultDS.localPriority", 128, 1, UINT8_MAX), + PORT_ITEM_INT("G.8275.portDS.localPriority", 128, 1, UINT8_MAX), GLOB_ITEM_INT("gmCapable", 1, 0, 1), PORT_ITEM_INT("hybrid_e2e", 0, 0, 1), PORT_ITEM_INT("ignore_transport_specific", 0, 0, 1), diff --git a/default.cfg b/default.cfg index 9736568..24836dd 100644 --- a/default.cfg +++ b/default.cfg @@ -28,6 +28,7 @@ syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 +G.8275.portDS.localPriority 128 # # Run time options # diff --git a/gPTP.cfg b/gPTP.cfg index 02fd395..095a444 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -26,6 +26,7 @@ delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 800 min_neighbor_prop_delay -20000000 +G.8275.portDS.localPriority 128 # # Run time options # diff --git a/port.c b/port.c index fc65153..3279417 100644 --- a/port.c +++ b/port.c @@ -77,7 +77,7 @@ static void announce_to_dataset(struct ptp_message *m, struct port *p, out->identity = a->grandmasterIdentity; out->quality = a->grandmasterClockQuality; out->priority2 = a->grandmasterPriority2; - out->localPriority = 128; + out->localPriority = p->localPriority; out->stepsRemoved = a->stepsRemoved; out->sender = m->header.sourcePortIdentity; out->receiver = p->portIdentity; @@ -1568,6 +1568,7 @@ int port_initialize(struct port *p) p->transportSpecific = config_get_int(cfg, p->name, "transportSpecific"); p->transportSpecific <<= 4; p->match_transport_specific = !config_get_int(cfg, p->name, "ignore_transport_specific"); + p->localPriority = config_get_int(cfg, p->name, "G.8275.portDS.localPriority"); p->logSyncInterval = config_get_int(cfg, p->name, "logSyncInterval"); p->logMinPdelayReqInterval = config_get_int(cfg, p->name, "logMinPdelayReqInterval"); p->neighborPropDelayThresh = config_get_int(cfg, p->name, "neighborPropDelayThresh"); diff --git a/port_private.h b/port_private.h index f8771c7..436e7b7 100644 --- a/port_private.h +++ b/port_private.h @@ -100,6 +100,7 @@ struct port { int announce_span; UInteger8 syncReceiptTimeout; UInteger8 transportSpecific; + UInteger8 localPriority; Integer8 logSyncInterval; Enumeration8 delayMechanism; Integer8 logMinPdelayReqInterval; diff --git a/ptp4l.8 b/ptp4l.8 index 10f55f2..11e3cc0 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -245,6 +245,21 @@ The default is UDPv4. Upper limit for peer delay in nanoseconds. If the estimated peer delay is greater than this value the port is marked as not 802.1AS capable. .TP +.B G.8275.portDS.localPriority +The Telecom Profiles (ITU-T G.8275.1 and G.8275.2) specify an +alternate Best Master Clock Algorithm (BMCA) with a unique data set +comparison algorithm. The value of this option is associated with +Announce messages arriving on a particular port and is used as a tie +breaker whenever clockClass, clockAccuracy, offsetScaledLogVariance, +and priority2 are equal. This option is only used when +"dataset_comparison" is set to "telecom". +The default value is 128. + +Warning: the BMCA is guaranteed to produce a spanning tree (that is, a +timing network without loops) only when using the default values of +G.8275.defaultDS.localPriority and G.8275.portDS.localPriority. +Careful network engineering is needed when using non-default values. +.TP .B min_neighbor_prop_delay Lower limit for peer delay in nanoseconds. If the estimated peer delay is smaller than this value the port is marked as not 802.1AS capable. -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-20 16:09:07
|
The Telecom Profiles G.8275.1 and G.8275.2 have invented a new per-port and per-clock attribute, not in 1588, called "localPriority". The use of this attribute is a distinguishing feature of the telecom data set comparison algorithm. This patch adds the attribute, hard coded to its default value. Signed-off-by: Richard Cochran <ric...@gm...> --- clock.c | 1 + ds.h | 1 + port.c | 1 + 3 files changed, 3 insertions(+) diff --git a/clock.c b/clock.c index afee960..cd7f850 100644 --- a/clock.c +++ b/clock.c @@ -926,6 +926,7 @@ struct clock *clock_create(enum clock_type type, struct config *config, c->dds.flags & DDS_SLAVE_ONLY) { c->dds.clockQuality.clockClass = 255; } + c->default_dataset.localPriority = 128; /* Harmonize the twoStepFlag with the time_stamping option. */ if (config_harmonize_onestep(config)) { diff --git a/ds.h b/ds.h index 0e48d05..9d9c417 100644 --- a/ds.h +++ b/ds.h @@ -55,6 +55,7 @@ struct dataset { struct ClockIdentity identity; struct ClockQuality quality; UInteger8 priority2; + UInteger8 localPriority; /* Telecom Profile only */ UInteger16 stepsRemoved; struct PortIdentity sender; struct PortIdentity receiver; diff --git a/port.c b/port.c index 1757dfe..d858027 100644 --- a/port.c +++ b/port.c @@ -77,6 +77,7 @@ static void announce_to_dataset(struct ptp_message *m, struct port *p, out->identity = a->grandmasterIdentity; out->quality = a->grandmasterClockQuality; out->priority2 = a->grandmasterPriority2; + out->localPriority = 128; out->stepsRemoved = a->stepsRemoved; out->sender = m->header.sourcePortIdentity; out->receiver = p->portIdentity; -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-20 16:09:08
|
The first half of the telecom algorithm from G.8275.1 and G.8275.2 differs from the one in 1588, making use of profile specific "localPriority" attributes. Signed-off-by: Richard Cochran <ric...@gm...> --- bmc.h | 12 +++++++++++ makefile | 2 +- telecom.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 telecom.c diff --git a/bmc.h b/bmc.h index 30fd443..3f4b5fa 100644 --- a/bmc.h +++ b/bmc.h @@ -55,4 +55,16 @@ int dscmp(struct dataset *a, struct dataset *b); */ int dscmp2(struct dataset *a, struct dataset *b); +/** + * Compare two data sets using the algorithm defined in the Telecom + * Profiles according to ITU-T G.8275.1 and G.8275.2. + * + * @param a A dataset to compare. + * @param b A dataset to compare. + * @return An integer less than, equal to, or greater than zero + * if the dataset @a a is found, respectively, to be + * less than, to match, or be greater than @a b. + */ +int telecom_dscmp(struct dataset *a, struct dataset *b); + #endif diff --git a/makefile b/makefile index 17189e6..d34eb6b 100644 --- a/makefile +++ b/makefile @@ -25,7 +25,7 @@ LDLIBS = -lm -lrt $(EXTRA_LDFLAGS) PRG = ptp4l hwstamp_ctl nsm phc2sys phc_ctl pmc timemaster OBJ = bmc.o clock.o clockadj.o clockcheck.o config.o fault.o \ filter.o fsm.o hash.o linreg.o mave.o mmedian.o msg.o ntpshm.o nullf.o phc.o \ - pi.o port.o print.o ptp4l.o raw.o rtnl.o servo.o sk.o stats.o tlv.o \ + pi.o port.o print.o ptp4l.o raw.o rtnl.o servo.o sk.o stats.o telecom.o tlv.o \ transport.o tsproc.o udp.o udp6.o uds.o util.o version.o OBJECTS = $(OBJ) hwstamp_ctl.o nsm.o phc2sys.o phc_ctl.o pmc.o pmc_common.o \ diff --git a/telecom.c b/telecom.c new file mode 100644 index 0000000..6119800 --- /dev/null +++ b/telecom.c @@ -0,0 +1,73 @@ +/** + * @file telecom.c + * @note Copyright (C) 2017 Richard Cochran <ric...@gm...> + * + * Derived from code in bmc.c. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. + */ +#include <string.h> + +#include "bmc.h" +#include "ds.h" + +int telecom_dscmp(struct dataset *a, struct dataset *b) +{ + int diff; + + if (a == b) + return 0; + if (a && !b) + return A_BETTER; + if (b && !a) + return B_BETTER; + + if (a->quality.clockClass < b->quality.clockClass) + return A_BETTER; + if (a->quality.clockClass > b->quality.clockClass) + return B_BETTER; + + if (a->quality.clockAccuracy < b->quality.clockAccuracy) + return A_BETTER; + if (a->quality.clockAccuracy > b->quality.clockAccuracy) + return B_BETTER; + + if (a->quality.offsetScaledLogVariance < + b->quality.offsetScaledLogVariance) + return A_BETTER; + if (a->quality.offsetScaledLogVariance > + b->quality.offsetScaledLogVariance) + return B_BETTER; + + if (a->priority2 < b->priority2) + return A_BETTER; + if (a->priority2 > b->priority2) + return B_BETTER; + + if (a->localPriority < b->localPriority) + return A_BETTER; + if (a->localPriority > b->localPriority) + return B_BETTER; + + if (a->quality.clockClass <= 127) + return dscmp2(a, b); + + diff = memcmp(&a->identity, &b->identity, sizeof(a->identity)); + + if (!diff) + return dscmp2(a, b); + + return diff < 0 ? A_BETTER : B_BETTER; +} -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-20 16:09:11
|
Signed-off-by: Richard Cochran <ric...@gm...> --- bmc.h | 5 +++++ clock.c | 6 +++++- config.c | 9 +++++++++ default.cfg | 1 + gPTP.cfg | 1 + port.c | 6 +++++- 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/bmc.h b/bmc.h index 3f4b5fa..2901cda 100644 --- a/bmc.h +++ b/bmc.h @@ -29,6 +29,11 @@ #define B_BETTER -1 #define B_BETTER_TOPO -2 +enum { + DS_CMP_IEEE1588, + DS_CMP_G8275, +}; + /** * BMC state decision algorithm. * @param c The local clock. diff --git a/clock.c b/clock.c index 1886c26..9339b1a 100644 --- a/clock.c +++ b/clock.c @@ -1059,7 +1059,11 @@ struct clock *clock_create(enum clock_type type, struct config *config, } c->servo_state = SERVO_UNLOCKED; c->servo_type = servo; - c->dscmp = dscmp; + if (config_get_int(config, NULL, "dataset_comparison") == DS_CMP_G8275) { + c->dscmp = telecom_dscmp; + } else { + c->dscmp = dscmp; + } c->tsproc = tsproc_create(config_get_int(config, NULL, "tsproc_mode"), config_get_int(config, NULL, "delay_filter"), config_get_int(config, NULL, "delay_filter_length")); diff --git a/config.c b/config.c index f75092e..0b656b7 100644 --- a/config.c +++ b/config.c @@ -22,6 +22,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> + +#include "bmc.h" #include "config.h" #include "ether.h" #include "hash.h" @@ -133,6 +135,12 @@ static struct config_enum clock_servo_enu[] = { { NULL, 0 }, }; +static struct config_enum dataset_comp_enu[] = { + { "ieee1588", DS_CMP_IEEE1588 }, + { "G.8275.x", DS_CMP_G8275 }, + { NULL, 0 }, +}; + static struct config_enum delay_filter_enu[] = { { "moving_average", FILTER_MOVING_AVERAGE }, { "moving_median", FILTER_MOVING_MEDIAN }, @@ -178,6 +186,7 @@ struct config_item config_tab[] = { GLOB_ITEM_INT("clockAccuracy", 0xfe, 0, UINT8_MAX), GLOB_ITEM_INT("clockClass", 248, 0, UINT8_MAX), GLOB_ITEM_ENU("clock_servo", CLOCK_SERVO_PI, clock_servo_enu), + GLOB_ITEM_ENU("dataset_comparison", DS_CMP_IEEE1588, dataset_comp_enu), 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), diff --git a/default.cfg b/default.cfg index 24836dd..d7b78f2 100644 --- a/default.cfg +++ b/default.cfg @@ -15,6 +15,7 @@ free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 +dataset_comparison ieee1588 G.8275.defaultDS.localPriority 128 # # Port Data Set diff --git a/gPTP.cfg b/gPTP.cfg index 095a444..14859e1 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -13,6 +13,7 @@ clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 +dataset_comparison ieee1588 G.8275.defaultDS.localPriority 128 # # Port Data Set diff --git a/port.c b/port.c index 8c52ade..0cee2fe 100644 --- a/port.c +++ b/port.c @@ -2786,7 +2786,11 @@ struct port *port_open(int phc_index, } p->state_machine = clock_slave_only(clock) ? ptp_slave_fsm : ptp_fsm; - p->dscmp = dscmp; + if (config_get_int(cfg, NULL, "dataset_comparison") == DS_CMP_G8275) { + p->dscmp = telecom_dscmp; + } else { + p->dscmp = dscmp; + } p->phc_index = phc_index; p->jbod = config_get_int(cfg, interface->name, "boundary_clock_jbod"); transport = config_get_int(cfg, interface->name, "network_transport"); -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-20 16:09:11
|
Signed-off-by: Richard Cochran <ric...@gm...> --- clock.c | 3 ++- config.c | 1 + default.cfg | 1 + gPTP.cfg | 1 + ptp4l.8 | 14 ++++++++++++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clock.c b/clock.c index cd7f850..1886c26 100644 --- a/clock.c +++ b/clock.c @@ -926,7 +926,8 @@ struct clock *clock_create(enum clock_type type, struct config *config, c->dds.flags & DDS_SLAVE_ONLY) { c->dds.clockQuality.clockClass = 255; } - c->default_dataset.localPriority = 128; + c->default_dataset.localPriority = + config_get_int(config, NULL, "G.8275.defaultDS.localPriority"); /* Harmonize the twoStepFlag with the time_stamping option. */ if (config_harmonize_onestep(config)) { diff --git a/config.c b/config.c index 320cc1b..9c26ccd 100644 --- a/config.c +++ b/config.c @@ -192,6 +192,7 @@ struct config_item config_tab[] = { PORT_ITEM_INT("follow_up_info", 0, 0, 1), GLOB_ITEM_INT("free_running", 0, 0, 1), PORT_ITEM_INT("freq_est_interval", 1, 0, INT_MAX), + GLOB_ITEM_INT("G.8275.defaultDS.localPriority", 128, 1, UINT8_MAX), GLOB_ITEM_INT("gmCapable", 1, 0, 1), PORT_ITEM_INT("hybrid_e2e", 0, 0, 1), PORT_ITEM_INT("ignore_transport_specific", 0, 0, 1), diff --git a/default.cfg b/default.cfg index e76aeae..9736568 100644 --- a/default.cfg +++ b/default.cfg @@ -15,6 +15,7 @@ free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 +G.8275.defaultDS.localPriority 128 # # Port Data Set # diff --git a/gPTP.cfg b/gPTP.cfg index 1e7a33e..02fd395 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -13,6 +13,7 @@ clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 +G.8275.defaultDS.localPriority 128 # # Port Data Set # diff --git a/ptp4l.8 b/ptp4l.8 index 950e07c..10f55f2 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -341,6 +341,20 @@ The offsetScaledLogVariance attribute of the local clock. It characterizes the stability of the clock. The default is 0xFFFF. .TP +.B G.8275.defaultDS.localPriority +The Telecom Profiles (ITU-T G.8275.1 and G.8275.2) specify an +alternate Best Master Clock Algorithm (BMCA) with a unique data set +comparison algorithm. The value of this option is associated with the +local clock and is used as a tie breaker whenever clockClass, +clockAccuracy, offsetScaledLogVariance, and priority2 are equal. This +option is only used when "dataset_comparison" is set to "telecom". +The default value is 128. + +Warning: the BMCA is guaranteed to produce a spanning tree (that is, a +timing network without loops) only when using the default values of +G.8275.defaultDS.localPriority and G.8275.portDS.localPriority. +Careful network engineering is needed when using non-default values. +.TP .B domainNumber The domain attribute of the local clock. The default is 0. -- 2.11.0 |
[Linuxptp-devel] [PATCH V2 4/6] telecom: Add a configuration option
for G.8275.portDS.localPriority.
From: Richard C. <ric...@gm...> - 2018-04-20 16:09:11
|
Signed-off-by: Richard Cochran <ric...@gm...> --- config.c | 1 + default.cfg | 1 + gPTP.cfg | 1 + port.c | 3 ++- port_private.h | 1 + ptp4l.8 | 15 +++++++++++++++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 9c26ccd..f75092e 100644 --- a/config.c +++ b/config.c @@ -193,6 +193,7 @@ struct config_item config_tab[] = { GLOB_ITEM_INT("free_running", 0, 0, 1), PORT_ITEM_INT("freq_est_interval", 1, 0, INT_MAX), GLOB_ITEM_INT("G.8275.defaultDS.localPriority", 128, 1, UINT8_MAX), + PORT_ITEM_INT("G.8275.portDS.localPriority", 128, 1, UINT8_MAX), GLOB_ITEM_INT("gmCapable", 1, 0, 1), PORT_ITEM_INT("hybrid_e2e", 0, 0, 1), PORT_ITEM_INT("ignore_transport_specific", 0, 0, 1), diff --git a/default.cfg b/default.cfg index 9736568..24836dd 100644 --- a/default.cfg +++ b/default.cfg @@ -28,6 +28,7 @@ syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 +G.8275.portDS.localPriority 128 # # Run time options # diff --git a/gPTP.cfg b/gPTP.cfg index 02fd395..095a444 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -26,6 +26,7 @@ delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 800 min_neighbor_prop_delay -20000000 +G.8275.portDS.localPriority 128 # # Run time options # diff --git a/port.c b/port.c index d858027..8c52ade 100644 --- a/port.c +++ b/port.c @@ -77,7 +77,7 @@ static void announce_to_dataset(struct ptp_message *m, struct port *p, out->identity = a->grandmasterIdentity; out->quality = a->grandmasterClockQuality; out->priority2 = a->grandmasterPriority2; - out->localPriority = 128; + out->localPriority = p->localPriority; out->stepsRemoved = a->stepsRemoved; out->sender = m->header.sourcePortIdentity; out->receiver = p->portIdentity; @@ -1568,6 +1568,7 @@ int port_initialize(struct port *p) p->transportSpecific = config_get_int(cfg, p->name, "transportSpecific"); p->transportSpecific <<= 4; p->match_transport_specific = !config_get_int(cfg, p->name, "ignore_transport_specific"); + p->localPriority = config_get_int(cfg, p->name, "G.8275.portDS.localPriority"); p->logSyncInterval = config_get_int(cfg, p->name, "logSyncInterval"); p->logMinPdelayReqInterval = config_get_int(cfg, p->name, "logMinPdelayReqInterval"); p->neighborPropDelayThresh = config_get_int(cfg, p->name, "neighborPropDelayThresh"); diff --git a/port_private.h b/port_private.h index 860a2bb..711dce1 100644 --- a/port_private.h +++ b/port_private.h @@ -101,6 +101,7 @@ struct port { int announce_span; UInteger8 syncReceiptTimeout; UInteger8 transportSpecific; + UInteger8 localPriority; Integer8 logSyncInterval; Enumeration8 delayMechanism; Integer8 logMinPdelayReqInterval; diff --git a/ptp4l.8 b/ptp4l.8 index 10f55f2..11e3cc0 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -245,6 +245,21 @@ The default is UDPv4. Upper limit for peer delay in nanoseconds. If the estimated peer delay is greater than this value the port is marked as not 802.1AS capable. .TP +.B G.8275.portDS.localPriority +The Telecom Profiles (ITU-T G.8275.1 and G.8275.2) specify an +alternate Best Master Clock Algorithm (BMCA) with a unique data set +comparison algorithm. The value of this option is associated with +Announce messages arriving on a particular port and is used as a tie +breaker whenever clockClass, clockAccuracy, offsetScaledLogVariance, +and priority2 are equal. This option is only used when +"dataset_comparison" is set to "telecom". +The default value is 128. + +Warning: the BMCA is guaranteed to produce a spanning tree (that is, a +timing network without loops) only when using the default values of +G.8275.defaultDS.localPriority and G.8275.portDS.localPriority. +Careful network engineering is needed when using non-default values. +.TP .B min_neighbor_prop_delay Lower limit for peer delay in nanoseconds. If the estimated peer delay is smaller than this value the port is marked as not 802.1AS capable. -- 2.11.0 |
From: Richard C. <ric...@gm...> - 2018-04-20 16:09:12
|
When G.8275.masterOnly is true, the port always returns NULL when computing its best foreign master. As a result, the port will never enter the SLAVE state, and the clock will ignore Announce messages received on that port. This attribute is specifically called out in G.8275.1 and G.8275.2, and it is implied by the "master only" mode G.8265.1. Signed-off-by: Richard Cochran <ric...@gm...> --- config.c | 1 + default.cfg | 1 + gPTP.cfg | 1 + port.c | 4 ++++ port_private.h | 1 + ptp4l.8 | 7 +++++++ 6 files changed, 15 insertions(+) diff --git a/config.c b/config.c index 0b656b7..8011e57 100644 --- a/config.c +++ b/config.c @@ -202,6 +202,7 @@ struct config_item config_tab[] = { GLOB_ITEM_INT("free_running", 0, 0, 1), PORT_ITEM_INT("freq_est_interval", 1, 0, INT_MAX), GLOB_ITEM_INT("G.8275.defaultDS.localPriority", 128, 1, UINT8_MAX), + PORT_ITEM_INT("G.8275.masterOnly", 0, 0, 1), PORT_ITEM_INT("G.8275.portDS.localPriority", 128, 1, UINT8_MAX), GLOB_ITEM_INT("gmCapable", 1, 0, 1), PORT_ITEM_INT("hybrid_e2e", 0, 0, 1), diff --git a/default.cfg b/default.cfg index d7b78f2..5773ccb 100644 --- a/default.cfg +++ b/default.cfg @@ -29,6 +29,7 @@ syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 +G.8275.masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options diff --git a/gPTP.cfg b/gPTP.cfg index 14859e1..9bbaddd 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -27,6 +27,7 @@ delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 800 min_neighbor_prop_delay -20000000 +G.8275.masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options diff --git a/port.c b/port.c index 0cee2fe..663f36e 100644 --- a/port.c +++ b/port.c @@ -1568,6 +1568,7 @@ int port_initialize(struct port *p) p->transportSpecific = config_get_int(cfg, p->name, "transportSpecific"); p->transportSpecific <<= 4; p->match_transport_specific = !config_get_int(cfg, p->name, "ignore_transport_specific"); + p->master_only = config_get_int(cfg, p->name, "G.8275.masterOnly"); p->localPriority = config_get_int(cfg, p->name, "G.8275.portDS.localPriority"); p->logSyncInterval = config_get_int(cfg, p->name, "logSyncInterval"); p->logMinPdelayReqInterval = config_get_int(cfg, p->name, "logMinPdelayReqInterval"); @@ -2198,6 +2199,9 @@ struct foreign_clock *port_compute_best(struct port *p) p->best = NULL; + if (p->master_only) + return p->best; + LIST_FOREACH(fc, &p->foreign_masters, list) { tmp = TAILQ_FIRST(&fc->messages); if (!tmp) diff --git a/port_private.h b/port_private.h index 711dce1..391db64 100644 --- a/port_private.h +++ b/port_private.h @@ -109,6 +109,7 @@ struct port { int follow_up_info; int freq_est_interval; int hybrid_e2e; + int master_only; int match_transport_specific; int min_neighbor_prop_delay; int net_sync_monitor; diff --git a/ptp4l.8 b/ptp4l.8 index 11e3cc0..0b17f10 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -245,6 +245,13 @@ The default is UDPv4. Upper limit for peer delay in nanoseconds. If the estimated peer delay is greater than this value the port is marked as not 802.1AS capable. .TP +.B G.8275.masterOnly +Setting this option to one (1) prevents the port from entering the +SLAVE state. In addition, the local clock will ignore Announce +messages received on this port. This option's intended use is to +support the Telecom Profiles according to ITU-T G.8265.1, G.8275.1, +and G.8275.2. The default value is zero or false. +.TP .B G.8275.portDS.localPriority The Telecom Profiles (ITU-T G.8275.1 and G.8275.2) specify an alternate Best Master Clock Algorithm (BMCA) with a unique data set -- 2.11.0 |
From: Anders S. <and...@es...> - 2018-04-23 09:00:59
|
Friday, April 20, 2018 6:09 PM > +int telecom_dscmp(struct dataset *a, struct dataset *b) This function introduces a lot of "if" without braces. /Anders |
From: Richard C. <ric...@gm...> - 2018-04-23 13:55:39
|
On Mon, Apr 23, 2018 at 09:00:46AM +0000, Anders Selhammer wrote: > This function introduces a lot of "if" without braces. Yes, and I explained the reason for it. Thanks, Richard |
From: Anders S. <and...@es...> - 2018-04-23 09:07:00
|
Friday, April 20, 2018 6:09 PM - p->dscmp = dscmp; + if (config_get_int(cfg, NULL, "dataset_comparison") == DS_CMP_G8275) { + p->dscmp = telecom_dscmp; + } else { + p->dscmp = dscmp; + } This should not be needed if port get the comparation function from clock. Added that in my version "v2 2/7] clock: Added getter for dscmp configured for the clock" /Anders |
From: Anders S. <and...@es...> - 2018-04-23 10:29:03
|
Friday, April 20, 2018 6:09 PM > + PORT_ITEM_INT("G.8275.masterOnly", 0, 0, 1), masterOnly will be included in v2.1 so it will not be a profile specific attribute. Should this be changed when updated for v2.1? /Anders |
From: Richard C. <ric...@gm...> - 2018-04-23 14:00:45
|
On Mon, Apr 23, 2018 at 10:28:50AM +0000, Anders Selhammer wrote: > masterOnly will be included in v2.1 so it will not be a profile specific attribute. > Should this be changed when updated for v2.1? Good point. I think it best to simply drop the prefix. Thanks, Richard |
From: Richard C. <ric...@gm...> - 2018-04-23 14:06:44
|
On Mon, Apr 23, 2018 at 09:06:48AM +0000, Anders Selhammer wrote: > Friday, April 20, 2018 6:09 PM > > - p->dscmp = dscmp; > + if (config_get_int(cfg, NULL, "dataset_comparison") == DS_CMP_G8275) { > + p->dscmp = telecom_dscmp; > + } else { > + p->dscmp = dscmp; > + } > > This should not be needed if port get the comparation function from clock. Right, I'll refactor that. > Added that in my version "v2 2/7] clock: Added getter for dscmp configured for the clock" Sorry for not making this clear, but I am going to merge *my* patch series from 2017, once it is ready. You can't expect to simply re-write existing code in a different way and expect that to be merged. You series also lacks proper change log messages. Also, I put a fair amount of testing into my 2017 series, but yours is brand new. Thanks, Richard |
From: Anders S. <and...@es...> - 2018-04-24 07:03:56
|
Monday, April 23, 2018 4:07 PM > Sorry for not making this clear, but I am going to merge *my* patch > series from 2017, once it is ready. You can't expect to simply > re-write existing code in a different way and expect that to be > merged. You series also lacks proper change log messages. Also, I > put a fair amount of testing into my 2017 series, but yours is brand > new. You are pretty clear now Just for the record: I have not taken any existing code from any mail thread. I subscribed to this list in the 28th of February this year, and I have not read through the history. Honestly, I did not know that you were working on the telecom profiles until last Friday. At that time I already made my set of patches for localPriority, masterOnly and some other parts. I´ve implemented this profile earlier some years ago so I did re-write the code, but from my head and the standard, not from anywhere else. Merge your set of patches and I can atleast get in my: clock: Added getter for dscmp configured for the clock" / Anders |