aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-10-25 14:23:29 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-11-20 09:24:51 +0000
commitcab4b54ad106caadb7f70025348f0aab5522bde4 (patch)
tree371aa6e24dea912c1952a7334cca73c393199713 /src
parent3d12272d183061c11cd80bfe96ae89898f4c081c (diff)
core: new 'rpmsg' subsystem
Most older Qualcomm SoCs (e.g. MSM8916, MSM8974, ...) communicate with the integrated modem via shared memory (SMD channels). This is similar to QRTR on newer SoCs, but without the "network" layer. In fact, the older SoCs also have QRTR, but the modem QMI services are not exposed there. The mainline Linux kernel exposes SMD channels via the "remote processor messaging bus" (rpmsg). Through special IOCTL calls it is possible to create a char device for a rpmsg/SMD channel. We can then use these to send QMI/AT messages to the modem, much like the ordinary serial char devices when using a Qualcomm modem through USB. This commit introduces support for the new 'rpmsg' subsystem, which allows exporting QMI-capable and AT-capable ports. By default NO rpmsg port is flagged as candidate, it is assumed that the plugin adding support for the rpmsg subsystem will add specific rules to do so (e.g. so that non-modem ports are explicitly not flagged as candidate). All rpmsg ports will be probed for AT or QMI capabilities, unless explicit port type hints (e.g. ID_MM_PORT_TYPE_QMI or ID_MM_PORT_TYPE_AT_PRIMARY) are set. These changes are highly based on the initial integration work done by Stephan Gerhold <stephan@gerhold.net> in postmarketOS, see: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/363
Diffstat (limited to 'src')
-rw-r--r--src/mm-base-modem.c18
-rw-r--r--src/mm-filter.c7
-rw-r--r--src/mm-filter.h23
-rw-r--r--src/mm-plugin.c5
-rw-r--r--src/mm-port-probe.c26
-rw-r--r--src/mm-port.h4
6 files changed, 61 insertions, 22 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index 09227da5..29256f7d 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -238,6 +238,20 @@ base_modem_create_usbmisc_port (MMBaseModem *self,
}
static MMPort *
+base_modem_create_rpmsg_port (MMBaseModem *self,
+ const gchar *name,
+ MMPortType ptype)
+{
+#if defined WITH_QMI
+ if (ptype == MM_PORT_TYPE_QMI)
+ return MM_PORT (mm_port_qmi_new (name, MM_PORT_SUBSYS_RPMSG));
+#endif
+ if (ptype == MM_PORT_TYPE_AT)
+ return MM_PORT (mm_port_serial_at_new (name, MM_PORT_SUBSYS_RPMSG));
+ return NULL;
+}
+
+static MMPort *
base_modem_create_virtual_port (MMBaseModem *self,
const gchar *name)
{
@@ -278,6 +292,8 @@ mm_base_modem_grab_port (MMBaseModem *self,
port = base_modem_create_tty_port (self, name, kernel_device, ptype);
else if (g_str_equal (subsys, "usbmisc"))
port = base_modem_create_usbmisc_port (self, name, ptype);
+ else if (g_str_equal (subsys, "rpmsg"))
+ port = base_modem_create_rpmsg_port (self, name, ptype);
else if (g_str_equal (subsys, "virtual"))
port = base_modem_create_virtual_port (self, name);
@@ -327,8 +343,6 @@ mm_base_modem_grab_port (MMBaseModem *self,
return TRUE;
}
-/******************************************************************************/
-
gboolean
mm_base_modem_disable_finish (MMBaseModem *self,
GAsyncResult *res,
diff --git a/src/mm-filter.c b/src/mm-filter.c
index c5a15312..52575a1c 100644
--- a/src/mm-filter.c
+++ b/src/mm-filter.c
@@ -199,6 +199,13 @@ mm_filter_port (MMFilter *self,
return TRUE;
}
+ /* If this is a rpmsg channel device, we always allow it */
+ if ((self->priv->enabled_rules & MM_FILTER_RULE_RPMSG) &&
+ (g_strcmp0 (subsystem, "rpmsg") == 0)) {
+ mm_obj_dbg (self, "(%s/%s) port allowed: rpmsg device", subsystem, name);
+ return TRUE;
+ }
+
/* If this is a tty device, we may allow it */
if ((self->priv->enabled_rules & MM_FILTER_RULE_TTY) &&
(g_strcmp0 (subsystem, "tty") == 0)) {
diff --git a/src/mm-filter.h b/src/mm-filter.h
index dc5f2bff..8d2e0e22 100644
--- a/src/mm-filter.h
+++ b/src/mm-filter.h
@@ -53,15 +53,16 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/
MM_FILTER_RULE_VIRTUAL = 1 << 3,
MM_FILTER_RULE_NET = 1 << 4,
MM_FILTER_RULE_USBMISC = 1 << 5,
- MM_FILTER_RULE_TTY = 1 << 6,
- MM_FILTER_RULE_TTY_BLACKLIST = 1 << 7,
- MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY = 1 << 8,
- MM_FILTER_RULE_TTY_PLATFORM_DRIVER = 1 << 9,
- MM_FILTER_RULE_TTY_DEFAULT_ALLOWED = 1 << 10,
- MM_FILTER_RULE_TTY_DRIVER = 1 << 11,
- MM_FILTER_RULE_TTY_ACM_INTERFACE = 1 << 12,
- MM_FILTER_RULE_TTY_WITH_NET = 1 << 13,
- MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN = 1 << 14,
+ MM_FILTER_RULE_RPMSG = 1 << 6,
+ MM_FILTER_RULE_TTY = 1 << 7,
+ MM_FILTER_RULE_TTY_BLACKLIST = 1 << 8,
+ MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY = 1 << 9,
+ MM_FILTER_RULE_TTY_PLATFORM_DRIVER = 1 << 10,
+ MM_FILTER_RULE_TTY_DEFAULT_ALLOWED = 1 << 11,
+ MM_FILTER_RULE_TTY_DRIVER = 1 << 12,
+ MM_FILTER_RULE_TTY_ACM_INTERFACE = 1 << 13,
+ MM_FILTER_RULE_TTY_WITH_NET = 1 << 14,
+ MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN = 1 << 15,
} MMFilterRule;
#define MM_FILTER_RULE_ALL \
@@ -71,6 +72,7 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/
MM_FILTER_RULE_VIRTUAL | \
MM_FILTER_RULE_NET | \
MM_FILTER_RULE_USBMISC | \
+ MM_FILTER_RULE_RPMSG | \
MM_FILTER_RULE_TTY | \
MM_FILTER_RULE_TTY_BLACKLIST | \
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY | \
@@ -89,6 +91,7 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/
MM_FILTER_RULE_VIRTUAL | \
MM_FILTER_RULE_NET | \
MM_FILTER_RULE_USBMISC | \
+ MM_FILTER_RULE_RPMSG | \
MM_FILTER_RULE_TTY | \
MM_FILTER_RULE_TTY_BLACKLIST | \
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY | \
@@ -104,6 +107,7 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/
MM_FILTER_RULE_VIRTUAL | \
MM_FILTER_RULE_NET | \
MM_FILTER_RULE_USBMISC | \
+ MM_FILTER_RULE_RPMSG | \
MM_FILTER_RULE_TTY | \
MM_FILTER_RULE_TTY_PLATFORM_DRIVER | \
MM_FILTER_RULE_TTY_DRIVER | \
@@ -120,6 +124,7 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/
MM_FILTER_RULE_VIRTUAL | \
MM_FILTER_RULE_NET | \
MM_FILTER_RULE_USBMISC | \
+ MM_FILTER_RULE_RPMSG | \
MM_FILTER_RULE_TTY | \
MM_FILTER_RULE_TTY_BLACKLIST | \
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY | \
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index be6e39ff..13b46a75 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -781,6 +781,11 @@ mm_plugin_supports_port (MMPlugin *self,
probe_run_flags |= MM_PORT_PROBE_MBIM;
else
probe_run_flags |= MM_PORT_PROBE_AT;
+ } else if (g_str_equal (mm_kernel_device_get_subsystem (port), "rpmsg")) {
+ if (self->priv->at)
+ probe_run_flags |= MM_PORT_PROBE_AT;
+ if (self->priv->qmi)
+ probe_run_flags |= MM_PORT_PROBE_QMI;
}
/* For potential AT ports, check for more things */
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index c6b535b5..d4bffb3e 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -491,16 +491,22 @@ wdm_probe_qmi (MMPortProbe *self)
ctx = g_task_get_task_data (self->priv->task);
#if defined WITH_QMI
- mm_obj_dbg (self, "probing QMI...");
+ {
+ MMPortSubsys subsys = MM_PORT_SUBSYS_USBMISC;
- /* Create a port and try to open it */
- ctx->port_qmi = mm_port_qmi_new (mm_kernel_device_get_name (self->priv->port),
- MM_PORT_SUBSYS_USBMISC);
- mm_port_qmi_open (ctx->port_qmi,
- FALSE,
- NULL,
- (GAsyncReadyCallback) port_qmi_open_ready,
- self);
+ mm_obj_dbg (self, "probing QMI...");
+
+ if (g_str_equal (mm_kernel_device_get_subsystem (self->priv->port), "rpmsg"))
+ subsys = MM_PORT_SUBSYS_RPMSG;
+
+ /* Create a port and try to open it */
+ ctx->port_qmi = mm_port_qmi_new (mm_kernel_device_get_name (self->priv->port), subsys);
+ mm_port_qmi_open (ctx->port_qmi,
+ FALSE,
+ NULL,
+ (GAsyncReadyCallback) port_qmi_open_ready,
+ self);
+ }
#else
/* If not compiled with QMI support, just assume we won't have any QMI port */
mm_port_probe_set_result_qmi (self, FALSE);
@@ -1273,6 +1279,8 @@ serial_open_at (MMPortProbe *self)
if (g_str_equal (mm_kernel_device_get_subsystem (self->priv->port), "usbmisc"))
subsys = MM_PORT_SUBSYS_USBMISC;
+ else if (g_str_equal (mm_kernel_device_get_subsystem (self->priv->port), "rpmsg"))
+ subsys = MM_PORT_SUBSYS_RPMSG;
ctx->serial = MM_PORT_SERIAL (mm_port_serial_at_new (mm_kernel_device_get_name (self->priv->port), subsys));
if (!ctx->serial) {
diff --git a/src/mm-port.h b/src/mm-port.h
index 2d8d1ad6..8295d264 100644
--- a/src/mm-port.h
+++ b/src/mm-port.h
@@ -28,8 +28,8 @@ typedef enum { /*< underscore_name=mm_port_subsys >*/
MM_PORT_SUBSYS_NET,
MM_PORT_SUBSYS_USBMISC,
MM_PORT_SUBSYS_UNIX,
-
- MM_PORT_SUBSYS_LAST = MM_PORT_SUBSYS_UNIX /*< skip >*/
+ MM_PORT_SUBSYS_RPMSG,
+ MM_PORT_SUBSYS_LAST = MM_PORT_SUBSYS_RPMSG /*< skip >*/
} MMPortSubsys;
typedef enum { /*< underscore_name=mm_port_type >*/