Skip to content

Commit c5a4469

Browse files
henrikbrixandersenmbolivar-nordic
authored andcommitted
drivers: can: add RX overrun counter statistic
The RX overrun counter is incremented when the CAN controller receives a CAN frame matching an installed filter but lacks the capacity to store it (either due to an already full RX mailbox or a full RX FIFO). Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent 46136b3 commit c5a4469

File tree

1 file changed

+16
-1
lines changed
  • include/zephyr/drivers

1 file changed

+16
-1
lines changed

include/zephyr/drivers/can.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ STATS_SECT_ENTRY32(stuff_error)
461461
STATS_SECT_ENTRY32(crc_error)
462462
STATS_SECT_ENTRY32(form_error)
463463
STATS_SECT_ENTRY32(ack_error)
464+
STATS_SECT_ENTRY32(rx_overrun)
464465
STATS_SECT_END;
465466

466467
STATS_NAME_START(can)
@@ -470,6 +471,7 @@ STATS_NAME(can, stuff_error)
470471
STATS_NAME(can, crc_error)
471472
STATS_NAME(can, form_error)
472473
STATS_NAME(can, ack_error)
474+
STATS_NAME(can, rx_overrun)
473475
STATS_NAME_END(can);
474476

475477
/** @endcond */
@@ -559,6 +561,18 @@ struct can_device_state {
559561
#define CAN_STATS_ACK_ERROR_INC(dev_) \
560562
STATS_INC(Z_CAN_GET_STATS(dev_), ack_error)
561563

564+
/**
565+
* @brief Increment the RX overrun counter for a CAN device
566+
*
567+
* The RX overrun counter is incremented when the CAN controller receives a CAN
568+
* frame matching an installed filter but lacks the capacity to store it (either
569+
* due to an already full RX mailbox or a full RX FIFO).
570+
*
571+
* @param dev_ Pointer to the device structure for the driver instance.
572+
*/
573+
#define CAN_STATS_RX_OVERRUN_INC(dev_) \
574+
STATS_INC(Z_CAN_GET_STATS(dev_), rx_overrun)
575+
562576
/** @cond INTERNAL_HIDDEN */
563577

564578
/**
@@ -579,7 +593,7 @@ struct can_device_state {
579593
{ \
580594
struct can_device_state *state = \
581595
CONTAINER_OF(dev->state, struct can_device_state, devstate); \
582-
stats_init(&state->stats.s_hdr, STATS_SIZE_32, 6, \
596+
stats_init(&state->stats.s_hdr, STATS_SIZE_32, 7, \
583597
STATS_NAME_INIT_PARMS(can)); \
584598
stats_register(dev->name, &(state->stats.s_hdr)); \
585599
return init_fn(dev); \
@@ -626,6 +640,7 @@ struct can_device_state {
626640
#define CAN_STATS_CRC_ERROR_INC(dev_)
627641
#define CAN_STATS_FORM_ERROR_INC(dev_)
628642
#define CAN_STATS_ACK_ERROR_INC(dev_)
643+
#define CAN_STATS_RX_OVERRUN_INC(dev_)
629644

630645
#define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
631646
prio, api, ...) \

0 commit comments

Comments
 (0)