All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] can/peak_canfd: fix echo management when loopback is on
@ 2020-02-04 15:33 Stephane Grosjean
  2020-02-13 15:42 ` FW: " Stéphane Grosjean
  0 siblings, 1 reply; 3+ messages in thread
From: Stephane Grosjean @ 2020-02-04 15:33 UTC (permalink / raw)
  To: linux-can Mailing List; +Cc: Stephane Grosjean

Echo management is driven by PUCAN_MSG_LOOPED_BACK bit, while loopback
frames are identified with PUCAN_MSG_SELF_RECEIVE bit. Those bits are set
for each outgoing frame written to the IP core so that a copy of each one
will be placed into the rx path. Thus,

- when PUCAN_MSG_LOOPED_BACK is set then the rx frame is an echo of a
  previously sent frame,
- when PUCAN_MSG_LOOPED_BACK+PUCAN_MSG_SELF_RECEIVE are set, then the rx
  frame is an echo AND a loopback frame. Therefore, this frame must be
  put into the socket rx path too.

This patch fixes how CAN frames are handled when these are sent while the
CAN interface is configured in "loopback on" mode.

Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
---
 drivers/net/can/peak_canfd/peak_canfd.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
index 10aa3e457c33..40c33b8a5fda 100644
--- a/drivers/net/can/peak_canfd/peak_canfd.c
+++ b/drivers/net/can/peak_canfd/peak_canfd.c
@@ -262,8 +262,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
 		cf_len = get_can_dlc(pucan_msg_get_dlc(msg));
 
 	/* if this frame is an echo, */
-	if ((rx_msg_flags & PUCAN_MSG_LOOPED_BACK) &&
-	    !(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE)) {
+	if (rx_msg_flags & PUCAN_MSG_LOOPED_BACK) {
 		unsigned long flags;
 
 		spin_lock_irqsave(&priv->echo_lock, flags);
@@ -277,7 +276,13 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
 		netif_wake_queue(priv->ndev);
 
 		spin_unlock_irqrestore(&priv->echo_lock, flags);
-		return 0;
+
+		/* if this frame is only an echo, stop here. Otherwise,
+		 * continue to push this application self-received frame into
+		 * its own rx queue.
+		 */
+		if (!(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE))
+			return 0;
 	}
 
 	/* otherwise, it should be pushed into rx fifo */
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* FW: [PATCH] can/peak_canfd: fix echo management when loopback is on
  2020-02-04 15:33 [PATCH] can/peak_canfd: fix echo management when loopback is on Stephane Grosjean
@ 2020-02-13 15:42 ` Stéphane Grosjean
  0 siblings, 0 replies; 3+ messages in thread
From: Stéphane Grosjean @ 2020-02-13 15:42 UTC (permalink / raw)
  To: linux-can Mailing List; +Cc: Marc Kleine-Budde, Oliver Hartkopp

Hello,

AFAIK I have no news about that patch...

Best regards,

- Stéphane

> -----Original Message-----
> From: Stephane Grosjean <s.grosjean@peak-system.com>
> Sent: mardi 4 février 2020 16:34
> To: linux-can Mailing List <linux-can@vger.kernel.org>
> Cc: Stéphane Grosjean <s.grosjean@peak-system.com>
> Subject: [PATCH] can/peak_canfd: fix echo management when loopback is
> on
>
> Echo management is driven by PUCAN_MSG_LOOPED_BACK bit, while
> loopback frames are identified with PUCAN_MSG_SELF_RECEIVE bit. Those
> bits are set for each outgoing frame written to the IP core so that a copy of
> each one will be placed into the rx path. Thus,
>
> - when PUCAN_MSG_LOOPED_BACK is set then the rx frame is an echo of a
>   previously sent frame,
> - when PUCAN_MSG_LOOPED_BACK+PUCAN_MSG_SELF_RECEIVE are set,
> then the rx
>   frame is an echo AND a loopback frame. Therefore, this frame must be
>   put into the socket rx path too.
>
> This patch fixes how CAN frames are handled when these are sent while the
> CAN interface is configured in "loopback on" mode.
>
> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
> ---
>  drivers/net/can/peak_canfd/peak_canfd.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/can/peak_canfd/peak_canfd.c
> b/drivers/net/can/peak_canfd/peak_canfd.c
> index 10aa3e457c33..40c33b8a5fda 100644
> --- a/drivers/net/can/peak_canfd/peak_canfd.c
> +++ b/drivers/net/can/peak_canfd/peak_canfd.c
> @@ -262,8 +262,7 @@ static int pucan_handle_can_rx(struct
> peak_canfd_priv *priv,
>                 cf_len = get_can_dlc(pucan_msg_get_dlc(msg));
>
>         /* if this frame is an echo, */
> -       if ((rx_msg_flags & PUCAN_MSG_LOOPED_BACK) &&
> -           !(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE)) {
> +       if (rx_msg_flags & PUCAN_MSG_LOOPED_BACK) {
>                 unsigned long flags;
>
>                 spin_lock_irqsave(&priv->echo_lock, flags); @@ -277,7 +276,13 @@
> static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
>                 netif_wake_queue(priv->ndev);
>
>                 spin_unlock_irqrestore(&priv->echo_lock, flags);
> -               return 0;
> +
> +               /* if this frame is only an echo, stop here. Otherwise,
> +                * continue to push this application self-received frame into
> +                * its own rx queue.
> +                */
> +               if (!(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE))
> +                       return 0;
>         }
>
>         /* otherwise, it should be pushed into rx fifo */
> --
> 2.20.1
>
>
> --
> PEAK-System Technik GmbH
> Sitz der Gesellschaft Darmstadt - HRB 9183
> Geschaeftsfuehrung: Alexander Gach / Uwe Wilhelm Unsere
> Datenschutzerklaerung mit wichtigen Hinweisen zur Behandlung
> personenbezogener Daten finden Sie unter www.peak-
> system.com/Datenschutz.483.0.html

--
PEAK-System Technik GmbH
Sitz der Gesellschaft Darmstadt - HRB 9183
Geschaeftsfuehrung: Alexander Gach / Uwe Wilhelm
Unsere Datenschutzerklaerung mit wichtigen Hinweisen
zur Behandlung personenbezogener Daten finden Sie unter
www.peak-system.com/Datenschutz.483.0.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] can/peak_canfd: fix echo management when loopback is on
@ 2020-10-13 15:39 Stephane Grosjean
  0 siblings, 0 replies; 3+ messages in thread
From: Stephane Grosjean @ 2020-10-13 15:39 UTC (permalink / raw)
  To: linux-can Mailing List; +Cc: Stephane Grosjean

Echo management is driven by PUCAN_MSG_LOOPED_BACK bit, while loopback
frames are identified with PUCAN_MSG_SELF_RECEIVE bit. Those bits are set
for each outgoing frame written to the IP core so that a copy of each one
will be placed into the rx path. Thus,

- when PUCAN_MSG_LOOPED_BACK is set then the rx frame is an echo of a
  previously sent frame,
- when PUCAN_MSG_LOOPED_BACK+PUCAN_MSG_SELF_RECEIVE are set, then the rx
  frame is an echo AND a loopback frame. Therefore, this frame must be
  put into the socket rx path too.

This patch fixes how CAN frames are handled when these are sent while the
can interface is configured in "loopback on" mode.

Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
---
 drivers/net/can/peak_canfd/peak_canfd.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
index 10aa3e457c33..40c33b8a5fda 100644
--- a/drivers/net/can/peak_canfd/peak_canfd.c
+++ b/drivers/net/can/peak_canfd/peak_canfd.c
@@ -262,8 +262,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
 		cf_len = get_can_dlc(pucan_msg_get_dlc(msg));
 
 	/* if this frame is an echo, */
-	if ((rx_msg_flags & PUCAN_MSG_LOOPED_BACK) &&
-	    !(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE)) {
+	if (rx_msg_flags & PUCAN_MSG_LOOPED_BACK) {
 		unsigned long flags;
 
 		spin_lock_irqsave(&priv->echo_lock, flags);
@@ -277,7 +276,13 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
 		netif_wake_queue(priv->ndev);
 
 		spin_unlock_irqrestore(&priv->echo_lock, flags);
-		return 0;
+
+		/* if this frame is only an echo, stop here. Otherwise,
+		 * continue to push this application self-received frame into
+		 * its own rx queue.
+		 */
+		if (!(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE))
+			return 0;
 	}
 
 	/* otherwise, it should be pushed into rx fifo */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-13 15:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 15:33 [PATCH] can/peak_canfd: fix echo management when loopback is on Stephane Grosjean
2020-02-13 15:42 ` FW: " Stéphane Grosjean
2020-10-13 15:39 Stephane Grosjean

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.