Quectel EG21 modem QMI connection works but MM fallbacks to ttyUSB2 as primary port

Rafal Mszal rafal.mszal at tier.app
Thu Nov 26 10:15:27 UTC 2020


Hi Aleksander,


> I saw your merge request and replied about that there, the problem you
> had with ModemManager not detecting the cdc-wdm port as a QMI port was
> indeed the kernel driver name, "qmi_wwan_q" vs "qmi_wwan":
>
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/406

Thanks for confirmation, no worries about the merge request, I wasn't
convinced this is the way to fix it neither.

Hi Carl,

> For you are using EC21, the upstream qmi_wwan driver is enough.
>         If the EC21's VID and PID is not in the qmi_wwan.c products
table, you just need add it, as next:
>         {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe
*/
>
>         If you are using LTE-A or 5G modules, it is recomment to use MBIM
(set by at+qcfg="usbnet", 2 )
>         (for these modems, it is recomment or mandatory to use "QMAP"
fucntion, but not well support by the upsream qmi_wwan)

Thanks for comment, I am using kernel 5.4.8 - I've just checked that
upstream qmi_wwan driver handles EG21 without any issues, so just like
you've said there is no point to add the qmi_wwan_q driver. Please update
the "LTE&5G Linux USB
Driver User Guide" doc so that in future no one else falls into these
issues.

For those who wants to use qmi_wwan_q driver with a Modem Manager, here is
the hint how the workaround patch should look like - I am basically
replacing strcmp checks with has_prefix checks against the 'qmi_wwan'
driver name to accept the 'qmi_wwan_q' driver as well:

diff --git a/src/kerneldevice/mm-kernel-device-udev.c
b/src/kerneldevice/mm-kernel-device-udev.c
index 4b06969e..10abefc4 100644
--- a/src/kerneldevice/mm-kernel-device-udev.c
+++ b/src/kerneldevice/mm-kernel-device-udev.c
@@ -87,7 +87,7 @@ get_device_ids (GUdevDevice *device,
                 success = TRUE;
                 goto out;
             } else if (g_str_has_prefix (parent_subsys, "usb") &&
-                       (!g_strcmp0 (g_udev_device_get_driver (parent),
"qmi_wwan") ||
+                       (g_str_has_prefix (g_udev_device_get_driver
(parent), "qmi_wwan") ||
                         !g_strcmp0 (g_udev_device_get_driver (parent),
"cdc_mbim"))) {
                 /* Need to look for vendor/product in the parent of the
QMI/MBIM device */
                 GUdevDevice *qmi_parent;
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index 7150b037..06128c93 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -316,7 +316,7 @@ apply_pre_probing_filters (MMPlugin       *self,

             for (j = 0; drivers[j]; j++) {
                 /* If we match the QMI driver: unsupported */
-                if (g_str_equal (drivers[j], "qmi_wwan")) {
+                if (g_str_has_prefix (drivers[j], "qmi_wwan")) {
                     mm_dbg ("(%s) [%s] filtered by implicit QMI driver",
                             self->priv->name,
                             mm_kernel_device_get_name (port));
@@ -801,7 +801,7 @@ mm_plugin_supports_port (MMPlugin            *self,
             probe_run_flags |= MM_PORT_PROBE_QCDM;
     } else {
         /* cdc-wdm ports... */
-        if (self->priv->qmi && !g_strcmp0 (mm_kernel_device_get_driver
(port), "qmi_wwan"))
+        if (self->priv->qmi && g_str_has_prefix
(mm_kernel_device_get_driver (port), "qmi_wwan"))
             probe_run_flags |= MM_PORT_PROBE_QMI;
         else if (self->priv->mbim && !g_strcmp0
(mm_kernel_device_get_driver (port), "cdc_mbim"))
             probe_run_flags |= MM_PORT_PROBE_MBIM;
@@ -980,7 +980,7 @@ mm_plugin_create_modem (MMPlugin  *self,
 #if defined WITH_QMI
             if (MM_IS_BROADBAND_MODEM_QMI (modem) &&
                 port_type == MM_PORT_TYPE_NET &&
-                g_strcmp0 (driver, "qmi_wwan") != 0) {
+                !g_str_has_prefix (driver, "qmi_wwan")) {
                 /* Non-QMI net ports are ignored in QMI modems */
                 mm_dbg ("(%s/%s): ignoring non-QMI net port in QMI modem",
subsys, name);
                 force_ignored = TRUE;
@@ -989,7 +989,7 @@ mm_plugin_create_modem (MMPlugin  *self,

             if (!MM_IS_BROADBAND_MODEM_QMI (modem) &&
                 port_type == MM_PORT_TYPE_NET &&
-                g_strcmp0 (driver, "qmi_wwan") == 0) {
+                g_str_has_prefix (driver, "qmi_wwan")) {
                 /* QMI net ports are ignored in non-QMI modems */
                 mm_dbg ("(%s/%s): ignoring QMI net port in non-QMI modem",
subsys, name);
                 force_ignored = TRUE;
@@ -997,7 +997,7 @@ mm_plugin_create_modem (MMPlugin  *self,
             }
 #else
             if (port_type == MM_PORT_TYPE_NET &&
-                g_strcmp0 (driver, "qmi_wwan") == 0) {
+                g_str_has_prefix (driver, "qmi_wwan")) {
                 /* QMI net ports are ignored if QMI support not built */
                 mm_dbg ("(%s/%s): ignoring QMI net port as QMI support
isn't available", subsys, name);
                 force_ignored = TRUE;

This was checked for Modem Manager v1.12.10.

Thanks a lot for help guys!

Best Regards,
Rafał

On Thu, Nov 26, 2020 at 10:09 AM Aleksander Morgado <
aleksander at aleksander.es> wrote:

> Hey Carl,
>
> >         Quectel has lot of customers, and most of them are use system
> like openwrt, android, others embedded -linux.
> >         and the kernel version used is usually is V3.x,V4.x.
> >         it will spend very much time (for quectel-self and customers):
> >                          if we appiled patch to the upstream qmi_wwan
> driver, and back-port the driver to the customer's kernel.
> >         So we directly povide qmi_wwan_q.c, suitable for ALL kernel
> versions (V3.2 and later), the customers just need 'copy + paste' it.
> >
>
> That's a fair enough reason I guess. May I suggest, though, that
> instead of always telling your customers to use the "qmi_wwan_q"
> driver, you could tell them something like "the EC21 (0x2c7c, 0x0121)
> is supported in the Linux kernel since v4.9"? Your driver should be a
> fallback case when the user is using an old kernel that doesn't
> support the module by default, your driver should not be the default
> IMO. Keeping a list with your module versions and the kernel versions
> where support was introduced would be a great source of information
> for your customers ;)
>
> --
> Aleksander
> https://aleksander.es
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/modemmanager-devel/attachments/20201126/ff6e2160/attachment-0001.htm>


More information about the ModemManager-devel mailing list