api,modem: new 'MaxActiveMultiplexedBearers' property

In addition to the amount of bearers a user may connect without
multiplexing enabled (the default until now), we now also expose the
maximum number of bearers a user may connect after enabling
multiplexing over one single network interface (if supported).

The method responsible for creating the MMBearerList is now also
subclassable, so that implementations supporting multiplexing can
provide their own version with their own thresholds.
This commit is contained in:
Aleksander Morgado
2021-02-25 15:42:35 +01:00
parent 35e20a48c8
commit 05b9ab7c25
9 changed files with 119 additions and 35 deletions

View File

@@ -162,6 +162,7 @@ mm_modem_peek_unlock_retries
mm_modem_get_unlock_retries
mm_modem_get_max_bearers
mm_modem_get_max_active_bearers
mm_modem_get_max_active_multiplexed_bearers
mm_modem_get_bearer_paths
mm_modem_dup_bearer_paths
mm_modem_get_own_numbers
@@ -2105,6 +2106,7 @@ mm_gdbus_modem_dup_equipment_identifier
mm_gdbus_modem_get_manufacturer
mm_gdbus_modem_dup_manufacturer
mm_gdbus_modem_get_max_active_bearers
mm_gdbus_modem_get_max_active_multiplexed_bearers
mm_gdbus_modem_get_max_bearers
mm_gdbus_modem_get_model
mm_gdbus_modem_dup_model
@@ -2193,6 +2195,7 @@ mm_gdbus_modem_set_drivers
mm_gdbus_modem_set_equipment_identifier
mm_gdbus_modem_set_manufacturer
mm_gdbus_modem_set_max_active_bearers
mm_gdbus_modem_set_max_active_multiplexed_bearers
mm_gdbus_modem_set_max_bearers
mm_gdbus_modem_set_model
mm_gdbus_modem_set_own_numbers

View File

@@ -351,14 +351,28 @@
The maximum number of active
<link linkend="MM-BEARER-TYPE-DEFAULT:CAPS"><constant>MM_BEARER_TYPE_DEFAULT</constant></link>
bearers that may be explicitly enabled by the user.
bearers that may be explicitly enabled by the user without multiplexing support.
POTS and CDMA2000-only devices support one active bearer, while GSM/UMTS
and LTE-capable devices (including LTE/CDMA devices) typically support
at least two active bearers.
and LTE/5GNR capable devices (including 3GPP+3GPP3 multimode devices) may support
one or more active bearers, depending on the amount of physical ports exposed
by the device.
-->
<property name="MaxActiveBearers" type="u" access="read" />
<!--
MaxActiveMultiplexedBearers:
The maximum number of active
<link linkend="MM-BEARER-TYPE-DEFAULT:CAPS"><constant>MM_BEARER_TYPE_DEFAULT</constant></link>
bearers that may be explicitly enabled by the user with multiplexing support
on one single network interface.
If the modem doesn't support multiplexing of data sessiones, a value of 0 will
be reported.
-->
<property name="MaxActiveMultiplexedBearers" type="u" access="read" />
<!--
Manufacturer:

View File

@@ -436,13 +436,15 @@ mm_modem_get_max_bearers (MMModem *self)
* mm_modem_get_max_active_bearers:
* @self: a #MMModem.
*
* Gets the maximum number of active packet data bearers this #MMModem supports.
* Gets the maximum number of active packet data bearers this #MMModem supports
* without enabling multiplexing support.
*
* POTS and CDMA2000-only devices support one active bearer, while GSM/UMTS
* and LTE-capable devices (including LTE/CDMA devices) typically support
* at least two active bearers.
* and LTE/5GNR capable devices (including 3GPP+3GPP3 multimode devices) may support
* one or more active bearers, depending on the amount of physical ports exposed
* by the device.
*
* Returns: the maximum number of defined packet data bearers.
* Returns: the maximum number of active packet data bearers.
*
* Since: 1.0
*/
@@ -456,6 +458,28 @@ mm_modem_get_max_active_bearers (MMModem *self)
/*****************************************************************************/
/**
* mm_modem_get_max_active_multiplexed_bearers:
* @self: a #MMModem.
*
* Gets the maximum number of active packet data bearers this #MMModem supports
* after enabling multiplexing support on one single network interface.
*
* Returns: the maximum number of active packet data bearers, or 0 if
* multiplexing is not supported.
*
* Since: 1.18
*/
guint
mm_modem_get_max_active_multiplexed_bearers (MMModem *self)
{
g_return_val_if_fail (MM_IS_MODEM (self), 0);
return mm_gdbus_modem_get_max_active_multiplexed_bearers (MM_GDBUS_MODEM (self));
}
/*****************************************************************************/
/**
* mm_modem_get_bearer_paths:
* @self: A #MMModem.

View File

@@ -94,7 +94,8 @@ G_DEPRECATED
guint mm_modem_get_max_bearers (MMModem *self);
#endif /* MM_DISABLE_DEPRECATED */
guint mm_modem_get_max_active_bearers (MMModem *self);
guint mm_modem_get_max_active_bearers (MMModem *self);
guint mm_modem_get_max_active_multiplexed_bearers (MMModem *self);
const gchar * const *mm_modem_get_bearer_paths (MMModem *self);
gchar **mm_modem_dup_bearer_paths (MMModem *self);

View File

@@ -35,6 +35,7 @@ enum {
PROP_0,
PROP_NUM_BEARERS,
PROP_MAX_ACTIVE_BEARERS,
PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS,
PROP_LAST
};
@@ -45,6 +46,7 @@ struct _MMBearerListPrivate {
GList *bearers;
/* Max number of active bearers */
guint max_active_bearers;
guint max_active_multiplexed_bearers;
};
/*****************************************************************************/
@@ -55,6 +57,12 @@ mm_bearer_list_get_max_active (MMBearerList *self)
return self->priv->max_active_bearers;
}
guint
mm_bearer_list_get_max_active_multiplexed (MMBearerList *self)
{
return self->priv->max_active_multiplexed_bearers;
}
gboolean
mm_bearer_list_add_bearer (MMBearerList *self,
MMBaseBearer *bearer,
@@ -238,11 +246,13 @@ mm_bearer_list_disconnect_all_bearers (MMBearerList *self,
/*****************************************************************************/
MMBearerList *
mm_bearer_list_new (guint max_active_bearers)
mm_bearer_list_new (guint max_active_bearers,
guint max_active_multiplexed_bearers)
{
/* Create the object */
return g_object_new (MM_TYPE_BEARER_LIST,
MM_BEARER_LIST_MAX_ACTIVE_BEARERS, max_active_bearers,
MM_BEARER_LIST_MAX_ACTIVE_MULTIPLEXED_BEARERS, max_active_multiplexed_bearers,
NULL);
}
@@ -261,6 +271,9 @@ set_property (GObject *object,
case PROP_MAX_ACTIVE_BEARERS:
self->priv->max_active_bearers = g_value_get_uint (value);
break;
case PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS:
self->priv->max_active_multiplexed_bearers = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -282,6 +295,9 @@ get_property (GObject *object,
case PROP_MAX_ACTIVE_BEARERS:
g_value_set_uint (value, self->priv->max_active_bearers);
break;
case PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS:
g_value_set_uint (value, self->priv->max_active_multiplexed_bearers);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -342,4 +358,13 @@ mm_bearer_list_class_init (MMBearerListClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_MAX_ACTIVE_BEARERS, properties[PROP_MAX_ACTIVE_BEARERS]);
properties[PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS] =
g_param_spec_uint (MM_BEARER_LIST_MAX_ACTIVE_MULTIPLEXED_BEARERS,
"Max active multiplexed bearers",
"Maximum number of active multiplexed bearers the list can handle",
1,
G_MAXUINT,
1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS, properties[PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS]);
}

View File

@@ -30,8 +30,9 @@
#define MM_IS_BEARER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BEARER_LIST))
#define MM_BEARER_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER_LIST, MMBearerListClass))
#define MM_BEARER_LIST_NUM_BEARERS "num-bearers"
#define MM_BEARER_LIST_MAX_ACTIVE_BEARERS "max-active-bearers"
#define MM_BEARER_LIST_NUM_BEARERS "num-bearers"
#define MM_BEARER_LIST_MAX_ACTIVE_BEARERS "max-active-bearers"
#define MM_BEARER_LIST_MAX_ACTIVE_MULTIPLEXED_BEARERS "max-active-multiplexed-bearers"
typedef struct _MMBearerList MMBearerList;
typedef struct _MMBearerListClass MMBearerListClass;
@@ -49,10 +50,12 @@ struct _MMBearerListClass {
GType mm_bearer_list_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMBearerList, g_object_unref)
MMBearerList *mm_bearer_list_new (guint max_active_bearers);
MMBearerList *mm_bearer_list_new (guint max_active_bearers,
guint max_active_multiplexed_bearers);
GStrv mm_bearer_list_get_paths (MMBearerList *self);
guint mm_bearer_list_get_max_active (MMBearerList *self);
GStrv mm_bearer_list_get_paths (MMBearerList *self);
guint mm_bearer_list_get_max_active (MMBearerList *self);
guint mm_bearer_list_get_max_active_multiplexed (MMBearerList *self);
gboolean mm_bearer_list_add_bearer (MMBearerList *self,
MMBaseBearer *bearer,

View File

@@ -417,6 +417,23 @@ modem_create_bearer (MMIfaceModem *self,
task);
}
/*****************************************************************************/
/* Create Bearer List (Modem interface) */
static MMBearerList *
modem_create_bearer_list (MMIfaceModem *self)
{
guint n;
/* The maximum number of available/connected modems is guessed from
* the size of the data ports list. */
n = g_list_length (mm_base_modem_peek_data_ports (MM_BASE_MODEM (self)));
mm_obj_dbg (self, "allowed up to %u active bearers", n);
/* by default, no multiplexing support */
return mm_bearer_list_new (n, 0);
}
/*****************************************************************************/
/* Create SIM (Modem interface) */
@@ -12425,6 +12442,7 @@ iface_modem_init (MMIfaceModem *iface)
iface->load_power_state_finish = modem_load_power_state_finish;
iface->load_supported_ip_families = modem_load_supported_ip_families;
iface->load_supported_ip_families_finish = modem_load_supported_ip_families_finish;
iface->create_bearer_list = modem_create_bearer_list;
/* Enabling steps */
iface->modem_power_up = modem_power_up;

View File

@@ -5083,47 +5083,38 @@ interface_initialization_step (GTask *task)
/* fall-through */
case INITIALIZATION_STEP_BEARERS: {
MMBearerList *list = NULL;
g_autoptr(MMBearerList) list = NULL;
/* Bearers setup is meant to be loaded only once during the whole
* lifetime of the modem. The list may have been created by the object
* implementing the interface; if so use it. */
* lifetime of the modem, so check if it exists; and if it doesn't,
* create it right away. */
g_object_get (self,
MM_IFACE_MODEM_BEARER_LIST, &list,
NULL);
if (!list) {
guint n;
/* The maximum number of available/connected modems is guessed from
* the size of the data ports list. */
n = g_list_length (mm_base_modem_peek_data_ports (MM_BASE_MODEM (self)));
mm_obj_dbg (self, "allowed up to %u active bearers", n);
/* Create new default list */
list = mm_bearer_list_new (n);
list = MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer_list (self);
g_signal_connect (list,
"notify::" MM_BEARER_LIST_NUM_BEARERS,
G_CALLBACK (bearer_list_updated),
self);
g_object_set (self,
MM_IFACE_MODEM_BEARER_LIST, list,
NULL);
}
if (mm_gdbus_modem_get_max_active_bearers (ctx->skeleton) == 0)
mm_gdbus_modem_set_max_active_bearers (
ctx->skeleton,
mm_bearer_list_get_max_active (list));
mm_gdbus_modem_set_max_active_multiplexed_bearers (
ctx->skeleton,
mm_bearer_list_get_max_active_multiplexed (list));
/* MaxBearers set equal to MaxActiveBearers */
if (mm_gdbus_modem_get_max_bearers (ctx->skeleton) == 0)
/* MaxBearers set equal to MaxActiveBearers */
mm_gdbus_modem_set_max_bearers (
ctx->skeleton,
mm_gdbus_modem_get_max_active_bearers (ctx->skeleton));
g_object_unref (list);
g_object_set (self,
MM_IFACE_MODEM_BEARER_LIST, list,
NULL);
}
ctx->step++;
} /* fall-through */

View File

@@ -26,6 +26,7 @@
#include "mm-port-serial-at.h"
#include "mm-base-bearer.h"
#include "mm-base-sim.h"
#include "mm-bearer-list.h"
#define MM_TYPE_IFACE_MODEM (mm_iface_modem_get_type ())
#define MM_IFACE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM, MMIfaceModem))
@@ -372,6 +373,10 @@ struct _MMIfaceModem {
MMBaseBearer * (*create_bearer_finish) (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
/* Create new bearer list object */
MMBearerList * (* create_bearer_list) (MMIfaceModem *self);
/* Setup SIM hot swap */
void (*setup_sim_hot_swap) (MMIfaceModem *self,
GAsyncReadyCallback callback,