Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
0002 /*
0003  * linux/can/netlink.h
0004  *
0005  * Definitions for the CAN netlink interface
0006  *
0007  * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
0008  *
0009  * This program is free software; you can redistribute it and/or modify
0010  * it under the terms of the version 2 of the GNU General Public License
0011  * as published by the Free Software Foundation
0012  *
0013  * This program is distributed in the hope that it will be useful,
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0016  * GNU General Public License for more details.
0017  */
0018 
0019 #ifndef _UAPI_CAN_NETLINK_H
0020 #define _UAPI_CAN_NETLINK_H
0021 
0022 #include <linux/types.h>
0023 
0024 /*
0025  * CAN bit-timing parameters
0026  *
0027  * For further information, please read chapter "8 BIT TIMING
0028  * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
0029  * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
0030  */
0031 struct can_bittiming {
0032     __u32 bitrate;      /* Bit-rate in bits/second */
0033     __u32 sample_point; /* Sample point in one-tenth of a percent */
0034     __u32 tq;       /* Time quanta (TQ) in nanoseconds */
0035     __u32 prop_seg;     /* Propagation segment in TQs */
0036     __u32 phase_seg1;   /* Phase buffer segment 1 in TQs */
0037     __u32 phase_seg2;   /* Phase buffer segment 2 in TQs */
0038     __u32 sjw;      /* Synchronisation jump width in TQs */
0039     __u32 brp;      /* Bit-rate prescaler */
0040 };
0041 
0042 /*
0043  * CAN hardware-dependent bit-timing constant
0044  *
0045  * Used for calculating and checking bit-timing parameters
0046  */
0047 struct can_bittiming_const {
0048     char name[16];      /* Name of the CAN controller hardware */
0049     __u32 tseg1_min;    /* Time segment 1 = prop_seg + phase_seg1 */
0050     __u32 tseg1_max;
0051     __u32 tseg2_min;    /* Time segment 2 = phase_seg2 */
0052     __u32 tseg2_max;
0053     __u32 sjw_max;      /* Synchronisation jump width */
0054     __u32 brp_min;      /* Bit-rate prescaler */
0055     __u32 brp_max;
0056     __u32 brp_inc;
0057 };
0058 
0059 /*
0060  * CAN clock parameters
0061  */
0062 struct can_clock {
0063     __u32 freq;     /* CAN system clock frequency in Hz */
0064 };
0065 
0066 /*
0067  * CAN operational and error states
0068  */
0069 enum can_state {
0070     CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */
0071     CAN_STATE_ERROR_WARNING,    /* RX/TX error count < 128 */
0072     CAN_STATE_ERROR_PASSIVE,    /* RX/TX error count < 256 */
0073     CAN_STATE_BUS_OFF,      /* RX/TX error count >= 256 */
0074     CAN_STATE_STOPPED,      /* Device is stopped */
0075     CAN_STATE_SLEEPING,     /* Device is sleeping */
0076     CAN_STATE_MAX
0077 };
0078 
0079 /*
0080  * CAN bus error counters
0081  */
0082 struct can_berr_counter {
0083     __u16 txerr;
0084     __u16 rxerr;
0085 };
0086 
0087 /*
0088  * CAN controller mode
0089  */
0090 struct can_ctrlmode {
0091     __u32 mask;
0092     __u32 flags;
0093 };
0094 
0095 #define CAN_CTRLMODE_LOOPBACK       0x01    /* Loopback mode */
0096 #define CAN_CTRLMODE_LISTENONLY     0x02    /* Listen-only mode */
0097 #define CAN_CTRLMODE_3_SAMPLES      0x04    /* Triple sampling mode */
0098 #define CAN_CTRLMODE_ONE_SHOT       0x08    /* One-Shot mode */
0099 #define CAN_CTRLMODE_BERR_REPORTING 0x10    /* Bus-error reporting */
0100 #define CAN_CTRLMODE_FD         0x20    /* CAN FD mode */
0101 #define CAN_CTRLMODE_PRESUME_ACK    0x40    /* Ignore missing CAN ACKs */
0102 #define CAN_CTRLMODE_FD_NON_ISO     0x80    /* CAN FD in non-ISO mode */
0103 #define CAN_CTRLMODE_CC_LEN8_DLC    0x100   /* Classic CAN DLC option */
0104 #define CAN_CTRLMODE_TDC_AUTO       0x200   /* CAN transiver automatically calculates TDCV */
0105 #define CAN_CTRLMODE_TDC_MANUAL     0x400   /* TDCV is manually set up by user */
0106 
0107 /*
0108  * CAN device statistics
0109  */
0110 struct can_device_stats {
0111     __u32 bus_error;    /* Bus errors */
0112     __u32 error_warning;    /* Changes to error warning state */
0113     __u32 error_passive;    /* Changes to error passive state */
0114     __u32 bus_off;      /* Changes to bus off state */
0115     __u32 arbitration_lost; /* Arbitration lost errors */
0116     __u32 restarts;     /* CAN controller re-starts */
0117 };
0118 
0119 /*
0120  * CAN netlink interface
0121  */
0122 enum {
0123     IFLA_CAN_UNSPEC,
0124     IFLA_CAN_BITTIMING,
0125     IFLA_CAN_BITTIMING_CONST,
0126     IFLA_CAN_CLOCK,
0127     IFLA_CAN_STATE,
0128     IFLA_CAN_CTRLMODE,
0129     IFLA_CAN_RESTART_MS,
0130     IFLA_CAN_RESTART,
0131     IFLA_CAN_BERR_COUNTER,
0132     IFLA_CAN_DATA_BITTIMING,
0133     IFLA_CAN_DATA_BITTIMING_CONST,
0134     IFLA_CAN_TERMINATION,
0135     IFLA_CAN_TERMINATION_CONST,
0136     IFLA_CAN_BITRATE_CONST,
0137     IFLA_CAN_DATA_BITRATE_CONST,
0138     IFLA_CAN_BITRATE_MAX,
0139     IFLA_CAN_TDC,
0140     IFLA_CAN_CTRLMODE_EXT,
0141 
0142     /* add new constants above here */
0143     __IFLA_CAN_MAX,
0144     IFLA_CAN_MAX = __IFLA_CAN_MAX - 1
0145 };
0146 
0147 /*
0148  * CAN FD Transmitter Delay Compensation (TDC)
0149  *
0150  * Please refer to struct can_tdc_const and can_tdc in
0151  * include/linux/can/bittiming.h for further details.
0152  */
0153 enum {
0154     IFLA_CAN_TDC_UNSPEC,
0155     IFLA_CAN_TDC_TDCV_MIN,  /* u32 */
0156     IFLA_CAN_TDC_TDCV_MAX,  /* u32 */
0157     IFLA_CAN_TDC_TDCO_MIN,  /* u32 */
0158     IFLA_CAN_TDC_TDCO_MAX,  /* u32 */
0159     IFLA_CAN_TDC_TDCF_MIN,  /* u32 */
0160     IFLA_CAN_TDC_TDCF_MAX,  /* u32 */
0161     IFLA_CAN_TDC_TDCV,  /* u32 */
0162     IFLA_CAN_TDC_TDCO,  /* u32 */
0163     IFLA_CAN_TDC_TDCF,  /* u32 */
0164 
0165     /* add new constants above here */
0166     __IFLA_CAN_TDC,
0167     IFLA_CAN_TDC_MAX = __IFLA_CAN_TDC - 1
0168 };
0169 
0170 /*
0171  * IFLA_CAN_CTRLMODE_EXT nest: controller mode extended parameters
0172  */
0173 enum {
0174     IFLA_CAN_CTRLMODE_UNSPEC,
0175     IFLA_CAN_CTRLMODE_SUPPORTED,    /* u32 */
0176 
0177     /* add new constants above here */
0178     __IFLA_CAN_CTRLMODE,
0179     IFLA_CAN_CTRLMODE_MAX = __IFLA_CAN_CTRLMODE - 1
0180 };
0181 
0182 /* u16 termination range: 1..65535 Ohms */
0183 #define CAN_TERMINATION_DISABLED 0
0184 
0185 #endif /* !_UAPI_CAN_NETLINK_H */