Skip to content

Commit 30e584a

Browse files
Merge pull request #64 from yegorich/update-linux-include-folder
Update Linux headers from kernel 6.13
2 parents c70b57e + d617410 commit 30e584a

File tree

5 files changed

+222
-63
lines changed

5 files changed

+222
-63
lines changed

include/linux/can.h

Lines changed: 115 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
12
/*
23
* linux/can.h
34
*
@@ -42,11 +43,12 @@
4243
* DAMAGE.
4344
*/
4445

45-
#ifndef CAN_H
46-
#define CAN_H
46+
#ifndef _UAPI_CAN_H
47+
#define _UAPI_CAN_H
4748

4849
#include <linux/types.h>
4950
#include <linux/socket.h>
51+
#include <linux/stddef.h> /* for offsetof */
5052

5153
/* controller area network (CAN) kernel definitions */
5254

@@ -59,6 +61,7 @@
5961
#define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
6062
#define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */
6163
#define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */
64+
#define CANXL_PRIO_MASK CAN_SFF_MASK /* 11 bit priority mask */
6265

6366
/*
6467
* Controller Area Network Identifier structure
@@ -72,42 +75,69 @@ typedef __u32 canid_t;
7275

7376
#define CAN_SFF_ID_BITS 11
7477
#define CAN_EFF_ID_BITS 29
78+
#define CANXL_PRIO_BITS CAN_SFF_ID_BITS
7579

7680
/*
7781
* Controller Area Network Error Message Frame Mask structure
7882
*
79-
* bit 0-28 : error class mask (see include/linux/can/error.h)
83+
* bit 0-28 : error class mask (see include/uapi/linux/can/error.h)
8084
* bit 29-31 : set to zero
8185
*/
8286
typedef __u32 can_err_mask_t;
8387

8488
/* CAN payload length and DLC definitions according to ISO 11898-1 */
8589
#define CAN_MAX_DLC 8
90+
#define CAN_MAX_RAW_DLC 15
8691
#define CAN_MAX_DLEN 8
8792

8893
/* CAN FD payload length and DLC definitions according to ISO 11898-7 */
8994
#define CANFD_MAX_DLC 15
9095
#define CANFD_MAX_DLEN 64
9196

97+
/*
98+
* CAN XL payload length and DLC definitions according to ISO 11898-1
99+
* CAN XL DLC ranges from 0 .. 2047 => data length from 1 .. 2048 byte
100+
*/
101+
#define CANXL_MIN_DLC 0
102+
#define CANXL_MAX_DLC 2047
103+
#define CANXL_MAX_DLC_MASK 0x07FF
104+
#define CANXL_MIN_DLEN 1
105+
#define CANXL_MAX_DLEN 2048
106+
92107
/**
93-
* struct can_frame - basic CAN frame structure
94-
* @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
95-
* @can_dlc: frame payload length in byte (0 .. 8) aka data length code
96-
* N.B. the DLC field from ISO 11898-1 Chapter 8.4.2.3 has a 1:1
97-
* mapping of the 'data length code' to the real payload length
98-
* @data: CAN frame payload (up to 8 byte)
108+
* struct can_frame - Classical CAN frame structure (aka CAN 2.0B)
109+
* @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
110+
* @len: CAN frame payload length in byte (0 .. 8)
111+
* @can_dlc: deprecated name for CAN frame payload length in byte (0 .. 8)
112+
* @__pad: padding
113+
* @__res0: reserved / padding
114+
* @len8_dlc: optional DLC value (9 .. 15) at 8 byte payload length
115+
* len8_dlc contains values from 9 .. 15 when the payload length is
116+
* 8 bytes but the DLC value (see ISO 11898-1) is greater then 8.
117+
* CAN_CTRLMODE_CC_LEN8_DLC flag has to be enabled in CAN driver.
118+
* @data: CAN frame payload (up to 8 byte)
99119
*/
100120
struct can_frame {
101121
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
102-
__u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
103-
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
122+
union {
123+
/* CAN frame payload length in byte (0 .. CAN_MAX_DLEN)
124+
* was previously named can_dlc so we need to carry that
125+
* name for legacy support
126+
*/
127+
__u8 len;
128+
__u8 can_dlc; /* deprecated */
129+
} __attribute__((packed)); /* disable padding added in some ABIs */
130+
__u8 __pad; /* padding */
131+
__u8 __res0; /* reserved / padding */
132+
__u8 len8_dlc; /* optional DLC for 8 byte payload length (9 .. 15) */
133+
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
104134
};
105135

106136
/*
107137
* defined bits for canfd_frame.flags
108138
*
109-
* The use of struct canfd_frame implies the Extended Data Length (EDL) bit to
110-
* be set in the CAN frame bitstream on the wire. The EDL bit switch turns
139+
* The use of struct canfd_frame implies the FD Frame (FDF) bit to
140+
* be set in the CAN frame bitstream on the wire. The FDF bit switch turns
111141
* the CAN controllers bitstream processor into the CAN FD mode which creates
112142
* two new options within the CAN FD frame specification:
113143
*
@@ -118,9 +148,18 @@ struct can_frame {
118148
* controller only the CANFD_BRS bit is relevant for real CAN controllers when
119149
* building a CAN FD frame for transmission. Setting the CANFD_ESI bit can make
120150
* sense for virtual CAN interfaces to test applications with echoed frames.
151+
*
152+
* The struct can_frame and struct canfd_frame intentionally share the same
153+
* layout to be able to write CAN frame content into a CAN FD frame structure.
154+
* When this is done the former differentiation via CAN_MTU / CANFD_MTU gets
155+
* lost. CANFD_FDF allows programmers to mark CAN FD frames in the case of
156+
* using struct canfd_frame for mixed CAN / CAN FD content (dual use).
157+
* Since the introduction of CAN XL the CANFD_FDF flag is set in all CAN FD
158+
* frame structures provided by the CAN subsystem of the Linux kernel.
121159
*/
122160
#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
123161
#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
162+
#define CANFD_FDF 0x04 /* mark CAN FD for dual use of struct canfd_frame */
124163

125164
/**
126165
* struct canfd_frame - CAN flexible data rate frame structure
@@ -140,8 +179,51 @@ struct canfd_frame {
140179
__u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
141180
};
142181

182+
/*
183+
* defined bits for canxl_frame.flags
184+
*
185+
* The canxl_frame.flags element contains two bits CANXL_XLF and CANXL_SEC
186+
* and shares the relative position of the struct can[fd]_frame.len element.
187+
* The CANXL_XLF bit ALWAYS needs to be set to indicate a valid CAN XL frame.
188+
* As a side effect setting this bit intentionally breaks the length checks
189+
* for Classical CAN and CAN FD frames.
190+
*
191+
* Undefined bits in canxl_frame.flags are reserved and shall be set to zero.
192+
*/
193+
#define CANXL_XLF 0x80 /* mandatory CAN XL frame flag (must always be set!) */
194+
#define CANXL_SEC 0x01 /* Simple Extended Content (security/segmentation) */
195+
196+
/* the 8-bit VCID is optionally placed in the canxl_frame.prio element */
197+
#define CANXL_VCID_OFFSET 16 /* bit offset of VCID in prio element */
198+
#define CANXL_VCID_VAL_MASK 0xFFUL /* VCID is an 8-bit value */
199+
#define CANXL_VCID_MASK (CANXL_VCID_VAL_MASK << CANXL_VCID_OFFSET)
200+
201+
/**
202+
* struct canxl_frame - CAN with e'X'tended frame 'L'ength frame structure
203+
* @prio: 11 bit arbitration priority with zero'ed CAN_*_FLAG flags / VCID
204+
* @flags: additional flags for CAN XL
205+
* @sdt: SDU (service data unit) type
206+
* @len: frame payload length in byte (CANXL_MIN_DLEN .. CANXL_MAX_DLEN)
207+
* @af: acceptance field
208+
* @data: CAN XL frame payload (CANXL_MIN_DLEN .. CANXL_MAX_DLEN byte)
209+
*
210+
* @prio shares the same position as @can_id from struct can[fd]_frame.
211+
*/
212+
struct canxl_frame {
213+
canid_t prio; /* 11 bit priority for arbitration / 8 bit VCID */
214+
__u8 flags; /* additional flags for CAN XL */
215+
__u8 sdt; /* SDU (service data unit) type */
216+
__u16 len; /* frame payload length in byte */
217+
__u32 af; /* acceptance field */
218+
__u8 data[CANXL_MAX_DLEN];
219+
};
220+
143221
#define CAN_MTU (sizeof(struct can_frame))
144222
#define CANFD_MTU (sizeof(struct canfd_frame))
223+
#define CANXL_MTU (sizeof(struct canxl_frame))
224+
#define CANXL_HDR_SIZE (offsetof(struct canxl_frame, data))
225+
#define CANXL_MIN_MTU (CANXL_HDR_SIZE + 64)
226+
#define CANXL_MAX_MTU CANXL_MTU
145227

146228
/* particular protocols of the protocol family PF_CAN */
147229
#define CAN_RAW 1 /* RAW sockets */
@@ -150,18 +232,11 @@ struct canfd_frame {
150232
#define CAN_TP20 4 /* VAG Transport Protocol v2.0 */
151233
#define CAN_MCNET 5 /* Bosch MCNet */
152234
#define CAN_ISOTP 6 /* ISO 15765-2 Transport Protocol */
153-
#define CAN_NPROTO 7
235+
#define CAN_J1939 7 /* SAE J1939 */
236+
#define CAN_NPROTO 8
154237

155238
#define SOL_CAN_BASE 100
156239

157-
/*
158-
* This typedef was introduced in Linux v3.1-rc2
159-
* (commit 6602a4b net: Make userland include of netlink.h more sane)
160-
* in <linux/socket.h>. It must be duplicated here to make the CAN
161-
* headers self-contained.
162-
*/
163-
typedef unsigned short __kernel_sa_family_t;
164-
165240
/**
166241
* struct sockaddr_can - the sockaddr structure for CAN sockets
167242
* @can_family: address family number AF_CAN.
@@ -175,6 +250,23 @@ struct sockaddr_can {
175250
/* transport protocol class address information (e.g. ISOTP) */
176251
struct { canid_t rx_id, tx_id; } tp;
177252

253+
/* J1939 address information */
254+
struct {
255+
/* 8 byte name when using dynamic addressing */
256+
__u64 name;
257+
258+
/* pgn:
259+
* 8 bit: PS in PDU2 case, else 0
260+
* 8 bit: PF
261+
* 1 bit: DP
262+
* 1 bit: reserved
263+
*/
264+
__u32 pgn;
265+
266+
/* 1 byte address */
267+
__u8 addr;
268+
} j1939;
269+
178270
/* reserved for future CAN protocols address information */
179271
} can_addr;
180272
};
@@ -199,4 +291,4 @@ struct can_filter {
199291

200292
#define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */
201293

202-
#endif /* CAN_H */
294+
#endif /* !_UAPI_CAN_H */

include/linux/can/bcm.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
12
/*
23
* linux/can/bcm.h
34
*
@@ -41,12 +42,17 @@
4142
* DAMAGE.
4243
*/
4344

44-
#ifndef CAN_BCM_H
45-
#define CAN_BCM_H
45+
#ifndef _UAPI_CAN_BCM_H
46+
#define _UAPI_CAN_BCM_H
4647

4748
#include <linux/types.h>
4849
#include <linux/can.h>
4950

51+
struct bcm_timeval {
52+
long tv_sec;
53+
long tv_usec;
54+
};
55+
5056
/**
5157
* struct bcm_msg_head - head of messages to/from the broadcast manager
5258
* @opcode: opcode, see enum below.
@@ -62,10 +68,10 @@ struct bcm_msg_head {
6268
__u32 opcode;
6369
__u32 flags;
6470
__u32 count;
65-
struct timeval ival1, ival2;
71+
struct bcm_timeval ival1, ival2;
6672
canid_t can_id;
6773
__u32 nframes;
68-
struct can_frame frames[0];
74+
struct can_frame frames[];
6975
};
7076

7177
enum {
@@ -94,5 +100,6 @@ enum {
94100
#define RX_ANNOUNCE_RESUME 0x0100
95101
#define TX_RESET_MULTI_IDX 0x0200
96102
#define RX_RTR_FRAME 0x0400
103+
#define CAN_FD_FRAME 0x0800
97104

98-
#endif /* CAN_BCM_H */
105+
#endif /* !_UAPI_CAN_BCM_H */

include/linux/can/error.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
12
/*
23
* linux/can/error.h
34
*
@@ -41,8 +42,8 @@
4142
* DAMAGE.
4243
*/
4344

44-
#ifndef CAN_ERROR_H
45-
#define CAN_ERROR_H
45+
#ifndef _UAPI_CAN_ERROR_H
46+
#define _UAPI_CAN_ERROR_H
4647

4748
#define CAN_ERR_DLC 8 /* dlc for error message frames */
4849

@@ -56,6 +57,8 @@
5657
#define CAN_ERR_BUSOFF 0x00000040U /* bus off */
5758
#define CAN_ERR_BUSERROR 0x00000080U /* bus error (may flood!) */
5859
#define CAN_ERR_RESTARTED 0x00000100U /* controller restarted */
60+
#define CAN_ERR_CNT 0x00000200U /* TX error counter / data[6] */
61+
/* RX error counter / data[7] */
5962

6063
/* arbitration lost in bit ... / data[0] */
6164
#define CAN_ERR_LOSTARB_UNSPEC 0x00 /* unspecified */
@@ -71,6 +74,7 @@
7174
#define CAN_ERR_CRTL_TX_PASSIVE 0x20 /* reached error passive status TX */
7275
/* (at least one error counter exceeds */
7376
/* the protocol-defined level of 127) */
77+
#define CAN_ERR_CRTL_ACTIVE 0x40 /* recovered to error active state */
7478

7579
/* error in CAN protocol (type) / data[2] */
7680
#define CAN_ERR_PROT_UNSPEC 0x00 /* unspecified */
@@ -118,6 +122,22 @@
118122
#define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70 /* 0111 0000 */
119123
#define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
120124

121-
/* controller specific additional information / data[5..7] */
125+
/* data[5] is reserved (do not use) */
122126

123-
#endif /* CAN_ERROR_H */
127+
/* TX error counter / data[6] */
128+
/* RX error counter / data[7] */
129+
130+
/* CAN state thresholds
131+
*
132+
* Error counter Error state
133+
* -----------------------------------
134+
* 0 - 95 Error-active
135+
* 96 - 127 Error-warning
136+
* 128 - 255 Error-passive
137+
* 256 and greater Bus-off
138+
*/
139+
#define CAN_ERROR_WARNING_THRESHOLD 96
140+
#define CAN_ERROR_PASSIVE_THRESHOLD 128
141+
#define CAN_BUS_OFF_THRESHOLD 256
142+
143+
#endif /* _UAPI_CAN_ERROR_H */

0 commit comments

Comments
 (0)