Commit Graph
158 Commits
Author SHA1 Message Date
Lukas Voegl 436081648b api,modem: new 'IgnoredPorts' property
Expose a new list of 'IgnoredPorts' via D-Bus and therefore remove the use of `MM_MODEM_PORT_TYPE_IGNORED`

Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2025-04-25 09:37:16 +02:00
Dan Williams 7d75a897a8 port-probe: allow per-port ID_MM_TTY_AT_PROBE_TRIES tag for custom number of AT probes
For modems that need more time to respond to AT port probes (like some Telit devices,
and Cinterion-based Telit MV31/MV32) allow a custom number of AT probe tries on a
per-port basis for generic probing, or plugins that opt into this functionality.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-03-27 18:40:38 -05:00
Dan Williams 89466b583b port-probe: ensure port is open for all plugin AT probes
If multiple plugins are selected for probing a modem with AT probes,
earlier plugins may only request some probes but not all.  When
those probes complete successfully, subsequent plugins won't re-do
the probes that were already completed, but jump to ones that
haven't yet been done.

For example, plugin A may request only AT probes but plugin B
may request AT, AT_PRODUCT, and AT_VENDOR. Plugin B will start
with AT_PRODUCT probes because plugin A already completed the AT
probe.

The code in probe_step() only opened the serial port for the
AT probe, I guess assuming that all AT-type probes would be
done in sequence. But in the above scenario they are not.

Instead, make sure the port is opened for all AT style probes
that have not yet been executed.

Fixes: 7937a89a37 port-probe: rework and consolidate port probe flow for AT/QCDM/QMI/MBIM

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-03-09 14:44:23 +00:00
Dan Williams 60de5751b4 port-probe: add some QCDM/DIAG response bytes to non-AT responses
Seen on a Qualcomm-based Quectel EG915Q on the diag port:

ModemManager[34547]: <dbg> [1732077670.330527] [ttyUSB0/at] <-- ' \0\0\0\8\0\0\0\2\0\0\0\0`%\160$"\6\169\128\200\1\30\197\142\0G\184\225\128\0\1+\127\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254\255\255\255\255\255\255\255\254'

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2024-12-27 23:42:09 -06:00
Aleksander Morgado 377a124865 port-probe: explicit close port steps
If by any chance the same ports needs to go through AT and
QMI/MBIM probing, make sure the serial port created during
AT probing is closed before starting the QMI/MBIM probing.
2024-12-27 15:24:01 +00:00
Aleksander Morgado e2633b46f0 port-probe: only run custom init on ports that will go through AT probing 2024-12-27 15:24:01 +00:00
Aleksander Morgado 0744ebd1c0 port-probe: rename serial_probe->probe 2024-12-27 15:24:01 +00:00
Dan Williams ed13e053cd port-probe: fix custom init probing not having open AT port
Referenced commit broke custom init flows because the AT port
was not opened when custom inits were run, which was the case
before the commit landed.

Rework probing flow to follow a step model like much of our
other code, and ensure that the AT port is opened as part
of the custom init flow.

Fixes: 7937a89a37 port-probe: rework and consolidate port probe flow for AT/QCDM/QMI/MBIM

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2024-11-20 11:50:43 +00:00
Dan Williams f19f20c008 helpers: consolidate some uses of mm_kernel_device_get_subsystem()
Signed-off-by: Dan Williams <dan@ioncontrol.co>
2024-09-17 12:20:46 -05:00
Dan Williams 0b5f2adb4b port-probe: restart AT probing if "NO CARRIER" is received during QCDM probing
If the system and modem are independently powered, a system restart may
leave one of the modem's AT ports in PPP mode. On restart this may cause
AT probing to fail. The modem may terminate PPP after receiving bogus
HDLC frames from QCDM probing (since PPP also uses HDLC framing), and
return "NO CARRIER". We can use this to restart AT probing now that
PPP is down and auto-detect the expected additional AT ports.

Feb 08 20:22:53 ModemManager[385]: <debug> [1675887773.887574] [ttyUSB2/at] <-- '\8\158\239~'
Feb 08 20:22:54 ModemManager[385]: <debug> [1675887774.215054] [ttyUSB2/at] <-- '\8\214\137~'
Feb 08 20:22:54 ModemManager[385]: <debug> [1675887774.851349] [ttyUSB2/at] <-- '\8\250\177~'
Feb 08 20:22:55 ModemManager[385]: <debug> [1675887775.576776] [ttyUSB2/at] <-- '\8\168u~'
Feb 08 20:22:55 ModemManager[385]: <debug> [1675887775.612694] [ttyUSB2/at] <-- '\8w\25~'
Feb 08 20:22:55 ModemManager[385]: <debug> [1675887775.862886] [ttyUSB2/at] <-- '\8!&~'
Feb 08 20:22:56 ModemManager[385]: <debug> [1675887776.614747] [ttyUSB2/at] <-- '\8%\254~'
Feb 08 20:22:56 ModemManager[385]: <debug> [1675887776.686207] [ttyUSB2/probe] port is not AT-capable
Feb 08 20:22:56 ModemManager[385]: <debug> [1675887776.686447] [ttyUSB2/probe] probing QCDM...
Feb 08 20:22:56 ModemManager[385]: <debug> [1675887776.725483] [ttyUSB2/qcdm] --> 7e 00 78 f0 7e
Feb 08 20:22:56 ModemManager[385]: <debug> [1675887776.880941] [ttyUSB2/qcdm] <-- 0d 0a 4e 4f 20 43 41 52 52 49 45 52 0d 0a

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2024-09-17 11:26:06 -05:00
Dan Williams 7937a89a37 port-probe: rework and consolidate port probe flow for AT/QCDM/QMI/MBIM
Open the AT port from the regular port probe flow rather than doing
that one-off at the beginning of probing. That lets us re-open the AT
port later if needed, based on QCDM/QMI/MBIM probing results.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2024-09-17 11:23:01 -05:00
Dan Williams 6664d3740d port-probe: consolidate serial port closure and cleanup
Signed-off-by: Dan Williams <dan@ioncontrol.co>
2024-09-17 11:11:23 -05:00
Thomas Vogt c2e3a8c10e port-probe: detect XMMRPC ports 2024-07-31 17:36:14 +00:00
Z-张旭 93548c29cc mm-port-probe: ignore the fastboot port of the wwan device during port detection 2024-03-13 04:19:49 +00:00
Aleksander Morgado bd255849dc base-manager: reprobe device on late port additions
There is no guarantee from the kernel that the ports of a given device
will all be notified via uevents on a timely manner. We assume it, but
we cannot be completely sure.

There are two main scenarios that we have been seen when the ports of a
device are not notified close enough to each other:

 * A modem object is created, but not with the desired control protocol.
   E.g. a QMI or MBIM modem would end up controlled via AT commands if
   the cdc-wdm port was added too late.

 * A modem object is not created at all, and the device object was
   removed completely. E.g. when the net port addition in a QMI or MBIM
   modem happens too late.

In order to avoid those cases, we will now fully reprobe all the ports
of the device from scratch whenever a new valid port addition happens
after the initial probing of the device has already been completed. If a
modem object is available at that time, we will remove it right away.
2024-03-12 10:15:59 +00:00
Aleksander Morgado f90778df43 port-probe: switch command error handling to g_autoptr 2024-03-12 10:15:59 +00:00
Madhav 2b0c7505fb mm-port-probe: Invoke the mm_port_qmi_open function with a GCancellable object
Ensure that the cdc-wdm port probing task is canceled if the
modem drops off the bus before the task completes.
This prevents the task from preventing other port probing tasks from starting.
2023-10-27 09:46:13 +00:00
Madhav 48ee4d3012 mm-port-probe: Invoke the mm_port_mbim_open function with a GCancellable object
After the modem recovers, the ports are up but not yet responsive. When MM tries to probe the ports, they do not respond.
As a result, the probing tasks are left ongoing, waiting for a response from the modem.

If the modem drops off the bus for any reason, the cdc-wdm port probing task is not immediately canceled.
This patch fixes this issue by passing a cancellable object to mm_port_mbim_open().

In other words, the patch ensures that the cdc-wdm port probing task is canceled if the
modem drops off the bus before the task completes. This prevents the task from preventing
other port probing tasks from starting.
2023-10-19 19:59:48 +00:00
Aleksander Morgado 8e81064020 core: use more inclusive words in logs 2023-10-06 08:57:32 +00:00
Aleksander Morgado cb2dea5dc4 port-probe: perform auto detection of port type hints for wwan
We can remove the port type hint udev tags for the wwan subsystem, as
that logic is now incorporated in the port type hint processing logic
in the daemon itself.

This makes it clearer to know what exact hints are being used, as the
logic is in a single place and it has proper logging of all possible
cases.
2023-04-13 11:53:54 +00:00
Aleksander Morgado e77df40b68 port-probe: perform auto detection of port type hints for cdc_wdm
Do not do this in the plugin; instead, do it along with the logic that
looks for port type hints in udev, so that we can properly warn if
things don't match.
2023-04-13 11:53:03 +00:00
Aleksander Morgado 131e783a5f port-probe: improve logging of detected port type hints in udev tags
Explicitly log when a tag is found, and also warn if too many por type
hints are provided in the same port.
2023-04-13 11:49:19 +00:00
Aleksander Morgado 585d2af713 port-probe: simplify AT port type hints handling
When processing the hints for port probing we don't care if the AT
port is flagged as primary or secondary.
2023-04-13 11:44:50 +00:00
Lubomir Rintel c40876de95 port-serial-at: make mm_port_serial_at_command_finish() transfer ownership
This will make it slightly easier to port mm_port_serial_at_command() to
use GTask, since we won't have to keep a pointer to the result in GTask
after _finish() has been called.

In most cases the caller needs the value anyway, so this doesn't add too
much hasle.
2023-04-11 13:49:03 +00:00
Aleksander Morgado 024485e321 port-probe: don't assume port is QCDM when QCDM is not required
When QCDM is not required we don't run an explicit QCDM port probing
operation.

In this case, though, we should not assume that the port is QCDM
capable, even if it is also flagged as ignored.

Instead, we'll flag the port as QCDM capable and ignored only if there
was a udev port type hint associated to the port. Otherwise, we'll
report the port as not being QCDM capable, and the port won't even be
reported in the list of ports as its type is unknown.
2023-03-27 13:10:17 +00:00
Aleksander Morgado 7787c34af0 port-probe: minor refactor in QCDM probing 2023-03-27 12:54:46 +00:00
Daniele Palmas d6203265c2 port-probe: avoid QCDM port probing if not for specific plugins
The QCDM/DIAG port is usually nowadays exclusively used by applications
gathering traces from the modem, so avoid port probing and grabbing
when plugins set the property MM_PLUGIN_ALLOWED_QCDM.

A new property MM_PLUGIN_REQUIRED_QCDM is created for those plugins
requiring the QCDM port for properly using a modem.
2022-06-19 13:40:48 +00:00
Aleksander Morgado b094fe4427 port-probe: duplicate amount of AT probing attempts
We originally did only 3 attempts every 3s, so the maximum probing
time for a given TTY port looking for AT capabilities was 9 seconds.
We now duplicate the amount of times, so up to 18s of port probing,
which is quite a lot more than before, but unfortunately it's needed
because most new modems take a lot of time to boot up internally.

The way to avoid this long probing time is to make sure port type
hints for the possible AT ports are set correctly.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/379
2021-12-11 20:22:57 +00:00
Loic Poulain 6db2e8f04d base: Add support for wwan subsystem
Add support for the Linux wwan subsystem that started to expose
control channel as character devices (e.g. /dev/wwan0p1MBIM...).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2021-04-21 12:53:16 +02:00
Andrew Lassalle 5f1bac5cf8 port-probe: create port-qmi using a QRTR node
For QRTR devices, create the qmi ports using the QRTR node.
2021-04-14 11:27:27 +02: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 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
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 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 5aa7632e88 port-probe: avoid subsystem based checks when reading probe results
There should be no need to do an early check to filter out ports of
the wrong subsystem.

For the user of these methods it is irrelevant if the FALSE is
returned because the port is of the wrong subsystem, or because the
test wasn't added to be probed, or because the test actually failed.

In other words, the ports where the test succeeded will only have
succeeded if they are of the correct subsystem and if the test was
actually executed successfully.
2020-11-09 17:58:40 +01:00
Aleksander Morgado afe7a8e236 port-probe: port to use object logging 2020-04-08 16:35:09 +02:00
Aleksander Morgado 9e24226364 port-probe: MMPortProbeAtCommand always has constant command strings 2020-01-31 15:18:35 +01:00
Aleksander Morgado 51ef497634 port-probe: fix warnings with -Wdiscarded-qualifiers
mm-port-probe.c:1091:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1091 |     { "AT",  3, mm_port_probe_response_processor_is_at },
        |       ^~~~
  ...
2020-01-30 11:59:14 +01:00
Aleksander Morgado 377691afd4 port-qmi: asynchronous close operation always
To be in sync with the qmi_device_close_async() underlying method,
given that the synchronous one is deprecated.
2020-01-22 13:56:59 +01:00
Aleksander Morgado e3a1364ddc core: allow flagging ports as 'audio'
Instead of flagging them as 'ignored' so that they aren't probed, we
can also flag them as 'audio' now, so that the logic knows which port
to report as used for audio in the Call object.
2019-10-15 13:19:10 +02:00
Dan Williams 88fac7f14a build: fix -Wunused-but-set-variable support and handle clang better
By default the build used -Wno-unused-but-set-variable but that's
clearly not what we want. Fix those problems.

When using clang, the compiler doesn't error on unknown compile
options, so let's add -Werror to the checking too.

CC='clang'
configure:3408: checking for gcc
configure:3435: result: clang
...
configure:17644: checking whether gcc understands -Wno-unused-but-set-variable
configure:17657: clang -c -Wall -std=gnu89 -g -O2 -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wstrict-prototypes -Wno-unused-parameter -Wno-sign-compare -Wno-deprecated-declarations -Wno-unused-but-set-variable  conftest.c >&5
warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]
1 warning generated.
configure:17657: $? = 0
configure:17666: result: yes

Reported-by: Torsten Hilbrich <torsten.hilbrich@secunet.com>
2019-04-02 10:48:40 -05:00
Aleksander Morgado 2a1a0b88fb udev: define all generic tags as symbols
This prevents errors due to nasty typos in the strings.

We define all symbols in a single header file that is NOT considered
part of the API, as there is no need for MM clients to know about
these tags code-wise. These tags are only meaningful when associated
to devices in udev.

Information of each tag is included in the general API documentation.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/88
2018-09-25 17:55:53 +00:00
Aleksander Morgado 4c669d3bf4 modem-helpers: reuse nicknames for the flow control tags
And check that the string given in the tag is actually a valid one.
2018-09-12 17:15:46 +00:00
Alfonso Sánchez-Beato 94879ce1ce base-modem,port-probe: set serial port flow control from udev tag
Set the serial port flow control from the udev tag
ID_MM_TTY_FLOW_CONTROL before accessing the port.
2018-09-12 17:15:46 +00:00
Aleksander Morgado 28c1acf2e1 port-probe: fix build when QMI over MBIM is unsupported 2018-08-28 09:25:37 +02:00
Ben Chan 0520836afa mbim: fix inconsistency in WITH_QMI guards 2018-08-23 09:44:28 +02:00
Aleksander Morgado 82262117e6 port-probe: support probing for Intel XMM capabilities
Same thing as we do for Icera.
2018-08-21 17:02:39 +00:00