Delio Brignoli
2013-03-13 19:16:59 UTC
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 ++
7 files changed, 21 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..6010404 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_to_nanoseconds(p->peer_delay) > p->neighborPropDelayThresh) {
+ 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,
---
config.c | 5 +++++
default.cfg | 1 +
ds.h | 1 +
gPTP.cfg | 1 +
port.c | 10 +++++++---
ptp4l.8 | 4 ++++
ptp4l.c | 2 ++
7 files changed, 21 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..6010404 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_to_nanoseconds(p->peer_delay) > p->neighborPropDelayThresh) {
+ 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,
--
1.7.0.4
1.7.0.4