[PATCH 0/9] can: netlink: add CAN XL

Vincent Mailhol posted 9 patches 3 months, 3 weeks ago
There is a newer version of this series
drivers/net/can/dev/bittiming.c      |  63 +++++++
drivers/net/can/dev/calc_bittiming.c |  36 ++++
drivers/net/can/dev/dev.c            |  20 +-
drivers/net/can/dev/netlink.c        | 357 +++++++++++++++++++++++++++++++++--
include/linux/can/bittiming.h        |  76 +++++++-
include/linux/can/dev.h              |  49 +++--
include/uapi/linux/can/netlink.h     |  35 ++++
7 files changed, 595 insertions(+), 41 deletions(-)
Re: [PATCH 0/9] can: netlink: add CAN XL
Posted by Marc Kleine-Budde 3 months, 3 weeks ago
On 13.10.2025 20:01:22, Vincent Mailhol wrote:
> Following all the refactoring on the CAN netlink done in series [1],
> [2] and [3], this is now time to finally introduce the CAN XL netlink
> interface.
> 
> 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.
> 
> Patch #1 adds a check in can_dev_dropped_skb() to drop CAN FD frames
> when CAN FD is turned off.
> 
> Patch #2 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.

What about merging patches 1+2 now?

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
Re: [PATCH 0/9] can: netlink: add CAN XL
Posted by Vincent Mailhol 3 months, 3 weeks ago
On 17/10/2025 at 22:53, Marc Kleine-Budde wrote:
> On 13.10.2025 20:01:22, Vincent Mailhol wrote:
>> Following all the refactoring on the CAN netlink done in series [1],
>> [2] and [3], this is now time to finally introduce the CAN XL netlink
>> interface.
>>
>> 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.
>>
>> Patch #1 adds a check in can_dev_dropped_skb() to drop CAN FD frames
>> when CAN FD is turned off.
>>
>> Patch #2 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.
> 
> What about merging patches 1+2 now?

If patch 1 had to be squashed, it should probably be in patch 3
"can: netlink: add initial CAN XL support". The MTU workaround as
introduced in patch 1 does not share any of the logic of the
CAN_CTRLMODE_RESTRICTED as introduced in patch 2. Patch 1 is really
just a preparation for CAN XL. You could remove patch 2 from the
series and it will still work (aside from missing one of ISO mandatory
features). Remove patch 1, and the thing breaks apart because it is
required by patch 3.

If I were to squash 1 and 2, I am not sure how I would describe those
two different changes in a single patch message.


Yours sincerely,
Vincent Mailhol
Re: [PATCH 0/9] can: netlink: add CAN XL
Posted by Marc Kleine-Budde 3 months, 3 weeks ago
On 18.10.2025 00:40:22, Vincent Mailhol wrote:
> On 17/10/2025 at 22:53, Marc Kleine-Budde wrote:
> > On 13.10.2025 20:01:22, Vincent Mailhol wrote:
> >> Following all the refactoring on the CAN netlink done in series [1],
> >> [2] and [3], this is now time to finally introduce the CAN XL netlink
> >> interface.
> >>
> >> 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.
> >>
> >> Patch #1 adds a check in can_dev_dropped_skb() to drop CAN FD frames
> >> when CAN FD is turned off.
> >>
> >> Patch #2 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.
> > 
> > What about merging patches 1+2 now?
> 
> If patch 1 had to be squashed,

Sorry - I was offering you to take patches 1+2 into can-next-testing
now.

> it should probably be in patch 3
> "can: netlink: add initial CAN XL support". The MTU workaround as
> introduced in patch 1 does not share any of the logic of the
> CAN_CTRLMODE_RESTRICTED as introduced in patch 2. Patch 1 is really
> just a preparation for CAN XL. You could remove patch 2 from the
> series and it will still work (aside from missing one of ISO mandatory
> features). Remove patch 1, and the thing breaks apart because it is
> required by patch 3.
> 
> If I were to squash 1 and 2, I am not sure how I would describe those
> two different changes in a single patch message.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
Re: [PATCH 0/9] can: netlink: add CAN XL
Posted by Vincent Mailhol 3 months, 3 weeks ago
On 18/10/2025 at 01:02, Marc Kleine-Budde wrote:
> On 18.10.2025 00:40:22, Vincent Mailhol wrote:
>> On 17/10/2025 at 22:53, Marc Kleine-Budde wrote:
>>> On 13.10.2025 20:01:22, Vincent Mailhol wrote:
>>>> Following all the refactoring on the CAN netlink done in series [1],
>>>> [2] and [3], this is now time to finally introduce the CAN XL netlink
>>>> interface.
>>>>
>>>> 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.
>>>>
>>>> Patch #1 adds a check in can_dev_dropped_skb() to drop CAN FD frames
>>>> when CAN FD is turned off.
>>>>
>>>> Patch #2 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.
>>>
>>> What about merging patches 1+2 now?
>>
>> If patch 1 had to be squashed,
> 
> Sorry - I was offering you to take patches 1+2 into can-next-testing
> now.

Ah! This makes more sense. Sorry for misreading you.

Yes, you can pick those two. But could you just push your
can-next-testing branch to git.kernel.org after picking those? This
way, I can rebase my series on top of it instead of dealing with some
complex dependencies.

 
Yours sincerely,
Vincent Mailhol
Re: [PATCH 0/9] can: netlink: add CAN XL
Posted by Marc Kleine-Budde 3 months, 3 weeks ago
On 18.10.2025 01:20:31, Vincent Mailhol wrote:
> >>> What about merging patches 1+2 now?
> >>
> >> If patch 1 had to be squashed,
> > 
> > Sorry - I was offering you to take patches 1+2 into can-next-testing
> > now.
> 
> Ah! This makes more sense. Sorry for misreading you.
> 
> Yes, you can pick those two. But could you just push your
> can-next-testing branch to git.kernel.org after picking those? This
> way, I can rebase my series on top of it instead of dealing with some
> complex dependencies.

Right, taking only part of the series makes things more complicated.
Better keep them for now.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
Re: [PATCH 0/9] can: netlink: add CAN XL
Posted by Vincent Mailhol 3 months, 3 weeks ago
On 13/10/2025 at 20:01, Vincent Mailhol wrote:
> Following all the refactoring on the CAN netlink done in series [1],
> [2] and [3], this is now time to finally introduce the CAN XL netlink
> interface.

I am sending this extra message to give a few additional hints on how
to test.

In addition to the mailing list, I also push this series and the
dummy_can driver to:

  https://git.kernel.org/pub/scm/linux/kernel/git/mailhol/linux.git/log/?h=b4/canxl-netlink

I also have a work in progress for iproute2 here:

  https://git.kernel.org/pub/scm/linux/kernel/git/mailhol/iproute2-next.git/log/?h=canxl-netlink

I will submit the iproute2 series later on, after receiving comments
on this series. For the moment, the iproute2 canxl is only available
through the link above.

To test, after cloning and compiling above branches, do:

  modprobe dummy-can

to load the driver. Then configure it, for example, this is a 500 KB/s
nominal bittiming and a 10 MB/s XL databittiming with TMS on:

  ./ip/ip link set can0 up type can bitrate 500000 xl on xbitrate 10000000 tms on

If you have debug log enabled (e.g. with CONFIG_CAN_DEBUG_DEVICES),
this is what you should see in the kernel log:

  can0: Clock frequency: 160000000
  can0: Maximum bitrate: 20000000
  can0: MTU: 2060
  can0: 
  can0: Control modes:
  can0: 	supported: 0x0001ba22
  can0: 	enabled: 0x00009000
  can0: 	list:
  can0: 		listen-only: off
  can0: 		fd: off
  can0: 		fd-tdc-auto: off
  can0: 		restricted-operation: off
  can0: 		xl: on
  can0: 		xl-tdc-auto: off
  can0: 		xl-tms: on
  can0: 		xl-error-signalling: off
  can0: 
  can0: Classical CAN nominal bittiming:
  can0: 	bitrate: 500000
  can0: 	sample_point: 875
  can0: 	tq: 12
  can0: 	prop_seg: 69
  can0: 	phase_seg1: 70
  can0: 	phase_seg2: 20
  can0: 	sjw: 10
  can0: 	brp: 2
  can0: 
  can0: 
  can0: CAN XL databittiming:
  can0: 	bitrate: 10000000
  can0: 	sample_point: 750
  can0: 	tq: 6
  can0: 	prop_seg: 5
  can0: 	phase_seg1: 6
  can0: 	phase_seg2: 4
  can0: 	sjw: 2
  can0: 	brp: 1
  can0: 	CAN XL PWM:
  can0: 		pwms: 4
  can0: 		pwml: 12
  can0: 		pwmo: 0
  can0: 
  can0: dummy-can is up

Finally, you can use a recent version of can-utils to generate some
traffic. The driver will echo back anything it receives.

I will continue to update the above branches according to the comments
received. See these as work in progress. Use the series as posted on
the mailing if you want something more stable.


Yours sincerely,
Vincent Mailhol