From 965c43fec7b5ca25483b1d73f0bdec339636f996 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sat, 31 Jul 2021 23:45:26 +0200 Subject: port-qmi: limit MTU to max RMNET packet size The maximum MTU that the master interface can support should be less or equal than RMNET_MAX_PACKET_SIZE, as defined in the `rmnet_private.h` file in the linux sources (not a public header). Only applicable to RMNET link management (i.e. not to qmi_wwan add_mux/del_mux). Fixes https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/issues/71 --- src/mm-port-qmi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/mm-port-qmi.c') diff --git a/src/mm-port-qmi.c b/src/mm-port-qmi.c index 5cccb02a..a7fbee84 100644 --- a/src/mm-port-qmi.c +++ b/src/mm-port-qmi.c @@ -31,6 +31,9 @@ #define DEFAULT_LINK_PREALLOCATED_AMOUNT 4 +/* as internally defined in the kernel */ +#define RMNET_MAX_PACKET_SIZE 16384 + G_DEFINE_TYPE (MMPortQmi, mm_port_qmi, MM_TYPE_PORT) #if defined WITH_QRTR @@ -1321,8 +1324,13 @@ setup_master_mtu (GTask *task) * aggregation size */ if (ctx->kernel_data_modes_requested & (MM_PORT_QMI_KERNEL_DATA_MODE_MUX_RMNET | MM_PORT_QMI_KERNEL_DATA_MODE_MUX_QMIWWAN)) { /* Load current max datagram size supported */ - if (MM_PORT_QMI_DAP_IS_SUPPORTED_QMAP (ctx->wda_dl_dap_requested)) + if (MM_PORT_QMI_DAP_IS_SUPPORTED_QMAP (ctx->wda_dl_dap_requested)) { mtu = ctx->wda_dl_dap_max_size_current; + if ((ctx->kernel_data_modes_requested & MM_PORT_QMI_KERNEL_DATA_MODE_MUX_RMNET) && (mtu > RMNET_MAX_PACKET_SIZE)) { + mm_obj_dbg (self, "mtu limited to maximum rmnet packet size"); + mtu = RMNET_MAX_PACKET_SIZE; + } + } /* If no max aggregation size was specified by the modem (e.g. if we requested QMAP * aggregation protocol but the modem doesn't support it), skip */ -- cgit v1.2.3-70-g09d2