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
This commit is contained in:
@@ -444,7 +444,7 @@ get_manager_ready (GObject *source,
|
|||||||
|
|
||||||
#if defined WITH_UDEV
|
#if defined WITH_UDEV
|
||||||
if (report_kernel_event_auto_scan) {
|
if (report_kernel_event_auto_scan) {
|
||||||
const gchar *subsys[] = { "tty", "usbmisc", "net", NULL };
|
const gchar *subsys[] = { "tty", "usbmisc", "net", "rpmsg", NULL };
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
ctx->udev = g_udev_client_new (subsys);
|
ctx->udev = g_udev_client_new (subsys);
|
||||||
|
@@ -237,6 +237,20 @@ base_modem_create_usbmisc_port (MMBaseModem *self,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 *
|
static MMPort *
|
||||||
base_modem_create_virtual_port (MMBaseModem *self,
|
base_modem_create_virtual_port (MMBaseModem *self,
|
||||||
const gchar *name)
|
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);
|
port = base_modem_create_tty_port (self, name, kernel_device, ptype);
|
||||||
else if (g_str_equal (subsys, "usbmisc"))
|
else if (g_str_equal (subsys, "usbmisc"))
|
||||||
port = base_modem_create_usbmisc_port (self, name, ptype);
|
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"))
|
else if (g_str_equal (subsys, "virtual"))
|
||||||
port = base_modem_create_virtual_port (self, name);
|
port = base_modem_create_virtual_port (self, name);
|
||||||
|
|
||||||
@@ -327,8 +343,6 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mm_base_modem_disable_finish (MMBaseModem *self,
|
mm_base_modem_disable_finish (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
|
@@ -199,6 +199,13 @@ mm_filter_port (MMFilter *self,
|
|||||||
return TRUE;
|
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 this is a tty device, we may allow it */
|
||||||
if ((self->priv->enabled_rules & MM_FILTER_RULE_TTY) &&
|
if ((self->priv->enabled_rules & MM_FILTER_RULE_TTY) &&
|
||||||
(g_strcmp0 (subsystem, "tty") == 0)) {
|
(g_strcmp0 (subsystem, "tty") == 0)) {
|
||||||
|
@@ -53,15 +53,16 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/
|
|||||||
MM_FILTER_RULE_VIRTUAL = 1 << 3,
|
MM_FILTER_RULE_VIRTUAL = 1 << 3,
|
||||||
MM_FILTER_RULE_NET = 1 << 4,
|
MM_FILTER_RULE_NET = 1 << 4,
|
||||||
MM_FILTER_RULE_USBMISC = 1 << 5,
|
MM_FILTER_RULE_USBMISC = 1 << 5,
|
||||||
MM_FILTER_RULE_TTY = 1 << 6,
|
MM_FILTER_RULE_RPMSG = 1 << 6,
|
||||||
MM_FILTER_RULE_TTY_BLACKLIST = 1 << 7,
|
MM_FILTER_RULE_TTY = 1 << 7,
|
||||||
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY = 1 << 8,
|
MM_FILTER_RULE_TTY_BLACKLIST = 1 << 8,
|
||||||
MM_FILTER_RULE_TTY_PLATFORM_DRIVER = 1 << 9,
|
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY = 1 << 9,
|
||||||
MM_FILTER_RULE_TTY_DEFAULT_ALLOWED = 1 << 10,
|
MM_FILTER_RULE_TTY_PLATFORM_DRIVER = 1 << 10,
|
||||||
MM_FILTER_RULE_TTY_DRIVER = 1 << 11,
|
MM_FILTER_RULE_TTY_DEFAULT_ALLOWED = 1 << 11,
|
||||||
MM_FILTER_RULE_TTY_ACM_INTERFACE = 1 << 12,
|
MM_FILTER_RULE_TTY_DRIVER = 1 << 12,
|
||||||
MM_FILTER_RULE_TTY_WITH_NET = 1 << 13,
|
MM_FILTER_RULE_TTY_ACM_INTERFACE = 1 << 13,
|
||||||
MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN = 1 << 14,
|
MM_FILTER_RULE_TTY_WITH_NET = 1 << 14,
|
||||||
|
MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN = 1 << 15,
|
||||||
} MMFilterRule;
|
} MMFilterRule;
|
||||||
|
|
||||||
#define MM_FILTER_RULE_ALL \
|
#define MM_FILTER_RULE_ALL \
|
||||||
@@ -71,6 +72,7 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/
|
|||||||
MM_FILTER_RULE_VIRTUAL | \
|
MM_FILTER_RULE_VIRTUAL | \
|
||||||
MM_FILTER_RULE_NET | \
|
MM_FILTER_RULE_NET | \
|
||||||
MM_FILTER_RULE_USBMISC | \
|
MM_FILTER_RULE_USBMISC | \
|
||||||
|
MM_FILTER_RULE_RPMSG | \
|
||||||
MM_FILTER_RULE_TTY | \
|
MM_FILTER_RULE_TTY | \
|
||||||
MM_FILTER_RULE_TTY_BLACKLIST | \
|
MM_FILTER_RULE_TTY_BLACKLIST | \
|
||||||
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY | \
|
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_VIRTUAL | \
|
||||||
MM_FILTER_RULE_NET | \
|
MM_FILTER_RULE_NET | \
|
||||||
MM_FILTER_RULE_USBMISC | \
|
MM_FILTER_RULE_USBMISC | \
|
||||||
|
MM_FILTER_RULE_RPMSG | \
|
||||||
MM_FILTER_RULE_TTY | \
|
MM_FILTER_RULE_TTY | \
|
||||||
MM_FILTER_RULE_TTY_BLACKLIST | \
|
MM_FILTER_RULE_TTY_BLACKLIST | \
|
||||||
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY | \
|
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_VIRTUAL | \
|
||||||
MM_FILTER_RULE_NET | \
|
MM_FILTER_RULE_NET | \
|
||||||
MM_FILTER_RULE_USBMISC | \
|
MM_FILTER_RULE_USBMISC | \
|
||||||
|
MM_FILTER_RULE_RPMSG | \
|
||||||
MM_FILTER_RULE_TTY | \
|
MM_FILTER_RULE_TTY | \
|
||||||
MM_FILTER_RULE_TTY_PLATFORM_DRIVER | \
|
MM_FILTER_RULE_TTY_PLATFORM_DRIVER | \
|
||||||
MM_FILTER_RULE_TTY_DRIVER | \
|
MM_FILTER_RULE_TTY_DRIVER | \
|
||||||
@@ -120,6 +124,7 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/
|
|||||||
MM_FILTER_RULE_VIRTUAL | \
|
MM_FILTER_RULE_VIRTUAL | \
|
||||||
MM_FILTER_RULE_NET | \
|
MM_FILTER_RULE_NET | \
|
||||||
MM_FILTER_RULE_USBMISC | \
|
MM_FILTER_RULE_USBMISC | \
|
||||||
|
MM_FILTER_RULE_RPMSG | \
|
||||||
MM_FILTER_RULE_TTY | \
|
MM_FILTER_RULE_TTY | \
|
||||||
MM_FILTER_RULE_TTY_BLACKLIST | \
|
MM_FILTER_RULE_TTY_BLACKLIST | \
|
||||||
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY | \
|
MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY | \
|
||||||
|
@@ -781,6 +781,11 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
probe_run_flags |= MM_PORT_PROBE_MBIM;
|
probe_run_flags |= MM_PORT_PROBE_MBIM;
|
||||||
else
|
else
|
||||||
probe_run_flags |= MM_PORT_PROBE_AT;
|
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 */
|
/* For potential AT ports, check for more things */
|
||||||
|
@@ -491,16 +491,22 @@ wdm_probe_qmi (MMPortProbe *self)
|
|||||||
ctx = g_task_get_task_data (self->priv->task);
|
ctx = g_task_get_task_data (self->priv->task);
|
||||||
|
|
||||||
#if defined WITH_QMI
|
#if defined WITH_QMI
|
||||||
mm_obj_dbg (self, "probing QMI...");
|
{
|
||||||
|
MMPortSubsys subsys = MM_PORT_SUBSYS_USBMISC;
|
||||||
|
|
||||||
/* Create a port and try to open it */
|
mm_obj_dbg (self, "probing QMI...");
|
||||||
ctx->port_qmi = mm_port_qmi_new (mm_kernel_device_get_name (self->priv->port),
|
|
||||||
MM_PORT_SUBSYS_USBMISC);
|
if (g_str_equal (mm_kernel_device_get_subsystem (self->priv->port), "rpmsg"))
|
||||||
mm_port_qmi_open (ctx->port_qmi,
|
subsys = MM_PORT_SUBSYS_RPMSG;
|
||||||
FALSE,
|
|
||||||
NULL,
|
/* Create a port and try to open it */
|
||||||
(GAsyncReadyCallback) port_qmi_open_ready,
|
ctx->port_qmi = mm_port_qmi_new (mm_kernel_device_get_name (self->priv->port), subsys);
|
||||||
self);
|
mm_port_qmi_open (ctx->port_qmi,
|
||||||
|
FALSE,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback) port_qmi_open_ready,
|
||||||
|
self);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* If not compiled with QMI support, just assume we won't have any QMI port */
|
/* If not compiled with QMI support, just assume we won't have any QMI port */
|
||||||
mm_port_probe_set_result_qmi (self, FALSE);
|
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"))
|
if (g_str_equal (mm_kernel_device_get_subsystem (self->priv->port), "usbmisc"))
|
||||||
subsys = MM_PORT_SUBSYS_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));
|
ctx->serial = MM_PORT_SERIAL (mm_port_serial_at_new (mm_kernel_device_get_name (self->priv->port), subsys));
|
||||||
if (!ctx->serial) {
|
if (!ctx->serial) {
|
||||||
|
@@ -28,8 +28,8 @@ typedef enum { /*< underscore_name=mm_port_subsys >*/
|
|||||||
MM_PORT_SUBSYS_NET,
|
MM_PORT_SUBSYS_NET,
|
||||||
MM_PORT_SUBSYS_USBMISC,
|
MM_PORT_SUBSYS_USBMISC,
|
||||||
MM_PORT_SUBSYS_UNIX,
|
MM_PORT_SUBSYS_UNIX,
|
||||||
|
MM_PORT_SUBSYS_RPMSG,
|
||||||
MM_PORT_SUBSYS_LAST = MM_PORT_SUBSYS_UNIX /*< skip >*/
|
MM_PORT_SUBSYS_LAST = MM_PORT_SUBSYS_RPMSG /*< skip >*/
|
||||||
} MMPortSubsys;
|
} MMPortSubsys;
|
||||||
|
|
||||||
typedef enum { /*< underscore_name=mm_port_type >*/
|
typedef enum { /*< underscore_name=mm_port_type >*/
|
||||||
|
Reference in New Issue
Block a user