Commit Graph
371 Commits
Author SHA1 Message Date
Dan Williams f7897daeb5 broadband-modem,iface-modem: move bearer counting to interface and generalize
Allow counting more kinds of bearers than just multiplexed ones.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-07-21 15:11:16 -05:00
Aleksander Morgado 7d4784ed28 iface-modem: ignore SIM events during a controlled SIM slot switch
If there is an ongoing SIM slot switch, we must ignore all SIM hotswap
related events happening during the process. The flag that is set in
the Modem interface private info to track this is never reset back to
FALSE on a successful SIM slot switch, it will be set for as long as
the modem object exists.

After the successful SIM slot switch, a new modem reprobe will be
requested, which leads to the old modem object to be disposed (the one
that had the flag set) and a new modem object created.

The logic that already existed in the MBIM modem object is now
generalized in the Modem interface itself so that SIM events reported
via other protocols are also properly ignored.

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2025-06-18 22:10:54 +00:00
Dan Williams 683a33b303 base-sms: determine 3GPP vs. CDMA at creation time
It won't ever change over the lifetime of the BaseSMS.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-08 20:24:37 -05:00
Dan Williams ef5cee3ab5 auth-provider: move auth provider logic into each class
Rather than make all of them rely on MMBaseModem for it. This
lets us disentangle dependencies for easier unit testing.

For interfaces, rather than casting directly to MMBaseModem
use intermediate interfaces (MMIfaceAuth and MMIfaceOpLock)
that tests can fake out.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-08 20:08:06 -05:00
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 57d1f21b36 broadband-modem,iface-modem: don't treat SIM unlocks as hot-swaps
If the old IMSI was unavailable because the SIM was locked, but now
is available because the SIM was unlocked, don't treat the SIM
properties change as a hotswap that may trigger dropping and re-probing
the modem.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-03-23 09:04:42 -05:00
Guido Günther 54dcc25d8b treewide: Fix some spelling errors
All in debug messages or code comments so not user / client visible.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-05 16:53:26 +00:00
Lukas Voegl 32435b430f broadband-modem-cinterion: never discard operator or mode
When setting an operator, AT+COPS overwrites the currently set allowed mode. Equally, the other way around, when setting the current mode, the configured operator is overwritten.

Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2024-11-20 12:07:20 +00:00
Aleksander Morgado dfc0f8ebfd base-modem: override disable operations done before modem object removal
If we are going to inhibit the modem or fully reprobe it after a SIM
switch event, we should forbid further operations done with the modem
object.

This logic can be tested by queing different operations one after the
other, and then adding a last device inhibition ("override" operation)
that should trigger the early abort of all non-running operations,
e.g.:
  mmcli -m a -e &
  sleep 0.2
  mmcli -m a --3gpp-set-initial-eps-bearer-settings="apn=internet,ip-type=ipv4v6,force=true" &
  sleep 0.2
  mmcli -m a -d &
  sleep 0.2
  mmcli -m a -e &
  sleep 0.2
  mmcli -m a --set-power-state-low &
  sleep 0.2
  mmcli -m a -e &
  sleep 0.2
  mmcli -m a --inhibit

This previous sequence produces MM logs as follows:
  <dbg> [1726567756.430308] [modem0] [operation 22] default - enable: scheduled
  <dbg> [1726567756.430806] [modem0] [operation 22] default - enable: lock acquired
  <dbg> [1726567756.623746] [modem0] [operation 23] default - set-initial-eps-bearer-settings: scheduled
  <dbg> [1726567756.751743] [modem0] [operation 22] default - enable: lock released
  <dbg> [1726567756.752027] [modem0] [operation 23] default - set-initial-eps-bearer-settings: lock acquired
  <dbg> [1726567756.823739] [modem0] [operation 24] default - disable: scheduled
  <dbg> [1726567757.049581] [modem0] [operation 25] default - enable: scheduled
  <dbg> [1726567757.250165] [modem0] [operation 26] default - set-power-state: scheduled
  <dbg> [1726567757.450518] [modem0] [operation 27] default - enable: scheduled
  <dbg> [1726567757.676362] [modem0] [operation 28] override - disabling: override requested - no new operations will be allowed
  <dbg> [1726567757.678792] [modem0] [operation 24] default - disable: aborted early
  <dbg> [1726567757.679866] [modem0] [operation 25] default - enable: aborted early
  <dbg> [1726567757.680157] [modem0] [operation 26] default - set-power-state: aborted early
  <dbg> [1726567757.680496] [modem0] [operation 27] default - enable: aborted early
  <dbg> [1726567759.695780] [modem0] [operation 23] default - set-initial-eps-bearer-settings: lock released
  <dbg> [1726567759.695935] [modem0] [operation 28] override - disabling: lock acquired
  <dbg> [1726567759.872196] [modem0] [operation 28] override - disabling: lock released
2024-09-30 11:07:11 +00:00
Aleksander Morgado 3510ffc418 iface-[modem|modem3gpp]: operation lock in all operations that change state
This logic can be tested by queing different operations one after the
other, e.g.:
  mmcli -m a -e &
  sleep 0.2
  mmcli -m a --3gpp-set-initial-eps-bearer-settings="apn=internet,ip-type=ipv4v6,force=true" &
  sleep 0.2
  mmcli -m a -d &
  sleep 0.2
  mmcli -m a -e &
  sleep 0.2
  mmcli -m a --set-power-state-low &
  sleep 0.2
  mmcli -m a -e &

This previous sequence produces MM logs as follows:
  <dbg> [1726567176.214906] [modem0] [operation 15] default - enable: scheduled
  <dbg> [1726567176.215108] [modem0] [operation 15] default - enable: lock acquired
  <dbg> [1726567176.436234] [modem0] [operation 16] default - set-initial-eps-bearer-settings: scheduled
  <dbg> [1726567176.554153] [modem0] [operation 15] default - enable: lock released
  <dbg> [1726567176.554492] [modem0] [operation 16] default - set-initial-eps-bearer-settings: lock acquired
  <dbg> [1726567176.619021] [modem0] [operation 17] default - disable: scheduled
  <dbg> [1726567176.840024] [modem0] [operation 18] default - enable: scheduled
  <dbg> [1726567177.037155] [modem0] [operation 19] default - set-power-state: scheduled
  <dbg> [1726567177.240225] [modem0] [operation 20] default - enable: scheduled
  <dbg> [1726567179.496397] [modem0] [operation 16] default - set-initial-eps-bearer-settings: lock released
  <dbg> [1726567179.496576] [modem0] [operation 17] default - disable: lock acquired
  <dbg> [1726567179.672141] [modem0] [operation 17] default - disable: lock released
  <dbg> [1726567179.672658] [modem0] [operation 18] default - enable: lock acquired
  <dbg> [1726567179.938481] [modem0] [operation 18] default - enable: lock released
  <dbg> [1726567179.940470] [modem0] [operation 19] default - set-power-state: lock acquired
  <dbg> [1726567182.147894] [modem0] [operation 19] default - set-power-state: lock released
  <dbg> [1726567182.148041] [modem0] [operation 20] default - enable: lock acquired
  <dbg> [1726567184.494469] [modem0] [operation 20] default - enable: lock released

iface-modem-3gpp: operation lock in all operations that change state
2024-09-30 11:07:02 +00:00
Aleksander Morgado be668462c0 base-modem: synchronize initialize/enable/disable/sync operations
Each of these now holds an exclusive lock, so all these operations are
synchronized.

This logic can be tested by queing different enable/disable operations
one after the other, e.g.:
  mmcli -m a -d &    --> Disable 1
  sleep 0.2
  mmcli -m a -e &    --> Enable 1
  sleep 0.2
  mmcli -m a -e &    --> Enable 2
  sleep 0.2
  mmcli -m a -d &    --> Disable 2
  sleep 0.2
  mmcli -m a -e &    --> Enable 3
  sleep 0.2
  mmcli -m a -d &    --> Disable 3

This previous sequence produces MM logs as follows:
  <dbg> [1726566352.936025] [modem0] [operation 9] default - disable:  scheduled     --> Disable 1 requested
  <dbg> [1726566352.936399] [modem0] [operation 9] default - disable:  lock acquired --> Disable 1 started
  <dbg> [1726566353.136445] [modem0] [operation 10] default - enable:  scheduled     --> Enable 1 requested
  <dbg> [1726566353.202980] [modem0] [operation 9] default - disable:  lock released --> Disable 1 finished
  <dbg> [1726566353.203526] [modem0] [operation 10] default - enable:  lock acquired --> Enable 1 started
  <dbg> [1726566353.320057] [modem0] [operation 11] default - enable:  scheduled     --> Enable 2 requested
  <dbg> [1726566353.440931] [modem0] [operation 10] default - enable:  lock released --> Enable 1 finished
  <dbg> [1726566353.443238] [modem0] [operation 11] default - enable:  lock acquired --> Enable 2 started
  <dbg> [1726566353.452984] [modem0] [operation 11] default - enable:  lock released --> Enable 2 finished
  <dbg> [1726566353.517512] [modem0] [operation 12] default - disable: scheduled     --> Disable 2 requested
  <dbg> [1726566353.517699] [modem0] [operation 12] default - disable: lock acquired --> Disable 2 started
  <dbg> [1726566353.688695] [modem0] [operation 12] default - disable: lock released --> Disable 2 finished
  <dbg> [1726566353.718237] [modem0] [operation 13] default - enable:  scheduled     --> Enable 3 requested
  <dbg> [1726566353.718417] [modem0] [operation 13] default - enable:  lock acquired --> Enable 3 started
  <dbg> [1726566353.937122] [modem0] [operation 14] default - disable: scheduled     --> Disable 3 requested
  <dbg> [1726566353.970791] [modem0] [operation 13] default - enable:  lock released --> Enable 3 finished
  <dbg> [1726566353.970964] [modem0] [operation 14] default - disable: lock acquired --> Disable 3 started
  <dbg> [1726566354.170938] [modem0] [operation 14] default - disable: lock released --> Disable 3 finished
2024-09-30 07:55:05 +00:00
Sebastian Krzyszkowiak 93c1e55d36 mm-iface-modem: Always check properties for disabling signal polling
MMBroadbandModemQmi only disables signal polling once it successfully
sets the indication up. To do that, it sets the properties on
MMIfaceModem. This, however, doesn't actually disable polling, as the
property values are only checked once in get_private when Private
structure hasn't been created yet. Once that happens, only the cached
values are ever checked, and there's nothing that would update them.

Since there's only one place where these properties are checked, get
rid of cached bools in Private structure and instead read the property
values directly in periodic_signal_check_step, letting QMI modems
actually disable polling at runtime.
2024-08-02 03:43:44 +02:00
Thomas Vogt c2e3a8c10e port-probe: detect XMMRPC ports 2024-07-31 17:36:14 +00:00
Lukas Voegl 7d0737a813 mm-iface-modem: clear signal only if supported
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2024-05-29 12:00:56 +00:00
Aleksander Morgado c5b9effdc7 iface-modem: allow reporting the previous power state after an update
Let the caller of mm_iface_modem_set_power_state() know which was the
power state in the device before the actual update happened.

This is useful in cases where we want to temporarily switch to a given
power state (e.g. low) before returning to the original power state.
2024-05-29 08:02:40 +00:00
Aleksander Morgado 35c0a6905b iface-modem: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:27:04 +00:00
Aleksander Morgado 83d5556f70 iface-modem: don't assume primary port always exists 2024-04-12 01:17:14 +00:00
Aleksander Morgado 2f5ebfadee iface-modem: create bearer list after loading revision
Modems may have certain features only available in new firmware
versions. We should try to load the firmware revision as soon as
possible, even before creating the bearer list, as that informs
already about multiplexing support in the device.
2024-02-15 21:01:52 +00:00
Aleksander Morgado b61adb1626 iface-modem: also run disable on failed low power mode update
If the user requested to set the modem in low power mode while
enabled, the user is also expecting the device to be implicitly
disabled.

If for any reason setting the modem to low power mode fails (e.g. it
could be not supported by the device), we should still try to run the
modem disabling sequence, as that is the expectation.
2024-02-08 14:31:19 +00:00
Aleksander Morgado e8f1edc5c4 iface-modem: allow low-power request while enabled
We now enable low-power mode request if we are enabled or even
connected. In this case, an explicit modem disable operation is run,
so that we don't end up with an enabled modem in low-power mode.

This new "low-power+disable" single operation makes the two
"disable+low-power" operation combo that was run until now much much
quicker, because the modem unregisters from the network and
disconnects PDNs in the same network interaction.
2024-01-25 15:40:30 +00:00
Aleksander Morgado 19b3e59151 iface-modem: ensure power state updates are spaced in time
This change is an attempt to behave a bit better with modems when
multiple consecutive enable/full-power/disable/low-power operations
are scheduled in a modem.

MM will automatically throttle these requests so that the power state
updates are spaced in time, with at least 2 full seconds between
them.
2024-01-11 11:13:12 +00:00
Aleksander Morgado 7f8b7adfde iface-modem: do not setup carrier config if eSIM without profiles
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/802
2024-01-11 10:47:02 +00:00
Aleksander Morgado 5fb2856645 iface-modem: allow cancellability during unlock required checks
The process doing the unlock required checks may need a lot of retries
e.g. to decide whether a SIM card is available or not. If we do a
quick SIM eject, so the unlock required check starts looping, and then
insert the SIM again, we expect the loop to be cancelled right away,
so that the new modem object can be reprobed without any interference
from the old modem object.

We now take the modem-wide cancellable and bind it to the GTask in
mm_iface_modem_update_lock_info(), and we pass it down to every
sub-step of the async logic in the operation. We also plug the
cancellable to the delayed retries in the interface logic, to allow
aborting the checks right away
2023-12-01 10:14:45 +00:00
Aleksander Morgado 1f9a04268f core: ensure all errors returned in DBus operations are normalized
We want to ensure that all errors reported via DBus operations are
normalized to MM-specific errors.

We don't want to return QMI or MBIM specific errors, as those are
protocol specific and we don't want DBus clients to need to rely on
knowing which is the protocol in use by the device.
2023-10-27 11:34:26 +02:00
Rukun Mao b7433b4c14 iface-modem: new logic to detect SIM swap with explicit IMSI/ICCID query
This improves SIM hot swap check process, and it can help avoid unnecessary
modem reprobe during suspend-resume without SIM inserted.

The changes in this CL implemented the new logic ONLY for MBIM, and the
new logic has not been implemented for QMI and AT yet. Thus, we keep the
legacy `mm_iface_modem_check_for_sim_swap()' till the new logic for QMI
and AT has been implemented.
2023-10-11 14:01:33 +00:00
okaestne 23fc7871db iface-modem: fix error message for failed mode setting 2023-10-09 00:54:32 +02:00
Robert Marko 39eb3749be iface-modem: actually respect build options
iface-modem does not include config.h so it doesnt actually have the meson
generated build defines to check against.

I found this while trying to use AT commands over D-Bus by enabling
at_command_via_dbus, confirming that Meson sees it, defines it in config.h
but then I still got the:
"Cannot send AT command to modem: operation only allowed in debug mode".

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
2023-09-27 13:25:36 +00:00
Lukas Voegl 8cd1c1bdb9 api,modem: new 'Physdev' property
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2023-09-18 10:53:12 +02:00
Aleksander Morgado c1382b3255 iface-modem: ensure error is set when UNKNOWN returned in modem state wait 2023-09-11 19:39:59 +00:00
Aleksander Morgado fb66cc26be iface-modem: ignore UNKNOWN modem state explicitly during wait operation 2023-09-11 19:39:59 +00:00
Aleksander Morgado 4db5635f44 iface-modem: sim swap check always refers to the active SIM
Since 503e886c02 the events on inactive SIMs don't trigger a full
modem reprobe, and the slot index check is fully unused.
2023-06-14 13:54:32 +00:00
Aleksander Morgado af89e63c35 iface-modem: ignore sim swap check if not implemented
Explicitly return TRUE to indicate success because otherwise the
caller will expect a valid GError set.
2023-06-14 13:48:06 +00:00
Nagi Marupaka eeba2ff32b broadband-modem-mbim: account for race condition in quick hot swap case
On MBIM modems, when the SIM is ejected and re-inserted in a quick manner,
the state machine logic encounters a race condition and eventually, the
modem response for subscriber status is ignored. This change accounts
for that state transition without erroring out.

Fixes #672.
2023-05-12 11:46:17 +00:00
Nagi Marupaka 110495dc44 mm-iface-modem: increase the SIM retries to 7
In some cases modem is taking 7 tries to detect an initialized SIM.
2023-05-11 18:20:45 +00:00
Aleksander Morgado 4e879cbede iface-modem: fix incorrectly halted periodic signal checks
Whenever an explicit signal refresh was requested we would flag the
check as ongoing but never reset the flag, so it would never attempt
to reload it again.

Fixes 0080ed612d
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/702
2023-04-11 10:47:19 +00:00
Aleksander Morgado a872541259 iface-modem: decrease severity of logs that don't affect functionality
Instead of warning about various unimportant things failing that don't
affect functionality, just print the logs in debug level and go on.

E.g. this warning can be completely skipped:
 <wrn> [modem0] couldn't load list of own numbers: Couldn't get MSISDN: QMI protocol error (16): 'NotProvisioned'
2022-11-04 13:12:58 +00:00
Aleksander Morgado 5c604d9d35 iface-modem: improve logging of user request to set current modes 2022-11-04 13:12:57 +00:00
Aleksander Morgado d4c0af9128 iface-modem: improve logging of user request to set current bands 2022-11-04 13:12:57 +00:00
Aleksander Morgado 21d60de42f iface-modem: improve logging of user request to factory reset modem 2022-11-04 13:12:57 +00:00
Aleksander Morgado b82c89f45c iface-modem: improve logging of user request to reset modem 2022-11-04 13:12:57 +00:00
Aleksander Morgado 03528fbff7 iface-modem: improve logging of user request to set power state 2022-11-04 13:12:57 +00:00
Aleksander Morgado a86fb711b3 iface-modem: improve logging of user request to enable/disable modem 2022-11-04 13:12:57 +00:00
Aleksander Morgado 9fe16af157 iface-modem: improve logging of user request to get cell info 2022-11-04 13:12:57 +00:00
Aleksander Morgado 73696cab1a iface-modem: improve logging of user request to set primary SIM slot 2022-11-04 13:12:57 +00:00
Aleksander Morgado 4fa773d234 iface-modem: improve logging of user request to delete bearer 2022-11-04 13:12:57 +00:00
Aleksander Morgado aed53fe30a iface-modem: improve logging of user request to run AT command 2022-11-04 13:12:57 +00:00
Aleksander Morgado ac28a6a1c0 iface-modem: improve logging of user request to set current capabilities 2022-11-04 13:12:57 +00:00
Aleksander Morgado 9840818766 iface-modem: improve logging of user request to create bearer 2022-11-04 13:12:56 +00:00
Aleksander Morgado f98bcd5f58 iface-modem: refactor user request to list bearers 2022-11-04 13:12:56 +00:00
Aleksander Morgado f1fa2eb81e iface-modem: improve logging in INFO level 2022-11-04 13:12:56 +00:00