Commit Graph
80 Commits
Author SHA1 Message Date
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
Dan Williams 6b25476dbb base-modem: allow port teardown operation to use callbacks if needed
Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-07 22:54:13 -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
Sushrut Shree Trivedi 092439369b base-modem: add subsystem device ID property
Subsystem device ID can be used for identifying PCI modems,
so expose the property.

Signed-off-by: Sushrut Shree Trivedi <quic_sushruts@quicinc.com>
2025-02-21 10:39:29 +05:30
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 0aef4c422f base-modem: new 'override' operation lock type
If a request to lock the operation with the override type arrives, all
pending operations will be immediately cancelled, and no new lock
requests will be allowed.
2024-09-30 11:07:05 +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 a24a6ee4c5 base-modem: add setup to allow exclusive operations
There are certain operations that cannot be run in parallel, e.g. one
should not disable and bring the modem to low power mode while there
are also incoming requests to enable the modem. This type of errors
will typically happen when multiple DBus clients are trying to use the
same modem at the same time for different purposes.

We do not have any way to have DBus clients take exclusive ownership
of a given modem object, so the best we can do for now is trying to
synchronize operations that cannot be run together, preserving the
order in which they arrived, and running them one by one.
2024-09-30 07:54:56 +00:00
Aleksander Morgado 0d11ff8566 base-modem: allow subclassing tty/usbmisc/wwan port creation
So that plugins can provide their own implementations as needed.
2024-04-23 07:25:12 +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 3870f774bf base-modem: remove unused has_at_port() method 2024-04-09 07:28:57 +00:00
Aleksander Morgado 7990499602 base-modem: minor alignment fix 2023-09-27 10:24:58 +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
Lubomir Rintel f0a77a2292 base-modem: remove mm_base_modem_get_cancellable()
No users left for the getter that takes a reference after a port of
MMBaseModemAT to GTask.

peek_cancellable() is used instead, because the GTask constructor
takes a reference itself.
2023-04-11 13:49:03 +00:00
Rukun Mao 3da84c2079 suspend: add suspend/resume support with powerd on ChromeOS
ModemManager handles suspend and resume signals sent from powerd

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/547
2022-06-09 08:32:13 +00:00
Daniele Palmas 654c5f5014 base-modem: add subsystem vendor ID property
Subsystem vendor ID can be used for identifying PCI modems,
so expose the property.
2022-05-24 09:22:06 +02:00
Aleksander Morgado b497de325a iface-modem: common SIM event reporting logic
We no longer have separate mm_base_modem_process_sim_event() and
mm_broadband_modem_sim_hot_swap_detected() methods. The only
difference between both of them was that one of them would attempt to
cleanup the ports context associated to the SIM hot swap event logic
as soon as a swap was detected, in order to avoid queueing up multiple
such events.

The previous logic wasn't working well, though, as there could be
mixed AT+QMI or AT+MBIM devices that would also require that same
cleanup and so we didn't always know which one should have been
called.

Now we have a single mm_iface_modem_process_sim_event() method, which
will trigger the reprobe and disabling, but which will also perform
the cleanup of the SIM ports swap setup as specified by the
implementation.

So, if a plugin explicitly initializes the serial ports context for
SIM hot swap handling, it should also explicitly clean it up.

Also, the initialization of the serial ports context for SIM hot swap
handling is no longer done automatically for all modems, it will be
done only for those modems using it; i.e. the modems that explicitly
report support SIM hot swap handling using AT URCs.
2022-05-20 09:03:54 +00:00
Aleksander Morgado eaf14b8d79 base-modem: make sync() available only if suspend-resume enabled 2021-05-26 13:14:52 +00:00
Dylan Van Assche 38740e9d11 base-manager: add quick suspend/resume base
Quick suspend/resume infrastructure for
synchronizing the interfaces when resuming.
2021-05-26 13:14:52 +00:00
Aleksander Morgado b3fb87cdf6 base-modem: new method to wait for an explicit link port
When new link ports are created, the QmiDevice link management methods
try to make sure that the port exists in the system by the time the
link addition method returns, but that doesn't guarantee that the port
has also been notified by the kernel to ModemManager (e.g. via udev or
via kernel events).

This new method allows to do a explicit wait for a given port link; if
we already have it it will return right away, and otherwise we'll wait
for it to be notified via the "link port grabbed" signal.
2021-03-10 12:58:12 +01:00
Aleksander Morgado 897e48709d base-modem: allow grabbing link ports after modem is created
We will grab the ports and make them available through find_ports() or
peek_port() or get_port().

The link ports are not 'organized' so they won't be available in
e.g. get_data_ports(), which is fine, because we don't want to mix
them with the real data ports exposed by the device.

Link port additions and removals are also notified via signals in the
modem object, so that explicit wait for specific ports can be done.
2021-03-10 12:58:12 +01:00
Aleksander Morgado 032a86915a port-net: new 'MMPortNet' object with netlink capabilities
Right now just with the support to setup link properties like up/down
state or the link mtu.

This features are required when using QMAP based multiplexing with the
qmi_wwan kernel driver.
2021-03-10 10:59:22 +01:00
Aleksander Morgado 5d176a1e61 base-modem: explicitly say if NET or TTY data ports are supported
A modem that creates exclusively bearer objects that work with NET
ports (e.g. all QMI or MBIM modems) must not add any TTY port in the
list of data ports.

A modem that creates exclusively bearer objects that work with TTY
ports (e.g. the generic modem) must not add any NET port in the
list of data ports.

A modem that may use both TTY and NET ports should add all in the list
of data ports.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/324
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/329
2021-03-04 18:03:28 +01:00
Aleksander Morgado 381e2f382b base-modem: separate method to lookup exact port by name
There's no point in returning a list of all ports with a given name,
just provide a lookup method that returns the single port with the
given name.
2021-02-25 14:13:03 +01: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
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 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 00949c4ad3 core: add autoptr cleanup methods to all internal types 2020-09-19 20:27:10 +02:00
Aleksander Morgado e20eebff47 base-modem: SIM switch handling at base modem level
When the SIM switch doesn't happen as part of an async hot swap
detection, we should trigger the switch handling at base modem level,
which e.g. doesn't require explicit cleanup of the SIM hot swap
detection port context.
2020-08-28 14:59:06 +00:00
Aleksander Morgado 9e50dda400 base-modem: set dbus id as soon as object is created 2020-04-08 16:35:08 +02:00
Aleksander Morgado 20ab6550fb auth-provider: refactor and simplify
The auth provider setup is a bit over-engineered. Simplify it by
making a single MMAuthProvider object that may or may not use polkit,
depending on configure options. This object is also setup as a
singleton object using the helper MM_DEFINE_SINGLETON_GETTER().
2020-01-23 11:50:23 +00: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
Aleksander Morgado ef50c085f9 base-modem,cinterion: no need for a peek_current_data_port() method
We already get the data port given as input parameter in
disconnect_3gpp(), so there is no point in trying to find out which the
data port is.
2017-01-04 14:11:17 +01:00
Matthew Stanger 1ffcb16349 cinterion: implement support for the new SWWAN interface 2017-01-04 14:11:17 +01:00
Aleksander Morgado ae9ede926a core: use the kernel device object in the port object and the plugin interface
The mm_base_modem_grab_port() now receives a MMKernelDevice directly from the
plugin, which is then stored in the MMPort corresponding to the port.

This means that we have direct access to e.g. all properties set by udev rules
everywhere, and we don't need additional GUdevClient objects (e.g. like the one
used in the Huawei plugin to detect NDISDUP support during runtime).

For virtual ports (e.g. generated during unit tests), we have a new 'generic'
kernel device object which just provides the values from the kernel device
properties given during its creation.
2016-09-29 15:43:05 +02:00
Aleksander Morgado dd98454a7d base-modem: add missing 'reprobe' property setup
The sim hotswap logic likely just uses the getter/setter methods, but we should
anyway fix the property definition bits.
2016-09-22 19:59:10 +02:00
Carlo Lobrano 60f4f9e57d modem: support SIM hot swap
BaseModem
  added reprobe property.

MMDevice
  added logic to recreate the modem if it is set invalid and "to reprobe"

MMBroadbandModem
 * added initialization step for SIM hot swap:
    1. keep dedicated ports open to listen to modem's unsolicited
    2. dedicated error management in case of initialization failure due to SIM missing
 * added function to be called in order to act upon SIM insertion/removal:
    1. close dedicated ports
    2. set the modem to be reprobed
    3. disable modem
 * added SIM HOT SWAP boolean property

MMIfaceModem
 * added initialization step for SIM hot swap, if supported by the plugin
 * dedicated error management in case of initialization failure due to SIM missing
2016-08-10 09:39:27 +02:00
Aleksander Morgado 6ba37aa041 base-modem: remove unused 'mm_base_modem_get_port()' method 2016-03-27 18:52:39 +02:00
Aleksander Morgado 1583452554 base-modem: remove unused 'mm_base_modem_owns_port()' method 2016-03-27 18:52:35 +02:00
Aleksander Morgado 547b9b9d87 base-modem: remove unused 'mm_base_modem_release_port()' method 2016-03-27 18:51:45 +02:00
Aleksander Morgado 7c347aa3ec port: store parent sysfs path in each MMPort 2014-06-23 18:12:27 +02:00
Aleksander Morgado 0d0f5de161 base-modem: allow looking for a subset of the available ports 2014-02-13 13:41:03 +01:00
Aleksander Morgado c236e18692 ports: rename 'MMMbimPort' to 'MMPortMbim' 2014-02-13 13:40:07 +01:00
Aleksander Morgado 403e013f15 ports: rename 'MMQmiPort' to 'MMPortQmi' 2014-02-13 13:40:04 +01:00
Aleksander Morgado 6f235b9948 ports: rename 'MMAtSerialPort' to 'MMPortSerialAt' 2014-02-13 13:40:01 +01:00
Aleksander Morgado 0d1602bf0f ports: rename 'MMQcdmSerialPort' to 'MMPortSerialQcdm' 2014-02-13 13:39:57 +01:00
Aleksander Morgado e505ea0a58 ports: rename 'MMGpsSerialPort' to 'MMPortSerialGps' 2014-02-13 13:39:54 +01:00
Aleksander Morgado 3206e95663 api,introspection: new 'Ports' property in the Modem interface
We will expose a new 'Ports' property listing all ports currently known by a
given modem. Ports which are not used but are detected as being part of the
modem will be listed with an 'unknown' port type.

This change uses the new 'MMModemPortType' enum and the new 'MMModemPortInfo'
helper struct to handle these values in libmm-glib. The already available
'MMPortType' enum hasn't been re-used for the interface because it contains
values that we don't need (e.g. IGNORED).

The port list is now also included in the modem information command of mmcli:

$ sudo mmcli -m 0

/org/freedesktop/ModemManager1/Modem/0 (device id '97b7b99e3e2bea103880545b619fb05a3cc81b26')
  -------------------------
  System   |         device: '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4'
           |        drivers: 'qcserial, qmi_wwan'
           |         plugin: 'Gobi'
           |   primary port: 'cdc-wdm0'
           |          ports: 'ttyUSB0 (qcdm), ttyUSB1 (at), cdc-wdm0 (qmi), wwp0s29u1u4 (net)'

https://bugzilla.gnome.org/show_bug.cgi?id=702678
2013-06-24 19:44:57 +02:00
Aleksander Morgado a0ced36f14 base-modem: allow grabbing MBIM ports 2013-04-17 15:19:37 +02:00
Aleksander Morgado b6402a4e21 bearer,3gpp: dial operation specifies which data port to use
Instead of deciding in advance which data port to use, we let the dialling
operation gather it. For the generic dialling logic, ATD-based, always an
'AT' port will be used as data port, even if we grabbed a 'net' port. Those
plugins that can work with 'net' ports will grab the specific 'net' port
themselves.
2013-02-18 15:41:26 +01:00