Commit Graph

193 Commits

Author SHA1 Message Date
Dan Williams
8c4318d87a iface-mode: downgrade "access technology changed" message to debug
We have a report of a modem that switches access technologies frequently,
in this case almost every 10 seconds.  While that's unusual, it's not
unexpected depending on the RF environment.  We shouldn't spam syslog
with that info; if we need it we can get it with mmcli.
2014-08-11 10:45:41 -05:00
Aleksander Morgado
5358d6fea0 sim: rename 'MMSim' to 'MMBaseSim'
Just so that we don't have same header names in src/ and /libmm-glib.
2014-07-06 16:55:29 +02:00
Aleksander Morgado
3ca267b01f bearer: rename 'MMBearer' to 'MMBaseBearer'
Just so that we don't have same header names in src/ and /libmm-glib.
2014-07-06 16:55:29 +02:00
Dan Williams
aedcb376a8 iface-modem: make "signal quality updated" log message debug not info
Otherwise your logs fill up if the signal quality changes, which is
pretty frequently for many devices.
2014-06-04 14:11:16 -05:00
Ben Chan
f20724ec3f iface-modem: allow setting power state to OFF when modem is in FAILED state 2014-03-03 11:18:23 +01:00
Aleksander Morgado
73dad3d899 iface-modem: allow requesting the refresh of the access tech
For periodic updates, we may want to request an explicit re-check at some point,
instead of waiting for the next scheduled update.
2014-02-28 16:35:18 +01:00
Aleksander Morgado
9239fbcd7a iface-modem: allow transitioning to the OFF power state
There are systems in which the modem power source can be controlled externally,
e.g. to switch it on or off. In these cases, it is sometimes advisable to be
able to tell the modem to cleanly shut off completely before the power is cut.
So, allow transitioning to the OFF power state if the modem supports it, even if
afterwards the modem could be completely unreachable.
2014-02-20 11:15:03 +01:00
Ben Chan
5c00736f44 iface-modem,sim: make SIM interface initialization cancellable 2014-01-11 23:33:35 +01:00
Ben Chan
ab12d17bfb iface-modem: fix crash in wait_for_final_state_context_complete_and_free
When wait_for_final_state_context_complete_and_free is invoked, if the callback
associated with the GSimpleAsyncResult object of the WaitForFinalStateContext
object updates the modem state via mm_iface_modem_update_state, state_changed
is invoked, which causes wait_for_final_state_context_complete_and_free to be
invoked again on the same WaitForFinalStateContext object. That leads to the
following crash, which is observed sometimes when a modem is being disabled.

Thread 0 *CRASHED* ( SIGSEGV @ 0x00000000 )

0x7fcb7728f202   [libgobject-2.0.so.0.3400.3] - gobject.c:2916              g_object_unref
0x7fcb7743205c   [ModemManager]               - mm-broadband-modem.c:8034   disabling_context_complete_and_free
0x7fcb77434d64   [ModemManager]               - mm-broadband-modem.c:8130   disabling_wait_for_final_state_ready
0x7fcb770c0b86   [libgio-2.0.so.0.3400.3]     - gsimpleasyncresult.c:775    g_simple_async_result_complete
0x7fcb7740cdbc   [ModemManager]               - mm-iface-modem.c:101]       wait_for_final_state_context_complete_and_free
0x7fcb7740ce19   [ModemManager]               - mm-iface-modem.c:128]       state_changed_wait_expired
0x7fcb76f78c33   [libglib-2.0.so.0.3400.3]    - gmain.c:4026]               g_timeout_dispatch
0x7fcb76f78087   [libglib-2.0.so.0.3400.3]    - gmain.c:2715]               g_main_context_dispatch
0x7fcb76f78437   [libglib-2.0.so.0.3400.3]    - gmain.c:3290]               g_main_context_iterate
0x7fcb76f78891   [libglib-2.0.so.0.3400.3]    - gmain.c:3484]               g_main_loop_run
0x7fcb773f4d55   [ModemManager]               - main.c:142]                 main
0x7fcb7698a9c6   [libc-2.15.so]               - libc-start.c:234]           __libc_start_main
0x7fcb773f48b8   [ModemManager]               + 0x000218b8]
2013-12-17 01:37:13 +01:00
Ben Chan
073163fb0b core: fix some typos in comments 2013-12-05 13:04:18 -06:00
Aleksander Morgado
7f442b777c introspection,api: new 'Bearers' property in the Modem interface
https://bugzilla.gnome.org/show_bug.cgi?id=712276
2013-11-21 10:50:49 +01:00
Thieu Le
c21709b32e altair-lte: add SIMREFRESH support
Register for SIMREFRESH event and reload own numbers and reregister
modem with network when this happens.
2013-11-21 10:48:53 +01:00
Ben Chan
9a9638ef20 iface-modem: remove unnecessary G_SIMPLE_ASYNC_RESULT() cast
This patch removes an unnecessary G_SIMPLE_ASYNC_RESULT() cast of the
'result' field, which is already of type GSimpleAsyncResult, of
InternalLoadUnlockRequiredContext.
2013-10-24 17:39:59 +02:00
Aleksander Morgado
13c7319bff iface-modem: consolidate new unlock required check with retries
The new internal_load_unlock_required() method will take care of running the
subclassed load_unlock_required(), if available, and also retry the check up
to 6 times.

This method will be used both by the standard unlock required check and by the
check within the current capabilities loading for multimode devices.
2013-09-19 09:33:08 -05:00
Ben Chan
aa74ea1aa6 iface-modem: fix MODEM_STATE_IS_INTERMEDIATE macro 2013-09-18 08:40:04 +02:00
Ben Chan
5d8efff291 iface-modem: free GError when interface initialization is cancelled
This patch fixes an assertion failure 'ctx->fatal_error == NULL' in
initialization_context_complete_and_free(), which happens if
'fatal_error' of the initialization context is set during the modem
interface initialization and the initialization is later cancelled.
2013-09-16 07:51:53 +02:00
Ben Chan
60e1ac6919 iface-modem: allow reset and factory reset operation in every state 2013-09-02 09:03:53 +02:00
Ben Chan
f515cd1d90 iface-modem: add mm_iface_modem_get_model helper to query model 2013-08-14 09:30:41 +02:00
Aleksander Morgado
ddb9691922 iface-modem: plug memleak 2013-06-25 11:48:50 +02: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
e227d4af39 iface-modem: don't rely on the cached current power state value
The real power state value of the modem may be changed by other means, e.g.
rfkill. So when changing power state of the modem in MM, we better recheck
which the current power status is.

A better full approach would be to follow rfkill changes, but this fix should
help until that is done.

https://bugzilla.gnome.org/show_bug.cgi?id=702838
2013-06-24 19:40:58 +02:00
Aleksander Morgado
b41278c423 iface-modem: allow changing capabilities in every state
Same as done with the firmware switching, we allow capabilities changing even
if the modem is in FAILED state, e.g. to switch from 3GPP to 3GPP2 mode.
2013-06-05 19:15:15 +02:00
Aleksander Morgado
f09eff633c iface-modem: load current modes and bands during initialization
We now load current modes and bands before enabling the modem, and we also allow
mode and bands changes while the modem is disabled.
2013-06-05 19:15:15 +02:00
Aleksander Morgado
a902e6859e api,introspection: new 'SetCurrentCapabilities' method
For those modems which expose a valid 'SupportedCapabilities' property with more
than one item in the list, we'll allow switching between them.
2013-06-05 19:15:15 +02:00
Aleksander Morgado
700ebc5c07 api,introspection: rename 'ModemCapabilities' to 'SupportedCapabilities'
And also make it a list of masks, specifying which are the specific combinations
supported, not just one mask with all.

E.g.:
  -------------------------
  Hardware |   manufacturer: 'Sierra Wireless, Incorporated'
           |          model: 'MC7710'
           |       revision: 'SWI9200X_03.05.19.04ap r5475 carmd-en-10527 2012/09/17 17:57:14'
           |      supported: 'gsm-umts
           |                  gsm-umts, lte'
           |        current: 'gsm-umts, lte'
           |   equipment id: '358178040668164'
2013-06-05 19:15:15 +02:00
Aleksander Morgado
1c67d050cb api,introspection: merge 'AllowedModes' and 'SupportedMode' into 'CurrentModes'
We now have a single 'CurrentModes' property which contains both values in a
tuple with signature "(uu)".

Also, rename 'SetAllowedModes()' to 'SetCurrentModes()', and update the list of
arguments expected to have a single "(uu)" tuple.
2013-06-05 19:15:14 +02:00
Aleksander Morgado
45ceba7692 api,introspection: 'SupportedModes' is now a list of possible combinations
Instead of just a mask of MMModemMode values, we now provide a list of the
allowed and preferred mode combinations supported by the modem. E.g.:

$> sudo mmcli -m 0
  -------------------------
  Modes    |      supported: 'allowed: 2g; preferred: none
           |                  allowed: 3g; preferred: none
           |                  allowed: 2g, 3g; preferred: none
           |                  allowed: 2g, 3g; preferred: 2g
           |                  allowed: 2g, 3g; preferred: 3g
           |                  allowed: 4g; preferred: none
           |                  allowed: 2g, 3g, 4g; preferred: none'
2013-06-05 19:15:14 +02:00
Aleksander Morgado
212d00c529 api,instrospection: rename 'Bands' to 'CurrentBands'
... and 'SetBands()' to 'SetCurrentBands()'.

We'll keep the 'Current' keyword in those properties which also have
'Supported' values.
2013-06-05 19:15:14 +02:00
Aleksander Morgado
b3222202bd api,introspection: new 'SupportedIpFamilies' property
This property will let the clients know which are the IP families supported by
the modem.
2013-06-05 19:15:13 +02:00
Dan Williams
18bfefba2d iface-modem: fix array insertion when setting bands
You can't g_array_insert_val() to an index that's beyond the end
of the array, which was happening if the user tried to set the
band list to "any":

mmcli -m 0 --set-bands=any

Just use g_array_append_val() instead.

==5618== Invalid read of size 2
==5618==    at 0x4A0A158: memcpy@GLIBC_2.2.5 (mc_replace_strmem.c:881)
==5618==    by 0x326201D8FB: g_array_insert_vals (string3.h:57)
==5618==    by 0x442EFB: mm_iface_modem_set_bands (mm-iface-modem.c:1982)
==5618==    by 0x44307E: handle_set_bands_auth_ready (mm-iface-modem.c:2100)
==5618==    by 0x326386DFF6: g_simple_async_result_complete (gsimpleasyncresult.c:775)
==5618==    by 0x4358E3: authorize_ready (mm-base-modem.c:1300)
==5618==    by 0x326386DFF6: g_simple_async_result_complete (gsimpleasyncresult.c:775)
==5618==    by 0x326386E0F8: complete_in_idle_cb (gsimpleasyncresult.c:787)
==5618==    by 0x3262047A54: g_main_context_dispatch (gmain.c:2715)
==5618==    by 0x3262047D87: g_main_context_iterate.isra.24 (gmain.c:3290)
==5618==    by 0x3262048181: g_main_loop_run (gmain.c:3484)
==5618==    by 0x426235: main (main.c:142)
==5618==  Address 0x10a7ea74e is not stack'd, malloc'd or (recently) free'd
==5618==
==5618==
==5618== Process terminating with default action of signal 11 (SIGSEGV)
==5618==  Access not within mapped region at address 0x10A7EA74E
==5618==    at 0x4A0A158: memcpy@GLIBC_2.2.5 (mc_replace_strmem.c:881)
==5618==    by 0x326201D8FB: g_array_insert_vals (string3.h:57)
==5618==    by 0x442EFB: mm_iface_modem_set_bands (mm-iface-modem.c:1982)
==5618==    by 0x44307E: handle_set_bands_auth_ready (mm-iface-modem.c:2100)
==5618==    by 0x326386DFF6: g_simple_async_result_complete (gsimpleasyncresult.c:775)
==5618==    by 0x4358E3: authorize_ready (mm-base-modem.c:1300)
==5618==    by 0x326386DFF6: g_simple_async_result_complete (gsimpleasyncresult.c:775)
==5618==    by 0x326386E0F8: complete_in_idle_cb (gsimpleasyncresult.c:787)
==5618==    by 0x3262047A54: g_main_context_dispatch (gmain.c:2715)
==5618==    by 0x3262047D87: g_main_context_iterate.isra.24 (gmain.c:3290)
==5618==    by 0x3262048181: g_main_loop_run (gmain.c:3484)
==5618==    by 0x426235: main (main.c:142)
2013-04-25 09:18:53 -05:00
Dan Williams
92035fdf1c iface-modem: skip modem_after_sim_unlock() for CDMA-only devices
We don't support SIM/RUIM on CDMA devices (yet), so for now it makes
no sense to run the after-sim-unlock step on CDMA-only devices where
a SIM won't be present.

Unfortunately we don't know at this point whether there is a SIM
or not, so if the modem is a multi-mode device (implying it has a SIM
slot) and its plugin implements the modem_after_sim_unlock() hook,
the hook will still be executed and might cause an unecessary delay
when a SIM is not inserted.
2013-04-18 12:22:28 -05:00
Aleksander Morgado
7d668eb407 iface-modem: for multimode 3GPP+3GPP2 devices, check if SIM is available
If SIM is not available, no 3GPP caps in current caps.
2013-04-18 18:47:25 +02:00
Aleksander Morgado
4f3932cb2b iface-modem: ignore SIM errors in 3GPP2-capable devices
We already fully skipped SIM unlock check in 3GPP2-only devices; now we also
ignore SIM errors if the device is a 3GPP+3GPP2 device.
2013-04-18 18:47:25 +02:00
Aleksander Morgado
cbee87f2f5 iface-modem: let the MBIM port be the primary one 2013-04-17 15:19:38 +02:00
Aleksander Morgado
1cb5831af3 iface-modem: ensure we cancel the re-initialization idle if the modem goes away
https://bugzilla.gnome.org/show_bug.cgi?id=697290
2013-04-05 08:54:09 +02:00
Aleksander Morgado
b377a62377 iface-modem: never try to create a SIM in a CDMA-only modem
CDMA modems without LTE capabilities will usually not have a SIM, so just skip
loading a SIM object if so.

https://bugzilla.gnome.org/show_bug.cgi?id=696582
2013-03-27 08:27:30 -05:00
Aleksander Morgado
89461cf7b3 iface-modem: allow falling back to 'failed' state
Allow mm_iface_modem_update_state() receive 'MM_MODEM_STATE_FAILED', and treat
it as any other change to failed state, but with
'MM_MODEM_STATE_FAILED_REASON_UNKNOWN'.
2013-02-26 21:17:43 +01:00
Aleksander Morgado
75d20c15d4 api: notify in the interface about the reason why the modem is FAILED
We currently implement 'SIM missing' and 'SIM error', which are probably the
most common ones.
2013-02-22 16:35:56 +01:00
Ben Chan
bb73ce0aaf iface-modem: fix modem state consolidation upon bearer disconnection
Patch "iface-modem: fix invalid modem state consolidation" (commit
69aff6183a) incorrectly consolidates the
modem state upon the disconnection of a bearer. The modem state remains
'connected' after the last bearer is disconnected. This patch fixes
that.
2013-02-20 09:17:08 +01:00
Aleksander Morgado
1746949277 ports: add port initialization sequences instead of iface-modem's modem_init()
Instead of a custom modem_init() step in the 'Modem' interface, just add a
sequence of port initialization commands in each port.

While enabling for the first time a non-hotplugged modem, we will issue the
port initialization commands only after having run the enabling_modem_init()
step (i.e. after ATZ usually).
2013-02-18 13:47:35 +01:00
Dan Williams
594adc38ff broadband-modem: don't try QCDM access technology checks for non-QCDM 3GPP devices
Result handling code mistakenly ran for these devices, when it shouldn't.
2013-02-14 14:52:23 -06:00
Ben Chan
24b28d1a72 iface-modem: add a missing step increment in interface_initialization_step 2013-01-30 23:11:51 +01:00
Ben Chan
c204a8ce4e iface-modem: rearrange initialization steps
This patch rearranges the initialization steps in MMIfaceModem such that
the following SIM related operations happen at the end of the
initialization:
    - INITIALIZATION_STEP_UNLOCK_REQUIRED
    - INITIALIZATION_STEP_SIM
    - INITIALIZATION_STEP_OWN_NUMBERS

The rationale of this change is that the SIM interface of some modems
may require some time to initialize before it responds to SIM related
AT commands. By rearranging the initialization steps to execute non-SIM
related AT commands first, some of the latency for the SIM
initialization can be absorbed.
2013-01-24 13:37:52 +01:00
Ben Chan
69aff6183a iface-modem: fix invalid modem state consolidation
ModemManager has a bogus modem state transition from 'enabling' to 'disabled':

ModemManager[26214]: <info>  Modem fully enabled...
ModemManager[26214]: <info>  Modem /org/freedesktop/ModemManager1/Modem/2: state changed (enabling -> disabled)

The root cause seems to be the following:

get_current_consolidated_state() in MMIfaceModem returns
MM_MODEM_STATE_DISABLED as the default fallback value. When
mm_iface_modem_update_state() is invoked to transition the modem state from
MM_MODEM_STATE_ENABLING to MM_MODEM_STATE_ENABLED, the following code can
potentially cause the final state to be MM_MODEM_STATE_DISABLED instead.

     /* Enabled may really be searching or registered */
     if (new_state == MM_MODEM_STATE_ENABLED)
         new_state = get_current_consolidated_state (self);

https://code.google.com/p/chromium-os/issues/detail?id=38173
2013-01-24 09:08:44 +01:00
Aleksander Morgado
9d5794e9e4 iface-modem: print power state as string
Thanks to Marius B. Kotsbak <marius@kotsbak.com> for reporting.
2013-01-21 10:33:49 +01:00
Ben Chan
1cf8ccbdd5 iface-modem: schedule signal quality check more often initially
This patch modifies MMIfaceModem to schedule the periodic signal quality
check with a period of 3s instead of 30s (up to 5 periods) initially
until a non-zero signal quality value is obtained and then switch back
to the 30s period.
2013-01-18 11:28:08 +01:00
Aleksander Morgado
e55b543d38 iface-modem: implement power mode loading and setting 2013-01-11 10:05:45 +01:00
Aleksander Morgado
1372933345 iface-modem,sim: improve lock info update logic
The logic to handle the lock information (current lock and unlock retry count)
wasn't handling all possible cases properly, e.g.:

 * When PIN is incorrectly entered too many times, a SIM-PUK error may happen.
   In this case we need to directly assume SIM-PUK is the current lock (some
   modems, like Option HSO ones, would incorrectly reply SIM-PIN if CPIN? asked
   just after the SIM-PUK error).

 * After every operation acting in SIM locks, we need to update the current
   unlock retry count.

This change tries to cover those cases, by:

 * The logic to check current lock is extended to also load the unlock retry
   count when needed.

 * Whenever a SIM-PUK error happens in the SIM operations, we directly assume
   that SIM-PUK is required, without re-asking CPIN?.

 * The overall logic of lock checking is now handled by a state machine, which
   is much easier to understand.
2013-01-08 18:40:47 +01:00
Ben Chan
e939221975 iface-modem, novatel-lte: disable network scan in LTE mode 2013-01-04 12:10:51 +01:00
Ben Chan
02ef7d9547 iface-modem: load own numbers after SIM initialization
In 3GPP, own numbers are loaded from the SIM card, the loading of own
numbers should be scheduled after the SIM card is ready.
2012-11-02 08:19:30 +01:00