src.dualinventive.com/dinet/sec-multi-proxy/libdi/include/di/can/stat.h

62 lines
2.3 KiB
C

/**
* @ingroup can
* @defgroup can_stat CAN stack statistics
* @brief Statistics
* @date Jan 14, 2016
* @author jjacobs
* @copyright 2016 Dual Inventive Technology Centre B.V.
*
* CAN stack statistics
* @{
*/
#ifndef LIBDI_INCLUDE_DI_CAN_STAT_H_
#define LIBDI_INCLUDE_DI_CAN_STAT_H_
#if defined(DI_CAN_CFG_DBG_STAT) || defined(__DOXYGEN__)
#define di_can_stat_lowlevel_rx(ctx, bytes) (ctx)->stat.lowlevel.rx += bytes /**< Increment receive bytes count */
#define di_can_stat_lowlevel_tx(ctx, bytes) (ctx)->stat.lowlevel.tx += bytes /**< Increment transmit bytes count */
#define di_can_stat_frame_rx(ctx) (ctx)->stat.frame.rx++ /**< Increment receive frame count */
#define di_can_stat_frame_tx(ctx) (ctx)->stat.frame.tx++ /**< Increment transmit frame count */
#define di_can_stat_msg_rx(ctx) (ctx)->stat.msg.rx++ /**< Increment receive msg count */
#define di_can_stat_msg_tx(ctx) (ctx)->stat.msg.tx++ /**< Increment transmit msg count */
#define di_can_stat_gc_runs(ctx) (ctx)->stat.gc.runs++ /**< Garbage collection run count */
#define di_can_stat_frame_drop(ctx) (ctx)->stat.frame.drop++ /**< di_can_frame_rx drop count */
#define di_can_stat_msg_drop(ctx) (ctx)->stat.msg.drop++ /**< di_can_msg drop count */
#else
#define di_can_stat_lowlevel_rx(ctx, bytes)
#define di_can_stat_lowlevel_tx(ctx, bytes)
#define di_can_stat_frame_rx(ctx)
#define di_can_stat_frame_tx(ctx)
#define di_can_stat_msg_rx(ctx)
#define di_can_stat_msg_tx(ctx)
#define di_can_stat_gc_runs(ctx)
#define di_can_stat_frame_drop(ctx)
#define di_can_stat_msg_drop(ctx)
#endif
struct di_can_stat {
struct {
uint32_t rx; /**< Received bytes */
uint32_t tx; /**< Transmitted bytes */
} lowlevel;
struct {
uint32_t rx; /**< Received frames */
uint32_t tx; /**< Transmitted frames */
uint32_t drop; /**< RX frames dropped by GC */
} frame;
struct {
uint32_t rx; /**< Received messages */
uint32_t tx; /**< Transmitted messages */
uint32_t drop; /**< RX Messages dropped due to invalid crc */
} msg;
struct {
uint32_t runs; /**< Garbage collect runs */
uint32_t ready; /**< Ready messages collected */
uint32_t dirty; /**< Dirty messages collected */
} gc;
};
/** @} */
#endif /* LIBDI_INCLUDE_DI_CAN_STAT_H_ */