From 5cc34d5f86bad12382d97e1daea894d8666a527d Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Wed, 3 Aug 2022 14:28:57 +0200 Subject: 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). --- src/mm-modem-helpers-qmi.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'src/mm-modem-helpers-qmi.c') diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c index ce3967f3..b6bcbd10 100644 --- a/src/mm-modem-helpers-qmi.c +++ b/src/mm-modem-helpers-qmi.c @@ -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) -{ - 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; - } +mm_port_net_driver_to_qmi_endpoint_type (const gchar *net_driver) +{ + 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; } /*****************************************************************************/ -- cgit v1.2.3-70-g09d2