Skip to content

modem: cmux: Remove double buffering from frame parsing#105370

Merged
MaureenHelm merged 2 commits intozephyrproject-rtos:mainfrom
SeppoTakalo:cmux_double_buffer
Mar 17, 2026
Merged

modem: cmux: Remove double buffering from frame parsing#105370
MaureenHelm merged 2 commits intozephyrproject-rtos:mainfrom
SeppoTakalo:cmux_double_buffer

Conversation

@SeppoTakalo
Copy link
Contributor

Remove double buffering that was using a separate cmux->work_buffer to fetch data from
modem_pipe. The packet content was then copied into cmux->receive_buffer before being pushed into the DLC pipe, which have their own buffer.
So this double-buffering is redudant.

                 |..frame is parsed here....and copied....|
[UART RX BUF]--->[CMUX work_buffer]-->[CMUX receive_buffer]--->[DLC rx buffer]

Instead, receive and parse frames directly into receive_buffer.

This saves MODEM_CMUX_WORK_BUFFER_SIZE of RAM and avoids
one copy from work_buffer to receive_buffer.

Driver already asserts if the receive buffer does not fit
maximum frame, so it should be properly sized.

Minor changes:

Add few checks into CMUX frame parsing.
These are mostly a result of fuzz testing the parser. Not issues seen in real life.

Remove double buffering that was using a separate work_buffer.
Receive and parse frames directly into receive_buffer instead.

This saves MODEM_CMUX_WORK_BUFFER_SIZE of RAM and avoids
one copy from work_buffer to receive_buffer.

Driver already asserts if the receive buffer does not fit
maximum frame, so it should be properly sized.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Check for:
* valid frame type
* valid address (range 0..63)
* command decoding length.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
@sonarqubecloud
Copy link

@MaureenHelm MaureenHelm merged commit 3abf8e4 into zephyrproject-rtos:main Mar 17, 2026
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants