Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jun 2025 07:09:12 +0000
From:      =?utf-8?B?SsOpcsOpbWllIEpPVVJESU4=?= <jeremie.jourdin@advens.fr>
To:        =?utf-8?B?0K/RgNC+0YHQu9Cw0LIg0JzQsNGI0LrQvg==?= <yaroslaw.mashko@gmail.com>
Cc:        "freebsd-hackers@FreeBSD.org" <freebsd-hackers@freebsd.org>
Subject:   Re: FreeBSD-native CAN Stack and AF_CAN Protocol Family
Message-ID:  <PAYP264MB35185F5D692E54300C95594BFD79A@PAYP264MB3518.FRAP264.PROD.OUTLOOK.COM>
In-Reply-To: <CAMVwyxLnqsw49zhcPjHHEuLLgGc7-yUdgYPN53ABzjE=aPnFyQ@mail.gmail.com>
References:  <PAYP264MB351822F6E68D313174A1C0F3FD7CA@PAYP264MB3518.FRAP264.PROD.OUTLOOK.COM> <CAMVwyxLnqsw49zhcPjHHEuLLgGc7-yUdgYPN53ABzjE=aPnFyQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
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

[-- Attachment #2 --]
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Aptos;
	panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	font-size:12.0pt;
	font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
span.EmailStyle20
	{mso-style-type:personal-reply;
	font-family:"Aptos",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;
	mso-ligatures:none;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
	{page:WordSection1;}
--></style>
</head>
<body lang="FR" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Hello,<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">My CAN controller reports itself as «&nbsp;AHC0512&nbsp;».<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">It is exposed via ACPI and is allocated with a classic bus_alloc_resource as SYS_RES_IOPORT.<br>
<br>
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.<br>
This will make it possible to configure the CAN interface using «&nbsp;ifconfig can0 bitrate 250000 &lt;other_timing_params&gt;&nbsp;»<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">I am working with equipments that use the NMEA2000 standard.
<br>
So in the CAN stack, in addition to supporting CAN_RAW, I hope to implement a more or less complete support for CAN_NMEA2K.<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">Jérémie<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">De&nbsp;:
</span></b><span style="color:black">Ярослав Машко &lt;yaroslaw.mashko@gmail.com&gt;<br>
<b>Date&nbsp;: </b>vendredi, 20 juin 2025 à 17:29<br>
<b>À&nbsp;: </b>Jérémie JOURDIN &lt;jeremie.jourdin@advens.fr&gt;<br>
<b>Cc&nbsp;: </b>freebsd-hackers@FreeBSD.org &lt;freebsd-hackers@freebsd.org&gt;<br>
<b>Objet&nbsp;: </b>Re: FreeBSD-native CAN Stack and AF_CAN Protocol Family<o:p></o:p></span></p>
</div>
<div style="border:solid maroon 1.0pt;padding:2.0pt 2.0pt 2.0pt 2.0pt">
<p class="MsoNormal" style="line-height:12.0pt;background:gold"><strong><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif;color:red">CAUTION:</span></strong><strong><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif;color:black"> External
 Sender.</span></strong><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif;color:black"> This email originated from outside of ADVENS. Do not click on links or open attachments from senders you do not trust.<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">Hello,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">BR<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Yaro<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<div>
<p class="MsoNormal">пт, 20 июн. 2025 г., 15:52 Jérémie JOURDIN &lt;<a href="mailto:jeremie.jourdin@advens.fr">jeremie.jourdin@advens.fr</a>&gt;:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">Hello all,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">I am working on a system (15-current) that requires interaction with a CAN network.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">So far, I have developped a driver for my controller, able to send and receive CAN frames to and from connected devices.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">I’d like to implement a&nbsp;FreeBSD-native&nbsp;CAN network stack that is&nbsp;API-compatible&nbsp;with Linux’s Netlink CAN (netcan).
</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">This would allow us to recompile and use existing Linux userland tools with minimal changes.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">If you believe this development could benefit the community, I would be happy to submit a set of patches (driver + netcan support).</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">We’re considering defining a new Protocol Family, AF_CAN, for this purpose.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">Would it be acceptable to use the first available «&nbsp;AF_VENDORXX&nbsp;» from sys/socket.h&nbsp;?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">I would appreciate your thoughts, advice, and any recommendations you may have on this matter.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:&quot;Courier New&quot;">-- Jérémie
</span><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?PAYP264MB35185F5D692E54300C95594BFD79A>