linux-can.vger.kernel.org archive mirror
 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: Thu, 17 Mar 2016 21:46:51 +0100	[thread overview]
Message-ID: <56EB17BB.9030308@hartkopp.net> (raw)
In-Reply-To: <SG2PR06MB103804EF4D818384C4F24DF5C38B0@SG2PR06MB1038.apcprd06.prod.outlook.com>

On 03/17/2016 01:03 PM, Ramesh Shanmugasundaram wrote:

>> I do not have real objections to change the behaviour in the way that the
>> user is forced to define ALL configuration options correctly.
>>
>> It's harder but doesn't seem to have real pitfalls.
>
> I kind of agree but I think we need to think further on the user interface design. For e.g. on IFI, PCAN where capabilities can be toggled by link change
>
> - ip link set can0 up type can bitrate 1000000 dbitrate 2000000 fd on -> CAN FD ISO mode
> - ip link set can0 down; ip link set can0 up type can bitrate 500000 - user wants to change CAN FD nom rate only or user wants CAN 2.0 mode switch?

When the interface is down, setting bitrate(s), ctrlmodes and e.g. 
restart-ms are independent of each other.

> 	- As of today, it will still be CAN FD ISO mode with different nominal bitrate

Yes - as no setting was provided to change ctrlmode settings.

> 	- To get into CAN 2.0 mode, user should see current state from "ip -d link show can0" and disable fd using "fd off".

Yes. This would change ctrlmode settings.

> Is this OK?

Don't know if it's clear to the user which netlink options can be 
changed independently from each other :-(

> To summarize, there are controllers that can do (capabilities)
>
> - CAN 2.0 only
> - CAN 2.0 & CAN FD (iso, non-iso) -> all combo switchable with link toggling (up/down) -> IFI, PCAN
> - CAN 2.0 & CAN FD (non-iso only) -> CAN 2.0 & CAN FD switchable with link toggling (up/down) -> M_CAN
> - CAN 2.0 only (or) CAN FD only (iso only) -> not switchable with link toggling - R-Car CAN FD
> (R-Car CAN FD can be categorized as two virtual controllers - CAN 2.0 only (or) CAN FD only (iso only) decided during power on)
> - CAN FD only (iso, non-iso) -> some unknown controller?
>
> Would the following rules be enough to have a consistent configuration?
> -------------
> CAN FD (identified by "fd on" flag passed)
> - MTU 72
> - Dbitrate MUST be provided always with "fd on"
> - Subtypes with "fd on" depending on controller capability (below args can be passed only with "fd on" passed)
> 	- ISO only supporting (some current & future controllers) - default
> 	- ISO & non-ISO (most current controllers) - identified by "fd-non-iso on/off" flag passed
> 		- unless "fd-non-iso on" is passed explicitly, it is off
> 	- non-ISO only (past & some current controllers) - identified by "fd-non-iso on" flag passed
>
> CAN 2.0 (identified with "fd off" (or) no "fd on")
> - MTU 16 (set automatically)
> - Not tolerant to FD frames
> - If FD capable, passed with "fd off" (or) "fd on" is not passed -> I think we should reset dbitrate to zero & clear all subtype bits of "fd on"
> - If FD capable, passed with dbitrate & but no "fd on" -> I think we should reject this? It is acting as CAN 2.0, why accept a dbitrate even it is not doing any harm? Just to be consistent.
> -------------

Boah - I was just wondering whether I would have to drink a beer before 
or after trying to understand all this ;-)

> I thought of resetting caps to original value when link goes down. But it may not be needed if we strictly implement the above?

I think setting a link down and up again should not change the settings.

But I wonder if we should allow the configuration in several steps:

ip link set can0 type can bitrate 1000000
ip link set can0 type can dbitrate 2000000
ip link set can0 type can fd on
ip link set can0 up

Today the can_changelink() function is not designed to process only a 
complete block of settings. It can only check the single netlink options 
for consistency.

1. ctrlmode is checked in can_changelink()
2. The (data) bitrate dependencies are checked in can_open()

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).

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.

I found a currently unused ops->validate option in the netlink ops, 
which may help us to define this kind of 'configuration block' mechanism.

By adding can_validate() here

static struct rtnl_link_ops can_link_ops __read_mostly = {
         .kind           = "can",
         .maxtype        = IFLA_CAN_MAX,
         .policy         = can_policy,
         .setup          = can_setup,
         .newlink        = can_newlink,
         .changelink     = can_changelink,
         .validate       = can_validate,
(..)

we can possibly clear the bitrates and ctrlmode when we see just one of 
them in the netlink message ... or something like this.

I have to take a look into ops->validate if it fits into our needs but I 
first wanted your feedback what you think about this 'configuration 
block' idea?

Best regards,
Oliver

  reply	other threads:[~2016-03-17 20:47 UTC|newest]

Thread overview: 71+ 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-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 [this message]
2016-03-18 13:23                       ` Ramesh Shanmugasundaram
2016-03-18 19:44                         ` Oliver Hartkopp
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=56EB17BB.9030308@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).