-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: can: various RTR fixes #47903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fabiobaltieri
merged 4 commits into
zephyrproject-rtos:main
from
vestas-wind-systems:can_mcan_rtr_vs_no_rtr
Jul 18, 2022
Merged
drivers: can: various RTR fixes #47903
fabiobaltieri
merged 4 commits into
zephyrproject-rtos:main
from
vestas-wind-systems:can_mcan_rtr_vs_no_rtr
Jul 18, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Bosch M_CAN IP does not support RX filtering of the RTR bit, so the driver handles this bit in software. If a recevied frame matches a filter with RTR enabled, the RTR bit of the frame must match that of the filter in order to be passed to the RX callback function. If the RTR bits do not match the frame must be dropped. Improve the readability of the the logic for determining if a frame should be dropped and add a missing FIFO acknowledge write for dropped frames. Fixes: zephyrproject-rtos#47204 Signed-off-by: Henrik Brix Andersen <[email protected]>
When installing a RX filter, the driver uses "filter->rtr & filter->rtr_mask" for setting the filter mask. It should just be using filter->rtr_mask, otherwise filters for non-RTR frames will match RTR frames as well. When transmitting a RTR frame, the hardware automatically switches the mailbox used for TX to RX in order to receive the reply. This, however, does not match the Zephyr CAN driver model, where mailboxes are dedicated to either RX or TX. Attempting to reuse the TX mailbox (which was automatically switched to an RX mailbox by the hardware) fails on the first call, after which the mailbox is reset and can be reused for TX. To overcome this, the driver must abort the RX mailbox operation when the hardware performs the TX to RX switch. Fixes: zephyrproject-rtos#47902 Signed-off-by: Henrik Brix Andersen <[email protected]>
Check the frame ID type and RTR bit when comparing loopback CAN frames against installed RX filters. Fixes: zephyrproject-rtos#47904 Signed-off-by: Henrik Brix Andersen <[email protected]>
Add test for CAN RX filtering of RTR frames. Signed-off-by: Henrik Brix Andersen <[email protected]>
bd1b42d
to
0e6f654
Compare
martinjaeger
approved these changes
Jul 17, 2022
str4t0m
approved these changes
Jul 18, 2022
This was referenced Jul 18, 2022
This was referenced Jul 18, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: CAN
backport v2.7-branch
Request backport to the v2.7-branch
bug
The issue is a bug, or the PR is fixing a bug
platform: NXP
NXP
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The newly added test cases were verified on the following boards:
lpcxpresso55s16
nucleo_g474re
twr_ke18f
mimxrt1024_evk
frdm_k64f
stm32f3_disco
native_posix_64
keyestudio_can_bus_ks0411
(shield)