public inbox for linux-can@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Wagner <thomas@the-wagner.de>
To: mkl@pengutronix.de
Cc: linux-can@vger.kernel.org, Thomas Wagner <thomas@the-wagner.de>
Subject: [PATCH v2] can: Documentation: Sending with canfd_frame on a CAN 2.0 interface
Date: Mon,  2 Aug 2021 12:40:48 +0200	[thread overview]
Message-ID: <20210802104048.32007-1-thomas@the-wagner.de> (raw)
In-Reply-To: <20210802102853.29308-1-thomas@the-wagner.de>

In response to my uncertainty described here
https://lore.kernel.org/linux-can/20210729121417.kysljj4636hmhem2@pengutronix.de/T/#t.

This patch clarifies sending CAN 2.0 frames on CAN FD capable hardware
when the interface is configured as CAN 2.0.

Signed-off-by: Thomas Wagner <thomas@the-wagner.de>
---
 Documentation/networking/can.rst | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/networking/can.rst b/Documentation/networking/can.rst
index f34cb0e4460e..ac3fe948c888 100644
--- a/Documentation/networking/can.rst
+++ b/Documentation/networking/can.rst
@@ -675,6 +675,17 @@ When sending to CAN devices make sure that the device is capable to handle
 CAN FD frames by checking if the device maximum transfer unit is CANFD_MTU.
 The CAN device MTU can be retrieved e.g. with a SIOCGIFMTU ioctl() syscall.
 
+You should also check the MTU in an environment, where the device is CAN
+FD capable, but the interface might be configured for just CAN 2.0. In
+this case the canfd_frame struct can still be used, but when writing to
+the socket write CAN_MTU bytes at most to send a CAN 2.0 frame.
+
+In conclusion, to handle devices with and without CAN FD and with
+interfaces configured as CAN 2.0 or CAN FD:
+- Set the CAN_RAW_FD_FRAMES flag and ignore the error on older kernels
+- Send and receive using the canfd_frame struct
+- Check the bytes received to know, whether you got an CAN 2.0 or FD frame
+- Check the devices MTU to know, whether you can send CAN 2.0 or FD frames
 
 RAW socket option CAN_RAW_JOIN_FILTERS
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
2.25.1


  reply	other threads:[~2021-08-02 10:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 10:28 [PATCH] can: Documentation: Sending with canfd_frame on a CAN 2.0 interface Thomas Wagner
2021-08-02 10:40 ` Thomas Wagner [this message]
2021-08-03 12:37   ` [PATCH v2] " Oliver Hartkopp

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=20210802104048.32007-1-thomas@the-wagner.de \
    --to=thomas@the-wagner.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox