All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
	Wolfgang Grandegger <wg@grandegger.com>
Cc: "Mario.Huettel" <Mario.Huettel@de.bosch.com>, linux-can@vger.kernel.org
Subject: Re: [PATCH 2/3] can: m_can: Enable M_CAN IP version dependent initialization
Date: Tue, 21 Mar 2017 12:33:38 +0100	[thread overview]
Message-ID: <6c627bf5-0451-07d6-c035-afdd01d260ab@hartkopp.net> (raw)
In-Reply-To: <e5834c2f-0860-1c34-c585-d9538852e760@pengutronix.de>



On 03/21/2017 11:30 AM, Marc Kleine-Budde wrote:
> On 03/19/2017 09:33 PM, Wolfgang Grandegger wrote:
>> Am 19.03.2017 um 21:16 schrieb Oliver Hartkopp:
>>>
>>>
>>> On 03/19/2017 08:12 PM, Wolfgang Grandegger wrote:
>>>> Am 19.03.2017 um 18:43 schrieb Oliver Hartkopp:
>>>
>>>>>>>> If I understood the frame flow correctly the 'non originating' socket
>>>>>>>> receives two frames:
>>>>>>>>
>>>>>>>> 1. the frame from the completed TX operation (echo_skb / IFF_ECHO)
>>>>>>>> 2. the frame received from the RX path from the hw loopback shortcut
>>>>>>
>>>>>> Yep.
>>>>>>
>>>>>>>> I would suggest to drop the frame coming from the RX path (case 2)
>>>>>>>> when
>>>>>>>> the CAN_CTRLMODE_LOOPBACK gets enabled.
>>>>>>
>>>>>> Why? Mario, what is you motivation/use case?
>>>>>
>>>>> This was just my (Olivers) suggestion.
>>>>>
>>>>> The effect with CAN_CTRLMODE_LOOPBACK enabled would then be similar to
>>>>> using a virtual CAN interface.
>>>>>
>>>>>>> Do we have an agreement on this?
>>>>>>> Did we ever discuss this topic in this detailed manner before?
>>>>>>
>>>>>> As I see it, the CAN_CTRLMODE_LOOPBACK provides a internal hardware
>>>>>> loopback to test the send and receive software (including echo skb). It
>>>>>> has noting to to with echo skbs.
>>>>>
>>>>> Agreed.
>>>>>
>>>>> But the question is what happens to the IFF_ECHO 'mechanism' when the
>>>>> CAN controller is switched into CAN_CTRLMODE_LOOPBACK?
>>>>
>>>> Nothing special. The software does *not* known that the message was
>>>> looped back by the hardware. The TX and RX is treated a usual.
>>>>
>>>>> Do we get a virtual CAN behavior (from IFF_ECHO on driver level) or do
>>>>> we get IFF_ECHO AND a reception due to the controllers loopback?
>>>>
>>>> The latter: The echoed message when TX is done and the RX (from the
>>>> hardware loopback).
>>>
>>> But this would be different to normal operation then!
>>
>> Depends on the intended usage. For testing if TX and RX software works
>> that's just fine.
>>
>>> When you have a second CAN interface on a real CAN bus that only ACKs
>>> your frames but doesn't send own traffic, you only see your echo'ed
>>> frames in the system (due to successful TX irq notification) - but no RX
>>> frames.
>>
>> Using the loopback as a virtual CAN device came never into my mind.
>>
>>>>>> The loopback mode never got big
>>>>>> attention. I think it's rarely used and if, then just for testing
>>>>>> purposes. That's maybe the reason why this issue was never discussed.
>>>
>>> So you vote for "The echoed message when TX is done and the RX (from the
>>> hardware loopback)." - which reflects the current implementation in
>>> SJA1000 and M_CAN.
>>>
>>> But my question is:
>>>
>>> Are developers using CAN_CTRLMODE_LOOPBACK to
>>>
>>> 1. Run their CAN controller without a working CAN bus hardware
>>> 2. To test the hardware loopback mode of the controller
>>>
>>> For case 1 the RX frames should be dropped and only the echo'ed frames
>>> should be provided to the system.
>>
>> Yes, feedback would really be useful.
>>
>> In the past I used it for the following purpose. After configuring and
>> starting the controller, I'm not able to get messages out to the bus or
>> receive from it. To understand if it's a software or hardware problem, I
>> switch to loopback mode. If it still doesn't work, it's software.
>
> From my point of view, the CAN_CTRLMODE_LOOPBACK mode should behave like
> an external loopback connector, but controllable by software. Like a
> short-circuit between RX and TX for RS232.
>
> So you would receive the echo packges on TX and the "real" packages on
> "RX". If you want a virtual CAN interface, make use of a vcan interace.

Ok. Then the posted implementation from Mario remains correct.

But it's good to have a common understanding about CAN_CTRLMODE_LOOPBACK 
now.

Regards,
Oliver


  reply	other threads:[~2017-03-21 11:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 14:00 [PATCH 0/3] can: m_can: Add driver support for M_CAN versions > v3.0.x Mario Huettel
2017-03-10 14:00 ` [PATCH 0/3] can: m_can: Add driver support for M_CAN versions > 3.0.x Mario Huettel
2017-03-10 14:00 ` [PATCH 1/3] can: m_can: Support M_CAN IP versions > v3.0.x Mario Huettel
2017-03-16  8:41   ` Oliver Hartkopp
2017-03-21 10:36   ` Marc Kleine-Budde
2017-03-10 14:00 ` [PATCH 2/3] can: m_can: Enable M_CAN IP version dependent initialization Mario Huettel
2017-03-16  8:52   ` Oliver Hartkopp
     [not found]     ` <c3d26079-554b-104d-4836-825a8496b66f@de.bosch.com>
2017-03-17 17:52       ` Oliver Hartkopp
2017-03-18 13:27         ` Oliver Hartkopp
2017-03-19 13:59           ` Wolfgang Grandegger
2017-03-19 14:44             ` Wolfgang Grandegger
2017-03-19 17:43             ` Oliver Hartkopp
2017-03-19 19:12               ` Wolfgang Grandegger
2017-03-19 20:16                 ` Oliver Hartkopp
2017-03-19 20:33                   ` Wolfgang Grandegger
2017-03-21 10:30                     ` Marc Kleine-Budde
2017-03-21 11:33                       ` Oliver Hartkopp [this message]
2017-03-21 14:33   ` Marc Kleine-Budde
2017-03-21 19:26     ` Oliver Hartkopp
2017-03-10 14:00 ` [PATCH 3/3] can: m_can: Enable TX FIFO Handling for M_CAN IP version >= v3.1.x Mario Huettel
2017-03-16  9:03   ` Oliver Hartkopp
2017-03-21 14:50   ` 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=6c627bf5-0451-07d6-c035-afdd01d260ab@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=Mario.Huettel@de.bosch.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --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.