@@ -12,6 +12,10 @@ LOG_MODULE_DECLARE(net_gptp, CONFIG_NET_GPTP_LOG_LEVEL);
1212#include "gptp_data_set.h"
1313#include "gptp_private.h"
1414
15+ #ifdef CONFIG_PTP_CLOCK_LOWRISC
16+ #include <posix/time.h>
17+ #endif
18+
1519static void gptp_md_sync_prepare (struct net_pkt * pkt ,
1620 struct gptp_md_sync_info * sync_send ,
1721 int port_number )
@@ -101,6 +105,10 @@ static int gptp_set_md_sync_receive(int port,
101105 struct net_ptp_time * sync_ts ;
102106 double prop_delay_rated ;
103107 double delay_asymmetry_rated ;
108+ #ifdef CONFIG_PTP_CLOCK_LOWRISC
109+ #define UPDATE_SECS 30
110+ static int count = UPDATE_SECS ;
111+ #endif
104112
105113 state = & GPTP_PORT_STATE (port )-> sync_rcv ;
106114 if (!state -> rcvd_sync_ptr || !state -> rcvd_follow_up_ptr ) {
@@ -129,6 +137,30 @@ static int gptp_set_md_sync_receive(int port,
129137 sync_rcv -> upstream_tx_time *= NSEC_PER_SEC ;
130138 sync_rcv -> upstream_tx_time += sync_ts -> nanosecond ;
131139
140+ #ifdef CONFIG_PTP_CLOCK_LOWRISC
141+ if (++ count >= UPDATE_SECS ) {
142+ struct timespec tp ;
143+ tp .tv_sec = sync_rcv -> precise_orig_ts .second ;
144+ tp .tv_nsec = sync_rcv -> precise_orig_ts .nanosecond ;
145+ clock_settime (CLOCK_REALTIME , & tp );
146+
147+ if (0 ) {
148+ struct tm tm , * tm_p = & tm ;
149+ gmtime_r (& tp .tv_sec , tm_p );
150+ NET_WARN ("seq %d sec:ns %d:%d %d-%02u-%02u " "%02u:%02u:%02u UTC" ,
151+ ntohs (fup_hdr -> sequence_id ),
152+ sync_rcv -> precise_orig_ts ._sec .low , sync_rcv -> precise_orig_ts .nanosecond ,
153+ tm_p -> tm_year + 1900 ,
154+ tm_p -> tm_mon + 1 ,
155+ tm_p -> tm_mday ,
156+ tm_p -> tm_hour ,
157+ tm_p -> tm_min ,
158+ tm_p -> tm_sec );
159+ }
160+ count = 0 ;
161+ }
162+ #endif
163+
132164 prop_delay_rated = port_ds -> neighbor_prop_delay ;
133165 prop_delay_rated /= port_ds -> neighbor_rate_ratio ;
134166
@@ -402,6 +434,9 @@ static void gptp_md_pdelay_compute(int port)
402434 */
403435 if ((port_ds -> neighbor_prop_delay <=
404436 port_ds -> neighbor_prop_delay_thresh )) {
437+ if (port_ds -> as_capable == false) {
438+ NET_WARN ("AS capable: true" );
439+ }
405440 port_ds -> as_capable = true;
406441 } else {
407442 port_ds -> as_capable = false;
0 commit comments