summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-daemons
diff options
context:
space:
mode:
authorleimaohui <leimaohui@cn.fujitsu.com>2015-08-19 10:45:02 +0800
committerJoe MacDonald <joe_macdonald@mentor.com>2015-09-11 10:51:03 -0400
commit743814403be40336d554aa686e5fb260487a8bf1 (patch)
tree4d845b6a77ed51a40aaf77a40f5ab321345030af /meta-networking/recipes-daemons
parent7e1de2f5c36b84d09afc3f38d76857c336b17a3c (diff)
downloadmeta-openembedded-743814403be40336d554aa686e5fb260487a8bf1.tar.gz
ptpd: 2.3.1-rc2->2.3.1
Delete ptpd-add-dpaa-etsec-support.patch.The reason is the following: - The ptpd-add-dpaa-etsec-support.patch does not suitable for new version. - The upstream didn't accept this patch. Signed-off-by: Lei Maohui <leimaohui@cn.fujitsu.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
Diffstat (limited to 'meta-networking/recipes-daemons')
-rw-r--r--meta-networking/recipes-daemons/ptpd/ptpd/ptpd-add-dpaa-etsec-support.patch621
-rw-r--r--meta-networking/recipes-daemons/ptpd/ptpd_2.3.1.bb (renamed from meta-networking/recipes-daemons/ptpd/ptpd_2.3.1-rc2.bb)7
2 files changed, 3 insertions, 625 deletions
diff --git a/meta-networking/recipes-daemons/ptpd/ptpd/ptpd-add-dpaa-etsec-support.patch b/meta-networking/recipes-daemons/ptpd/ptpd/ptpd-add-dpaa-etsec-support.patch
deleted file mode 100644
index abb393310..000000000
--- a/meta-networking/recipes-daemons/ptpd/ptpd/ptpd-add-dpaa-etsec-support.patch
+++ /dev/null
@@ -1,621 +0,0 @@
1Add FSL QorIQ DPAA and eTSEC support
2
3This patch is for Freescale QorIQ DPAA and eTSEC which support 1588 hardware
4assist module, and mainly uses SO_TIMESTAMPING API for HW timestamp and PHC
5API.
6
7Signed-off-by: Lu Yangbo <yangbo.lu@freescale.com>
8Upstream-Status: Submitted [http://sourceforge.net/p/ptpd/patches/56/]
9
10diff --git a/src/bmc.c b/src/bmc.c
11index f4c74bd..925daba 100644
12--- a/src/bmc.c
13+++ b/src/bmc.c
14@@ -249,6 +249,7 @@ void s1(MsgHeader *header,MsgAnnounce *announce,PtpClock *ptpClock, const RunTim
15 ptpClock->timePropertiesDS.ptpTimescale = IS_SET(header->flagField1, PTPT);
16 ptpClock->timePropertiesDS.timeSource = announce->timeSource;
17
18+#ifndef FSL_1588
19 #if defined(MOD_TAI) && NTP_API == 4
20 /*
21 * update kernel TAI offset, but only if timescale is
22@@ -261,6 +262,7 @@ void s1(MsgHeader *header,MsgAnnounce *announce,PtpClock *ptpClock, const RunTim
23 INFO("Set kernel UTC offset to %d\n", ptpClock->timePropertiesDS.currentUtcOffset);
24 }
25 #endif /* MOD_TAI */
26+#endif
27
28 /* Leap second handling */
29
30@@ -280,9 +282,11 @@ void s1(MsgHeader *header,MsgAnnounce *announce,PtpClock *ptpClock, const RunTim
31 ptpClock->leapSecondPending = FALSE;
32 ptpClock->leapSecondInProgress = FALSE;
33 timerStop(LEAP_SECOND_PAUSE_TIMER, ptpClock->itimer);
34+#ifndef FSL_1588
35 #ifdef HAVE_SYS_TIMEX_H
36 unsetTimexFlags(STA_INS | STA_DEL,TRUE);
37 #endif /* HAVE_SYS_TIMEX_H */
38+#endif /* FSL_1588 */
39 }
40
41 /*
42@@ -295,6 +299,7 @@ void s1(MsgHeader *header,MsgAnnounce *announce,PtpClock *ptpClock, const RunTim
43 ((!previousLeap59 && ptpClock->timePropertiesDS.leap59) ||
44 (!previousLeap61 && ptpClock->timePropertiesDS.leap61)))) {
45 #ifdef HAVE_SYS_TIMEX_H
46+#ifndef FSL_1588
47 WARNING("Leap second pending! Setting kernel to %s "
48 "one second at midnight\n",
49 ptpClock->timePropertiesDS.leap61 ? "add" : "delete");
50@@ -304,6 +309,7 @@ void s1(MsgHeader *header,MsgAnnounce *announce,PtpClock *ptpClock, const RunTim
51 setTimexFlags(ptpClock->timePropertiesDS.leap61 ? STA_INS : STA_DEL,
52 FALSE);
53 }
54+#endif
55 #else
56 WARNING("Leap second pending! No kernel leap second "
57 "API support - expect a clock jump at "
58diff --git a/src/dep/net.c b/src/dep/net.c
59index 34d23ad..9075847 100644
60--- a/src/dep/net.c
61+++ b/src/dep/net.c
62@@ -85,6 +85,9 @@
63 #include <linux/ethtool.h>
64 #endif /* SO_TIMESTAMPING */
65
66+#if defined(FSL_1588)
67+char fsl_1588_if_name[IFACE_NAME_LENGTH];
68+#endif
69 /**
70 * shutdown the IPv4 multicast for specific address
71 *
72@@ -461,6 +464,9 @@ testInterface(char * ifaceName, RunTimeOpts* rtOpts)
73 if(getInterfaceInfo(ifaceName, &info) != 1)
74 return FALSE;
75
76+#if defined(FSL_1588)
77+ memcpy(fsl_1588_if_name, ifaceName, IFACE_NAME_LENGTH);
78+#endif
79 switch(rtOpts->transport) {
80
81 case UDP_IPV4:
82@@ -666,6 +672,27 @@ end:
83 }
84 #endif /* SO_TIMESTAMPING */
85
86+#if defined(FSL_1588)
87+/* select HWTSTAMP_TX_ON or HWTSTAMP_TX_OFF */
88+void hwtstamp_tx_ctl(NetPath *netPath, Boolean enable)
89+{
90+ struct ifreq hwtstamp;
91+ struct hwtstamp_config hwconfig;
92+
93+ memset(&hwtstamp, 0, sizeof(hwtstamp));
94+ strncpy(hwtstamp.ifr_name, fsl_1588_if_name, sizeof(hwtstamp.ifr_name));
95+ hwtstamp.ifr_data = (void *)&hwconfig;
96+ memset(&hwconfig, 0, sizeof(hwconfig));
97+ hwconfig.tx_type =
98+ enable ?
99+ HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
100+ hwconfig.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_SYNC;
101+ if (ioctl(netPath->eventSock, SIOCSHWTSTAMP, &hwtstamp) < 0
102+ || ioctl(netPath->generalSock, SIOCSHWTSTAMP, &hwtstamp) < 0)
103+ printf("error:hwtstamp_tx_ctl\n");
104+}
105+#endif
106+
107
108 /**
109 * Initialize timestamping of packets
110@@ -682,10 +709,17 @@ netInitTimestamping(NetPath * netPath, RunTimeOpts * rtOpts)
111 Boolean result = TRUE;
112 #if defined(SO_TIMESTAMPING) && defined(SO_TIMESTAMPNS)/* Linux - current API */
113 DBG("netInitTimestamping: trying to use SO_TIMESTAMPING\n");
114+#if defined(FSL_1588)
115+ val = SOF_TIMESTAMPING_TX_HARDWARE |
116+ SOF_TIMESTAMPING_RX_HARDWARE |
117+ SOF_TIMESTAMPING_RAW_HARDWARE;
118+#else
119 val = SOF_TIMESTAMPING_TX_SOFTWARE |
120 SOF_TIMESTAMPING_RX_SOFTWARE |
121 SOF_TIMESTAMPING_SOFTWARE;
122+#endif
123
124+#ifndef FSL_1588
125 /* unless compiled with PTPD_EXPERIMENTAL, check if we support the desired tstamp capabilities */
126 #ifndef PTPD_EXPERIMENTAL
127 #ifdef ETHTOOL_GET_TS_INFO
128@@ -716,6 +750,7 @@ netInitTimestamping(NetPath * netPath, RunTimeOpts * rtOpts)
129 val = 1;
130 #endif /* ETHTOOL_GET_TS_INFO */
131 #endif /* PTPD_EXPERIMENTAL */
132+#endif /* FSL_1588 */
133
134 if(val == 1) {
135 if (setsockopt(netPath->eventSock, SOL_SOCKET, SO_TIMESTAMPNS, &val, sizeof(int)) < 0) {
136@@ -902,6 +937,9 @@ netInit(NetPath * netPath, RunTimeOpts * rtOpts, PtpClock * ptpClock)
137
138 DBG("Listening on IP: %s\n",inet_ntoa(
139 ((struct sockaddr_in*)&(netPath->interfaceInfo.afAddress))->sin_addr));
140+#if defined(FSL_1588)
141+ hwtstamp_tx_ctl(&ptpClock->netPath, FALSE);/* HWTSTAMP_TX_OFF */
142+#endif
143
144 #ifdef PTPD_PCAP
145 if (rtOpts->pcap == TRUE) {
146@@ -1319,7 +1357,11 @@ netRecvEvent(Octet * buf, TimeInternal * time, NetPath * netPath, int flags)
147 #if defined(SO_TIMESTAMPING) && defined(SO_TIMESTAMPNS)
148 if(cmsg->cmsg_type == SO_TIMESTAMPING ||
149 cmsg->cmsg_type == SO_TIMESTAMPNS) {
150+#if defined(FSL_1588)
151+ ts = (struct timespec *)CMSG_DATA(cmsg) + 2;
152+#else
153 ts = (struct timespec *)CMSG_DATA(cmsg);
154+#endif
155 time->seconds = ts->tv_sec;
156 time->nanoseconds = ts->tv_nsec;
157 timestampValid = TRUE;
158@@ -1520,6 +1562,9 @@ netSendEvent(Octet * buf, UInteger16 length, NetPath * netPath,
159 ssize_t ret;
160 struct sockaddr_in addr;
161
162+#if defined(FSL_1588)
163+ hwtstamp_tx_ctl(netPath, TRUE);/* HWTSTAMP_TX_ON */
164+#endif
165 addr.sin_family = AF_INET;
166 addr.sin_port = htons(PTP_EVENT_PORT);
167
168@@ -1559,6 +1604,9 @@ netSendEvent(Octet * buf, UInteger16 length, NetPath * netPath,
169 DBG("Error sending unicast event message\n");
170 else
171 netPath->sentPackets++;
172+#if defined(FSL_1588)
173+ usleep(100);
174+#endif
175 #ifndef SO_TIMESTAMPING
176 /*
177 * Need to forcibly loop back the packet since
178@@ -1574,10 +1622,14 @@ netSendEvent(Octet * buf, UInteger16 length, NetPath * netPath,
179 #else
180 if(!netPath->txTimestampFailure) {
181 if(!getTxTimestamp(netPath, tim)) {
182+#if defined(FSL_1588)
183+ printf("getTxTimestamp: get tx timestamp error\n");
184+#else
185 netPath->txTimestampFailure = TRUE;
186 if (tim) {
187 clearTime(tim);
188 }
189+#endif
190 }
191 }
192
193@@ -1609,9 +1661,15 @@ netSendEvent(Octet * buf, UInteger16 length, NetPath * netPath,
194 DBG("Error sending multicast event message\n");
195 else
196 netPath->sentPackets++;
197+#if defined(FSL_1588)
198+ usleep(100);
199+#endif
200 #ifdef SO_TIMESTAMPING
201 if(!netPath->txTimestampFailure) {
202 if(!getTxTimestamp(netPath, tim)) {
203+#if defined(FSL_1588)
204+ printf("getTxTimestamp: get tx timestamp error\n");
205+#else
206 if (tim) {
207 clearTime(tim);
208 }
209@@ -1620,6 +1678,7 @@ netSendEvent(Octet * buf, UInteger16 length, NetPath * netPath,
210
211 /* Try re-enabling MULTICAST_LOOP */
212 netSetMulticastLoopback(netPath, TRUE);
213+#endif
214 }
215 }
216 #endif /* SO_TIMESTAMPING */
217@@ -1638,6 +1697,9 @@ netSendGeneral(Octet * buf, UInteger16 length, NetPath * netPath,
218 ssize_t ret;
219 struct sockaddr_in addr;
220
221+#if defined(FSL_1588)
222+ hwtstamp_tx_ctl(netPath, TRUE);/* HWTSTAMP_TX_ON */
223+#endif
224 addr.sin_family = AF_INET;
225 addr.sin_port = htons(PTP_GENERAL_PORT);
226
227@@ -1707,6 +1769,9 @@ netSendPeerGeneral(Octet * buf, UInteger16 length, NetPath * netPath, RunTimeOpt
228 ssize_t ret;
229 struct sockaddr_in addr;
230
231+#if defined(FSL_1588)
232+ hwtstamp_tx_ctl(netPath, TRUE);/* HWTSTAMP_TX_ON */
233+#endif
234 addr.sin_family = AF_INET;
235 addr.sin_port = htons(PTP_GENERAL_PORT);
236
237@@ -1762,6 +1827,9 @@ netSendPeerEvent(Octet * buf, UInteger16 length, NetPath * netPath, RunTimeOpts
238 ssize_t ret;
239 struct sockaddr_in addr;
240
241+#if defined(FSL_1588)
242+ hwtstamp_tx_ctl(netPath, TRUE);/* HWTSTAMP_TX_ON */
243+#endif
244 addr.sin_family = AF_INET;
245 addr.sin_port = htons(PTP_EVENT_PORT);
246
247@@ -1788,6 +1856,9 @@ netSendPeerEvent(Octet * buf, UInteger16 length, NetPath * netPath, RunTimeOpts
248 DBG("Error sending unicast peer event message\n");
249 else
250 netPath->sentPackets++;
251+#if defined(FSL_1588)
252+ usleep(100);
253+#endif
254
255 #ifndef SO_TIMESTAMPING
256 /*
257@@ -1804,10 +1875,14 @@ netSendPeerEvent(Octet * buf, UInteger16 length, NetPath * netPath, RunTimeOpts
258 #else
259 if(!netPath->txTimestampFailure) {
260 if(!getTxTimestamp(netPath, tim)) {
261+#if defined(FSL_1588)
262+ printf("getTxTimestamp: get tx timestamp error\n");
263+#else
264 netPath->txTimestampFailure = TRUE;
265 if (tim) {
266 clearTime(tim);
267 }
268+#endif
269 }
270 }
271
272@@ -1839,9 +1914,15 @@ netSendPeerEvent(Octet * buf, UInteger16 length, NetPath * netPath, RunTimeOpts
273 DBG("Error sending multicast peer event message\n");
274 else
275 netPath->sentPackets++;
276+#if defined(FSL_1588)
277+ usleep(100);
278+#endif
279 #ifdef SO_TIMESTAMPING
280 if(!netPath->txTimestampFailure) {
281 if(!getTxTimestamp(netPath, tim)) {
282+#if defined(FSL_1588)
283+ printf("getTxTimestamp: get tx timestamp error\n");
284+#else
285 if (tim) {
286 clearTime(tim);
287 }
288@@ -1850,6 +1931,7 @@ netSendPeerEvent(Octet * buf, UInteger16 length, NetPath * netPath, RunTimeOpts
289
290 /* Try re-enabling MULTICAST_LOOP */
291 netSetMulticastLoopback(netPath, TRUE);
292+#endif
293 }
294 }
295 #endif /* SO_TIMESTAMPING */
296diff --git a/src/dep/ntpengine/ntpdcontrol.c b/src/dep/ntpengine/ntpdcontrol.c
297index d773284..e84af9e 100644
298--- a/src/dep/ntpengine/ntpdcontrol.c
299+++ b/src/dep/ntpengine/ntpdcontrol.c
300@@ -170,6 +170,15 @@ get_systime(
301 {
302 double dtemp;
303
304+#if defined(FSL_1588)
305+ struct timespec tp;
306+ clock_gettime(clkid, &tp);
307+ tv.tv_sec = tp.tv_sec;
308+ tv.tv_usec = tp.tv_nsec / 1000;
309+
310+ now->l_i = tv.tv_sec + JAN_1970;
311+ dtemp = tv.tv_usec / 1e6;
312+#else /* FSL_1588 */
313 #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK)
314 struct timespec ts; /* seconds and nanoseconds */
315
316@@ -195,6 +204,7 @@ get_systime(
317 dtemp = tv.tv_usec / 1e6;
318
319 #endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
320+#endif /* FSL_1588 */
321
322 /*
323 * Renormalize to seconds past 1900 and fraction.
324diff --git a/src/dep/ptpd_dep.h b/src/dep/ptpd_dep.h
325index 8778988..03ae642 100644
326--- a/src/dep/ptpd_dep.h
327+++ b/src/dep/ptpd_dep.h
328@@ -14,6 +14,7 @@
329 #define PTPD_DBGV
330 #endif
331
332+#define FSL_1588 1
333 /** \name System messages*/
334 /**\{*/
335
336@@ -280,6 +281,11 @@ UInteger16 msgPackManagementResponse(Octet * buf,MsgHeader*,MsgManagement*,PtpCl
337 * -Init network stuff, send and receive datas*/
338 /**\{*/
339
340+#if defined(FSL_1588)
341+extern char fsl_1588_if_name[IFACE_NAME_LENGTH];
342+/* select HWTSTAMP_TX_ON or HWTSTAMP_TX_OFF */
343+void hwtstamp_tx_ctl(NetPath *netPath, Boolean enable);
344+#endif
345 Boolean testInterface(char* ifaceName, RunTimeOpts* rtOpts);
346 Boolean netInit(NetPath*,RunTimeOpts*,PtpClock*);
347 Boolean netShutdown(NetPath*);
348@@ -357,6 +363,10 @@ void restartLogging(RunTimeOpts* rtOpts);
349 void logStatistics(RunTimeOpts *rtOpts, PtpClock *ptpClock);
350 void displayStatus(PtpClock *ptpClock, const char *prefixMessage);
351 void displayPortIdentity(PortIdentity *port, const char *prefixMessage);
352+#if defined(FSL_1588)
353+clockid_t get_clockid(int fd);
354+int clock_adjtime(clockid_t id, struct timex *tx);
355+#endif
356 Boolean nanoSleep(TimeInternal*);
357 void getTime(TimeInternal*);
358 void setTime(TimeInternal*);
359@@ -378,12 +388,15 @@ void adjTime(Integer32);
360 void adjFreq_wrapper(RunTimeOpts * rtOpts, PtpClock * ptpClock, double adj);
361 Boolean adjFreq(double);
362 double getAdjFreq(void);
363+#ifndef FSL_1588
364 void informClockSource(PtpClock* ptpClock);
365+#endif
366
367 /* Observed drift save / recovery functions */
368 void restoreDrift(PtpClock * ptpClock, RunTimeOpts * rtOpts, Boolean quiet);
369 void saveDrift(PtpClock * ptpClock, RunTimeOpts * rtOpts, Boolean quiet);
370
371+#ifndef FSL_1588
372 /* Helper function to manage ntpadjtime / adjtimex flags */
373 void setTimexFlags(int flags, Boolean quiet);
374 void unsetTimexFlags(int flags, Boolean quiet);
375@@ -393,6 +406,7 @@ Boolean checkTimexFlags(int flags);
376 #if defined(MOD_TAI) && NTP_API == 4
377 void setKernelUtcOffset(int utc_offset);
378 #endif /* MOD_TAI */
379+#endif
380
381 #endif /* HAVE_SYS_TIMEX_H */
382
383diff --git a/src/dep/servo.c b/src/dep/servo.c
384index 06215e6..6651a20 100644
385--- a/src/dep/servo.c
386+++ b/src/dep/servo.c
387@@ -1013,10 +1013,12 @@ if(rtOpts->ntpOptions.enableEngine && rtOpts->panicModeNtp) {
388 /* Adjust the clock first -> the PI controller runs here */
389 adjFreq_wrapper(rtOpts, ptpClock, runPIservo(&ptpClock->servo, ptpClock->offsetFromMaster.nanoseconds));
390 warn_operator_fast_slewing(rtOpts, ptpClock, ptpClock->servo.observedDrift);
391+#ifndef FSL_1588
392 /* Unset STA_UNSYNC */
393 unsetTimexFlags(STA_UNSYNC, TRUE);
394 /* "Tell" the clock about maxerror, esterror etc. */
395 informClockSource(ptpClock);
396+#endif /* FSL_1588 */
397 #endif /* HAVE_SYS_TIMEX_H */
398 }
399
400diff --git a/src/dep/sys.c b/src/dep/sys.c
401index 52b274c..8551724 100644
402--- a/src/dep/sys.c
403+++ b/src/dep/sys.c
404@@ -344,7 +344,14 @@ int writeMessage(FILE* destination, int priority, const char * format, va_list a
405 * it also can cause problems in nested debug statements (which are solved by turning the signal
406 * handling synchronous, and not calling this function inside asycnhronous signal processing)
407 */
408+#if defined(FSL_1588)
409+ struct timespec tp;
410+ clock_gettime(clkid, &tp);
411+ now.tv_sec = tp.tv_sec;
412+ now.tv_usec = tp.tv_nsec / 1000;
413+#else
414 gettimeofday(&now, 0);
415+#endif
416 strftime(time_str, MAXTIMESTR, "%F %X", localtime((time_t*)&now.tv_sec));
417 fprintf(destination, "%s.%06d ", time_str, (int)now.tv_usec );
418 fprintf(destination,PTPD_PROGNAME"[%d].%s (%-9s ",
419@@ -1174,13 +1181,33 @@ nanoSleep(TimeInternal * t)
420 return TRUE;
421 }
422
423+#if defined(FSL_1588)
424+clockid_t get_clockid(int fd)
425+{
426+#define CLOCKFD 3
427+#define FD_TO_CLOCKID(fd) ((~(clockid_t) (fd) << 3) | CLOCKFD)
428+ return FD_TO_CLOCKID(fd);
429+}
430+
431+/* When glibc offers the syscall, this will go away. */
432+#include <sys/syscall.h>
433+int clock_adjtime(clockid_t id, struct timex *tx)
434+{
435+ return syscall(__NR_clock_adjtime, id, tx);
436+}
437+#endif
438+
439 void
440 getTime(TimeInternal * time)
441 {
442-#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
443+#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) || defined(FSL_1588)
444
445 struct timespec tp;
446+#if defined(FSL_1588)
447+ if (clock_gettime(clkid, &tp) < 0) {
448+#else
449 if (clock_gettime(CLOCK_REALTIME, &tp) < 0) {
450+#endif
451 PERROR("clock_gettime() failed, exiting.");
452 exit(0);
453 }
454@@ -1201,7 +1228,7 @@ void
455 setTime(TimeInternal * time)
456 {
457
458-#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
459+#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) || defined(FSL_1588)
460
461 struct timespec tp;
462 tp.tv_sec = time->seconds;
463@@ -1215,9 +1242,13 @@ setTime(TimeInternal * time)
464
465 #endif /* _POSIX_TIMERS */
466
467-#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
468
469+#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) || defined(FSL_1588)
470+#if defined(FSL_1588)
471+ if (clock_settime(clkid, &tp) < 0) {
472+#else
473 if (clock_settime(CLOCK_REALTIME, &tp) < 0) {
474+#endif
475 PERROR("Could not set system time");
476 return;
477 }
478@@ -1595,7 +1626,11 @@ adjFreq(double adj)
479 #endif /* HAVE_STRUCT_TIMEX_TICK */
480 DBG2(" adj is %.09f; t freq is %d (float: %.09f)\n", adj, t.freq, dFreq);
481
482+#if defined(FSL_1588)
483+ return !clock_adjtime(clkid, &t);
484+#else
485 return !adjtimex(&t);
486+#endif
487 }
488
489
490@@ -1609,7 +1644,11 @@ getAdjFreq(void)
491
492 memset(&t, 0, sizeof(t));
493 t.modes = 0;
494+#if defined(FSL_1588)
495+ clock_adjtime(clkid, &t);
496+#else
497 adjtimex(&t);
498+#endif
499
500 dFreq = (t.freq + 0.0) / ((1<<16) / 1000.0);
501
502@@ -1764,6 +1803,7 @@ saveDrift(PtpClock * ptpClock, RunTimeOpts * rtOpts, Boolean quiet)
503 fclose(driftFP);
504 }
505
506+#ifndef FSL_1588
507 void
508 setTimexFlags(int flags, Boolean quiet)
509 {
510@@ -1922,6 +1962,7 @@ setKernelUtcOffset(int utc_offset) {
511 }
512 }
513 #endif /* MOD_TAI */
514+#endif /* FSL_1588 */
515
516
517 #else
518diff --git a/src/protocol.c b/src/protocol.c
519index c73728b..90554f3 100644
520--- a/src/protocol.c
521+++ b/src/protocol.c
522@@ -615,6 +615,7 @@ if(!rtOpts->panicModeNtp || !ptpClock->panicMode)
523 timerStart(STATISTICS_UPDATE_TIMER, rtOpts->statsUpdateInterval, ptpClock->itimer);
524 #endif /* PTPD_STATISTICS */
525
526+#ifndef FSL_1588
527 #ifdef HAVE_SYS_TIMEX_H
528
529 /*
530@@ -632,6 +633,7 @@ if(!rtOpts->panicModeNtp || !ptpClock->panicMode)
531 unsetTimexFlags(STA_INS | STA_DEL, TRUE);
532 }
533 #endif /* HAVE_SYS_TIMEX_H */
534+#endif /* FSL_1588 */
535 break;
536 default:
537 DBG("to unrecognized state\n");
538@@ -934,6 +936,7 @@ doState(RunTimeOpts *rtOpts, PtpClock *ptpClock)
539 WARNING("Leap second event imminent - pausing "
540 "clock and offset updates\n");
541 ptpClock->leapSecondInProgress = TRUE;
542+#ifndef FSL_1588
543 #ifdef HAVE_SYS_TIMEX_H
544 if(!checkTimexFlags(ptpClock->timePropertiesDS.leap61 ?
545 STA_INS : STA_DEL)) {
546@@ -944,6 +947,7 @@ doState(RunTimeOpts *rtOpts, PtpClock *ptpClock)
547 STA_INS : STA_DEL, FALSE);
548 }
549 #endif /* HAVE_SYS_TIMEX_H */
550+#endif /* FSL_1588 */
551 /*
552 * start pause timer from now until [pause] after
553 * midnight, plus an extra second if inserting
554@@ -1290,6 +1294,9 @@ handle(RunTimeOpts *rtOpts, PtpClock *ptpClock)
555 int ret;
556 ssize_t length = -1;
557
558+#if defined(FSL_1588)
559+ hwtstamp_tx_ctl(&ptpClock->netPath, FALSE);/* HWTSTAMP_TX_OFF */
560+#endif
561 TimeInternal timeStamp = { 0, 0 };
562 fd_set readfds;
563
564@@ -1437,9 +1444,11 @@ handleAnnounce(MsgHeader *header, ssize_t length,
565 ptpClock->leapSecondInProgress=FALSE;
566 ptpClock->timePropertiesDS.leap59 = FALSE;
567 ptpClock->timePropertiesDS.leap61 = FALSE;
568+#ifndef FSL_1588
569 #ifdef HAVE_SYS_TIMEX_H
570 unsetTimexFlags(STA_INS | STA_DEL, TRUE);
571 #endif /* HAVE_SYS_TIMEX_H */
572+#endif /* FSL_1588 */
573 }
574 }
575 DBG2("___ Announce: received Announce from current Master, so reset the Announce timer\n");
576diff --git a/src/ptpd.c b/src/ptpd.c
577index 3fad379..471b1e9 100644
578--- a/src/ptpd.c
579+++ b/src/ptpd.c
580@@ -78,6 +78,21 @@ main(int argc, char **argv)
581 PtpClock *ptpClock;
582 Integer16 ret;
583
584+#if defined(FSL_1588)
585+ char device[] = "/dev/ptp0";
586+ int fd;
587+
588+ fd = open(device, O_RDWR);
589+ if (fd < 0) {
590+ fprintf(stderr, "opening %s: %s\n", device, strerror(errno));
591+ return -1;
592+ }
593+ clkid = get_clockid(fd);
594+ if (clkid == -1) {
595+ fprintf(stderr, "failed to read clock id\n");
596+ return -1;
597+ }
598+#endif
599 startupInProgress = TRUE;
600
601 /* Initialize run time options with command line arguments */
602diff --git a/src/ptpd.h b/src/ptpd.h
603index 009f51c..6641649 100644
604--- a/src/ptpd.h
605+++ b/src/ptpd.h
606@@ -172,6 +172,15 @@
607 #include <linux/rtc.h>
608 #endif /* HAVE_LINUX_RTC_H */
609
610+#ifdef FSL_1588
611+#ifndef SO_TIMESTAMPING
612+#define SO_TIMESTAMPING 37
613+#endif
614+#ifndef HAVE_SYS_TIMEX_H
615+#define HAVE_SYS_TIMEX_H 1
616+#endif
617+clockid_t clkid;
618+#endif
619 /** \name arith.c
620 * -Timing management and arithmetic*/
621 /**\{*/
diff --git a/meta-networking/recipes-daemons/ptpd/ptpd_2.3.1-rc2.bb b/meta-networking/recipes-daemons/ptpd/ptpd_2.3.1.bb
index c65e73585..f6aaee0eb 100644
--- a/meta-networking/recipes-daemons/ptpd/ptpd_2.3.1-rc2.bb
+++ b/meta-networking/recipes-daemons/ptpd/ptpd_2.3.1.bb
@@ -6,7 +6,7 @@ time coordination of LAN connected computers."
6HOMEPAGE = "http://sourceforge.net/projects/ptpd" 6HOMEPAGE = "http://sourceforge.net/projects/ptpd"
7SECTION = "net" 7SECTION = "net"
8LICENSE = "BSD" 8LICENSE = "BSD"
9LIC_FILES_CHKSUM = "file://README;md5=2452033fe374283f29579898663b1aa8" 9LIC_FILES_CHKSUM = "file://README;md5=0733e1b3788ab2ebbc63bf33a020da1d"
10 10
11DEPENDS = "libpcap" 11DEPENDS = "libpcap"
12 12
@@ -22,14 +22,13 @@ def get_sub(d):
22 return parts[0] 22 return parts[0]
23 23
24SRC_URI = "http://downloads.sourceforge.net/project/ptpd/ptpd/${@get_sub(d)}/ptpd-${PV}.tar.gz \ 24SRC_URI = "http://downloads.sourceforge.net/project/ptpd/ptpd/${@get_sub(d)}/ptpd-${PV}.tar.gz \
25 file://ptpd-add-dpaa-etsec-support.patch \
26 file://ptpd-use-pkgconfig.patch \ 25 file://ptpd-use-pkgconfig.patch \
27 file://ptpd.service \ 26 file://ptpd.service \
28 file://ptpd.conf \ 27 file://ptpd.conf \
29" 28"
30 29
31SRC_URI[md5sum] = "1ef2f1f2825080a865bbce0eb61246d4" 30SRC_URI[md5sum] = "253bab7ab51d969616ea811be1f132f3"
32SRC_URI[sha256sum] = "2802aab758649bb222859dfcb62a5d282709ccb4d3f1df3f26f739cc091d0c8d" 31SRC_URI[sha256sum] = "0dbf54dd2c178bd9fe62481d2c37513ee36636d8bf137cfdad96891490cdbf93"
33 32
34S = "${WORKDIR}/ptpd-${PV}" 33S = "${WORKDIR}/ptpd-${PV}"
35 34