[PATCH can-next v8 00/17] can: netlink: add CAN XL support

Marc Kleine-Budde posted 17 patches 5 days, 11 hours ago
drivers/net/can/Kconfig              |  17 ++
drivers/net/can/Makefile             |   1 +
drivers/net/can/dev/bittiming.c      |  63 +++++++
drivers/net/can/dev/calc_bittiming.c | 114 ++++++++++---
drivers/net/can/dev/dev.c            |  42 +++--
drivers/net/can/dev/netlink.c        | 319 ++++++++++++++++++++++++++++++++---
drivers/net/can/dummy_can.c          | 285 +++++++++++++++++++++++++++++++
include/linux/can/bittiming.h        |  81 ++++++++-
include/linux/can/dev.h              |  68 ++++++--
include/uapi/linux/can/netlink.h     |  34 ++++
net/can/raw.c                        |  54 +++++-
11 files changed, 990 insertions(+), 88 deletions(-)
[PATCH can-next v8 00/17] can: netlink: add CAN XL support
Posted by Marc Kleine-Budde 5 days, 11 hours ago
Similarly to how CAN FD reuses the bittiming logic of Classical CAN, CAN XL
also reuses the entirety of CAN FD features, and, on top of that, adds new
features which are specific to CAN XL.

A so-called 'mixed-mode' is intended to have (XL-tolerant) CAN FD nodes and
CAN XL nodes on one CAN segment, where the FD-controllers can talk CC/FD
and the XL-controllers can talk CC/FD/XL. This mixed-mode utilizes the
known error-signalling (ES) for sending CC/FD/XL frames. For CAN FD and CAN
XL the tranceiver delay compensation (TDC) is supported to use common CAN
and CAN-SIG transceivers.

The CANXL-only mode disables the error-signalling in the CAN XL controller.
This mode does not allow CC/FD frames to be sent but additionally offers a
CAN XL transceiver mode switching (TMS) to send CAN XL frames with up to
20Mbit/s data rate. The TMS utilizes a PWM configuration which is added to
the netlink interface.

Configured with CAN_CTRLMODE_FD and CAN_CTRLMODE_XL this leads to:

FD=0 XL=0 CC-only mode         (ES=1)
FD=1 XL=0 FD/CC mixed-mode     (ES=1)
FD=1 XL=1 XL/FD/CC mixed-mode  (ES=1)
FD=0 XL=1 XL-only mode         (ES=0, TMS optional)

Patch #1 print defined ctrlmode strings capitalized to increase the
readability and to be in line with the 'ip' tool (iproute2).

Patch #2 is a small clean-up which makes can_calc_bittiming() use
NL_SET_ERR_MSG() instead of netdev_err().

Patch #3 adds a check in can_dev_dropped_skb() to drop CAN FD frames
when CAN FD is turned off.

Patch #4 adds CAN_CTRLMODE_RESTRICTED. Note that contrary to the other
CAN_CTRL_MODE_XL_* that are introduced in the later patches, this control
mode is not specific to CAN XL. The nuance is that because this restricted
mode was only added in ISO 11898-1:2024, it is made mandatory for CAN XL
devices but optional for other protocols. This is why this patch is added
as a preparation before introducing the core CAN XL logic.

Patch #5 adds all the CAN XL features which are inherited from CAN FD: the
nominal bittiming, the data bittiming and the TDC.

Patch #6 add a new CAN_CTRLMODE_XL_TMS control mode which is specific to
CAN XL to enable the transceiver mode switching (TMS) in XL-only mode.

Patch #7 adds a check in can_dev_dropped_skb() to drop CAN CC/FD frames
when the CAN XL controller is in CAN XL-only mode. The introduced
can_dev_in_xl_only_mode() function also determines the error-signalling
configuration for the CAN XL controllers.

Patch #8 to #11 add the PWM logic for the CAN XL TMS mode.

Patch #12 to #14 add different default sample-points for standard CAN and
CAN SIG transceivers (with TDC) and CAN XL transceivers using PWM in the
CAN XL TMS mode.

Patch #15 add a dummy_can driver for netlink testing and debugging.

Patch #16 check CAN frame type (CC/FD/XL) when writing those frames to the
CAN_RAW socket and reject them if it's not supported by the CAN interface.

Patch #17 increase the resolution when printing the bitrate error and
round-up the value to 0.01% in the case the resolution would still provide
values which would lead to 0.00%.

---
Changes in v8:
- Patch #12: replace "nominal" by "reference" instead of removing "nominal"

---
Oliver Hartkopp (4):
      can: dev: can_get_ctrlmode_str: use capitalized ctrlmode strings
      can: dev: can_dev_dropped_skb: drop CC/FD frames in CANXL-only mode
      can: raw: instantly reject unsupported CAN frames
      can: dev: print bitrate error with two decimal digits

Vincent Mailhol (13):
      can: bittiming: apply NL_SET_ERR_MSG() to can_calc_bittiming()
      can: dev: can_dev_dropped_skb: drop CAN FD skbs if FD is off
      can: netlink: add CAN_CTRLMODE_RESTRICTED
      can: netlink: add initial CAN XL support
      can: netlink: add CAN_CTRLMODE_XL_TMS flag
      can: bittiming: add PWM parameters
      can: bittiming: add PWM validation
      can: calc_bittiming: add PWM calculation
      can: netlink: add PWM netlink interface
      can: calc_bittiming: replace misleading "nominal" by "reference"
      can: calc_bittiming: add can_calc_sample_point_nrz()
      can: calc_bittiming: add can_calc_sample_point_pwm()
      can: add dummy_can driver

 drivers/net/can/Kconfig              |  17 ++
 drivers/net/can/Makefile             |   1 +
 drivers/net/can/dev/bittiming.c      |  63 +++++++
 drivers/net/can/dev/calc_bittiming.c | 114 ++++++++++---
 drivers/net/can/dev/dev.c            |  42 +++--
 drivers/net/can/dev/netlink.c        | 319 ++++++++++++++++++++++++++++++++---
 drivers/net/can/dummy_can.c          | 285 +++++++++++++++++++++++++++++++
 include/linux/can/bittiming.h        |  81 ++++++++-
 include/linux/can/dev.h              |  68 ++++++--
 include/uapi/linux/can/netlink.h     |  34 ++++
 net/can/raw.c                        |  54 +++++-
 11 files changed, 990 insertions(+), 88 deletions(-)
---
base-commit: ab084f0b8d6d2ee4b1c6a28f39a2a7430bdfa7f0
change-id: 20251126-canxl-637fa388c916

Best regards,
--  
Marc Kleine-Budde <mkl@pengutronix.de>