config: port: convert 'delayAsymmetry' to the new scheme.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-15 10:46:05 +02:00
parent 4c9c447429
commit 95a629624f
3 changed files with 9 additions and 12 deletions

View File

@ -93,6 +93,7 @@ struct config_item {
struct config_item config_tab[] = {
GLOB_ITEM_INT("assume_two_step", 0, 0, 1),
GLOB_ITEM_INT("check_fup_sync", 0, 0, 1),
PORT_ITEM_INT("delayAsymmetry", 0, INT_MIN, INT_MAX),
GLOB_ITEM_DBL("first_step_threshold", 0.00002, 0.0, DBL_MAX),
GLOB_ITEM_INT("logging_level", LOG_INFO, PRINT_LEVEL_MIN, PRINT_LEVEL_MAX),
GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX),
@ -262,13 +263,7 @@ static enum parser_result parse_pod_setting(const char *option,
enum parser_result r;
if (!strcmp(option, "delayAsymmetry")) {
r = get_ranged_int(value, &val, INT_MIN, INT_MAX);
if (r != PARSED_OK)
return r;
pod->asymmetry = (Integer64) val << 16;
} else if (!strcmp(option, "logAnnounceInterval")) {
if (!strcmp(option, "logAnnounceInterval")) {
r = get_ranged_int(value, &val, INT8_MIN, INT8_MAX);
if (r != PARSED_OK)
return r;

1
ds.h
View File

@ -125,7 +125,6 @@ struct portDS {
#define FRI_ASAP (-128)
struct port_defaults {
Integer64 asymmetry;
Integer8 logAnnounceInterval;
Integer8 logSyncInterval;
Integer8 logMinDelayReqInterval;

11
port.c
View File

@ -97,6 +97,7 @@ struct port {
struct port_defaults pod;
struct PortIdentity portIdentity;
enum port_state state; /*portState*/
Integer64 asymmetry;
int asCapable;
Integer8 logMinDelayReqInterval;
TimeInterval peerMeanPathDelay;
@ -1148,7 +1149,7 @@ static int port_pdelay_request(struct port *p)
msg->header.ver = PTP_VERSION;
msg->header.messageLength = sizeof(struct pdelay_req_msg);
msg->header.domainNumber = clock_domain_number(p->clock);
msg->header.correction = -p->pod.asymmetry;
msg->header.correction = -p->asymmetry;
msg->header.sourcePortIdentity = p->portIdentity;
msg->header.sequenceId = p->seqnum.delayreq++;
msg->header.control = CTL_OTHER;
@ -1205,7 +1206,7 @@ static int port_delay_request(struct port *p)
msg->header.ver = PTP_VERSION;
msg->header.messageLength = sizeof(struct delay_req_msg);
msg->header.domainNumber = clock_domain_number(p->clock);
msg->header.correction = -p->pod.asymmetry;
msg->header.correction = -p->asymmetry;
msg->header.sourcePortIdentity = p->portIdentity;
msg->header.sequenceId = p->seqnum.delayreq++;
msg->header.control = CTL_DELAY_REQ;
@ -1817,7 +1818,7 @@ static void port_peer_delay(struct port *p)
t1 = timespec_to_tmv(req->hwts.ts);
t4 = timespec_to_tmv(rsp->hwts.ts);
c1 = correction_to_tmv(rsp->header.correction + p->pod.asymmetry);
c1 = correction_to_tmv(rsp->header.correction + p->asymmetry);
/* Process one-step response immediately. */
if (one_step(rsp)) {
@ -1953,7 +1954,7 @@ static void process_sync(struct port *p, struct ptp_message *m)
clock_sync_interval(p->clock, p->log_sync_interval);
}
m->header.correction += p->pod.asymmetry;
m->header.correction += p->asymmetry;
if (one_step(m)) {
port_synchronize(p, m->hwts.ts, m->ts.pdu,
@ -2524,6 +2525,8 @@ struct port *port_open(int phc_index,
p->pod = interface->pod;
p->name = interface->name;
p->asymmetry = config_get_int(cfg, p->name, "delayAsymmetry");
p->asymmetry <<= 16;
p->clock = clock;
p->trp = transport_create(cfg, interface->transport);
if (!p->trp)