Skip to content

Commit cfe4196

Browse files
committed
include: update includes to latest Linux v6.2 upstream
Update includes to support CAN XL and latest CAN netlink features. Upstream commits: (1a3e3034c049) "can: canxl: introduce CAN XL data structure" (061834624c87) "can: set CANFD_FDF flag in all CAN FD frame structures" (94dfc73e7cf4) "treewide: uapi: Replace zero-length arrays with flexible-array members" (383f0993fc77) "can: netlink: report the CAN controller mode supported flags" (d99755f71a80) "can: netlink: add interface for CAN-FD Transmitter Delay Compensation (TDC)" (63dfe0709643) "can: bittiming: allow TDC{V,O} to be zero and add can_tdc_const::tdc{v,o,f}_min" (626332696d75) "can: raw: add CAN XL support" Signed-off-by: Oliver Hartkopp <[email protected]>
1 parent 999c650 commit cfe4196

File tree

4 files changed

+97
-5
lines changed

4 files changed

+97
-5
lines changed

include/linux/can.h

+53-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
#include <linux/types.h>
5050
#include <linux/socket.h>
51+
#include <linux/stddef.h> /* for offsetof */
5152

5253
/* controller area network (CAN) kernel definitions */
5354

@@ -60,6 +61,7 @@
6061
#define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
6162
#define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */
6263
#define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */
64+
#define CANXL_PRIO_MASK CAN_SFF_MASK /* 11 bit priority mask */
6365

6466
/*
6567
* Controller Area Network Identifier structure
@@ -73,6 +75,7 @@ typedef __u32 canid_t;
7375

7476
#define CAN_SFF_ID_BITS 11
7577
#define CAN_EFF_ID_BITS 29
78+
#define CANXL_PRIO_BITS CAN_SFF_ID_BITS
7679

7780
/*
7881
* Controller Area Network Error Message Frame Mask structure
@@ -91,6 +94,16 @@ typedef __u32 can_err_mask_t;
9194
#define CANFD_MAX_DLC 15
9295
#define CANFD_MAX_DLEN 64
9396

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+
94107
/**
95108
* struct can_frame - Classical CAN frame structure (aka CAN 2.0B)
96109
* @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
@@ -141,8 +154,8 @@ struct can_frame {
141154
* When this is done the former differentiation via CAN_MTU / CANFD_MTU gets
142155
* lost. CANFD_FDF allows programmers to mark CAN FD frames in the case of
143156
* using struct canfd_frame for mixed CAN / CAN FD content (dual use).
144-
* N.B. the Kernel APIs do NOT provide mixed CAN / CAN FD content inside of
145-
* struct canfd_frame therefore the CANFD_FDF flag is disregarded by Linux.
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.
146159
*/
147160
#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
148161
#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
@@ -166,8 +179,46 @@ struct canfd_frame {
166179
__u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
167180
};
168181

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+
/**
197+
* struct canxl_frame - CAN with e'X'tended frame 'L'ength frame structure
198+
* @prio: 11 bit arbitration priority with zero'ed CAN_*_FLAG flags
199+
* @flags: additional flags for CAN XL
200+
* @sdt: SDU (service data unit) type
201+
* @len: frame payload length in byte (CANXL_MIN_DLEN .. CANXL_MAX_DLEN)
202+
* @af: acceptance field
203+
* @data: CAN XL frame payload (CANXL_MIN_DLEN .. CANXL_MAX_DLEN byte)
204+
*
205+
* @prio shares the same position as @can_id from struct can[fd]_frame.
206+
*/
207+
struct canxl_frame {
208+
canid_t prio; /* 11 bit priority for arbitration (canid_t) */
209+
__u8 flags; /* additional flags for CAN XL */
210+
__u8 sdt; /* SDU (service data unit) type */
211+
__u16 len; /* frame payload length in byte */
212+
__u32 af; /* acceptance field */
213+
__u8 data[CANXL_MAX_DLEN];
214+
};
215+
169216
#define CAN_MTU (sizeof(struct can_frame))
170217
#define CANFD_MTU (sizeof(struct canfd_frame))
218+
#define CANXL_MTU (sizeof(struct canxl_frame))
219+
#define CANXL_HDR_SIZE (offsetof(struct canxl_frame, data))
220+
#define CANXL_MIN_MTU (CANXL_HDR_SIZE + 64)
221+
#define CANXL_MAX_MTU CANXL_MTU
171222

172223
/* particular protocols of the protocol family PF_CAN */
173224
#define CAN_RAW 1 /* RAW sockets */

include/linux/can/bcm.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct bcm_msg_head {
7171
struct bcm_timeval ival1, ival2;
7272
canid_t can_id;
7373
__u32 nframes;
74-
struct can_frame frames[0];
74+
struct can_frame frames[];
7575
};
7676

7777
enum {

include/linux/can/netlink.h

+42-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ struct can_ctrlmode {
101101
#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
102102
#define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
103103
#define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */
104+
#define CAN_CTRLMODE_TDC_AUTO 0x200 /* CAN transiver automatically calculates TDCV */
105+
#define CAN_CTRLMODE_TDC_MANUAL 0x400 /* TDCV is manually set up by user */
104106

105107
/*
106108
* CAN device statistics
@@ -134,10 +136,48 @@ enum {
134136
IFLA_CAN_BITRATE_CONST,
135137
IFLA_CAN_DATA_BITRATE_CONST,
136138
IFLA_CAN_BITRATE_MAX,
137-
__IFLA_CAN_MAX
139+
IFLA_CAN_TDC,
140+
IFLA_CAN_CTRLMODE_EXT,
141+
142+
/* add new constants above here */
143+
__IFLA_CAN_MAX,
144+
IFLA_CAN_MAX = __IFLA_CAN_MAX - 1
138145
};
139146

140-
#define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1)
147+
/*
148+
* CAN FD Transmitter Delay Compensation (TDC)
149+
*
150+
* Please refer to struct can_tdc_const and can_tdc in
151+
* include/linux/can/bittiming.h for further details.
152+
*/
153+
enum {
154+
IFLA_CAN_TDC_UNSPEC,
155+
IFLA_CAN_TDC_TDCV_MIN, /* u32 */
156+
IFLA_CAN_TDC_TDCV_MAX, /* u32 */
157+
IFLA_CAN_TDC_TDCO_MIN, /* u32 */
158+
IFLA_CAN_TDC_TDCO_MAX, /* u32 */
159+
IFLA_CAN_TDC_TDCF_MIN, /* u32 */
160+
IFLA_CAN_TDC_TDCF_MAX, /* u32 */
161+
IFLA_CAN_TDC_TDCV, /* u32 */
162+
IFLA_CAN_TDC_TDCO, /* u32 */
163+
IFLA_CAN_TDC_TDCF, /* u32 */
164+
165+
/* add new constants above here */
166+
__IFLA_CAN_TDC,
167+
IFLA_CAN_TDC_MAX = __IFLA_CAN_TDC - 1
168+
};
169+
170+
/*
171+
* IFLA_CAN_CTRLMODE_EXT nest: controller mode extended parameters
172+
*/
173+
enum {
174+
IFLA_CAN_CTRLMODE_UNSPEC,
175+
IFLA_CAN_CTRLMODE_SUPPORTED, /* u32 */
176+
177+
/* add new constants above here */
178+
__IFLA_CAN_CTRLMODE,
179+
IFLA_CAN_CTRLMODE_MAX = __IFLA_CAN_CTRLMODE - 1
180+
};
141181

142182
/* u16 termination range: 1..65535 Ohms */
143183
#define CAN_TERMINATION_DISABLED 0

include/linux/can/raw.h

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum {
6262
CAN_RAW_RECV_OWN_MSGS, /* receive my own msgs (default:off) */
6363
CAN_RAW_FD_FRAMES, /* allow CAN FD frames (default:off) */
6464
CAN_RAW_JOIN_FILTERS, /* all filters must match to trigger */
65+
CAN_RAW_XL_FRAMES, /* allow CAN XL frames (default:off) */
6566
};
6667

6768
#endif /* !_UAPI_CAN_RAW_H */

0 commit comments

Comments
 (0)