Commit 623dcf31 authored by Adam Wujek's avatar Adam Wujek

pp-instance: add tx and rx packet counters

Add counting of tx and rx PTP packets.
__recv_and_count and __send_and_log are arch independent functions.
Increase WRS_PPSI_SHMEM_VERSION due to add of tx_count and tx_count firlds in
pp_instance.
Update WRS_PPSI_SHMEM_VERSION to 5
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 34c57cba
......@@ -11,7 +11,7 @@ CFLAGS += -U_FORTIFY_SOURCE
A := arch-$(ARCH)
L := lib-bare
CFLAGS += -Ilib-bare
CFLAGS += -Ilib-bare -Iproto-standard
OBJ-y += $A/crt0.o \
$L/bare-startup.o \
......
......@@ -11,7 +11,7 @@ CFLAGS += -U_FORTIFY_SOURCE
A := arch-$(ARCH)
L := lib-bare
CFLAGS += -Ilib-bare
CFLAGS += -Ilib-bare -Iproto-standard
OBJ-y += $A/crt0.o \
$L/bare-startup.o \
......
......@@ -2,7 +2,7 @@
# All files are under A (short for ARCH): I'm lazy
A := arch-$(ARCH)
CFLAGS += -Itools
CFLAGS += -Itools -Iproto-standard
OBJ-y += $A/sim-startup.o \
$A/main-loop.o \
......
......@@ -14,6 +14,7 @@
#include <linux/if_ether.h>
#include <ppsi/ppsi.h>
#include <common-fun.h>
#include "ppsi-sim.h"
/* Call pp_state_machine for each instance. To be called periodically,
......@@ -79,7 +80,7 @@ void sim_main_loop(struct pp_globals *ppg)
sim_fast_forward_ns(ppg, 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,
&ppi->last_rcv_time);
......
......@@ -24,7 +24,7 @@ include time-$(TIME)/Makefile
ifneq ($(TIME),unix)
include time-unix/Makefile
endif
CFLAGS += -Itime-unix
CFLAGS += -Itime-unix -Iproto-standard
all: $(TARGET)
......
......@@ -14,6 +14,7 @@
#include <linux/if_ether.h>
#include <ppsi/ppsi.h>
#include <common-fun.h>
#include "ppsi-unix.h"
/* Call pp_state_machine for each instance. To be called periodically,
......@@ -109,7 +110,7 @@ void unix_main_loop(struct pp_globals *ppg)
if ((NP(ppi)->ch[PP_NP_GEN].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,
&ppi->last_rcv_time);
......
......@@ -2,7 +2,7 @@
CFLAGS += -ffreestanding -Os \
-ffunction-sections -fdata-sections \
-mmultiply-enabled -mbarrel-shift-enabled \
-Itools
-Itools -Iproto-standard
# Root of wrpc-sw project
WRPCSW_ROOT ?= $(CONFIG_WRPCSW_ROOT)
......
......@@ -10,6 +10,7 @@
#include <errno.h>
#include <ppsi/ppsi.h>
#include "wrpc.h"
#include <common-fun.h>
#include "../proto-ext-whiterabbit/wr-api.h"
#include "../proto-ext-whiterabbit/wr-constants.h"
......@@ -243,7 +244,7 @@ int wrc_ptp_update()
if (!ptp_enabled)
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);
if ((!i) && (timer_get_tics() - start_tics < delay_ms))
......
......@@ -26,7 +26,7 @@ include time-$(TIME)/Makefile
# Unix time operations are always included as a fallback
include time-unix/Makefile
CFLAGS += -Iproto-ext-whiterabbit
CFLAGS += -Iproto-ext-whiterabbit -Iproto-standard
# mini-rpc directory contains minipc library
export CROSS_COMPILE
......
......@@ -18,6 +18,7 @@
#include <ppsi-wrs.h>
#include <wr-api.h>
#include <hal_exports.h>
#include <common-fun.h>
/* Call pp_state_machine for each instance. To be called periodically,
* when no packets are incoming */
......@@ -151,7 +152,7 @@ void wrs_main_loop(struct pp_globals *ppg)
if ((NP(ppi)->ch[PP_NP_GEN].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,
&ppi->last_rcv_time);
......
......@@ -187,6 +187,9 @@ struct pp_instance {
int port_idx;
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 */
#define PPI_FLAG_FROM_CURRENT_PARENT 0x01
......
......@@ -10,6 +10,7 @@
*/
#include <ppsi/ppsi.h>
#include "bare-linux.h"
#include <common-fun.h>
/* Define other hackish stuff */
struct bare_fd_set {
......@@ -66,7 +67,7 @@ void bare_main_loop(struct pp_instance *ppi)
*
* 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,
&ppi->last_rcv_time);
......
......@@ -12,7 +12,8 @@
#include <ppsi/lib.h>
#include "wr-constants.h"
#define WRS_PPSI_SHMEM_VERSION 4 /* several changes to wr_servo_state */
#define WRS_PPSI_SHMEM_VERSION 5 /* added fields tx_count and rx_count to
* pp_instance */
/*
* This structure is used as extension-specific data in the DSPort
......
......@@ -51,7 +51,22 @@ static inline int __send_and_log(struct pp_instance *ppi, int msglen,
pp_msg_names[msgtype]);
if (chtype == PP_NP_EVT && ppi->last_snt_time.correct == 0)
return PP_SEND_NO_STAMP;
/* count sent packets */
ppi->ptp_tx_count++;
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 */
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