OSDN Git Service

can: add optional DLC element to Classical CAN frame structure
authorOliver Hartkopp <socketcan@hartkopp.net>
Tue, 10 Nov 2020 10:18:45 +0000 (11:18 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 20 Nov 2020 08:43:29 +0000 (09:43 +0100)
commitea7800565a128c1adafa1791ce80afd6016fe21c
tree382831535a4110c793d1177432c27b8101dcecee
parentb7d3c0e5930deb3c8f69d7572e17baf2f07c56db
can: add optional DLC element to Classical CAN frame structure

ISO 11898-1 Chapter 8.4.2.3 defines a 4 bit data length code (DLC) table which
maps the DLC to the payload length of the CAN frame in bytes:

    DLC      ->  payload length
    0 .. 8   ->  0 .. 8
    9 .. 15  ->  8

Although the DLC values 8 .. 15 in Classical CAN always result in a payload
length of 8 bytes these DLC values are transparently transmitted on the CAN
bus. As the struct can_frame only provides a 'len' element (formerly 'can_dlc')
which contains the plain payload length ( 0 .. 8 ) of the CAN frame, the raw
DLC is not visible to the application programmer, e.g. for testing use-cases.

To access the raw DLC values 9 .. 15 the len8_dlc element is introduced, which
is only valid when the payload length 'len' is 8 and the DLC is greater than 8.

The len8_dlc element is filled by the CAN interface driver and used for CAN
frame creation by the CAN driver when the CAN_CTRLMODE_CC_LEN8_DLC flag is
supported by the driver and enabled via netlink configuration interface.

Reported-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/r/20201110101852.1973-2-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include/uapi/linux/can.h
include/uapi/linux/can/netlink.h