aboutsummaryrefslogtreecommitdiff
path: root/src/mm-bearer-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2023-06-15 08:27:13 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2023-06-16 20:58:04 +0000
commit3004a3e53263625da0b26e50c9107f1bad5b371e (patch)
treee9377da944a3ec31e6b297d407716a998f8928fd /src/mm-bearer-qmi.c
parent547d40009c665d523e15cabfee028fc2604660dd (diff)
broadband-modem-qmi|mbim: allow limiting multiplexed links with udev tags
Certain QMI or MBIM devices may not be able to support multiplexing at all, or they may support a limited amount of links. The new ID_MM_MAX_MULTIPLEXED_LINKS udev tag allows specifying the maximum number of supported multiplexed links; e.g. 0 to report none supported or 1 to report that one single multiplexed link is supported.
Diffstat (limited to 'src/mm-bearer-qmi.c')
-rw-r--r--src/mm-bearer-qmi.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c
index caf925db..54f2e934 100644
--- a/src/mm-bearer-qmi.c
+++ b/src/mm-bearer-qmi.c
@@ -2442,8 +2442,21 @@ load_settings_from_bearer (MMBearerQmi *self,
GError *inner_error = NULL;
const gchar *str;
const gchar *data_port_driver;
+ guint current_multiplexed_bearers;
+ guint max_multiplexed_bearers;
+ gboolean multiplex_supported = TRUE;
+
+ if (!mm_broadband_modem_get_active_multiplexed_bearers (MM_BROADBAND_MODEM (ctx->modem),
+ &current_multiplexed_bearers,
+ &max_multiplexed_bearers,
+ error))
+ return FALSE;
+ /* Check multiplex support in the kernel and the device */
data_port_driver = mm_kernel_device_get_driver (mm_port_peek_kernel_device (ctx->data));
+ /* All drivers should support multiplexing */
+ if (!max_multiplexed_bearers)
+ multiplex_supported = FALSE;
/* If no multiplex setting given by the user, assume none; unless in IPA */
ctx->multiplex = mm_bearer_properties_get_multiplex (properties);
@@ -2456,9 +2469,31 @@ load_settings_from_bearer (MMBearerQmi *self,
ctx->multiplex = MM_BEARER_MULTIPLEX_SUPPORT_NONE;
}
- /* The link prefix hint given must be modem-specific */
+ /* If multiplex unsupported, either abort or default to none */
+ if (!multiplex_supported) {
+ if (ctx->multiplex == MM_BEARER_MULTIPLEX_SUPPORT_REQUIRED) {
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Multiplexing required but not supported");
+ return FALSE;
+ }
+ if (ctx->multiplex == MM_BEARER_MULTIPLEX_SUPPORT_REQUESTED) {
+ mm_obj_dbg (self, "Multiplexing unsupported");
+ ctx->multiplex = MM_BEARER_MULTIPLEX_SUPPORT_NONE;
+ }
+ }
+
+ /* Go on with multiplexing enabled */
if (ctx->multiplex == MM_BEARER_MULTIPLEX_SUPPORT_REQUESTED ||
ctx->multiplex == MM_BEARER_MULTIPLEX_SUPPORT_REQUIRED) {
+ g_assert (multiplex_supported);
+
+ if (current_multiplexed_bearers == max_multiplexed_bearers) {
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Maximum number of multiplexed bearers reached");
+ return FALSE;
+ }
+
+ /* The link prefix hint given must be modem-specific */
ctx->link_prefix_hint = g_strdup_printf ("qmapmux%u.", mm_base_modem_get_dbus_id (MM_BASE_MODEM (modem)));
}