Re: FreeBSD-native CAN Stack and AF_CAN Protocol Family

From: Jérémie JOURDIN <jeremie.jourdin_at_advens.fr>
Date: Mon, 23 Jun 2025 07:09:12 UTC
Hello,
My CAN controller reports itself as « AHC0512 ».
It is exposed via ACPI and is allocated with a classic bus_alloc_resource as SYS_RES_IOPORT.

For now, bit timing parameters are hardcoded in my driver, and that’s precisely why I want to progress with adding support for socket CAN into the kernel.
This will make it possible to configure the CAN interface using « ifconfig can0 bitrate 250000 <other_timing_params> »
I am working with equipments that use the NMEA2000 standard.
So in the CAN stack, in addition to supporting CAN_RAW, I hope to implement a more or less complete support for CAN_NMEA2K.
Jérémie

De : Ярослав Машко <yaroslaw.mashko@gmail.com>
Date : vendredi, 20 juin 2025 à 17:29
À : Jérémie JOURDIN <jeremie.jourdin@advens.fr>
Cc : freebsd-hackers@FreeBSD.org <freebsd-hackers@freebsd.org>
Objet : Re: FreeBSD-native CAN Stack and AF_CAN Protocol Family
CAUTION: External Sender. This email originated from outside of ADVENS. Do not click on links or open attachments from senders you do not trust.

Hello,

What devices(the setup) do you have? I use FreeBSD regulary and always wanted to start programming some microcontrollers with it. Can i know your configuration. Have to start somewhere, maybe I can copy your config.

BR

Yaro

пт, 20 июн. 2025 г., 15:52 Jérémie JOURDIN <jeremie.jourdin@advens.fr<mailto:jeremie.jourdin@advens.fr>>:
Hello all,

I am working on a system (15-current) that requires interaction with a CAN network.
So far, I have developped a driver for my controller, able to send and receive CAN frames to and from connected devices.

I’d like to implement a FreeBSD-native CAN network stack that is API-compatible with Linux’s Netlink CAN (netcan).
This would allow us to recompile and use existing Linux userland tools with minimal changes.

If you believe this development could benefit the community, I would be happy to submit a set of patches (driver + netcan support).

We’re considering defining a new Protocol Family, AF_CAN, for this purpose.
Would it be acceptable to use the first available « AF_VENDORXX » from sys/socket.h ?

I would appreciate your thoughts, advice, and any recommendations you may have on this matter.

-- Jérémie