Commit Graph

52 Commits

Author SHA1 Message Date
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
Daniele Palmas
6de2d84af1 telit: support QMI and MBIM modems
Vendor specific plugins that support QMI or MBIM based devices need to
handle the creation of these modems themselves.

https://bugs.freedesktop.org/show_bug.cgi?id=100372

Original patch by Aleksander Morgado.
2017-03-28 11:06:55 +02:00
Aleksander Morgado
4c164287eb telit: don't require udev tags to bind devices
The vendor id/string based rules should already be enough to get the
telit plugin bind telit devices.

This simplifies support for future Telit devices, as we wouldn't need
any additional change in the plugin. It also helps when working with
RS232 devices as the user wouldn't need to add the explicit tag to get
the devices bound to this plugin.

https://bugs.freedesktop.org/show_bug.cgi?id=100373
2017-03-24 21:57:12 +01:00
Aleksander Morgado
00fb9e98f6 kernel-device: device-specific properties in either port or physdev
There are 2 main types of udev properties: device-specific and
port-specific.

The port-specific properties are set independently per port (e.g. port
type hints set per interface number for a given vid:pid).

The device-specific properties apply to all ports in the device. Some
of these properties are currently expected in the physical device
(e.g. ID_MM_PLATFORM_DRIVER_PROBE) while some others are expected in
each port (e.g. the plugin udev tag filters).

This patch tries to simplify the logic and just assume that the device
specific tags may be given in either the physical device or the port
device, by providing separate APIs to retrieve port-specific or
device-specific (global) properties. If the same tag is given in both
the device and the port, the one in the device takes preference.

For the generic backend, these new APIs are really useless, as all
device-specific and port-specific properties are always stored in the
port object themselves (there is no 'tree' of devices in the generic
backend, no 'physdev' device).

For the udev backend, though, there really is a difference, as the
tags may be set in port or device.

https://bugs.freedesktop.org/show_bug.cgi?id=100156
2017-03-22 09:40:10 +01:00
Aleksander Morgado
9384817a14 telit: lock/unlock CSIM operations by default
Wrap the AT+CSIM=XX commands between lock (CSIM=1) and
unlock (CSIM=0) operations.

This seems to avoid the TTY lockup seen in several different Telit
modules.

https://bugs.freedesktop.org/show_bug.cgi?id=100205

Reported-by: Penalva, Salvador <Salvador.Penalva@digi.com>
2017-03-16 22:30:27 +01:00
Aleksander Morgado
8664b2a38a telit: support RS232 modems
Adding the vendor string match allows us to support RS232 devices in
the Telit plugin: the USB vendor id check may now be ignored and
instead we probe for the vendor string via AT commands, which works
even if the device is behind a USB<->RS232 adapter.

https://bugs.freedesktop.org/show_bug.cgi?id=100171
2017-03-16 22:29:05 +01:00
Aleksander Morgado
60be293fa5 telit: don't ignore AT ports without an explicit port type hint tag
The telit plugin is based on two main ways of checking the purpose of
each port: udev tags flagging specific interfaces (with info taken
from Windows .inf drivers), or otherwise using AT#PORTCFG? to query
the modem about that information. If none of those applies, the port
is ignored by default.

In order to support devices that are not explicitly tagged, the plugin
shouldn't flag as ignored the AT-capable TTYs, instead they are now
grabbed as 'secondary': ports grabbed as secondary will never be used
for either primary/data IF there is another port flagged explicitly
for primary/data.

This fixes the support for modems with a single TTY and no explicit
port type hint tag, e.g. RS232 modems with just one single TTY where
there's no point in specifying port type hints: the port will be
grabbed as secondary, and then automatically promoted to primary/data
as there is no other port grabbed.

https://bugs.freedesktop.org/show_bug.cgi?id=100159
2017-03-16 22:24:03 +01:00
Ben Chan
31655bb5a5 glib: remove invocations of g_type_init()
g_type_init() has been deprecated (and also marked with the attribute
'deprecated') since glib 2.36 as the type system is automatically
initialized. Since the minimum version of glib required by ModemManager
is 2.36, calling g_type_init() isn't necessarily in the ModemManager
code.
2017-02-03 10:05:14 +01:00
Dan Williams
ab48dc5b17 telit: add LTE access technology reporting 2017-01-28 21:54:13 -06:00
Ben Chan
4a80c24169 telit: use g_assert instead of g_assert_true / g_assert_false
`g_assert_true' and `g_assert_false' are defined in glib 2.38 or later.
The minimum glib version currently required by ModemMamanger is 2.36.
While `g_assert_true' and `g_assert_false' may be preferred over the
more generic `g_assert', it seems like overkill to bump the minimum glib
version requirement just for that. When more code in ModemManager later
requires newer versions of glib, we can migrate all existing code to use
`g_assert_true' and `g_assert_false' when appropriate.
2017-01-12 11:37:08 +01:00
Carlo Lobrano
61dc32a72c telit: wrong port peek in telit_qss_toggle_ready
qss unsolicited handler should be assigned to primary port first,
while secondary port was peeked.
2017-01-04 13:35:36 +01:00
Carlo Lobrano
7078587f58 telit: optimized supported and current band code
In place of two slightly different regexes for 2g/3g and 2g/3g/4g modems
we now use only one regex with conditional patterns for both supported
and current Bands detection.

Adding also minor fix in test code
2016-10-20 12:40:04 +02:00
Daniele Palmas
6f11ff10cd telit: fix supported and current bands query with GE910
GE910 is a 2g only modem and when queried for bands it returns
only a 2g set of bands:

--> 'AT#BND=?<CR>'
<-- '<CR><LF>#BND: (0-3)<CR><LF><CR><LF>OK<CR><LF>'

Current regex fails, since it considers the 3g bands block mandatory.

A similar problem happens for current bands.

This patch modifies the regular expressions for properly
supporting GE910 and updates tests.
2016-10-11 10:16:24 +02:00
Daniele Palmas
d5cfad49d8 telit: add GE910 #PORTCFG layouts
GE910 family supports #PORTCFG layouts different than HE910
family ones.

This patch properly tags GE910 ports according to Telit document
"GE910 Family Ports Arrangements, 1vv0301049"
2016-10-06 11:37:09 +02:00
Daniele Palmas
30bcf5605c telit: add udev rules for supporting GE910
This patch adds the udev rules for supporting GE910 (PID 0x22)
2016-10-06 11:37:02 +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
aa4577dfb9 core: new kernel device object instead of an explicit GUdevDevice
Instead of relying constantly on GUdevDevice objects reported by GUdev, we now
use a new generic object (MMKernelDevice) for which we provide an initial GUdev
based backend.
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
Aleksander Morgado
07858461b8 dell,telit: set one tag per rule match 2016-09-18 15:51:32 +02:00
Aleksander Morgado
c7d8ac622a udev: fix tagging per interface number
Commit 7ff57f9808 introduced a change to try to
use ATTRS{bInterfaceNumber} as a common way to match by interface number, but
this logic is broken because all the rules that we use to match by interface
number (attribute in the interface device) also require matching by idVendor
and idProduct (attributes in the physdev device), and udev rules forbid matches
from more than one parent device at a time.

We could use ATTR{bInterfaceNumber} (instead of ATTRS) to tag the actual USB
interface device, but that would require a change in all the plugins to look for
the tag not in the TTY device, but in its parent.

So, recover the original behavior, where a hidden property is created containing
the first bInterfaceNumber found in the list of parent devices, and then run
the matches against idVendor and idProduct only if the hidden property is found
with the expected value.
2016-09-18 15:43:30 +02:00
Aleksander Morgado
aa0e108107 udev: fix SUBSYSTEMS and ATTRS{idVendor} checks
Rules with a single condition where a parent property is checked with != don't
work properly. E.g.:
  SUBSYSTEMS!="usb", GOTO="end"
or:
  ATTRS{idVendor}!="abcd", GOTO="end"

Instead, we can mix both those previous parent rules and match them:
  SUBSYSTEMS=="usb",ATTRS{idVendor}=="abcd", GOTO="next"
  GOTO="end"
  LABEL="next"
  # Apply rules here
  LABEL="end"

In this case both SUBSYSTEMS and ATTRS conditions apply to the parent usb_device
(idVendor attribute is only available in the usb_device), so they apply to all
ports of the same device.
2016-09-18 14:08:20 +02:00
Carlo Lobrano
f670861939 telit: add support to SIM hot swap
MMBroadbandModemTelit:
 * added logic to set MMBroadbandModem's SIM_HOT_SWAP property to TRUE
 * added function to enable QSS unsolicited
 * added QSS unsolicited handler
2016-08-10 09:39:47 +02:00
Aleksander Morgado
a5f33f0070 telit,udev: single 'usb' subsystems check and simplified single vendor check 2016-08-06 10:41:52 +02:00
Aleksander Morgado
7ff57f9808 udev: replace ENV{.MM_USBIFNUM} conditions with ATTRS{bInterfaceNumber} 2016-08-06 10:41:52 +02:00
Carlo Lobrano
bff43b26bf telit: adding a short delay after SIM unlock
A short delay is necessary with some SIMs when
they have just been unlocked. Using 1 second as secure margin.
2016-07-26 14:10:27 +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
Daniele Palmas
850318fd96 telit: code refactoring
This patch moves init and port grabbing functions to a separate file
to allow functions call from Dell plugin
2016-05-03 11:44:30 -05:00
Carlo Lobrano
1322201a43 telit: implemented set current bands 2016-03-10 16:10:18 +01:00
Daniele Palmas
c8a26e472e telit: add current modes setting
This patch adds current modes setting in Telit plugin
2016-02-24 11:22:14 +01:00
Carlo Lobrano
beeabdea2f telit: add load_current_bands interface 2016-02-15 14:22:48 +01:00
Daniele Palmas
7f173dfd15 plugin: telit: add current mode loading
This patch adds current mode loading in Telit plugin
2016-02-04 11:11:42 -06:00
Daniele Palmas
85e6c5b915 plugin: telit: add supported modes loading
This patch add supported modes loading in Telit plugin.
2016-02-04 11:11:42 -06:00
Aleksander Morgado
3911ea5a0f telit: minor coding style fixes 2016-01-25 13:58:57 +01:00
Carlo Lobrano
70b8ec1a88 telit: add load_supported_bands interface 2016-01-25 12:37:46 +01:00
Carlo Lobrano
81019ca5b5 telit: add udev rule for Telit LE910 V2 modem 2016-01-25 10:16:09 +01:00
Aleksander Morgado
0a88ae2d6d telit: use explicit FIRST step name 2015-12-19 11:51:11 +01:00
Aleksander Morgado
46f601edf6 telit: don't talk to the user in a GError 2015-12-19 11:50:22 +01:00
Aleksander Morgado
a74edab57f telit: prefix helper methods with 'mm_telit' 2015-12-19 11:45:32 +01:00
Aleksander Morgado
740e1b5461 telit: fix minor coding style issues 2015-12-19 11:44:00 +01:00
Carlo Lobrano
c4ffe572ae telit: add load_unlock_retries interface 2015-12-19 11:39:48 +01:00
Carlo Lobrano
7978225934 telit: add modem_reset to telit plugin 2015-12-11 09:09:57 +01:00
Carlo Lobrano
14e4771056 telit: add modem_power_down to telit plugin 2015-12-04 10:59:28 +01:00
Aleksander Morgado
948be2343a telit: minor coding style fixes 2015-03-27 19:06:43 +01:00
Daniele Palmas
12318970a7 telit: changing udev rules for HE910/UE910/UL865
Changing udev rules for HE910/UE910/UL865 in order to use dynamic port
identification through #PORTCFG (tag ID_MM_TELIT_PORTS_TAGGED)
2015-03-27 19:01:52 +01:00
Daniele Palmas
ad6d15b535 telit: implementing dynamic port identification with #PORTCFG
Adding dynamic port identification for Telit modems that support AT#PORTCFG
command. Port configurations for HE910/UE910/UL865 taken from document
"HE910/UE910/UL865 Families Ports Arrangements User Guide"
2015-03-27 19:01:45 +01:00
Daniele Palmas
a92566ec0e telit: adding 3gpp unsolicited events support for Telit modems
Mobile Equipment Event Reporting command for Telit modems (+CMER)
does not support <ind>=1. Changing to <ind>=2
2015-03-13 19:04:02 +01:00
Daniele Palmas
f9a5848d71 telit: add custom flow control settings for Telit HE910, UE910, UL865
Telit HE910, UE910 and UL865 do not support XON/XOFF; defaulting
to RTS/CTS
2015-03-12 12:01:23 +01:00
Daniele Palmas
00b5ae3e5b telit: Adding udev rules for Telit HE910, UE910 and UL865
Adding udev rules for proper modem identification.
2015-03-12 09:55:30 +01:00
Aleksander Morgado
7c347aa3ec port: store parent sysfs path in each MMPort 2014-06-23 18:12:27 +02:00
Aleksander Morgado
6f235b9948 ports: rename 'MMAtSerialPort' to 'MMPortSerialAt' 2014-02-13 13:40:01 +01:00