Commit 24fe3621 authored by Alessandro Rubini's avatar Alessandro Rubini

time: fix wrpc

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 38427664
...@@ -49,7 +49,7 @@ static int wrpc_open_ch(struct pp_instance *ppi) ...@@ -49,7 +49,7 @@ static int wrpc_open_ch(struct pp_instance *ppi)
/* To receive and send packets, we call the minic low-level stuff */ /* To receive and send packets, we call the minic low-level stuff */
static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len, static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t) struct pp_time *t)
{ {
int got; int got;
struct wrpc_socket *sock; struct wrpc_socket *sock;
...@@ -59,15 +59,11 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len, ...@@ -59,15 +59,11 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len,
got = ptpd_netif_recvfrom(sock, &addr, pkt, len, &wr_ts); got = ptpd_netif_recvfrom(sock, &addr, pkt, len, &wr_ts);
if (t) { if (t) {
t->seconds = wr_ts.sec; t->secs = wr_ts.sec;
t->nanoseconds = wr_ts.nsec; t->scaled_nsecs = (int64_t)wr_ts.nsec << 16;
t->phase = wr_ts.phase; t->scaled_nsecs += wr_ts.phase * (1 << 16) / 1000;
t->correct = wr_ts.correct; if (!wr_ts.correct)
#if 0 /* I disabled the fields, for space: they were only used here */ mark_incorrect(t);
t->raw_nsec = wr_ts.raw_nsec;
t->raw_phase = wr_ts.raw_phase;
#endif
t->raw_ahead = wr_ts.raw_ahead;
} }
/* wrpc-sw may pass this in USER_CFLAGS, to remove footprint */ /* wrpc-sw may pass this in USER_CFLAGS, to remove footprint */
...@@ -87,7 +83,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len, ...@@ -87,7 +83,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
struct wrpc_socket *sock; struct wrpc_socket *sock;
struct wr_timestamp wr_ts; struct wr_timestamp wr_ts;
struct wr_sockaddr addr; struct wr_sockaddr addr;
TimeInternal *t = &ppi->last_snt_time; struct pp_time *t = &ppi->last_snt_time;
int is_pdelay = pp_msgtype_info[msgtype].is_pdelay; int is_pdelay = pp_msgtype_info[msgtype].is_pdelay;
static const uint8_t macaddr[2][ETH_ALEN] = { static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS, [PP_E2E_MECH] = PP_MCAST_MACADDRESS,
...@@ -102,13 +98,14 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len, ...@@ -102,13 +98,14 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
snt = ptpd_netif_sendto(sock, &addr, pkt, len, &wr_ts); snt = ptpd_netif_sendto(sock, &addr, pkt, len, &wr_ts);
if (t) { if (t) {
t->seconds = wr_ts.sec; t->secs = wr_ts.sec;
t->nanoseconds = wr_ts.nsec; t->scaled_nsecs = (int64_t)wr_ts.nsec << 16;
t->phase = 0; if (!wr_ts.correct)
t->correct = wr_ts.correct; mark_incorrect(t);
pp_diag(ppi, frames, 2, "%s: snt=%d, sec=%d, nsec=%d\n", pp_diag(ppi, frames, 2, "%s: snt=%d, sec=%ld, nsec=%ld\n",
__func__, snt, t->seconds, t->nanoseconds); __func__, snt, (long)t->secs,
(long)(t->scaled_nsecs >> 16));
} }
/* wrpc-sw may pass this in USER_CFLAGS, to remove footprint */ /* wrpc-sw may pass this in USER_CFLAGS, to remove footprint */
#ifndef CONFIG_NO_PTPDUMP #ifndef CONFIG_NO_PTPDUMP
......
...@@ -9,22 +9,22 @@ ...@@ -9,22 +9,22 @@
#include "pps_gen.h" /* in wrpc-sw */ #include "pps_gen.h" /* in wrpc-sw */
#include "syscon.h" /* in wrpc-sw */ #include "syscon.h" /* in wrpc-sw */
static int wrpc_time_get(struct pp_instance *ppi, TimeInternal *t) static int wrpc_time_get(struct pp_instance *ppi, struct pp_time *t)
{ {
uint64_t sec; uint64_t sec;
uint32_t nsec; uint32_t nsec;
shw_pps_gen_get_time(&sec, &nsec); shw_pps_gen_get_time(&sec, &nsec);
t->seconds = sec; t->secs = sec;
t->nanoseconds = nsec; t->scaled_nsecs = (int64_t)nsec << 16;
if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG)) if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG))
pp_diag(ppi, time, 2, "%s: %9lu.%09li\n", __func__, pp_diag(ppi, time, 2, "%s: %9lu.%09li\n", __func__,
(long)sec, (long)nsec); (long)sec, (long)nsec);
return 0; return 0;
} }
static int wrpc_time_set(struct pp_instance *ppi, TimeInternal *t) static int wrpc_time_set(struct pp_instance *ppi, const struct pp_time *t)
{ {
uint64_t sec; uint64_t sec;
unsigned long nsec; unsigned long nsec;
...@@ -32,8 +32,8 @@ static int wrpc_time_set(struct pp_instance *ppi, TimeInternal *t) ...@@ -32,8 +32,8 @@ static int wrpc_time_set(struct pp_instance *ppi, TimeInternal *t)
if (!t) /* tai offset changed. We don't have it in wrpc-sw */ if (!t) /* tai offset changed. We don't have it in wrpc-sw */
return 0; return 0;
sec = t->seconds; sec = t->secs;
nsec = t->nanoseconds; nsec = t->scaled_nsecs >> 16;
shw_pps_gen_set_time(sec, nsec, PPSG_SET_ALL); shw_pps_gen_set_time(sec, nsec, PPSG_SET_ALL);
pp_diag(ppi, time, 1, "%s: %9lu.%09li\n", __func__, pp_diag(ppi, time, 1, "%s: %9lu.%09li\n", __func__,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment