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.
This commit is contained in:

committed by
Dan Williams

parent
6026c99f2e
commit
692d076ba6
@@ -341,7 +341,7 @@ dnl-----------------------------------------------------------------------------
|
||||
dnl QMI support (enabled by default)
|
||||
dnl
|
||||
|
||||
LIBQMI_VERSION=1.21.3
|
||||
LIBQMI_VERSION=1.21.4
|
||||
|
||||
AC_ARG_WITH(qmi, AS_HELP_STRING([--without-qmi], [Build without QMI support]), [], [with_qmi=yes])
|
||||
AM_CONDITIONAL(WITH_QMI, test "x$with_qmi" = "xyes")
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -753,6 +753,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)
|
||||
{
|
||||
@@ -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
|
||||
|
@@ -46,6 +46,8 @@ MMModemAccessTechnology mm_modem_access_technologies_from_qmi_radio_interface_ar
|
||||
MMModemAccessTechnology mm_modem_access_technology_from_qmi_data_capability (QmiNasDataCapability cap);
|
||||
MMModemAccessTechnology mm_modem_access_technologies_from_qmi_data_capability_array (GArray *data_capabilities);
|
||||
|
||||
MMModemMode mm_modem_mode_from_qmi_nas_radio_interface (QmiNasRadioInterface iface);
|
||||
|
||||
MMModemMode mm_modem_mode_from_qmi_radio_technology_preference (QmiNasRadioTechnologyPreference qmi);
|
||||
QmiNasRadioTechnologyPreference mm_modem_mode_to_qmi_radio_technology_preference (MMModemMode mode,
|
||||
gboolean is_cdma);
|
||||
@@ -58,6 +60,12 @@ QmiNasRatModePreference mm_modem_mode_to_qmi_rat_mode_preference (MMModemMode mo
|
||||
MMModemCapability mm_modem_capability_from_qmi_rat_mode_preference (QmiNasRatModePreference qmi);
|
||||
QmiNasRatModePreference mm_modem_capability_to_qmi_rat_mode_preference (MMModemCapability caps);
|
||||
|
||||
GArray *mm_modem_capability_to_qmi_acquisition_order_preference (MMModemCapability caps);
|
||||
GArray *mm_modem_mode_to_qmi_acquisition_order_preference (MMModemMode allowed,
|
||||
MMModemMode preferred,
|
||||
gboolean is_cdma,
|
||||
gboolean is_3gpp);
|
||||
|
||||
MMModemCapability mm_modem_capability_from_qmi_radio_technology_preference (QmiNasRadioTechnologyPreference qmi);
|
||||
QmiNasRadioTechnologyPreference mm_modem_capability_to_qmi_radio_technology_preference (MMModemCapability caps);
|
||||
|
||||
|
1267
src/mm-shared-qmi.c
1267
src/mm-shared-qmi.c
File diff suppressed because it is too large
Load Diff
@@ -62,19 +62,60 @@ gboolean mm_shared_qmi_ensure_client (MMSharedQmi *self,
|
||||
|
||||
/* Shared QMI device management support */
|
||||
|
||||
void mm_shared_qmi_reset (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_reset_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_factory_reset (MMIfaceModem *self,
|
||||
const gchar *code,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_factory_reset_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_load_supported_capabilities (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
GArray *mm_shared_qmi_load_supported_capabilities_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_load_current_capabilities (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
MMModemCapability mm_shared_qmi_load_current_capabilities_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_set_current_capabilities (MMIfaceModem *self,
|
||||
MMModemCapability capabilities,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_set_current_capabilities_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_load_supported_modes (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
GArray *mm_shared_qmi_load_supported_modes_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_load_current_modes (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_load_current_modes_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
MMModemMode *allowed,
|
||||
MMModemMode *preferred,
|
||||
GError **error);
|
||||
void mm_shared_qmi_set_current_modes (MMIfaceModem *self,
|
||||
MMModemMode allowed,
|
||||
MMModemMode preferred,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_set_current_modes_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_reset (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_reset_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_factory_reset (MMIfaceModem *self,
|
||||
const gchar *code,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_factory_reset_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Shared QMI location support */
|
||||
|
||||
|
Reference in New Issue
Block a user