Commit Graph

146 Commits

Author SHA1 Message Date
Aleksander Morgado
4b058872a0 plugins: don't add plugin name in log message explicitly 2020-04-08 17:53:42 +02:00
Aleksander Morgado
8722215f7e plugins: use logging module name as plugin name 2020-04-08 17:53:42 +02:00
Aleksander Morgado
e956bac47b log: common logging method definition for all testers and helpers 2020-04-08 17:53:42 +02:00
Aleksander Morgado
d15da9cf60 sierra: port to use object logging 2020-04-08 16:35:10 +02:00
Aleksander Morgado
0f708daf0b modem-helpers: port supported modes filtering to use object logging 2020-04-08 16:35:09 +02:00
Aleksander Morgado
9bcadea172 log: new object logging support
So that we can provide the specific object id in every log associated
to a given object.
2020-04-08 16:35:08 +02:00
Aleksander Morgado
accd1a5841 base-modem: define new helper MMBaseModemAtCommandAlloc
It has the same exact format as MMBaseModemAtCommand, but its contents
are assumed heap allocated.

The only real purpose of this type is to allow defining static
constant MMBaseModemAtCommand variables without warnings when using
-Wdiscarded-qualifiers.
2020-01-31 15:18:35 +01:00
Aleksander Morgado
b8a8b772b4 sierra: remove unused cdma_manual_activation_context_free() 2020-01-31 14:52:49 +01:00
Aleksander Morgado
54a6e9fc85 sierra: fix warnings with -Wdiscarded-qualifiers
sierra/mm-broadband-modem-sierra.c:1815:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1815 |     { "!TIME?", 3, FALSE, parse_time_reply },    /* 3GPP */
        |       ^~~~~~~~
  sierra/mm-broadband-modem-sierra.c:1816:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1816 |     { "!SYSTIME?", 3, FALSE, parse_time_reply }, /* CDMA */
        |       ^~~~~~~~~~~
2020-01-31 14:52:49 +01:00
Aleksander Morgado
4a74ae07bc sierra: fix warnings with -Wimplicit-fallthrough
sierra/mm-broadband-bearer-sierra.c: In function ‘dial_3gpp_context_step’:
  sierra/mm-broadband-bearer-sierra.c:304:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    304 |         ctx->step++;
        |         ~~~~~~~~~^~
  sierra/mm-broadband-bearer-sierra.c:306:5: note: here
    306 |     case DIAL_3GPP_STEP_PS_ATTACH:
        |     ^~~~
  sierra/mm-broadband-bearer-sierra.c:398:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    398 |         ctx->step++;
        |         ~~~~~~~~~^~
2020-01-31 14:52:49 +01:00
Aleksander Morgado
8e216b30a6 sierra: fix warnings with -Wswitch-enum
sierra/mm-broadband-modem-sierra.c: In function ‘modem_time_load_network_time’:
  sierra/mm-broadband-modem-sierra.c:1733:5: error: enumeration value ‘TIME_METHOD_UNKNOWN’ not handled in switch [-Werror=switch-enum]
   1733 |     switch (MM_BROADBAND_MODEM_SIERRA (self)->priv->time_method) {
        |     ^~~~~~
2020-01-31 14:52:49 +01:00
Aleksander Morgado
e71819fcfe sierra: fix warnings with -Wswitch-default 2020-01-31 14:52:49 +01:00
Aleksander Morgado
32d1f1deda sierra: implement manual CDMA activation 2019-12-03 08:43:40 +00:00
Aleksander Morgado
af08492209 sierra: implement automatic CDMA activation 2019-12-03 08:43:39 +00:00
Aleksander Morgado
23df25f25c sierra: setup as loadable 'shared' utils 2019-11-27 10:11:43 +00:00
Amol Lad
8f4b5b52ee sierra: add port hints for EM7565 modem 2019-11-19 16:01:41 +05:30
Aleksander Morgado
d5d0ed0b24 tests: print MM logs only on verbose test mode
Therefore, avoid needing ENABLE_TEST_MESSAGE_TRACES build symbol.
2019-10-14 15:30:27 +02:00
Aleksander Morgado
b0ec3030a3 sierra: add port type hints for the MC74xx modules
As suggested by Paul Bartell <paul.bartell@gmail.com>
2019-08-26 09:07:38 +02:00
Ben Chan
beb1aab178 sierra: remove unused 'self' variable in scact_periodic_query_ready() 2018-10-22 11:23:29 +02:00
Ben Chan
7de6b6f2e1 core: remove unnecessary NULL checks for g_match_info_free()
g_match_info_free() already check if the given pointer is NULL and does
nothing on a NULL pointer.
2018-10-18 13:17:36 +02:00
Aleksander Morgado
fa67a4f9bb sierra-legacy: implement connection status monitoring with !SCACT?
Devices like the Netgear AC313U require explicit context monitoring,
otherwise the device may end up disconnected internally and MM would
still think that the connection is ongoing.
2018-10-09 14:34:59 +00:00
Aleksander Morgado
c07382a486 udev: add tags also on bind action
When a new USB device is hotplugged, e.g. a USB<->RS232 converter that
exposes a single ttyUSB0, these udev events happen:

  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb/usb-device)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb/usb-interface)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0 (usb-serial)
  add  /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0/tty/ttyUSB0 (tty)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/ttyUSB0 (usb-serial)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0 (usb/usb-interface)
  bind /devices/pci0000:00/0000:00:14.0/usb2/2-1 (usb/usb-device)

Our udev rules in MM only added tags in the 'add' events, and it looks
like the only ones 'persistent' after this sequence are those of the
last event happening on the specific path.

This meant that all TTY subsystem rules (e.g. ID_MM_CANDIDATE) would
be stored for later check (e.g. if ModemManager is started after these
rules have been applied), which was ok. "udevadm info -p ..." would
show these tags correctly always.

But this also meant that the 'bind' udev event happening for the USB
device didn't get any of our device-specific tags, and so we would be
missing them (e.g. ID_MM_DEVICE_MANUAL_SCAN_ONLY) if MM is started
after the last event has happened. "udevadm info -p ..." would
not show these tags.

Modify all our rules to also run at the 'bind' events.

See, for context:
  https://github.com/systemd/systemd/issues/8221
2018-06-02 16:54:37 +02:00
Aleksander Morgado
291300cfcb sierra: enable QMI connection status polling in Netgear AC341U
The Netgear AC341U seems to delay reporting packet service status
indications or actually not even send them. This leaves us with modems
in connected state in ModemManager but actually disconnected. We can
detect this situation by actively polling ourselves the connection
status.

See e.g. this case where the indication is received 2.5 mins after the
first OutOfCall error detected when loading statistics.

    Aug 30 22:52:50 ModemManager[574]: <info>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connecting -> connected)
    Aug 30 22:52:50 ModemManager[574]: <info>  Simple connect state (8/8): All done
    Aug 30 22:52:50 ModemManager[574]: <warn>  Reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
    Aug 30 22:53:20 ModemManager[574]: <warn>  Reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
    Aug 30 22:53:50 ModemManager[574]: <warn>  Reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
    Aug 30 22:54:20 ModemManager[574]: <warn>  Reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
    Aug 30 22:56:21 ModemManager[574]: <info>  bearer call end reason (2): 'generic-client-end'
    Aug 30 22:56:21 ModemManager[574]: <info>  bearer verbose call end reason (3,2000): [cm] client-end
    Aug 30 22:56:21 ModemManager[574]: <info>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connected -> registered)
2017-11-23 14:20:39 +01:00
Aleksander Morgado
f710278b3d sierra: remove unneeded explicit casts 2017-09-18 21:21:59 -07:00
Aleksander Morgado
fd508d7057 sierra: skip setting GError if not used
The return status of mm_base_modem_at_command_finish() already
specifies whether an error has happened or not, so skip creating the
GError if we don't care about the actual error details.
2017-09-18 20:50:45 -07:00
Ben Chan
4fbd88395d sierra: port get_detailed_registration_state to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
7ca5e8875a sierra: port modem_time_check_support to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
509ba7475a sierra: port setup_registration_checks to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
26be99b8a7 sierra: port modem_power_down to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
841d175961 sierra: port modem_create_bearer to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
7446e411c7 sierra: port modem_load_own_numbers to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
85915853e5 sierra: port modem_after_sim_unlock to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
228bd14a11 sierra: port set_current_modes to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
5dbf7f77e2 sierra: port load_current_modes to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
abff4adf62 sierra: port load_supported_modes to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
8f129d64ed sierra: port load_access_technologies to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
f663022aca sierra: port modem_create_bearer to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
d0dc8b97a7 sierra: port disconnect_3gpp to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
4c2ebaba16 sierra: port dial_3gpp to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
043645ea57 sierra: port mm_common_sierra_load_power_state to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
1eb51d96f7 sierra: port mm_common_sierra_modem_power_up to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
c401646db8 sierra: port mm_common_sierra_custom_init to use GTask 2017-09-18 20:39:03 -07:00
Ben Chan
8fb6f30f49 sierra: port load_sim_identifier to use GTask 2017-09-18 20:39:03 -07:00
Aleksander Morgado
2eb55d3224 plugins: use G_N_ELEMENTS when iterating ports array 2017-05-30 17:28:23 +02:00
Ben Chan
254f2e3412 plugins: remove explicit GDestroyNotify cast on g_free / g_object_unref
g_free and g_object_unref are in form of  `void (*)(gpointer)`, which
matches the GDestroyNotify signature. An explicit GDestroyNotify cast on
g_free and g_object_unref is thus not needed.
2017-03-29 10:22:18 +02:00
Aleksander Morgado
37bd614212 broadband-modem: implement default connection monitoring logic
A default implementation to monitor the ongoing connection is provided in the
generic MMBroadbandModem, based on AT+CGACT? to check whether the PDP context
of the connection (identified by the cached cid) is active or not.

This commit also disables the connection monitoring logic in those plugins that
have custom connection methods.
2016-10-12 11:29:52 +02: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
1f813c4e96 core: allow identifying devices by a user-provided 'uid'
All ports of the same modem reported by the kernel will all be associated with
a common 'uid' (unique id), which uniquely identifies the physical device. This
logic was already in place, what we do now is avoid calling it  the 'sysfs
path' of the physical device, because we may not want to use that to identify
a device.

This logic now also enables the possibility of "naming" the modems in a unique
way by setting the "ID_MM_PHYSDEV_UID" property in the "usb_device" that owns
all the ports.

E.g. a custom device has 4 modems in 4 different USB ports. The device path of
each USB device will always be the same, so the naming rules could go like this:

    $ vim /usr/lib/udev/rules.d/78-mm-naming.rules

    ACTION!="add|change|move", GOTO="mm_naming_rules_end"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.1", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-1"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.2", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-2"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.3", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-3"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.4", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-4"
    LABEL="mm_naming_rules_end"

Each of the modems found will have a unique UID retrieved from the previous list
of rules. Then, "mmcli" has also been updated to allow using the UID instead of
the modem DBus path or index, e.g.:

    $ sudo mmcli -m USB-MODEM-1
    /org/freedesktop/ModemManager1/Modem/0 (device id '988d83252c0598f670c2d69d5f41e077204a92fd')
      -------------------------
      Hardware |   manufacturer: 'ZTE CORPORATION'
               |          model: 'MF637'
               |       revision: 'BD_W7P673A3F3V1.0.0B04'
               |      supported: 'gsm-umts'
               |        current: 'gsm-umts'
               |   equipment id: '356516027657837'
      -------------------------
      System   |         device: 'USB-MODEM-1'
               |        drivers: 'option'
               |         plugin: 'ZTE'
               |   primary port: 'ttyUSB5'
               |          ports: 'ttyUSB5 (at)'
    ...

    $ sudo mmcli -m USB-MODEM-1 --enable
    ...
2016-09-29 15:41:21 +02:00
Ting-Yuan Huang
969189d42c plugin-manager: protect mm_plugin_{major,minor}_version
This patch makes declarations bind to definitions within the same module
to prevent the potential ambiguity if referenced directly.

AddressSanitizer think they violated one definition rule, although
those symbols are accessed by address through their modules and do
not depend on the order of the libararies loaded.
2016-05-28 13:59:54 +02:00
Aleksander Morgado
ffde429843 core: use G_SOURCE_REMOVE and G_SOURCE_CONTINUE in GSourceFuncs 2015-12-02 17:07:39 +01:00