Commit 847031e2 authored by Aurelio Colosimo's avatar Aurelio Colosimo

Minimal diagnostic implemented

It is mostly inherited from ptpd-2.1.0. May be done in a better way, but
should be fine for first tests
parent b925e0f6
...@@ -8,9 +8,15 @@ ...@@ -8,9 +8,15 @@
#include <time.h> #include <time.h>
#include <sys/timex.h> #include <sys/timex.h>
#include <pptp/pptp.h> #include <pptp/pptp.h>
#include <pptp/diag.h>
const Integer32 PP_ADJ_FREQ_MAX = 512000; const Integer32 PP_ADJ_FREQ_MAX = 512000;
static void print_clock_gettime_err_msg(void)
{
PP_PRINTF("clock_gettime() failed, exiting.");
}
void posix_puts(const char *s) void posix_puts(const char *s)
{ {
fputs(s, stdout); fputs(s, stdout);
...@@ -40,7 +46,7 @@ void posix_get_tstamp(TimeInternal *t) ...@@ -40,7 +46,7 @@ void posix_get_tstamp(TimeInternal *t)
{ {
struct timespec tp; struct timespec tp;
if (clock_gettime(CLOCK_REALTIME, &tp) < 0) { if (clock_gettime(CLOCK_REALTIME, &tp) < 0) {
/* FIXME diag PERROR("clock_gettime() failed, exiting."); */ print_clock_gettime_err_msg();
exit(0); exit(0);
} }
t->seconds = tp.tv_sec; t->seconds = tp.tv_sec;
...@@ -53,14 +59,14 @@ int32_t posix_set_tstamp(TimeInternal *t) ...@@ -53,14 +59,14 @@ int32_t posix_set_tstamp(TimeInternal *t)
struct timespec tp; struct timespec tp;
if (clock_gettime(CLOCK_REALTIME, &tp_orig) < 0) { if (clock_gettime(CLOCK_REALTIME, &tp_orig) < 0) {
/* FIXME diag PERROR("clock_gettime() failed, exiting."); */ print_clock_gettime_err_msg();
exit(0); exit(0);
} }
tp.tv_sec = t->seconds; tp.tv_sec = t->seconds;
tp.tv_nsec = t->nanoseconds; tp.tv_nsec = t->nanoseconds;
if (clock_settime(CLOCK_REALTIME, &tp) < 0) { if (clock_settime(CLOCK_REALTIME, &tp) < 0) {
/* FIXME diag PERROR("clock_settime() failed, exiting."); */ print_clock_gettime_err_msg();
exit(0); exit(0);
} }
......
...@@ -62,7 +62,7 @@ int posix_timer_expired(struct pp_timer *tm) ...@@ -62,7 +62,7 @@ int posix_timer_expired(struct pp_timer *tm)
uint32_t now; uint32_t now;
if (tm->start == 0) { if (tm->start == 0) {
/* FIXME: print a warning message */ PP_PRINTF("Warning: posix_timer_expired: timer not started\n");
return 0; return 0;
} }
......
...@@ -335,6 +335,7 @@ extern int to_TimeInternal(TimeInternal *internal, Timestamp *external); ...@@ -335,6 +335,7 @@ extern int to_TimeInternal(TimeInternal *internal, Timestamp *external);
extern void add_TimeInternal(TimeInternal *r, TimeInternal *x, TimeInternal *y); extern void add_TimeInternal(TimeInternal *r, TimeInternal *x, TimeInternal *y);
extern void sub_TimeInternal(TimeInternal *r, TimeInternal *x, TimeInternal *y); extern void sub_TimeInternal(TimeInternal *r, TimeInternal *x, TimeInternal *y);
extern void set_TimeInternal(TimeInternal *t, Integer32 s, Integer32 ns); extern void set_TimeInternal(TimeInternal *t, Integer32 s, Integer32 ns);
extern void display_TimeInternal(const char *label, TimeInternal *t);
/* Get and Set system timestamp */ /* Get and Set system timestamp */
extern void pp_get_tstamp(TimeInternal *t); extern void pp_get_tstamp(TimeInternal *t);
...@@ -372,8 +373,7 @@ extern pp_action pp_initializing, pp_faulty, pp_disabled, pp_listening, ...@@ -372,8 +373,7 @@ extern pp_action pp_initializing, pp_faulty, pp_disabled, pp_listening,
extern int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen); extern int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen);
/* /*
* FIXME * FIXME Whe talk raw sockets on PP_PROTO_NR.
* Whe talk raw sockets on PP_PROTO_NR.
*/ */
#define PP_PROTO_NR 0xcccc #define PP_PROTO_NR 0xcccc
......
...@@ -36,9 +36,8 @@ int from_TimeInternal(TimeInternal *internal, Timestamp *external) ...@@ -36,9 +36,8 @@ int from_TimeInternal(TimeInternal *internal, Timestamp *external)
if ((internal->seconds & ~INT_MAX) || if ((internal->seconds & ~INT_MAX) ||
(internal->nanoseconds & ~INT_MAX)) { (internal->nanoseconds & ~INT_MAX)) {
/* FIXME diag PP_PRINTF("Error: Negative value cannot be converted into "
* DBG("Negative value cannot be converted into timestamp \n"); "timestamp\n");
*/
return -1; return -1;
} else { } else {
external->secondsField.lsb = internal->seconds; external->secondsField.lsb = internal->seconds;
...@@ -56,10 +55,8 @@ int to_TimeInternal(TimeInternal *internal, Timestamp *external) ...@@ -56,10 +55,8 @@ int to_TimeInternal(TimeInternal *internal, Timestamp *external)
internal->nanoseconds = external->nanosecondsField; internal->nanoseconds = external->nanosecondsField;
return 0; return 0;
} else { } else {
/* FIXME diag PP_PRINTF("to_TimeInternal: "
DBG("Clock servo canno't be executed : " "seconds field is higher than signed integer (32bits)\n");
"seconds field is higher than signed integer (32bits) \n");
*/
return -1; return -1;
} }
} }
...@@ -99,3 +96,8 @@ void set_TimeInternal(TimeInternal *t, Integer32 s, Integer32 ns) ...@@ -99,3 +96,8 @@ void set_TimeInternal(TimeInternal *t, Integer32 s, Integer32 ns)
t->seconds = s; t->seconds = s;
t->nanoseconds = ns; t->nanoseconds = ns;
} }
void display_TimeInternal(const char *label, TimeInternal *t)
{
PP_VPRINTF("%s: %d.%d \n", label, t->seconds, t->nanoseconds);
}
...@@ -139,9 +139,7 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi, ...@@ -139,9 +139,7 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi,
hdr_a->sourcePortIdentity.clockIdentity, hdr_a->sourcePortIdentity.clockIdentity,
ppci, ppci,
PP_CLOCK_IDENTITY_LENGTH)) { PP_CLOCK_IDENTITY_LENGTH)) {
/* FIXME PP_PRINTF("Sender=Receiver: Error -1");
* DBG("Sender=Receiver : Error -1");
*/
return 0; return 0;
} else } else
return 1; return 1;
...@@ -151,9 +149,7 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi, ...@@ -151,9 +149,7 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi,
hdr_b->sourcePortIdentity.clockIdentity, hdr_b->sourcePortIdentity.clockIdentity,
ppci, ppci,
PP_CLOCK_IDENTITY_LENGTH)) { PP_CLOCK_IDENTITY_LENGTH)) {
/* FIXME PP_PRINTF("Sender=Receiver: Error -3");
* DBG("Sender=Receiver : Error -1");
*/
return 0; return 0;
} else { } else {
return -1; return -1;
...@@ -163,9 +159,7 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi, ...@@ -163,9 +159,7 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi,
hdr_a->sourcePortIdentity.clockIdentity, hdr_a->sourcePortIdentity.clockIdentity,
hdr_b->sourcePortIdentity.clockIdentity, hdr_b->sourcePortIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH)) { PP_CLOCK_IDENTITY_LENGTH)) {
/* FIXME PP_PRINTF("Sender=Receiver: Error -2");
* DBG("Sender=Receiver : Error -2");
*/
return 0; return 0;
} else if ((pp_memcmp( } else if ((pp_memcmp(
hdr_a->sourcePortIdentity.clockIdentity, hdr_a->sourcePortIdentity.clockIdentity,
...@@ -285,7 +279,7 @@ UInteger8 bmc_state_decision( struct pp_instance *ppi, ...@@ -285,7 +279,7 @@ UInteger8 bmc_state_decision( struct pp_instance *ppi,
} }
if (cmpres == 0) { if (cmpres == 0) {
PP_PRINTF("Error in bmcDataSetComparison.\n"); PP_PRINTF("Error in bmc_state_decision, cmpres=0.\n");
} }
/* MB: Is this the return code below correct? */ /* MB: Is this the return code below correct? */
......
...@@ -41,8 +41,9 @@ int st_com_execute_slave(struct pp_instance *ppi) ...@@ -41,8 +41,9 @@ int st_com_execute_slave(struct pp_instance *ppi)
void st_com_restart_annrec_timer(struct pp_instance *ppi) void st_com_restart_annrec_timer(struct pp_instance *ppi)
{ {
/* 0 <= logAnnounceInterval <= 4, see pag. 237 of spec */ /* 0 <= logAnnounceInterval <= 4, see pag. 237 of spec */
/* FIXME: if (logAnnounceInterval < 0), error? Or handle a right if (DSPOR(ppi)->logAnnounceInterval < 0)
* shift?*/ PP_PRINTF("Error: logAnnounceInterval < 0");
pp_timer_start((DSPOR(ppi)->announceReceiptTimeout) << pp_timer_start((DSPOR(ppi)->announceReceiptTimeout) <<
DSPOR(ppi)->logAnnounceInterval, DSPOR(ppi)->logAnnounceInterval,
ppi->timers[PP_TIMER_ANN_RECEIPT]); ppi->timers[PP_TIMER_ANN_RECEIPT]);
...@@ -180,7 +181,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -180,7 +181,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
ppi->sync_receive_time.seconds = time->seconds; ppi->sync_receive_time.seconds = time->seconds;
ppi->sync_receive_time.nanoseconds = time->nanoseconds; ppi->sync_receive_time.nanoseconds = time->nanoseconds;
/* FIXME diag check. Delete it? /* FIXME diag to file? will we ever handle it?
if (ppi->rt_opts->recordFP) if (ppi->rt_opts->recordFP)
fprintf(rtOpts->recordFP, "%d %llu\n", fprintf(rtOpts->recordFP, "%d %llu\n",
header->sequenceId, header->sequenceId,
...@@ -204,9 +205,10 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -204,9 +205,10 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
int64_to_TimeInternal( int64_to_TimeInternal(
ppi->msg_tmp_header.correctionfield, ppi->msg_tmp_header.correctionfield,
&correction_field); &correction_field);
/* FIXME diag check
* timeInternal_display(&correctionfield); display_TimeInternal("Correction field",
*/ &correction_field);
ppi->waiting_for_follow = FALSE; ppi->waiting_for_follow = FALSE;
to_TimeInternal(&origin_tstamp, to_TimeInternal(&origin_tstamp,
&ppi->msg_tmp.sync.originTimestamp); &ppi->msg_tmp.sync.originTimestamp);
......
...@@ -4,6 +4,66 @@ ...@@ -4,6 +4,66 @@
*/ */
#include <pptp/pptp.h> #include <pptp/pptp.h>
#include <pptp/diag.h>
static inline void Integer64_display(const char *label, Integer64 *bigint)
{
PP_VPRINTF("%s:\n", label);
PP_VPRINTF("LSB: %u\n", bigint->lsb);
PP_VPRINTF("MSB: %d\n", bigint->msb);
}
static inline void UInteger48_display(const char *label, UInteger48 *bigint)
{
PP_VPRINTF("%s:\n", label);
PP_VPRINTF("LSB: %u\n", bigint->lsb);
PP_VPRINTF("MSB: %u\n", bigint->msb);
}
static inline void timestamp_display(const char *label, Timestamp *timestamp)
{
PP_VPRINTF("%s:\n", label);
UInteger48_display("seconds", &timestamp->secondsField);
PP_VPRINTF("nanoseconds: %u\n", timestamp->nanosecondsField);
}
static inline void msg_display_header(MsgHeader *header)
{
PP_VPRINTF("Message header: \n");
PP_VPRINTF("\n");
PP_VPRINTF("transportSpecific: %d\n", header->transportSpecific);
PP_VPRINTF("messageType: %d\n", header->messageType);
PP_VPRINTF("versionPTP: %d\n", header->versionPTP);
PP_VPRINTF("messageLength: %d\n", header->messageLength);
PP_VPRINTF("domainNumber: %d\n", header->domainNumber);
PP_VPRINTF("FlagField %02hhx:%02hhx\n", header->flagField[0],
header->flagField[1]);
Integer64_display("correctionfield",&header->correctionfield);
/* FIXME diag portIdentity_display(&header->sourcePortIdentity); */
PP_VPRINTF("sequenceId: %d\n", header->sequenceId);
PP_VPRINTF("controlField: %d\n", header->controlField);
PP_VPRINTF("logMessageInterval: %d\n", header->logMessageInterval);
PP_VPRINTF("\n");
}
static inline void msg_display_announce(MsgAnnounce *announce)
{
PP_VPRINTF("Message ANNOUNCE:\n");
timestamp_display("Origin Timestamp", &announce->originTimestamp);
PP_VPRINTF("currentUtcOffset: %d\n", announce->currentUtcOffset);
PP_VPRINTF("grandMasterPriority1: %d\n",
announce->grandmasterPriority1);
PP_VPRINTF("grandMasterClockQuality:\n");
/* FIXME diag clockQuality_display(&announce->grandmasterClockQuality); */
PP_VPRINTF("grandMasterPriority2: %d\n",
announce->grandmasterPriority2);
PP_VPRINTF("grandMasterIdentity:\n");
/* FIXME diag clockIdentity_display(announce->grandmasterIdentity); */
PP_VPRINTF("stepsRemoved: %d\n", announce->stepsRemoved);
PP_VPRINTF("timeSource: %d\n", announce->timeSource);
PP_VPRINTF("\n");
}
/* Unpack header from in buffer to msg_tmp_header field */ /* Unpack header from in buffer to msg_tmp_header field */
void msg_unpack_header(struct pp_instance *ppi, void *buf) void msg_unpack_header(struct pp_instance *ppi, void *buf)
...@@ -50,11 +110,7 @@ void msg_unpack_header(struct pp_instance *ppi, void *buf) ...@@ -50,11 +110,7 @@ void msg_unpack_header(struct pp_instance *ppi, void *buf)
else else
ppi->is_from_cur_par = 0; ppi->is_from_cur_par = 0;
/* FIXME: diag msg_display_header(hdr);
#ifdef PTPD_DBG
msgHeader_display(header);
#endif
*/
} }
/* Pack header message into out buffer of ppi */ /* Pack header message into out buffer of ppi */
...@@ -122,11 +178,9 @@ void msg_unpack_sync(void *buf, MsgSync *sync) ...@@ -122,11 +178,9 @@ void msg_unpack_sync(void *buf, MsgSync *sync)
sync->originTimestamp.nanosecondsField = sync->originTimestamp.nanosecondsField =
htonl(*(UInteger32 *) (buf + 40)); htonl(*(UInteger32 *) (buf + 40));
/* FIXME: diag PP_VPRINTF("Message SYNC\n");
#ifdef PTPD_DBG timestamp_display("Origin Timestamp", &sync->originTimestamp);
msgSync_display(sync); PP_VPRINTF("\n");
#endif
*/
} }
/* Pack Announce message into out buffer of ppi */ /* Pack Announce message into out buffer of ppi */
...@@ -184,11 +238,7 @@ void msg_unpack_announce(void *buf, MsgAnnounce *ann) ...@@ -184,11 +238,7 @@ void msg_unpack_announce(void *buf, MsgAnnounce *ann)
ann->stepsRemoved = htons(*(UInteger16 *) (buf + 61)); ann->stepsRemoved = htons(*(UInteger16 *) (buf + 61));
ann->timeSource = *(Enumeration8 *) (buf + 63); ann->timeSource = *(Enumeration8 *) (buf + 63);
/* FIXME: diag msg_display_announce(ann);
#ifdef PTPD_DBG
msgAnnounce_display(announce);
#endif
*/
} }
...@@ -233,11 +283,10 @@ void msg_unpack_follow_up(void *buf, MsgFollowUp *flwup) ...@@ -233,11 +283,10 @@ void msg_unpack_follow_up(void *buf, MsgFollowUp *flwup)
flwup->preciseOriginTimestamp.nanosecondsField = flwup->preciseOriginTimestamp.nanosecondsField =
htonl(*(UInteger32 *) (buf + 40)); htonl(*(UInteger32 *) (buf + 40));
/* FIXME: diag PP_VPRINTF("Message FOLLOW_UP\n");
#ifdef PTPD_DBG timestamp_display("Precise Origin Timestamp",
msgFollowUp_display(follow); &flwup->preciseOriginTimestamp);
#endif PP_VPRINTF("\n");
*/
} }
/* pack PdelayReq message into out buffer of ppi */ /* pack PdelayReq message into out buffer of ppi */
...@@ -346,8 +395,6 @@ void msg_pack_delay_resp(struct pp_instance *ppi, ...@@ -346,8 +395,6 @@ void msg_pack_delay_resp(struct pp_instance *ppi,
htons(hdr->sourcePortIdentity.portNumber); htons(hdr->sourcePortIdentity.portNumber);
} }
/* Pack PdelayResp message into out buffer of ppi */ /* Pack PdelayResp message into out buffer of ppi */
void msg_pack_pdelay_resp(struct pp_instance *ppi, MsgHeader *hdr, void msg_pack_pdelay_resp(struct pp_instance *ppi, MsgHeader *hdr,
Timestamp *req_rec_tstamp) Timestamp *req_rec_tstamp)
...@@ -383,7 +430,6 @@ void msg_pack_pdelay_resp(struct pp_instance *ppi, MsgHeader *hdr, ...@@ -383,7 +430,6 @@ void msg_pack_pdelay_resp(struct pp_instance *ppi, MsgHeader *hdr,
} }
/* Unpack delayReq message from in buffer of ppi to msgtmp.req */ /* Unpack delayReq message from in buffer of ppi to msgtmp.req */
void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req) void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req)
{ {
...@@ -393,11 +439,11 @@ void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req) ...@@ -393,11 +439,11 @@ void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req)
htonl(*(UInteger32 *) (buf + 36)); htonl(*(UInteger32 *) (buf + 36));
delay_req->originTimestamp.nanosecondsField = delay_req->originTimestamp.nanosecondsField =
htonl(*(UInteger32 *) (buf + 40)); htonl(*(UInteger32 *) (buf + 40));
/* FIXME: diag
#ifdef PTPD_DBG PP_VPRINTF("Message DELAY_REQ\n");
msgDelayReq_display(delayreq); timestamp_display("Origin Timestamp",
#endif &delay_req->originTimestamp);
*/ PP_VPRINTF("\n");
} }
...@@ -411,11 +457,11 @@ void msg_unpack_pdelay_req(void *buf, MsgPDelayReq *pdelay_req) ...@@ -411,11 +457,11 @@ void msg_unpack_pdelay_req(void *buf, MsgPDelayReq *pdelay_req)
htonl(*(UInteger32 *) (buf + 36)); htonl(*(UInteger32 *) (buf + 36));
pdelay_req->originTimestamp.nanosecondsField = pdelay_req->originTimestamp.nanosecondsField =
htonl(*(UInteger32 *) (buf + 40)); htonl(*(UInteger32 *) (buf + 40));
/* FIXME: diag
#ifdef PTPD_DBG PP_VPRINTF("Message PDELAY_REQ\n");
msgPDelayReq_display(pdelayreq); timestamp_display("Origin Timestamp",
#endif &pdelay_req->originTimestamp);
*/ PP_VPRINTF("\n");
} }
/* Unpack delayResp message from IN buffer of ppi to msgtmp.presp */ /* Unpack delayResp message from IN buffer of ppi to msgtmp.presp */
...@@ -432,11 +478,11 @@ void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp) ...@@ -432,11 +478,11 @@ void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp)
resp->requestingPortIdentity.portNumber = resp->requestingPortIdentity.portNumber =
htons(*(UInteger16 *) (buf + 52)); htons(*(UInteger16 *) (buf + 52));
/* FIXME: diag PP_VPRINTF("Message DELAY_RESP\n");
#ifdef PTPD_DBG timestamp_display("Receive Timestamp",
msgDelayResp_display(resp); &resp->receiveTimestamp);
#endif /* FIXME diag display requestingPortIdentity */
*/ PP_VPRINTF("\n");
} }
/* Unpack PdelayResp message from IN buffer of ppi to msgtmp.presp */ /* Unpack PdelayResp message from IN buffer of ppi to msgtmp.presp */
...@@ -453,11 +499,11 @@ void msg_unpack_pdelay_resp(void *buf, MsgPDelayResp *presp) ...@@ -453,11 +499,11 @@ void msg_unpack_pdelay_resp(void *buf, MsgPDelayResp *presp)
presp->requestingPortIdentity.portNumber = presp->requestingPortIdentity.portNumber =
htons(*(UInteger16 *) (buf + 52)); htons(*(UInteger16 *) (buf + 52));
/* FIXME: diag PP_VPRINTF("Message PDELAY_RESP\n");
#ifdef PTPD_DBG timestamp_display("Request Receipt Timestamp",
msgPDelayResp_display(presp); &presp->requestReceiptTimestamp);
#endif /* FIXME diag display requestingPortIdentity */
*/ PP_VPRINTF("\n");
} }
/* Pack PdelayRespFollowUp message into out buffer of ppi */ /* Pack PdelayRespFollowUp message into out buffer of ppi */
...@@ -515,14 +561,21 @@ void msg_unpack_pdelay_resp_followup(void *buf, ...@@ -515,14 +561,21 @@ void msg_unpack_pdelay_resp_followup(void *buf,
(buf + 44), PP_CLOCK_IDENTITY_LENGTH); (buf + 44), PP_CLOCK_IDENTITY_LENGTH);
presp_follow->requestingPortIdentity.portNumber = presp_follow->requestingPortIdentity.portNumber =
htons(*(UInteger16 *) (buf + 52)); htons(*(UInteger16 *) (buf + 52));
PP_VPRINTF("Message PDELAY_RESP_FOLLOW_UP\n");
timestamp_display("Response Origin Timestamp",
&presp_follow->responseOriginTimestamp);
/* FIXME diag display requestingPortIdentity */
PP_VPRINTF("\n");
} }
/* FIXME diag in the following macro */
#define MSG_SEND_AND_RET(x,y)\ #define MSG_SEND_AND_RET(x,y)\
if (pp_send_packet(ppi, ppi->buf_out, PP_## x ##_LENGTH, PP_NP_## y) <\ if (pp_send_packet(ppi, ppi->buf_out, PP_## x ##_LENGTH, PP_NP_## y) <\
PP_## x ##_LENGTH) {\ PP_## x ##_LENGTH) {\
PP_PRINTF("## x ## Message can't be sent -> FAULTY state!");\
return -1;\ return -1;\
}\ }\
PP_VPRINTF("## x ## Message sent");\
ppi->sent_seq_id[PPM_## x]++;\ ppi->sent_seq_id[PPM_## x]++;\
return 0; return 0;
......
...@@ -33,20 +33,16 @@ void pp_update_delay(struct pp_instance *ppi, TimeInternal *correction_field) ...@@ -33,20 +33,16 @@ void pp_update_delay(struct pp_instance *ppi, TimeInternal *correction_field)
if (OPTS(ppi)->max_dly) { /* If max_delay is 0 then it's OFF */ if (OPTS(ppi)->max_dly) { /* If max_delay is 0 then it's OFF */
if (s_to_m_dly.seconds) { if (s_to_m_dly.seconds) {
/*FIXME diag PP_PRINTF("updateDelay aborted, delay greater than 1"
* INFO("updateDelay aborted, delay greater than 1"
" second."); " second.");
*/
return; return;
} }
if (s_to_m_dly.nanoseconds > OPTS(ppi)->max_dly) { if (s_to_m_dly.nanoseconds > OPTS(ppi)->max_dly) {
/*FIXME diag PP_PRINTF("updateDelay aborted, delay %d greater than "
INFO("updateDelay aborted, delay %d greater than "
"administratively set maximum %d\n", "administratively set maximum %d\n",
slave_to_master_delay.nanoseconds, s_to_m_dly.nanoseconds,
rtOpts->maxDelay); OPTS(ppi)->max_dly);
*/
return; return;
} }
} }
...@@ -103,9 +99,8 @@ void pp_update_delay(struct pp_instance *ppi, TimeInternal *correction_field) ...@@ -103,9 +99,8 @@ void pp_update_delay(struct pp_instance *ppi, TimeInternal *correction_field)
owd_fltr->nsec_prev = DSCUR(ppi)->meanPathDelay.nanoseconds; owd_fltr->nsec_prev = DSCUR(ppi)->meanPathDelay.nanoseconds;
DSCUR(ppi)->meanPathDelay.nanoseconds = owd_fltr->y; DSCUR(ppi)->meanPathDelay.nanoseconds = owd_fltr->y;
/*FIXME diag PP_VPRINTF("delay filter %d, %d\n",
* DBGV("delay filter %d, %d\n", owd_filt->y, owd_fltr->s_exp); owd_fltr->y, owd_fltr->s_exp);
*/
} }
} }
...@@ -115,7 +110,7 @@ void pp_update_peer_delay(struct pp_instance *ppi, ...@@ -115,7 +110,7 @@ void pp_update_peer_delay(struct pp_instance *ppi,
Integer16 s; Integer16 s;
struct pp_owd_fltr *owd_fltr = &SRV(ppi)->owd_fltr; struct pp_owd_fltr *owd_fltr = &SRV(ppi)->owd_fltr;
/* FIXME diag DBGV("updateDelay\n");*/ PP_VPRINTF("pp_update_peer_delay\n");
if (two_step) { if (two_step) {
/* calc 'slave_to_master_delay' */ /* calc 'slave_to_master_delay' */
...@@ -181,8 +176,7 @@ void pp_update_peer_delay(struct pp_instance *ppi, ...@@ -181,8 +176,7 @@ void pp_update_peer_delay(struct pp_instance *ppi,
owd_fltr->nsec_prev = DSPOR(ppi)->peerMeanPathDelay.nanoseconds; owd_fltr->nsec_prev = DSPOR(ppi)->peerMeanPathDelay.nanoseconds;
DSPOR(ppi)->peerMeanPathDelay.nanoseconds = owd_fltr->y; DSPOR(ppi)->peerMeanPathDelay.nanoseconds = owd_fltr->y;
/* FIXME diag PP_VPRINTF("delay filter %d, %d\n", owd_fltr->y, owd_fltr->s_exp);
* DBGV("delay filter %d, %d\n", owd_fltr->y, owd_fltr->s_exp);*/
} }
void pp_update_offset(struct pp_instance *ppi, TimeInternal *send_time, void pp_update_offset(struct pp_instance *ppi, TimeInternal *send_time,
...@@ -191,27 +185,23 @@ void pp_update_offset(struct pp_instance *ppi, TimeInternal *send_time, ...@@ -191,27 +185,23 @@ void pp_update_offset(struct pp_instance *ppi, TimeInternal *send_time,
TimeInternal m_to_s_dly; TimeInternal m_to_s_dly;
struct pp_ofm_fltr *ofm_fltr = &SRV(ppi)->ofm_fltr; struct pp_ofm_fltr *ofm_fltr = &SRV(ppi)->ofm_fltr;
/* FIXME diag DBGV("updateOffset\n");*/ PP_VPRINTF("pp_update_offset\n");
/* calc 'master_to_slave_delay' */ /* calc 'master_to_slave_delay' */
sub_TimeInternal(&m_to_s_dly, recv_time, send_time); sub_TimeInternal(&m_to_s_dly, recv_time, send_time);
if (OPTS(ppi)->max_dly) { /* If maxDelay is 0 then it's OFF */ if (OPTS(ppi)->max_dly) { /* If maxDelay is 0 then it's OFF */
if (m_to_s_dly.seconds) { if (m_to_s_dly.seconds) {
/* FIXME diag PP_PRINTF("pp_update_offset aborted, delay greater "
INFO("updateDelay aborted, delay greater than 1" "than 1 second\n");
" second.");
*/
return; return;
} }
if (m_to_s_dly.nanoseconds > OPTS(ppi)->max_dly) { if (m_to_s_dly.nanoseconds > OPTS(ppi)->max_dly) {
/* FIXME diag PP_PRINTF("updateDelay aborted, delay %d greater than "
INFO("updateDelay aborted, delay %d greater than " "administratively set maximum %d\n",
"administratively set maximum %d\n", m_to_s_dly.nanoseconds,
master_to_slave_delay.nanoseconds, OPTS(ppi)->max_dly);
rtOpts->maxDelay);
*/
return; return;
} }
} }
...@@ -248,7 +238,7 @@ void pp_update_offset(struct pp_instance *ppi, TimeInternal *send_time, ...@@ -248,7 +238,7 @@ void pp_update_offset(struct pp_instance *ppi, TimeInternal *send_time,
ofm_fltr->nsec_prev = DSCUR(ppi)->offsetFromMaster.nanoseconds; ofm_fltr->nsec_prev = DSCUR(ppi)->offsetFromMaster.nanoseconds;
DSCUR(ppi)->offsetFromMaster.nanoseconds = ofm_fltr->y; DSCUR(ppi)->offsetFromMaster.nanoseconds = ofm_fltr->y;
/* FIXME diag DBGV("offset filter %d\n", ofm_filt->y); */ PP_VPRINTF("offset filter %d\n", ofm_fltr->y);
/* Offset must have been computed at least one time before /* Offset must have been computed at least one time before
* computing end to end delay */ * computing end to end delay */
...@@ -262,26 +252,22 @@ void pp_update_clock(struct pp_instance *ppi) ...@@ -262,26 +252,22 @@ void pp_update_clock(struct pp_instance *ppi)
TimeInternal time_tmp; TimeInternal time_tmp;
uint32_t tstamp_diff; uint32_t tstamp_diff;
/* FIXME diag DBGV("updateClock\n");*/ PP_VPRINTF("pp_update_clock\n");
if (OPTS(ppi)->max_rst) { /* If max_rst is 0 then it's OFF */ if (OPTS(ppi)->max_rst) { /* If max_rst is 0 then it's OFF */
if (DSCUR(ppi)->offsetFromMaster.seconds) { if (DSCUR(ppi)->offsetFromMaster.seconds) {
/* FIXME diag PP_PRINTF("pp_update_clock aborted, offset greater "
INFO("updateClock aborted, offset greater than 1" "than 1 second.");
" second.");
goto display; goto display;
*/
} }
if (DSCUR(ppi)->offsetFromMaster.nanoseconds > if (DSCUR(ppi)->offsetFromMaster.nanoseconds >
OPTS(ppi)->max_rst) { OPTS(ppi)->max_rst) {
/* FIXME diag PP_PRINTF("updateClock aborted, offset %d greater than "
INFO("updateClock aborted, offset %d greater than "
"administratively set maximum %d\n", "administratively set maximum %d\n",
ptpClock->offsetFromMaster.nanoseconds, DSCUR(ppi)->offsetFromMaster.nanoseconds,
rtOpts->maxReset); OPTS(ppi)->max_rst);
goto display; goto display;
*/
} }
} }
...@@ -329,32 +315,33 @@ void pp_update_clock(struct pp_instance *ppi) ...@@ -329,32 +315,33 @@ void pp_update_clock(struct pp_instance *ppi)
pp_adj_freq(-adj); pp_adj_freq(-adj);
} }
/* FIXME diag
display: display:
/* FIXME diag
if (rtOpts->displayStats) if (rtOpts->displayStats)
displayStats(rtOpts, ptpClock); displayStats(rtOpts, ptpClock);
*/
DBG("\n--Offset Correction-- \n"); PP_PRINTF("\n--Offset Correction-- \n");
DBG("Raw offset from master: %10ds %11dns\n", PP_PRINTF("Raw offset from master: %10ds %11dns\n",
ptpClock->master_to_slave_delay.seconds, SRV(ppi)->m_to_s_dly.seconds,