RFC: Breaking API Change: drivers: can: rework support for manual bus-off recovery #69459
Labels
Architecture Review
Discussion in the Architecture WG required
area: CAN
Breaking API Change
Breaking changes to stable, public APIs
RFC
Request For Comments: want input from the community
Introduction
Many CAN controllers support two different modes for recovering from bus-off state:
The Zephyr CAN controller API supports both modes through the the
CONFIG_CAN_AUTO_BUS_OFF_RECOVERY
Kconfig option, which is enabled by default. The manual recovery API functioncan_recover()
is only functional whenCONFIG_CAN_AUTO_BUS_OFF_RECOVERY
is disabled.Problem description
Even though ISO11898-1 §6.15 states that no CAN node should automatically recover from bus-off events, manual recovery initiation is not consistently supported by the CAN controllers/drivers available in Zephyr.
This leads to incoherent behavior between drivers with
CONFIG_CAN_AUTO_BUS_OFF_RECOVERY=n
. Drivers supporting manual recovery initiation disable automatic bus-off recovery at driver initialization, while the ones not supporting manual recovery initiation keep it enabled regardless ofCONFIG_CAN_AUTO_BUS_OFF_RECOVERY=n
(there is no other option) and return-ENOTSUP
from the mandatorycan_recover()
API function.An overview of the currently supported CAN controllers along with their support manual/automatic bus-off recovery is shown in the table below.
Proposed change
Since all CAN controllers seem to support automatic recovery (for any future drivers for hardware without this hardware capability this can easily be implemented in the driver), change the Zephyr CAN controller API policy to:
CONFIG_CAN_AUTO_BUS_OFF_RECOVERY
, which is enabled by default, toCONFIG_CAN_MANUAL_RECOVERY_MODE
, which is disabled by default. EnablingCONFIG_CAN_MANUAL_RECOVERY_MODE=y
enables support for thecan_recover()
API function and a new manual recovery mode (see next bullet). Keeping this guarded by Kconfig allows keeping the flash footprint down for applications not using manual bus-off recovery.CAN_MODE_MANUAL_RECOVERY
. Support for this is only enabled ifCONFIG_CAN_MANUAL_RECOVERY_MODE=y
. Having this as a mode allows applications to inquire whether the CAN controller supports manual recovery mode via thecan_get_capabilities()
API function and either fail or rely on automatic recovery - and it allows CAN controller drivers not supporting manual recovery mode to fail early incan_set_mode()
during application startup instead of failing whencan_recover()
is called at a later point in time.Detailed RFC
Please see PR #69460.
Proposed change (Detailed)
Please see PR #69460.
Dependencies
None
Concerns and Unresolved Questions
None so far.
Alternatives
None so far.
The text was updated successfully, but these errors were encountered: