linux/include/uapi/linux/can/error.h

/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
/*
 * linux/can/error.h
 *
 * Definitions of the CAN error messages to be filtered and passed to the user.
 *
 * Author: Oliver Hartkopp <[email protected]>
 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of Volkswagen nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * Alternatively, provided that this notice is retained in full, this
 * software may be distributed under the terms of the GNU General
 * Public License ("GPL") version 2, in which case the provisions of the
 * GPL apply INSTEAD OF those given above.
 *
 * The provided data structures and external interfaces from this code
 * are not restricted to be used by modules with a GPL compatible license.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 */

#ifndef _UAPI_CAN_ERROR_H
#define _UAPI_CAN_ERROR_H

#define CAN_ERR_DLC

/* error class (mask) in can_id */
#define CAN_ERR_TX_TIMEOUT
#define CAN_ERR_LOSTARB
#define CAN_ERR_CRTL
#define CAN_ERR_PROT
#define CAN_ERR_TRX
#define CAN_ERR_ACK
#define CAN_ERR_BUSOFF
#define CAN_ERR_BUSERROR
#define CAN_ERR_RESTARTED
#define CAN_ERR_CNT
					 /* RX error counter / data[7] */

/* arbitration lost in bit ... / data[0] */
#define CAN_ERR_LOSTARB_UNSPEC
				      /* else bit number in bitstream */

/* error status of CAN-controller / data[1] */
#define CAN_ERR_CRTL_UNSPEC
#define CAN_ERR_CRTL_RX_OVERFLOW
#define CAN_ERR_CRTL_TX_OVERFLOW
#define CAN_ERR_CRTL_RX_WARNING
#define CAN_ERR_CRTL_TX_WARNING
#define CAN_ERR_CRTL_RX_PASSIVE
#define CAN_ERR_CRTL_TX_PASSIVE
				      /* (at least one error counter exceeds */
				      /* the protocol-defined level of 127)  */
#define CAN_ERR_CRTL_ACTIVE

/* error in CAN protocol (type) / data[2] */
#define CAN_ERR_PROT_UNSPEC
#define CAN_ERR_PROT_BIT
#define CAN_ERR_PROT_FORM
#define CAN_ERR_PROT_STUFF
#define CAN_ERR_PROT_BIT0
#define CAN_ERR_PROT_BIT1
#define CAN_ERR_PROT_OVERLOAD
#define CAN_ERR_PROT_ACTIVE
#define CAN_ERR_PROT_TX

/* error in CAN protocol (location) / data[3] */
#define CAN_ERR_PROT_LOC_UNSPEC
#define CAN_ERR_PROT_LOC_SOF
#define CAN_ERR_PROT_LOC_ID28_21
#define CAN_ERR_PROT_LOC_ID20_18
#define CAN_ERR_PROT_LOC_SRTR
#define CAN_ERR_PROT_LOC_IDE
#define CAN_ERR_PROT_LOC_ID17_13
#define CAN_ERR_PROT_LOC_ID12_05
#define CAN_ERR_PROT_LOC_ID04_00
#define CAN_ERR_PROT_LOC_RTR
#define CAN_ERR_PROT_LOC_RES1
#define CAN_ERR_PROT_LOC_RES0
#define CAN_ERR_PROT_LOC_DLC
#define CAN_ERR_PROT_LOC_DATA
#define CAN_ERR_PROT_LOC_CRC_SEQ
#define CAN_ERR_PROT_LOC_CRC_DEL
#define CAN_ERR_PROT_LOC_ACK
#define CAN_ERR_PROT_LOC_ACK_DEL
#define CAN_ERR_PROT_LOC_EOF
#define CAN_ERR_PROT_LOC_INTERM

/* error status of CAN-transceiver / data[4] */
/*                                             CANH CANL */
#define CAN_ERR_TRX_UNSPEC
#define CAN_ERR_TRX_CANH_NO_WIRE
#define CAN_ERR_TRX_CANH_SHORT_TO_BAT
#define CAN_ERR_TRX_CANH_SHORT_TO_VCC
#define CAN_ERR_TRX_CANH_SHORT_TO_GND
#define CAN_ERR_TRX_CANL_NO_WIRE
#define CAN_ERR_TRX_CANL_SHORT_TO_BAT
#define CAN_ERR_TRX_CANL_SHORT_TO_VCC
#define CAN_ERR_TRX_CANL_SHORT_TO_GND
#define CAN_ERR_TRX_CANL_SHORT_TO_CANH

/* data[5] is reserved (do not use) */

/* TX error counter / data[6] */
/* RX error counter / data[7] */

/* CAN state thresholds
 *
 * Error counter	Error state
 * -----------------------------------
 * 0 -  95		Error-active
 * 96 - 127		Error-warning
 * 128 - 255		Error-passive
 * 256 and greater	Bus-off
 */
#define CAN_ERROR_WARNING_THRESHOLD
#define CAN_ERROR_PASSIVE_THRESHOLD
#define CAN_BUS_OFF_THRESHOLD

#endif /* _UAPI_CAN_ERROR_H */