Commit Graph

8181 Commits

Author SHA1 Message Date
Jonas Bonn e52d224d9a Add support for Quectel EC21/25 modems
This follows the same pattern as the Telit QMI modems, routing the
setup through a QMI driver.  I think this can be cleaned up somehow,
but for now this at least provides support for these two modem models
so that others can aid in testing.
2017-04-20 12:45:11 -05:00
Vincent Cesson 9cc3eaabf9 gemalto: Use sim_state_query for sim detection
Populate gemalto_data structure.
Add sim_state callbacks.
Fix enable/disable return value.
2017-04-20 12:43:28 -05:00
Jonas Bonn d6704223d8 qmi: move rat_to_tech() into own module
We want to use this function from multiple atoms so this patch moves
it out to its own module for NAS-related helper functions.
2017-04-18 09:48:04 -05:00
Jonas Bonn 526b30b7ec ofono: add missing header inclusions
This is a "leaf" header and doesn't even have header guards, but
it still seems natural that the header should pull in its own declarations
rather than relying on the including source file to ensure that they
are included.
2017-04-18 09:47:42 -05:00
Jonas Bonn c0273f9d85 qmi: add missing header inclusion 2017-04-18 09:47:39 -05:00
Jonas Bonn 27b527c4f9 qim: use named status value 2017-04-17 12:11:40 -05:00
Jonas Bonn 949f968676 qmi: implement detach_shutdown method
The detach_shutdown method is invoked to unconditionally release
an active context.  For QMI, this is equivalent to a call to
deactivate_primary.

This patch makes the callback to deactivate_primary optional and
implements detach_shutdown to simply call it.  When there is no
callback, the stop_net callback notifies ofono about the context
release via an asynchronous ofono_gprs_context_deactivated() call.
2017-04-17 12:09:48 -05:00
Jonas Bonn f0f5a19af5 qmi: free cb_data on error
...and move allocation of structure up to variable declarations to
match the pattern used elsewhere in the code.
2017-04-17 12:07:43 -05:00
Jonas Bonn 91b89f472f qmi: read_settings needs to call start network
For LTE networks, a default bearer is automatically activated when
the modem registers to the network.  QMI modems, however, do not
automatically enable the network interface just because the bearer
exists; a call to "start network" needs to be made in order to
get the packet handle before get_settings will return any data and
the network interface can be configured.

This patch makes read_settings call "start network" in order to
enable the interface for the default bearer.  No new bearer will
be created with this call and the settings for the bearer will come
from the default profile, irregardless of what parameters are passed
to the "start network" method.
2017-04-14 17:54:29 -05:00
Jonas Bonn 0167c3339c gprs: set driver_attached when activating automatic contexts
The ofono_gprs_cid_activated attachment machinery cannot go through
ofono_gprs_status_notify for getting the attached property set because
that would result in the automatic contexts that were just set up
being released.  As such, it needs to call gprs_set_attached_property
manually.  Doing so, however, means that the driver_attached property
never gets set, resulting in all contexts being released when the
network transitions between registered states (roaming/non-roaming).
2017-04-14 17:43:13 -05:00
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