Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
0002 /*
0003  * linux/can/error.h
0004  *
0005  * Definitions of the CAN error messages to be filtered and passed to the user.
0006  *
0007  * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
0008  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
0009  * All rights reserved.
0010  *
0011  * Redistribution and use in source and binary forms, with or without
0012  * modification, are permitted provided that the following conditions
0013  * are met:
0014  * 1. Redistributions of source code must retain the above copyright
0015  *    notice, this list of conditions and the following disclaimer.
0016  * 2. Redistributions in binary form must reproduce the above copyright
0017  *    notice, this list of conditions and the following disclaimer in the
0018  *    documentation and/or other materials provided with the distribution.
0019  * 3. Neither the name of Volkswagen nor the names of its contributors
0020  *    may be used to endorse or promote products derived from this software
0021  *    without specific prior written permission.
0022  *
0023  * Alternatively, provided that this notice is retained in full, this
0024  * software may be distributed under the terms of the GNU General
0025  * Public License ("GPL") version 2, in which case the provisions of the
0026  * GPL apply INSTEAD OF those given above.
0027  *
0028  * The provided data structures and external interfaces from this code
0029  * are not restricted to be used by modules with a GPL compatible license.
0030  *
0031  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0032  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0033  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0034  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0035  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0036  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0037  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0038  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0039  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0041  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
0042  * DAMAGE.
0043  */
0044 
0045 #ifndef _UAPI_CAN_ERROR_H
0046 #define _UAPI_CAN_ERROR_H
0047 
0048 #define CAN_ERR_DLC 8 /* dlc for error message frames */
0049 
0050 /* error class (mask) in can_id */
0051 #define CAN_ERR_TX_TIMEOUT   0x00000001U /* TX timeout (by netdevice driver) */
0052 #define CAN_ERR_LOSTARB      0x00000002U /* lost arbitration    / data[0]    */
0053 #define CAN_ERR_CRTL         0x00000004U /* controller problems / data[1]    */
0054 #define CAN_ERR_PROT         0x00000008U /* protocol violations / data[2..3] */
0055 #define CAN_ERR_TRX          0x00000010U /* transceiver status  / data[4]    */
0056 #define CAN_ERR_ACK          0x00000020U /* received no ACK on transmission */
0057 #define CAN_ERR_BUSOFF       0x00000040U /* bus off */
0058 #define CAN_ERR_BUSERROR     0x00000080U /* bus error (may flood!) */
0059 #define CAN_ERR_RESTARTED    0x00000100U /* controller restarted */
0060 #define CAN_ERR_CNT          0x00000200U /* TX error counter / data[6] */
0061                      /* RX error counter / data[7] */
0062 
0063 /* arbitration lost in bit ... / data[0] */
0064 #define CAN_ERR_LOSTARB_UNSPEC   0x00 /* unspecified */
0065                       /* else bit number in bitstream */
0066 
0067 /* error status of CAN-controller / data[1] */
0068 #define CAN_ERR_CRTL_UNSPEC      0x00 /* unspecified */
0069 #define CAN_ERR_CRTL_RX_OVERFLOW 0x01 /* RX buffer overflow */
0070 #define CAN_ERR_CRTL_TX_OVERFLOW 0x02 /* TX buffer overflow */
0071 #define CAN_ERR_CRTL_RX_WARNING  0x04 /* reached warning level for RX errors */
0072 #define CAN_ERR_CRTL_TX_WARNING  0x08 /* reached warning level for TX errors */
0073 #define CAN_ERR_CRTL_RX_PASSIVE  0x10 /* reached error passive status RX */
0074 #define CAN_ERR_CRTL_TX_PASSIVE  0x20 /* reached error passive status TX */
0075                       /* (at least one error counter exceeds */
0076                       /* the protocol-defined level of 127)  */
0077 #define CAN_ERR_CRTL_ACTIVE      0x40 /* recovered to error active state */
0078 
0079 /* error in CAN protocol (type) / data[2] */
0080 #define CAN_ERR_PROT_UNSPEC      0x00 /* unspecified */
0081 #define CAN_ERR_PROT_BIT         0x01 /* single bit error */
0082 #define CAN_ERR_PROT_FORM        0x02 /* frame format error */
0083 #define CAN_ERR_PROT_STUFF       0x04 /* bit stuffing error */
0084 #define CAN_ERR_PROT_BIT0        0x08 /* unable to send dominant bit */
0085 #define CAN_ERR_PROT_BIT1        0x10 /* unable to send recessive bit */
0086 #define CAN_ERR_PROT_OVERLOAD    0x20 /* bus overload */
0087 #define CAN_ERR_PROT_ACTIVE      0x40 /* active error announcement */
0088 #define CAN_ERR_PROT_TX          0x80 /* error occurred on transmission */
0089 
0090 /* error in CAN protocol (location) / data[3] */
0091 #define CAN_ERR_PROT_LOC_UNSPEC  0x00 /* unspecified */
0092 #define CAN_ERR_PROT_LOC_SOF     0x03 /* start of frame */
0093 #define CAN_ERR_PROT_LOC_ID28_21 0x02 /* ID bits 28 - 21 (SFF: 10 - 3) */
0094 #define CAN_ERR_PROT_LOC_ID20_18 0x06 /* ID bits 20 - 18 (SFF: 2 - 0 )*/
0095 #define CAN_ERR_PROT_LOC_SRTR    0x04 /* substitute RTR (SFF: RTR) */
0096 #define CAN_ERR_PROT_LOC_IDE     0x05 /* identifier extension */
0097 #define CAN_ERR_PROT_LOC_ID17_13 0x07 /* ID bits 17-13 */
0098 #define CAN_ERR_PROT_LOC_ID12_05 0x0F /* ID bits 12-5 */
0099 #define CAN_ERR_PROT_LOC_ID04_00 0x0E /* ID bits 4-0 */
0100 #define CAN_ERR_PROT_LOC_RTR     0x0C /* RTR */
0101 #define CAN_ERR_PROT_LOC_RES1    0x0D /* reserved bit 1 */
0102 #define CAN_ERR_PROT_LOC_RES0    0x09 /* reserved bit 0 */
0103 #define CAN_ERR_PROT_LOC_DLC     0x0B /* data length code */
0104 #define CAN_ERR_PROT_LOC_DATA    0x0A /* data section */
0105 #define CAN_ERR_PROT_LOC_CRC_SEQ 0x08 /* CRC sequence */
0106 #define CAN_ERR_PROT_LOC_CRC_DEL 0x18 /* CRC delimiter */
0107 #define CAN_ERR_PROT_LOC_ACK     0x19 /* ACK slot */
0108 #define CAN_ERR_PROT_LOC_ACK_DEL 0x1B /* ACK delimiter */
0109 #define CAN_ERR_PROT_LOC_EOF     0x1A /* end of frame */
0110 #define CAN_ERR_PROT_LOC_INTERM  0x12 /* intermission */
0111 
0112 /* error status of CAN-transceiver / data[4] */
0113 /*                                             CANH CANL */
0114 #define CAN_ERR_TRX_UNSPEC             0x00 /* 0000 0000 */
0115 #define CAN_ERR_TRX_CANH_NO_WIRE       0x04 /* 0000 0100 */
0116 #define CAN_ERR_TRX_CANH_SHORT_TO_BAT  0x05 /* 0000 0101 */
0117 #define CAN_ERR_TRX_CANH_SHORT_TO_VCC  0x06 /* 0000 0110 */
0118 #define CAN_ERR_TRX_CANH_SHORT_TO_GND  0x07 /* 0000 0111 */
0119 #define CAN_ERR_TRX_CANL_NO_WIRE       0x40 /* 0100 0000 */
0120 #define CAN_ERR_TRX_CANL_SHORT_TO_BAT  0x50 /* 0101 0000 */
0121 #define CAN_ERR_TRX_CANL_SHORT_TO_VCC  0x60 /* 0110 0000 */
0122 #define CAN_ERR_TRX_CANL_SHORT_TO_GND  0x70 /* 0111 0000 */
0123 #define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
0124 
0125 /* data[5] is reserved (do not use) */
0126 
0127 /* TX error counter / data[6] */
0128 /* RX error counter / data[7] */
0129 
0130 /* CAN state thresholds
0131  *
0132  * Error counter    Error state
0133  * -----------------------------------
0134  * 0 -  95      Error-active
0135  * 96 - 127     Error-warning
0136  * 128 - 255        Error-passive
0137  * 256 and greater  Bus-off
0138  */
0139 #define CAN_ERROR_WARNING_THRESHOLD 96
0140 #define CAN_ERROR_PASSIVE_THRESHOLD 128
0141 #define CAN_BUS_OFF_THRESHOLD 256
0142 
0143 #endif /* _UAPI_CAN_ERROR_H */