Commit Graph

7971 Commits

Author SHA1 Message Date
Jonas Bonn 1fd419e5b4 gprs: _cid_activated is an 'attaching' state
ofono_gprs_status_notify is an asynchronous notification that messes
with the 'attached' state of the GPRS atom.  This method is normally
prevented from running while an attach is in progress because the
attachment machinery wants to finish up and make it's own determination
of attach state.

When automatic context activation is relevant, as for LTE networks,
the ofono_gprs_cid_activated machinery replaces the usual set_attach
machinery for attaching to the network.  The cid_activated variant,
however, does not guard against simulatenous invocations of
ofono_gprs_status_notify.  This causes a race whereby status_notify
sets the state to 'attached' before the context is fully constructed
and set to active.  If the connection manager sees the 'attached'
state before there are any 'active' contexts, it may decide to
activate a context manually which is not the correct behaviour for
this type of network.

This patch makes the *_cid_activated machinery an 'attaching' state,
introducing the same guards that set_attached has to prevent
ofono_gprs_status_notify from running concurrently.
2017-04-14 17:28:46 -05:00
Jonas Bonn ad39b9003b qmi: fix typo 2017-04-14 16:49:31 -05:00
Jonas Bonn 71372ba0b3 qmi: duplicate callback data correctly 2017-04-14 16:44:05 -05:00
Vincent Cesson 920f77b770 gemalto: Change offline mode, keep USIM available
Gemalto has two airplane mode:
CFUN=0 disables USIM
CFUN=4 keeps USIM connected
2017-04-13 11:56:27 -05:00
Vincent Cesson 160a03e2bf gemalto: Clean post init functions
Remove inappropriate interfaces.
Move GPRS init from post_online to post_sim.
2017-04-13 11:55:15 -05:00
Denis Kenzior b84fc8df19 AUTHORS: Mention Jonas' contributions 2017-04-13 11:54:56 -05:00
Denis Kenzior 7a2e198fd7 qmi: Use destroy callback for context activate 2017-04-11 12:01:15 -05:00
Denis Kenzior f29a316c91 qmi: Use destroy callback for context deactivate
This ensures that cbd will be freed even if the device is hot-unplugged.
Also, this fixes a memory leak on the failure path inside stop_net_cb
2017-04-11 12:01:06 -05:00
Jonas Bonn ef9af151ee qmi: implement read_settings for automatic contexts
For LTE, a context is created automatically when the modem registers
to the network.  The read_settings function is called for these
automatic contexts to get their configuration.
2017-04-11 11:45:41 -05:00
Jonas Bonn 475b789f3d qmi: retrieve GPRS context parameters
The GPRS context needs to be configured with connection parameters when
the bearer has been established.  This was only partially implemented, so
this patch adds additional parameters to those passed to the context.
2017-04-11 11:43:16 -05:00
Jonas Bonn 55bd639ae1 qmi: add WDS parameter definition 2017-04-11 11:22:29 -05:00
Jonas Bonn a0b3a8e0b8 qmi: NAS definitions adjustment
Calling the ps_state/cs_state alternatives *ATTACH_STATUS* was confusing
because there is also a status field in the *serving_system structure.
This patch does a minor rename and adds the appropriate definitions for
the status field.
2017-04-11 10:22:57 -05:00
Denis Kenzior 829fc23137 qmi: Fix qmi_device_shutdown
qmi_device_shutdown allocated a new orphaned data structure and kicked
off a timeout to wait for the shutdown to complete.  The logic was quite
racy, but the main issue was that the timeouts could not be canceled
when the underlying qmi_device object was destroyed.  This resulted in
crashes.

This patch switches to first-past-the-gate mechanism.  Since only the
modem driver should be issuing a qmi_device_shutdown call, this should
not be a limitation.  The shutdown source is then tracked on the
qmi_device object itself and is canceled when the qmi_device object is
freed.

As an added bonus, the shutdown_destroy callback should now actually
function.  Before it was simply never called.
2017-04-04 10:24:13 -05:00
Denis Kenzior 2701dd8919 qmi: Optimize structure allocations
struct discovery was allocated for every discovery procedure that was
kicked off, which itself allocated a structure.  This patch uses a
class/subclass concept to only allocate a single structure per discovery
procedure.
2017-04-03 12:56:26 -05:00
Jonas Bonn a722cef201 modem: set_online is valid for AlwaysOnline modems
Calling set_online(TRUE) for an AlwaysOnline modem should succeed; the
modem is, after all, in the requested state when the call returns.
Returning not_implemented is not necessarily wrong, but it's a bit ugly.
2017-04-03 09:23:53 -05:00
Jonas Bonn 1e39a9d26d qmi: fix bad lookup and double free
This function was never removing discovery instances because it was looking
them up in the wrong list.  This led to some strangeness with the discovery
callbacks being invoked after the "failure" timeout of 5 seconds and
consequent failures with everything getting out of sync.

With this patch we fix the lookup to use the correct queue.  There's also
a double-free in the function that was never being hit before because the
lookups never succeeded; fix that as well.

With this, service discovery and creation work as expected when testing with
an EC21.
2017-04-03 09:23:53 -05:00
Jonas Bonn 529afeb67f qmi: add service ID's 2017-04-03 09:23:53 -05:00
Jonas Bonn 174eddc80d udevng: remove 'option' driver setup
No driver named 'option' exists so this device can never be instantiated.
2017-03-31 18:15:19 -05:00
Lukasz Nowak 81a54c5a47 atmodem: telit - re-attach gprs automatically
Telit AT modem firmware (tested with UE910-EUR) generates
+CGREG: 0\r\n\r\n+CGEV: NW DETACH
after a context is de-activated and ppp connection closed.
Then, after a random amount of time (observed from a few seconds
to a few hours), an unsolicited +CGREG: 1 arrives.
Attempt to fix the problem, by sending AT+CGATT=1 once.
This does not re-activate the context, but if a network connection
is still correct, will generate an immediate +CGREG: 1.
2017-03-29 10:01:50 -05:00
Jonas Bonn ed66682315 plugins: remove udev module
This functionality has been moved into the udevng module and was
already disabled in an earlier patch.
2017-03-29 09:56:32 -05:00
Jonas Bonn bf20f0df18 udevng: get properties from interface
Device properties are generally on the device, on the USB interface
descriptor, or the on the USB device descriptor.
2017-03-29 09:56:28 -05:00
Jonas Bonn 1b28cb5cc6 udevng: hook up legacy devices
...and disable old udev code by shorting it out in it's init() function.

The check_device function is augmented to differentiate between USB
and serial devices:

- if the device sits on a USB bus, the device is handled as before
- if not, an attempt is made to handle the device as a serial device
2017-03-29 09:55:51 -05:00
Jonas Bonn 90c8885f4f udevng: match on the hsi subsystem for legacy devices 2017-03-29 09:55:33 -05:00
Jonas Bonn 3ac449e25f udevng: add serial device handling functions
This adds, but does not hook up, support for simple serial modems.  These
modems generally have only a single device node so are simpler than the
USB devices which generally have different device nodes for different
functions.  These modems are currently handled by udev.c, but this
functionality will allow to remove that module completely in a later patch.

- A new "device_info" type is created called serial_device_info
- the function add_serial_device sets up a modem_info structure and a
  serial_device_info for the device
- A reference to the device's udev node is saved in the device info
- The device driver is retrieved from the OFONO_DRIVER environment variable
  which needs to be set up by some udev rule
- Setup functions are added for these types of devices: a common function
  setup_serial_modem covers the generic (simple) case, whereas modems
  with special requirements are given their own setup functions to handle
  the special bits
- Modem destroy needs to know the "device_info" type in order to clean
  up properly, so a 'type' value is set on the modem_info structure to
  guide selection of the proper cleanup function
2017-03-29 09:53:48 -05:00
Denis Kenzior 4c46605f6b qmi: track discovery tasks so clean up is possible
There are various device & service discovery tasks that are initiated
based on a qmi_device object.  qmi_device object does not currently
keep track of these tasks.  Unfortunately the qmi_device object can
go away at any time, and these tasks can become orphaned.

The result of this can lead to crashes.  E.g. a discovery task timeout fires
after the qmi_device object has been destroyed.  Since the object is no
longer valid, any accesses to it will likely result in a SEGFAULT.

This patch attempts to track all discovery tasks on the qmi_device
object itself, so that they can be cleaned up properly.  This patch does
not handle the qmi_device_shutdown functionality.
2017-03-28 14:21:07 -05:00
Lukasz Nowak 975a4df862 unit: rilmodem-test - add missing string.h
Remove warnings of undeclared memcpy, strncpy, etc.
2017-03-28 11:57:26 -05:00
Lukasz Nowak e1f42cb68a udevng: add Telit LE910 V1 support
Tested with LE910-SVG and Verizon.
2017-03-26 22:41:50 -05:00
Jonas Bonn 36be849043 udev: remove extraneous subsystem check
The enumeration construct is already set up with matches for these
subsystems.
2017-03-26 21:21:43 -05:00
Jonas Bonn 8c30bcf576 udev: simplify wavecom modem registration 2017-03-26 21:21:18 -05:00
Jonas Bonn 43e2be3574 udev: simplify ifx modem registration 2017-03-26 21:20:56 -05:00
Jonas Bonn 3c16db19e2 udev: add common modem registration code
Many of these drivers do exactly the same setup when registering
the modem.  Consolidate these setup functions into common code.
2017-03-26 21:19:46 -05:00
Jonas Bonn 55a4bbf7e3 udev: simplify add_modem
Adding a modem boils down to finding the device in the hierarchy with
the OFONO_DRIVER property.  The original code special-cased the property
being on the device itself rather than on a parent device.  This patch
combines the two cases.
2017-03-26 21:17:58 -05:00
Jonas Bonn 5a2591ce4d udev: remove unused modem property
The property 'Registered' is not used anywhere.
2017-03-26 20:50:50 -05:00
Jonas Bonn 428fdc7fb6 udev: get udev property via lib function 2017-03-26 20:50:36 -05:00
Jonas Bonn 0df3231f7f udev: remove extraneous subsystem check
The udev-monitor already guarantees that only devices with these
subsystems will be returned so we don't need to check again.
2017-03-26 20:49:34 -05:00
Jonas Bonn dd1e441966 ofono.rules: remove 'change' action
The code doesn't do anything with this action so don't bother setting
extra device properties for it.
2017-03-26 20:44:52 -05:00
Jonas Bonn 03e1ec2f66 udevng: simplify logic in check_usb_device
This patch simplifies and cleans up the check_usb_device function a bit
by doing the two following (slightly intertwined) things:

1)  The parent "usb_device" is searched for early in this function and this
device will always have the ID_VENDOR_ID and ID_MODEL_ID properties.
As such, we can get them from this device and thereby be certain that
we _always_ have them available.

2)  The logic of iterating the vendor_list table is cleaned up.  It's
easier to follow and won't be any less efficient.
2017-03-26 20:42:27 -05:00
Jonas Bonn b3b0cbb045 gobi: query presence of WDA service 2017-03-25 16:01:45 -05:00
Jonas Bonn f3911b1669 qmimodem: add WDA service string 2017-03-25 16:01:21 -05:00
Jonas Bonn c548fe2eb5 qmimodem: fix typo 2017-03-25 16:01:06 -05:00
Lukasz Nowak 988cec2fc2 gobi: Do not use low-power modes for some modems
Telit QMI modems have a problem with the low-power operating modes.
After entering and leaving such a state, UIM service does not return.
The sim card is still marked as powered-down. The QMI interface does
not have a way to power it back on.

To avoid this, keep modems with the "AlwaysOnline" flag online
in the disable-modem and offline-modem procedures.
2017-03-24 09:59:34 -05:00
Denis Kenzior da00fdb725 AUTHORS: Mention Lukasz's contributions 2017-03-23 10:32:00 -05:00
Lukasz Nowak 078582d567 qmimodem: detect utf-8 string as operator name
Telit QMI modems can return non-utf-8 characters in plmn-desc.
Observed with LE910-SVG and Verizon. When that happens, libdbus
will abort ofono.
If non-utf-8 characters are detected, use mccmnc string.
2017-03-23 10:26:30 -05:00
Lukasz Nowak 4219fcf7bc qmimodem: read ss_info at probe time
LTE modems (observed with Telit LE910 V1) can power on
already registered to a network. In that case, the SS_INFO
change notification will never arrive, and the gprs driver
will never be marked as attached.

To avoid this situation, read SS_INFO at probe time, and if
registered, mark the gprs driver as attached.
2017-03-23 10:25:23 -05:00
Denis Kenzior 8559a29d77 qmimodem: Fix warning
This was introduced by the previous patch:
drivers/qmimodem/devinfo.c: In function ‘get_ids_cb’:
drivers/qmimodem/devinfo.c:129:14: error: implicit declaration of function ‘strcmp’ [-Werror=implicit-function-declaration]
  if (!str || strcmp(str, "0") == 0) {
2017-03-23 10:24:34 -05:00
Lukasz Nowak a2a8e71db2 qmimodem: telit LE910 V1 - fix ESN string
Telit QMI modems report "0", rather than a NULL string,
if ESN is not available.
2017-03-23 10:23:50 -05:00
Christophe Ronco 26aba4612c huawei: reopen modem channel if it disconnects
On E3372 after a GPRS disconnection, modem AT channel (used by PPP) gets
disconnected (G_IO_HUP and G_IO_ERR are detected in received_data
in gatio.c).
After that all connection attempts fail because we are not able to send
any AT commands on modem channel (it is closed).

With this patch, when this behavior is detected, we close gprs context
driver, reopen AT channel and gprs context driver.
2017-02-21 11:13:51 -06:00
Christophe Ronco 94fd4d804d provision: add plugin to provision from config file
This plugin allows to provision gprs-context data based on MCC and MNC.
This is useful when provisioning using mbpi fails (either because you
are using a private APN or because there are multiple internet type context
for your operator in mbpi database).
Config file is STORAGEDIR/provisioning.
Config file should look like that:
[operator:MCC1,MNC1]
internet.AccessPointName=apn1
internet.Username=myUsername
internet.Password=myPassword
internet.AuthenticationMethod=pap
internet.Protocol=ipv6
[operator:MCC2,MNC2]
internet.AccessPointName=apn2

The only mandatory parameter for each operator is internet.AccessPointName.

Parameter description:
internet.AccessPointName: APN
internet.Username: Username
internet.Password: Password
internet.AuthenticationMethod: authentication method.
 Possible values are:
  - pap
  - chap
 Default is chap if unset.
internet.Protocol: protocol
 Possible values are:
  - ip: ipv4
  - ipv6
  - dual
 Default is ip if not set.

All parameters are prefixed with internet to be able to extend this plugin
to other type of contexts (MMS, ...).
2017-02-21 11:08:27 -06:00
Christophe Ronco 89c92e7277 qmimodem: fix sim file reading on MC7304
Command read_file_info on MC7304 always fails.
Using qmicli or AT command, I am able to read file info.
Qmicli command is:
qmicli -d /dev/cdc-wdm0 --uim-get-file-attributes=0x3f00,0x7fff,0x6fad
[(null)] Successfully got file '/dev/cdc-wdm0' attributes from the UIM:
Card result:
        SW1: '0x90'
        SW2: '0x00'
File attributes:
        File size: 4
        File ID: 28589
        File type: transparent
        Record size: 0
        Record count: 0
        Read security attributes: (always) (null)
        Write security attributes: (single) adm
        Increase security attributes: (always) (null)
        Deactivate security attributes: (single) adm
        Activate security attributes: (single) adm
        Raw:    62:17:82:02:41:21:83:02:6F:AD:8A:01:05:8B:...

After a check of parameters sent by qmimodem driver and qmicli,
the only difference is on parameter "Session Information".
Session type sent by qmimodem driver is 'Card on slot 1'.
Session type sent by qmicli command is 'primary-gw-provisioning'.
Changing session type in qmimodem driver fixed problem (on this modem).

Comparing with what is done by qmili command
2017-02-17 11:16:54 -06:00
Christophe Ronco 8e929df4f5 atmodem: use ATD99 to enter data state when needed
Some modems do not support AT+CGDATA="PPP",X to enter data state.
Use AT+CGDATA=? to detect these modems and for them use ATD*99***X#
to enter data state.
2017-02-16 11:52:49 -06:00