modem: modem_cellular: Configurable MTU for CMUX

Allow configuring MTU for CMUX.
Some AT manual and specification define this as a
frame size. Linux ldattach default to 127 bytes,
3GPP TS 27.010 defaults to 31.

We should limit our CMUX frames to a size that
remote end is capable of handling.
Linux silently drops oversized frames.

Also, remove MODEM_CELLULAR_CMUX_MAX_FRAME_SIZE as
this was only limiting a buffer sizes, and resulted
CMUX frames to be capped to same value.
Use MODEM_CMUX_WORK_BUFFER_SIZE and MODEM_CMUX_MTU instead.

Also rename CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZES to
CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZE as it is now
only used as a Chat module. DLCI pipes use
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit is contained in:
Seppo Takalo 2025-03-14 14:58:09 +02:00 committed by Benjamin Cabé
commit c78081e5cf
11 changed files with 75 additions and 23 deletions

View file

@ -5,5 +5,6 @@ CONFIG_NO_OPTIMIZATIONS=y
CONFIG_MODEM_MODULES=y
CONFIG_MODEM_CMUX=y
CONFIG_MODEM_CMUX_MTU=64
CONFIG_ZTEST=y

View file

@ -27,6 +27,8 @@
#define EVENT_CMUX_DLCI1_CLOSED BIT(7)
#define EVENT_CMUX_DLCI2_CLOSED BIT(8)
#define EVENT_CMUX_DISCONNECTED BIT(9)
#define CMUX_BASIC_HRD_SMALL_SIZE 6
#define CMUX_BASIC_HRD_LARGE_SIZE 7
/*************************************************************************************************/
/* Instances */
@ -195,6 +197,8 @@ static uint8_t cmux_frame_data_dlci2_ppp_18[] = {0x7E, 0xFF, 0x7D, 0x23, 0xC0, 0
0x7D, 0x22, 0x7D, 0x21, 0x7D, 0x20,
0x7D, 0x24, 0x7D, 0x3C, 0x90, 0x7E};
static uint8_t cmux_frame_data_large[127] = { [0 ... 126] = 0xAA };
const static struct modem_backend_mock_transaction transaction_control_cld = {
.get = cmux_frame_control_cld_cmd,
.get_size = sizeof(cmux_frame_control_cld_cmd),
@ -864,4 +868,22 @@ ZTEST(modem_cmux, test_modem_drop_frames_with_invalid_length)
"Incorrect data received");
}
ZTEST(modem_cmux, test_modem_cmux_split_large_data)
{
int ret;
uint32_t events;
ret = modem_pipe_transmit(dlci2_pipe, cmux_frame_data_large,
sizeof(cmux_frame_data_large));
zassert_true(ret == CONFIG_MODEM_CMUX_MTU, "Failed to split large data %d", ret);
events = k_event_wait(&cmux_event, EVENT_CMUX_DLCI2_TRANSMIT_IDLE, false, K_MSEC(200));
zassert_equal(events, EVENT_CMUX_DLCI2_TRANSMIT_IDLE,
"Transmit idle event not received for DLCI2 pipe");
ret = modem_backend_mock_get(&bus_mock, buffer2, sizeof(buffer2));
zassert_true(ret == CONFIG_MODEM_CMUX_MTU + CMUX_BASIC_HRD_SMALL_SIZE,
"Incorrect number of bytes transmitted %d", ret);
}
ZTEST_SUITE(modem_cmux, NULL, test_modem_cmux_setup, test_modem_cmux_before, NULL, NULL);

View file

@ -5,5 +5,6 @@ CONFIG_NO_OPTIMIZATIONS=y
CONFIG_MODEM_MODULES=y
CONFIG_MODEM_CMUX=y
CONFIG_MODEM_CMUX_MTU=64
CONFIG_ZTEST=y