Skip to content

Commit f047a41

Browse files
JordanYateshenrikbrixandersen
authored andcommitted
modem: cmux: auto calculate work buffer sizes
Automatically size the CMUX work buffers based on `CONFIG_MODEM_CMUX_MTU`. This eliminates a Kconfig variable that would otherwise need to manually be kept in sync. The option to extend the size of these buffers is still provided through `CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA`. Signed-off-by: Jordan Yates <[email protected]>
1 parent 4b39be6 commit f047a41

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

doc/releases/migration-guide-4.3.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ Modem
197197
*****
198198

199199
* ``CONFIG_MODEM_AT_SHELL_USER_PIPE`` has been renamed to :kconfig:option:`CONFIG_MODEM_AT_USER_PIPE`.
200+
* ``CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE`` has been updated to :kconfig:option:`CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA`,
201+
which only takes the number of extra bytes desired over the default of (:kconfig:option:`CONFIG_MODEM_CMUX_MTU` + 7).
200202

201203
Display
202204
*******

drivers/modem/modem_cellular.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@ struct modem_cellular_data {
112112

113113
/* CMUX */
114114
struct modem_cmux cmux;
115-
uint8_t cmux_receive_buf[CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE];
116-
uint8_t cmux_transmit_buf[CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE];
115+
uint8_t cmux_receive_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
116+
uint8_t cmux_transmit_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
117117

118118
struct modem_cmux_dlci dlci1;
119119
struct modem_cmux_dlci dlci2;
120120
struct modem_pipe *dlci1_pipe;
121121
struct modem_pipe *dlci2_pipe;
122122
/* Points to dlci2_pipe or NULL. Used for shutdown script if not NULL */
123123
struct modem_pipe *cmd_pipe;
124-
uint8_t dlci1_receive_buf[CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE];
124+
uint8_t dlci1_receive_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
125125
/* DLCI 2 is only used for chat scripts. */
126-
uint8_t dlci2_receive_buf[CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE];
126+
uint8_t dlci2_receive_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
127127

128128
/* Modem chat */
129129
struct modem_chat chat;

include/zephyr/modem/cmux.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ typedef void (*modem_cmux_callback)(struct modem_cmux *cmux, enum modem_cmux_eve
5757
* @cond INTERNAL_HIDDEN
5858
*/
5959

60+
/* Total size of the CMUX work buffers */
61+
#define MODEM_CMUX_WORK_BUFFER_SIZE (CONFIG_MODEM_CMUX_MTU + 7 + \
62+
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA)
63+
6064
enum modem_cmux_state {
6165
MODEM_CMUX_STATE_DISCONNECTED = 0,
6266
MODEM_CMUX_STATE_CONNECTING,
@@ -152,7 +156,7 @@ struct modem_cmux {
152156
uint16_t receive_buf_size;
153157
uint16_t receive_buf_len;
154158

155-
uint8_t work_buf[CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE];
159+
uint8_t work_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
156160

157161
/* Transmit buffer */
158162
struct ring_buf transmit_rb;

subsys/modem/Kconfig

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ config MODEM_CMUX_MTU
4242
Maximum Transmission Unit (MTU) size for the CMUX module.
4343
Linux ldattach defaults to 127 bytes, 3GPP TS 27.010 to 31.
4444

45-
config MODEM_CMUX_WORK_BUFFER_SIZE
46-
int "CMUX module work buffer size in bytes"
47-
range 23 1507
48-
default 134 if MODEM_CMUX_DEFAULT_MTU_127
49-
default 38
45+
config MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA
46+
int "CMUX module extra work buffer size in bytes"
47+
default 0
5048
help
51-
Size of the work buffer used by the CMUX module.
52-
Recommended size is MODEM_CMUX_MTU + 7 (CMUX header size).
49+
Extra bytes to add to the work buffers used by the CMUX module.
50+
The default size of these buffers is MODEM_CMUX_MTU + 7 (CMUX header size).
5351

5452
module = MODEM_CMUX
5553
module-str = modem_cmux

0 commit comments

Comments
 (0)