summaryrefslogtreecommitdiff
path: root/rust/helpers/xarray.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2025-09-24 17:06:20 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2025-09-24 17:08:05 +0200
commit2d51a5b83cf88dcf0100c2f1404da279fe66b522 (patch)
tree26f000f3c192ce4bedd53673fef3ac1fd07bb93e /rust/helpers/xarray.c
parentc0b595230cc19833f3a3def766a5e9865b80f8fa (diff)
parentb98aceb65e2c57df9646530e5f2b2531a661203f (diff)
Merge patch series "can: rework the CAN MTU logic (CAN XL preparation step 2/3)"
Vincent Mailhol <mailhol@kernel.org> says: The CAN MTU logic is currently broken. can_change_mtu() will update both the MTU and the CAN_CTRLMODE_FD flag. Back then, commit bc05a8944a34 ("can: allow to change the device mtu for CAN FD capable devices") stated that: The configuration can be done either with the 'fd { on | off }' option in the 'ip' tool from iproute2 or by setting the CAN netdevice MTU to CAN_MTU (16) or to CANFD_MTU (72). Link: https://git.kernel.org/torvalds/c/bc05a8944a34 The problem is that after doing for example: $ ip link set can0 mtu 72 bittiming 500000 on a CAN FD interface, we are left with a device on which CAN FD is enabled but which does not have the FD databittiming parameters configured. The same goes on when setting the mtu back to 16: ip link set can0 type can bitrate 500000 fd on dbitrate 5000000 ip link set can0 mtu 16 The device is now in Classical CAN mode but iproute2 is still reporting the databittiming values (although this time, the issue seems less critical as it is only a reporting problem). The only way to resolve the problem and bring the device back to a coherent state is to call again the netlink interface using the "fd on" or "fd off" options. The idea of being able to infer the CAN_CTRLMODE_FD flag from the MTU value is just incorrect for physical devices. Note that this logic remains valid on virtual interfaces (vcan and vxcan) because those do not have control mode flags and thus no conflict occurs. This series reworks the CAN MTU logic. The goal is to always maintain a coherent state between the MTU and the control mode flags as listed in below table: fd off, xl off fd on, xl off fd any, xl on --------------------------------------------------------------------------- default mtu CAN_MTU CANFD_MTU CANXL_MTU min mtu CAN_MTU CANFD_MTU CANXL_MIN_MTU max mtu CAN_MTU CANFD_MTU CANXL_MAX_MTU In order to switch between one column to another, the user must use the fd/xl on/off flags. Directly modifying the MTU from one column to the other is not permitted any more. The CAN XL is not yet supported at the moment, so the last column is just given as a reference to better understand what is coming up. This series will just implement the first two columns. While doing the rewrite, the logic is adjusted to reuse as much as possible the net core infrastructure. By populating: net_device->min_mtu and net_device->max_mtu the net core infrastructure will automatically: 1. validate that the user's inputs are in range. 2. report those min and max MTU values through the netlink interface. Point 1. will allow us to get rid of the can_change_mtu() in a near future for all the physical devices and point 2. allows the end user to see the valid MTU range by doing a: $ ip --details link show can0 Finally, because using the net core, it will be possible after the removal of can_change_mtu() to modify the MTU while the device is up. As stated previously, the only modifications allowed will be within the MTU range of a given CAN protocol. So for Classical CAN and CAN FD, the MTU is fixed to, respectively, CAN_MTU and CANFD_MTU. For the upcoming CAN XL, the user will be able to change the MTU to anything between CANXL_MIN_MTU and CANXL_MAX_MTU even if the device is up. The first patch of this series annotates the read access on net_device->mtu. This preparation is needed to prevent any race condition to occur when modifying the MTU while the device is up. The second patch is another preparation change which moves can_set_static_ctrlmode() from dev.h to dev.c. The third patch populates the MTU minimum and maximum value. The fourth patch is just a clean-up to remove the old can_change_mtu(). The fourth and last patch comes as a bonus content and modifies the default MTU of the vcan and vxcan so that CAN XL is on by default. Note that after this series, the old can_change_mtu() becomes useless. That function can not yet be removed because some pending changes from other maintainers' trees still depend on it. It will be removed in the next development window once all those changes reach net-next. Link: https://patch.msgid.link/20250923-can-fix-mtu-v3-0-581bde113f52@kernel.org [mkl: squashed fixup patch into 3] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'rust/helpers/xarray.c')
0 files changed, 0 insertions, 0 deletions