From c92dc21a18e6e79de2195bf6d2ec821c7f6195ef Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sat, 24 Oct 2020 09:29:39 +0200 Subject: [PATCH] api: new ID_MM_PORT_TYPE_QMI and ID_MM_PORT_TYPE_MBIM udev hints It is no longer true that all QMI ports are exposed by the qmi_wwan driver and that all MBIM ports are exposed by the cdc_mbim driver. There are other generic setups that allow exposing these types of ports using different drivers, and usually we can also know the type of port in advance via other means. Therefore, allow adding udev port type hints for QMI and MBIM ports as well. --- docs/reference/api/ModemManager-docs.xml | 4 ++ docs/reference/api/ModemManager-sections.txt | 2 + include/ModemManager-tags.h | 30 +++++++++++++ src/mm-port-probe.c | 46 ++++++++++++++++---- 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/docs/reference/api/ModemManager-docs.xml b/docs/reference/api/ModemManager-docs.xml index 42dbf1f6..61850603 100644 --- a/docs/reference/api/ModemManager-docs.xml +++ b/docs/reference/api/ModemManager-docs.xml @@ -139,4 +139,8 @@ Index of new symbols in 1.12 + + Index of new symbols in 1.16 + + diff --git a/docs/reference/api/ModemManager-sections.txt b/docs/reference/api/ModemManager-sections.txt index e63ce121..478f4793 100644 --- a/docs/reference/api/ModemManager-sections.txt +++ b/docs/reference/api/ModemManager-sections.txt @@ -164,6 +164,8 @@ ID_MM_PORT_TYPE_AT_SECONDARY ID_MM_PORT_TYPE_GPS ID_MM_PORT_TYPE_QCDM ID_MM_PORT_TYPE_AUDIO +ID_MM_PORT_TYPE_QMI +ID_MM_PORT_TYPE_MBIM ID_MM_TTY_BAUDRATE ID_MM_TTY_FLOW_CONTROL diff --git a/include/ModemManager-tags.h b/include/ModemManager-tags.h index 633060b7..2566cebb 100644 --- a/include/ModemManager-tags.h +++ b/include/ModemManager-tags.h @@ -213,6 +213,36 @@ */ #define ID_MM_PORT_TYPE_AUDIO "ID_MM_PORT_TYPE_AUDIO" +/** + * ID_MM_PORT_TYPE_QMI: + * + * This is a port-specific tag applied to generic ports that we know in advance + * are QMI ports. + * + * This tag will also prevent other types of probing (e.g. AT, MBIM) on the + * port. + * + * This tag is not required for QMI ports exposed by the qmi_wwan driver. + * + * Since: 1.16 + */ +#define ID_MM_PORT_TYPE_QMI "ID_MM_PORT_TYPE_QMI" + +/** + * ID_MM_PORT_TYPE_MBIM: + * + * This is a port-specific tag applied to generic ports that we know in advance + * are MBIM ports. + * + * This tag will also prevent other types of probing (e.g. AT, QMI) on the + * port. + * + * This tag is not required for MBIM ports exposed by the cdc_mbim driver. + * + * Since: 1.16 + */ +#define ID_MM_PORT_TYPE_MBIM "ID_MM_PORT_TYPE_MBIM" + /** * ID_MM_TTY_BAUDRATE: * diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c index 947be83b..e2b57bda 100644 --- a/src/mm-port-probe.c +++ b/src/mm-port-probe.c @@ -101,6 +101,8 @@ struct _MMPortProbePrivate { gboolean maybe_at_secondary; gboolean maybe_at_ppp; gboolean maybe_qcdm; + gboolean maybe_qmi; + gboolean maybe_mbim; /* Current probing task. Only one can be available at a time */ GTask *task; @@ -1428,30 +1430,54 @@ mm_port_probe_run (MMPortProbe *self, return; } - /* If this is a port flagged as a GPS port, don't do any AT or QCDM probing */ + /* If this is a port flagged as a GPS port, don't do any other probing */ if (self->priv->is_gps) { mm_obj_dbg (self, "GPS port detected"); - mm_port_probe_set_result_at (self, FALSE); + mm_port_probe_set_result_at (self, FALSE); mm_port_probe_set_result_qcdm (self, FALSE); + mm_port_probe_set_result_qmi (self, FALSE); + mm_port_probe_set_result_mbim (self, FALSE); } - /* If this is a port flagged as an audio port, don't do any AT or QCDM probing */ + /* If this is a port flagged as an audio port, don't do any other probing */ if (self->priv->is_audio) { mm_obj_dbg (self, "audio port detected"); - mm_port_probe_set_result_at (self, FALSE); + mm_port_probe_set_result_at (self, FALSE); mm_port_probe_set_result_qcdm (self, FALSE); + mm_port_probe_set_result_qmi (self, FALSE); + mm_port_probe_set_result_mbim (self, FALSE); } - /* If this is a port flagged as being an AT port, don't do any QCDM probing */ + /* If this is a port flagged as being an AT port, don't do any other probing */ if (self->priv->maybe_at_primary || self->priv->maybe_at_secondary || self->priv->maybe_at_ppp) { - mm_obj_dbg (self, "no QCDM probing in possible AT port"); + mm_obj_dbg (self, "no QCDM/QMI/MBIM probing in possible AT port"); mm_port_probe_set_result_qcdm (self, FALSE); + mm_port_probe_set_result_qmi (self, FALSE); + mm_port_probe_set_result_mbim (self, FALSE); } - /* If this is a port flagged as being a QCDM port, don't do any AT probing */ + /* If this is a port flagged as being a QCDM port, don't do any other probing */ if (self->priv->maybe_qcdm) { - mm_obj_dbg (self, "no AT probing in possible QCDM port"); - mm_port_probe_set_result_at (self, FALSE); + mm_obj_dbg (self, "no AT/QMI/MBIM probing in possible QCDM port"); + mm_port_probe_set_result_at (self, FALSE); + mm_port_probe_set_result_qmi (self, FALSE); + mm_port_probe_set_result_mbim (self, FALSE); + } + + /* If this is a port flagged as being a QMI port, don't do any other probing */ + if (self->priv->maybe_qmi) { + mm_obj_dbg (self, "no AT/QCDM/MBIM probing in possible QMI port"); + mm_port_probe_set_result_at (self, FALSE); + mm_port_probe_set_result_qcdm (self, FALSE); + mm_port_probe_set_result_mbim (self, FALSE); + } + + /* If this is a port flagged as being a MBIM port, don't do any other probing */ + if (self->priv->maybe_mbim) { + mm_obj_dbg (self, "no AT/QCDM/QMI probing in possible MBIM port"); + mm_port_probe_set_result_at (self, FALSE); + mm_port_probe_set_result_qcdm (self, FALSE); + mm_port_probe_set_result_qmi (self, FALSE); } /* Check if we already have the requested probing results. @@ -1819,6 +1845,8 @@ set_property (GObject *object, self->priv->maybe_at_secondary = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_SECONDARY); self->priv->maybe_at_ppp = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_PPP); self->priv->maybe_qcdm = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_QCDM); + self->priv->maybe_qmi = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_QMI); + self->priv->maybe_mbim = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_MBIM); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);