diff options
Diffstat (limited to 'include/linux/can')
-rw-r--r-- | include/linux/can/core.h | 64 | ||||
-rw-r--r-- | include/linux/can/error.h | 93 |
2 files changed, 157 insertions, 0 deletions
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 | */ | ||
39 | struct 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 | |||
49 | extern int can_proto_register(struct can_proto *cp); | ||
50 | extern void can_proto_unregister(struct can_proto *cp); | ||
51 | |||
52 | extern 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 | |||
57 | extern 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 | |||
62 | extern 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 */ | ||