All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Ramesh Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>,
	"mkl@pengutronix.de" <mkl@pengutronix.de>,
	"wg@grandegger.com" <wg@grandegger.com>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Re: [PATCH v3] can: rcar_canfd: Add Renesas R-Car CAN FD driver
Date: Fri, 18 Mar 2016 20:44:48 +0100	[thread overview]
Message-ID: <56EC5AB0.1080107@hartkopp.net> (raw)
In-Reply-To: <SG2PR06MB1038AD3F5496E8B833098229C38C0@SG2PR06MB1038.apcprd06.prod.outlook.com>

On 03/18/2016 02:23 PM, Ramesh Shanmugasundaram wrote:

>> Does it make sense to create some kind of 'configuration block'
>> consisting of the two bitrates and the ctrlmode? So that when the
>> (nominal) bitrate is provided the data bitrate and the ctrlmode is cleared
>> (aka set to initial values).
>
> "configuration block" would provide better clarity but I wonder if we need to enforce this as "can" may be the only link type forcing this.

But only CAN has these strange dependencies.

> Will it impact CAN 2.0 only controllers?
>
> ip link set can0 type can bitrate 1000000
> ip link set can0 up

I can't see why.

This example is still valid as up/down has nothing to do with bitrate & 
ctrlmode settings.

> Are other CAN FD controllers that are out in the market OK with it?

Why not? I don't see a direct impact on controllers - it's only the 
configuration interface to talk about.

> I mean if they have userland apis/gui/docs for their controller would they need an update?

The effect would be that the bitrate(s) and the ctrlmode would have to 
be provided in one netlink message - instead of up to three.

Today the only known alternative to the 'ip' tool from iproute2 is 
'libsocketcan'

http://git.pengutronix.de/?p=tools/libsocketcan.git;a=summary

But libsocketcan is not CAN FD aware by now.

> The rules I proposed yesterday would also break existing documentation and we should drop that :-(.

ACK.

>
> Hmm... user interface is a complicated topic ;-)
>
>>
>> My intention would be that the user is forced to provide all these
>> settings in one step which has to reflect the static ctrlmode too.
>>
>> E.g.
>>
>> ip link set can0 up type can bitrate 1000000 dbitrate 2000000 fd on
>>
>> would be the ONLY correct way to configure the R-Car CAN FD then.
>>
>> ip link set can0 down; ip link set can0 up type can bitrate 500000
>>
>> would fail due to missing 'fd on' from static_ctrlmode and the missing
>> data bitrate.
>
> Even today it would fail with your static_ctrlmode patch.

Yes, I know - that's why I wrote it would turn that patch upside down.

> Only thing is static_ctrlmode is not explicit and would allow
>
> ip link set can0 up type can bitrate 1000000 dbitrate 1000000
>
> on PCAN -> this resolves to CAN 2.0
> on R-Car CAN FD -> this resolves to CAN FD mode

Exactly! That's why I would like to force all ctrlmode_static options to 
be passed.

In the case of R-Car CAN FD the above example would lead to an error as 
'fd on' is missing.

>
> unless the user does "ip -d link show can0" -> they would not know the mode configured.
>
>>
>> I found a currently unused ops->validate option in the netlink ops, which
>> may help us to define this kind of 'configuration block' mechanism.
>>
>
> I looked at ops->validate now. It does not seem to take an ndev arg and maybe its scope is limited to sanitize the user option only against given link type/protocol?

Oh. Without a link to the netdevice we won't be able to check the CAN FD 
capabilities - but we could check the following:

1. If we have a ctrlmode attribute and it has CAN_CTRLMODE_FD set we 
need to have bitrate and data bitrate attributes.

2. If we have a data bitrate attribute we need to have a bitrate 
attribute and a ctrlmode attribute with CAN_CTRLMODE_FD set.

> If we agree on "configuration block", we could resolve dependencies in ops->changelink at the end of the function.

That won't work as ops->changelink has no context and is executed for 
every netlink attribute separately when netlink parses the message.

> Anyways that's implementation detail as you mentioned.
>
> I am wondering if we are complicating things for ourselves. Can we say
>
> - if "nbitrate" alone is provided, configure CAN 2.0. If controller not capable, it will fail - fine.
> - if "dbitrate" is provided & FD capable, set fd mode automatically with ISO (default) or non-iso (if that's only supported). Since dbitrate is FD property, it is logical to set fd mode. Same way if "fd-non-iso on" alone is provided without "fd on", can't we take fd mode is implied? Of course explicit setting of these options are also fine (already supported today)
> - if link brought down and some options changed when it is brought up, we logical OR that with existing config and apply if valid (like all netdev & current behaviour)

The problem is that there's no defined sequence of attributes and no 
context to check this.

> This looks simpler & may not break existing documentation/expectation like
>

With my suggestion above ...

> ip link set can0 type can bitrate 1000000
-> would work

> ip link set can0 type can dbitrate 2000000
-> would fail (bitrate & 'fd on' missing)

> ip link set can0 type can fd on
-> would fail (bitrates missing)

> ip link set can0 up
-> would work as-is

> We are only improving consistency in abnormal or accidental configs this way. Yes things like "fd only or fd but non-iso only" caps are not explicit.
I think making things more explicit is a good idea.

> May be we could improve "ip -d link show can0" output to show ctrlmode -> "supported, fixed" like we print bitrate constant ranges today?
Oh - an interesting idea. Don't know whether we can extend the existing 
data structure in a backward compatible way ...

>
> However,
>
> "ip link set can0 up type can bitrate 1000000 dbitrate 1000000"
>
> will configure PCAN (may be IFI & M_CAN) to FD mode than CAN2.0 as it is today.

Ugh.

> But why would one document such a case with dbitrate if CAN 2.0 is the intention isn't? It may not break existing expectations I believe.
>
> I think we need Marc & others to comment so that we do changes once and update conclusions in Documentation/networking/can.txt

Best regards,
Oliver


  reply	other threads:[~2016-03-18 19:45 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-01  9:34 [PATCH] can: rcar_canfd: Add Renesas R-Car CAN FD driver Ramesh Shanmugasundaram
     [not found] ` <1456824849-7987-1-git-send-email-ramesh.shanmugasundaram-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
2016-03-01 20:41   ` Marc Kleine-Budde
2016-03-01 20:41     ` Marc Kleine-Budde
2016-03-02  8:41     ` Ramesh Shanmugasundaram
2016-03-02  9:20       ` Marc Kleine-Budde
2016-03-02 10:08         ` Ramesh Shanmugasundaram
2016-03-02 10:21           ` Marc Kleine-Budde
2016-03-03 13:48             ` Ramesh Shanmugasundaram
2016-03-01 21:07 ` Oliver Hartkopp
2016-03-02  8:45   ` Ramesh Shanmugasundaram
2016-03-03 15:38 ` [PATCH v2] " Ramesh Shanmugasundaram
2016-03-05  4:30   ` Rob Herring
2016-03-07  9:33     ` Ramesh Shanmugasundaram
2016-03-06 11:32   ` Oliver Hartkopp
2016-03-07  8:02     ` Ramesh Shanmugasundaram
2016-03-07  8:08       ` Marc Kleine-Budde
2016-03-07  8:32         ` Ramesh Shanmugasundaram
2016-03-08  7:46           ` Oliver Hartkopp
2016-03-08  8:57             ` Ramesh Shanmugasundaram
2016-03-08 12:25               ` Oliver Hartkopp
2016-03-08 12:48                 ` Ramesh Shanmugasundaram
2016-03-08 17:16                   ` Oliver Hartkopp
2016-03-11  7:14                     ` Ramesh Shanmugasundaram
2016-03-12 18:49                       ` Oliver Hartkopp
2016-03-15  9:48   ` [PATCH v3] " Ramesh Shanmugasundaram
2016-03-15 12:46     ` Oliver Hartkopp
2016-03-15 14:17       ` Ramesh Shanmugasundaram
2016-03-15 19:38         ` Oliver Hartkopp
2016-03-16  7:45           ` Ramesh Shanmugasundaram
2016-03-16  9:47             ` Oliver Hartkopp
2016-03-16 10:50               ` Ramesh Shanmugasundaram
2016-03-16 21:20                 ` Oliver Hartkopp
2016-03-17 12:03                   ` Ramesh Shanmugasundaram
2016-03-17 20:46                     ` Oliver Hartkopp
2016-03-18 13:23                       ` Ramesh Shanmugasundaram
2016-03-18 19:44                         ` Oliver Hartkopp [this message]
2016-03-21  8:30                           ` Ramesh Shanmugasundaram
2016-03-21 15:30                             ` Oliver Hartkopp
2016-03-21 15:43                               ` Ramesh Shanmugasundaram
2016-03-21 15:49                                 ` Oliver Hartkopp
2016-03-15 12:51     ` Marc Kleine-Budde
2016-03-15 14:26       ` Ramesh Shanmugasundaram
2016-03-18 21:07     ` Rob Herring
2016-03-21 16:45     ` [PATCH v4 0/2] Add CAN FD driver support to r8a7795 SoC Ramesh Shanmugasundaram
2016-03-21 16:45       ` [PATCH 1/2] can: rcar_canfd: Add Renesas R-Car CAN FD driver Ramesh Shanmugasundaram
2016-03-21 16:45       ` [PATCH 2/2] can: rcar_can: Move Renesas CAN driver to rcar dir Ramesh Shanmugasundaram
2016-03-31 20:51   ` [PATCH v2] can: rcar_canfd: Add Renesas R-Car CAN FD driver Marc Kleine-Budde
2016-04-01 12:48     ` Ramesh Shanmugasundaram
2016-04-13  6:25       ` Ramesh Shanmugasundaram
2016-04-28  6:27         ` Oliver Hartkopp
2016-04-28 12:31           ` Ramesh Shanmugasundaram
2016-04-28 12:23 ` [PATCH v5 0/2] Add CAN FD driver support to r8a7795 SoC Ramesh Shanmugasundaram
2016-04-28 12:23   ` [PATCH v5 1/2] can: rcar_canfd: Add Renesas R-Car CAN FD driver Ramesh Shanmugasundaram
2016-05-03 16:47     ` Rob Herring
2016-05-04  6:23       ` Ramesh Shanmugasundaram
2016-04-28 12:23   ` [PATCH v5 2/2] can: rcar_can: Move Renesas CAN driver to rcar dir Ramesh Shanmugasundaram
2016-05-16 15:52   ` [PATCH v5 0/2] Add CAN FD driver support to r8a7795 SoC Chris Paterson
2016-06-02  9:45 ` [RESEND PATCH " Ramesh Shanmugasundaram
2016-06-02  9:45   ` [RESEND PATCH v5 1/2] can: rcar_canfd: Add Renesas R-Car CAN FD driver Ramesh Shanmugasundaram
2016-06-02 16:01     ` Ulrich Hecht
2016-06-03  6:42       ` Ramesh Shanmugasundaram
2016-06-03 17:03         ` Ulrich Hecht
2016-06-03 17:15           ` Oliver Hartkopp
2016-06-03 18:39             ` David Miller
2016-06-07 13:18               ` Ramesh Shanmugasundaram
2016-06-08  6:38                 ` [PATCH v6 0/2] Add CAN FD driver support to r8a7795 SoC Ramesh Shanmugasundaram
2016-06-08  6:38                   ` [PATCH v6 1/2] can: rcar_canfd: Add Renesas R-Car CAN FD driver Ramesh Shanmugasundaram
2016-06-13  8:42                     ` Ulrich Hecht
2016-06-14  7:23                       ` Ramesh Shanmugasundaram
2016-06-08  6:38                   ` [PATCH v6 2/2] can: rcar_can: Move Renesas CAN driver to rcar dir Ramesh Shanmugasundaram
2016-06-13  7:12                   ` [PATCH v6 0/2] Add CAN FD driver support to r8a7795 SoC Chris Paterson
2016-06-02  9:45   ` [RESEND PATCH v5 2/2] can: rcar_can: Move Renesas CAN driver to rcar dir Ramesh Shanmugasundaram

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=56EC5AB0.1080107@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=ramesh.shanmugasundaram@bp.renesas.com \
    --cc=wg@grandegger.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.