aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/can.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/can.h')
-rw-r--r--include/linux/can.h59
1 files changed, 54 insertions, 5 deletions
diff --git a/include/linux/can.h b/include/linux/can.h
index 17334c09bd93..1a66cf6112ae 100644
--- a/include/linux/can.h
+++ b/include/linux/can.h
@@ -46,18 +46,67 @@ typedef __u32 canid_t;
46 */ 46 */
47typedef __u32 can_err_mask_t; 47typedef __u32 can_err_mask_t;
48 48
49/* CAN payload length and DLC definitions according to ISO 11898-1 */
50#define CAN_MAX_DLC 8
51#define CAN_MAX_DLEN 8
52
53/* CAN FD payload length and DLC definitions according to ISO 11898-7 */
54#define CANFD_MAX_DLC 15
55#define CANFD_MAX_DLEN 64
56
49/** 57/**
50 * struct can_frame - basic CAN frame structure 58 * struct can_frame - basic CAN frame structure
51 * @can_id: the CAN ID of the frame and CAN_*_FLAG flags, see above. 59 * @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
52 * @can_dlc: the data length field of the CAN frame 60 * @can_dlc: frame payload length in byte (0 .. 8) aka data length code
53 * @data: the CAN frame payload. 61 * N.B. the DLC field from ISO 11898-1 Chapter 8.4.2.3 has a 1:1
62 * mapping of the 'data length code' to the real payload length
63 * @data: CAN frame payload (up to 8 byte)
54 */ 64 */
55struct can_frame { 65struct can_frame {
56 canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ 66 canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
57 __u8 can_dlc; /* data length code: 0 .. 8 */ 67 __u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
58 __u8 data[8] __attribute__((aligned(8))); 68 __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
59}; 69};
60 70
71/*
72 * defined bits for canfd_frame.flags
73 *
74 * As the default for CAN FD should be to support the high data rate in the
75 * payload section of the frame (HDR) and to support up to 64 byte in the
76 * data section (EDL) the bits are only set in the non-default case.
77 * Btw. as long as there's no real implementation for CAN FD network driver
78 * these bits are only preliminary.
79 *
80 * RX: NOHDR/NOEDL - info about received CAN FD frame
81 * ESI - bit from originating CAN controller
82 * TX: NOHDR/NOEDL - control per-frame settings if supported by CAN controller
83 * ESI - bit is set by local CAN controller
84 */
85#define CANFD_NOHDR 0x01 /* frame without high data rate */
86#define CANFD_NOEDL 0x02 /* frame without extended data length */
87#define CANFD_ESI 0x04 /* error state indicator */
88
89/**
90 * struct canfd_frame - CAN flexible data rate frame structure
91 * @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
92 * @len: frame payload length in byte (0 .. CANFD_MAX_DLEN)
93 * @flags: additional flags for CAN FD
94 * @__res0: reserved / padding
95 * @__res1: reserved / padding
96 * @data: CAN FD frame payload (up to CANFD_MAX_DLEN byte)
97 */
98struct canfd_frame {
99 canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
100 __u8 len; /* frame payload length in byte */
101 __u8 flags; /* additional flags for CAN FD */
102 __u8 __res0; /* reserved / padding */
103 __u8 __res1; /* reserved / padding */
104 __u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
105};
106
107#define CAN_MTU (sizeof(struct can_frame))
108#define CANFD_MTU (sizeof(struct canfd_frame))
109
61/* particular protocols of the protocol family PF_CAN */ 110/* particular protocols of the protocol family PF_CAN */
62#define CAN_RAW 1 /* RAW sockets */ 111#define CAN_RAW 1 /* RAW sockets */
63#define CAN_BCM 2 /* Broadcast Manager */ 112#define CAN_BCM 2 /* Broadcast Manager */