zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.71k stars 6.54k forks source link

drivers: can: mcan Filtering not possible for Regular and Fd frames for the same frame type #64554

Closed palisows closed 9 months ago

palisows commented 11 months ago

Descpription Can filters has been used to capture selected frames types, e.g. CAN B and CAN B FD. CanId is not used for filtering - id and mask from can_filter are set to 0. Filter is successfully applied with can_add_rx_filter, assigned filterId are 0 and 1.

When frame is captured, zephyr can't properly point out filt_idx in can_mcan_get_message. It's always 0 not mater I send CAN B or CAN B FD frame. Thus for CAN B FD frame pointed filter is for CAN B and frame is dropped.

As workaround conditions related to CAN_FRAME_FDF and CAN_FILTER_FDF could be removed from can_mcan_get_message. It means FD flag will be ignored when filtering.

Problem is caused by HW limitation which is not able to distinguish filters when difference is only in filter flags. Basically HW doesn't take it into consideration when matching frames.

I'm using zephyr version 3.5.0. Platform is stm32 with can fd driver.

To Reproduce Configure two filters with can_add_rx_filter and flags set to:

  1. CAN_FILTER_DATA | CAN_FILTER_IDE
  2. CAN_FILTER_DATA | CAN_FILTER_IDE | CAN_FILTER_FDF

id and mask are set to 0 for both cases. Send both frame types and check filt_idx from can_mcan_get_message. It's always 0 and points for first configured filter.

Expected behavior For CAN B, filt_idx should 0, for CAN B FD, filt_idx should 1.

Impact I can workaround but at cost of lost performance.

Logs and console output

Environment (please complete the following information):

Additional context Order of filters can be reversed when configured, then CAN B FD frames will be accepted.

github-actions[bot] commented 11 months ago

Hi @palisows! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

henrikbrixandersen commented 11 months ago

@palisows Thanks, I am looking into a fix.

henrikbrixandersen commented 11 months ago

@palisows Proposed fix provided as part of RFC #65109.

github-actions[bot] commented 9 months ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.