xref: /linux-6.15/include/uapi/linux/can/error.h (revision 3f9c2621)
13926a3a0SYegor Yefremov /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
2922cd657SDavid Howells /*
3922cd657SDavid Howells  * linux/can/error.h
4922cd657SDavid Howells  *
5922cd657SDavid Howells  * Definitions of the CAN error messages to be filtered and passed to the user.
6922cd657SDavid Howells  *
7922cd657SDavid Howells  * Author: Oliver Hartkopp <[email protected]>
8922cd657SDavid Howells  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
9922cd657SDavid Howells  * All rights reserved.
10922cd657SDavid Howells  *
112485602fSUwe Kleine-König  * Redistribution and use in source and binary forms, with or without
122485602fSUwe Kleine-König  * modification, are permitted provided that the following conditions
132485602fSUwe Kleine-König  * are met:
142485602fSUwe Kleine-König  * 1. Redistributions of source code must retain the above copyright
152485602fSUwe Kleine-König  *    notice, this list of conditions and the following disclaimer.
162485602fSUwe Kleine-König  * 2. Redistributions in binary form must reproduce the above copyright
172485602fSUwe Kleine-König  *    notice, this list of conditions and the following disclaimer in the
182485602fSUwe Kleine-König  *    documentation and/or other materials provided with the distribution.
192485602fSUwe Kleine-König  * 3. Neither the name of Volkswagen nor the names of its contributors
202485602fSUwe Kleine-König  *    may be used to endorse or promote products derived from this software
212485602fSUwe Kleine-König  *    without specific prior written permission.
222485602fSUwe Kleine-König  *
232485602fSUwe Kleine-König  * Alternatively, provided that this notice is retained in full, this
242485602fSUwe Kleine-König  * software may be distributed under the terms of the GNU General
252485602fSUwe Kleine-König  * Public License ("GPL") version 2, in which case the provisions of the
262485602fSUwe Kleine-König  * GPL apply INSTEAD OF those given above.
272485602fSUwe Kleine-König  *
282485602fSUwe Kleine-König  * The provided data structures and external interfaces from this code
292485602fSUwe Kleine-König  * are not restricted to be used by modules with a GPL compatible license.
302485602fSUwe Kleine-König  *
312485602fSUwe Kleine-König  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
322485602fSUwe Kleine-König  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
332485602fSUwe Kleine-König  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
342485602fSUwe Kleine-König  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
352485602fSUwe Kleine-König  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
362485602fSUwe Kleine-König  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
372485602fSUwe Kleine-König  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
382485602fSUwe Kleine-König  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
392485602fSUwe Kleine-König  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
402485602fSUwe Kleine-König  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
412485602fSUwe Kleine-König  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
422485602fSUwe Kleine-König  * DAMAGE.
43922cd657SDavid Howells  */
44922cd657SDavid Howells 
4542193e3eSOliver Hartkopp #ifndef _UAPI_CAN_ERROR_H
4642193e3eSOliver Hartkopp #define _UAPI_CAN_ERROR_H
47922cd657SDavid Howells 
48922cd657SDavid Howells #define CAN_ERR_DLC 8 /* dlc for error message frames */
49922cd657SDavid Howells 
50922cd657SDavid Howells /* error class (mask) in can_id */
51922cd657SDavid Howells #define CAN_ERR_TX_TIMEOUT   0x00000001U /* TX timeout (by netdevice driver) */
52922cd657SDavid Howells #define CAN_ERR_LOSTARB      0x00000002U /* lost arbitration    / data[0]    */
53922cd657SDavid Howells #define CAN_ERR_CRTL         0x00000004U /* controller problems / data[1]    */
54922cd657SDavid Howells #define CAN_ERR_PROT         0x00000008U /* protocol violations / data[2..3] */
55922cd657SDavid Howells #define CAN_ERR_TRX          0x00000010U /* transceiver status  / data[4]    */
56922cd657SDavid Howells #define CAN_ERR_ACK          0x00000020U /* received no ACK on transmission */
57922cd657SDavid Howells #define CAN_ERR_BUSOFF       0x00000040U /* bus off */
58922cd657SDavid Howells #define CAN_ERR_BUSERROR     0x00000080U /* bus error (may flood!) */
59922cd657SDavid Howells #define CAN_ERR_RESTARTED    0x00000100U /* controller restarted */
603e5c291cSVincent Mailhol #define CAN_ERR_CNT          0x00000200U /* TX error counter / data[6] */
613e5c291cSVincent Mailhol 					 /* RX error counter / data[7] */
62922cd657SDavid Howells 
63922cd657SDavid Howells /* arbitration lost in bit ... / data[0] */
64922cd657SDavid Howells #define CAN_ERR_LOSTARB_UNSPEC   0x00 /* unspecified */
65922cd657SDavid Howells 				      /* else bit number in bitstream */
66922cd657SDavid Howells 
67922cd657SDavid Howells /* error status of CAN-controller / data[1] */
68922cd657SDavid Howells #define CAN_ERR_CRTL_UNSPEC      0x00 /* unspecified */
69922cd657SDavid Howells #define CAN_ERR_CRTL_RX_OVERFLOW 0x01 /* RX buffer overflow */
70922cd657SDavid Howells #define CAN_ERR_CRTL_TX_OVERFLOW 0x02 /* TX buffer overflow */
71922cd657SDavid Howells #define CAN_ERR_CRTL_RX_WARNING  0x04 /* reached warning level for RX errors */
72922cd657SDavid Howells #define CAN_ERR_CRTL_TX_WARNING  0x08 /* reached warning level for TX errors */
73922cd657SDavid Howells #define CAN_ERR_CRTL_RX_PASSIVE  0x10 /* reached error passive status RX */
74922cd657SDavid Howells #define CAN_ERR_CRTL_TX_PASSIVE  0x20 /* reached error passive status TX */
75922cd657SDavid Howells 				      /* (at least one error counter exceeds */
76922cd657SDavid Howells 				      /* the protocol-defined level of 127)  */
77bac78aabSAndri Yngvason #define CAN_ERR_CRTL_ACTIVE      0x40 /* recovered to error active state */
78922cd657SDavid Howells 
79922cd657SDavid Howells /* error in CAN protocol (type) / data[2] */
80922cd657SDavid Howells #define CAN_ERR_PROT_UNSPEC      0x00 /* unspecified */
81922cd657SDavid Howells #define CAN_ERR_PROT_BIT         0x01 /* single bit error */
82922cd657SDavid Howells #define CAN_ERR_PROT_FORM        0x02 /* frame format error */
83922cd657SDavid Howells #define CAN_ERR_PROT_STUFF       0x04 /* bit stuffing error */
84922cd657SDavid Howells #define CAN_ERR_PROT_BIT0        0x08 /* unable to send dominant bit */
85922cd657SDavid Howells #define CAN_ERR_PROT_BIT1        0x10 /* unable to send recessive bit */
86922cd657SDavid Howells #define CAN_ERR_PROT_OVERLOAD    0x20 /* bus overload */
87922cd657SDavid Howells #define CAN_ERR_PROT_ACTIVE      0x40 /* active error announcement */
88922cd657SDavid Howells #define CAN_ERR_PROT_TX          0x80 /* error occurred on transmission */
89922cd657SDavid Howells 
90922cd657SDavid Howells /* error in CAN protocol (location) / data[3] */
91922cd657SDavid Howells #define CAN_ERR_PROT_LOC_UNSPEC  0x00 /* unspecified */
92922cd657SDavid Howells #define CAN_ERR_PROT_LOC_SOF     0x03 /* start of frame */
93922cd657SDavid Howells #define CAN_ERR_PROT_LOC_ID28_21 0x02 /* ID bits 28 - 21 (SFF: 10 - 3) */
94922cd657SDavid Howells #define CAN_ERR_PROT_LOC_ID20_18 0x06 /* ID bits 20 - 18 (SFF: 2 - 0 )*/
95922cd657SDavid Howells #define CAN_ERR_PROT_LOC_SRTR    0x04 /* substitute RTR (SFF: RTR) */
96922cd657SDavid Howells #define CAN_ERR_PROT_LOC_IDE     0x05 /* identifier extension */
97922cd657SDavid Howells #define CAN_ERR_PROT_LOC_ID17_13 0x07 /* ID bits 17-13 */
98922cd657SDavid Howells #define CAN_ERR_PROT_LOC_ID12_05 0x0F /* ID bits 12-5 */
99922cd657SDavid Howells #define CAN_ERR_PROT_LOC_ID04_00 0x0E /* ID bits 4-0 */
100922cd657SDavid Howells #define CAN_ERR_PROT_LOC_RTR     0x0C /* RTR */
101922cd657SDavid Howells #define CAN_ERR_PROT_LOC_RES1    0x0D /* reserved bit 1 */
102922cd657SDavid Howells #define CAN_ERR_PROT_LOC_RES0    0x09 /* reserved bit 0 */
103922cd657SDavid Howells #define CAN_ERR_PROT_LOC_DLC     0x0B /* data length code */
104922cd657SDavid Howells #define CAN_ERR_PROT_LOC_DATA    0x0A /* data section */
105922cd657SDavid Howells #define CAN_ERR_PROT_LOC_CRC_SEQ 0x08 /* CRC sequence */
106922cd657SDavid Howells #define CAN_ERR_PROT_LOC_CRC_DEL 0x18 /* CRC delimiter */
107922cd657SDavid Howells #define CAN_ERR_PROT_LOC_ACK     0x19 /* ACK slot */
108922cd657SDavid Howells #define CAN_ERR_PROT_LOC_ACK_DEL 0x1B /* ACK delimiter */
109922cd657SDavid Howells #define CAN_ERR_PROT_LOC_EOF     0x1A /* end of frame */
110922cd657SDavid Howells #define CAN_ERR_PROT_LOC_INTERM  0x12 /* intermission */
111922cd657SDavid Howells 
112922cd657SDavid Howells /* error status of CAN-transceiver / data[4] */
113922cd657SDavid Howells /*                                             CANH CANL */
114922cd657SDavid Howells #define CAN_ERR_TRX_UNSPEC             0x00 /* 0000 0000 */
115922cd657SDavid Howells #define CAN_ERR_TRX_CANH_NO_WIRE       0x04 /* 0000 0100 */
116922cd657SDavid Howells #define CAN_ERR_TRX_CANH_SHORT_TO_BAT  0x05 /* 0000 0101 */
117922cd657SDavid Howells #define CAN_ERR_TRX_CANH_SHORT_TO_VCC  0x06 /* 0000 0110 */
118922cd657SDavid Howells #define CAN_ERR_TRX_CANH_SHORT_TO_GND  0x07 /* 0000 0111 */
119922cd657SDavid Howells #define CAN_ERR_TRX_CANL_NO_WIRE       0x40 /* 0100 0000 */
120922cd657SDavid Howells #define CAN_ERR_TRX_CANL_SHORT_TO_BAT  0x50 /* 0101 0000 */
121922cd657SDavid Howells #define CAN_ERR_TRX_CANL_SHORT_TO_VCC  0x60 /* 0110 0000 */
122922cd657SDavid Howells #define CAN_ERR_TRX_CANL_SHORT_TO_GND  0x70 /* 0111 0000 */
123922cd657SDavid Howells #define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
124922cd657SDavid Howells 
125e70a3263SVincent Mailhol /* data[5] is reserved (do not use) */
126e70a3263SVincent Mailhol 
127e70a3263SVincent Mailhol /* TX error counter / data[6] */
128e70a3263SVincent Mailhol /* RX error counter / data[7] */
129922cd657SDavid Howells 
130*3f9c2621SVincent Mailhol /* CAN state thresholds
131*3f9c2621SVincent Mailhol  *
132*3f9c2621SVincent Mailhol  * Error counter	Error state
133*3f9c2621SVincent Mailhol  * -----------------------------------
134*3f9c2621SVincent Mailhol  * 0 -  95		Error-active
135*3f9c2621SVincent Mailhol  * 96 - 127		Error-warning
136*3f9c2621SVincent Mailhol  * 128 - 255		Error-passive
137*3f9c2621SVincent Mailhol  * 256 and greater	Bus-off
138*3f9c2621SVincent Mailhol  */
139*3f9c2621SVincent Mailhol #define CAN_ERROR_WARNING_THRESHOLD 96
140*3f9c2621SVincent Mailhol #define CAN_ERROR_PASSIVE_THRESHOLD 128
141*3f9c2621SVincent Mailhol #define CAN_BUS_OFF_THRESHOLD 256
142*3f9c2621SVincent Mailhol 
14342193e3eSOliver Hartkopp #endif /* _UAPI_CAN_ERROR_H */
144