13926a3a0SYegor Yefremov /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2922cd657SDavid Howells /* 3922cd657SDavid Howells * linux/can/netlink.h 4922cd657SDavid Howells * 5922cd657SDavid Howells * Definitions for the CAN netlink interface 6922cd657SDavid Howells * 7922cd657SDavid Howells * Copyright (c) 2009 Wolfgang Grandegger <[email protected]> 8922cd657SDavid Howells * 91c2da13cSUwe Kleine-König * This program is free software; you can redistribute it and/or modify 101c2da13cSUwe Kleine-König * it under the terms of the version 2 of the GNU General Public License 111c2da13cSUwe Kleine-König * as published by the Free Software Foundation 121c2da13cSUwe Kleine-König * 131c2da13cSUwe Kleine-König * This program is distributed in the hope that it will be useful, 141c2da13cSUwe Kleine-König * but WITHOUT ANY WARRANTY; without even the implied warranty of 151c2da13cSUwe Kleine-König * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 161c2da13cSUwe Kleine-König * GNU General Public License for more details. 17922cd657SDavid Howells */ 18922cd657SDavid Howells 1942193e3eSOliver Hartkopp #ifndef _UAPI_CAN_NETLINK_H 2042193e3eSOliver Hartkopp #define _UAPI_CAN_NETLINK_H 21922cd657SDavid Howells 22922cd657SDavid Howells #include <linux/types.h> 23922cd657SDavid Howells 24922cd657SDavid Howells /* 25922cd657SDavid Howells * CAN bit-timing parameters 26922cd657SDavid Howells * 27922cd657SDavid Howells * For further information, please read chapter "8 BIT TIMING 28922cd657SDavid Howells * REQUIREMENTS" of the "Bosch CAN Specification version 2.0" 29922cd657SDavid Howells * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf. 30922cd657SDavid Howells */ 31922cd657SDavid Howells struct can_bittiming { 32922cd657SDavid Howells __u32 bitrate; /* Bit-rate in bits/second */ 33922cd657SDavid Howells __u32 sample_point; /* Sample point in one-tenth of a percent */ 34922cd657SDavid Howells __u32 tq; /* Time quanta (TQ) in nanoseconds */ 35922cd657SDavid Howells __u32 prop_seg; /* Propagation segment in TQs */ 36922cd657SDavid Howells __u32 phase_seg1; /* Phase buffer segment 1 in TQs */ 37922cd657SDavid Howells __u32 phase_seg2; /* Phase buffer segment 2 in TQs */ 38922cd657SDavid Howells __u32 sjw; /* Synchronisation jump width in TQs */ 39922cd657SDavid Howells __u32 brp; /* Bit-rate prescaler */ 40922cd657SDavid Howells }; 41922cd657SDavid Howells 42922cd657SDavid Howells /* 433ca3c4aaSAndre Hartmann * CAN hardware-dependent bit-timing constant 44922cd657SDavid Howells * 45922cd657SDavid Howells * Used for calculating and checking bit-timing parameters 46922cd657SDavid Howells */ 47922cd657SDavid Howells struct can_bittiming_const { 48922cd657SDavid Howells char name[16]; /* Name of the CAN controller hardware */ 493ca3c4aaSAndre Hartmann __u32 tseg1_min; /* Time segment 1 = prop_seg + phase_seg1 */ 50922cd657SDavid Howells __u32 tseg1_max; 513ca3c4aaSAndre Hartmann __u32 tseg2_min; /* Time segment 2 = phase_seg2 */ 52922cd657SDavid Howells __u32 tseg2_max; 53922cd657SDavid Howells __u32 sjw_max; /* Synchronisation jump width */ 54922cd657SDavid Howells __u32 brp_min; /* Bit-rate prescaler */ 55922cd657SDavid Howells __u32 brp_max; 56922cd657SDavid Howells __u32 brp_inc; 57922cd657SDavid Howells }; 58922cd657SDavid Howells 59922cd657SDavid Howells /* 60922cd657SDavid Howells * CAN clock parameters 61922cd657SDavid Howells */ 62922cd657SDavid Howells struct can_clock { 63922cd657SDavid Howells __u32 freq; /* CAN system clock frequency in Hz */ 64922cd657SDavid Howells }; 65922cd657SDavid Howells 66922cd657SDavid Howells /* 67922cd657SDavid Howells * CAN operational and error states 68922cd657SDavid Howells */ 69922cd657SDavid Howells enum can_state { 70922cd657SDavid Howells CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */ 71922cd657SDavid Howells CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */ 72922cd657SDavid Howells CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */ 73922cd657SDavid Howells CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */ 74922cd657SDavid Howells CAN_STATE_STOPPED, /* Device is stopped */ 75922cd657SDavid Howells CAN_STATE_SLEEPING, /* Device is sleeping */ 76922cd657SDavid Howells CAN_STATE_MAX 77922cd657SDavid Howells }; 78922cd657SDavid Howells 79922cd657SDavid Howells /* 80922cd657SDavid Howells * CAN bus error counters 81922cd657SDavid Howells */ 82922cd657SDavid Howells struct can_berr_counter { 83922cd657SDavid Howells __u16 txerr; 84922cd657SDavid Howells __u16 rxerr; 85922cd657SDavid Howells }; 86922cd657SDavid Howells 87922cd657SDavid Howells /* 88922cd657SDavid Howells * CAN controller mode 89922cd657SDavid Howells */ 90922cd657SDavid Howells struct can_ctrlmode { 91922cd657SDavid Howells __u32 mask; 92922cd657SDavid Howells __u32 flags; 93922cd657SDavid Howells }; 94922cd657SDavid Howells 95922cd657SDavid Howells #define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */ 96922cd657SDavid Howells #define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */ 97922cd657SDavid Howells #define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */ 98922cd657SDavid Howells #define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */ 99922cd657SDavid Howells #define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */ 100bc05a894SOliver Hartkopp #define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */ 1014b9e1babSNikita Edward Baruzdin #define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */ 1026cfda7fbSOliver Hartkopp #define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */ 103ea780056SOliver Hartkopp #define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */ 10463dfe070SVincent Mailhol #define CAN_CTRLMODE_TDC_AUTO 0x200 /* CAN transiver automatically calculates TDCV */ 10563dfe070SVincent Mailhol #define CAN_CTRLMODE_TDC_MANUAL 0x400 /* TDCV is manually set up by user */ 106922cd657SDavid Howells 107922cd657SDavid Howells /* 108922cd657SDavid Howells * CAN device statistics 109922cd657SDavid Howells */ 110922cd657SDavid Howells struct can_device_stats { 111922cd657SDavid Howells __u32 bus_error; /* Bus errors */ 112922cd657SDavid Howells __u32 error_warning; /* Changes to error warning state */ 113922cd657SDavid Howells __u32 error_passive; /* Changes to error passive state */ 114922cd657SDavid Howells __u32 bus_off; /* Changes to bus off state */ 115922cd657SDavid Howells __u32 arbitration_lost; /* Arbitration lost errors */ 116922cd657SDavid Howells __u32 restarts; /* CAN controller re-starts */ 117922cd657SDavid Howells }; 118922cd657SDavid Howells 119922cd657SDavid Howells /* 120922cd657SDavid Howells * CAN netlink interface 121922cd657SDavid Howells */ 122922cd657SDavid Howells enum { 123922cd657SDavid Howells IFLA_CAN_UNSPEC, 124922cd657SDavid Howells IFLA_CAN_BITTIMING, 125922cd657SDavid Howells IFLA_CAN_BITTIMING_CONST, 126922cd657SDavid Howells IFLA_CAN_CLOCK, 127922cd657SDavid Howells IFLA_CAN_STATE, 128922cd657SDavid Howells IFLA_CAN_CTRLMODE, 129922cd657SDavid Howells IFLA_CAN_RESTART_MS, 130922cd657SDavid Howells IFLA_CAN_RESTART, 131922cd657SDavid Howells IFLA_CAN_BERR_COUNTER, 1329859ccd2SOliver Hartkopp IFLA_CAN_DATA_BITTIMING, 1339859ccd2SOliver Hartkopp IFLA_CAN_DATA_BITTIMING_CONST, 13412a6075cSOliver Hartkopp IFLA_CAN_TERMINATION, 13512a6075cSOliver Hartkopp IFLA_CAN_TERMINATION_CONST, 136431af779SMarc Kleine-Budde IFLA_CAN_BITRATE_CONST, 137431af779SMarc Kleine-Budde IFLA_CAN_DATA_BITRATE_CONST, 1382290aefaSFranklin S Cooper Jr IFLA_CAN_BITRATE_MAX, 139d99755f7SVincent Mailhol IFLA_CAN_TDC, 140*383f0993SVincent Mailhol IFLA_CAN_CTRLMODE_EXT, 141d99755f7SVincent Mailhol 142d99755f7SVincent Mailhol /* add new constants above here */ 143d99755f7SVincent Mailhol __IFLA_CAN_MAX, 144d99755f7SVincent Mailhol IFLA_CAN_MAX = __IFLA_CAN_MAX - 1 145922cd657SDavid Howells }; 146922cd657SDavid Howells 147d99755f7SVincent Mailhol /* 148d99755f7SVincent Mailhol * CAN FD Transmitter Delay Compensation (TDC) 149d99755f7SVincent Mailhol * 150d99755f7SVincent Mailhol * Please refer to struct can_tdc_const and can_tdc in 151d99755f7SVincent Mailhol * include/linux/can/bittiming.h for further details. 152d99755f7SVincent Mailhol */ 153d99755f7SVincent Mailhol enum { 154d99755f7SVincent Mailhol IFLA_CAN_TDC_UNSPEC, 155d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCV_MIN, /* u32 */ 156d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCV_MAX, /* u32 */ 157d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCO_MIN, /* u32 */ 158d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCO_MAX, /* u32 */ 159d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCF_MIN, /* u32 */ 160d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCF_MAX, /* u32 */ 161d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCV, /* u32 */ 162d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCO, /* u32 */ 163d99755f7SVincent Mailhol IFLA_CAN_TDC_TDCF, /* u32 */ 164d99755f7SVincent Mailhol 165d99755f7SVincent Mailhol /* add new constants above here */ 166d99755f7SVincent Mailhol __IFLA_CAN_TDC, 167d99755f7SVincent Mailhol IFLA_CAN_TDC_MAX = __IFLA_CAN_TDC - 1 168d99755f7SVincent Mailhol }; 169922cd657SDavid Howells 170*383f0993SVincent Mailhol /* 171*383f0993SVincent Mailhol * IFLA_CAN_CTRLMODE_EXT nest: controller mode extended parameters 172*383f0993SVincent Mailhol */ 173*383f0993SVincent Mailhol enum { 174*383f0993SVincent Mailhol IFLA_CAN_CTRLMODE_UNSPEC, 175*383f0993SVincent Mailhol IFLA_CAN_CTRLMODE_SUPPORTED, /* u32 */ 176*383f0993SVincent Mailhol 177*383f0993SVincent Mailhol /* add new constants above here */ 178*383f0993SVincent Mailhol __IFLA_CAN_CTRLMODE, 179*383f0993SVincent Mailhol IFLA_CAN_CTRLMODE_MAX = __IFLA_CAN_CTRLMODE - 1 180*383f0993SVincent Mailhol }; 181*383f0993SVincent Mailhol 18212a6075cSOliver Hartkopp /* u16 termination range: 1..65535 Ohms */ 18312a6075cSOliver Hartkopp #define CAN_TERMINATION_DISABLED 0 18412a6075cSOliver Hartkopp 18542193e3eSOliver Hartkopp #endif /* !_UAPI_CAN_NETLINK_H */ 186