Make use of the configuration file for the port data set.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2011-12-31 09:38:09 +01:00
parent 1092c4237b
commit 59163df8b1
5 changed files with 21 additions and 14 deletions

View File

@ -156,7 +156,7 @@ UInteger8 clock_class(struct clock *c)
} }
struct clock *clock_create(char *phc, struct interface *iface, int count, struct clock *clock_create(char *phc, struct interface *iface, int count,
struct defaultDS *ds) struct defaultDS *ds, struct port_defaults *pod)
{ {
int i, max_adj, sw_ts = 0; int i, max_adj, sw_ts = 0;
struct clock *c = &the_clock; struct clock *c = &the_clock;
@ -219,7 +219,7 @@ struct clock *clock_create(char *phc, struct interface *iface, int count,
} }
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
c->port[i] = port_open(iface[i].name, iface[i].transport, c->port[i] = port_open(pod, iface[i].name, iface[i].transport,
iface[i].timestamping, 1+i, DM_E2E, c); iface[i].timestamping, 1+i, DM_E2E, c);
if (!c->port[i]) { if (!c->port[i]) {
pr_err("failed to open port %s", iface[i].name); pr_err("failed to open port %s", iface[i].name);

View File

@ -68,10 +68,11 @@ UInteger8 clock_class(struct clock *c);
* @param interface An array of network interfaces. * @param interface An array of network interfaces.
* @param count The number of elements in @a interfaces. * @param count The number of elements in @a interfaces.
* @param ds A pointer to a default data set for the clock. * @param ds A pointer to a default data set for the clock.
* @param pod A pointer to a default port data set for the clock.
* @return A pointer to the single global clock instance. * @return A pointer to the single global clock instance.
*/ */
struct clock *clock_create(char *phc, struct interface *iface, int count, struct clock *clock_create(char *phc, struct interface *iface, int count,
struct defaultDS *ds); struct defaultDS *ds, struct port_defaults *pod);
/** /**
* Obtains a clock's default data set. * Obtains a clock's default data set.

17
port.c
View File

@ -34,10 +34,6 @@
#define PTP_VERSION 2 #define PTP_VERSION 2
#define LOG_MIN_DELAY_REQ_INTERVAL 0 /* allow Delay_Req every 1 sec */
#define LOG_ANNOUNCE_INTERVAL 1 /* every 2 sec */
#define ANNOUNCE_RECEIPT_TIMEOUT 3 /* wait for 3 missing announce */
#define LOG_SYNC_INTERVAL 0 /* every 1 sec */
#define LOG_MIN_PDELAY_REQ_INTERVAL 2 /* allow PDelay_Req every 4 sec */ #define LOG_MIN_PDELAY_REQ_INTERVAL 2 /* allow PDelay_Req every 4 sec */
struct port { struct port {
@ -57,6 +53,7 @@ struct port {
} seqnum; } seqnum;
struct tmtab tmtab; struct tmtab tmtab;
/* portDS */ /* portDS */
struct port_defaults pod;
struct PortIdentity portIdentity; struct PortIdentity portIdentity;
enum port_state state; /*portState*/ enum port_state state; /*portState*/
Integer8 logMinDelayReqInterval; Integer8 logMinDelayReqInterval;
@ -491,11 +488,11 @@ static int port_initialize(struct port *p)
{ {
int fd[N_TIMER_FDS], i; int fd[N_TIMER_FDS], i;
p->logMinDelayReqInterval = LOG_MIN_DELAY_REQ_INTERVAL; p->logMinDelayReqInterval = p->pod.logMinDelayReqInterval;
p->peerMeanPathDelay = 0; p->peerMeanPathDelay = 0;
p->logAnnounceInterval = LOG_ANNOUNCE_INTERVAL; p->logAnnounceInterval = p->pod.logAnnounceInterval;
p->announceReceiptTimeout = ANNOUNCE_RECEIPT_TIMEOUT; p->announceReceiptTimeout = p->pod.announceReceiptTimeout;
p->logSyncInterval = LOG_SYNC_INTERVAL; p->logSyncInterval = p->pod.logSyncInterval;
p->logMinPdelayReqInterval = LOG_MIN_PDELAY_REQ_INTERVAL; p->logMinPdelayReqInterval = LOG_MIN_PDELAY_REQ_INTERVAL;
tmtab_init(&p->tmtab, 1 + p->logMinDelayReqInterval); tmtab_init(&p->tmtab, 1 + p->logMinDelayReqInterval);
@ -937,7 +934,8 @@ enum fsm_event port_event(struct port *p, int fd_index)
return event; return event;
} }
struct port *port_open(char *name, struct port *port_open(struct port_defaults *pod,
char *name,
enum transport_type transport, enum transport_type transport,
enum timestamp_type timestamping, enum timestamp_type timestamping,
int number, int number,
@ -950,6 +948,7 @@ struct port *port_open(char *name,
memset(p, 0, sizeof(*p)); memset(p, 0, sizeof(*p));
p->pod = *pod;
p->name = name; p->name = name;
p->clock = clock; p->clock = clock;
p->transport = transport_find(transport); p->transport = transport_find(transport);

4
port.h
View File

@ -84,6 +84,7 @@ enum fsm_event port_event(struct port *port, int fd_index);
/** /**
* Open a network port. * Open a network port.
* @param pod A pointer to a default port data set for this port.
* @param name The name of the network interface. * @param name The name of the network interface.
* @param transport The network transport type to use on this port. * @param transport The network transport type to use on this port.
* @param timestamping The flavor of time stamping to use on this port. * @param timestamping The flavor of time stamping to use on this port.
@ -92,7 +93,8 @@ enum fsm_event port_event(struct port *port, int fd_index);
* @param clock A pointer to the system PTP clock. * @param clock A pointer to the system PTP clock.
* @return A pointer to an open port on success, or NULL otherwise. * @return A pointer to an open port on success, or NULL otherwise.
*/ */
struct port *port_open(char *name, struct port *port_open(struct port_defaults *pod,
char *name,
enum transport_type transport, enum transport_type transport,
enum timestamp_type timestamping, enum timestamp_type timestamping,
int number, int number,

View File

@ -156,6 +156,11 @@ int main(int argc, char *argv[])
ds.clockQuality.offsetScaledLogVariance = 0xffff; ds.clockQuality.offsetScaledLogVariance = 0xffff;
ds.priority2 = 128; ds.priority2 = 128;
pod.logAnnounceInterval = 1;
pod.logSyncInterval = 0;
pod.logMinDelayReqInterval = 0;
pod.announceReceiptTimeout = 3;
if (generate_clock_identity(&ds.clockIdentity, iface[0].name)) { if (generate_clock_identity(&ds.clockIdentity, iface[0].name)) {
fprintf(stderr, "failed to generate a clock identity\n"); fprintf(stderr, "failed to generate a clock identity\n");
return -1; return -1;
@ -171,7 +176,7 @@ int main(int argc, char *argv[])
ds.clockQuality.clockClass = 255; ds.clockQuality.clockClass = 255;
} }
clock = clock_create(phc, iface, nports, &ds); clock = clock_create(phc, iface, nports, &ds, &pod);
if (!clock) { if (!clock) {
fprintf(stderr, "failed to create a clock\n"); fprintf(stderr, "failed to create a clock\n");
return -1; return -1;