fibocom: new shared interface for common logic

The set_initial_eps_bearer_settings() operation is the same in XMM
capable and generic MBIM modem objects. Place it in a common shared
interface so that we don't duplicate code.
This commit is contained in:
Aleksander Morgado
2022-03-08 15:59:15 +01:00
parent 5fc6b9ee1b
commit c74a377f98
9 changed files with 404 additions and 297 deletions

View File

@@ -513,7 +513,8 @@ MM_ENABLE_PLUGIN([dell],
with_shared_foxconn]) with_shared_foxconn])
MM_ENABLE_PLUGIN([dlink]) MM_ENABLE_PLUGIN([dlink])
MM_ENABLE_PLUGIN([fibocom], MM_ENABLE_PLUGIN([fibocom],
[with_shared_xmm]) [with_shared_fibocom,
with_shared_xmm])
MM_ENABLE_PLUGIN([foxconn], MM_ENABLE_PLUGIN([foxconn],
[with_shared_foxconn]) [with_shared_foxconn])
MM_ENABLE_PLUGIN([gosuncn]) MM_ENABLE_PLUGIN([gosuncn])
@@ -565,6 +566,7 @@ MM_BUILD_SHARED([novatel])
MM_BUILD_SHARED([xmm]) MM_BUILD_SHARED([xmm])
MM_BUILD_SHARED([telit]) MM_BUILD_SHARED([telit])
MM_BUILD_SHARED([foxconn]) MM_BUILD_SHARED([foxconn])
MM_BUILD_SHARED([fibocom])
dnl----------------------------------------------------------------------------- dnl-----------------------------------------------------------------------------
dnl Output dnl Output

View File

@@ -280,6 +280,7 @@ enable_gtk_doc = get_option('gtk_doc')
enable_plugins = not get_option('auto_features').disabled() enable_plugins = not get_option('auto_features').disabled()
plugins_shared_reqs = { plugins_shared_reqs = {
'fibocom': enable_mbim,
'foxconn': enable_mbim, 'foxconn': enable_mbim,
'icera': true, 'icera': true,
'novatel': true, 'novatel': true,
@@ -296,7 +297,7 @@ plugins_options_reqs = {
'cinterion': {'available': true, 'shared': []}, 'cinterion': {'available': true, 'shared': []},
'dell': {'available': true, 'shared': ['foxconn', 'novatel', 'sierra', 'telit', 'xmm']}, 'dell': {'available': true, 'shared': ['foxconn', 'novatel', 'sierra', 'telit', 'xmm']},
'dlink': {'available': true, 'shared': []}, 'dlink': {'available': true, 'shared': []},
'fibocom': {'available': true, 'shared': ['xmm']}, 'fibocom': {'available': true, 'shared': ['fibocom', 'xmm']},
'foxconn': {'available': true, 'shared': ['foxconn']}, 'foxconn': {'available': true, 'shared': ['foxconn']},
'generic': {'available': true, 'shared': []}, 'generic': {'available': true, 'shared': []},
'gosuncn': {'available': true, 'shared': []}, 'gosuncn': {'available': true, 'shared': []},

View File

@@ -446,6 +446,31 @@ FOXCONN_COMMON_COMPILER_FLAGS = -I$(top_srcdir)/plugins/foxconn
endif endif
endif endif
################################################################################
# common fibocom support
################################################################################
# Common Fibocom modem support library (MBIM only)
if WITH_SHARED_FIBOCOM
if WITH_MBIM
pkglib_LTLIBRARIES += libmm-shared-fibocom.la
libmm_shared_fibocom_la_SOURCES = \
fibocom/mm-shared.c \
fibocom/mm-shared-fibocom.h \
fibocom/mm-shared-fibocom.c \
$(NULL)
libmm_shared_fibocom_la_CPPFLAGS = \
$(SHARED_COMMON_COMPILER_FLAGS) \
-DMM_MODULE_NAME=\"shared-fibocom\" \
$(NULL)
libmm_shared_fibocom_la_LDFLAGS = $(SHARED_COMMON_LINKER_FLAGS)
libmm_shared_fibocom_la_LIBADD = $(NULL)
FIBOCOM_COMMON_COMPILER_FLAGS = -I$(top_srcdir)/plugins/fibocom
endif
endif
################################################################################ ################################################################################
# plugin: generic # plugin: generic
################################################################################ ################################################################################
@@ -708,6 +733,7 @@ endif
libmm_plugin_fibocom_la_CPPFLAGS = \ libmm_plugin_fibocom_la_CPPFLAGS = \
$(PLUGIN_COMMON_COMPILER_FLAGS) \ $(PLUGIN_COMMON_COMPILER_FLAGS) \
$(XMM_COMMON_COMPILER_FLAGS) \ $(XMM_COMMON_COMPILER_FLAGS) \
$(FIBOCOM_COMMON_COMPILER_FLAGS) \
-DMM_MODULE_NAME=\"fibocom\" \ -DMM_MODULE_NAME=\"fibocom\" \
$(NULL) $(NULL)
libmm_plugin_fibocom_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS) libmm_plugin_fibocom_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)

View File

@@ -26,157 +26,16 @@
#include "mm-iface-modem.h" #include "mm-iface-modem.h"
#include "mm-iface-modem-3gpp.h" #include "mm-iface-modem-3gpp.h"
#include "mm-broadband-modem-mbim-fibocom.h" #include "mm-broadband-modem-mbim-fibocom.h"
#include "mm-shared-fibocom.h"
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface); static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
static void shared_fibocom_init (MMSharedFibocom *iface);
static MMIfaceModem3gpp *iface_modem_3gpp_parent; static MMIfaceModem3gpp *iface_modem_3gpp_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimFibocom, mm_broadband_modem_mbim_fibocom, MM_TYPE_BROADBAND_MODEM_MBIM, 0, G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimFibocom, mm_broadband_modem_mbim_fibocom, MM_TYPE_BROADBAND_MODEM_MBIM, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)) G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_FIBOCOM, shared_fibocom_init))
/*****************************************************************************/
typedef struct {
MMBearerProperties *config;
gboolean initial_eps_off_on;
} SetInitialEpsBearerSettingsContext;
static void
set_initial_eps_bearer_settings_context_free (SetInitialEpsBearerSettingsContext *ctx)
{
g_clear_object (&ctx->config);
g_slice_free (SetInitialEpsBearerSettingsContext, ctx);
}
static gboolean
modem_3gpp_set_initial_eps_bearer_settings_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error)
{
return g_task_propagate_boolean (G_TASK (res), error);
}
static void
after_attach_apn_modem_power_up_ready (MMIfaceModem *self,
GAsyncResult *res,
GTask *task)
{
GError *error = NULL;
if (!mm_iface_modem_set_power_state_finish (self, res, &error)) {
mm_obj_warn (self, "failed to power up modem after attach APN settings update: %s", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
}
mm_obj_dbg (self, "success toggling modem power up after attach APN");
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
parent_set_initial_eps_bearer_settings_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
GTask *task)
{
SetInitialEpsBearerSettingsContext *ctx;
GError *error = NULL;
ctx = g_task_get_task_data (task);
if (!iface_modem_3gpp_parent->set_initial_eps_bearer_settings_finish (self, res, &error)) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
if (ctx->initial_eps_off_on) {
mm_obj_dbg (self, "toggle modem power up after attach APN");
mm_iface_modem_set_power_state (MM_IFACE_MODEM (self),
MM_MODEM_POWER_STATE_ON,
(GAsyncReadyCallback) after_attach_apn_modem_power_up_ready,
task);
return;
}
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
parent_set_initial_eps_bearer_settings (GTask *task)
{
MMBroadbandModemMbimFibocom *self;
SetInitialEpsBearerSettingsContext *ctx;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
g_assert (iface_modem_3gpp_parent->set_initial_eps_bearer_settings);
g_assert (iface_modem_3gpp_parent->set_initial_eps_bearer_settings_finish);
iface_modem_3gpp_parent->set_initial_eps_bearer_settings (MM_IFACE_MODEM_3GPP (self),
ctx->config,
(GAsyncReadyCallback)parent_set_initial_eps_bearer_settings_ready,
task);
}
static void
before_attach_apn_modem_power_down_ready (MMIfaceModem *self,
GAsyncResult *res,
GTask *task)
{
GError *error = NULL;
if (!mm_iface_modem_set_power_state_finish (self, res, &error)) {
mm_obj_warn (self, "failed to power down modem before attach APN settings update: %s", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
}
mm_obj_dbg (self, "success toggling modem power down before attach APN");
parent_set_initial_eps_bearer_settings (task);
}
static void
modem_3gpp_set_initial_eps_bearer_settings (MMIfaceModem3gpp *self,
MMBearerProperties *config,
GAsyncReadyCallback callback,
gpointer user_data)
{
SetInitialEpsBearerSettingsContext *ctx;
GTask *task;
MMPortMbim *port;
task = g_task_new (self, NULL, callback, user_data);
port = mm_broadband_modem_mbim_peek_port_mbim (MM_BROADBAND_MODEM_MBIM (self));
if (!port) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"No valid MBIM port found");
g_object_unref (task);
return;
}
ctx = g_slice_new0 (SetInitialEpsBearerSettingsContext);
ctx->config = g_object_ref (config);
ctx->initial_eps_off_on = mm_kernel_device_get_property_as_boolean (mm_port_peek_kernel_device (MM_PORT (port)), "ID_MM_FIBOCOM_INITIAL_EPS_OFF_ON");
g_task_set_task_data (task, ctx, (GDestroyNotify)set_initial_eps_bearer_settings_context_free);
if (ctx->initial_eps_off_on) {
mm_obj_dbg (self, "toggle modem power down before attach APN");
mm_iface_modem_set_power_state (MM_IFACE_MODEM (self),
MM_MODEM_POWER_STATE_LOW,
(GAsyncReadyCallback) before_attach_apn_modem_power_down_ready,
task);
return;
}
parent_set_initial_eps_bearer_settings (task);
}
/******************************************************************************/ /******************************************************************************/
@@ -215,8 +74,20 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
{ {
iface_modem_3gpp_parent = g_type_interface_peek_parent (iface); iface_modem_3gpp_parent = g_type_interface_peek_parent (iface);
iface->set_initial_eps_bearer_settings = modem_3gpp_set_initial_eps_bearer_settings; iface->set_initial_eps_bearer_settings = mm_shared_fibocom_set_initial_eps_bearer_settings;
iface->set_initial_eps_bearer_settings_finish = modem_3gpp_set_initial_eps_bearer_settings_finish; iface->set_initial_eps_bearer_settings_finish = mm_shared_fibocom_set_initial_eps_bearer_settings_finish;
}
static MMIfaceModem3gpp *
peek_parent_3gpp_interface (MMSharedFibocom *self)
{
return iface_modem_3gpp_parent;
}
static void
shared_fibocom_init (MMSharedFibocom *iface)
{
iface->peek_parent_3gpp_interface = peek_parent_3gpp_interface;
} }
static void static void

View File

@@ -26,157 +26,16 @@
#include "mm-iface-modem.h" #include "mm-iface-modem.h"
#include "mm-iface-modem-3gpp.h" #include "mm-iface-modem-3gpp.h"
#include "mm-broadband-modem-mbim-xmm-fibocom.h" #include "mm-broadband-modem-mbim-xmm-fibocom.h"
#include "mm-shared-fibocom.h"
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface); static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
static void shared_fibocom_init (MMSharedFibocom *iface);
static MMIfaceModem3gpp *iface_modem_3gpp_parent; static MMIfaceModem3gpp *iface_modem_3gpp_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimXmmFibocom, mm_broadband_modem_mbim_xmm_fibocom, MM_TYPE_BROADBAND_MODEM_MBIM_XMM, 0, G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimXmmFibocom, mm_broadband_modem_mbim_xmm_fibocom, MM_TYPE_BROADBAND_MODEM_MBIM_XMM, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)) G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_FIBOCOM, shared_fibocom_init))
/*****************************************************************************/
typedef struct {
MMBearerProperties *config;
gboolean initial_eps_off_on;
} SetInitialEpsBearerSettingsContext;
static void
set_initial_eps_bearer_settings_context_free (SetInitialEpsBearerSettingsContext *ctx)
{
g_clear_object (&ctx->config);
g_slice_free (SetInitialEpsBearerSettingsContext, ctx);
}
static gboolean
modem_3gpp_set_initial_eps_bearer_settings_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error)
{
return g_task_propagate_boolean (G_TASK (res), error);
}
static void
after_attach_apn_modem_power_up_ready (MMIfaceModem *self,
GAsyncResult *res,
GTask *task)
{
GError *error = NULL;
if (!mm_iface_modem_set_power_state_finish (self, res, &error)) {
mm_obj_warn (self, "failed to power up modem after attach APN settings update: %s", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
}
mm_obj_dbg (self, "success toggling modem power up after attach APN");
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
parent_set_initial_eps_bearer_settings_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
GTask *task)
{
SetInitialEpsBearerSettingsContext *ctx;
GError *error = NULL;
ctx = g_task_get_task_data (task);
if (!iface_modem_3gpp_parent->set_initial_eps_bearer_settings_finish (self, res, &error)) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
if (ctx->initial_eps_off_on) {
mm_obj_dbg (self, "toggle modem power up after attach APN");
mm_iface_modem_set_power_state (MM_IFACE_MODEM (self),
MM_MODEM_POWER_STATE_ON,
(GAsyncReadyCallback) after_attach_apn_modem_power_up_ready,
task);
return;
}
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
parent_set_initial_eps_bearer_settings (GTask *task)
{
MMBroadbandModemMbimXmmFibocom *self;
SetInitialEpsBearerSettingsContext *ctx;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
g_assert (iface_modem_3gpp_parent->set_initial_eps_bearer_settings);
g_assert (iface_modem_3gpp_parent->set_initial_eps_bearer_settings_finish);
iface_modem_3gpp_parent->set_initial_eps_bearer_settings (MM_IFACE_MODEM_3GPP (self),
ctx->config,
(GAsyncReadyCallback)parent_set_initial_eps_bearer_settings_ready,
task);
}
static void
before_attach_apn_modem_power_down_ready (MMIfaceModem *self,
GAsyncResult *res,
GTask *task)
{
GError *error = NULL;
if (!mm_iface_modem_set_power_state_finish (self, res, &error)) {
mm_obj_warn (self, "failed to power down modem before attach APN settings update: %s", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
}
mm_obj_dbg (self, "success toggling modem power down before attach APN");
parent_set_initial_eps_bearer_settings (task);
}
static void
modem_3gpp_set_initial_eps_bearer_settings (MMIfaceModem3gpp *self,
MMBearerProperties *config,
GAsyncReadyCallback callback,
gpointer user_data)
{
SetInitialEpsBearerSettingsContext *ctx;
GTask *task;
MMPortMbim *port;
task = g_task_new (self, NULL, callback, user_data);
port = mm_broadband_modem_mbim_peek_port_mbim (MM_BROADBAND_MODEM_MBIM (self));
if (!port) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"No valid MBIM port found");
g_object_unref (task);
return;
}
ctx = g_slice_new0 (SetInitialEpsBearerSettingsContext);
ctx->config = g_object_ref (config);
ctx->initial_eps_off_on = mm_kernel_device_get_property_as_boolean (mm_port_peek_kernel_device (MM_PORT (port)), "ID_MM_FIBOCOM_INITIAL_EPS_OFF_ON");
g_task_set_task_data (task, ctx, (GDestroyNotify)set_initial_eps_bearer_settings_context_free);
if (ctx->initial_eps_off_on) {
mm_obj_dbg (self, "toggle modem power down before attach APN");
mm_iface_modem_set_power_state (MM_IFACE_MODEM (self),
MM_MODEM_POWER_STATE_LOW,
(GAsyncReadyCallback) before_attach_apn_modem_power_down_ready,
task);
return;
}
parent_set_initial_eps_bearer_settings (task);
}
/******************************************************************************/ /******************************************************************************/
@@ -215,8 +74,20 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
{ {
iface_modem_3gpp_parent = g_type_interface_peek_parent (iface); iface_modem_3gpp_parent = g_type_interface_peek_parent (iface);
iface->set_initial_eps_bearer_settings = modem_3gpp_set_initial_eps_bearer_settings; iface->set_initial_eps_bearer_settings = mm_shared_fibocom_set_initial_eps_bearer_settings;
iface->set_initial_eps_bearer_settings_finish = modem_3gpp_set_initial_eps_bearer_settings_finish; iface->set_initial_eps_bearer_settings_finish = mm_shared_fibocom_set_initial_eps_bearer_settings_finish;
}
static MMIfaceModem3gpp *
peek_parent_3gpp_interface (MMSharedFibocom *self)
{
return iface_modem_3gpp_parent;
}
static void
shared_fibocom_init (MMSharedFibocom *iface)
{
iface->peek_parent_3gpp_interface = peek_parent_3gpp_interface;
} }
static void static void

View File

@@ -0,0 +1,246 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2022 Fibocom Wireless Inc.
*/
#include <config.h>
#include <arpa/inet.h>
#include <glib-object.h>
#include <gio/gio.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-log-object.h"
#include "mm-broadband-modem.h"
#include "mm-broadband-modem-mbim.h"
#include "mm-iface-modem.h"
#include "mm-iface-modem-3gpp.h"
#include "mm-shared-fibocom.h"
/*****************************************************************************/
/* Private data context */
#define PRIVATE_TAG "shared-intel-private-tag"
static GQuark private_quark;
typedef struct {
/* 3GPP interface support */
MMIfaceModem3gpp *iface_modem_3gpp_parent;
} Private;
static void
private_free (Private *priv)
{
g_slice_free (Private, priv);
}
static Private *
get_private (MMSharedFibocom *self)
{
Private *priv;
if (G_UNLIKELY (!private_quark))
private_quark = g_quark_from_static_string (PRIVATE_TAG);
priv = g_object_get_qdata (G_OBJECT (self), private_quark);
if (!priv) {
priv = g_slice_new0 (Private);
/* Setup parent class' MMIfaceModem3gpp */
g_assert (MM_SHARED_FIBOCOM_GET_INTERFACE (self)->peek_parent_3gpp_interface);
priv->iface_modem_3gpp_parent = MM_SHARED_FIBOCOM_GET_INTERFACE (self)->peek_parent_3gpp_interface (self);
g_object_set_qdata_full (G_OBJECT (self), private_quark, priv, (GDestroyNotify)private_free);
}
return priv;
}
/*****************************************************************************/
typedef struct {
MMBearerProperties *config;
gboolean initial_eps_off_on;
} SetInitialEpsBearerSettingsContext;
static void
set_initial_eps_bearer_settings_context_free (SetInitialEpsBearerSettingsContext *ctx)
{
g_clear_object (&ctx->config);
g_slice_free (SetInitialEpsBearerSettingsContext, ctx);
}
gboolean
mm_shared_fibocom_set_initial_eps_bearer_settings_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error)
{
return g_task_propagate_boolean (G_TASK (res), error);
}
static void
after_attach_apn_modem_power_up_ready (MMIfaceModem *self,
GAsyncResult *res,
GTask *task)
{
GError *error = NULL;
if (!mm_iface_modem_set_power_state_finish (self, res, &error)) {
mm_obj_warn (self, "failed to power up modem after attach APN settings update: %s", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
}
mm_obj_dbg (self, "success toggling modem power up after attach APN");
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
parent_set_initial_eps_bearer_settings_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
GTask *task)
{
SetInitialEpsBearerSettingsContext *ctx;
Private *priv;
GError *error = NULL;
ctx = g_task_get_task_data (task);
priv = get_private (MM_SHARED_FIBOCOM (self));
if (!priv->iface_modem_3gpp_parent->set_initial_eps_bearer_settings_finish (self, res, &error)) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
if (ctx->initial_eps_off_on) {
mm_obj_dbg (self, "toggle modem power up after attach APN");
mm_iface_modem_set_power_state (MM_IFACE_MODEM (self),
MM_MODEM_POWER_STATE_ON,
(GAsyncReadyCallback) after_attach_apn_modem_power_up_ready,
task);
return;
}
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
parent_set_initial_eps_bearer_settings (GTask *task)
{
MMSharedFibocom *self;
SetInitialEpsBearerSettingsContext *ctx;
Private *priv;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
priv = get_private (self);
g_assert (priv->iface_modem_3gpp_parent);
g_assert (priv->iface_modem_3gpp_parent->set_initial_eps_bearer_settings);
g_assert (priv->iface_modem_3gpp_parent->set_initial_eps_bearer_settings_finish);
priv->iface_modem_3gpp_parent->set_initial_eps_bearer_settings (MM_IFACE_MODEM_3GPP (self),
ctx->config,
(GAsyncReadyCallback)parent_set_initial_eps_bearer_settings_ready,
task);
}
static void
before_attach_apn_modem_power_down_ready (MMIfaceModem *self,
GAsyncResult *res,
GTask *task)
{
GError *error = NULL;
if (!mm_iface_modem_set_power_state_finish (self, res, &error)) {
mm_obj_warn (self, "failed to power down modem before attach APN settings update: %s", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
}
mm_obj_dbg (self, "success toggling modem power down before attach APN");
parent_set_initial_eps_bearer_settings (task);
}
void
mm_shared_fibocom_set_initial_eps_bearer_settings (MMIfaceModem3gpp *self,
MMBearerProperties *config,
GAsyncReadyCallback callback,
gpointer user_data)
{
SetInitialEpsBearerSettingsContext *ctx;
GTask *task;
MMPortMbim *port;
task = g_task_new (self, NULL, callback, user_data);
/* This shared logic is only expected in MBIM capable devices */
g_assert (MM_IS_BROADBAND_MODEM_MBIM (self));
port = mm_broadband_modem_mbim_peek_port_mbim (MM_BROADBAND_MODEM_MBIM (self));
if (!port) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"No valid MBIM port found");
g_object_unref (task);
return;
}
ctx = g_slice_new0 (SetInitialEpsBearerSettingsContext);
ctx->config = g_object_ref (config);
ctx->initial_eps_off_on = mm_kernel_device_get_property_as_boolean (mm_port_peek_kernel_device (MM_PORT (port)), "ID_MM_FIBOCOM_INITIAL_EPS_OFF_ON");
g_task_set_task_data (task, ctx, (GDestroyNotify)set_initial_eps_bearer_settings_context_free);
if (ctx->initial_eps_off_on) {
mm_obj_dbg (self, "toggle modem power down before attach APN");
mm_iface_modem_set_power_state (MM_IFACE_MODEM (self),
MM_MODEM_POWER_STATE_LOW,
(GAsyncReadyCallback) before_attach_apn_modem_power_down_ready,
task);
return;
}
parent_set_initial_eps_bearer_settings (task);
}
/*****************************************************************************/
static void
shared_fibocom_init (gpointer g_iface)
{
}
GType
mm_shared_fibocom_get_type (void)
{
static GType shared_fibocom_type = 0;
if (!G_UNLIKELY (shared_fibocom_type)) {
static const GTypeInfo info = {
sizeof (MMSharedFibocom), /* class_size */
shared_fibocom_init, /* base_init */
NULL, /* base_finalize */
};
shared_fibocom_type = g_type_register_static (G_TYPE_INTERFACE, "MMSharedFibocom", &info, 0);
g_type_interface_add_prerequisite (shared_fibocom_type, MM_TYPE_IFACE_MODEM);
g_type_interface_add_prerequisite (shared_fibocom_type, MM_TYPE_IFACE_MODEM_3GPP);
}
return shared_fibocom_type;
}

View File

@@ -0,0 +1,53 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2022 Fibocom Wireless Inc.
*/
#ifndef MM_SHARED_FIBOCOM_H
#define MM_SHARED_FIBOCOM_H
#include <glib-object.h>
#include <gio/gio.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-broadband-modem.h"
#include "mm-iface-modem-3gpp.h"
#include "mm-iface-modem.h"
#define MM_TYPE_SHARED_FIBOCOM (mm_shared_fibocom_get_type ())
#define MM_SHARED_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SHARED_FIBOCOM, MMSharedFibocom))
#define MM_IS_SHARED_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SHARED_FIBOCOM))
#define MM_SHARED_FIBOCOM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_SHARED_FIBOCOM, MMSharedFibocom))
typedef struct _MMSharedFibocom MMSharedFibocom;
struct _MMSharedFibocom {
GTypeInterface g_iface;
/* Peek 3GPP interface of the parent class of the object */
MMIfaceModem3gpp * (* peek_parent_3gpp_interface) (MMSharedFibocom *self);
};
GType mm_shared_fibocom_get_type (void);
void mm_shared_fibocom_set_initial_eps_bearer_settings (MMIfaceModem3gpp *self,
MMBearerProperties *config,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_shared_fibocom_set_initial_eps_bearer_settings_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error);
#endif /* MM_SHARED_FIBOCOM_H */

View File

@@ -0,0 +1,20 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2022 Aleksander Morgado <aleksander@aleksander.es>
*/
#include "mm-shared.h"
MM_SHARED_DEFINE_MAJOR_VERSION
MM_SHARED_DEFINE_MINOR_VERSION
MM_SHARED_DEFINE_NAME(Intel)

View File

@@ -53,6 +53,23 @@ if enable_qmi
plugins_deps += qmi_glib_dep plugins_deps += qmi_glib_dep
endif endif
# common Fibocom support library (MBIM only)
if plugins_shared['fibocom']
fibocom_inc = include_directories('fibocom')
c_args = '-DMM_MODULE_NAME="shared-fibocom"'
sources = files(
'fibocom/mm-shared.c',
'fibocom/mm-shared-fibocom.c',
)
plugins += {'shared-fibocom': {
'plugin': false,
'module': {'sources': sources, 'include_directories': plugins_incs, 'c_args': c_args},
}}
endif
# Common Foxconn modem support library (MBIM only) # Common Foxconn modem support library (MBIM only)
if plugins_shared['foxconn'] if plugins_shared['foxconn']
foxconn_inc = include_directories('foxconn') foxconn_inc = include_directories('foxconn')
@@ -350,7 +367,7 @@ if plugins_options['fibocom']
endif endif
plugins += {'plugin-fibocom': { plugins += {'plugin-fibocom': {
'plugin': true, 'plugin': true,
'module': {'sources': sources, 'include_directories': plugins_incs + [xmm_inc], 'c_args': c_args}, 'module': {'sources': sources, 'include_directories': plugins_incs + [xmm_inc] + [fibocom_inc], 'c_args': c_args},
}} }}
plugins_udev_rules += files('fibocom/77-mm-fibocom-port-types.rules') plugins_udev_rules += files('fibocom/77-mm-fibocom-port-types.rules')