port-qmi: Detect endpoint type based on net driver

At the moment the endpoint type and number for the QMI WDA calls are
chosen based on the subsystem of the QMI control port. This does not
work correctly for some configurations:

  - SUBSYS_QRTR currently implies ENDPOINT_TYPE_EMBEDDED, but this is
    only valid for QRTR+IPA configurations. For QRTR+BAM-DMUX the
    correct type is ENDPOINT_TYPE_BAM_DMUX.

  - SUBSYS_WWAN currently implies ENDPOINT_TYPE_PCIE, but there is
    already a comment that mentions that this selection works only for
    MHI/PCIe modems. SUBSYS_WWAN is also used by RPMSG+BAM-DMUX
    configurations in which case the correct type is also
    ENDPOINT_TYPE_BAM_DMUX.

Looking closer at these cases suggests that the endpoint type actually
refers to the data/net port and not the control port. It is more
reliable choose it based on the network driver and not the subsystem
of the control port.

Address this partially by choosing the endpoint type based on the
net_driver. Choosing the endpoint interface number correctly requires
more refactoring since most of the logic is currently handled globally
for a QMI control port, while it's actually specific to the chosen
data/net port in some cases (e.g. multiple BAM-DMUX network interfaces).
This commit is contained in:
Stephan Gerhold
2022-08-18 09:05:58 +00:00
committed by Aleksander Morgado
parent 598b9ae639
commit 5cc34d5f86
3 changed files with 14 additions and 39 deletions
+11 -22
View File
@@ -1795,29 +1795,18 @@ qmi_mobile_equipment_error_from_verbose_call_end_reason_3gpp (QmiWdsVerboseCallE
/* QMI/WDA to MM translations */
QmiDataEndpointType
mm_port_subsys_to_qmi_endpoint_type (MMPortSubsys subsys)
mm_port_net_driver_to_qmi_endpoint_type (const gchar *net_driver)
{
switch (subsys) {
case MM_PORT_SUBSYS_USBMISC:
return QMI_DATA_ENDPOINT_TYPE_HSUSB;
case MM_PORT_SUBSYS_RPMSG:
case MM_PORT_SUBSYS_QRTR:
return QMI_DATA_ENDPOINT_TYPE_EMBEDDED;
/* The WWAN subsystem abstracts the underlying transport bus, and so
* endpoint type can not be deducted from that. This function should
* then be revisited, but in practice, only MHI/PCI modem ports are
* exposed through the WWAN subsystem for now.
*/
case MM_PORT_SUBSYS_WWAN:
return QMI_DATA_ENDPOINT_TYPE_PCIE;
case MM_PORT_SUBSYS_UNKNOWN:
case MM_PORT_SUBSYS_TTY:
case MM_PORT_SUBSYS_NET:
case MM_PORT_SUBSYS_UNIX:
default:
g_assert_not_reached ();
break;
}
if (!g_strcmp0 (net_driver, "qmi_wwan"))
return QMI_DATA_ENDPOINT_TYPE_HSUSB;
if (!g_strcmp0 (net_driver, "mhi_net"))
return QMI_DATA_ENDPOINT_TYPE_PCIE;
if (!g_strcmp0 (net_driver, "ipa"))
return QMI_DATA_ENDPOINT_TYPE_EMBEDDED;
if (!g_strcmp0 (net_driver, "bam-dmux"))
return QMI_DATA_ENDPOINT_TYPE_BAM_DMUX;
return QMI_DATA_ENDPOINT_TYPE_UNKNOWN;
}
/*****************************************************************************/
+1 -1
View File
@@ -140,7 +140,7 @@ GError *qmi_mobile_equipment_error_from_verbose_call_end_reason_3gpp (QmiWdsVerb
/*****************************************************************************/
/* QMI/WDA to MM translations */
QmiDataEndpointType mm_port_subsys_to_qmi_endpoint_type (MMPortSubsys subsys);
QmiDataEndpointType mm_port_net_driver_to_qmi_endpoint_type (const gchar *net_driver);
/*****************************************************************************/
/* QMI/OMA to MM translations */
+2 -16
View File
@@ -67,7 +67,6 @@ struct _MMPortQmiPrivate {
/* timeout monitoring */
gulong timeout_monitoring_id;
/* endpoint info */
gulong endpoint_info_signal_id;
QmiDataEndpointType endpoint_type;
gint endpoint_interface_number;
/* kernel data mode */
@@ -149,10 +148,7 @@ initialize_endpoint_info (MMPortQmi *self)
kernel_device = mm_port_peek_kernel_device (MM_PORT (self));
if (!kernel_device)
self->priv->endpoint_type = QMI_DATA_ENDPOINT_TYPE_UNDEFINED;
else
self->priv->endpoint_type = mm_port_subsys_to_qmi_endpoint_type (mm_port_get_subsys (MM_PORT (self)));
self->priv->endpoint_type = mm_port_net_driver_to_qmi_endpoint_type (self->priv->net_driver);
switch (self->priv->endpoint_type) {
case QMI_DATA_ENDPOINT_TYPE_HSUSB:
@@ -2578,6 +2574,7 @@ mm_port_qmi_set_net_driver (MMPortQmi *self,
g_assert (MM_IS_PORT_QMI (self));
g_assert (!self->priv->net_driver);
self->priv->net_driver = g_strdup (net_driver);
initialize_endpoint_info (self);
}
/*****************************************************************************/
@@ -2729,12 +2726,6 @@ static void
mm_port_qmi_init (MMPortQmi *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_PORT_QMI, MMPortQmiPrivate);
/* load endpoint info as soon as kernel device is set */
self->priv->endpoint_info_signal_id = g_signal_connect (self,
"notify::" MM_PORT_KERNEL_DEVICE,
G_CALLBACK (initialize_endpoint_info),
NULL);
}
#if defined WITH_QRTR
@@ -2784,11 +2775,6 @@ dispose (GObject *object)
MMPortQmi *self = MM_PORT_QMI (object);
GList *l;
if (self->priv->endpoint_info_signal_id) {
g_signal_handler_disconnect (self, self->priv->endpoint_info_signal_id);
self->priv->endpoint_info_signal_id = 0;
}
/* Deallocate all clients */
for (l = self->priv->services; l; l = g_list_next (l)) {
ServiceInfo *info = l->data;