All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>
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: Sun, 19 Mar 2017 18:43:50 +0100	[thread overview]
Message-ID: <4e92ae71-e310-ff42-36fc-f734d9fe22c2@hartkopp.net> (raw)
In-Reply-To: <e04f267c-3f2d-50e6-0e94-982202c994e4@grandegger.com>

Hi Wolfgang,

On 03/19/2017 02:59 PM, Wolfgang Grandegger wrote:
> Am 18.03.2017 um 14:27 schrieb Oliver Hartkopp:
>> On 03/17/2017 06:52 PM, Oliver Hartkopp wrote:
>>> On 03/17/2017 12:06 PM, Mario.Huettel wrote:
>>>> On 03/16/2017 09:52 AM, Oliver Hartkopp wrote:
>>>>>> * Chip configuaration for CAN_CTRLMODE_LOOPBACK is changed: Enabled
>>>>>>   CCCR_MON bit. In combination with TEST_LBCK it activates the
>>>>>> internal
>>>>>>   loopback mode. Leaving CCCR_MON '0' results in external loopback
>>>>>> mode.
>>>>>
>>>>> How is the interaction with the IFF_ECHO functionality then?
>>>>
>>>> It is the same as before. Internal loopback mode cuts the connection to
>>>> the CAN RX and TX pins.
>>>>
>>>> However, sending a frame with enabled loopback results in following
>>>> situation:
>>>> * The socket that sent a frame receives the looped back frame
>>>
>>> In fact it receives the RX frame and not the echo'ed frame, right?
>>>
>>>> * Any other socket also receives the looped back frame but, in addition
>>>> to that, they
>>>>    also receive the echo frame created by the driver. Thus the frame is
>>>> received 2 times.
>>>
>>> This is bad.
>>>
>>> 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?

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

Right.

> There might even be hardware specific issues, e.g. some controller may
> not even do the loopback like the SJA1000.

Controllers that do not provide the loopback (like the SJA1000 or the 
M_CAN) do not (must not) set CAN_CTRLMODE_LOOPBACK in the drivers flags.

Regards,
Oliver

  parent reply	other threads:[~2017-03-19 18:09 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 [this message]
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
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=4e92ae71-e310-ff42-36fc-f734d9fe22c2@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.