From 0499513f1ec6c828d1bf654f3d3eacf656d5d574 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Mon, 20 Aug 2012 10:56:13 -0700 Subject: [PATCH] ptp4l: remove timestamping as a per-port configuration option The current code for the timestamping mode does not allow interfaces to have separate timestamping modes. This is (probably) due to hardware timestamping mode being required on all ports to work properly. This patch removes the timestamping field in the struct iface, and makes it a clock variable which is really what the mode does anyways. Ports get passed the timestamping mode but no longer appear as though they are separate. Signed-off-by: Jacob Keller --- clock.c | 14 ++++---------- clock.h | 19 ++++++++++--------- ptp4l.c | 7 ++----- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/clock.c b/clock.c index fc44089..af49d7b 100644 --- a/clock.c +++ b/clock.c @@ -210,9 +210,10 @@ UInteger8 clock_class(struct clock *c) } struct clock *clock_create(int phc_index, struct interface *iface, int count, - struct defaultDS *ds, struct port_defaults *pod) + enum timestamp_type timestamping, struct defaultDS *ds, + struct port_defaults *pod) { - int i, max_adj, sw_ts = 0; + int i, max_adj, sw_ts = timestamping == TS_SOFTWARE ? 1 : 0; struct clock *c = &the_clock; char phc[32]; @@ -238,13 +239,6 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, max_adj = 512000; } - for (i = 0; i < count; i++) { - if (iface[i].timestamping == TS_SOFTWARE) { - sw_ts = 1; - break; - } - } - c->servo = servo_create("pi", max_adj, sw_ts); if (!c->servo) { pr_err("Failed to create clock servo"); @@ -274,7 +268,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, for (i = 0; i < count; i++) { c->port[i] = port_open(pod, phc_index, iface[i].name, iface[i].transport, - iface[i].timestamping, 1+i, iface[i].dm, c); + timestamping, 1+i, iface[i].dm, c); if (!c->port[i]) { pr_err("failed to open port %s", iface[i].name); return NULL; diff --git a/clock.h b/clock.h index e48aaeb..ddf5889 100644 --- a/clock.h +++ b/clock.h @@ -35,7 +35,6 @@ struct interface { char *name; enum delay_mechanism dm; enum transport_type transport; - enum timestamp_type timestamping; }; /** Opaque type. */ @@ -68,16 +67,18 @@ UInteger8 clock_class(struct clock *c); * Create a clock instance. There can only be one clock in any system, * so subsequent calls will destroy the previous clock instance. * - * @param phc_index PTP hardware clock device to use. - * Pass -1 to select CLOCK_REALTIME. - * @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. + * @param phc_index PTP hardware clock device to use. + * Pass -1 to select CLOCK_REALTIME. + * @param interface An array of network interfaces. + * @param count The number of elements in @a interfaces. + * @param timestamping The timestamping mode for this 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. */ struct clock *clock_create(int phc_index, struct interface *iface, int count, - struct defaultDS *ds, struct port_defaults *pod); + enum timestamp_type timestamping, struct defaultDS *ds, + struct port_defaults *pod); /** * Obtains a clock's default data set. diff --git a/ptp4l.c b/ptp4l.c index 14d93f2..95400cc 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -73,7 +73,7 @@ static void usage(char *progname) int main(int argc, char *argv[]) { char *config = NULL, *req_phc = NULL, *progname; - int c, i, nports = 0, slaveonly = 0; + int c, nports = 0, slaveonly = 0; struct interface iface[MAX_PORTS]; enum delay_mechanism dm = DM_E2E; enum transport_type transport = TRANS_UDP_IPV4; @@ -159,9 +159,6 @@ int main(int argc, char *argv[]) usage(progname); return -1; } - for (i = 0; i < nports; i++) { - iface[i].timestamping = timestamping; - } /* determine PHC Clock index */ if (timestamping == TS_SOFTWARE || timestamping == TS_LEGACY_HW) { @@ -222,7 +219,7 @@ int main(int argc, char *argv[]) ds.clockQuality.clockClass = 255; } - clock = clock_create(phc_index, iface, nports, &ds, &pod); + clock = clock_create(phc_index, iface, nports, timestamping, &ds, &pod); if (!clock) { fprintf(stderr, "failed to create a clock\n"); return -1;