Linux CAN drivers development
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Cc: linux-can@vger.kernel.org,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	 Robert Nawrath <mbro1689@gmail.com>
Subject: Re: [RFC PATCH 12/14] can: netlink: add CAN XL support
Date: Tue, 12 Nov 2024 09:41:14 +0100	[thread overview]
Message-ID: <20241112-towering-ruby-pony-d93ab0-mkl@pengutronix.de> (raw)
In-Reply-To: <CAMZ6RqKQLaEtgoLOAa3NHJotyHcAo=7ObXf=7tLh_DJ_QTCKOg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3542 bytes --]

On 12.11.2024 17:31:38, Vincent Mailhol wrote:
> On Tue. 12 Nov. 2024 at 17:09, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> > On 11.11.2024 00:56:01, Vincent Mailhol wrote:
> > > Add the netlink interface for CAN XL.
> > >
> > > Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> > > ---
> > >  drivers/net/can/dev/netlink.c    | 78 +++++++++++++++++++++++++++++---
> > >  include/linux/can/bittiming.h    |  2 +
> > >  include/linux/can/dev.h          | 13 ++++--
> > >  include/uapi/linux/can/netlink.h |  7 +++
> > >  4 files changed, 90 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
> > > index 6c3fa5aa22cf..3c89b304c5b8 100644
> > > --- a/drivers/net/can/dev/netlink.c
> > > +++ b/drivers/net/can/dev/netlink.c
> > > @@ -22,6 +22,9 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = {
> > >       [IFLA_CAN_TERMINATION] = { .type = NLA_U16 },
> > >       [IFLA_CAN_TDC] = { .type = NLA_NESTED },
> > >       [IFLA_CAN_CTRLMODE_EXT] = { .type = NLA_NESTED },
> > > +     [IFLA_CAN_XL_DATA_BITTIMING] = { .len = sizeof(struct can_bittiming) },
> > > +     [IFLA_CAN_XL_DATA_BITTIMING_CONST] = { .len = sizeof(struct can_bittiming_const) },
> > > +     [IFLA_CAN_XL_TDC] = { .type = NLA_NESTED },
> >
> > I haven't looked at the can_xl IP-core docs yet.
> >
> > I don't want to pass "struct can_bittiming_const" via netlink to user
> > space. It's not sufficient to fully describe the CAN-FD controllers, as
> > tseg1_min cannot equally divided into prop_seg and phase_seg1.
> >
> > Better make it a NLA_NESTED, as you did for the TDC.
> 
> I considered this point. The fact is that the code to handle the "struct
> can_bittiming_const" already exists. And so here, I am left with two
> choices:
> 
>   - small code refactor and reuse the existing
> 
>   - rewrite the full thing just for CAN XL and have two different ways
>     to handle the constant bittiming: one for Classical CAN and CAN FD
>     and the other for CAN XL.
> 
> For consistency, I chose the former approach which is the least
> disruptive. If you want this nested, what about an in-between
> solution:
> 
>   IFLA_CAN_XL /* NLA_NESTED */
>     + IFLA_CAN_DATA_BITTIMING /* struct can_bittiming */
>     + IFLA_CAN_DATA_BITTIMING_CONST /* struct can_bittiming */
>     + IFLA_CAN_TDC /* NLA_NESTED */
>         + IFLA_CAN_TDC_TDCV_MIN
>         + IFLA_CAN_TDC_TDCV_MAX
>         + (all other TDC nested values)...
> 
> This way, we can still keep most of the current CAN(-FD) logic, and if
> we want to add one value, we can add it as a standalone within the
> IFLA_CAN_XL nest.
> 
> Also, the main reason for not creating the nest was that I thought
> that the current bittiming API was stable. I was not aware of the
> current flaw on how to divide tseg1_min. Maybe we should first discuss
> how to solve this issue for CAN FD?

The bittiming API is stable. I thought of adding an additional nested
type to hold all relevant information. Luckily it's only from kernel ->
user space. So we can pass both, the old struct can_bittiming_const and
the new nested type and the user space can decide which one to use.

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   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2024-11-12  8:41 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 [this message]
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
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=20241112-towering-ruby-pony-d93ab0-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=mbro1689@gmail.com \
    --cc=socketcan@hartkopp.net \
    /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