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)
/* 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,
TimeInternal *t)
struct pp_time *t)
{
int got;
struct wrpc_socket *sock;
......@@ -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);
if (t) {
t->seconds = wr_ts.sec;
t->nanoseconds = wr_ts.nsec;
t->phase = wr_ts.phase;
t->correct = wr_ts.correct;
#if 0 /* I disabled the fields, for space: they were only used here */
t->raw_nsec = wr_ts.raw_nsec;
t->raw_phase = wr_ts.raw_phase;
#endif
t->raw_ahead = wr_ts.raw_ahead;
t->secs = wr_ts.sec;
t->scaled_nsecs = (int64_t)wr_ts.nsec << 16;
t->scaled_nsecs += wr_ts.phase * (1 << 16) / 1000;
if (!wr_ts.correct)
mark_incorrect(t);
}
/* 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,
struct wrpc_socket *sock;
struct wr_timestamp wr_ts;
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;
static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS,
......@@ -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);
if (t) {
t->seconds = wr_ts.sec;
t->nanoseconds = wr_ts.nsec;
t->phase = 0;
t->correct = wr_ts.correct;
pp_diag(ppi, frames, 2, "%s: snt=%d, sec=%d, nsec=%d\n",
__func__, snt, t->seconds, t->nanoseconds);
t->secs = wr_ts.sec;
t->scaled_nsecs = (int64_t)wr_ts.nsec << 16;
if (!wr_ts.correct)
mark_incorrect(t);
pp_diag(ppi, frames, 2, "%s: snt=%d, sec=%ld, nsec=%ld\n",
__func__, snt, (long)t->secs,
(long)(t->scaled_nsecs >> 16));
}
/* wrpc-sw may pass this in USER_CFLAGS, to remove footprint */
#ifndef CONFIG_NO_PTPDUMP
......
......@@ -9,22 +9,22 @@
#include "pps_gen.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;
uint32_t nsec;
shw_pps_gen_get_time(&sec, &nsec);
t->seconds = sec;
t->nanoseconds = nsec;
t->secs = sec;
t->scaled_nsecs = (int64_t)nsec << 16;
if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG))
pp_diag(ppi, time, 2, "%s: %9lu.%09li\n", __func__,
(long)sec, (long)nsec);
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;
unsigned long nsec;
......@@ -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 */
return 0;
sec = t->seconds;
nsec = t->nanoseconds;
sec = t->secs;
nsec = t->scaled_nsecs >> 16;
shw_pps_gen_set_time(sec, nsec, PPSG_SET_ALL);
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