]> git.itanic.dy.fi Git - linux-stable/commit
can: raw: add CAN XL support
authorOliver Hartkopp <socketcan@hartkopp.net>
Mon, 12 Sep 2022 17:07:25 +0000 (19:07 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 15 Sep 2022 07:08:09 +0000 (09:08 +0200)
commit626332696d7506e8f844a564277bdba2dc78fcb5
treec1532f305f9e94718e2ff618c36452ad6d818dda
parentebf87fc728502244550eaf8819fc785e2014b2ad
can: raw: add CAN XL support

Enable CAN_RAW sockets to read and write CAN XL frames analogue to the
CAN FD extension (new CAN_RAW_XL_FRAMES sockopt).

A CAN XL network interface is capable to handle Classical CAN, CAN FD and
CAN XL frames. When CAN_RAW_XL_FRAMES is enabled, the CAN_RAW socket checks
whether the addressed CAN network interface is capable to handle the
provided CAN frame.

In opposite to the fixed number of bytes for
- CAN frames (CAN_MTU = sizeof(struct can_frame))
- CAN FD frames (CANFD_MTU = sizeof(struct can_frame))
the number of bytes when reading/writing CAN XL frames depends on the
number of data bytes. For efficiency reasons the length of the struct
canxl_frame is truncated to the needed size for read/write operations.
This leads to a calculated size of CANXL_HDR_SIZE + canxl_frame::len which
is enforced on write() operations and guaranteed on read() operations.

NB: Valid length values are 1 .. 2048 (CANXL_MIN_DLEN .. CANXL_MAX_DLEN).

Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/all/20220912170725.120748-8-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include/uapi/linux/can/raw.h
net/can/raw.c