Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

can: dev: can_dev_dropped_skb: drop CC/FD frames in CANXL-only mode

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>
Link: https://patch.msgid.link/20251126-canxl-v8-7-e7e3eb74f889@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Oliver Hartkopp and committed by
Marc Kleine-Budde
6df01533 233134af

+19
+19
include/linux/can/dev.h
··· 135 135 const char *can_get_state_str(const enum can_state state); 136 136 const char *can_get_ctrlmode_str(u32 ctrlmode); 137 137 138 + static inline bool can_dev_in_xl_only_mode(struct can_priv *priv) 139 + { 140 + const u32 mixed_mode = CAN_CTRLMODE_FD | CAN_CTRLMODE_XL; 141 + 142 + /* When CAN XL is enabled but FD is disabled we are running in 143 + * the so-called 'CANXL-only mode' where the error signalling is 144 + * disabled. This helper function determines the required value 145 + * to disable error signalling in the CAN XL controller. 146 + * The so-called CC/FD/XL 'mixed mode' requires error signalling. 147 + */ 148 + return ((priv->ctrlmode & mixed_mode) == CAN_CTRLMODE_XL); 149 + } 150 + 138 151 /* drop skb if it does not contain a valid CAN frame for sending */ 139 152 static inline bool can_dev_dropped_skb(struct net_device *dev, struct sk_buff *skb) 140 153 { ··· 163 150 164 151 if (!(priv->ctrlmode & CAN_CTRLMODE_FD) && can_is_canfd_skb(skb)) { 165 152 netdev_info_once(dev, "CAN FD is disabled, dropping skb\n"); 153 + goto invalid_skb; 154 + } 155 + 156 + if (can_dev_in_xl_only_mode(priv) && !can_is_canxl_skb(skb)) { 157 + netdev_info_once(dev, 158 + "Error signaling is disabled, dropping skb\n"); 166 159 goto invalid_skb; 167 160 } 168 161