From a8fd33ebaa80a0844c375fdb39173736d18f71cb Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Fri, 24 Jan 2020 12:27:07 +0100 Subject: port-qmi: fallback to raw-ip if WDA Get Data Format requests arguments New devices return a "Missing Argument" error in WDA Get Data Format, requiring the use of the "Endpoint info" TLV. Given that all these new devices are raw-ip only anyway, let's use this error to right away fallback to require raw-ip in the interface. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/177 --- src/mm-port-qmi.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mm-port-qmi.c b/src/mm-port-qmi.c index efaa3d15..75d3ee48 100644 --- a/src/mm-port-qmi.c +++ b/src/mm-port-qmi.c @@ -304,15 +304,26 @@ get_data_format_ready (QmiClientWda *client, { PortOpenContext *ctx; QmiMessageWdaGetDataFormatOutput *output; + g_autoptr(GError) error = NULL; ctx = g_task_get_task_data (task); output = qmi_client_wda_get_data_format_finish (client, res, NULL); if (!output || - !qmi_message_wda_get_data_format_output_get_result (output, NULL) || - !qmi_message_wda_get_data_format_output_get_link_layer_protocol (output, &ctx->llp, NULL)) - /* If loading WDA data format fails, fallback to 802.3 requested via CTL */ - ctx->step = PORT_OPEN_STEP_CLOSE_BEFORE_OPEN_WITH_DATA_FORMAT; - else + !qmi_message_wda_get_data_format_output_get_result (output, &error) || + !qmi_message_wda_get_data_format_output_get_link_layer_protocol (output, &ctx->llp, NULL)) { + /* A 'missing argument' error when querying data format is seen in new + * devices like the Quectel RM500Q, requiring the 'endpoint info' TLV. + * When this happens, assume the device supports only raw-ip and be done + * with it. */ + if (error && g_error_matches (error, QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR_MISSING_ARGUMENT)) { + mm_dbg ("Querying data format failed: '%s', assuming raw-ip is only supported", error->message); + ctx->llp = QMI_WDA_LINK_LAYER_PROTOCOL_RAW_IP; + ctx->step++; + } else { + /* If loading WDA data format fails, fallback to 802.3 requested via CTL */ + ctx->step = PORT_OPEN_STEP_CLOSE_BEFORE_OPEN_WITH_DATA_FORMAT; + } + } else /* Go on to next step */ ctx->step++; -- cgit v1.2.3-70-g09d2