Re: [Question] Sending CAN error frames

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2021-01-31 13:59, Oliver Hartkopp wrote:
Hi Vincent,

On 31.01.21 07:22, Vincent MAILHOL wrote:
Hello,

The socket CAN API handles the CAN errors (as reported by the
microcontroller) by emitting some RX CAN frames with the
CAN_ERR_FLAG set.

Yes. This is the only intention.

My question concerns the transmission path: I would like to
understand how drivers should handle *TX* CAN frames which have
the CAN_ERR_FLAG set.

The socket API allows sending such frames. For example doing:
     cansend can0 20000123#0011223344556677
will generate such frames and it will reach the xmit() function of
the driver.

The reason to pass the frame as-is to the driver layer (including CAN_ERR_FLAG) is the possibility to test the correct behavior on the RX path, e.g. when you use the vcan driver.

On the sending path the CAN_ERR_FLAG has no functionality so far - at least it was not defined by the community.

However, contrary to the other flags (EFF, RTR, FDF, BRS), the
ERR flag is not present on the data link layer. Instead, the data
link layer is responsible for detecting errors and signaling those
as soon as they occur (thus interrupting the transmission).

While the ISO standard does not explicitly forbid having upper
layers generating such frames, it is not documented. Also, I am
not aware of CAN controllers allowing to generate error frames on
demand.

There are specialized CAN testers, e.g. IIRC Vector CANstress that can generate error frames on specific conditions (e.g. when detecting a specific CAN ID).

But I heave not seen CAN controllers that provide such functionality.

My initial expectation is that those error frames only make
sense in the RX path and that we should drop such TX frames in,
for example, can_dropped_invalid_skb().

No. As written above the bit is defined to be valid in the RX path only and it makes sense for testing.

However, after looking at the code of other drivers, it appears
that one (and only one) of them: the Kvaser hydra, does actually
check this CAN_ERR_FLAG flag in the TX path:
https://elixir.bootlin.com/linux/v5.11-rc5/source/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c#L1421

I would be thankful if anyone knowledgeable about the Kvaser hydra
could explain to me how the device handles those error frames.

o_O - Yes, would be interested too!!

Hi Vincent and Oliver,

When the user passes a frame with CAN_ERR_FLAG set, the CAN controller will generate an error frame.
We got customers that use this for testing system robustness and fault reporting/handling.

We also got this implemented in the early version of kvaser_pciefd driver, but dropped it:
https://marc.info/?l=linux-can&m=154324867704480&w=2
Is this something that we should remove from kvasr_usb aswell?

Regards,
jimmy



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux