linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, wg@grandegger.com,
	Stephane Grosjean <s.grosjean@peak-system.com>
Subject: Re: [PATCH v3 5/5] can: allow to change the device mtu for CAN FD capable devices
Date: Wed, 19 Feb 2014 19:25:31 +0100	[thread overview]
Message-ID: <5304F71B.9030408@hartkopp.net> (raw)
In-Reply-To: <53035B42.8030802@hartkopp.net>



On 18.02.2014 14:08, Oliver Hartkopp wrote:
>
>
> On 02/18/2014 12:09 PM, Marc Kleine-Budde wrote:
>> On 02/15/2014 06:29 PM, Oliver Hartkopp wrote:
>>>> On 02/15/2014 05:32 PM, Oliver Hartkopp wrote:
>>>>> The configuration for CAN FD depends on CAN_CTRLMODE_FD enabled in the
>>>>> driver
>>>>> specific ctrlmode_supported capabilities.
>>>>>
>>>>> The configuration can be done either with the 'fd { on | off }' option in
>>>>> the
>>>>> 'ip' tool from iproute2 or by setting the CAN netdevice MTU to CAN_MTU
>>>>> (16) or
>>>>> to CANFD_MTU (72).
>>>>
>>>> Please don't add two possibilities to activate canfd on a CAN network
>>>> card. There should only be one.
>>>
>>> Yes it /should/ be like this.
>>> I thought about it some time but I didn't find a better solution.
>>>
>>> The problem is that dev->mtu is the switch for the skb->len whether CAN frames
>>> or CAN FD frames are generated or received.
>>>
>>> The MTU can be modified by 'ip' (independently from CAN specific settings).
>>
>> It _can_ be modified (directly by the userspace) _if_ the change mtu
>> callback is implemented. Maybe we don't need the callback?

See:
http://lxr.free-electrons.com/source/net/core/dev.c#L5324

When we do not define our own callback function the mtu is set to any value 
the user specifies. This is definitely not a good idea %-)

The question is if we define our own can_change_mtu() callback to control the 
mtu access - but only allow the FD switching via ip tool.

Or if we allow to modify the FD switch via 'ip' and mtu setting which was the 
original patch idea?!?

>
> We need the callback to check if the setting is allowed.
> E.g. to set the MTU to 72 is only allowed for CAN FD capable devices.
>
> Or do you think about *only* switching the MTU via
>
> ip link set can0 type can fd on
> ip link set can0 type can fd off
>
> ??
>
> This could be an idea too.
>
> Currently the vcan can only be switched via mtu setting to identify CAN or CAN
> FD. But this could be a single and only exception to do it like this - as the
> vcan does not use the CAN driver infrastructure.
>
>>
>>> OTOH the only way the CAN devices provide their capabilities is the
>>> ctrlmode_supported bitfield - and it does not make sense to provide
>>> CAN_CTRLMODE_FD in ctrlmode_supported and do not provide the configuration
>>> for it.
>>>
>>> If you would skip the CAN_CTRLMODE_FD bit in ctrlmode_supported there's no way
>>> to identify a CAN FD capable device. You could only try to set the MTU to
>>> CANFD_MTU and see, if it fails. Not a good solution either.
>>>
>>>
>>>>> +EXPORT_SYMBOL_GPL(can_change_mtu);
>>>>
>>>> Who will be the user of this function? The individual network drivers?
>>>>
>>>
>>> Yes. It manages the MTU and CAN_CTRLMODE_FD consistency and only allows the
>>> CANFD_MTU when the driver supports it.
>>
>> And it has to be assigned by a FD capable driver to the net_device_ops,
>> right?
>>
>
> Yes.
>
> Regards,
> Oliver
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2014-02-19 18:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-15 16:32 [PATCH v3 1/5] can: preserve skbuff protocol in can_put_echo_skb Oliver Hartkopp
2014-02-15 16:32 ` [PATCH v3 2/5] can: netlink send bittiming data only when a bitrate is available Oliver Hartkopp
2014-02-15 16:32 ` [PATCH v3 3/5] can: provide a separate bittiming_const parameter to bittiming functions Oliver Hartkopp
2014-02-15 16:32 ` [PATCH v3 4/5] can: introduce the data bitrate configuration for CAN FD Oliver Hartkopp
2014-02-21  8:27   ` Stephane Grosjean
2014-02-15 16:32 ` [PATCH v3 5/5] can: allow to change the device mtu for CAN FD capable devices Oliver Hartkopp
2014-02-15 16:59   ` Marc Kleine-Budde
2014-02-15 17:00     ` Marc Kleine-Budde
2014-02-15 17:29     ` Oliver Hartkopp
2014-02-18 11:09       ` Marc Kleine-Budde
2014-02-18 13:08         ` Oliver Hartkopp
2014-02-19 18:25           ` Oliver Hartkopp [this message]

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=5304F71B.9030408@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=s.grosjean@peak-system.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).