aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2012-10-09 04:48:41 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2012-10-10 16:24:21 -0400
commit922cd657c95fe3e4214d68a958e98288b7a55bba (patch)
treed55095ac1cba7e4e9c715cadb932045e46bb953c /include/uapi
parent85457685e0e314f6902caaef976b3fd8ef4f51b4 (diff)
UAPI: (Scripted) Disintegrate include/linux/can
Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Michael Kerrisk <mtk.manpages@gmail.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Dave Jones <davej@redhat.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'include/uapi')
-rw-r--r--include/uapi/linux/can/Kbuild5
-rw-r--r--include/uapi/linux/can/bcm.h66
-rw-r--r--include/uapi/linux/can/error.h91
-rw-r--r--include/uapi/linux/can/gw.h162
-rw-r--r--include/uapi/linux/can/netlink.h122
-rw-r--r--include/uapi/linux/can/raw.h30
6 files changed, 476 insertions, 0 deletions
diff --git a/include/uapi/linux/can/Kbuild b/include/uapi/linux/can/Kbuild
index aafaa5aa54d..21c91bf25a2 100644
--- a/include/uapi/linux/can/Kbuild
+++ b/include/uapi/linux/can/Kbuild
@@ -1 +1,6 @@
1# UAPI Header export list 1# UAPI Header export list
2header-y += bcm.h
3header-y += error.h
4header-y += gw.h
5header-y += netlink.h
6header-y += raw.h
diff --git a/include/uapi/linux/can/bcm.h b/include/uapi/linux/can/bcm.h
new file mode 100644
index 00000000000..3ebe387fea4
--- /dev/null
+++ b/include/uapi/linux/can/bcm.h
@@ -0,0 +1,66 @@
1/*
2 * linux/can/bcm.h
3 *
4 * Definitions for CAN Broadcast Manager (BCM)
5 *
6 * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
8 * All rights reserved.
9 *
10 */
11
12#ifndef CAN_BCM_H
13#define CAN_BCM_H
14
15#include <linux/types.h>
16#include <linux/can.h>
17
18/**
19 * struct bcm_msg_head - head of messages to/from the broadcast manager
20 * @opcode: opcode, see enum below.
21 * @flags: special flags, see below.
22 * @count: number of frames to send before changing interval.
23 * @ival1: interval for the first @count frames.
24 * @ival2: interval for the following frames.
25 * @can_id: CAN ID of frames to be sent or received.
26 * @nframes: number of frames appended to the message head.
27 * @frames: array of CAN frames.
28 */
29struct bcm_msg_head {
30 __u32 opcode;
31 __u32 flags;
32 __u32 count;
33 struct timeval ival1, ival2;
34 canid_t can_id;
35 __u32 nframes;
36 struct can_frame frames[0];
37};
38
39enum {
40 TX_SETUP = 1, /* create (cyclic) transmission task */
41 TX_DELETE, /* remove (cyclic) transmission task */
42 TX_READ, /* read properties of (cyclic) transmission task */
43 TX_SEND, /* send one CAN frame */
44 RX_SETUP, /* create RX content filter subscription */
45 RX_DELETE, /* remove RX content filter subscription */
46 RX_READ, /* read properties of RX content filter subscription */
47 TX_STATUS, /* reply to TX_READ request */
48 TX_EXPIRED, /* notification on performed transmissions (count=0) */
49 RX_STATUS, /* reply to RX_READ request */
50 RX_TIMEOUT, /* cyclic message is absent */
51 RX_CHANGED /* updated CAN frame (detected content change) */
52};
53
54#define SETTIMER 0x0001
55#define STARTTIMER 0x0002
56#define TX_COUNTEVT 0x0004
57#define TX_ANNOUNCE 0x0008
58#define TX_CP_CAN_ID 0x0010
59#define RX_FILTER_ID 0x0020
60#define RX_CHECK_DLC 0x0040
61#define RX_NO_AUTOTIMER 0x0080
62#define RX_ANNOUNCE_RESUME 0x0100
63#define TX_RESET_MULTI_IDX 0x0200
64#define RX_RTR_FRAME 0x0400
65
66#endif /* CAN_BCM_H */
diff --git a/include/uapi/linux/can/error.h b/include/uapi/linux/can/error.h
new file mode 100644
index 00000000000..7b7148bded7
--- /dev/null
+++ b/include/uapi/linux/can/error.h
@@ -0,0 +1,91 @@
1/*
2 * linux/can/error.h
3 *
4 * Definitions of the CAN error messages to be filtered and passed to the user.
5 *
6 * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
8 * All rights reserved.
9 *
10 */
11
12#ifndef CAN_ERROR_H
13#define CAN_ERROR_H
14
15#define CAN_ERR_DLC 8 /* dlc for error message frames */
16
17/* error class (mask) in can_id */
18#define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */
19#define CAN_ERR_LOSTARB 0x00000002U /* lost arbitration / data[0] */
20#define CAN_ERR_CRTL 0x00000004U /* controller problems / data[1] */
21#define CAN_ERR_PROT 0x00000008U /* protocol violations / data[2..3] */
22#define CAN_ERR_TRX 0x00000010U /* transceiver status / data[4] */
23#define CAN_ERR_ACK 0x00000020U /* received no ACK on transmission */
24#define CAN_ERR_BUSOFF 0x00000040U /* bus off */
25#define CAN_ERR_BUSERROR 0x00000080U /* bus error (may flood!) */
26#define CAN_ERR_RESTARTED 0x00000100U /* controller restarted */
27
28/* arbitration lost in bit ... / data[0] */
29#define CAN_ERR_LOSTARB_UNSPEC 0x00 /* unspecified */
30 /* else bit number in bitstream */
31
32/* error status of CAN-controller / data[1] */
33#define CAN_ERR_CRTL_UNSPEC 0x00 /* unspecified */
34#define CAN_ERR_CRTL_RX_OVERFLOW 0x01 /* RX buffer overflow */
35#define CAN_ERR_CRTL_TX_OVERFLOW 0x02 /* TX buffer overflow */
36#define CAN_ERR_CRTL_RX_WARNING 0x04 /* reached warning level for RX errors */
37#define CAN_ERR_CRTL_TX_WARNING 0x08 /* reached warning level for TX errors */
38#define CAN_ERR_CRTL_RX_PASSIVE 0x10 /* reached error passive status RX */
39#define CAN_ERR_CRTL_TX_PASSIVE 0x20 /* reached error passive status TX */
40 /* (at least one error counter exceeds */
41 /* the protocol-defined level of 127) */
42
43/* error in CAN protocol (type) / data[2] */
44#define CAN_ERR_PROT_UNSPEC 0x00 /* unspecified */
45#define CAN_ERR_PROT_BIT 0x01 /* single bit error */
46#define CAN_ERR_PROT_FORM 0x02 /* frame format error */
47#define CAN_ERR_PROT_STUFF 0x04 /* bit stuffing error */
48#define CAN_ERR_PROT_BIT0 0x08 /* unable to send dominant bit */
49#define CAN_ERR_PROT_BIT1 0x10 /* unable to send recessive bit */
50#define CAN_ERR_PROT_OVERLOAD 0x20 /* bus overload */
51#define CAN_ERR_PROT_ACTIVE 0x40 /* active error announcement */
52#define CAN_ERR_PROT_TX 0x80 /* error occurred on transmission */
53
54/* error in CAN protocol (location) / data[3] */
55#define CAN_ERR_PROT_LOC_UNSPEC 0x00 /* unspecified */
56#define CAN_ERR_PROT_LOC_SOF 0x03 /* start of frame */
57#define CAN_ERR_PROT_LOC_ID28_21 0x02 /* ID bits 28 - 21 (SFF: 10 - 3) */
58#define CAN_ERR_PROT_LOC_ID20_18 0x06 /* ID bits 20 - 18 (SFF: 2 - 0 )*/
59#define CAN_ERR_PROT_LOC_SRTR 0x04 /* substitute RTR (SFF: RTR) */
60#define CAN_ERR_PROT_LOC_IDE 0x05 /* identifier extension */
61#define CAN_ERR_PROT_LOC_ID17_13 0x07 /* ID bits 17-13 */
62#define CAN_ERR_PROT_LOC_ID12_05 0x0F /* ID bits 12-5 */
63#define CAN_ERR_PROT_LOC_ID04_00 0x0E /* ID bits 4-0 */
64#define CAN_ERR_PROT_LOC_RTR 0x0C /* RTR */
65#define CAN_ERR_PROT_LOC_RES1 0x0D /* reserved bit 1 */
66#define CAN_ERR_PROT_LOC_RES0 0x09 /* reserved bit 0 */
67#define CAN_ERR_PROT_LOC_DLC 0x0B /* data length code */
68#define CAN_ERR_PROT_LOC_DATA 0x0A /* data section */
69#define CAN_ERR_PROT_LOC_CRC_SEQ 0x08 /* CRC sequence */
70#define CAN_ERR_PROT_LOC_CRC_DEL 0x18 /* CRC delimiter */
71#define CAN_ERR_PROT_LOC_ACK 0x19 /* ACK slot */
72#define CAN_ERR_PROT_LOC_ACK_DEL 0x1B /* ACK delimiter */
73#define CAN_ERR_PROT_LOC_EOF 0x1A /* end of frame */
74#define CAN_ERR_PROT_LOC_INTERM 0x12 /* intermission */
75
76/* error status of CAN-transceiver / data[4] */
77/* CANH CANL */
78#define CAN_ERR_TRX_UNSPEC 0x00 /* 0000 0000 */
79#define CAN_ERR_TRX_CANH_NO_WIRE 0x04 /* 0000 0100 */
80#define CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05 /* 0000 0101 */
81#define CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06 /* 0000 0110 */
82#define CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07 /* 0000 0111 */
83#define CAN_ERR_TRX_CANL_NO_WIRE 0x40 /* 0100 0000 */
84#define CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50 /* 0101 0000 */
85#define CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60 /* 0110 0000 */
86#define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70 /* 0111 0000 */
87#define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
88
89/* controller specific additional information / data[5..7] */
90
91#endif /* CAN_ERROR_H */
diff --git a/include/uapi/linux/can/gw.h b/include/uapi/linux/can/gw.h
new file mode 100644
index 00000000000..8e1db18c3cb
--- /dev/null
+++ b/include/uapi/linux/can/gw.h
@@ -0,0 +1,162 @@
1/*
2 * linux/can/gw.h
3 *
4 * Definitions for CAN frame Gateway/Router/Bridge
5 *
6 * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Copyright (c) 2011 Volkswagen Group Electronic Research
8 * All rights reserved.
9 *
10 */
11
12#ifndef CAN_GW_H
13#define CAN_GW_H
14
15#include <linux/types.h>
16#include <linux/can.h>
17
18struct rtcanmsg {
19 __u8 can_family;
20 __u8 gwtype;
21 __u16 flags;
22};
23
24/* CAN gateway types */
25enum {
26 CGW_TYPE_UNSPEC,
27 CGW_TYPE_CAN_CAN, /* CAN->CAN routing */
28 __CGW_TYPE_MAX
29};
30
31#define CGW_TYPE_MAX (__CGW_TYPE_MAX - 1)
32
33/* CAN rtnetlink attribute definitions */
34enum {
35 CGW_UNSPEC,
36 CGW_MOD_AND, /* CAN frame modification binary AND */
37 CGW_MOD_OR, /* CAN frame modification binary OR */
38 CGW_MOD_XOR, /* CAN frame modification binary XOR */
39 CGW_MOD_SET, /* CAN frame modification set alternate values */
40 CGW_CS_XOR, /* set data[] XOR checksum into data[index] */
41 CGW_CS_CRC8, /* set data[] CRC8 checksum into data[index] */
42 CGW_HANDLED, /* number of handled CAN frames */
43 CGW_DROPPED, /* number of dropped CAN frames */
44 CGW_SRC_IF, /* ifindex of source network interface */
45 CGW_DST_IF, /* ifindex of destination network interface */
46 CGW_FILTER, /* specify struct can_filter on source CAN device */
47 __CGW_MAX
48};
49
50#define CGW_MAX (__CGW_MAX - 1)
51
52#define CGW_FLAGS_CAN_ECHO 0x01
53#define CGW_FLAGS_CAN_SRC_TSTAMP 0x02
54
55#define CGW_MOD_FUNCS 4 /* AND OR XOR SET */
56
57/* CAN frame elements that are affected by curr. 3 CAN frame modifications */
58#define CGW_MOD_ID 0x01
59#define CGW_MOD_DLC 0x02
60#define CGW_MOD_DATA 0x04
61
62#define CGW_FRAME_MODS 3 /* ID DLC DATA */
63
64#define MAX_MODFUNCTIONS (CGW_MOD_FUNCS * CGW_FRAME_MODS)
65
66struct cgw_frame_mod {
67 struct can_frame cf;
68 __u8 modtype;
69} __attribute__((packed));
70
71#define CGW_MODATTR_LEN sizeof(struct cgw_frame_mod)
72
73struct cgw_csum_xor {
74 __s8 from_idx;
75 __s8 to_idx;
76 __s8 result_idx;
77 __u8 init_xor_val;
78} __attribute__((packed));
79
80struct cgw_csum_crc8 {
81 __s8 from_idx;
82 __s8 to_idx;
83 __s8 result_idx;
84 __u8 init_crc_val;
85 __u8 final_xor_val;
86 __u8 crctab[256];
87 __u8 profile;
88 __u8 profile_data[20];
89} __attribute__((packed));
90
91/* length of checksum operation parameters. idx = index in CAN frame data[] */
92#define CGW_CS_XOR_LEN sizeof(struct cgw_csum_xor)
93#define CGW_CS_CRC8_LEN sizeof(struct cgw_csum_crc8)
94
95/* CRC8 profiles (compute CRC for additional data elements - see below) */
96enum {
97 CGW_CRC8PRF_UNSPEC,
98 CGW_CRC8PRF_1U8, /* compute one additional u8 value */
99 CGW_CRC8PRF_16U8, /* u8 value table indexed by data[1] & 0xF */
100 CGW_CRC8PRF_SFFID_XOR, /* (can_id & 0xFF) ^ (can_id >> 8 & 0xFF) */
101 __CGW_CRC8PRF_MAX
102};
103
104#define CGW_CRC8PRF_MAX (__CGW_CRC8PRF_MAX - 1)
105
106/*
107 * CAN rtnetlink attribute contents in detail
108 *
109 * CGW_XXX_IF (length 4 bytes):
110 * Sets an interface index for source/destination network interfaces.
111 * For the CAN->CAN gwtype the indices of _two_ CAN interfaces are mandatory.
112 *
113 * CGW_FILTER (length 8 bytes):
114 * Sets a CAN receive filter for the gateway job specified by the
115 * struct can_filter described in include/linux/can.h
116 *
117 * CGW_MOD_XXX (length 17 bytes):
118 * Specifies a modification that's done to a received CAN frame before it is
119 * send out to the destination interface.
120 *
121 * <struct can_frame> data used as operator
122 * <u8> affected CAN frame elements
123 *
124 * CGW_CS_XOR (length 4 bytes):
125 * Set a simple XOR checksum starting with an initial value into
126 * data[result-idx] using data[start-idx] .. data[end-idx]
127 *
128 * The XOR checksum is calculated like this:
129 *
130 * xor = init_xor_val
131 *
132 * for (i = from_idx .. to_idx)
133 * xor ^= can_frame.data[i]
134 *
135 * can_frame.data[ result_idx ] = xor
136 *
137 * CGW_CS_CRC8 (length 282 bytes):
138 * Set a CRC8 value into data[result-idx] using a given 256 byte CRC8 table,
139 * a given initial value and a defined input data[start-idx] .. data[end-idx].
140 * Finally the result value is XOR'ed with the final_xor_val.
141 *
142 * The CRC8 checksum is calculated like this:
143 *
144 * crc = init_crc_val
145 *
146 * for (i = from_idx .. to_idx)
147 * crc = crctab[ crc ^ can_frame.data[i] ]
148 *
149 * can_frame.data[ result_idx ] = crc ^ final_xor_val
150 *
151 * The calculated CRC may contain additional source data elements that can be
152 * defined in the handling of 'checksum profiles' e.g. shown in AUTOSAR specs
153 * like http://www.autosar.org/download/R4.0/AUTOSAR_SWS_E2ELibrary.pdf
154 * E.g. the profile_data[] may contain additional u8 values (called DATA_IDs)
155 * that are used depending on counter values inside the CAN frame data[].
156 * So far only three profiles have been implemented for illustration.
157 *
158 * Remark: In general the attribute data is a linear buffer.
159 * Beware of sending unpacked or aligned structs!
160 */
161
162#endif
diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h
new file mode 100644
index 00000000000..14966ddb7df
--- /dev/null
+++ b/include/uapi/linux/can/netlink.h
@@ -0,0 +1,122 @@
1/*
2 * linux/can/netlink.h
3 *
4 * Definitions for the CAN netlink interface
5 *
6 * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
7 *
8 */
9
10#ifndef CAN_NETLINK_H
11#define CAN_NETLINK_H
12
13#include <linux/types.h>
14
15/*
16 * CAN bit-timing parameters
17 *
18 * For further information, please read chapter "8 BIT TIMING
19 * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
20 * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
21 */
22struct can_bittiming {
23 __u32 bitrate; /* Bit-rate in bits/second */
24 __u32 sample_point; /* Sample point in one-tenth of a percent */
25 __u32 tq; /* Time quanta (TQ) in nanoseconds */
26 __u32 prop_seg; /* Propagation segment in TQs */
27 __u32 phase_seg1; /* Phase buffer segment 1 in TQs */
28 __u32 phase_seg2; /* Phase buffer segment 2 in TQs */
29 __u32 sjw; /* Synchronisation jump width in TQs */
30 __u32 brp; /* Bit-rate prescaler */
31};
32
33/*
34 * CAN harware-dependent bit-timing constant
35 *
36 * Used for calculating and checking bit-timing parameters
37 */
38struct can_bittiming_const {
39 char name[16]; /* Name of the CAN controller hardware */
40 __u32 tseg1_min; /* Time segement 1 = prop_seg + phase_seg1 */
41 __u32 tseg1_max;
42 __u32 tseg2_min; /* Time segement 2 = phase_seg2 */
43 __u32 tseg2_max;
44 __u32 sjw_max; /* Synchronisation jump width */
45 __u32 brp_min; /* Bit-rate prescaler */
46 __u32 brp_max;
47 __u32 brp_inc;
48};
49
50/*
51 * CAN clock parameters
52 */
53struct can_clock {
54 __u32 freq; /* CAN system clock frequency in Hz */
55};
56
57/*
58 * CAN operational and error states
59 */
60enum can_state {
61 CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */
62 CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */
63 CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */
64 CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */
65 CAN_STATE_STOPPED, /* Device is stopped */
66 CAN_STATE_SLEEPING, /* Device is sleeping */
67 CAN_STATE_MAX
68};
69
70/*
71 * CAN bus error counters
72 */
73struct can_berr_counter {
74 __u16 txerr;
75 __u16 rxerr;
76};
77
78/*
79 * CAN controller mode
80 */
81struct can_ctrlmode {
82 __u32 mask;
83 __u32 flags;
84};
85
86#define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */
87#define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */
88#define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */
89#define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */
90#define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
91
92/*
93 * CAN device statistics
94 */
95struct can_device_stats {
96 __u32 bus_error; /* Bus errors */
97 __u32 error_warning; /* Changes to error warning state */
98 __u32 error_passive; /* Changes to error passive state */
99 __u32 bus_off; /* Changes to bus off state */
100 __u32 arbitration_lost; /* Arbitration lost errors */
101 __u32 restarts; /* CAN controller re-starts */
102};
103
104/*
105 * CAN netlink interface
106 */
107enum {
108 IFLA_CAN_UNSPEC,
109 IFLA_CAN_BITTIMING,
110 IFLA_CAN_BITTIMING_CONST,
111 IFLA_CAN_CLOCK,
112 IFLA_CAN_STATE,
113 IFLA_CAN_CTRLMODE,
114 IFLA_CAN_RESTART_MS,
115 IFLA_CAN_RESTART,
116 IFLA_CAN_BERR_COUNTER,
117 __IFLA_CAN_MAX
118};
119
120#define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1)
121
122#endif /* CAN_NETLINK_H */
diff --git a/include/uapi/linux/can/raw.h b/include/uapi/linux/can/raw.h
new file mode 100644
index 00000000000..a814062b071
--- /dev/null
+++ b/include/uapi/linux/can/raw.h
@@ -0,0 +1,30 @@
1/*
2 * linux/can/raw.h
3 *
4 * Definitions for raw CAN sockets
5 *
6 * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Urs Thuermann <urs.thuermann@volkswagen.de>
8 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
9 * All rights reserved.
10 *
11 */
12
13#ifndef CAN_RAW_H
14#define CAN_RAW_H
15
16#include <linux/can.h>
17
18#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
19
20/* for socket options affecting the socket (not the global system) */
21
22enum {
23 CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */
24 CAN_RAW_ERR_FILTER, /* set filter for error frames */
25 CAN_RAW_LOOPBACK, /* local loopback (default:on) */
26 CAN_RAW_RECV_OWN_MSGS, /* receive my own msgs (default:off) */
27 CAN_RAW_FD_FRAMES, /* allow CAN FD frames (default:off) */
28};
29
30#endif