linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] can: esd_usb: Some more preparation for supporting esd CAN-USB/3
@ 2022-12-19 21:20 Frank Jungclaus
  2022-12-19 21:20 ` [PATCH 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1) Frank Jungclaus
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Jungclaus @ 2022-12-19 21:20 UTC (permalink / raw)
  To: linux-can, Marc Kleine-Budde, Wolfgang Grandegger, Vincent Mailhol
  Cc: Stefan Mätje, netdev, linux-kernel, Frank Jungclaus

Another small batch of patches to be seen as preparation for adding
support of the newly available esd CAN-USB/3 to esd_usb.c.

Due to some unresolved questions adding support for
CAN_CTRLMODE_BERR_REPORTING has been postponed to one of the future
patches.

Frank Jungclaus (3):
  can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1)
  can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (2)
  can: esd_usb: Improved decoding for ESD_EV_CAN_ERROR_EXT messages

 drivers/net/can/usb/esd_usb.c | 36 +++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)


base-commit: 47bf2b2393ea1aacdefbe4e9d643599e057bb3a2
-- 
2.25.1


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

* [PATCH 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1)
  2022-12-19 21:20 [PATCH 0/3] can: esd_usb: Some more preparation for supporting esd CAN-USB/3 Frank Jungclaus
@ 2022-12-19 21:20 ` Frank Jungclaus
  2022-12-20  5:16   ` Vincent MAILHOL
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Jungclaus @ 2022-12-19 21:20 UTC (permalink / raw)
  To: linux-can, Marc Kleine-Budde, Wolfgang Grandegger, Vincent Mailhol
  Cc: Stefan Mätje, netdev, linux-kernel, Frank Jungclaus

Moved the supply for cf->data[3] (bit stream position of CAN error)
outside of the "switch (ecc & SJA1000_ECC_MASK){}"-statement, because
this position is independent of the error type.

Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device")
Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
---
 drivers/net/can/usb/esd_usb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
index 42323f5e6f3a..5e182fadd875 100644
--- a/drivers/net/can/usb/esd_usb.c
+++ b/drivers/net/can/usb/esd_usb.c
@@ -286,7 +286,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
 				cf->data[2] |= CAN_ERR_PROT_STUFF;
 				break;
 			default:
-				cf->data[3] = ecc & SJA1000_ECC_SEG;
 				break;
 			}
 
@@ -294,6 +293,9 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
 			if (!(ecc & SJA1000_ECC_DIR))
 				cf->data[2] |= CAN_ERR_PROT_TX;
 
+			/* Bit stream position in CAN frame as the error was detected */
+			cf->data[3] = ecc & SJA1000_ECC_SEG;
+
 			if (priv->can.state == CAN_STATE_ERROR_WARNING ||
 			    priv->can.state == CAN_STATE_ERROR_PASSIVE) {
 				cf->data[1] = (txerr > rxerr) ?
-- 
2.25.1


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

* Re: [PATCH 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1)
  2022-12-19 21:20 ` [PATCH 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1) Frank Jungclaus
@ 2022-12-20  5:16   ` Vincent MAILHOL
  2022-12-21 17:55     ` Frank Jungclaus
  0 siblings, 1 reply; 5+ messages in thread
From: Vincent MAILHOL @ 2022-12-20  5:16 UTC (permalink / raw)
  To: Frank Jungclaus
  Cc: linux-can, Marc Kleine-Budde, Wolfgang Grandegger,
	Stefan Mätje, netdev, linux-kernel

On Tue. 20 Dec. 2022 at 06:25, Frank Jungclaus <frank.jungclaus@esd.eu> wrote:
>
> Moved the supply for cf->data[3] (bit stream position of CAN error)
> outside of the "switch (ecc & SJA1000_ECC_MASK){}"-statement, because
> this position is independent of the error type.
>
> Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device")
> Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
> ---
>  drivers/net/can/usb/esd_usb.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
> index 42323f5e6f3a..5e182fadd875 100644
> --- a/drivers/net/can/usb/esd_usb.c
> +++ b/drivers/net/can/usb/esd_usb.c
> @@ -286,7 +286,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
>                                 cf->data[2] |= CAN_ERR_PROT_STUFF;
>                                 break;
>                         default:
> -                               cf->data[3] = ecc & SJA1000_ECC_SEG;
>                                 break;
>                         }
>
> @@ -294,6 +293,9 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
>                         if (!(ecc & SJA1000_ECC_DIR))
>                                 cf->data[2] |= CAN_ERR_PROT_TX;
>
> +                       /* Bit stream position in CAN frame as the error was detected */
> +                       cf->data[3] = ecc & SJA1000_ECC_SEG;

Can you confirm that the value returned by the device matches the
specifications from linux/can/error.h?

  https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/can/error.h#L90

>                         if (priv->can.state == CAN_STATE_ERROR_WARNING ||
>                             priv->can.state == CAN_STATE_ERROR_PASSIVE) {
>                                 cf->data[1] = (txerr > rxerr) ?
> --
> 2.25.1
>

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

* Re: [PATCH 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1)
  2022-12-20  5:16   ` Vincent MAILHOL
@ 2022-12-21 17:55     ` Frank Jungclaus
  2022-12-22  0:46       ` Vincent MAILHOL
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Jungclaus @ 2022-12-21 17:55 UTC (permalink / raw)
  To: mailhol.vincent
  Cc: Stefan Mätje, linux-can, mkl, netdev, wg, linux-kernel

On Tue, 2022-12-20 at 14:16 +0900, Vincent MAILHOL wrote:
> On Tue. 20 Dec. 2022 at 06:25, Frank Jungclaus <frank.jungclaus@esd.eu> wrote:
> > 
> > Moved the supply for cf->data[3] (bit stream position of CAN error)
> > outside of the "switch (ecc & SJA1000_ECC_MASK){}"-statement, because
> > this position is independent of the error type.
> > 
> > Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device")
> > Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
> > ---
> >  drivers/net/can/usb/esd_usb.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
> > index 42323f5e6f3a..5e182fadd875 100644
> > --- a/drivers/net/can/usb/esd_usb.c
> > +++ b/drivers/net/can/usb/esd_usb.c
> > @@ -286,7 +286,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
> >                                 cf->data[2] |= CAN_ERR_PROT_STUFF;
> >                                 break;
> >                         default:
> > -                               cf->data[3] = ecc & SJA1000_ECC_SEG;
> >                                 break;
> >                         }
> > 
> > @@ -294,6 +293,9 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
> >                         if (!(ecc & SJA1000_ECC_DIR))
> >                                 cf->data[2] |= CAN_ERR_PROT_TX;
> > 
> > +                       /* Bit stream position in CAN frame as the error was detected */
> > +                       cf->data[3] = ecc & SJA1000_ECC_SEG;
> 
> Can you confirm that the value returned by the device matches the
> specifications from linux/can/error.h?

The value returned is supposed to be compatible to the SJA1000 ECC
register.

See
https://esd.eu/fileadmin/esd/docs/manuals/NTCAN_Part1_Function_API_Manual_en_56.pdf

Chapter "6.2.10 EV_CAN_ERROR_EXT" (page 185)
and 
"Annex B: Bus Error Code" table 37 and 38 (page 272 and following).

So this should be compliant with the values given in linux/can/error.h.


> 
>   https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/can/error.h#L90
> 
> >                         if (priv->can.state == CAN_STATE_ERROR_WARNING ||
> >                             priv->can.state == CAN_STATE_ERROR_PASSIVE) {
> >                                 cf->data[1] = (txerr > rxerr) ?
> > --
> > 2.25.1
> > 


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

* Re: [PATCH 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1)
  2022-12-21 17:55     ` Frank Jungclaus
@ 2022-12-22  0:46       ` Vincent MAILHOL
  0 siblings, 0 replies; 5+ messages in thread
From: Vincent MAILHOL @ 2022-12-22  0:46 UTC (permalink / raw)
  To: Frank Jungclaus
  Cc: Stefan Mätje, linux-can, mkl, netdev, wg, linux-kernel

On Tue. 22 Dec. 2022 at 02:55, Frank Jungclaus <Frank.Jungclaus@esd.eu> wrote:
> On Tue, 2022-12-20 at 14:16 +0900, Vincent MAILHOL wrote:
> > On Tue. 20 Dec. 2022 at 06:25, Frank Jungclaus <frank.jungclaus@esd.eu> wrote:
> > >
> > > Moved the supply for cf->data[3] (bit stream position of CAN error)
> > > outside of the "switch (ecc & SJA1000_ECC_MASK){}"-statement, because
> > > this position is independent of the error type.
> > >
> > > Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device")
> > > Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
> > > ---
> > >  drivers/net/can/usb/esd_usb.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
> > > index 42323f5e6f3a..5e182fadd875 100644
> > > --- a/drivers/net/can/usb/esd_usb.c
> > > +++ b/drivers/net/can/usb/esd_usb.c
> > > @@ -286,7 +286,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
> > >                                 cf->data[2] |= CAN_ERR_PROT_STUFF;
> > >                                 break;
> > >                         default:
> > > -                               cf->data[3] = ecc & SJA1000_ECC_SEG;
> > >                                 break;
> > >                         }
> > >
> > > @@ -294,6 +293,9 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
> > >                         if (!(ecc & SJA1000_ECC_DIR))
> > >                                 cf->data[2] |= CAN_ERR_PROT_TX;
> > >
> > > +                       /* Bit stream position in CAN frame as the error was detected */
> > > +                       cf->data[3] = ecc & SJA1000_ECC_SEG;
> >
> > Can you confirm that the value returned by the device matches the
> > specifications from linux/can/error.h?
>
> The value returned is supposed to be compatible to the SJA1000 ECC
> register.
>
> See
> https://esd.eu/fileadmin/esd/docs/manuals/NTCAN_Part1_Function_API_Manual_en_56.pdf
>
> Chapter "6.2.10 EV_CAN_ERROR_EXT" (page 185)
> and
> "Annex B: Bus Error Code" table 37 and 38 (page 272 and following).
>
> So this should be compliant with the values given in linux/can/error.h.

Thanks for the link. It is indeed compliant.

Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

> >   https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/can/error.h#L90
> >
> > >                         if (priv->can.state == CAN_STATE_ERROR_WARNING ||
> > >                             priv->can.state == CAN_STATE_ERROR_PASSIVE) {
> > >                                 cf->data[1] = (txerr > rxerr) ?
> > > --
> > > 2.25.1
> > >
>

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

end of thread, other threads:[~2022-12-22  0:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 21:20 [PATCH 0/3] can: esd_usb: Some more preparation for supporting esd CAN-USB/3 Frank Jungclaus
2022-12-19 21:20 ` [PATCH 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1) Frank Jungclaus
2022-12-20  5:16   ` Vincent MAILHOL
2022-12-21 17:55     ` Frank Jungclaus
2022-12-22  0:46       ` Vincent MAILHOL

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