Commit Graph

4774 Commits

Author SHA1 Message Date
Aleksander Morgado
5dbf8fdb47 iface-modem-signal: remove unused variable
src/mm-iface-modem-signal.c:99:27: warning: unused variable 'current_time' [-Wunused-variable]
      g_autoptr(GDateTime)  current_time = NULL;
                            ^
2023-03-15 09:07:15 +00:00
Aleksander Morgado
6c2822167b sim-mbim: remove unused variable
src/mm-sim-mbim.c:1134:30: warning: unused variable 'request' [-Wunused-variable]
      g_autoptr(MbimMessage)   request = NULL;
                               ^
2023-03-15 09:03:56 +00:00
Aleksander Morgado
dad3e82747 broadband-modem-qmi: disable profile changed indications during our operations
Just ignoring the received indications is not enough, because they
could arrive after the operation response has been processed.

We now explicitly disable the indications by reconfiguring the modem
before and after every profile update operation triggered by our own
logic.
2023-03-10 10:59:42 +00:00
Daniele Palmas
592f8b6364 telit: ignore composition 0x1075
When Telit FN990 is integrated through PCIe, but also USB lines are
available, ModemManager will consider the port on the USB composition
as a different modem:

oem@sw-test:~$ mmcli -L
    /org/freedesktop/ModemManager1/Modem/1 [telit] FN990A40
    /org/freedesktop/ModemManager1/Modem/0 [Telit] FN990A40

oem@sw-test:~$ mmcli -m 0
<snip>
           |         equipment id: 359172390022295
  --------------------------------
  System   |               device: /sys/devices/pci0000:00/0000:00:14.0/usb2/2-5
           |              drivers: option
           |               plugin: telit
           |         primary port: ttyUSB0
           |                ports: ttyUSB0 (at)

oem@sw-test:~$ mmcli -m 1
<snip>
            |           equipment id: 359172390022295
  -----------------------------------
  System    |                 device: /sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0
            |                drivers: mhi-pci-generic
            |                 plugin: telit
            |           primary port: wwan0mbim0
            |                  ports: wwan0 (net), wwan0at0 (at), wwan0at1 (at),
            |                         wwan0mbim0 (mbim), wwan0nmea0 (ignored), wwan0qcdm0 (ignored)

Ignore composition 0x1075, since it should not be used by ModemManager
and can only show when PCIe is used.
2023-03-07 11:06:51 +00:00
dchard
00f3054652 quectel: add support for EG12-EA type usb modules 2023-03-03 08:47:04 +00:00
Nagi Marupaka
3a76cb29ef broadband-modem-mbim: add support for setting up thresholds on v1 MBIM modems
On MBIM modems that do not support mbimex v2, extra steps are required
to retrieve 3G/4G signal quality markers from the modem when using
thresholds to trigger signal quality indications.
2023-02-28 17:32:58 +00:00
Aleksander Morgado
dee307d2cf base-manager: remove shadowing variable
[1/2] Compiling C object src/ModemManager.p/mm-base-manager.c.o
  ../src/mm-base-manager.c: In function ‘remove_device_inhibition’:
  ../src/mm-base-manager.c:1127:20: warning: declaration of ‘l’ shadows a previous local [-Wshadow]
   1127 |             GList *l;
        |                    ^
  ../src/mm-base-manager.c:1116:16: note: shadowed declaration is here
   1116 |         GList *l;
        |                ^
2023-02-24 13:43:34 +00:00
QuectelDuke
fb386765a5 quectel: add support for EC21-EUX usb modules
Signed-off-by: QuectelDuke <duke.xin@quectel.com>
2023-02-23 15:06:23 +08:00
Aleksander Morgado
fbd79a278b xmm: fix crash parsing XACT? response
Ensure we don't assert when processing an unexpected response.

We were not correctly handling the case where g_match_info_matches()
was not succeeding.

  0x00007d8be96cc462 (libc.so.6 + 0x00028462)     abort
  0x00007d8be995ff01 (libglib-2.0.so.0 - gtestutils.c: 3253)      g_assertion_message
  0x00007d8be995ff64 (libglib-2.0.so.0 - gtestutils.c: 3279)      g_assertion_message_expr
  0x00007d8be858086a (libmm-shared-xmm.so - mm-modem-helpers-xmm.c: 467)  mm_xmm_parse_xact_query_response
  0x00007d8be857d4e0 (libmm-shared-xmm.so - mm-shared-xmm.c: 310) xact_query_bands_ready
  0x00007d8be9a79463 (libgio-2.0.so.0 - gsimpleasyncresult.c: 802)        g_simple_async_result_complete
  0x00005c8d2a11e9b9 (ModemManager - mm-base-modem-at.c: 538)     at_command_ready
  0x00007d8be9a79463 (libgio-2.0.so.0 - gsimpleasyncresult.c: 802)        g_simple_async_result_complete
  0x00005c8d2a19376b (ModemManager - mm-port-serial-at.c) serial_command_ready
  0x00007d8be9a79463 (libgio-2.0.so.0 - gsimpleasyncresult.c: 802)        g_simple_async_result_complete
  0x00005c8d2a18f93f (ModemManager - mm-port-serial.c: 139)       command_context_complete_and_free
  0x00005c8d2a192985 (ModemManager - mm-port-serial.c: 753)       port_serial_got_response
  0x00005c8d2a192dff (ModemManager - mm-port-serial.c: 924)       common_input_available
  0x00007d8be993e3fc (libglib-2.0.so.0 - gmain.c: 3417)   g_main_context_dispatch
  0x00007d8be993e704 (libglib-2.0.so.0 - gmain.c: 4211)   g_main_context_iterate
  0x00007d8be993e978 (libglib-2.0.so.0 - gmain.c: 4411)   g_main_loop_run
  0x00005c8d2a105e66 (ModemManager - main.c: 217) main
  0x00007d8be96cc6c5 (libc.so.6 + 0x000286c5)     __libc_init_first
  0x00007d8be96cc781 (libc.so.6 + 0x00028781)     __libc_start_main
  0x00005c8d2a105b80 (ModemManager + 0x00061b80)  _start
2023-02-21 14:59:01 +00:00
Aleksander Morgado
7837944e25 base-manager: fix crash when uninhibiting partially removed device
If the device is not fully removed from the system during inhibition
and port additions happen, we reach a state where the MMDevice object
is still tracked by ModemManager and we also have new port additions
tracked that will require explicit port probings before a new modem
object can be created.

Solve this mixup by faking the removal of all existing device ports,
which will end up completely removing hte MMDevice, so that new port
additions reported afterwards also involve the full device probing
process triggered by the plugin manager.

The issue could be reproduced easily on a MBIM device that also
exposed TTYs, as follows:

 * mmcli -m a --inhibit, leave it running
 * rmmod cdc_mbim && sleep 5 && modprobe cdc_mbim (so that the
   cdc-wdm and net ports go away from the system but NOT the TTYs.)
 * Cltr+C to stop the inhibit in the mmcli call.

ModemManager would assert as follows:

  0x000079918bcf2a3f (libc.so.6 + 0x00087a3f)     pthread_key_delete
  0x000079918bca7c6c (libc.so.6 + 0x0003cc6c)     gsignal
  0x000079918bc93462 (libc.so.6 + 0x00028462)     abort
  0x000079918bf26f03 (libglib-2.0.so.0 - gtestutils.c: 3253)      g_assertion_message
  0x000079918bf26f66 (libglib-2.0.so.0 - gtestutils.c: 3279)      g_assertion_message_expr
  0x0000594ff1093d0c (ModemManager - mm-base-manager.c: 1110)     remove_device_inhibition
  0x0000594ff1093968 (ModemManager - mm-base-manager.c: 1247)     inhibit_device_auth_ready
  0x000079918c0536a8 (libgio-2.0.so.0 - gtask.c: 1230)    g_task_return_now
  0x000079918c0536db (libgio-2.0.so.0 - gtask.c: 1244)    complete_in_idle_cb
  0x000079918bf053fc (libglib-2.0.so.0 - gmain.c: 3417)   g_main_context_dispatch
  0x000079918bf05704 (libglib-2.0.so.0 - gmain.c: 4211)   g_main_context_iterate
  0x000079918bf05978 (libglib-2.0.so.0 - gmain.c: 4411)   g_main_loop_run
  0x0000594ff108de66 (ModemManager - main.c: 217) main
  0x000079918bc936c5 (libc.so.6 + 0x000286c5)     __libc_init_first
  0x000079918bc93781 (libc.so.6 + 0x00028781)     __libc_start_main
  0x0000594ff108db80 (ModemManager + 0x00061b80)  _start
2023-02-21 14:35:18 +00:00
Aleksander Morgado
6d1f4aee30 broadband-modem-mbim: limit the use of context types defined in MBIMEx
The Tethering context type UUID was defined by Microsoft in its
extensions as `5e4e0601-48dc-4e2b-acb8-08b4016bbaac` (along with
others like Admin, Xcap, App and EmergencyCalling), see
https://learn.microsoft.com/en-us/windows-hardware/drivers/network/mb-provisioned-context-operations.

These UUIDs are expected to be usable only if the modem supports
`MBIM_CID_MS_PROVISIONED_CONTEXT_V2` (CID=1) in the Basic Connect
Extensions service (3d01dcc5-fef5-4d05-0d3abef7058e9aaf).

If the modem doesn't support these, we should try to fallback to a
more generic APN type automatically, e.g. "Internet", which was
defined in MBIM 1.0 and should always be supported.

There should be no problem in a modem to have 2 separate PDN
connections with the same context type.
2023-02-20 11:07:38 +00:00
Aleksander Morgado
278678d8ed modem-helpers-mbim: add missing support for 'emergency' APN type 2023-02-17 14:18:41 +00:00
Aleksander Morgado
3e960b97e2 modem-helpers-mbim: small refactor in the EARFCN/NRARFCN to frequency converters 2023-02-17 10:43:20 +00:00
Aleksander Morgado
5c5126b7ff broadband-modem-mbim: avoid using already freed element during iteration
If we remove the current element being iterated in the GList, we can
no longer call g_list_next() on it. Ensure we keep a valid pointer to
the next element in the list before removing the current one.
2023-02-17 10:43:20 +00:00
som
d1ed6114a8 broadband-modem-mbim: cell-info core logic implementation
Handling of gdbus interface changes for additional
properties(service cell type and bandwidth) in
broadband modem mbim.

Co-author: Shilpa Shivakumar
2023-02-17 10:43:20 +00:00
Michal Mazur
6f00fb867b iface-modem-3gpp: enable reading of IMEI in FAILED state
It was not possible to read IMEI of modem when SIM was not inserted or
initialization failed due to modem facility locks. To load IMEI, the
3gpp interface need to be initialized before going to FALLBACK_LIMITED.
2023-02-15 15:00:41 +00:00
Akash Aggarwal
02d730604d mm-broadband-modem-qmi: update signal values while processing NAS signal info indication 2023-02-06 23:38:02 +05:30
Eric Caruso
e31c43ebd2 mm-iface-modem-3gpp: reject unspecified values for 5G reg settings
It seems like users can put the "unsupported" value for
both DRX cycle and MICO mode, so we should reject that.
2023-02-03 21:09:36 +00:00
Oliver Kästner
652a562aeb qmi: implement GetCellInfo for LTE, NR 2023-02-03 10:23:44 +00:00
Daniele Palmas
6748fb7c2c telit: fallback to AT commands in case of MBIM loading revision failure
Some firmware versions return an empty string for the revision when
using the device caps MBIM request, so use AT commands as a fallback
in case this happens.
2023-01-30 16:00:45 +01:00
Daniele Palmas
a9e841e931 telit: increase initial delay for AT ports
FN990 requires more time for the AT ports to become responsive,
so increase the initial delay up to 40 seconds.
2023-01-30 16:00:45 +01:00
Daniele Palmas
6632136990 telit: add port type hints for FN990 0x1070, 0x1071 compositions 2023-01-30 16:00:45 +01:00
Daniele Palmas
2c235260e4 telit: add shared support for 5G modes 2023-01-30 16:00:45 +01:00
Louis-Alexis Eyraud
6006dd1d63 broadband-modem-qmi: don't fail on power indication registration error
This commit modifies the QMI DMS Operating Mode indication registration logic.
During the power sequence chance, if a QMI_PROTOCOL_ERROR_MISSING_ARGUMENT error
was returned in "DMS Set Event Report" operation for Operating Mode Reporting failed,
the whole sequence was aborted, leading the modem to be disabled.

<debug> [modem0] Power indication registration request is sent
...
<debug> [modem0] couldn't update power state: Couldn't register for power indications: QMI protocol error (17): 'MissingArgument'
<warn>  [modem0] couldn't enable interface: 'Couldn't register for power indications: QMI protocol error (17): 'MissingArgument''
<debug> [modem0] running implicit disable after failed enable...

This commit modifies the logic to properly detect the failure and
continue the sequence without the indications.

Fixes #683

Signed-off-by: Louis-Alexis Eyraud <louis-alexis.eyraud@unabiz.com>
2023-01-23 14:49:33 +00:00
Lubomir Rintel
3a1cc27f2e bearer-qmi: fix a mnc/mcc typo
Makes my compiler unhappy:

  [471/539] Compiling C object src/ModemManager.p/mm-bearer-qmi.c.o
  ../src/mm-bearer-qmi.c: In function ‘process_operator_reserved_pco’:
  ../src/mm-bearer-qmi.c:580:18: warning: logical ‘and’ of equal expressions [-Wlogical-op]
    580 |     if (!tmp_mcc && !tmp_mcc && !container_id && !array->len)
        |                  ^~

Fixes: f4b8d14b8d ('bearer-qmi: explicitly ignore PCOs with undefined contents:')
2023-01-20 15:05:50 +01:00
Ulrich Mohr
5ed79518be broadband-modem-mbim,qmi-shared: Fallback from qmi uim service only when not supported
When using qmi uim service from mbim broadband modem, a fallback from using
qmi uim service to normal mbim operations is done every time a call to
qmi_set_primary_sim_slot fails. But this may fall for various reasons,
and a fallback only makes sense when the device does not support that call

Patch reworked by Aleksander Morgado <aleksandermj@chromium.org>
2023-01-18 11:14:14 +00:00
Michal Mazur
7750e927f6 broadband-modem-mbim: Sync state of sim_hot_swap_configured variable 2023-01-18 10:15:43 +00:00
Michal Mazur
68e92d9308 broadband-modem-mbim: Fix bug in cleanup_unsolicited_events_3gpp() 2023-01-18 10:15:43 +00:00
Aleksander Morgado
f4b8d14b8d bearer-qmi: explicitly ignore PCOs with undefined contents:
There is nothing to process in this kind of PCO fields:

  <<<<<< TLV:
  <<<<<<   type       = "Operator Reserved PCO" (0x2f)
  <<<<<<   length     = 8
  <<<<<<   value      = 00:00:00:00:00:00:00:00
  <<<<<<   translated = [ mcc = '0' mnc = '0' mnc_includes_pcs_digit = 'no' app_specific_info = '{}' container_id = '0' ]

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/690
2023-01-16 15:05:29 +00:00
Aleksander Morgado
cf59b497bc bearer-qmi: app specific info in PCO may be empty
ModemManager[562783]: <err> [1673538458.350130] mm_utils_bin2hexstr: assertion 'bin != NULL' failed
  ModemManager[562783]: <dbg> [1673538458.350167] [modem0/bearer0] container ID: 0
  ModemManager[562783]: <dbg> [1673538458.350201] [modem0/bearer0] app specific info: (null)

Treat it better by only trying to build the app specific info string
if there are contents in the array.
2023-01-16 15:05:21 +00:00
Daniele Palmas
34ba11b3fa bearer-qmi: fix pco array declaration 2023-01-12 17:03:58 +01:00
Michal Mazur
d7e599f13f sim-mbim: Reset cached SIM info when SIM is unlocked
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/684
2023-01-11 10:30:33 +00:00
Aleksander Morgado
cc78a6439f broadband-modem-qmi: ignore our own profile changed indications
The device may emit a "WDS Profile Changed" indication triggered from
our own "WDS Modify Profile", "WDS Create Profile" or "WDS Delete
Profile" operations, so ensure those are fully ignored so that we
don't emit the "Updated" signal in the ProfileManager interface.

The logic keeps track of the amount of concurrent operations so that
the signal is ignored for as long as there is at least one operation
running.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/687
2023-01-11 08:43:27 +00:00
Aleksander Morgado
e3667ecb56 build: fix dependency on daemon enums required by plugins
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/686
2023-01-10 14:13:34 +00:00
Aleksander Morgado
1c4da332ee build: new option to build plugins within the daemon binary
Instead of creating libmm-plugin* and libmm-shared* libraries that are
dlopen()-ed on runtime, allow incorporating all plugins into the
daemon binary itself.

This makes the startup of the daemon much faster and also avoids
issues with builds that require linker namespace isolation.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/674
2023-01-03 13:56:25 +00:00
Aleksander Morgado
1dd70be4c8 plugins: setup new helper macros to define shared utils 2023-01-03 13:56:25 +00:00
Aleksander Morgado
f0a9f09558 plugins: setup new helper macros to define plugins
We also remove the plugin headers completely as they are not really
required anywhere.
2023-01-03 13:56:25 +00:00
Aleksander Morgado
d30ba8414a plugin-manager: don't crash when loading an invalid shared utils library
<wrn> [plugin-manager] could not load shared '/usr/lib/ModemManager/libmm-shared-xmm.so': Missing major version info
  Thread 1 "ModemManager" received signal SIGSEGV, Segmentation fault.
  0x000055555562b79d in load_external_shared (path=<optimized out>, self=0x5555557b5880) at ../src/mm-plugin-manager.c:1885
  1885        if (module && !(*shared_name))
  (gdb) p module
  $1 = (GModule *) 0x5555557b9670
  (gdb) p shared_name
  $2 = (const gchar **) 0x0
2023-01-03 13:56:25 +00:00
Aleksander Morgado
876e8537c4 plugins: don't include daemon enums sources 2023-01-03 13:56:25 +00:00
Aleksander Morgado
cc90f2ffe8 build: compile plugins before daemon 2023-01-03 13:56:25 +00:00
Aleksander Morgado
f562a51afb build: fix missing module name in shared option utils 2023-01-03 13:56:25 +00:00
Aleksander Morgado
e14b904cbd build: move plugins directory to src/plugins
We are going to allow including the plugin sources built within the
ModemManager daemon binary; moving the sources within the daemon
sources directory makes it easier.
2023-01-03 13:56:25 +00:00
Aleksander Morgado
072d7ac906 log: avoid redefining MM_MODULE_NAME 2023-01-03 13:56:25 +00:00
Aleksander Morgado
a5058eb799 base-modem: don't assume ports tables always exist
The 'link_ports' and 'ports' tables are created during object init(),
but they are fully removed and cleared during dispose(). Given that
the MMDevice executes an explicit g_object_run_dispose(), there may be
cases where a long-running operation that isn't cancelled ends up
being completed by the time the object disposal has already run at
least once.

That would end up crashing the process if we attempt to e.g. iterate
over one of the ports hash tables:

  0x00007c3594eb3b93 (libglib-2.0.so.0 - ghash.c: 1180)   g_hash_table_iter_next
  0x00005b60d86f2563 (ModemManager - mm-base-modem.c: 1133)       mm_base_modem_get_port_infos
  0x00005b60d870228e (ModemManager - mm-iface-modem.c: 4013)      fcc_unlock
  0x00007c35950126a8 (libgio-2.0.so.0 - gtask.c: 1230)    g_task_return_now
  0x00007c35950116fa (libgio-2.0.so.0 - gtask.c: 1300)    g_task_return
  0x00007c3595011d12 (libgio-2.0.so.0 - gtask.c: 1930)    g_task_return_new_error
  0x00005b60d87518f2 (ModemManager - mm-broadband-modem-mbim.c: 1970)     radio_state_set_up_ready
  0x00007c35950126a8 (libgio-2.0.so.0 - gtask.c: 1230)    g_task_return_now
  0x00007c35950116fa (libgio-2.0.so.0 - gtask.c: 1300)    g_task_return
  0x00007c35950c486c (libmbim-glib.so.4 - mbim-device.c: 253)     transaction_task_complete_and_free
  0x00007c35950c714b (libmbim-glib.so.4 - mbim-device.c: 335)     transaction_timed_out
  0x00007c3594ec1232 (libglib-2.0.so.0 - gmain.c: 4971)   g_timeout_dispatch
  0x00007c3594ec43fc (libglib-2.0.so.0 - gmain.c: 3417)   g_main_context_dispatch
  0x00007c3594ec4704 (libglib-2.0.so.0 - gmain.c: 4211)   g_main_context_iterate
  0x00007c3594ec4978 (libglib-2.0.so.0 - gmain.c: 4411)   g_main_loop_run
  0x00005b60d86d7c56 (ModemManager - main.c: 217) main
  0x00007c3594c526c5 (libc.so.6 + 0x000286c5)     __libc_init_first
  0x00007c3594c52781 (libc.so.6 + 0x00028781)     __libc_start_main
  0x00005b60d86d7970 (ModemManager + 0x00061970)  _start

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

Change-Id: I6695c284f86a196e60de7f714bc1671332d08848
2022-12-20 20:53:58 +00:00
Aleksander Morgado
c7dac25315 port-mbim: chain up device notifications through the port
Instead of having the modem object listen notifications in the
MbimDevice, the MMPortMbim will act as an intermediate emitter for the
same.

The primary benefit is that the lifecycle of the port object is
tightly coupled to the life of the modem object, so there is no chance
that the port object outlives the modem object.

And the port object will ensure its own device notification handler is
correctly cleared up on its dispose, so there should be no chance of
firing up a signal in the device for a listener that is already
freed.
2022-12-18 21:55:21 +00:00
Aleksander Morgado
309a8a515b port-mbim: implement the new generic 'removed' signal
Letting the MMBroadbandModemMbim listen for the notifications of the
MbimDevice was not a good idea, especially since no explicit reference
to the device object was hold in the modem object. This leads to race
conditions in which the MbimDevice outlives the MMBroadbandModemMbim and
the MMPortMbim, and when the "device-removed" signal is triggered, the
program crashes.

The MMPortMbim will now emit its own 'removed' signals when the
underlying MbimDevice emits "device-removed', ensuring that the signal
handler is properly cleared up during the MMPortMbim disposal.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/518
2022-12-18 21:54:58 +00:00
Aleksander Morgado
a20f2428ee port-qmi: implement the new generic 'removed' signal
Letting the MMBroadbandModemQmi listen for the notifications of the
QmiDevice was not a good idea, especially since no explicit reference
to the device object was hold in the modem object. This leads to race
conditions in which the QmiDevice outlives the MMBroadbandModemQmi and
the MMPortQmi, and when the "device-removed" signal is triggered, the
program crashes.

The MMPortQmi will now emit its own 'removed' signals when the
underlying QmiDevice emits "device-removed', ensuring that the signal
handler is properly cleared up during the MMPortQmi disposal.
2022-12-18 21:52:51 +00:00
Aleksander Morgado
455c486091 port: define new generic 'removed' signal
This signal indicates that the port is no longer accessible. Unlike a
udev port removal event, this indication may happen even if the port
is still exposed by the system.

It is designed to detect protocol proxy crashes, and so when such
event is detected by the modem, a full reprobe of the device will be
done to start from scratch the protocol management operations.
2022-12-18 21:52:51 +00:00
Sven Schwermer
e96ea83f61 iface-modem-3gpp: Check before registering
If the modem is already registered when ModemManager probes the modem,
it will ignore the registration state since the modem is not enabled
yet. Always querying the registration state before starting the
registration procedure makes sure to catch such cases and not perform
unnecessary registration steps.

Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com>
2022-12-06 14:03:47 +00:00
Aleksander Morgado
0d6651aeb6 broadband-modem-mbim: print MbimSmsStatusFlag as flags string
This requires bumping libmbim to 1.29.2, which is the version
including the enum->flags change.
2022-12-06 12:46:28 +00:00