diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-12-27 22:47:36 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-03-03 17:23:07 +0000 |
commit | 353e27065dc9d8cf95e0ad81e14aae61648e2c85 (patch) | |
tree | a4004a8e13db094b1e3960d0eb50c22613e27fa0 | |
parent | 9ef84d2cff27e99c2e805d636528d1740bc4985a (diff) |
huawei: try to read port type hints from interface descriptions
So far, we're really only interested in the "modem" and "pcui" ports.
root@9d52738:/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4# find . -name interface|sort
./1-1.4:2.0/interface
./1-1.4:2.1/interface
./1-1.4:2.2/interface
./1-1.4:2.3/interface
./1-1.4:2.4/interface
./1-1.4:2.5/interface
./1-1.4:2.6/interface
root@9d52738:/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4# find . -name interface|sort|xargs cat
CDC Ethernet Control Model (ECM)
CDC Ethernet Data
Huawei Mobile Connect - Modem
Huawei Mobile Connect - Application
Huawei Mobile Connect - Pcui
Huawei Mobile Connect - Ctrl
Huawei Mobile Connect - Serial B
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/170
-rw-r--r-- | plugins/huawei/mm-plugin-huawei.c | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/plugins/huawei/mm-plugin-huawei.c b/plugins/huawei/mm-plugin-huawei.c index 26bf3f2a..2fd73995 100644 --- a/plugins/huawei/mm-plugin-huawei.c +++ b/plugins/huawei/mm-plugin-huawei.c @@ -421,42 +421,67 @@ static void propagate_port_mode_results (GList *probes) { MMDevice *device; - GList *l; - gboolean primary_flagged = FALSE; + GList *l; + gboolean primary_flagged = FALSE; g_assert (probes != NULL); - device = mm_port_probe_peek_device (MM_PORT_PROBE (probes->data)); /* Now we propagate the tags to the specific port probes */ + device = mm_port_probe_peek_device (MM_PORT_PROBE (probes->data)); for (l = probes; l; l = g_list_next (l)) { - MMPortSerialAtFlag at_port_flags = MM_PORT_SERIAL_AT_FLAG_NONE; - guint usbif; + MMPortSerialAtFlag at_port_flags = MM_PORT_SERIAL_AT_FLAG_NONE; + MMPortProbe *probe; + guint usbif; + const gchar *description; + + probe = MM_PORT_PROBE (l->data); - usbif = mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (MM_PORT_PROBE (l->data)), "ID_USB_INTERFACE_NUM"); + /* Tags only applicable to AT ports */ + if (!mm_port_probe_is_at (probe)) + goto next; + /* Port type hints from AT^GETPORTMODE */ + usbif = mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (probe), "ID_USB_INTERFACE_NUM"); if (GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_GETPORTMODE_SUPPORTED))) { if (usbif + 1 == GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_HUAWEI_PCUI_PORT))) { at_port_flags = MM_PORT_SERIAL_AT_FLAG_PRIMARY; primary_flagged = TRUE; - } else if (usbif + 1 == GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_HUAWEI_MODEM_PORT))) + } else if (usbif + 1 == GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_HUAWEI_MODEM_PORT))) { at_port_flags = MM_PORT_SERIAL_AT_FLAG_PPP; - else if (!g_object_get_data (G_OBJECT (device), TAG_HUAWEI_MODEM_PORT) && - usbif + 1 == GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_HUAWEI_NDIS_PORT))) + } else if (!g_object_get_data (G_OBJECT (device), TAG_HUAWEI_MODEM_PORT) && + usbif + 1 == GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (device), TAG_HUAWEI_NDIS_PORT))) { /* If NDIS reported only instead of MDM, use it */ at_port_flags = MM_PORT_SERIAL_AT_FLAG_PPP; - } else if (usbif == 0 && - mm_port_probe_is_at (MM_PORT_PROBE (l->data))) { - /* If GETPORTMODE is not supported, we assume usbif 0 is the modem port */ - at_port_flags = MM_PORT_SERIAL_AT_FLAG_PPP; + } + goto next; + } + + /* Port type hints from interface description */ + description = mm_kernel_device_get_interface_description (mm_port_probe_peek_port (probe)); + if (description) { + gchar *lower_description; - /* /\* TODO. */ - /* * For CDMA modems we assume usbif0 is both primary and PPP, since */ - /* * they don't have problems with talking on secondary ports. */ - /* *\/ */ - /* if (caps & CAP_CDMA) */ - /* pflags |= MM_PORT_SERIAL_AT_FLAG_PRIMARY; */ + mm_dbg ("(Huawei) %s interface description: %s", mm_port_probe_get_port_name (probe), description); + + lower_description = g_ascii_strdown (description, -1); + if (strstr (lower_description, "modem")) + at_port_flags = MM_PORT_SERIAL_AT_FLAG_PPP; + else if (strstr (lower_description, "pcui")) { + at_port_flags = MM_PORT_SERIAL_AT_FLAG_PRIMARY; + primary_flagged = TRUE; + } + g_free (lower_description); + goto next; + } + + /* If GETPORTMODE unsupported and no other port type hints, we assume + * usbif 0 is the modem port */ + if (usbif == 0) { + at_port_flags = MM_PORT_SERIAL_AT_FLAG_PPP; + goto next; } + next: g_object_set_data (G_OBJECT (l->data), TAG_AT_PORT_FLAGS, GUINT_TO_POINTER (at_port_flags)); } |