aboutsummaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-07-15 22:54:18 +0200
committerDan Williams <dcbw@redhat.com>2018-09-12 17:25:19 +0000
commit692d076ba68e09bcad146d78109d4a59e1563918 (patch)
treeb736525a272432333658ad054c94857264f2b1b1 /src/mm-modem-helpers-qmi.c
parent6026c99f2ec99e2721356ee645472d8403676bf6 (diff)
shared-qmi: implement reworked mode and capabilities management
This commit introduces several improvements and changes in the way modes and capabilities are managed in QMI capable devices. It is organized into a single commit, as all changes in all 6 operations (load current capabilities, load supported capabilities, set current capabilities, load supported modes, load current modes, set current modes) are related one to the other (given that the same QMI commands are used for both capabilities and mode management). The primary change is related to which capabilities are reported as supported for a given device. In the previous implementation we allowed switching between every combination possible for GSM/UMTS+LTE, CDMA/EVDO+LTE or GSM/UMTS+CDMA/EVDO+LTE devices. E.g. we would allow "LTE only" and "GSM/UMTS only" capabilities for GSM/UMTS+LTE devices, even if they would both be managed in exactly the same way. That setup wasn't ideal, because it meant that switching to a "LTE only" configuration would require a power cycle, as capability switching requires a power cycle, even if no change was expected in the exposed DBus interfaces (which is why we require the power cycle). So, instead of allowing every possible capability combination, we use capability switching logic exclusively for configuring GSM/UMTS+CDMA/EVDO devices (regardless of whether it has LTE or not) to add or remove the GSM/UMTS and CDMA/EVDO capabilities. E.g. for a GSM/UMTS+CDMA/EVDO+LTE device we would allow 3 combinatios: "GSM/UMTS+LTE", "CDMA/EVDO+LTE" and "GSM/UMTS+CDMA/EVDO+LTE". The "GSM/UMTS+CDMA/EVDO+LTE" is a special case because for this one we allow switching to "LTE only" capabilities while we forbid switching to "4G only" mode. As the same commands are used for mode and capability switching, if we didn't have "LTE only" and we allowed "4G only" mode instead and rebooted the device, we would end up not being able to know which other capabilities (GSM/UMTS or CDMA/EVDO or both) were also enabled. Now that we have capability switching confined to a very subset of combinations, we can use the mode switching logic to e.g. allow "4G only" configurations in all non multimode devices, as well as masks of allowed modes with one being preferred, which we didn't allow before. In the previous implementation all mode switching logic was disabled for LTE capable QMI devices. In the new implementation, we use the "Acquisition Order Preference" TLV in NAS Set System Selection Preference to define the full list of mode preferences for all supported modes. We also no longer just assume that NAS Technology Preference is always available and NAS System Selection Preference only after NAS >= 1.1. This logic is flawed, instead we're going to probe for those features once when loading current capabilities, and we then just implement the capabilities/mode switching logic based on that.
Diffstat (limited to 'src/mm-modem-helpers-qmi.c')
-rw-r--r--src/mm-modem-helpers-qmi.c131
1 files changed, 125 insertions, 6 deletions
diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c
index ccc2a912..5df34478 100644
--- a/src/mm-modem-helpers-qmi.c
+++ b/src/mm-modem-helpers-qmi.c
@@ -754,6 +754,25 @@ mm_modem_access_technologies_from_qmi_data_capability_array (GArray *data_capabi
/*****************************************************************************/
MMModemMode
+mm_modem_mode_from_qmi_nas_radio_interface (QmiNasRadioInterface iface)
+{
+ switch (iface) {
+ case QMI_NAS_RADIO_INTERFACE_CDMA_1X:
+ case QMI_NAS_RADIO_INTERFACE_GSM:
+ return MM_MODEM_MODE_2G;
+ case QMI_NAS_RADIO_INTERFACE_CDMA_1XEVDO:
+ case QMI_NAS_RADIO_INTERFACE_UMTS:
+ return MM_MODEM_MODE_3G;
+ case QMI_NAS_RADIO_INTERFACE_LTE:
+ return MM_MODEM_MODE_4G;
+ default:
+ return MM_MODEM_MODE_NONE;
+ }
+}
+
+/*****************************************************************************/
+
+MMModemMode
mm_modem_mode_from_qmi_radio_technology_preference (QmiNasRadioTechnologyPreference qmi)
{
MMModemMode mode = MM_MODEM_MODE_NONE;
@@ -909,6 +928,94 @@ mm_modem_capability_to_qmi_rat_mode_preference (MMModemCapability caps)
/*****************************************************************************/
+GArray *
+mm_modem_capability_to_qmi_acquisition_order_preference (MMModemCapability caps)
+{
+ GArray *array;
+ QmiNasRadioInterface value;
+
+ array = g_array_new (FALSE, FALSE, sizeof (QmiNasRadioInterface));
+
+ if (caps & MM_MODEM_CAPABILITY_LTE) {
+ value = QMI_NAS_RADIO_INTERFACE_LTE;
+ g_array_append_val (array, value);
+ }
+
+ if (caps & MM_MODEM_CAPABILITY_GSM_UMTS) {
+ value = QMI_NAS_RADIO_INTERFACE_UMTS;
+ g_array_append_val (array, value);
+ value = QMI_NAS_RADIO_INTERFACE_GSM;
+ g_array_append_val (array, value);
+ }
+
+ if (caps & MM_MODEM_CAPABILITY_CDMA_EVDO) {
+ value = QMI_NAS_RADIO_INTERFACE_CDMA_1XEVDO;
+ g_array_append_val (array, value);
+ value = QMI_NAS_RADIO_INTERFACE_CDMA_1X;
+ g_array_append_val (array, value);
+ }
+
+ return array;
+}
+
+GArray *
+mm_modem_mode_to_qmi_acquisition_order_preference (MMModemMode allowed,
+ MMModemMode preferred,
+ gboolean is_cdma,
+ gboolean is_3gpp)
+{
+ GArray *array;
+ QmiNasRadioInterface value;
+
+ array = g_array_new (FALSE, FALSE, sizeof (QmiNasRadioInterface));
+
+ if (allowed & MM_MODEM_MODE_4G) {
+ value = QMI_NAS_RADIO_INTERFACE_LTE;
+ if (preferred == MM_MODEM_MODE_4G)
+ g_array_prepend_val (array, value);
+ else
+ g_array_append_val (array, value);
+ }
+
+ if (allowed & MM_MODEM_MODE_3G) {
+ if (is_cdma) {
+ value = QMI_NAS_RADIO_INTERFACE_CDMA_1XEVDO;
+ if (preferred == MM_MODEM_MODE_3G)
+ g_array_prepend_val (array, value);
+ else
+ g_array_append_val (array, value);
+ }
+ if (is_3gpp) {
+ value = QMI_NAS_RADIO_INTERFACE_UMTS;
+ if (preferred == MM_MODEM_MODE_3G)
+ g_array_prepend_val (array, value);
+ else
+ g_array_append_val (array, value);
+ }
+ }
+
+ if (allowed & MM_MODEM_MODE_2G) {
+ if (is_cdma) {
+ value = QMI_NAS_RADIO_INTERFACE_CDMA_1X;
+ if (preferred == MM_MODEM_MODE_2G)
+ g_array_prepend_val (array, value);
+ else
+ g_array_append_val (array, value);
+ }
+ if (is_3gpp) {
+ value = QMI_NAS_RADIO_INTERFACE_GSM;
+ if (preferred == MM_MODEM_MODE_2G)
+ g_array_prepend_val (array, value);
+ else
+ g_array_append_val (array, value);
+ }
+ }
+
+ return array;
+}
+
+/*****************************************************************************/
+
MMModemCapability
mm_modem_capability_from_qmi_radio_technology_preference (QmiNasRadioTechnologyPreference qmi)
{
@@ -1200,6 +1307,15 @@ mm_bearer_allowed_auth_to_qmi_authentication (MMBearerAllowedAuth auth)
/*****************************************************************************/
+/**
+ * The only case where we need to apply some logic to decide what the current
+ * capabilities are is when we have a multimode CDMA/EVDO+GSM/UMTS device, in
+ * which case we'll check the SSP and TP current values to decide which
+ * capabilities are present and which have been disabled.
+ *
+ * For all the other cases, the DMS capabilities are exactly the current ones,
+ * as there would be no capability switching support.
+ */
MMModemCapability
mm_modem_capability_from_qmi_capabilities_context (MMQmiCapabilitiesContext *ctx)
{
@@ -1209,16 +1325,19 @@ mm_modem_capability_from_qmi_capabilities_context (MMQmiCapabilitiesContext *ctx
gchar *dms_capabilities_str;
gchar *tmp_str;
- /* SSP logic to gather capabilities uses the Mode Preference TLV if available,
- * and if not available it falls back to using Band Preference TLVs */
+ /* If not a multimode device, we're done */
+#define MULTIMODE (MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_CDMA_EVDO)
+ if ((ctx->dms_capabilities & MULTIMODE) != MULTIMODE)
+ return ctx->dms_capabilities;
+
+ /* We have a multimode CDMA/EVDO+GSM/UMTS device, check SSP and TP */
+
+ /* SSP logic to gather capabilities uses the Mode Preference TLV if available */
if (ctx->nas_ssp_mode_preference_mask)
tmp = mm_modem_capability_from_qmi_rat_mode_preference (ctx->nas_ssp_mode_preference_mask);
-
/* If no value retrieved from SSP, check TP. We only process TP
* values if not 'auto'. */
- if ( tmp == MM_MODEM_CAPABILITY_NONE
- && ctx->nas_tp_mask
- && ctx->nas_tp_mask != QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO)
+ else if (ctx->nas_tp_mask && (ctx->nas_tp_mask != QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO))
tmp = mm_modem_capability_from_qmi_radio_technology_preference (ctx->nas_tp_mask);
/* Final capabilities are the intersection between the Technology