aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/can
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/can')
-rw-r--r--include/linux/can/Kbuild3
-rw-r--r--include/linux/can/bcm.h65
-rw-r--r--include/linux/can/core.h64
-rw-r--r--include/linux/can/error.h93
-rw-r--r--include/linux/can/raw.h31
5 files changed, 256 insertions, 0 deletions
diff --git a/include/linux/can/Kbuild b/include/linux/can/Kbuild
new file mode 100644
index 000000000000..eff898aac02b
--- /dev/null
+++ b/include/linux/can/Kbuild
@@ -0,0 +1,3 @@
1header-y += raw.h
2header-y += bcm.h
3header-y += error.h
diff --git a/include/linux/can/bcm.h b/include/linux/can/bcm.h
new file mode 100644
index 000000000000..7f293273c444
--- /dev/null
+++ b/include/linux/can/bcm.h
@@ -0,0 +1,65 @@
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/**
18 * struct bcm_msg_head - head of messages to/from the broadcast manager
19 * @opcode: opcode, see enum below.
20 * @flags: special flags, see below.
21 * @count: number of frames to send before changing interval.
22 * @ival1: interval for the first @count frames.
23 * @ival2: interval for the following frames.
24 * @can_id: CAN ID of frames to be sent or received.
25 * @nframes: number of frames appended to the message head.
26 * @frames: array of CAN frames.
27 */
28struct bcm_msg_head {
29 __u32 opcode;
30 __u32 flags;
31 __u32 count;
32 struct timeval ival1, ival2;
33 canid_t can_id;
34 __u32 nframes;
35 struct can_frame frames[0];
36};
37
38enum {
39 TX_SETUP = 1, /* create (cyclic) transmission task */
40 TX_DELETE, /* remove (cyclic) transmission task */
41 TX_READ, /* read properties of (cyclic) transmission task */
42 TX_SEND, /* send one CAN frame */
43 RX_SETUP, /* create RX content filter subscription */
44 RX_DELETE, /* remove RX content filter subscription */
45 RX_READ, /* read properties of RX content filter subscription */
46 TX_STATUS, /* reply to TX_READ request */
47 TX_EXPIRED, /* notification on performed transmissions (count=0) */
48 RX_STATUS, /* reply to RX_READ request */
49 RX_TIMEOUT, /* cyclic message is absent */
50 RX_CHANGED /* updated CAN frame (detected content change) */
51};
52
53#define SETTIMER 0x0001
54#define STARTTIMER 0x0002
55#define TX_COUNTEVT 0x0004
56#define TX_ANNOUNCE 0x0008
57#define TX_CP_CAN_ID 0x0010
58#define RX_FILTER_ID 0x0020
59#define RX_CHECK_DLC 0x0040
60#define RX_NO_AUTOTIMER 0x0080
61#define RX_ANNOUNCE_RESUME 0x0100
62#define TX_RESET_MULTI_IDX 0x0200
63#define RX_RTR_FRAME 0x0400
64
65#endif /* CAN_BCM_H */
diff --git a/include/linux/can/core.h b/include/linux/can/core.h
new file mode 100644
index 000000000000..e9ca210ffa5b
--- /dev/null
+++ b/include/linux/can/core.h
@@ -0,0 +1,64 @@
1/*
2 * linux/can/core.h
3 *
4 * Protoypes and definitions for CAN protocol modules using the PF_CAN core
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_CORE_H
16#define CAN_CORE_H
17
18#include <linux/can.h>
19#include <linux/skbuff.h>
20#include <linux/netdevice.h>
21
22#define CAN_VERSION "20071116"
23
24/* increment this number each time you change some user-space interface */
25#define CAN_ABI_VERSION "8"
26
27#define CAN_VERSION_STRING "rev " CAN_VERSION " abi " CAN_ABI_VERSION
28
29#define DNAME(dev) ((dev) ? (dev)->name : "any")
30
31/**
32 * struct can_proto - CAN protocol structure
33 * @type: type argument in socket() syscall, e.g. SOCK_DGRAM.
34 * @protocol: protocol number in socket() syscall.
35 * @capability: capability needed to open the socket, or -1 for no restriction.
36 * @ops: pointer to struct proto_ops for sock->ops.
37 * @prot: pointer to struct proto structure.
38 */
39struct can_proto {
40 int type;
41 int protocol;
42 int capability;
43 struct proto_ops *ops;
44 struct proto *prot;
45};
46
47/* function prototypes for the CAN networklayer core (af_can.c) */
48
49extern int can_proto_register(struct can_proto *cp);
50extern void can_proto_unregister(struct can_proto *cp);
51
52extern int can_rx_register(struct net_device *dev, canid_t can_id,
53 canid_t mask,
54 void (*func)(struct sk_buff *, void *),
55 void *data, char *ident);
56
57extern void can_rx_unregister(struct net_device *dev, canid_t can_id,
58 canid_t mask,
59 void (*func)(struct sk_buff *, void *),
60 void *data);
61
62extern int can_send(struct sk_buff *skb, int loop);
63
64#endif /* CAN_CORE_H */
diff --git a/include/linux/can/error.h b/include/linux/can/error.h
new file mode 100644
index 000000000000..d4127fd9e681
--- /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 occured 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/raw.h b/include/linux/can/raw.h
new file mode 100644
index 000000000000..b2a0f87492c5
--- /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