Commit Graph

82 Commits

Author SHA1 Message Date
Aleksander Morgado
da046fe566 plugin: new properties to support Intel XMM capability probing 2018-08-21 17:02:39 +00:00
Ville Skyttä
90b89bb9f4 *: Spelling fixes 2018-01-25 09:52:12 +01:00
Ben Chan
36e7cd50ce plugin: fix forbidden_product_strings check in apply_post_probing_filters
This patch fixes a bug in apply_post_probing_filters() where it iterates
through `self->priv->forbidden_product_strings' but incorrectly accesses
`self->priv->product_strings[i]' inside the loop.
`self->priv->forbidden_product_strings[i]' should be accessed instead.
2017-08-11 17:09:18 -05:00
Ben Chan
627ef274df plugin: check error returned by g_task_propagate_error instead
mm_plugin_supports_port_finish directly casts the value returned by
g_task_propagate_int to MMPluginSupportsResult enum value, which
implicitly assumes MM_PLUGIN_SUPPORTS_PORT_UNKNOWN equals to -1.
Instead of relying on such an implicit assumption, this patch modifies
the code to check if the GError argument to g_task_propagate_error is
populated instead.
2017-07-07 10:23:46 +02:00
Aleksander Morgado
00fb9e98f6 kernel-device: device-specific properties in either port or physdev
There are 2 main types of udev properties: device-specific and
port-specific.

The port-specific properties are set independently per port (e.g. port
type hints set per interface number for a given vid:pid).

The device-specific properties apply to all ports in the device. Some
of these properties are currently expected in the physical device
(e.g. ID_MM_PLATFORM_DRIVER_PROBE) while some others are expected in
each port (e.g. the plugin udev tag filters).

This patch tries to simplify the logic and just assume that the device
specific tags may be given in either the physical device or the port
device, by providing separate APIs to retrieve port-specific or
device-specific (global) properties. If the same tag is given in both
the device and the port, the one in the device takes preference.

For the generic backend, these new APIs are really useless, as all
device-specific and port-specific properties are always stored in the
port object themselves (there is no 'tree' of devices in the generic
backend, no 'physdev' device).

For the udev backend, though, there really is a difference, as the
tags may be set in port or device.

https://bugs.freedesktop.org/show_bug.cgi?id=100156
2017-03-22 09:40:10 +01:00
Aleksander Morgado
30c2790aa4 kerneldevice,generic: load virtual devices without default rules
This is so that "make check" doesn't depend on having the rule files
installed in the default udev rules directory, which currently would
break the build:

    TEST: test-service-generic... (pid=2601)
      /MM/Service/Generic/enable-disable:                                  Activating service name='org.freedesktop.ModemManager1'
    Successfully activated service 'org.freedesktop.ModemManager1'

    ** (/home/aleksander/Development/foss/ModemManager/plugins/.libs/lt-test-service-generic:2601):
    ERROR **: Error setting test profile: GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Failed: Failed to find primary AT port
    FAIL
    GTester: last random seed: R02S3897abaae9df36f8d2eeb679406ab675
    make[3]: *** [Makefile:3804: test-nonrecursive] Terminated
2016-11-21 13:44:08 +01:00
Aleksander Morgado
ae9ede926a core: use the kernel device object in the port object and the plugin interface
The mm_base_modem_grab_port() now receives a MMKernelDevice directly from the
plugin, which is then stored in the MMPort corresponding to the port.

This means that we have direct access to e.g. all properties set by udev rules
everywhere, and we don't need additional GUdevClient objects (e.g. like the one
used in the Huawei plugin to detect NDISDUP support during runtime).

For virtual ports (e.g. generated during unit tests), we have a new 'generic'
kernel device object which just provides the values from the kernel device
properties given during its creation.
2016-09-29 15:43:05 +02:00
Aleksander Morgado
aa4577dfb9 core: new kernel device object instead of an explicit GUdevDevice
Instead of relying constantly on GUdevDevice objects reported by GUdev, we now
use a new generic object (MMKernelDevice) for which we provide an initial GUdev
based backend.
2016-09-29 15:43:05 +02:00
Aleksander Morgado
1f813c4e96 core: allow identifying devices by a user-provided 'uid'
All ports of the same modem reported by the kernel will all be associated with
a common 'uid' (unique id), which uniquely identifies the physical device. This
logic was already in place, what we do now is avoid calling it  the 'sysfs
path' of the physical device, because we may not want to use that to identify
a device.

This logic now also enables the possibility of "naming" the modems in a unique
way by setting the "ID_MM_PHYSDEV_UID" property in the "usb_device" that owns
all the ports.

E.g. a custom device has 4 modems in 4 different USB ports. The device path of
each USB device will always be the same, so the naming rules could go like this:

    $ vim /usr/lib/udev/rules.d/78-mm-naming.rules

    ACTION!="add|change|move", GOTO="mm_naming_rules_end"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.1", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-1"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.2", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-2"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.3", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-3"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.4", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-4"
    LABEL="mm_naming_rules_end"

Each of the modems found will have a unique UID retrieved from the previous list
of rules. Then, "mmcli" has also been updated to allow using the UID instead of
the modem DBus path or index, e.g.:

    $ sudo mmcli -m USB-MODEM-1
    /org/freedesktop/ModemManager1/Modem/0 (device id '988d83252c0598f670c2d69d5f41e077204a92fd')
      -------------------------
      Hardware |   manufacturer: 'ZTE CORPORATION'
               |          model: 'MF637'
               |       revision: 'BD_W7P673A3F3V1.0.0B04'
               |      supported: 'gsm-umts'
               |        current: 'gsm-umts'
               |   equipment id: '356516027657837'
      -------------------------
      System   |         device: 'USB-MODEM-1'
               |        drivers: 'option'
               |         plugin: 'ZTE'
               |   primary port: 'ttyUSB5'
               |          ports: 'ttyUSB5 (at)'
    ...

    $ sudo mmcli -m USB-MODEM-1 --enable
    ...
2016-09-29 15:41:21 +02:00
Aleksander Morgado
c605b0bc46 port-probe: allow cancellation 2016-03-09 23:59:46 +01:00
Aleksander Morgado
d3bf07e7a8 plugin: allow cancellation of the port probe operation 2016-03-09 23:59:46 +01:00
Aleksander Morgado
37bda21a37 plugin: add implicit QMI and MBIM forbidden drivers check 2015-02-18 20:00:01 +01:00
Aleksander Morgado
07fcb807dd plugin: allow having both 'drivers' and 'forbidden drivers' filters 2015-02-16 17:30:38 +01:00
Aleksander Morgado
51ab292802 plugin: let vendor/product filter be complementary
So that a plugin can specify a full VID and a specific PID subset of another VID
as supported.
2015-02-16 17:30:38 +01:00
Aleksander Morgado
dc38332224 plugin: avoid segfault when port driver is unknown
Based on a patch from Bastiaan Jacques <bastiaan@bjacques.org>

https://bugzilla.redhat.com/show_bug.cgi?id=1177799
https://bugs.freedesktop.org/show_bug.cgi?id=88864
2015-01-29 12:23:31 +01:00
Aleksander Morgado
31f81725e6 plugin: allow to explicitly ignore any kind of port via udev
The new 'ID_MM_PORT_IGNORE' tag will tell ModemManager to fully avoid using a
given port.

Note that it is key to not only flag the port probe as ignored, but also to
fully ignore the ports in e.g. mm_port_probe_list_has_qmi_port() as those
methods will be used to decide which kind of modem object to create. We don't
want to create a QMI-based modem which may have all QMI ports blacklisted.
2014-09-05 09:54:55 +02:00
Aleksander Morgado
8450e563bb plugin: if no QMI or no MBIM still grab the WWAN ports, flagged as ignored
E.g. this would be the result when having ModemManager compiled without QMI
support, and a modem with 2 QMI/WWAN pairs:

    $ mmcli -m 2

    /org/freedesktop/ModemManager1/Modem/2 (device id '417e4dcff7f232b62cfe6c972e2099701848fd7f')
      -------------------------
      Hardware |   manufacturer: 'Sierra Wireless, Incorporated'
               |          model: 'MC7304'
               |       revision: 'SWI9X15C_05.05.02.00 r19147 carmd-fwbuild1 2013/11/15 13:54:28'
               |      supported: 'gsm-umts'
               |        current: 'gsm-umts'
               |   equipment id: 'unknown'
      -------------------------
      System   |         device: '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.7'
               |        drivers: 'qcserial, qmi_wwan'
               |         plugin: 'Gobi'
               |   primary port: 'ttyUSB8'
               |          ports: 'ttyUSB8 (at), wwp0s29u1u7i8 (unknown), ttyUSB6 (qcdm), wwp0s29u1u7i10 (unknown)'

The /dev/cdc-wdm ports don't even appear (as they were not even probed), but the
newly ignored WWAN ports do appear in the list, but flagged as UNKNOWN type
(instead of NET).
2014-09-05 09:16:11 +02:00
Aleksander Morgado
f203b1bf00 plugin: improve probing decision logic for QMI and MBIM
So, we may have modems with multiple /dev/cdc-wdm ports, like Ericsson modems,
where only 1 of them is MBIM. With the previous logic, we would probe all
/dev/cdc-wdm ports for MBIM as soon as one of the ports was handled by the
cdc_mbim driver. That is totally not optimal, as we are already know that they
are not MBIM (not handled by cdc_mbim).

Instead, fix the logic to just probe for MBIM or QMI if the actual driver
managing the port is MBIM or QMI.
2014-07-27 13:55:10 +02:00
Aleksander Morgado
7c347aa3ec port: store parent sysfs path in each MMPort 2014-06-23 18:12:27 +02:00
Aleksander Morgado
2d9d15f892 plugin: allow creating 'virtual' modems with 'virtual' ports 2014-02-13 13:41:41 +01:00
Aleksander Morgado
070f4938f3 plugin: allow probing non-tty AT ports 2014-02-13 13:40:58 +01:00
Aleksander Morgado
6f235b9948 ports: rename 'MMAtSerialPort' to 'MMPortSerialAt' 2014-02-13 13:40:01 +01:00
Aleksander Morgado
0d1602bf0f ports: rename 'MMQcdmSerialPort' to 'MMPortSerialQcdm' 2014-02-13 13:39:57 +01:00
Aleksander Morgado
5e7fee1d11 build: use 'g_cclosure_marshal_generic' by default
Avoid custom marshalers, and just use libffi-based 'g_cclosure_marshal_generic'.
2013-11-20 15:17:09 +01:00
Aleksander Morgado
b09044bcb3 plugin: for non-AT ports, don't expect vendor/product string probing
When running the pre-probing VID/PID filters, the ports were not filtered out if
the plugin had configured post-probing vendor/product string filters. But, these
post-probing filters are only applicable to AT ports.

From now on, this logic will not be applied to non-serial ports. In other words,
pre-probing VID/PID filters applied to non-serial ports will always result in
the port being filtered out or being allowed, regardless of any additional
vendor/product string post-probing filter configured by the plugin.

https://bugzilla.gnome.org/show_bug.cgi?id=710437
2013-10-28 18:13:14 +01:00
Aleksander Morgado
6b379e525d plugin: limit cdc-wdm port probing types depending on the available drivers
We'll use the given device drivers as a hint of what we can or should probe.
2013-04-17 15:19:38 +02:00
Aleksander Morgado
cb45de048f plugin: allow plugins to require MBIM probing of cdc-wdm ports 2013-04-17 15:19:37 +02:00
ori inbar
633708b364 serial: add support to optionally send line-feed at the end of AT commands. 2013-03-28 20:15:58 +01:00
Aleksander Morgado
d6ac6508d9 plugin: explicitly request QMI probing
Plugins which may support QMI ports need to explicitly request QMI probing
in cdc-wdm devices. This should also avoid probing cdc-wdm ports when we know
that the plugin doesn't support them (e.g. with Ericsson MBM devices).

https://bugzilla.gnome.org/show_bug.cgi?id=696701
2013-03-28 17:33:08 +01:00
Aleksander Morgado
a18140e8ed plugin: avoid using uninitialized variable
Reported by: Jose Maria Gonzalez <jmgonzalezc@indra.es>
2013-02-21 11:15:37 +01:00
Aleksander Morgado
5b072b9198 plugin: plug memleak
A new reference to probe was acquired through mm_device_get_probe(), just unref it
when no longer needed. Note that mm_port_probe_run() will take its own reference
for as long as required to complete the operation.
2013-02-20 17:00:14 +01:00
Aleksander Morgado
688bb2cb3a plugin: plug memleaks
This is really just to have a nice valgrind/memcheck output report, no big deal
if they were never freed.
2013-02-20 16:48:41 +01:00
Aleksander Morgado
2267fb0480 plugin: plug memleaks 2013-02-20 09:59:20 +01:00
Ben Chan
e75dba639f core: add 'hotplugged' flag to indicate if modem is newly plugged in
This patch adds a 'hotplugged' flag to MMBaseModem to indicate if a
modem is newly plugged in. A plugin can use this information to
determine if, for example, the modem needs to be soft reset using the
ATZ command.

Dan Williams <dcbw@redhat.com> contributed the idea of implementation.
2013-01-18 11:27:51 +01:00
Aleksander Morgado
731812fe34 plugin: avoid QMI-managed net ports when compiling without QMI support 2012-12-27 13:51:28 +01:00
Aleksander Morgado
c8fcf7a91d plugin: re-run subsystems filter before grabbing the ports
Every port probing will have the Generic plugin as fallback, and due to some
other issues in other plugins (see ee099fcd), we need to allow overwriting the
suggested plugin from the Generic to a more specific one.

One of the drawbacks of this is that we're actually allowing the Generic plugin
to probe and accept the port, which means that the generic plugin may accept a
specific port type (e.g. QMI) while the specific plugin wouldn't. So, we will
now also run the subsystems filter before grabbing the specific port, in order
to really filter out those cases. We still keep the subsystems filter in
pre-probing, so that we build a better initial plugin list to probe.
2012-12-27 08:53:45 +01:00
Aleksander Morgado
0ca6ae1b4b plugin-manager,plugin: run pre-probing filters early
For each port, we will construct the list of plugins to test with. In that list
we will include those plugins which are likely to handle a given port, so we
will skip all those which aren't.

To see if a plugin is likely or not, we will run the pre-probing filters before
adding them to the list, with the new `mm_plugin_discard_port_early()'. This
method will return one of these hints:

 * UNSUPPORTED: The plugin will not be able to handle this port.
 * MAYBE: The plugin may handle this port.
 * LIKELY: The plugin may (very likely) handle this port.
 * SUPPORTED: If any plugin should support the port, this is it.

Plugins reported to be 'likely' supporting the port will be probed before the
ones reported just as 'maybe'.

If a plugin reports 'supported' only that one and the fallback generic ones will
be tried.
2012-10-30 15:35:58 +01:00
Aleksander Morgado
49c19bf83e plugin: avoid unneeded vendor/product AT probing if already passed USB ID filter
Don't require vendor/product string probing if the plugin already had
vendor/product ID filters and we actually passed those.
2012-10-30 15:35:58 +01:00
Aleksander Morgado
3f255b628a plugin-manager,plugin: improve logging
Logging which are the reasons for a plugin to filter a given port really help
when trying to debug user issues. Some other general logging improvements also
done.
2012-10-30 15:35:58 +01:00
Aleksander Morgado
72db2a53ed plugin: defer task if supports check tells us to retry
Huawei modems will probe interface 0 always first; if we try to probe another
interface meanwhile the supports check will give us a MM_CORE_ERROR_RETRY error,
indicating that we need to defer the probing of the port.
2012-09-04 10:21:44 +02:00
Aleksander Morgado
1e5b00e33b plugin: let plugins decide if they want echo removal during AT probing
This is the port to git master of the following patch:

commit 21e66dfa1774ac2ee037ac8b6e8bb4d71a6f7931
Author: Dan Williams <dcbw@redhat.com>
Date:   Thu Aug 23 21:13:35 2012 -0500

    core: add function to open probe ports without removing echo

    Some devices (Sierra GSM ones) return stuff we need but don't
    bother to prefix it with <CR><LF>, so we need to optionally turn
    off the echo removal at probe time.
2012-08-31 09:20:43 +02:00
Aleksander Morgado
494a70a8ff core: handle the 'usb'->'usbmisc' subsystem rename in the kernel
We'll try to cope with getting devices being reported in either 'usb' or
'usbmisc', trying to avoid the need of checking kernel version during runtime.
2012-08-29 17:26:46 +02:00
Aleksander Morgado
db99f340c8 port-probe: launch QMI probing on cdc-wdm ports
Some devices may export cdc-wdm ports talking AT. We need to explicitly check
for QMI protocol support on the cdc-wdm ports before assuming they are QMI.
2012-08-29 17:14:47 +02:00
Aleksander Morgado
306b4eb509 core: allow grabbing QMI ports 2012-08-29 17:14:47 +02:00
Aleksander Morgado
0436b3e457 api,introspection: report list of drivers, not just one
Different ports of the same modem may get handled by different drivers. We
therefore need to provide a list of drivers (new `Modem.Drivers' property with
signature 'as') instead of just one (removed `Modem.Driver' property with
signature 's').

$ sudo mmcli -m 0 | grep drivers
           |        drivers: 'qcserial, qmi_wwan'
2012-08-24 13:34:51 +02:00
Aleksander Morgado
84d205c9be plugin: new filters for forbidden product IDs/strings
Plugins may specify that specific vendor & product IDs or strings are not
supported. This is useful when plugins need to specify that they support
all devices of a given vendor except for some specific ones.
2012-08-20 16:26:55 +02:00
Aleksander Morgado
4e84cd241b plugin: fix icera filters when using the allowed product string filter 2012-08-20 16:26:55 +02:00
Aleksander Morgado
9512eda21d plugin: don't apply product ID filters if no vendor ID was retrieved 2012-08-20 16:26:55 +02:00
Aleksander Morgado
509ad94204 plugin: check if the current probe is the one with AT support before assuming it's not 2012-08-06 20:07:27 +02:00
Aleksander Morgado
edc9825788 plugin: let plugins request Icera support checks and Icera based filters 2012-08-06 20:07:27 +02:00