Commit a7f53cf9 authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch 'adam-proposed_master'

--update hal_shmem to version 7
--add tx and rx packet counters
--add error counters for SNMP
--increase ppsi shmem version to 6
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents 78277307 74a79aab
...@@ -11,7 +11,7 @@ CFLAGS += -U_FORTIFY_SOURCE ...@@ -11,7 +11,7 @@ CFLAGS += -U_FORTIFY_SOURCE
A := arch-$(ARCH) A := arch-$(ARCH)
L := lib-bare L := lib-bare
CFLAGS += -Ilib-bare CFLAGS += -Ilib-bare -Iproto-standard
OBJ-y += $A/crt0.o \ OBJ-y += $A/crt0.o \
$L/bare-startup.o \ $L/bare-startup.o \
......
...@@ -11,7 +11,7 @@ CFLAGS += -U_FORTIFY_SOURCE ...@@ -11,7 +11,7 @@ CFLAGS += -U_FORTIFY_SOURCE
A := arch-$(ARCH) A := arch-$(ARCH)
L := lib-bare L := lib-bare
CFLAGS += -Ilib-bare CFLAGS += -Ilib-bare -Iproto-standard
OBJ-y += $A/crt0.o \ OBJ-y += $A/crt0.o \
$L/bare-startup.o \ $L/bare-startup.o \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# All files are under A (short for ARCH): I'm lazy # All files are under A (short for ARCH): I'm lazy
A := arch-$(ARCH) A := arch-$(ARCH)
CFLAGS += -Itools CFLAGS += -Itools -Iproto-standard
OBJ-y += $A/sim-startup.o \ OBJ-y += $A/sim-startup.o \
$A/main-loop.o \ $A/main-loop.o \
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <common-fun.h>
#include "ppsi-sim.h" #include "ppsi-sim.h"
/* Call pp_state_machine for each instance. To be called periodically, /* Call pp_state_machine for each instance. To be called periodically,
...@@ -79,7 +80,7 @@ void sim_main_loop(struct pp_globals *ppg) ...@@ -79,7 +80,7 @@ void sim_main_loop(struct pp_globals *ppg)
sim_fast_forward_ns(ppg, data->pending->delay_ns); sim_fast_forward_ns(ppg, data->pending->delay_ns);
delay_ns -= data->pending->delay_ns; delay_ns -= data->pending->delay_ns;
i = ppi->n_ops->recv(ppi, ppi->rx_frame, i = __recv_and_count(ppi, ppi->rx_frame,
PP_MAX_FRAME_LENGTH - 4, PP_MAX_FRAME_LENGTH - 4,
&ppi->last_rcv_time); &ppi->last_rcv_time);
......
...@@ -24,7 +24,7 @@ include time-$(TIME)/Makefile ...@@ -24,7 +24,7 @@ include time-$(TIME)/Makefile
ifneq ($(TIME),unix) ifneq ($(TIME),unix)
include time-unix/Makefile include time-unix/Makefile
endif endif
CFLAGS += -Itime-unix CFLAGS += -Itime-unix -Iproto-standard
all: $(TARGET) all: $(TARGET)
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <common-fun.h>
#include "ppsi-unix.h" #include "ppsi-unix.h"
/* Call pp_state_machine for each instance. To be called periodically, /* Call pp_state_machine for each instance. To be called periodically,
...@@ -109,7 +110,7 @@ void unix_main_loop(struct pp_globals *ppg) ...@@ -109,7 +110,7 @@ void unix_main_loop(struct pp_globals *ppg)
if ((NP(ppi)->ch[PP_NP_GEN].pkt_present) || if ((NP(ppi)->ch[PP_NP_GEN].pkt_present) ||
(NP(ppi)->ch[PP_NP_EVT].pkt_present)) { (NP(ppi)->ch[PP_NP_EVT].pkt_present)) {
i = ppi->n_ops->recv(ppi, ppi->rx_frame, i = __recv_and_count(ppi, ppi->rx_frame,
PP_MAX_FRAME_LENGTH - 4, PP_MAX_FRAME_LENGTH - 4,
&ppi->last_rcv_time); &ppi->last_rcv_time);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
CFLAGS += -ffreestanding -Os \ CFLAGS += -ffreestanding -Os \
-ffunction-sections -fdata-sections \ -ffunction-sections -fdata-sections \
-mmultiply-enabled -mbarrel-shift-enabled \ -mmultiply-enabled -mbarrel-shift-enabled \
-Itools -Itools -Iproto-standard
# Root of wrpc-sw project # Root of wrpc-sw project
WRPCSW_ROOT ?= $(CONFIG_WRPCSW_ROOT) WRPCSW_ROOT ?= $(CONFIG_WRPCSW_ROOT)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <errno.h> #include <errno.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "wrpc.h" #include "wrpc.h"
#include <common-fun.h>
#include "../proto-ext-whiterabbit/wr-api.h" #include "../proto-ext-whiterabbit/wr-api.h"
#include "../proto-ext-whiterabbit/wr-constants.h" #include "../proto-ext-whiterabbit/wr-constants.h"
...@@ -243,7 +244,7 @@ int wrc_ptp_update() ...@@ -243,7 +244,7 @@ int wrc_ptp_update()
if (!ptp_enabled) if (!ptp_enabled)
return 0; return 0;
i = ppi->n_ops->recv(ppi, ppi->rx_frame, PP_MAX_FRAME_LENGTH - 4, i = __recv_and_count(ppi, ppi->rx_frame, PP_MAX_FRAME_LENGTH - 4,
&ppi->last_rcv_time); &ppi->last_rcv_time);
if ((!i) && (timer_get_tics() - start_tics < delay_ms)) if ((!i) && (timer_get_tics() - start_tics < delay_ms))
......
...@@ -26,7 +26,7 @@ include time-$(TIME)/Makefile ...@@ -26,7 +26,7 @@ include time-$(TIME)/Makefile
# Unix time operations are always included as a fallback # Unix time operations are always included as a fallback
include time-unix/Makefile include time-unix/Makefile
CFLAGS += -Iproto-ext-whiterabbit CFLAGS += -Iproto-ext-whiterabbit -Iproto-standard
# mini-rpc directory contains minipc library # mini-rpc directory contains minipc library
export CROSS_COMPILE export CROSS_COMPILE
......
...@@ -107,15 +107,11 @@ struct hal_temp_sensors { ...@@ -107,15 +107,11 @@ struct hal_temp_sensors {
int pll; /* IC18 */ int pll; /* IC18 */
int psl; /* IC20 Power Supply Left (PSL) */ int psl; /* IC20 Power Supply Left (PSL) */
int psr; /* IC17 Power Supply Right (PSR) */ int psr; /* IC17 Power Supply Right (PSR) */
int fpga_thold; /* Threshold value for FPGA temperature */
int pll_thold; /* Threshold value for PLL temperature */
int psl_thold; /* Threshold value for PSL temperature */
int psr_thold; /* Threshold value for PSR temperature */
}; };
/* This is the overall structure stored in shared memory */ /* This is the overall structure stored in shared memory */
#define HAL_SHMEM_VERSION 6 /* Version 6 because of new structure #define HAL_SHMEM_VERSION 7 /* Version 7 because of moving of reading
* hal_temp_sensors in hal_shmem_header */ * temperature treshold values to snmpd */
struct hal_shmem_header { struct hal_shmem_header {
int nports; int nports;
struct hal_port_state *ports; struct hal_port_state *ports;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <ppsi-wrs.h> #include <ppsi-wrs.h>
#include <wr-api.h> #include <wr-api.h>
#include <hal_exports.h> #include <hal_exports.h>
#include <common-fun.h>
/* Call pp_state_machine for each instance. To be called periodically, /* Call pp_state_machine for each instance. To be called periodically,
* when no packets are incoming */ * when no packets are incoming */
...@@ -151,7 +152,7 @@ void wrs_main_loop(struct pp_globals *ppg) ...@@ -151,7 +152,7 @@ void wrs_main_loop(struct pp_globals *ppg)
if ((NP(ppi)->ch[PP_NP_GEN].pkt_present) || if ((NP(ppi)->ch[PP_NP_GEN].pkt_present) ||
(NP(ppi)->ch[PP_NP_EVT].pkt_present)) { (NP(ppi)->ch[PP_NP_EVT].pkt_present)) {
i = ppi->n_ops->recv(ppi, ppi->rx_frame, i = __recv_and_count(ppi, ppi->rx_frame,
PP_MAX_FRAME_LENGTH - 4, PP_MAX_FRAME_LENGTH - 4,
&ppi->last_rcv_time); &ppi->last_rcv_time);
......
...@@ -187,6 +187,9 @@ struct pp_instance { ...@@ -187,6 +187,9 @@ struct pp_instance {
int port_idx; int port_idx;
struct pp_instance_cfg cfg; struct pp_instance_cfg cfg;
unsigned long ptp_tx_count;
unsigned long ptp_rx_count;
}; };
/* The following things used to be bit fields. Other flags are now enums */ /* The following things used to be bit fields. Other flags are now enums */
#define PPI_FLAG_FROM_CURRENT_PARENT 0x01 #define PPI_FLAG_FROM_CURRENT_PARENT 0x01
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
*/ */
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "bare-linux.h" #include "bare-linux.h"
#include <common-fun.h>
/* Define other hackish stuff */ /* Define other hackish stuff */
struct bare_fd_set { struct bare_fd_set {
...@@ -66,7 +67,7 @@ void bare_main_loop(struct pp_instance *ppi) ...@@ -66,7 +67,7 @@ void bare_main_loop(struct pp_instance *ppi)
* *
* FIXME: we don't know which socket to receive from * FIXME: we don't know which socket to receive from
*/ */
i = ppi->n_ops->recv(ppi, ppi->rx_frame, i = __recv_and_count(ppi, ppi->rx_frame,
PP_MAX_FRAME_LENGTH - 4, PP_MAX_FRAME_LENGTH - 4,
&ppi->last_rcv_time); &ppi->last_rcv_time);
......
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
#include <ppsi/lib.h> #include <ppsi/lib.h>
#include "wr-constants.h" #include "wr-constants.h"
#define WRS_PPSI_SHMEM_VERSION 4 /* several changes to wr_servo_state */ #define WRS_PPSI_SHMEM_VERSION 6 /* added fields n_err_state, n_err_offset,
* n_err_rtt, n_err_deltas to
* wr_servo_state_t */
/* /*
* This structure is used as extension-specific data in the DSPort * This structure is used as extension-specific data in the DSPort
...@@ -163,6 +165,13 @@ struct wr_servo_state { ...@@ -163,6 +165,13 @@ struct wr_servo_state {
char servo_state_name[32]; char servo_state_name[32];
int64_t skew; int64_t skew;
int64_t offset; int64_t offset;
/* Values used by snmp. Values are increased at servo update when
* erroneous condition occurs. */
uint32_t n_err_state;
uint32_t n_err_offset;
uint32_t n_err_delta_rtt;
uint32_t n_err_rxtx_deltas;
}; };
/* All data used as extension ppsi-wr must be put here */ /* All data used as extension ppsi-wr must be put here */
......
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
#define FIX_ALPHA_FRACBITS 40 #define FIX_ALPHA_FRACBITS 40
/* Define threshold values for SNMP */
/* TODO: These values need to be tuned! */
#define SNMP_MAX_OFFSET 1000000
#define SNMP_MAX_DELTA_RTT 1000000
#define SNMP_MAX_RXTX_DELTAS 1000000
static const char *servo_name[] = { static const char *servo_name[] = {
[WR_SERVO_NONE] = "Uninitialized", [WR_SERVO_NONE] = "Uninitialized",
[WR_SYNC_NSEC] = "SYNC_NSEC", [WR_SYNC_NSEC] = "SYNC_NSEC",
...@@ -238,7 +244,7 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -238,7 +244,7 @@ int wr_servo_update(struct pp_instance *ppi)
uint64_t delay_ms_fix; uint64_t delay_ms_fix;
static int errcount; static int errcount;
int remaining_offset; int remaining_offset;
int64_t picos_mu_prev = 0;
TimeInternal ts_offset, ts_offset_hw /*, ts_phase_adjust */; TimeInternal ts_offset, ts_offset_hw /*, ts_phase_adjust */;
if(!got_sync) if(!got_sync)
...@@ -272,7 +278,7 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -272,7 +278,7 @@ int wr_servo_update(struct pp_instance *ppi)
dump_timestamp(ppi, "servo:t4", s->t4); dump_timestamp(ppi, "servo:t4", s->t4);
dump_timestamp(ppi, "->mdelay", s->mu); dump_timestamp(ppi, "->mdelay", s->mu);
} }
picos_mu_prev = s->picos_mu;
s->picos_mu = ts_to_picos(s->mu); s->picos_mu = ts_to_picos(s->mu);
big_delta_fix = s->delta_tx_m + s->delta_tx_s big_delta_fix = s->delta_tx_m + s->delta_tx_s
+ s->delta_rx_m + s->delta_rx_s; + s->delta_rx_m + s->delta_rx_s;
...@@ -403,6 +409,29 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -403,6 +409,29 @@ int wr_servo_update(struct pp_instance *ppi)
/* update string state name */ /* update string state name */
strcpy(s->servo_state_name, servo_name[s->state]); strcpy(s->servo_state_name, servo_name[s->state]);
/* Increase number of servo updates with state different than
* WR_TRACK_PHASE. (Used by SNMP) */
if (s->state != WR_TRACK_PHASE)
s->n_err_state++;
/* Increase number of servo updates with offset exceeded
* SNMP_MAX_OFFSET (Used by SNMP) */
if (s->offset > SNMP_MAX_OFFSET)
s->n_err_offset++;
/* Increase number of servo updates with delta rtt exceeded
* SNMP_MAX_DELTA_RTT (Used by SNMP) */
if (picos_mu_prev - s->picos_mu > SNMP_MAX_DELTA_RTT)
s->n_err_delta_rtt++;
/* Increase number of servo updates with delta_*x_* bigger than
* SNMP_MAX_RXTX_DELTAS. (Used by SNMP) */
if ((s->delta_tx_m > SNMP_MAX_RXTX_DELTAS)
|| (s->delta_rx_m > SNMP_MAX_RXTX_DELTAS)
|| (s->delta_tx_s > SNMP_MAX_RXTX_DELTAS)
|| (s->delta_rx_s > SNMP_MAX_RXTX_DELTAS))
s->n_err_rxtx_deltas++;
out: out:
/* shmem unlock */ /* shmem unlock */
wrs_shm_write(ppsi_head, WRS_SHM_WRITE_END); wrs_shm_write(ppsi_head, WRS_SHM_WRITE_END);
......
...@@ -51,7 +51,22 @@ static inline int __send_and_log(struct pp_instance *ppi, int msglen, ...@@ -51,7 +51,22 @@ static inline int __send_and_log(struct pp_instance *ppi, int msglen,
pp_msg_names[msgtype]); pp_msg_names[msgtype]);
if (chtype == PP_NP_EVT && ppi->last_snt_time.correct == 0) if (chtype == PP_NP_EVT && ppi->last_snt_time.correct == 0)
return PP_SEND_NO_STAMP; return PP_SEND_NO_STAMP;
/* count sent packets */
ppi->ptp_tx_count++;
return 0; return 0;
} }
/* Count successfully received PTP packets */
static inline int __recv_and_count(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t)
{
int ret;
ret = ppi->n_ops->recv(ppi, pkt, len, t);
if (ret >= 0)
ppi->ptp_rx_count++;
return ret;
}
#endif /* __COMMON_FUN_H */ #endif /* __COMMON_FUN_H */
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