Discussion:
[Linuxptp-devel] [PATCH] Implement neighborPropDelayThresh check in port_capable()
Delio Brignoli
2013-03-13 14:21:16 UTC
Permalink
Signed-off-by: Delio Brignoli <***@audioscience.com>
---
config.c | 5 +++++
default.cfg | 1 +
ds.h | 1 +
gPTP.cfg | 1 +
port.c | 10 +++++++---
ptp4l.8 | 4 ++++
ptp4l.c | 2 ++
tmv.h | 9 +++++++++
8 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/config.c b/config.c
index dd96fc1..1e5c7ff 100644
--- a/config.c
+++ b/config.c
@@ -107,6 +107,11 @@ static enum parser_result parse_pod_setting(const char *option,
return BAD_VALUE;
pod->follow_up_info = val ? 1 : 0;

+ } else if (!strcmp(option, "neighborPropDelayThresh")) {
+ if (1 != sscanf(value, "%d", &val))
+ return BAD_VALUE;
+ pod->neighborPropDelayThresh = val;
+
} else if (!strcmp(option, "fault_reset_interval")) {
if (!strcasecmp("ASAP", value)) {
pod->fault_reset_interval = FRI_ASAP;
diff --git a/default.cfg b/default.cfg
index 7b3e2f7..84a009c 100644
--- a/default.cfg
+++ b/default.cfg
@@ -22,6 +22,7 @@ logMinPdelayReqInterval 0
announceReceiptTimeout 3
delayAsymmetry 0
fault_reset_interval 4
+neighborPropDelayThresh 20000000
#
# Run time options
#
diff --git a/ds.h b/ds.h
index 06cb30a..05d49bc 100644
--- a/ds.h
+++ b/ds.h
@@ -125,6 +125,7 @@ struct port_defaults {
int follow_up_info;
int freq_est_interval; /*log seconds*/
int fault_reset_interval; /*log seconds*/
+ UInteger32 neighborPropDelayThresh; /*nanoseconds*/
};

#endif
diff --git a/gPTP.cfg b/gPTP.cfg
index ecd5f71..186a003 100644
--- a/gPTP.cfg
+++ b/gPTP.cfg
@@ -21,6 +21,7 @@ logMinPdelayReqInterval 0
announceReceiptTimeout 3
delayAsymmetry 0
fault_reset_interval 4
+neighborPropDelayThresh 800
#
# Run time options
#
diff --git a/port.c b/port.c
index 1770706..d7a86cc 100644
--- a/port.c
+++ b/port.c
@@ -83,6 +83,7 @@ struct port {
Integer8 logSyncInterval;
Enumeration8 delayMechanism;
Integer8 logMinPdelayReqInterval;
+ UInteger32 neighborPropDelayThresh;
unsigned int versionNumber; /*UInteger4*/
/* foreignMasterDS */
LIST_HEAD(fm, foreign_clock) foreign_masters;
@@ -380,9 +381,11 @@ static int port_capable(struct port *p)
/* Normal 1588 ports are always capable. */
return 1;
}
- /*
- * TODO - Compare p->peer_delay with neighborPropDelayThresh.
- */
+
+ if (tmv_cmp(p->peer_delay, p->neighborPropDelayThresh) > 0) {
+ return 0;
+ }
+
if (p->pdr_missing > ALLOWED_LOST_RESPONSES) {
return 0;
}
@@ -1031,6 +1034,7 @@ static int port_initialize(struct port *p)
p->transportSpecific = p->pod.transportSpecific;
p->logSyncInterval = p->pod.logSyncInterval;
p->logMinPdelayReqInterval = p->pod.logMinPdelayReqInterval;
+ p->neighborPropDelayThresh = p->pod.neighborPropDelayThresh;

tmtab_init(&p->tmtab, 1 + p->logMinDelayReqInterval);

diff --git a/ptp4l.8 b/ptp4l.8
index 3ee222d..be0d3a6 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -195,6 +195,10 @@ The default is E2E.
.B network_transport
Select the network transport. Possible values are UDPv4, UDPv6 and L2.
The default is UDPv4.
+.TP
+.B neighborPropDelayThresh
+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.

.SH PROGRAM AND CLOCK OPTIONS

diff --git a/ptp4l.c b/ptp4l.c
index 32b69d0..05a7521 100644
--- a/ptp4l.c
+++ b/ptp4l.c
@@ -80,6 +80,8 @@ static struct config cfg_settings = {
.follow_up_info = 0,
.freq_est_interval = 1,
.fault_reset_interval = 4,
+ /* Default to very a large neighborPropDelay threshold */
+ .neighborPropDelayThresh = 20000000,
},

.timestamping = TS_HARDWARE,
diff --git a/tmv.h b/tmv.h
index 16a0772..fc72231 100644
--- a/tmv.h
+++ b/tmv.h
@@ -56,6 +56,15 @@ static inline int tmv_eq(tmv_t a, tmv_t b)
return a == b ? 1 : 0;
}

+static inline int tmv_cmp(tmv_t a, tmv_t b)
+{
+ if (a < b)
+ return -1;
+ if (a > b)
+ return 1;
+ return 0;
+}
+
static inline int tmv_is_zero(tmv_t x)
{
return x == ((tmv_t) 0) ? 1 : 0;
--
1.7.0.4
Richard Cochran
2013-03-13 18:49:35 UTC
Permalink
This looks good to me, except for one small detail...
Post by Delio Brignoli
diff --git a/port.c b/port.c
index 1770706..d7a86cc 100644
--- a/port.c
+++ b/port.c
@@ -83,6 +83,7 @@ struct port {
Integer8 logSyncInterval;
Enumeration8 delayMechanism;
Integer8 logMinPdelayReqInterval;
+ UInteger32 neighborPropDelayThresh;
This is an POD type, okay.
Post by Delio Brignoli
unsigned int versionNumber; /*UInteger4*/
/* foreignMasterDS */
LIST_HEAD(fm, foreign_clock) foreign_masters;
@@ -380,9 +381,11 @@ static int port_capable(struct port *p)
/* Normal 1588 ports are always capable. */
return 1;
}
- /*
- * TODO - Compare p->peer_delay with neighborPropDelayThresh.
- */
+
+ if (tmv_cmp(p->peer_delay, p->neighborPropDelayThresh) > 0) {
+ return 0;
+ }
+
But here you treat it like a tmv_t. I think it better to do

if (tmv_to_nanoseconds(p->peer_delay) > p->neighborPropDelayThresh) {
return 0;
}

and then we can drop the new tmv_cmp function.

Thanks,
Richard
Delio Brignoli
2013-03-13 19:14:38 UTC
Permalink
Post by Richard Cochran
This looks good to me, except for one small detail...
[...]
Post by Richard Cochran
But here you treat it like a tmv_t. I think it better to do
if (tmv_to_nanoseconds(p->peer_delay) > p->neighborPropDelayThresh) {
return 0;
}
and then we can drop the new tmv_cmp function.
Good point. I'll post a new version.

Thanks
--
Delio

Loading...