Commit 6c1f5146 authored by Marc Kleine-Budde's avatar Marc Kleine-Budde
Browse files

Merge patch series "can: raw: better approach to instantly reject unsupported CAN frames"

Oliver Hartkopp <socketcan@hartkopp.net> says:

This series reverts commit 1a620a72 ("can: raw: instantly reject
unsupported CAN frames").

and its follow-up fixes for the introduced dependency issues.

commit 1a620a72 ("can: raw: instantly reject unsupported CAN frames")
commit cb2dc6d2 ("can: Kconfig: select CAN driver infrastructure by default")
commit 6abd4577 ("can: fix build dependency")
commit 5a5aff63 ("can: fix build dependency")

The reverted patch was accessing CAN device internal data structures
from the network layer because it needs to know about the CAN protocol
capabilities of the CAN devices.

This data access caused build problems between the CAN network and the
CAN driver layer which introduced unwanted Kconfig dependencies and fixes.

The patches 2 & 3 implement a better approach which makes use of the
CAN specific ml_priv data which is accessible from both sides.

With this change the CAN network layer can check the required features
and the decoupling of the driver layer and network layer is restored.

Link: https://patch.msgid.link/20260109144135.8495-1-socketcan@hartkopp.net


[mkl: give series a more descriptive name]
[mkl: properly format reverted patch commitish]
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parents 3879cffd faba5860
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only

menuconfig CAN_DEV
	bool "CAN Device Drivers"
	tristate "CAN Device Drivers"
	default y
	depends on CAN
	help
@@ -17,7 +17,10 @@ menuconfig CAN_DEV
	  virtual ones. If you own such devices or plan to use the virtual CAN
	  interfaces to develop applications, say Y here.

if CAN_DEV && CAN
	  To compile as a module, choose M here: the module will be called
	  can-dev.

if CAN_DEV

config CAN_VCAN
	tristate "Virtual Local CAN Interface (vcan)"
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ obj-$(CONFIG_CAN_VCAN) += vcan.o
obj-$(CONFIG_CAN_VXCAN)		+= vxcan.o
obj-$(CONFIG_CAN_SLCAN)		+= slcan/

obj-$(CONFIG_CAN_DEV)		+= dev/
obj-y				+= dev/
obj-y				+= esd/
obj-y				+= rcar/
obj-y				+= rockchip/
+3 −2
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0

obj-$(CONFIG_CAN) += can-dev.o
obj-$(CONFIG_CAN_DEV) += can-dev.o

can-dev-y += skb.o

can-dev-$(CONFIG_CAN_DEV) += skb.o
can-dev-$(CONFIG_CAN_CALC_BITTIMING) += calc_bittiming.o
can-dev-$(CONFIG_CAN_NETLINK) += bittiming.o
can-dev-$(CONFIG_CAN_NETLINK) += dev.o
+27 −0
Original line number Diff line number Diff line
@@ -375,6 +375,32 @@ void can_set_default_mtu(struct net_device *dev)
	}
}

void can_set_cap_info(struct net_device *dev)
{
	struct can_priv *priv = netdev_priv(dev);
	u32 can_cap;

	if (can_dev_in_xl_only_mode(priv)) {
		/* XL only mode => no CC/FD capability */
		can_cap = CAN_CAP_XL;
	} else {
		/* mixed mode => CC + FD/XL capability */
		can_cap = CAN_CAP_CC;

		if (priv->ctrlmode & CAN_CTRLMODE_FD)
			can_cap |= CAN_CAP_FD;

		if (priv->ctrlmode & CAN_CTRLMODE_XL)
			can_cap |= CAN_CAP_XL;
	}

	if (priv->ctrlmode & (CAN_CTRLMODE_LISTENONLY |
			      CAN_CTRLMODE_RESTRICTED))
		can_cap |= CAN_CAP_RO;

	can_set_cap(dev, can_cap);
}

/* helper to define static CAN controller features at device creation time */
int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode)
{
@@ -390,6 +416,7 @@ int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode)

	/* override MTU which was set by default in can_setup()? */
	can_set_default_mtu(dev);
	can_set_cap_info(dev);

	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -377,6 +377,7 @@ static int can_ctrlmode_changelink(struct net_device *dev,
	}

	can_set_default_mtu(dev);
	can_set_cap_info(dev);

	return 0;
}
Loading