linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: linux-can@vger.kernel.org
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Subject: [canxl v4 06/17] can: dev: can_dev_dropped_skb: drop CC/FD frames in CANXL-only mode
Date: Fri, 21 Nov 2025 09:34:03 +0100	[thread overview]
Message-ID: <20251121083414.3642-7-socketcan@hartkopp.net> (raw)
In-Reply-To: <20251121083414.3642-1-socketcan@hartkopp.net>

The error-signalling (ES) is a mandatory functionality for CAN CC and
CAN FD to report CAN frame format violations by sending an error-frame
signal on the bus.

A so-called 'mixed-mode' is intended to have (XL-tolerant) CAN FD nodes
and CAN XL nodes on one CAN segment, where the FD-controllers can talk
CC/FD and the XL-controllers can talk CC/FD/XL. This mixed-mode
utilizes the error-signalling for sending CC/FD/XL frames.

The CANXL-only mode disables the error-signalling in the CAN XL
controller. This mode does not allow CC/FD frames to be sent but
additionally offers a CAN XL transceiver mode switching (TMS).

Configured with CAN_CTRLMODE_FD and CAN_CTRLMODE_XL this leads to:

FD=0 XL=0 CC-only mode         (ES=1)
FD=1 XL=0 FD/CC mixed-mode     (ES=1)
FD=1 XL=1 XL/FD/CC mixed-mode  (ES=1)
FD=0 XL=1 XL-only mode         (ES=0, TMS optional)

The helper function can_dev_in_xl_only_mode() determines the required
value to disable error signalling in the CAN XL controller.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
 include/linux/can/dev.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 945c16743702..13b25b0dceeb 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -129,10 +129,23 @@ int can_restart_now(struct net_device *dev);
 void can_bus_off(struct net_device *dev);
 
 const char *can_get_state_str(const enum can_state state);
 const char *can_get_ctrlmode_str(u32 ctrlmode);
 
+static inline bool can_dev_in_xl_only_mode(struct can_priv *priv)
+{
+	const u32 mixed_mode = CAN_CTRLMODE_FD | CAN_CTRLMODE_XL;
+
+	/* When CAN XL is enabled but FD is disabled we are running in
+	 * the so-called 'CANXL-only mode' where the error signalling is
+	 * disabled. This helper function determines the required value
+	 * to disable error signalling in the CAN XL controller.
+	 * The so-called CC/FD/XL 'mixed mode' requires error signalling.
+	 */
+	return ((priv->ctrlmode & mixed_mode) == CAN_CTRLMODE_XL);
+}
+
 /* drop skb if it does not contain a valid CAN frame for sending */
 static inline bool can_dev_dropped_skb(struct net_device *dev, struct sk_buff *skb)
 {
 	struct can_priv *priv = netdev_priv(dev);
 	u32 silent_mode = priv->ctrlmode & (CAN_CTRLMODE_LISTENONLY |
@@ -147,10 +160,16 @@ static inline bool can_dev_dropped_skb(struct net_device *dev, struct sk_buff *s
 	if (!(priv->ctrlmode & CAN_CTRLMODE_FD) && can_is_canfd_skb(skb)) {
 		netdev_info_once(dev, "CAN FD is disabled, dropping skb\n");
 		goto invalid_skb;
 	}
 
+	if (can_dev_in_xl_only_mode(priv) && !can_is_canxl_skb(skb)) {
+		netdev_info_once(dev,
+				 "Error signaling is disabled, dropping skb\n");
+		goto invalid_skb;
+	}
+
 	return can_dropped_invalid_skb(dev, skb);
 
 invalid_skb:
 	kfree_skb(skb);
 	dev->stats.tx_dropped++;
-- 
2.47.3


  parent reply	other threads:[~2025-11-21  8:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21  8:33 [canxl v4 00/17] CAN XL support for review (full series) Oliver Hartkopp
2025-11-21  8:33 ` [canxl v4 01/17] can: bittiming: apply NL_SET_ERR_MSG() to can_calc_bittiming() Oliver Hartkopp
2025-11-21  8:33 ` [canxl v4 02/17] can: dev: can_dev_dropped_skb: drop CAN FD skbs if FD is off Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 03/17] can: netlink: add CAN_CTRLMODE_RESTRICTED Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 04/17] can: netlink: add initial CAN XL support Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 05/17] can: netlink: add CAN_CTRLMODE_XL_TMS flag Oliver Hartkopp
2025-11-21  8:34 ` Oliver Hartkopp [this message]
2025-11-21  8:34 ` [canxl v4 07/17] can: bittiming: add PWM parameters Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 08/17] can: bittiming: add PWM validation Oliver Hartkopp
2025-11-21  9:14   ` Marc Kleine-Budde
2025-11-21  9:23     ` Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 09/17] can: calc_bittiming: add PWM calculation Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 10/17] can: netlink: add PWM netlink interface Oliver Hartkopp
2025-11-21  9:19   ` Marc Kleine-Budde
2025-11-21  9:24     ` Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 11/17] can: calc_bittiming: get rid of the incorrect "nominal" word Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 12/17] can: calc_bittiming: add can_calc_sample_point_nrz() Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 13/17] can: calc_bittiming: add can_calc_sample_point_pwm() Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 14/17] can: add dummy_can driver Oliver Hartkopp
2025-11-21  9:21   ` Marc Kleine-Budde
2025-11-21  9:25     ` Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 15/17] can: raw: instantly reject unsupported CAN frames Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 16/17] can: dev: can_get_ctrlmode_str: use capitalized ctrlmode strings Oliver Hartkopp
2025-11-21  8:47   ` Marc Kleine-Budde
2025-11-21  9:19     ` Oliver Hartkopp
2025-11-21  9:30       ` Marc Kleine-Budde
2025-11-21  9:40         ` Oliver Hartkopp
2025-11-21  8:34 ` [canxl v4 17/17] can: dev: print bitrate error with two decimal digits Oliver Hartkopp
2025-11-21  9:13   ` Marc Kleine-Budde
2025-11-21  9:22     ` 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=20251121083414.3642-7-socketcan@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).