aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/can
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/can')
-rw-r--r--include/linux/can/Kbuild4
-rw-r--r--include/linux/can/bcm.h67
-rw-r--r--include/linux/can/error.h93
-rw-r--r--include/linux/can/netlink.h124
-rw-r--r--include/linux/can/raw.h31
5 files changed, 319 insertions, 0 deletions
diff --git a/include/linux/can/Kbuild b/include/linux/can/Kbuild
new file mode 100644
index 00000000000..8cb05aae661
--- /dev/null
+++ b/include/linux/can/Kbuild
@@ -0,0 +1,4 @@
1header-y += raw.h
2header-y += bcm.h
3header-y += error.h
4header-y += netlink.h
diff --git a/include/linux/can/bcm.h b/include/linux/can/bcm.h
new file mode 100644
index 00000000000..1432b278c52
--- /dev/null
+++ b/include/linux/can/bcm.h
@@ -0,0 +1,67 @@
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 * Send feedback to <socketcan-users@lists.berlios.de>
11 *
12 */
13
14#ifndef CAN_BCM_H
15#define CAN_BCM_H
16
17#include <linux/types.h>
18
19/**
20 * struct bcm_msg_head - head of messages to/from the broadcast manager
21 * @opcode: opcode, see enum below.
22 * @flags: special flags, see below.
23 * @count: number of frames to send before changing interval.
24 * @ival1: interval for the first @count frames.
25 * @ival2: interval for the following frames.
26 * @can_id: CAN ID of frames to be sent or received.
27 * @nframes: number of frames appended to the message head.
28 * @frames: array of CAN frames.
29 */
30struct bcm_msg_head {
31 __u32 opcode;
32 __u32 flags;
33 __u32 count;
34 struct timeval ival1, ival2;
35 canid_t can_id;
36 __u32 nframes;
37 struct can_frame frames[0];
38};
39
40enum {
41 TX_SETUP = 1, /* create (cyclic) transmission task */
42 TX_DELETE, /* remove (cyclic) transmission task */
43 TX_READ, /* read properties of (cyclic) transmission task */
44 TX_SEND, /* send one CAN frame */
45 RX_SETUP, /* create RX content filter subscription */
46 RX_DELETE, /* remove RX content filter subscription */
47 RX_READ, /* read properties of RX content filter subscription */
48 TX_STATUS, /* reply to TX_READ request */
49 TX_EXPIRED, /* notification on performed transmissions (count=0) */
50 RX_STATUS, /* reply to RX_READ request */
51 RX_TIMEOUT, /* cyclic message is absent */
52 RX_CHANGED /* updated CAN frame (detected content change) */
53};
54
55#define SETTIMER 0x0001
56#define STARTTIMER 0x0002
57#define TX_COUNTEVT 0x0004
58#define TX_ANNOUNCE 0x0008
59#define TX_CP_CAN_ID 0x0010
60#define RX_FILTER_ID 0x0020
61#define RX_CHECK_DLC 0x0040
62#define RX_NO_AUTOTIMER 0x0080
63#define RX_ANNOUNCE_RESUME 0x0100
64#define TX_RESET_MULTI_IDX 0x0200
65#define RX_RTR_FRAME 0x0400
66
67#endif /* CAN_BCM_H */
diff --git a/include/linux/can/error.h b/include/linux/can/error.h
new file mode 100644
index 00000000000..5958074302a
--- /dev/null
+++ b/include/linux/can/error.h
@@ -0,0 +1,93 @@
1/*
2 * linux/can/error.h
3 *
4 * Definitions of the CAN error frame 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 * Send feedback to <socketcan-users@lists.berlios.de>
11 *
12 */
13
14#ifndef CAN_ERROR_H
15#define CAN_ERROR_H
16
17#define CAN_ERR_DLC 8 /* dlc for error frames */
18
19/* error class (mask) in can_id */
20#define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */
21#define CAN_ERR_LOSTARB 0x00000002U /* lost arbitration / data[0] */
22#define CAN_ERR_CRTL 0x00000004U /* controller problems / data[1] */
23#define CAN_ERR_PROT 0x00000008U /* protocol violations / data[2..3] */
24#define CAN_ERR_TRX 0x00000010U /* transceiver status / data[4] */
25#define CAN_ERR_ACK 0x00000020U /* received no ACK on transmission */
26#define CAN_ERR_BUSOFF 0x00000040U /* bus off */
27#define CAN_ERR_BUSERROR 0x00000080U /* bus error (may flood!) */
28#define CAN_ERR_RESTARTED 0x00000100U /* controller restarted */
29
30/* arbitration lost in bit ... / data[0] */
31#define CAN_ERR_LOSTARB_UNSPEC 0x00 /* unspecified */
32 /* else bit number in bitstream */
33
34/* error status of CAN-controller / data[1] */
35#define CAN_ERR_CRTL_UNSPEC 0x00 /* unspecified */
36#define CAN_ERR_CRTL_RX_OVERFLOW 0x01 /* RX buffer overflow */
37#define CAN_ERR_CRTL_TX_OVERFLOW 0x02 /* TX buffer overflow */
38#define CAN_ERR_CRTL_RX_WARNING 0x04 /* reached warning level for RX errors */
39#define CAN_ERR_CRTL_TX_WARNING 0x08 /* reached warning level for TX errors */
40#define CAN_ERR_CRTL_RX_PASSIVE 0x10 /* reached error passive status RX */
41#define CAN_ERR_CRTL_TX_PASSIVE 0x20 /* reached error passive status TX */
42 /* (at least one error counter exceeds */
43 /* the protocol-defined level of 127) */
44
45/* error in CAN protocol (type) / data[2] */
46#define CAN_ERR_PROT_UNSPEC 0x00 /* unspecified */
47#define CAN_ERR_PROT_BIT 0x01 /* single bit error */
48#define CAN_ERR_PROT_FORM 0x02 /* frame format error */
49#define CAN_ERR_PROT_STUFF 0x04 /* bit stuffing error */
50#define CAN_ERR_PROT_BIT0 0x08 /* unable to send dominant bit */
51#define CAN_ERR_PROT_BIT1 0x10 /* unable to send recessive bit */
52#define CAN_ERR_PROT_OVERLOAD 0x20 /* bus overload */
53#define CAN_ERR_PROT_ACTIVE 0x40 /* active error announcement */
54#define CAN_ERR_PROT_TX 0x80 /* error occurred on transmission */
55
56/* error in CAN protocol (location) / data[3] */
57#define CAN_ERR_PROT_LOC_UNSPEC 0x00 /* unspecified */
58#define CAN_ERR_PROT_LOC_SOF 0x03 /* start of frame */
59#define CAN_ERR_PROT_LOC_ID28_21 0x02 /* ID bits 28 - 21 (SFF: 10 - 3) */
60#define CAN_ERR_PROT_LOC_ID20_18 0x06 /* ID bits 20 - 18 (SFF: 2 - 0 )*/
61#define CAN_ERR_PROT_LOC_SRTR 0x04 /* substitute RTR (SFF: RTR) */
62#define CAN_ERR_PROT_LOC_IDE 0x05 /* identifier extension */
63#define CAN_ERR_PROT_LOC_ID17_13 0x07 /* ID bits 17-13 */
64#define CAN_ERR_PROT_LOC_ID12_05 0x0F /* ID bits 12-5 */
65#define CAN_ERR_PROT_LOC_ID04_00 0x0E /* ID bits 4-0 */
66#define CAN_ERR_PROT_LOC_RTR 0x0C /* RTR */
67#define CAN_ERR_PROT_LOC_RES1 0x0D /* reserved bit 1 */
68#define CAN_ERR_PROT_LOC_RES0 0x09 /* reserved bit 0 */
69#define CAN_ERR_PROT_LOC_DLC 0x0B /* data length code */
70#define CAN_ERR_PROT_LOC_DATA 0x0A /* data section */
71#define CAN_ERR_PROT_LOC_CRC_SEQ 0x08 /* CRC sequence */
72#define CAN_ERR_PROT_LOC_CRC_DEL 0x18 /* CRC delimiter */
73#define CAN_ERR_PROT_LOC_ACK 0x19 /* ACK slot */
74#define CAN_ERR_PROT_LOC_ACK_DEL 0x1B /* ACK delimiter */
75#define CAN_ERR_PROT_LOC_EOF 0x1A /* end of frame */
76#define CAN_ERR_PROT_LOC_INTERM 0x12 /* intermission */
77
78/* error status of CAN-transceiver / data[4] */
79/* CANH CANL */
80#define CAN_ERR_TRX_UNSPEC 0x00 /* 0000 0000 */
81#define CAN_ERR_TRX_CANH_NO_WIRE 0x04 /* 0000 0100 */
82#define CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05 /* 0000 0101 */
83#define CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06 /* 0000 0110 */
84#define CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07 /* 0000 0111 */
85#define CAN_ERR_TRX_CANL_NO_WIRE 0x40 /* 0100 0000 */
86#define CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50 /* 0101 0000 */
87#define CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60 /* 0110 0000 */
88#define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70 /* 0111 0000 */
89#define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
90
91/* controller specific additional information / data[5..7] */
92
93#endif /* CAN_ERROR_H */
diff --git a/include/linux/can/netlink.h b/include/linux/can/netlink.h
new file mode 100644
index 00000000000..34542d374dd
--- /dev/null
+++ b/include/linux/can/netlink.h
@@ -0,0 +1,124 @@
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 * Send feedback to <socketcan-users@lists.berlios.de>
9 *
10 */
11
12#ifndef CAN_NETLINK_H
13#define CAN_NETLINK_H
14
15#include <linux/types.h>
16
17/*
18 * CAN bit-timing parameters
19 *
20 * For further information, please read chapter "8 BIT TIMING
21 * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
22 * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
23 */
24struct can_bittiming {
25 __u32 bitrate; /* Bit-rate in bits/second */
26 __u32 sample_point; /* Sample point in one-tenth of a percent */
27 __u32 tq; /* Time quanta (TQ) in nanoseconds */
28 __u32 prop_seg; /* Propagation segment in TQs */
29 __u32 phase_seg1; /* Phase buffer segment 1 in TQs */
30 __u32 phase_seg2; /* Phase buffer segment 2 in TQs */
31 __u32 sjw; /* Synchronisation jump width in TQs */
32 __u32 brp; /* Bit-rate prescaler */
33};
34
35/*
36 * CAN harware-dependent bit-timing constant
37 *
38 * Used for calculating and checking bit-timing parameters
39 */
40struct can_bittiming_const {
41 char name[16]; /* Name of the CAN controller hardware */
42 __u32 tseg1_min; /* Time segement 1 = prop_seg + phase_seg1 */
43 __u32 tseg1_max;
44 __u32 tseg2_min; /* Time segement 2 = phase_seg2 */
45 __u32 tseg2_max;
46 __u32 sjw_max; /* Synchronisation jump width */
47 __u32 brp_min; /* Bit-rate prescaler */
48 __u32 brp_max;
49 __u32 brp_inc;
50};
51
52/*
53 * CAN clock parameters
54 */
55struct can_clock {
56 __u32 freq; /* CAN system clock frequency in Hz */
57};
58
59/*
60 * CAN operational and error states
61 */
62enum can_state {
63 CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */
64 CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */
65 CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */
66 CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */
67 CAN_STATE_STOPPED, /* Device is stopped */
68 CAN_STATE_SLEEPING, /* Device is sleeping */
69 CAN_STATE_MAX
70};
71
72/*
73 * CAN bus error counters
74 */
75struct can_berr_counter {
76 __u16 txerr;
77 __u16 rxerr;
78};
79
80/*
81 * CAN controller mode
82 */
83struct can_ctrlmode {
84 __u32 mask;
85 __u32 flags;
86};
87
88#define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */
89#define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */
90#define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */
91#define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */
92#define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
93
94/*
95 * CAN device statistics
96 */
97struct can_device_stats {
98 __u32 bus_error; /* Bus errors */
99 __u32 error_warning; /* Changes to error warning state */
100 __u32 error_passive; /* Changes to error passive state */
101 __u32 bus_off; /* Changes to bus off state */
102 __u32 arbitration_lost; /* Arbitration lost errors */
103 __u32 restarts; /* CAN controller re-starts */
104};
105
106/*
107 * CAN netlink interface
108 */
109enum {
110 IFLA_CAN_UNSPEC,
111 IFLA_CAN_BITTIMING,
112 IFLA_CAN_BITTIMING_CONST,
113 IFLA_CAN_CLOCK,
114 IFLA_CAN_STATE,
115 IFLA_CAN_CTRLMODE,
116 IFLA_CAN_RESTART_MS,
117 IFLA_CAN_RESTART,
118 IFLA_CAN_BERR_COUNTER,
119 __IFLA_CAN_MAX
120};
121
122#define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1)
123
124#endif /* CAN_NETLINK_H */
diff --git a/include/linux/can/raw.h b/include/linux/can/raw.h
new file mode 100644
index 00000000000..b2a0f87492c
--- /dev/null
+++ b/include/linux/can/raw.h
@@ -0,0 +1,31 @@
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 * Send feedback to <socketcan-users@lists.berlios.de>
12 *
13 */
14
15#ifndef CAN_RAW_H
16#define CAN_RAW_H
17
18#include <linux/can.h>
19
20#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
21
22/* for socket options affecting the socket (not the global system) */
23
24enum {
25 CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */
26 CAN_RAW_ERR_FILTER, /* set filter for error frames */
27 CAN_RAW_LOOPBACK, /* local loopback (default:on) */
28 CAN_RAW_RECV_OWN_MSGS /* receive my own msgs (default:off) */
29};
30
31#endif