From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Cc: linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>,
Robert Nawrath <mbro1689@gmail.com>
Subject: Re: [RFC PATCH 00/14] can: netlink: add CAN XL
Date: Tue, 17 Dec 2024 10:53:53 +0100 [thread overview]
Message-ID: <2bd47866-a995-4359-9639-724cd8a90a43@hartkopp.net> (raw)
In-Reply-To: <c4771c16-c578-4a6d-baee-918fe276dbe9@wanadoo.fr>
Hi Vincent,
On 15.12.24 10:21, Vincent Mailhol wrote:
> I am done reading (and understanding) ISO 11898-1:2024, so let's resume
> the work!
Good! ;-)
> On 04/12/2024 at 16:56, Oliver Hartkopp wrote:
>> Hi Vincent,
>>
>> On 03.12.24 10:45, Vincent Mailhol wrote:
>>
>>>> https://lore.kernel.org/linux-can/20241201112333.6950-1-
>>>> socketcan@hartkopp.net/T/#u
>>>> https://lore.kernel.org/linux-can/20241201112230.6917-1-
>>>> socketcan@hartkopp.net/T/#t
>>
>>> Thanks for all the testing and the fixes. Because of the lack of
>>> testing of this RFC on my side, I was expecting such issues. But I
>>> really appreciate that you took time to investigate and debug, really
>>> helpful! I will make sure to incorporate these fixes in the next
>>> version.
>>
>> I'll send out an extended RFC V2 which is my current test base for you
>> in some minutes.
>>
>> Either for the kernel and iproute2 there are two new patches that add
>> new controlmode flags.
>>
>>> The next series I send will add the pwm and drop the RFC patch.
>>
>> Excellent!
>>
>> I assume it will follow the TDC pattern with
>> CAN_CTRLMODE_XL_PWM_AUTO and CAN_CTRLMODE_XL_PWM_MANUAL
>> or something similar?
>
> I am not sure why we would need a tristate here. The reason why I put
> the tristate for the TDC is because some transceiver (the majority) will
> automatically measure TDCV but some may give the option for the user to
> manually set it.
>
> From what I understand from the specification, PWMO is not something
> which is dynamically measured. If I got it right, it is just the
> remainder whenever the bit time is not a multiple of PWM. Something like
> this:
>
> pwmo = bit_time_in_minimum_time_quantum % pwm;
>
> Same for the PWMS and PWML. I am not yet sure how to calculate those
> (more on this below) but these seem to be calculated once for all (like
> any bittimming value other than the TDCs).
>
> Let me know if I missed something, the PWM is very new to me :)
>
>
> So, for the implementation, I am thinking of:
The PWM stuff is some very CAN XL specific therefore I would suggest to
bring this into the naming too:
>
> 1. Add a CAN_CTRLMODE_PWM mode and a new nest for the PWM in netlink.h
CAN_CTRLMODE_XL_PWM or CAN_CTRLMODE_XLPWM
>
> 2. Add these to bittiming.c:
>
> struct can_pwm {
can_xl_pwm or can_xlpwm
> u32 pwms; /* PWM short phase length */
> u32 pwml; /* PWM long phase length */
> u32 pwmo; /* PWM offset */
that's fine
> };
>
> struct can_pwm_const {
dito
> u32 pwms_max;
> u32 pwml_max;
> u32 pwmo_max;
> };
>
> static inline u32 can_get_pwm(const struct can_pwm *pwm)
> {
> return pwm->pwms + pwm->pwml;
> }
??
>
> The minimum value of all those configurable ranges is already specified
> to be one minimum time quantum (tq min), so I do not think we need a
> field for the minimums.
>
>
> At the moment, I am stuck on the PWM calculation. I do not know how to
> derive good PWMS and PWML values out of the const ranges.
>
> The ISO 11898-1:2024 tells me that CiA 612-2 has recommendations on the
> topic. But getting access to this document requires a subscription
> (which I do not have):
>
>
> https://www.can-cia.org/can-knowledge/cia-612-series-can-xl-guidelines-and-application-notes
>
> Do any of you have access to this document? Or do any of you know a good
> formula for the PWMS and PWML calculation?
I have to check for the referenced document.
Btw. this is some code that shows the idea of how to calculate the PWM
values based on the CAN clock and the XL data bitrate:
if (CanClock_mhz == 100 && XlDatarate_mbps == 5) {
// @5Mbit/s
pwmo = 0;
pwms = 6;
pwml = 14;
} else if (CanClock_mhz == 100) {
// @10Mbit/s
pwmo = 0;
pwms = 3;
pwml = 7;
} else if (CanClock_mhz == 160) {
// @10Mbit/s
pwmo = 0;
pwms = 2;
pwml = 6;
}
For that reason I was thinking about some default calculation provided
by the kernel (CAN_CTRLMODE_XL_PWM_AUTO) and some manual setting if
people want to set the values analog to tseg1 and friends instead of
setting a single bitrate.
Best regards,
Oliver
next prev parent reply other threads:[~2024-12-17 9:54 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-10 15:55 [RFC PATCH 00/14] can: netlink: add CAN XL Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 01/14] can: dev: add struct data_bittiming_params to group FD parameters Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 02/14] can: netlink: replace tabulation by space in assignement Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 03/14] can: bittiming: rename CAN_CTRLMODE_TDC_MASK into CAN_CTRLMODE_FD_TDC_MASK Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 04/14] can: bittiming: rename can_tdc_is_enabled() into can_fd_tdc_is_enabled() Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 05/14] can: netlink: can_changelink(): rename tdc_mask into fd_tdc_flag_provided Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 06/14] can: netlink: make can_tdc_changelink() FD agnostic Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 07/14] can: netlink: add can_dtb_changelink() Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 08/14] can: netlink: add can_validate_tdc() Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 09/14] can: netlink: make can_tdc_get_size() FD agnostic Vincent Mailhol
2024-11-10 15:55 ` [RFC PATCH 10/14] can: netlink: make can_tdc_fill_info() " Vincent Mailhol
2024-11-10 15:56 ` [RFC PATCH 11/14] can: netlink: document which symbols are FD specific Vincent Mailhol
2024-11-10 15:56 ` [RFC PATCH 12/14] can: netlink: add CAN XL support Vincent Mailhol
2024-11-12 8:09 ` Marc Kleine-Budde
2024-11-12 8:31 ` Vincent Mailhol
2024-11-12 8:41 ` Marc Kleine-Budde
2024-12-04 10:56 ` Oliver Hartkopp
2024-12-04 11:15 ` Marc Kleine-Budde
2024-12-04 11:35 ` Oliver Hartkopp
2024-12-04 11:44 ` Marc Kleine-Budde
2024-12-05 8:16 ` Oliver Hartkopp
2024-12-05 9:15 ` Marc Kleine-Budde
2024-12-09 13:13 ` Oliver Hartkopp
2024-12-10 11:58 ` Marc Kleine-Budde
2024-12-15 8:05 ` Vincent Mailhol
2024-11-10 15:56 ` [RFC PATCH 13/14] can: netlink: add userland error messages Vincent Mailhol
2024-11-10 15:56 ` [RFC PATCH 14/14] !!! DO NOT MERGE !!! can: add dummyxl driver Vincent Mailhol
2024-11-11 14:08 ` [RFC PATCH 00/14] can: netlink: add CAN XL Oliver Hartkopp
2024-11-11 15:17 ` Vincent Mailhol
2024-11-11 15:32 ` Oliver Hartkopp
2024-11-21 20:10 ` Oliver Hartkopp
2024-12-01 11:32 ` Oliver Hartkopp
2024-12-03 9:45 ` Vincent Mailhol
2024-12-04 7:56 ` Oliver Hartkopp
2024-12-15 9:21 ` Vincent Mailhol
2024-12-17 9:53 ` Oliver Hartkopp [this message]
2024-12-17 18:17 ` Vincent Mailhol
2024-12-17 20:03 ` Oliver Hartkopp
2024-12-18 9:13 ` Oliver Hartkopp
2025-01-30 5:42 ` Vincent Mailhol
2025-01-30 7:34 ` Marc Kleine-Budde
2024-11-12 8:53 ` Marc Kleine-Budde
2024-11-12 9:24 ` Vincent Mailhol
2024-11-12 10:12 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2bd47866-a995-4359-9639-724cd8a90a43@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mbro1689@gmail.com \
--cc=mkl@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox