Commit 4b07d444 authored by Alessandro Rubini's avatar Alessandro Rubini

kill timer: implement timeout

The timer implementatin was incredibly complex.  Now there is no such
thing as a timer in ptp. We only have timeouts.

A timeout is a point in time. We calculate; we can be earlier; we
can be later. The only thing which is arch-specific is calculating.

This replaces every "timer" operation with the equivalent "timeout"
one. All stuff is renamed to avoid confusion between "time" and
"timer".

Unfortunately, the resulting program as of this commit is not working.
the pdelay_request timeout happens continuously, I'm sure I've exposed
a latent bug, which I'm now going to fix.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent b9de5693
......@@ -11,7 +11,7 @@ LIBARCH := $A/libarch.a
OBJ-libarch := $A/bare-startup.o \
$A/main-loop.o \
$A/bare-socket.o \
$A/bare-timer.o \
$A/bare-timeout.o \
$A/bare-io.o \
$A/bare-time.o \
$A/syscalls.o \
......
/*
* There is no such thing as a timer in ptp. We only have timeouts.
*
* A timeout is a point in time. We calculate; we can be earlier; we
* can be later. The only thing which is arch-specific is calculating.
*/
#include <ppsi/ppsi.h>
#include "bare-i386.h"
unsigned long pp_calc_timeout(int millisec)
{
struct bare_timespec now;
uint64_t now_ms;
unsigned long result;
if (!millisec)
millisec = 1;
sys_clock_gettime(CLOCK_MONOTONIC, &now);
now_ms = 1000LL * now.tv_sec + now.tv_nsec / 1000 / 1000;
result = now_ms + millisec;
return result ? result : 1; /* cannot return 0 */
}
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-i386.h"
#include <unistd.h>
static struct pp_timer bare_timers[PP_TIMER_ARRAY_SIZE];
int bare_timer_init(struct pp_instance *ppi)
{
uint32_t i;
for (i = 0; i < PP_TIMER_ARRAY_SIZE; i++)
ppi->timers[i] = &bare_timers[i];
return 0;
}
int bare_timer_start(uint32_t interval_ms, struct pp_timer *tm)
{
struct bare_timeval now;
sys_clock_gettime(CLOCK_MONOTONIC, &now);
tm->start = ((uint64_t)(now.tv_sec)) * 1000 +
(now.tv_nsec / 1000000);
tm->interval_ms = interval_ms;
return 0;
}
int bare_timer_stop(struct pp_timer *tm)
{
tm->interval_ms = 0;
tm->start = 0;
return 0;
}
int bare_timer_expired(struct pp_timer *tm)
{
struct bare_timespec now;
uint64_t now_ms;
if (tm->start == 0) {
PP_PRINTF("%s: Warning: timer %p not started\n", __func__, tm);
return 0;
}
sys_clock_gettime(CLOCK_MONOTONIC, &now);
now_ms = ((uint64_t)(now.tv_sec)) * 1000 +
(now.tv_nsec / 1000000);
if (now_ms > tm->start + tm->interval_ms) {
tm->start = now_ms;
return 1;
}
return 0;
}
int pp_timer_init(struct pp_instance *ppi)
__attribute__((alias("bare_timer_init")));
int pp_timer_start(uint32_t interval_ms, struct pp_timer *tm)
__attribute__((alias("bare_timer_start")));
int pp_timer_stop(struct pp_timer *tm)
__attribute__((alias("bare_timer_stop")));
int pp_timer_expired(struct pp_timer *tm)
__attribute__((alias("bare_timer_expired")));
......@@ -11,7 +11,7 @@ LIBARCH := $A/libarch.a
OBJ-libarch := $A/bare-startup.o \
$A/main-loop.o \
$A/bare-socket.o \
$A/bare-timer.o \
$A/bare-timeout.o \
$A/bare-io.o \
$A/bare-time.o \
$A/syscall.o \
......
/*
* There is no such thing as a timer in ptp. We only have timeouts.
*
* A timeout is a point in time. We calculate; we can be earlier; we
* can be later. The only thing which is arch-specific is calculating.
*/
#include <ppsi/ppsi.h>
#include "bare-x86-64.h"
unsigned long pp_calc_timeout(int millisec)
{
struct bare_timespec now;
uint64_t now_ms;
unsigned long result;
if (!millisec)
millisec = 1;
sys_clock_gettime(CLOCK_MONOTONIC, &now);
now_ms = 1000LL * now.tv_sec + now.tv_nsec / 1000 / 1000;
result = now_ms + millisec;
return result ? result : 1; /* cannot return 0 */
}
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-x86-64.h"
#include <unistd.h>
static struct pp_timer bare_timers[PP_TIMER_ARRAY_SIZE];
int bare_timer_init(struct pp_instance *ppi)
{
uint32_t i;
for (i = 0; i < PP_TIMER_ARRAY_SIZE; i++)
ppi->timers[i] = &bare_timers[i];
return 0;
}
int bare_timer_start(uint32_t interval_ms, struct pp_timer *tm)
{
struct bare_timeval now;
sys_clock_gettime(CLOCK_MONOTONIC, &now);
tm->start = ((uint64_t)(now.tv_sec)) * 1000 +
(now.tv_nsec / 1000000);
tm->interval_ms = interval_ms;
return 0;
}
int bare_timer_stop(struct pp_timer *tm)
{
tm->interval_ms = 0;
tm->start = 0;
return 0;
}
int bare_timer_expired(struct pp_timer *tm)
{
struct bare_timespec now;
uint64_t now_ms;
if (tm->start == 0) {
PP_PRINTF("%s: Warning: timer %p not started\n", __func__, tm);
return 0;
}
sys_clock_gettime(CLOCK_MONOTONIC, &now);
now_ms = ((uint64_t)(now.tv_sec)) * 1000 +
(now.tv_nsec / 1000000);
if (now_ms > tm->start + tm->interval_ms) {
tm->start = now_ms;
return 1;
}
return 0;
}
int pp_timer_init(struct pp_instance *ppi)
__attribute__((alias("bare_timer_init")));
int pp_timer_start(uint32_t interval_ms, struct pp_timer *tm)
__attribute__((alias("bare_timer_start")));
int pp_timer_stop(struct pp_timer *tm)
__attribute__((alias("bare_timer_stop")));
int pp_timer_expired(struct pp_timer *tm)
__attribute__((alias("bare_timer_expired")));
......@@ -13,7 +13,7 @@ OBJ-libarch := $A/posix-startup.o \
$A/posix-socket.o \
$A/posix-io.o \
$A/posix-time.o \
$A/posix-timer.o \
$A/posix-timeout.o \
lib/cmdline.o \
lib/libc-functions.o \
lib/div64.o
......
/*
* There is no such thing as a timer in ptp. We only have timeouts.
*
* A timeout is a point in time. We calculate; we can be earlier; we
* can be later. The only thing which is arch-specific is calculating.
*/
#include <ppsi/ppsi.h>
#include <time.h>
unsigned long pp_calc_timeout(int millisec)
{
struct timespec now;
uint64_t now_ms;
unsigned long result;
if (!millisec)
millisec = 1;
clock_gettime(CLOCK_MONOTONIC, &now);
now_ms = 1000LL * now.tv_sec + now.tv_nsec / 1000 / 1000;
result = now_ms + millisec;
return result ? result : 1; /* cannot return 0 */
}
/*
* Aurelio Colosimo for CERN, 2011 -- GNU LGPL v2.1 or later
*/
/* Timer interface for GNU/Linux (and most likely other posix systems */
#include <time.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "posix.h"
/* In ptpd-2.1.0/src/dep/timer.c the mechanism was different.
* A SIGALARM timer was called once a second, increasing the counter of elapsed
* time.
* I find it easier to check for the timestamp when needed. The granularity of
* this timer is the same as the ptpd solution: 1 second.
* Should be checked if this is enough, but I guess yes.
* Maybe a certain SIGALARM timer solution must be re-introduced, because the
* select in the main loop must exit when a timer elapses. To be tested and
* checked
*/
int posix_timer_init(struct pp_instance *ppi)
{
struct pp_timer *t;
int i;
for (i = 0; i < PP_TIMER_ARRAY_SIZE; i++) {
t = calloc(1, sizeof(*t));
if (!t)
return -1;
ppi->timers[i] = t;
}
return 0;
}
int posix_timer_start(uint32_t interval_ms, struct pp_timer *tm)
{
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
tm->start = ((uint64_t)(now.tv_sec)) * 1000 +
(now.tv_nsec / 1000000);
tm->interval_ms = interval_ms;
return 0;
}
int posix_timer_stop(struct pp_timer *tm)
{
tm->interval_ms = 0;
tm->start = 0;
return 0;
}
int posix_timer_expired(struct pp_timer *tm)
{
struct timespec now;
uint64_t now_ms;
if (tm->start == 0) {
PP_PRINTF("%s: Warning: timer %p not started\n", __func__, tm);
return 0;
}
clock_gettime(CLOCK_MONOTONIC, &now);
now_ms = ((uint64_t)(now.tv_sec)) * 1000 +
(now.tv_nsec / 1000000);
if (now_ms > tm->start + tm->interval_ms) {
tm->start = now_ms;
return 1;
}
return 0;
}
int pp_timer_init(struct pp_instance *ppi)
__attribute__((alias("posix_timer_init")));
int pp_timer_start(uint32_t interval_ms, struct pp_timer *tm)
__attribute__((alias("posix_timer_start")));
int pp_timer_stop(struct pp_timer *tm)
__attribute__((alias("posix_timer_stop")));
int pp_timer_expired(struct pp_timer *tm)
__attribute__((alias("posix_timer_expired")));
......@@ -29,7 +29,7 @@ LIBS += -L$A -larch
OBJ-libarch := $A/wrpc-socket.o \
$A/wrpc-io.o \
$A/wrpc-timer.o \
$A/wrpc-timeout.o \
$A/wrpc-spll.o \
$A/wrpc-calibration.o \
lib/div64.o
......
/*
* There is no such thing as a timer in ptp. We only have timeouts.
*
* A timeout is a point in time. We calculate; we can be earlier; we
* can be later. The only thing which is arch-specific is calculating.
*/
#include <ppsi/ppsi.h>
#include <syscon.h>
unsigned long pp_calc_timeout(int millisec)
{
unsigned long result;
if (!millisec)
millisec = 1;
result = timer_get_tics() + millisec;
return result ? result : 1; /* cannot return 0 */
}
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include <pps_gen.h>
#include <syscon.h>
#include <ptpd_netif.h>
static struct pp_timer wrpc_timers[PP_TIMER_ARRAY_SIZE];
int wrpc_timer_init(struct pp_instance *ppi)
{
uint32_t i;
for (i = 0; i < PP_TIMER_ARRAY_SIZE; i++)
ppi->timers[i] = &wrpc_timers[i];
return 0;
}
int wrpc_timer_start(uint32_t interval_ms, struct pp_timer *tm)
{
tm->start = ptpd_netif_get_msec_tics();
tm->interval_ms = interval_ms;
return 0;
}
int wrpc_timer_stop(struct pp_timer *tm)
{
tm->interval_ms = 0;
tm->start = 0;
return 0;
}
int wrpc_timer_expired(struct pp_timer *tm)
{
uint32_t now;
if (tm->start == 0) {
PP_PRINTF("%s: Warning: timer %p not started\n", __func__, tm);
return 0;
}
now = ptpd_netif_get_msec_tics();
if (now > tm->start + tm->interval_ms) {
tm->start = now;
return 1;
}
return 0;
}
uint32_t wrpc_timer_get_msec_tics(void)
{
return timer_get_tics();
}
int pp_timer_init(struct pp_instance *ppi)
__attribute__((alias("wrpc_timer_init")));
int pp_timer_start(uint32_t interval_ms, struct pp_timer *tm)
__attribute__((alias("wrpc_timer_start")));
int pp_timer_stop(struct pp_timer *tm)
__attribute__((alias("wrpc_timer_stop")));
int pp_timer_expired(struct pp_timer *tm)
__attribute__((alias("wrpc_timer_expired")));
uint32_t wr_timer_get_msec_tics(void)
__attribute__((alias("wrpc_timer_get_msec_tics")));
......@@ -46,22 +46,23 @@
#define PP_DEFAULT_NO_ADJUST 0
#define PP_DEFAULT_TTL 1
/* We use an array of timers, with these indexes */
#define PP_TIMER_UNUSED 0
#define PP_TIMER_DELAYREQ 1
#define PP_TIMER_SYNC 2
#define PP_TIMER_ANN_RECEIPT 3
#define PP_TIMER_ANN_INTERVAL 4
/* White Rabbit timers */
#define PP_TIMER_WRS_PRESENT 5
#define PP_TIMER_WRS_S_LOCK 6
#define PP_TIMER_WRS_M_LOCK 7
#define PP_TIMER_WRS_LOCKED 8
#define PP_TIMER_WRS_CALIBRATION 9
#define PP_TIMER_WRS_CALIBRATED 10
#define PP_TIMER_WRS_RESP_CALIB_REQ 11
#define PP_TIMER_WRS_WR_LINK_ON 12
#define PP_TIMER_ARRAY_SIZE 13
/* We use an array of timeouts, with these indexes */
enum pp_timeouts {
PP_TO_DELAYREQ = 0,
PP_TO_SYNC,
PP_TO_ANN_RECEIPT,
PP_TO_ANN_INTERVAL,
/* White Rabbit timers */
PP_TO_WRS_PRESENT,
PP_TO_WRS_S_LOCK,
PP_TO_WRS_M_LOCK,
PP_TO_WRS_LOCKED,
PP_TO_WRS_CALIBRATION,
PP_TO_WRS_CALIBRATED,
PP_TO_WRS_RESP_CALIB_REQ,
PP_TO_WRS_WR_LINK_ON,
__PP_TO_ARRAY_SIZE,
};
#define PP_TWO_STEP_FLAG 2
#define PP_VERSION_PTP 2
......
......@@ -12,6 +12,7 @@
#include <ppsi/lib.h>
#include <ppsi/ieee1588_types.h>
#include <ppsi/constants.h>
#include <ppsi/jiffies.h>
/*
* Runtime options. Default values can be overridden by command line.
......@@ -75,16 +76,6 @@ struct pp_frgn_master {
MsgHeader hdr;
};
/*
* Timer. Struct which contains timestamp of timer start and desired interval
* for timer expiration computation. Both are seconds
*/
struct pp_timer {
uint64_t start;
uint32_t interval_ms;
};
/*
* Servo. Structs which contain filters for delay average computation. They
* are used in servo.c src, where specific function for time setting of the
......@@ -163,8 +154,7 @@ struct pp_instance {
DSParent *parentDS; /* page 68 */
DSPort *portDS; /* page 72 */
DSTimeProperties *timePropertiesDS; /* page 70 */
struct pp_timer *timers[PP_TIMER_ARRAY_SIZE];
unsigned long timeouts[__PP_TO_ARRAY_SIZE];
UInteger16 number_foreign_records;
Integer16 foreign_record_i;
Integer16 foreign_record_best;
......@@ -309,6 +299,38 @@ struct pp_time_operations {
extern struct pp_time_operations pp_t_ops;
/*
* Timeouts. I renamed from "timer" to "timeout" to avoid
* misread/miswrite with the time operations above. A timeout, actually,
* is just a number that must be compared with the current counter.
* So we don't need struct operations, as it is one function only.
*/
extern unsigned long pp_calc_timeout(int millisec); /* cannot return zero */
static inline void pp_timeout_set(struct pp_instance *ppi, int index,
int millisec)
{
ppi->timeouts[index] = pp_calc_timeout(millisec);
}
static inline void pp_timeout_clr(struct pp_instance *ppi, int index)
{
ppi->timeouts[index] = 0;
}
static inline int pp_timeout(struct pp_instance *ppi, int index)
{
return ppi->timeouts[index] &&
time_after_eq(pp_calc_timeout(0), ppi->timeouts[index]);
}
/* This functions are generic, not architecture-specific */
extern void pp_timeout_set(struct pp_instance *ppi, int index, int millisec);
extern void pp_timeout_clr(struct pp_instance *ppi, int index);
extern int pp_timeout(struct pp_instance *ppi, int index); /* 1 == timeout */
/* The channel for an instance must be created and possibly destroyed. */
extern int pp_open_instance(struct pp_instance *ppi,
struct pp_runtime_opts *rt_opts);
......@@ -317,13 +339,6 @@ extern int pp_close_instance(struct pp_instance *ppi);
extern int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv);
/* Timers */
extern int pp_timer_init(struct pp_instance *ppi); /* initializes timer common
structure */
extern int pp_timer_start(uint32_t interval_ms, struct pp_timer *tm);
extern int pp_timer_stop(struct pp_timer *tm);
extern int pp_timer_expired(struct pp_timer *tm); /* returns 1 when expired */
/* Servo */
extern void pp_init_clock(struct pp_instance *ppi);
extern void pp_update_delay(struct pp_instance *ppi,
......
......@@ -13,11 +13,11 @@ int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->is_new_state) {
WR_DSPOR(ppi)->wrPortState = WRS_CALIBRATED;
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
pp_timer_start(WR_DSPOR(ppi)->wrStateTimeout,
ppi->timers[PP_TIMER_WRS_CALIBRATED]);
pp_timeout_set(ppi, PP_TO_WRS_CALIBRATED,
WR_DSPOR(ppi)->wrStateTimeout);
}
if (pp_timer_expired(ppi->timers[PP_TIMER_WRS_CALIBRATED])) {
if (pp_timeout(ppi, PP_TO_WRS_CALIBRATED)) {
if (WR_DSPOR(ppi)->wrMode == WR_MASTER)
ppi->next_state = PPS_MASTER;
else
......@@ -43,7 +43,7 @@ int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
state_updated:
if (ppi->next_state != ppi->state)
pp_timer_stop(ppi->timers[PP_TIMER_WRS_CALIBRATED]);
pp_timeout_clr(ppi, PP_TO_WRS_CALIBRATED);
ret:
ppi->next_delay = WR_DSPOR(ppi)->wrStateTimeout;
......
......@@ -16,13 +16,13 @@ int wr_calibration(struct pp_instance *ppi, unsigned char *pkt, int plen)
WR_DSPOR(ppi)->wrPortState = WRS_CALIBRATION;
e = msg_issue_wrsig(ppi, CALIBRATE);
pp_timer_start(WR_DSPOR(ppi)->calPeriod,
ppi->timers[PP_TIMER_WRS_CALIBRATION]);
pp_timeout_set(ppi, PP_TO_WRS_CALIBRATION,
WR_DSPOR(ppi)->calPeriod);
if (WR_DSPOR(ppi)->calibrated)
WR_DSPOR(ppi)->wrPortState = WRS_CALIBRATION_2;
}
if (pp_timer_expired(ppi->timers[PP_TIMER_WRS_CALIBRATION])) {
if (pp_timeout(ppi, PP_TO_WRS_CALIBRATION)) {
if (WR_DSPOR(ppi)->wrMode == WR_MASTER)
ppi->next_state = PPS_MASTER;
else
......@@ -127,7 +127,7 @@ int wr_calibration(struct pp_instance *ppi, unsigned char *pkt, int plen)
state_updated:
if (ppi->next_state != ppi->state)
pp_timer_stop(ppi->timers[PP_TIMER_WRS_CALIBRATION]);
pp_timeout_clr(ppi, PP_TO_WRS_CALIBRATION);
ppi->next_delay = WR_DSPOR(ppi)->wrStateTimeout;
......
......@@ -14,13 +14,14 @@ int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->is_new_state) {
DSPOR(ppi)->portState = PPS_UNCALIBRATED;
WR_DSPOR(ppi)->wrPortState = WRS_LOCKED;
pp_timer_start(WR_DSPOR(ppi)->wrStateTimeout,
ppi->timers[PP_TIMER_WRS_LOCKED]);
pp_timeout_set(ppi, PP_TO_WRS_LOCKED,
WR_DSPOR(ppi)->wrStateTimeout);
e = msg_issue_wrsig(ppi, LOCKED);
}
if (pp_timer_expired(ppi->timers[PP_TIMER_WRS_LOCKED])) {
if (pp_timeout(ppi, PP_TO_WRS_LOCKED)) {
ppi->next_state = PPS_LISTENING;
WR_DSPOR(ppi)->wrMode = NON_WR;
WR_DSPOR(ppi)->wrPortState = WRS_IDLE;
......@@ -45,7 +46,7 @@ no_incoming_msg:
state_updated:
if (ppi->next_state != ppi->state)
pp_timer_stop(ppi->timers[PP_TIMER_WRS_LOCKED]);
pp_timeout_clr(ppi, PP_TO_WRS_LOCKED);
ppi->next_delay = WR_DSPOR(ppi)->wrStateTimeout;
......
......@@ -16,11 +16,10 @@ int wr_m_lock(struct pp_instance *ppi, unsigned char *pkt, int plen)
WR_DSPOR(ppi)->wrPortState = WRS_M_LOCK;
WR_DSPOR(ppi)->wrMode = WR_MASTER;
e = msg_issue_wrsig(ppi, LOCK);
pp_timer_start(WR_M_LOCK_TIMEOUT_MS,
ppi->timers[PP_TIMER_WRS_M_LOCK]);
pp_timeout_set(ppi, PP_TO_WRS_M_LOCK, WR_M_LOCK_TIMEOUT_MS);
}
if (pp_timer_expired(ppi->timers[PP_TIMER_WRS_M_LOCK])) {
if (pp_timeout(ppi, PP_TO_WRS_M_LOCK)) {
ppi->next_state = PPS_MASTER;
WR_DSPOR(ppi)->wrPortState = WRS_IDLE;
goto state_updated;
......@@ -44,7 +43,7 @@ no_incoming_msg:
state_updated:
if (ppi->next_state != ppi->state)
pp_timer_stop(ppi->timers[PP_TIMER_WRS_M_LOCK]);
pp_timeout_clr(ppi, PP_TO_WRS_M_LOCK);
ppi->next_delay = WR_DSPOR(ppi)->wrStateTimeout;
......
......@@ -17,13 +17,13 @@ int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen)
DSPOR(ppi)->portState = PPS_UNCALIBRATED;
WR_DSPOR(ppi)->wrPortState = WRS_PRESENT;
WR_DSPOR(ppi)->wrMode = WR_SLAVE;
pp_timer_start(WR_WRS_PRESENT_TIMEOUT_MS,
ppi->timers[PP_TIMER_WRS_PRESENT]);
pp_timeout_set(ppi, PP_TO_WRS_PRESENT,
WR_WRS_PRESENT_TIMEOUT_MS);
st_com_restart_annrec_timer(ppi);
e = msg_issue_wrsig(ppi, SLAVE_PRESENT);
}
if (pp_timer_expired(ppi->timers[PP_TIMER_WRS_PRESENT])) {
if (pp_timeout(ppi, PP_TO_WRS_PRESENT)) {
ppi->next_state = PPS_LISTENING;
WR_DSPOR(ppi)->wrMode = NON_WR;
WR_DSPOR(ppi)->wrPortState = WRS_IDLE;
......@@ -50,8 +50,8 @@ no_incoming_msg:
state_updated:
if (ppi->next_state != ppi->state) {
pp_timer_stop(ppi->timers[PP_TIMER_WRS_PRESENT]);
pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]);
pp_timeout_clr(ppi, PP_TO_WRS_PRESENT);
pp_timeout_clr(ppi, PP_TO_ANN_RECEIPT);
}
ppi->next_delay = WR_DSPOR(ppi)->wrStateTimeout;
......
......@@ -16,15 +16,14 @@ int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen)
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
if (WR_DSPOR(ppi)->otherNodeCalSendPattern) {
wr_calibration_pattern_enable(ppi, 0, 0, 0);
pp_timer_start(
WR_DSPOR(ppi)->otherNodeCalPeriod / 1000,
ppi->timers[PP_TIMER_WRS_RESP_CALIB_REQ]);
pp_timeout_set(ppi, PP_TO_WRS_RESP_CALIB_REQ,
WR_DSPOR(ppi)->otherNodeCalPeriod / 1000);
}
}
if ((WR_DSPOR(ppi)->otherNodeCalSendPattern) &&
(pp_timer_expired(ppi->timers[PP_TIMER_WRS_RESP_CALIB_REQ]))) {
(pp_timeout(ppi, PP_TO_WRS_RESP_CALIB_REQ))) {
if (WR_DSPOR(ppi)->wrMode == WR_MASTER)
ppi->next_state = PPS_MASTER;
else
......@@ -54,7 +53,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen)
state_updated:
if (ppi->next_state != ppi->state)
pp_timer_stop(ppi->timers[PP_TIMER_WRS_M_LOCK]);
pp_timeout_clr(ppi, PP_TO_WRS_M_LOCK);
ppi->next_delay = WR_DSPOR(ppi)->wrStateTimeout;