Commit Graph
653 Commits
Author SHA1 Message Date
Dan Williams 1fa21fcc48 base-cbm,cbm-list,iface-cbm: remove usage of MMBaseModem
CBM isn't as complicated as SMS, and the CBM class itself doesn't
need to be overridden by QMI/MBIM/etc. Now that the log parent
and connection binding no longer require MMBaseModem we can flatten
the CBM object creation and remove usage of MMBaseModem.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-08 20:08:06 -05:00
Dan Williams ec5104c9a8 Move log parent and connection property binding to helper
Continues removing usage of MMBaseModem in a bunch of files
by splitting out bits of its usage to separate interfaces.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-08 20:08:06 -05:00
Dan Williams b13bdacf38 broadband-modem: close serial ports in dispose
We want ports to be closed as early as possible; so make sure they
are closed in dispose() which is run explicitly by MMDevice when
cleaning up and removing the modem. Otherwise they could stay
open longer than we want, causing problems for suspend/resume.

This caused problems with suspend because cancelling the
MMBaseModem's cancellable triggered an idle handler that held
a reference to the modem, preventing finalize() from running
until after the suspend code was finished, thus preventing
ports from being closed and cleaned up. Closing them in
dispose() handles this.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-08 15:41:10 -05:00
Dan Williams febab17f07 broadband-modem: reload registration info after manual registration
This refreshes operator information after manual registration. QMI and
MBIM implementations return operator info along with registration info
so they handle this easily, while with AT-based devices we must run
additional commands to retrieve that after the manual registration has
finished.

Suggested by: Kirill Buksha <kirill.buksha@axians.rs>
Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/971

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-01 15:15:29 -05:00
Dan Williams 8cf25a97a1 broadband-modem: detect old Mediatek 62xx chipsets as GSM-capable
They don't necessarily reply to +WS46 but like old Motorola ESX
devices they reply to +CGMM with a known string.

Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/980

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-04-23 10:11:22 -05:00
Guido Günther b83df955fa modem: Load current channels on startup
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-28 20:53:52 +00:00
Guido Günther 2878833f5c modem: Allow to set current channel list
This adds support for setting the channels to override the boot up modem
defaults:

```
  busctl --system call org.freedesktop.ModemManager1 /org/freedesktop/ModemManager1/Modem/0 org.freedesktop.ModemManager1.Modem.CellBroadcast SetChannels 'a(uu)' 1 0 9999
  busctl --system get-property org.freedesktop.ModemManager1 /org/freedesktop/ModemManager1/Modem/0 org.freedesktop.ModemManager1.Modem.CellBroadcast Channels
  a(uu) 1 0 9999
```

Closes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/934

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-28 20:53:52 +00:00
Dan Williams bad4765581 broadband-modem: detect modem modes with +CEREG and +C5GREG
Some AT-based modems like the Quectel Unisoc-based RM500U don't
support the older AT commands we used to detect modes like
AT*CNTI=2 and AT+WS46. Add support for detecting 4G and 5G
with generic commands too.

Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/786

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-03-27 23:51:17 +00: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 68933455df treewide: Fix typos
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-11 23:15:57 +01:00
Dan Williams f014f3843e broadband-modem,cli: slightly bump 3GPP scan timeout; add some cli dbus timeout slack
Add some mmcli D-Bus timeout slack, making them slightly higher than the
ModemManager internal timeout, to ensure the cli doesn't time out the
D-Bus call when MM succeeds.

For 3GPP scan, some modems appear to have internal 5 minute timeouts,
so ensure MM doesn't time out right before the modem returns results:

ModemManager[282578]: <dbg> [1741054422.321400] [ttyUSB2/at] --> 'AT+COPS=?<CR>'
ModemManager[282578]: <wrn> [1741054722.247806] [modem1] failed scanning networks: Serial command timed out
ModemManager[282578]: <dbg> [1741054724.119770] [ttyUSB2/at] <-- '<CR><LF>+COPS: (1,"T-Mobile","T-Mobile","310260",0),,(0,1,2,3,4),(0,1,2)<CR><LF><CR><LF>OK<CR><LF>'

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-03-06 04:52:50 +00:00
Akula Susmitha bf5245bb27 messaging: load default storage from modem during initialization
Signed-off-by: Akula Susmitha <quic_asusmith@quicinc.com>
2025-02-27 15:04:59 +00:00
Aleksander Morgado 781428ddcd iface-modem-firmware: common logic to check for sahara/firehose tags
The logic will exclusively look for the udev tags reporting
sahara/firehose support in the primary control port of each modem
type.
2025-02-21 14:08:50 +00:00
Lukas Voegl 155893ea38 broadband-modem: generic Firehose and Sahara support
Allows setting the renamed `ID_MM_QUALCOMM_FIREHOSE` and
`ID_MM_QUALCOMM_SAHARA` environment variables for all devices.

Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2025-02-21 14:08:50 +00:00
Aleksander Morgado ef5fe9b8d5 broadband-modem: prefer explicit return to break
Just to make it explicit that there is no more logic running
afterwards.
2025-02-03 10:21:32 +00:00
Aleksander Morgado 4ce23a9ebd broadband-modem: exit with error if enable() while in unknown state
We should not assert if the modem is flagged as invalid but an
outstanding enabling request is processed. Let's exit gracefully and
let the object get properly disposed afterwards.

   (libc.so.6 - pthread_kill.c: 44)         __pthread_kill_implementation
   (libc.so.6 - raise.c: 26)    raise
   (libc.so.6 - abort.c: 79)    abort
   (libglib-2.0.so.0 - gtestutils.c: 3450)  g_assertion_message
   (libglib-2.0.so.0 - gtestutils.c: 3476)  g_assertion_message_expr
   (ModemManager - mm-broadband-modem.c)    enable
   (ModemManager - mm-iface-modem.c: 2340)  handle_enable_auth_ready
   (libgio-2.0.so.0 - gtask.c: 1309)        g_task_return_now
   (libgio-2.0.so.0 - gtask.c: 1378)        g_task_return
   (ModemManager - mm-base-modem.c: 2011)   lock_after_authorize_ready
   (libgio-2.0.so.0 - gtask.c: 1309)        g_task_return_now
   (libgio-2.0.so.0 - gtask.c: 1378)        g_task_return
   (ModemManager - mm-base-modem.c: 1841)   base_modem_operation_run
   (ModemManager - mm-base-modem.c: 764)    state_operation_ready
   (libgio-2.0.so.0 - gtask.c: 1309)        g_task_return_now
   (libgio-2.0.so.0 - gtask.c: 1323)        complete_in_idle_cb
   (libglib-2.0.so.0 - gmain.c: 3460)       g_main_dispatch
   (libglib-2.0.so.0 - gmain.c: 4200)       g_main_context_dispatch
   (libglib-2.0.so.0 - gmain.c: 4276)       g_main_context_iterate
   (libglib-2.0.so.0 - gmain.c: 4479)       g_main_loop_run
   (ModemManager - main.c: 236) main
   (libc.so.6 - libc_start_call_main.h: 58) __libc_start_call_main
   (libc.so.6 - libc-start.c: 360)          __libc_start_main_impl
   (ModemManager + 0x000b8850)              _start
2025-02-03 10:18:19 +00:00
Guido Günther 60357247eb broadband-modem: Add Cell Broadcast implementation
The CBMs are read via unsolicted events for which we register
an event handler.

We don't enable unsolicted events explicitly as this already happens
via the `+CNMI=*,*,2,*,*` whens setting up unsolicted events in
`modem_messaging_enable_unsolicited_events` (ETSI TS 127 005).
2024-12-01 21:41:10 +00:00
Aleksander Morgado 9a76a00095 broadband-modem: don't assert Modem interface skeleton during enabling
There is no guarantee that during an enabling operation the skeleton
for the Modem interface unconditionally exists, e.g. the modem may
have been flagged as invalid and untracked from DBus during the
operation.

Just remove the assertion, because mm_iface_modem_enable() will
already cleanly fail if the skeleton object is not found.

   Thread 0 (crashed),
    0  libc.so.6!__pthread_kill_implementation [pthread_kill.c : 44 + 0x0],
    1  libc.so.6!raise [raise.c : 26 + 0xb],
    2  libc.so.6!abort [abort.c : 79 + 0xa],
    3  libglib-2.0.so.0!g_assertion_message [gtestutils.c : 3450 + 0x5],
    4  libglib-2.0.so.0!g_assertion_message_expr [gtestutils.c : 3476 + 0x14],
    5  ModemManager!enabling_step [mm-broadband-modem.c : 0 + 0x7],
    6  libgio-2.0.so.0!g_task_return_now [gtask.c : 1309 + 0x5],
    7  libgio-2.0.so.0!g_task_return [gtask.c : 1378 + 0x8],
    8  ModemManager!parent_enabling_started_ready [mm-broadband-modem-mbim.c : 3239 + 0xd],
    9  libgio-2.0.so.0!g_task_return_now [gtask.c : 1309 + 0x5],
   10  libgio-2.0.so.0!complete_in_idle_cb [gtask.c : 1323 + 0x5],
   11  libglib-2.0.so.0!g_main_dispatch [gmain.c : 3460 + 0x2],
2024-10-29 18:16:27 +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
Aleksander Morgado 8e8e88b75d broadband-modem: update modem state before disabling task is completed
The modem state property update was happening at disabling task context
free time, after the actual task completion has happened.

Avoid wrong assumptions on the modem state value in operations
scheduled after the task completion, in the same way as done in the
enabling sequence.
2024-09-30 07:51:53 +00:00
Aleksander Morgado 17929188d8 broadband-modem: update modem state before enabling task is completed
The modem state property update was happening at enabling task context
free time, after the actual task completion has happened. Due to this,
scheduling a new enable request right after finishing one would end up
with the logic asserting, as the new enable operation would be
scheduled while the modem was still reporting "enabling" state.

  ModemManager[7673]: <inf> [1722359278.131123] [modem0] processing user request to enable modem...
  **
  ERROR:../src/mm-broadband-modem.c:12487:enable: code should not be reached
  Bail out! ERROR:../src/mm-broadband-modem.c:12487:enable: code should not be reached
  Aborted
2024-09-30 07:51:53 +00:00
Lubomir Rintel 5f6b095360 broadband-modem: fix a potential leak in cusd_process_string() error handling
On error, *converted may already be allocated and we need to free it
(but not in case we're returning it from the task).
2024-05-31 10:46:30 +00:00
Aleksander Morgado 9fcff66406 broadband-modem: allow subclassing initial eps bearer cid selection 2024-05-29 09:08:13 +00:00
Aleksander Morgado e7492270c2 broadband-modem: implement setting initial EPS bearer settings 2024-05-29 09:05:22 +00:00
Aleksander Morgado 471656addf broadband-modem: implement loading initial EPS bearer info 2024-05-29 09:05:22 +00:00
Aleksander Morgado 97cab9f37e broadband-modem: implement loading initial EPS bearer settings
The main issue here is how to select the id of the context that is
used for attach in the modem.

We will assume that the lowest cid value for the IP range returned in
the CGDCONT=? test is the one used for the attach context. This
assumption works with modems following the 3GPP specs (with cid=0) and
also in Qualcomm based modems (with cid=1).
2024-05-29 09:05:04 +00:00
Aleksander Morgado 1c919890c6 iface-modem-cdma: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:39 +00:00
Aleksander Morgado 92a89efd02 iface-modem-oma: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:39 +00:00
Aleksander Morgado 0f48695d54 iface-modem-voice: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:38 +00:00
Aleksander Morgado 074277ca1a iface-modem-time: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:38 +00:00
Aleksander Morgado bec62a406c iface-modem-signal: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:38 +00:00
Aleksander Morgado 0a91a6035b iface-modem-simple: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:38 +00:00
Aleksander Morgado cc2f1317b3 iface-modem-sar: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:38 +00:00
Aleksander Morgado 070975736f iface-modem-messaging: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:38 +00:00
Aleksander Morgado aa94b21e0a iface-modem-location: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:45:38 +00:00
Aleksander Morgado e535c90f5f iface-modem-firmware: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:27:05 +00:00
Aleksander Morgado 2b7e738b9b iface-modem-3gpp-ussd: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:27:04 +00:00
Aleksander Morgado f033a0a9f2 iface-modem-3gpp-profile-manager: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:27:04 +00:00
Aleksander Morgado ab6e4bf391 iface-modem-3gpp: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:27:04 +00:00
Aleksander Morgado 35c0a6905b iface-modem: use G_DECLARE|DEFINE_INTERFACE() macros 2024-05-06 13:27:04 +00:00
Aleksander Morgado 939be0fbf8 base-modem: support non-serial ports when peeking the best AT port
When we don't care about the type of AT port to use, prefer the QMI or
MBIM based ones if any available.
2024-04-23 07:25:12 +00:00
Aleksander Morgado 480e12c34e base-modem-at: switch to use the MMIfacePortAt by default
The whole codebase is updated to assume the MMBaseModem AT operations
require an object implementing the MMIfacePortAt interface, instead of
a MMPortSerialAt object.

In the places where we know the port is a MMPortSerialAt, e.g. when we
query explicitly for the primary or secondary serial AT port, we will
use an explicit MM_IFACE_PORT_AT() cast when calling the AT command
method.

In the places where we get_best_at_port() we're going to assume that
we don't know the port type. This method will be updated in a follow
up commit to support the MMIfacePortAt interface as well.
2024-04-23 07:25:12 +00:00
Aleksander Morgado b158c2e92a broadband-modem: don't assume an AT port always exists in explicit registration 2024-04-12 01:17:14 +00:00
Aleksander Morgado f1fb3d1145 broadband-modem: don't assume primary port always exists 2024-04-12 01:17:14 +00:00
Aleksander Morgado 04e59852a9 broadband-modem: remove unnecessary early check for AT ports
There is no need for an explicit early check, the at_command()
operation will do that implicitly.
2024-04-12 01:17:14 +00:00
Aleksander Morgado a18d9d621b broadband-modem: use primary port to get flow control settings 2024-04-12 01:17:14 +00:00
Aleksander Morgado f08803e858 broadband-modem: coding style fixes in the 3GPP URC enabling/disabling logic 2024-03-27 12:09:32 +00:00
Aleksander Morgado 4ed45af376 broadband-modem: track primary/secondary ports while enabling/disabling 3GPP URCs
We should not blindly assume that peek_port_primary() always returns a
valid port, because the device may have been ejected while the AT
sequence is running.

Instead, keep a valid port object reference in the operation context,
and use it in all the AT command requests. The requests will fail if
the device has been ejected, but the port object reference will be
valid and the daemon won't crash.
2024-03-27 12:09:32 +00:00
Aleksander Morgado 07f1f58642 modem-helpers: rework AT string quote operation and add unit tests
Rework the AT string quote operation to build the output with the
GString helper, instead of manually calculating how many bytes we'll
need in the output. It just makes it clearer.
2024-03-12 10:15:59 +00:00
Aleksander Morgado 311d6f389e broadband-modem: fix crash when ports gone while setting up messaging URCs
We cannot assume that the ports may be peeked after the AT sequence
has finished, because they may have been already removed. We can store
a full port reference instead, to ensure the validity of the objects
at that time.

  ==19351== Process terminating with default action of signal 5 (SIGTRAP)
  ==19351==    at 0x4A1DB24: g_logv (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6800.1)
  ==19351==    by 0x4A1DDB2: g_log (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6800.1)
  ==19351==    by 0x28B54E: mm_port_get_device (mm-port.c:62)
  ==19351==    by 0x1B1247: modem_messaging_enable_unsolicited_events_secondary_ready (mm-broadband-modem.c:7373)
  ==19351==    by 0x4BA37D8: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.6800.1)
  ==19351==    by 0x4BA381C: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.6800.1)
  ==19351==    by 0x4A157EE: g_main_context_dispatch (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6800.1)
  ==19351==    by 0x4A68D27: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6800.1)
  ==19351==    by 0x4A14E52: g_main_loop_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6800.1)
  ==19351==    by 0x176B91: main (main.c:236)
2024-03-12 10:15:59 +00:00