blob: 94ffe0c83ce72cf5e396a615fe039bec6fe468d4 [file] [log] [blame]
Wolfgang Grandegger39549ee2009-05-15 23:39:29 +00001/*
2 * linux/can/netlink.h
3 *
4 * Definitions for the CAN netlink interface
5 *
6 * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
7 *
Uwe Kleine-König1c2da132013-09-07 21:34:38 +02008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the version 2 of the GNU General Public License
10 * as published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Wolfgang Grandegger39549ee2009-05-15 23:39:29 +000016 */
17
Oliver Hartkopp42193e32014-05-15 20:31:56 +020018#ifndef _UAPI_CAN_NETLINK_H
19#define _UAPI_CAN_NETLINK_H
Wolfgang Grandegger39549ee2009-05-15 23:39:29 +000020
21#include <linux/types.h>
22
23/*
24 * CAN bit-timing parameters
25 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -030026 * For further information, please read chapter "8 BIT TIMING
Wolfgang Grandegger39549ee2009-05-15 23:39:29 +000027 * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
28 * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
29 */
30struct can_bittiming {
31 __u32 bitrate; /* Bit-rate in bits/second */
32 __u32 sample_point; /* Sample point in one-tenth of a percent */
33 __u32 tq; /* Time quanta (TQ) in nanoseconds */
34 __u32 prop_seg; /* Propagation segment in TQs */
35 __u32 phase_seg1; /* Phase buffer segment 1 in TQs */
36 __u32 phase_seg2; /* Phase buffer segment 2 in TQs */
37 __u32 sjw; /* Synchronisation jump width in TQs */
38 __u32 brp; /* Bit-rate prescaler */
39};
40
41/*
42 * CAN harware-dependent bit-timing constant
43 *
44 * Used for calculating and checking bit-timing parameters
45 */
46struct can_bittiming_const {
47 char name[16]; /* Name of the CAN controller hardware */
48 __u32 tseg1_min; /* Time segement 1 = prop_seg + phase_seg1 */
49 __u32 tseg1_max;
50 __u32 tseg2_min; /* Time segement 2 = phase_seg2 */
51 __u32 tseg2_max;
52 __u32 sjw_max; /* Synchronisation jump width */
53 __u32 brp_min; /* Bit-rate prescaler */
54 __u32 brp_max;
55 __u32 brp_inc;
56};
57
58/*
59 * CAN clock parameters
60 */
61struct can_clock {
62 __u32 freq; /* CAN system clock frequency in Hz */
63};
64
65/*
66 * CAN operational and error states
67 */
68enum can_state {
69 CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */
70 CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */
71 CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */
72 CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */
73 CAN_STATE_STOPPED, /* Device is stopped */
74 CAN_STATE_SLEEPING, /* Device is sleeping */
75 CAN_STATE_MAX
76};
77
78/*
Wolfgang Grandegger52c793f2010-02-22 22:21:17 +000079 * CAN bus error counters
80 */
81struct can_berr_counter {
82 __u16 txerr;
83 __u16 rxerr;
84};
85
86/*
Wolfgang Grandegger39549ee2009-05-15 23:39:29 +000087 * CAN controller mode
88 */
89struct can_ctrlmode {
90 __u32 mask;
91 __u32 flags;
92};
93
Wolfgang Grandegger52c793f2010-02-22 22:21:17 +000094#define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */
Nikita Edward Baruzdinf736d992014-07-11 16:13:21 +040095#define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */
Wolfgang Grandegger52c793f2010-02-22 22:21:17 +000096#define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */
97#define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */
98#define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
Oliver Hartkoppbc05a892014-02-28 16:36:24 +010099#define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */
Nikita Edward Baruzdin4b9e1ba2014-07-11 16:13:22 +0400100#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
Oliver Hartkopp6cfda7f2015-01-05 19:47:43 +0100101#define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
Wolfgang Grandegger39549ee2009-05-15 23:39:29 +0000102
103/*
104 * CAN device statistics
105 */
106struct can_device_stats {
107 __u32 bus_error; /* Bus errors */
108 __u32 error_warning; /* Changes to error warning state */
109 __u32 error_passive; /* Changes to error passive state */
110 __u32 bus_off; /* Changes to bus off state */
111 __u32 arbitration_lost; /* Arbitration lost errors */
112 __u32 restarts; /* CAN controller re-starts */
113};
114
115/*
116 * CAN netlink interface
117 */
118enum {
119 IFLA_CAN_UNSPEC,
120 IFLA_CAN_BITTIMING,
121 IFLA_CAN_BITTIMING_CONST,
122 IFLA_CAN_CLOCK,
123 IFLA_CAN_STATE,
124 IFLA_CAN_CTRLMODE,
125 IFLA_CAN_RESTART_MS,
126 IFLA_CAN_RESTART,
Wolfgang Grandegger52c793f2010-02-22 22:21:17 +0000127 IFLA_CAN_BERR_COUNTER,
Oliver Hartkopp9859ccd2014-02-28 16:36:23 +0100128 IFLA_CAN_DATA_BITTIMING,
129 IFLA_CAN_DATA_BITTIMING_CONST,
Wolfgang Grandegger39549ee2009-05-15 23:39:29 +0000130 __IFLA_CAN_MAX
131};
132
133#define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1)
134
Oliver Hartkopp42193e32014-05-15 20:31:56 +0200135#endif /* !_UAPI_CAN_NETLINK_H */