Commit Graph

7297 Commits

Author SHA1 Message Date
Eric Caruso
446d497040 introspection: fix Bearer documentation
If e.g. a bearer with IPv6 configuration has DNS servers but exports
its link-local address, MM will avoid giving it the "static" method
type, and instead fall back to the "dhcp" type. However, it may
still have DNS information. Therefore, the comment that "method" is
the only property on configuration with type DHCP is misleading.
2020-11-30 09:25:10 -08:00
Dylan Van Assche
756894bc76 build: Allow elogind for suspend/resume support 2020-11-27 18:07:02 +01:00
Pavan Holla
1f0c04644d base-sim: Reprobe modem if puk lock is discovered after sending pin1
Enabling/Disabling/Changing/Sending the PIN1 lock is usually limited to
3 retries. If these attempts are exhausted, the modem is puk_locked.
We reprobe the modem to get rid of any unwanted interfaces and move
to a locked state.
2020-11-26 08:53:14 +00:00
Pavan Holla
38f6704fa1 base-sim: Reprobe modem if lock status cannot be read after sending puk
If the lock status cannot be read during a puk unblock attempt, reprobe
the modem. It is likely that the SIM was permanently blocked if the lock
status cannot be read.
2020-11-26 08:53:14 +00:00
Thomas Dendale
92c86e2b1b huawei: add GPS port type hints for Huawei ME906e 2020-11-25 21:14:19 +01:00
Aleksander Morgado
935e73c8df build: fix build with single plugins
We need to quote arguments with [] so that lists are not expanded as
different arguments.

Fixes 65560dd885
2020-11-22 14:34:07 +01:00
Aleksander Morgado
6e0380c165 base-modem: order ports by name by default
When there are multiple ports with the same purpose (e.g. multiple net
data ports, or multiple QMI control ports), sort them by name by
default.

The port order does not make any difference for ports that have
flagged with a specific purpose (e.g. AT primary).

The sorting is done both in the internal lists and when looking up
ports with find_ports().
2020-11-20 09:24:51 +00:00
Aleksander Morgado
65560dd885 build: qcom-soc plugin by default disabled
It will not be automatically enabled by the implicit
--enable-all-plugins; instead, it must be explicitly enabled with
--enable-plugin-qcom-soc.

This plugin only makes sense under very specific SoC builds, so there
is no point in always building it by default. It should be explicitly
requested only in those SoC builds that are really going to make use
of it (e.g. postmarketOS).
2020-11-20 09:24:51 +00:00
Stephan Gerhold
9065e3b227 qcom-soc: simplify port type hint rules 2020-11-20 09:24:51 +00:00
Aleksander Morgado
8fc60754dd qcom-soc: new plugin for Qualcomm SoCs
This plugin implements support for old Qualcomm SoCs like the MSM8916
or the MSM8974, where:
 * control ports are available via RPMSG channels exported as devices
   e.g. with rpmsgexport:
   https://github.com/andersson/rpmsgexport
 * network ports are exposed by the bam-dmux kernel driver:
   https://github.com/msm8916-mainline/linux/commits/bam-dmux

Adding support for newer Qualcomm SoCs (e.g. QRTR+IPA) could be done
in a similar way on this very same plugin.

This plugin is the first and only one that implements support for a
modem device that is "built in" the system, as opposed to external
modems that may be available via USB or PCI.

The ID_MM_PHYSDEV_UID based udev tags provided by the plugin provide
the logic to bind all the SoC ports together in the same modem object,
and therefore ID_MM_PHYSDEV_UID should not be used by users to
override the ones set by the plugin.

All "rpmsg[0-9]*" ports that are considered part of the modem are
flagged as candidate, ignoring the parent "rpmsg_ctrl[0-9]*" ports on
purpose. This setup therefore assumes that the channels have been
exported already as devices (e.g. using rpmsgexport).

libqmi 1.27.2 is required to support the "WDS Bind Data Port" message.
2020-11-20 09:24:51 +00:00
Aleksander Morgado
cab4b54ad1 core: new 'rpmsg' subsystem
Most older Qualcomm SoCs (e.g. MSM8916, MSM8974, ...) communicate with
the integrated modem via shared memory (SMD channels). This is similar
to QRTR on newer SoCs, but without the "network" layer. In fact, the
older SoCs also have QRTR, but the modem QMI services are not exposed
there.

The mainline Linux kernel exposes SMD channels via the "remote processor
messaging bus" (rpmsg). Through special IOCTL calls it is possible to
create a char device for a rpmsg/SMD channel. We can then use these to
send QMI/AT messages to the modem, much like the ordinary serial char
devices when using a Qualcomm modem through USB.

This commit introduces support for the new 'rpmsg' subsystem, which
allows exporting QMI-capable and AT-capable ports.

By default NO rpmsg port is flagged as candidate, it is assumed that
the plugin adding support for the rpmsg subsystem will add specific
rules to do so (e.g. so that non-modem ports are explicitly not
flagged as candidate).

All rpmsg ports will be probed for AT or QMI capabilities, unless
explicit port type hints (e.g. ID_MM_PORT_TYPE_QMI or
ID_MM_PORT_TYPE_AT_PRIMARY) are set.

These changes are highly based on the initial integration work done by
Stephan Gerhold <stephan@gerhold.net> in postmarketOS, see:
  https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/363
2020-11-20 09:24:51 +00:00
Aleksander Morgado
3d12272d18 kerneldevice: allow loading port attributes
In addition to loading port and device properties, we now also allow
loading sysfs properties that are assumed to be static (i.e. their
values won't change since loaded the first time).
2020-11-20 09:24:51 +00:00
Aleksander Morgado
399a042dad bearer-qmi: support binding to data port
Allow plugins to specify a QmiSioPort value to bind to. This is used
e.g. in the RPMSG+BAM-DMUX setup in order to allow any RPMSG port to
control all the available net ports.
2020-11-20 09:24:51 +00:00
Aleksander Morgado
3be07bb38d tests,cdma: test CDMA SMS with different text lengths 2020-11-20 00:40:39 +01:00
David Leonard
7ac42e7648 sms: fix 7-bit ASCII SMS decoding
Fixes an issue where (5+8n)-character long SMS messages received on a
CDMA network would be dropped with a "cannot read user data" error,
while other length SMS messages would be delivered fine.

Fix thanks to Peter Hunt
2020-11-20 00:40:39 +01:00
Aleksander Morgado
c3bc515b8a base-manager: never create kernel device objects for remove events
There is no point in creating a new kernel device object just to
process a remove event; instead, do any matching with existing
kernel device objects by subsystem and name, which is what the generic
backend already did anyway.

This avoids unnecessary lookup of information in sysfs during removal
events, because the port is anyway already gone when we try to look
those up.
2020-11-19 17:01:55 +00:00
Aleksander Morgado
047805348d iface-modem-firmware: allow plugins to ignore carrier info
Skip building the firmware version information with carrier config
information if the plugin already knows that the firmware upgrade
method doesn't implement carrier-specific upgrade paths.
2020-11-16 11:28:46 +01:00
Aleksander Morgado
c7016f8933 iface-modem-firmware: report generic IDs for both USB and PCI devices
Instead of assuming that all modules supporting firmware upgrade are
USB based.
2020-11-16 11:28:46 +01:00
Andrew Lassalle
9533ee2f22 mm-plugin-manager: Fix typos
Change-Id: I662061384cf48abd0975e15a91b090aa6b33ac34
2020-11-15 06:49:42 -08:00
Aleksander Morgado
e112896994 base-manager: allow forcing the testing without udev
Even if udev support is really built and available.

This is extremely useful to test the udev-less setup without fully
recompiling the whole daemon.

  E.g.: the daemon can be run like this:
    $ sudo /usr/sbin/ModemManager --debug --test-no-udev

  And then, the kernel events may be reported using mmcli like this:
    $ sudo mmcli --report-kernel-event-auto-scan
2020-11-14 22:55:52 +01:00
Aleksander Morgado
6e642418bb kerneldevice,generic: use regex to implement string matching
Instead of the custom simple implementation which only supported the
'*' modifier in the pattern. This allows us to support e.g. attribute
value matches like e.g. 'DATA[0-9]*_CNTL'.
2020-11-14 13:39:40 +00:00
Aleksander Morgado
cca83392f0 kerneldevice,generic: implement ATTRS matching for any attribute
Until now we did not support ATTRS{} matches against attributes we
don't support in the core codebase. Implement now a simple lookup
mechanism which traverses the tree of sysfs path from the port sysfs
path to the physical device sysfs path, looking up the attribute
requested.

This is not completely equivalent to what udev does, because the udev
rules matching ATTRS would usually also include an additional previous
matching e.g. SUBSYSTEMS and such, so that the ATTRS is looked up
exactly in the device that also matches the additional previous
rules. In our case, we just simplify the logic and return the first
one found.
2020-11-14 13:39:40 +00:00
Aleksander Morgado
769ba3cee6 kerneldevice,generic: fix DRIVERS and SUBSYSTEMS checks
We were applying the DRIVERS check looking only at the single port
driver. Instead, we now lookup and cache all drivers found in the
device tree, and apply the loose DRIVERS check properly looking at all
of them.

We were applying the SUBSYSTEMS and SUBSYSTEM check looking at the
sysfs path and just hoping the subsystem we're looking for is included
in the path itself. Instead, we now lookup and cache all susystems
found in the device tree, and apply the loose SUBSYSTEMS check
properly looking at all of them.

E.g. we can now match SUBSYSTEMS="mhi_q" in the following device tree,
without needing it to be found in the sysfs path:

  looking at device '/devices/pci0000:00/0000:00:1b.0/0000:01:00.0/1001_00.01.00_MBIM/mhi_uci_q/mhi_MBIM':
    SUBSYSTEM=="mhi_uci_q"
  looking at parent device '/devices/pci0000:00/0000:00:1b.0/0000:01:00.0/1001_00.01.00_MBIM':
    SUBSYSTEMS=="mhi_q"
  looking at parent device '/devices/pci0000:00/0000:00:1b.0/0000:01:00.0':
    SUBSYSTEMS=="pci"
2020-11-14 13:39:40 +00:00
Aleksander Morgado
ba361f41c4 kerneldevice,generic: support PCI device common attribute names
The vendor and product IDs stored for the MMKernelDevice object in the
PCI subsystem are mapped to the "vendor" and "device" attributes.
2020-11-14 13:39:40 +00:00
Aleksander Morgado
d3a7f70135 kerneldevice,generic: preload port info based on the system bus
The generic backend implementation was really based on detecting USB
devices, not so much devices in other subsystems. This patch puts the
generic backend at the same level as the udev backend to support
non-USB modems.
2020-11-14 13:39:40 +00:00
Aleksander Morgado
bc895067ec kerneldevice,udev: preload port info based on the system bus
USB, PCI, PCMCIA... all these different system buses expose modems in
different ways. Instead of having single methods to attempt to load
different things for all these device types, detect first which is the
system bus in use, and then perform a bus-specific operation to
preload the different things.
2020-11-14 13:39:40 +00:00
Aleksander Morgado
4550dcfbdf kerneldevice: no need to subclass the type getters
We can just subclass the methods to check whether a given property
exists and to get it as a string, and then implement in the generic
class the actual boolean/int/hex type getters common for all.
2020-11-14 13:39:40 +00:00
Aleksander Morgado
1e1fe8fb9c kerneldevice: remove all unneeded g_return_if_fail() checks
These kind of checks are only useful on public APIs really, there
should be no need to have them in internal code.
2020-11-14 13:39:40 +00:00
Aleksander Morgado
5d150ed23e core,plugins: consolidate connection/disconnection timeout values
Each different plugin or protocol had a different connection attempt
value. E.g. QMI and MBIM both used 60s max for the connection attempt,
while the u-blox plugin had up to 180s for ECM based connection
setups.

This commit consolidates all plugins and protocols to use the same
timeout values for commands that may take long to respond, e.g. a
connection atempt under low signal quality conditions.

A value of 180s for the connection attempt steps and 120s for a
disconnection attempt step is considered. Note, though, that in some
cases (like a IPv4v6 setup attempt using QMI) we may have more than
one such long step, so this doesn't mean that a connection attempt
will always take less than 180s.

Users of the connection/disconnection APIs should be able to handle
the case where the attempt times out in their side (e.g. with a lower
DBus request timeout), and which would not mean the actual request
they did really failed. E.g. a connection attempt with a DBus timeout
of 30s may fail in the user with a timeout error, but the attempt
would still go on for as much as the plugin/protocol needs.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/270
2020-11-14 09:41:43 +00:00
Aleksander Morgado
da77dc7152 plugin: build probing needs based on subsystem
Don't rely on the QMI or MBIM ports named cdc-wdm, use the device
subsystem instead.
2020-11-13 08:57:06 +00:00
Aleksander Morgado
71f5c97543 base-manager: automatic required subsystem detection
Instead of assuming we require a fixed set of subsystems to monitor,
compile the full list based on what the plugins have requested
themselves.
2020-11-13 08:57:06 +00:00
Aleksander Morgado
950abbf8ee core: stop monitoring the 'usb' subsystem
Back in Linux < 3.6 days, the cdc-wdm ports exposed by the QMI driver
were flagged as owned by the 'usb' subsystem. That changed in 3.6 when
the subsystem was renamed to 'usbmisc':

  https://mail.gnome.org/archives/networkmanager-list/2012-June/msg00125.html

This patch removes all monitoring of the 'usb' subsystem completely,
which is anyway a valid subsystem but for which we shouldn't need any
special handling. Right now, with newer kernels, we were using that
monitoring exclusively to get notified of full USB device remove
events, which is really not required as we already process the port
removals one by one.

We simplify the logic everywhere that attempted to match either the
'usb' or 'usbmisc' subsystems, and we no longer require the explicit
checks for the port name being named 'cdc-wdm[0-9]*' in the code, as
that is already taken care of by the ID_MM_CANDIDATE udev tag rule.
2020-11-13 08:57:06 +00:00
Frederic Martinsons
519df2544b tools: add new system daemon stub tester application
This script mock some of ModemManager DBus interfaces (main object, Modem, Sim),
it also adds a test interface "org.freedesktop.ModemManager1.LibmmGlibTest"
which allow to inject some errors and simulate behavior:
  - Add a modem object
  - Emit modem state changed
  - Set modem error

This script also add the possibility to log in a file for debugging purpose.
Because the stdout/stderr are not shown when the program is spawned by DBus
auto activation.

Note: Script is heavily inspired from test-networkmanager-service.py from
NetworkManager project

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-11-12 18:34:59 +01:00
Aleksander Morgado
06f75500db base-manager: log kernel event handling failures
Don't just return the error to the client, we want this info in the
daemon log as well.
2020-11-09 22:26:32 +01:00
Aleksander Morgado
37b3771ef5 kerneldevice,generic: plug cached string leaks
Both 'physdev_subsystem' and 'interface_description' were leaking.
2020-11-09 22:19:39 +01:00
Aleksander Morgado
5b91e489eb port-qmi: expected kernel data format is qmi_wwan specific
The qmi_wwan driver is the only one that allows switching between
802.3 and raw-ip during runtime, and therefore we must not assume that
every QMI port managed allows to do so, we'll limit that feature only
to QMI ports in the 'usbmisc' subsystem.

For every other port, we assume the kernel expects raw-ip by default,
and so we include logic to switch the modem to raw-ip both using WDA
and CTL (WDA preferred over CTL). This assumption may not be perfect,
but it's probably a good guess, as raw-ip is the preferred and
sometimes the only format supported by new devices.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
799c4c72ce port-qmi: allow specifying input subsystem
We have assumed until now that all QMI ports are based on the
qmi_wwan driver, exposed in the 'usbmisc' subsystem by the cdc-wdm
driver.

This may no longer be true, so allow creating QMI ports with
an explicit subsystem instead of defaulting always to USBMISC.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
7faa3a5e25 port-mbim: allow specifying input subsystem
We have assumed until now that all MBIM ports are based on the
cdc_mbim driver, exposed in the 'usbmisc' subsystem by the cdc-wdm
driver.

This may no longer be true, so allow creating MBIM ports with
an explicit subsystem instead of defaulting always to USBMISC.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
4ec2db75b8 port-serial-qcdm: allow specifying input subsystem
We have assumed until now that all QCDM ports are based on TTY
drivers, e.g. exposed via USB.

This may no longer be true, so allow creating QCDM ports with
an explicit subsystem instead of defaulting always to TTY.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
56fca14473 base-modem: refactor port grabbing logic
Split in its own method the per-subsystem port creation mechanism, and
apply all common AT port settings (e.g. response parser, flags) in a
single place.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
2a6b596bcf port-serial-at: skip validating input subsystem argument
This check is pointless given that we're not implementing API, if
anything it should be an assert. Anyway, just get rid of it, so that
we don't need to update it on every new subsystem we add as supported.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
f052e914c8 port: rename subsystem from 'usb' to 'usbmisc'
Back in Linux < 3.6 days, the cdc-wdm ports exposed by the QMI driver
were flagged as owned by the 'usb' subsystem. That changed in 3.6 when
the subsystem was renamed to 'usbmisc':

  https://mail.gnome.org/archives/networkmanager-list/2012-June/msg00125.html

So, rename the port subsystem type enumn to 'usbmisc'.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
c92dc21a18 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.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
e01c8b379c broadband-modem-qmi: peek QMI port from any subsystem
No longer has to be bound to the USB subsystem.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
b8cbc87249 broadband-modem-qmi: allow subclassing the match of control vs net ports
By default we provide the implementation for the qmi_wwan driver,
where both control and net ports share the same USB interface.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
b8f6fb59ed broadband-modem-qmi: peeking QMI port only in QMI modems
Move the logic out of the base modem, and make it applicable only for
QMI modems.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
0dbb8d03f5 broadband-modem-mbim: peek MBIM port from any subsystem
No longer has to be bound to the USB subsystem.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
85d549ef00 broadband-modem-mbim: allow subclassing the match of control vs net ports
By default we provide the implementation for the cdc_mbim driver,
where both control and net ports share the same USB interface.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
6defec2fae broadband-modem-mbim: peeking MBIM port only in MBIM modems
Move the logic out of the base modem, and make it applicable only for
MBIM modems.
2020-11-09 18:41:57 +01:00
Aleksander Morgado
ca0dbd0728 plugin: network interface force ignore rules for certain drivers only
The rules to force ignoring certain network ports because the modem is
using some specific drivers should definitely only be applied for the
very known qmi_wwan and cdc_mbim drivers.

If network ports for QMI or MBIM modems are exposed using different
network drivers, don't ignore them.
2020-11-09 18:41:57 +01:00