xref: /OK3568_Linux_fs/kernel/include/uapi/linux/can/error.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * linux/can/error.h
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Definitions of the CAN error messages to be filtered and passed to the user.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
8*4882a593Smuzhiyun  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
9*4882a593Smuzhiyun  * All rights reserved.
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * Redistribution and use in source and binary forms, with or without
12*4882a593Smuzhiyun  * modification, are permitted provided that the following conditions
13*4882a593Smuzhiyun  * are met:
14*4882a593Smuzhiyun  * 1. Redistributions of source code must retain the above copyright
15*4882a593Smuzhiyun  *    notice, this list of conditions and the following disclaimer.
16*4882a593Smuzhiyun  * 2. Redistributions in binary form must reproduce the above copyright
17*4882a593Smuzhiyun  *    notice, this list of conditions and the following disclaimer in the
18*4882a593Smuzhiyun  *    documentation and/or other materials provided with the distribution.
19*4882a593Smuzhiyun  * 3. Neither the name of Volkswagen nor the names of its contributors
20*4882a593Smuzhiyun  *    may be used to endorse or promote products derived from this software
21*4882a593Smuzhiyun  *    without specific prior written permission.
22*4882a593Smuzhiyun  *
23*4882a593Smuzhiyun  * Alternatively, provided that this notice is retained in full, this
24*4882a593Smuzhiyun  * software may be distributed under the terms of the GNU General
25*4882a593Smuzhiyun  * Public License ("GPL") version 2, in which case the provisions of the
26*4882a593Smuzhiyun  * GPL apply INSTEAD OF those given above.
27*4882a593Smuzhiyun  *
28*4882a593Smuzhiyun  * The provided data structures and external interfaces from this code
29*4882a593Smuzhiyun  * are not restricted to be used by modules with a GPL compatible license.
30*4882a593Smuzhiyun  *
31*4882a593Smuzhiyun  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*4882a593Smuzhiyun  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*4882a593Smuzhiyun  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34*4882a593Smuzhiyun  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*4882a593Smuzhiyun  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36*4882a593Smuzhiyun  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37*4882a593Smuzhiyun  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38*4882a593Smuzhiyun  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39*4882a593Smuzhiyun  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40*4882a593Smuzhiyun  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41*4882a593Smuzhiyun  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
42*4882a593Smuzhiyun  * DAMAGE.
43*4882a593Smuzhiyun  */
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #ifndef _UAPI_CAN_ERROR_H
46*4882a593Smuzhiyun #define _UAPI_CAN_ERROR_H
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun #define CAN_ERR_DLC 8 /* dlc for error message frames */
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun /* error class (mask) in can_id */
51*4882a593Smuzhiyun #define CAN_ERR_TX_TIMEOUT   0x00000001U /* TX timeout (by netdevice driver) */
52*4882a593Smuzhiyun #define CAN_ERR_LOSTARB      0x00000002U /* lost arbitration    / data[0]    */
53*4882a593Smuzhiyun #define CAN_ERR_CRTL         0x00000004U /* controller problems / data[1]    */
54*4882a593Smuzhiyun #define CAN_ERR_PROT         0x00000008U /* protocol violations / data[2..3] */
55*4882a593Smuzhiyun #define CAN_ERR_TRX          0x00000010U /* transceiver status  / data[4]    */
56*4882a593Smuzhiyun #define CAN_ERR_ACK          0x00000020U /* received no ACK on transmission */
57*4882a593Smuzhiyun #define CAN_ERR_BUSOFF       0x00000040U /* bus off */
58*4882a593Smuzhiyun #define CAN_ERR_BUSERROR     0x00000080U /* bus error (may flood!) */
59*4882a593Smuzhiyun #define CAN_ERR_RESTARTED    0x00000100U /* controller restarted */
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /* arbitration lost in bit ... / data[0] */
62*4882a593Smuzhiyun #define CAN_ERR_LOSTARB_UNSPEC   0x00 /* unspecified */
63*4882a593Smuzhiyun 				      /* else bit number in bitstream */
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun /* error status of CAN-controller / data[1] */
66*4882a593Smuzhiyun #define CAN_ERR_CRTL_UNSPEC      0x00 /* unspecified */
67*4882a593Smuzhiyun #define CAN_ERR_CRTL_RX_OVERFLOW 0x01 /* RX buffer overflow */
68*4882a593Smuzhiyun #define CAN_ERR_CRTL_TX_OVERFLOW 0x02 /* TX buffer overflow */
69*4882a593Smuzhiyun #define CAN_ERR_CRTL_RX_WARNING  0x04 /* reached warning level for RX errors */
70*4882a593Smuzhiyun #define CAN_ERR_CRTL_TX_WARNING  0x08 /* reached warning level for TX errors */
71*4882a593Smuzhiyun #define CAN_ERR_CRTL_RX_PASSIVE  0x10 /* reached error passive status RX */
72*4882a593Smuzhiyun #define CAN_ERR_CRTL_TX_PASSIVE  0x20 /* reached error passive status TX */
73*4882a593Smuzhiyun 				      /* (at least one error counter exceeds */
74*4882a593Smuzhiyun 				      /* the protocol-defined level of 127)  */
75*4882a593Smuzhiyun #define CAN_ERR_CRTL_ACTIVE      0x40 /* recovered to error active state */
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /* error in CAN protocol (type) / data[2] */
78*4882a593Smuzhiyun #define CAN_ERR_PROT_UNSPEC      0x00 /* unspecified */
79*4882a593Smuzhiyun #define CAN_ERR_PROT_BIT         0x01 /* single bit error */
80*4882a593Smuzhiyun #define CAN_ERR_PROT_FORM        0x02 /* frame format error */
81*4882a593Smuzhiyun #define CAN_ERR_PROT_STUFF       0x04 /* bit stuffing error */
82*4882a593Smuzhiyun #define CAN_ERR_PROT_BIT0        0x08 /* unable to send dominant bit */
83*4882a593Smuzhiyun #define CAN_ERR_PROT_BIT1        0x10 /* unable to send recessive bit */
84*4882a593Smuzhiyun #define CAN_ERR_PROT_OVERLOAD    0x20 /* bus overload */
85*4882a593Smuzhiyun #define CAN_ERR_PROT_ACTIVE      0x40 /* active error announcement */
86*4882a593Smuzhiyun #define CAN_ERR_PROT_TX          0x80 /* error occurred on transmission */
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun /* error in CAN protocol (location) / data[3] */
89*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_UNSPEC  0x00 /* unspecified */
90*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_SOF     0x03 /* start of frame */
91*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_ID28_21 0x02 /* ID bits 28 - 21 (SFF: 10 - 3) */
92*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_ID20_18 0x06 /* ID bits 20 - 18 (SFF: 2 - 0 )*/
93*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_SRTR    0x04 /* substitute RTR (SFF: RTR) */
94*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_IDE     0x05 /* identifier extension */
95*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_ID17_13 0x07 /* ID bits 17-13 */
96*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_ID12_05 0x0F /* ID bits 12-5 */
97*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_ID04_00 0x0E /* ID bits 4-0 */
98*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_RTR     0x0C /* RTR */
99*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_RES1    0x0D /* reserved bit 1 */
100*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_RES0    0x09 /* reserved bit 0 */
101*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_DLC     0x0B /* data length code */
102*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_DATA    0x0A /* data section */
103*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_CRC_SEQ 0x08 /* CRC sequence */
104*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_CRC_DEL 0x18 /* CRC delimiter */
105*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_ACK     0x19 /* ACK slot */
106*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_ACK_DEL 0x1B /* ACK delimiter */
107*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_EOF     0x1A /* end of frame */
108*4882a593Smuzhiyun #define CAN_ERR_PROT_LOC_INTERM  0x12 /* intermission */
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun /* error status of CAN-transceiver / data[4] */
111*4882a593Smuzhiyun /*                                             CANH CANL */
112*4882a593Smuzhiyun #define CAN_ERR_TRX_UNSPEC             0x00 /* 0000 0000 */
113*4882a593Smuzhiyun #define CAN_ERR_TRX_CANH_NO_WIRE       0x04 /* 0000 0100 */
114*4882a593Smuzhiyun #define CAN_ERR_TRX_CANH_SHORT_TO_BAT  0x05 /* 0000 0101 */
115*4882a593Smuzhiyun #define CAN_ERR_TRX_CANH_SHORT_TO_VCC  0x06 /* 0000 0110 */
116*4882a593Smuzhiyun #define CAN_ERR_TRX_CANH_SHORT_TO_GND  0x07 /* 0000 0111 */
117*4882a593Smuzhiyun #define CAN_ERR_TRX_CANL_NO_WIRE       0x40 /* 0100 0000 */
118*4882a593Smuzhiyun #define CAN_ERR_TRX_CANL_SHORT_TO_BAT  0x50 /* 0101 0000 */
119*4882a593Smuzhiyun #define CAN_ERR_TRX_CANL_SHORT_TO_VCC  0x60 /* 0110 0000 */
120*4882a593Smuzhiyun #define CAN_ERR_TRX_CANL_SHORT_TO_GND  0x70 /* 0111 0000 */
121*4882a593Smuzhiyun #define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun /* data[5] is reserved (do not use) */
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun /* TX error counter / data[6] */
126*4882a593Smuzhiyun /* RX error counter / data[7] */
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun #endif /* _UAPI_CAN_ERROR_H */
129