RTEMS 7.0-rc1
Loading...
Searching...
No Matches
can-stats.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0 OR GPL-2.0-or-later */
2
15/*
16 * Copyright (C) 2023-2024 Michal Lenc <michallenc@seznam.cz>
17 * Copyright (C) 2002-2009 DCE FEE CTU Prague
18 * Copyright (C) 2002-2024 Pavel Pisa <pisa@cmp.felk.cvut.cz>
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
33 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#ifndef _DEV_CAN_CAN_STATS_H
43#define _DEV_CAN_CAN_STATS_H
44
85};
86
94 unsigned long tx_done;
98 unsigned long rx_done;
102 unsigned long tx_bytes;
106 unsigned long rx_bytes;
110 unsigned long tx_error;
114 unsigned long rx_error;
118 unsigned long rx_overflows;
124};
125
126static inline void rtems_can_stats_add_tx_done(
127 struct rtems_can_stats *stats
128)
129{
130 stats->tx_done += 1;
131}
132
133static inline void rtems_can_stats_add_rx_done(
134 struct rtems_can_stats *stats
135)
136{
137 stats->rx_done += 1;
138}
139
140static inline void rtems_can_stats_add_tx_bytes(
141 struct rtems_can_stats *stats,
142 uint16_t nbytes
143)
144{
145 stats->tx_bytes += nbytes;
146}
147
148static inline void rtems_can_stats_add_rx_bytes(
149 struct rtems_can_stats *stats,
150 uint16_t nbytes
151)
152{
153 stats->rx_bytes += nbytes;
154}
155
156static inline void rtems_can_stats_add_tx_error(
157 struct rtems_can_stats *stats
158)
159{
160 stats->tx_error += 1;
161}
162
163static inline void rtems_can_stats_add_rx_error(
164 struct rtems_can_stats *stats
165)
166{
167 stats->rx_error += 1;
168}
169
170static inline void rtems_can_stats_add_rx_overflows(
171 struct rtems_can_stats *stats
172)
173{
174 stats->rx_overflows += 1;
175}
176
177static inline void rtems_can_stats_set_state(
178 struct rtems_can_stats *stats,
179 enum can_state state
180)
181{
182 stats->chip_state = state;
183}
184
193void rtems_can_stats_reset( struct rtems_can_stats *stats );
194
195#endif /* _DEV_CAN_CAN_STATS_H */
void rtems_can_stats_reset(struct rtems_can_stats *stats)
This function resets the controller's statistics.
Definition: can-devcommon.c:80
can_state
This enum represents the current state of CAN controller.
Definition: can-stats.h:48
@ CAN_STATE_ERROR_ACTIVE
This member indicates the controller is in error active state ( RX/TX error count < 96)
Definition: can-stats.h:53
@ CAN_STATE_ERROR_WARNING
This member indicates the controller is in error warning state ( RX/TX error count < 128)
Definition: can-stats.h:58
@ CAN_STATE_STOPPING
This member indicates the the controller is in stopping process.
Definition: can-stats.h:80
@ CAN_STATE_SLEEPING
This member indicates the the controller is in sleep.
Definition: can-stats.h:76
@ CAN_STATE_STOPPED
This member indicates the the controller is stopped.
Definition: can-stats.h:72
@ CAN_STATE_BUS_OFF
This member indicates the controller is in bus off state ( RX/TX error count >= 256)
Definition: can-stats.h:68
@ CAN_STATE_MAX
This member holds the maximum number of controller's states.
Definition: can-stats.h:84
@ CAN_STATE_ERROR_PASSIVE
This member indicates the controller is in error passive state ( RX/TX error count < 256)
Definition: can-stats.h:63
This structure is used to represent CAN statistics.
Definition: can-stats.h:90
unsigned long rx_overflows
This member holds number of overflows on RX side.
Definition: can-stats.h:118
unsigned long tx_error
This member holds number of TX errors.
Definition: can-stats.h:110
unsigned long rx_error
This member holds number of RX errors.
Definition: can-stats.h:114
unsigned long tx_bytes
This member holds number of bytes succesfully send.
Definition: can-stats.h:102
unsigned long rx_done
This member holds number of succesful RX frames.
Definition: can-stats.h:98
unsigned long tx_done
This member holds number of succesful TX frames.
Definition: can-stats.h:94
unsigned long rx_bytes
This member holds number of bytes succesfully received.
Definition: can-stats.h:106
int chip_state
This member holds controller's state (error active, passive, bus off)
Definition: can-stats.h:123