Make use of the configuration file for the port data set.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
1092c4237b
commit
59163df8b1
4
clock.c
4
clock.c
|
@ -156,7 +156,7 @@ UInteger8 clock_class(struct clock *c)
|
|||
}
|
||||
|
||||
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;
|
||||
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++) {
|
||||
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);
|
||||
if (!c->port[i]) {
|
||||
pr_err("failed to open port %s", iface[i].name);
|
||||
|
|
3
clock.h
3
clock.h
|
@ -68,10 +68,11 @@ UInteger8 clock_class(struct clock *c);
|
|||
* @param interface An array of network interfaces.
|
||||
* @param count The number of elements in @a interfaces.
|
||||
* @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.
|
||||
*/
|
||||
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.
|
||||
|
|
17
port.c
17
port.c
|
@ -34,10 +34,6 @@
|
|||
|
||||
#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 */
|
||||
|
||||
struct port {
|
||||
|
@ -57,6 +53,7 @@ struct port {
|
|||
} seqnum;
|
||||
struct tmtab tmtab;
|
||||
/* portDS */
|
||||
struct port_defaults pod;
|
||||
struct PortIdentity portIdentity;
|
||||
enum port_state state; /*portState*/
|
||||
Integer8 logMinDelayReqInterval;
|
||||
|
@ -491,11 +488,11 @@ static int port_initialize(struct port *p)
|
|||
{
|
||||
int fd[N_TIMER_FDS], i;
|
||||
|
||||
p->logMinDelayReqInterval = LOG_MIN_DELAY_REQ_INTERVAL;
|
||||
p->logMinDelayReqInterval = p->pod.logMinDelayReqInterval;
|
||||
p->peerMeanPathDelay = 0;
|
||||
p->logAnnounceInterval = LOG_ANNOUNCE_INTERVAL;
|
||||
p->announceReceiptTimeout = ANNOUNCE_RECEIPT_TIMEOUT;
|
||||
p->logSyncInterval = LOG_SYNC_INTERVAL;
|
||||
p->logAnnounceInterval = p->pod.logAnnounceInterval;
|
||||
p->announceReceiptTimeout = p->pod.announceReceiptTimeout;
|
||||
p->logSyncInterval = p->pod.logSyncInterval;
|
||||
p->logMinPdelayReqInterval = LOG_MIN_PDELAY_REQ_INTERVAL;
|
||||
|
||||
tmtab_init(&p->tmtab, 1 + p->logMinDelayReqInterval);
|
||||
|
@ -937,7 +934,8 @@ enum fsm_event port_event(struct port *p, int fd_index)
|
|||
return event;
|
||||
}
|
||||
|
||||
struct port *port_open(char *name,
|
||||
struct port *port_open(struct port_defaults *pod,
|
||||
char *name,
|
||||
enum transport_type transport,
|
||||
enum timestamp_type timestamping,
|
||||
int number,
|
||||
|
@ -950,6 +948,7 @@ struct port *port_open(char *name,
|
|||
|
||||
memset(p, 0, sizeof(*p));
|
||||
|
||||
p->pod = *pod;
|
||||
p->name = name;
|
||||
p->clock = clock;
|
||||
p->transport = transport_find(transport);
|
||||
|
|
4
port.h
4
port.h
|
@ -84,6 +84,7 @@ enum fsm_event port_event(struct port *port, int fd_index);
|
|||
|
||||
/**
|
||||
* 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 transport The network transport type 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.
|
||||
* @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 timestamp_type timestamping,
|
||||
int number,
|
||||
|
|
7
ptp4l.c
7
ptp4l.c
|
@ -156,6 +156,11 @@ int main(int argc, char *argv[])
|
|||
ds.clockQuality.offsetScaledLogVariance = 0xffff;
|
||||
ds.priority2 = 128;
|
||||
|
||||
pod.logAnnounceInterval = 1;
|
||||
pod.logSyncInterval = 0;
|
||||
pod.logMinDelayReqInterval = 0;
|
||||
pod.announceReceiptTimeout = 3;
|
||||
|
||||
if (generate_clock_identity(&ds.clockIdentity, iface[0].name)) {
|
||||
fprintf(stderr, "failed to generate a clock identity\n");
|
||||
return -1;
|
||||
|
@ -171,7 +176,7 @@ int main(int argc, char *argv[])
|
|||
ds.clockQuality.clockClass = 255;
|
||||
}
|
||||
|
||||
clock = clock_create(phc, iface, nports, &ds);
|
||||
clock = clock_create(phc, iface, nports, &ds, &pod);
|
||||
if (!clock) {
|
||||
fprintf(stderr, "failed to create a clock\n");
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue