Skip to content

modem: cmux: Decouple modem cmux and modem cellular driver #93441

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

Conversation

bjarki-andreasen
Copy link
Contributor

The modem modules cmux module is currently directly coupled to the presence of specific modems, rather than being selected by drivers for whatever hardware wants to request the default MTU of 127 bytes.

This commit moves the makes the device drivers (for now, modem_cellular) select the symbol, thus decoupling the modem modules from the presence of any specific device.

Copy link
Contributor

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message typo? This commit moves the makes the device drivers

help
Use the default MTU size of 127 bytes for the CMUX module on certain modems.
This must match the AT+CMUX commands in the modem_cellular driver.
Hint that the default MODEM_CMUX_MTU size should be 127 bytes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's not just a hint? It's enforced by the CMUX module?

Copy link
Contributor Author

@bjarki-andreasen bjarki-andreasen Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its enforced by MODEM_CMUX_MTU :) The default is just a default, so this hint is telling CMUX that something in the system would prefer MTU be 127, but it is definitely still directly settable by the application

Copy link
Contributor Author

@bjarki-andreasen bjarki-andreasen Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking a bit closer, what does MODEM_CMUX_MTU do? It seems like an artificial limit, given the actual limit of CMUX frame sizes is MODEM_CMUX_WORK_BUFFER_SIZE, where is it used favorably to MODEM_CMUX_WORK_BUFFER_SIZE?

Copy link
Contributor Author

@bjarki-andreasen bjarki-andreasen Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, we have no way to configure the MTU used by CMUX, major oversight on my end when creating the API...

The struct modem_cmux_config should be updated to include the MTU, this way, it becomes instance specific and needs no global config. On top of that, part of the receive buffer should be reserved for the work buffer. These two changes remove all hardcoded configs from the CMUX implementation :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good. FYI @SeppoTakalo @MarkusLassila

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMUX frame sizes were last worked on PR #87115
And it is configurable by Kconfig.
Surely it can be a runtime configurable, but does it really make much difference? You have selected the modem already in the build time.

Some modems use hard-coded MTU for the CMUX. Some allow it to be configured in the AT command that enables the CMUX framing.
Even some clients hard-code the value. For example Linux ldattach uses 127.
3GPP default is 32.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking a bit closer, what does MODEM_CMUX_MTU do? It seems like an artificial limit

It is not an artificial limit, frames bigger than the MTU what the receiver can process, are dropped.

It is not directly related to how much we have buffer space. It depends on the remote end as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is not to make the MTU runtime configurable, but to make it instance specific instead a global property.

The modem modules cmux module is currently directly coupled to the
presence of specific modems, rather than being selected by drivers
for whatever hardware wants to request the default MTU of 127 bytes.

This commit the makes the device drivers (for now, modem_cellular)
select the symbol, thus decoupling the modem modules from the
presence of any specific device.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
@bjarki-andreasen bjarki-andreasen force-pushed the modem-cmux-default-mtu-sym branch from f22cd6c to 9106b15 Compare July 21, 2025 14:44
Copy link

@tomi-font
Copy link
Contributor

Commit message typo? This commit moves the makes the device drivers

Still typo? 😄 This commit the makes the device drivers

@fabiobaltieri fabiobaltieri merged commit 638bf6b into zephyrproject-rtos:main Jul 23, 2025
25 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.

6 participants