From patchwork Thu Feb 22 20:15:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13568057 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41D8A54914 for ; Thu, 22 Feb 2024 20:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633010; cv=none; b=UEn99wWvUhslYS1WqaPviyWliIioU9jnBTg9bghb9qiJPDTAIsmcvllRa2aGmyu6lNcfgOiG/n6Y9HNjfxROTejWvEYL+B3YCB8UONK3ymkAFl0otUMczzhXmKsZVe8C1lOsiaWg5VduD86V9PatYoostBVuBiRNigr+84JS/2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633010; c=relaxed/simple; bh=72z+tT7DEB+5bcUz/kgwn+wcqAfQIkCkH77m0wCRMUw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=C6Jh03svSigmDRXa4DqEYl985rWe6EjZpkftDYakC2QUsxM7ZUJ6x7QH37cu6AlB4x/QEJS5XBMx9/rVRs07VIPfd5+Gp9cK9H8LuyWH1zo4ncsRwNt6pAiVUx0r9pI46G3y5Ju+T0usvbyIauyWrKdVt0IAWpYcvGy6y9HblRg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kavxCksC; arc=none smtp.client-ip=209.85.161.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kavxCksC" Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-599f5e71d85so137530eaf.3 for ; Thu, 22 Feb 2024 12:16:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708633007; x=1709237807; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qlm5KhKwNC/pQaGIooXCUL1ClSIUaniMVo/Csisk3wQ=; b=kavxCksCT9nLX7KWjQW3fgGWBudSzS0F9N1ivzKqZCp/kNfheJ3Inl7yaOpSEjAm2c zwzMf79cfY/ls9HgP17AeWb8lc1N9W8fnWTfkJcbWU5Hom3dmBBM3lSB0d61k5OMvaA2 qRaqNG8VOZJaMHJvnV8deKiP9C4GqSkWY6Ef28kTWiF6BKaKhQvyLgTW4UM+r23H1DcJ qIjQ7ci4KzWMQrZ51o70QNDEXmcBGPsox03lU1/uyuXW3Z4UAVl7tpFbHJMy1o48vKVv pUyo9l4xyCmeJHcMV3772hcfHnMZPRsCyTmfzZQbPSzRBpn6XCVdKGCuOL36lD8pnbLu NE4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708633007; x=1709237807; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qlm5KhKwNC/pQaGIooXCUL1ClSIUaniMVo/Csisk3wQ=; b=ILAIrJFaSoJ38cDoNkFMjyrUDT1fA8DfMDv/hGxOZQDQRWE7fCaKvF+kuVy7QBG0HA T4JgMsiVdyxrm/YxNU7mpSpl7V2SdkkXCQ3qHYRdDQuu0R8iEe2VYSAtlxqte7Dtw20g JZBkHVmzK5OpYvzYOk/Q8qEuoOygVRN9sztLpKETjFn4zO26NW+ywk2Td3txERYJHSzP wtgAOAFzzZ0rnjofBhqbTjKRUFFJQvJ/7V1m5rr3NUFEkoWc3RB/nRbrnvkRFtPttMo1 /cJ4CnW5FZUWZi41mRDDPgnkt8+/dmnAFlA+UzdTRpnP1T4P2axr35s+r0RIRO7Arcrs kegQ== X-Gm-Message-State: AOJu0YySz9OrziKnzB1mn98zMrLEGpNi7r9ipAHwo0LadUg1GUdF9pRu 8auPyr9NJ7zHHOAOqRjIAn+rm7HZpbsBybcbWsfOJjbcQitsY+O6XLYeeBW6 X-Google-Smtp-Source: AGHT+IG9L2YIPsWkPFseLsQoGifTATRRccn3RpJYf0Xl//1curVsvqaQEOTUmpezIuaCglBaMOvBVQ== X-Received: by 2002:a4a:3446:0:b0:5a0:109f:edff with SMTP id n6-20020a4a3446000000b005a0109fedffmr29699oof.4.1708633007139; Thu, 22 Feb 2024 12:16:47 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id k1-20020a4a9101000000b0059a14309a29sm2472353oog.16.2024.02.22.12.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:16:46 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 1/4] qmi: Introduce discover() driver method Date: Thu, 22 Feb 2024 14:15:42 -0600 Message-ID: <20240222201559.1293947-1-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On QMUX the discover operation queries all available services by sending a QMUX Control message and processing its reply. The reply contains a list of services and the corresponding major / minor version number. QRTR has a similar, but much more dynamic mechanism utilizing the QRTR nameserver. Services on QRTR can appear and disappear freely compared to services on QMUX. Abstract the discovery operation behind a discover() method in the ops structure, and move the QMUX specific implementation there. While here, change the return signature of qmi_device_discover() to return an int, such that better error reporting can be supported. --- drivers/qmimodem/qmi.c | 358 +++++++++++++++++++++-------------------- drivers/qmimodem/qmi.h | 2 +- 2 files changed, 188 insertions(+), 172 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index ec7a74778079..2a6e79efeed2 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -56,6 +56,9 @@ struct qmi_version { }; struct qmi_device_ops { + int (*discover)(struct qmi_device *device, + qmi_discover_func_t discover_func, + void *user, qmi_destroy_func_t destroy); int (*client_create)(struct qmi_device *device, uint16_t service_type, qmi_create_func_t func, @@ -1139,183 +1142,16 @@ static bool qmi_device_sync(struct qmi_device *device, return true; } -static void discover_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) -{ - struct discover_data *data = user_data; - struct qmi_device *device = data->device; - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); - const struct qmi_result_code *result_code; - const struct qmi_service_list *service_list; - const void *ptr; - uint16_t len; - struct qmi_version *list; - uint8_t count; - unsigned int i; - - count = 0; - list = NULL; - - result_code = tlv_get(buffer, length, 0x02, &len); - if (!result_code) - goto done; - - if (len != QMI_RESULT_CODE_SIZE) - goto done; - - service_list = tlv_get(buffer, length, 0x01, &len); - if (!service_list) - goto done; - - if (len < QMI_SERVICE_LIST_SIZE) - goto done; - - list = l_malloc(sizeof(struct qmi_version) * service_list->count); - - for (i = 0; i < service_list->count; i++) { - uint16_t major = - L_LE16_TO_CPU(service_list->services[i].major); - uint16_t minor = - L_LE16_TO_CPU(service_list->services[i].minor); - uint8_t type = service_list->services[i].type; - const char *name = __service_type_to_string(type); - - if (name) - __debug_device(device, "found service [%s %d.%d]", - name, major, minor); - else - __debug_device(device, "found service [%d %d.%d]", - type, major, minor); - - if (type == QMI_SERVICE_CONTROL) { - qmux->control_major = major; - qmux->control_minor = minor; - continue; - } - - list[count].type = type; - list[count].major = major; - list[count].minor = minor; - list[count].name = name; - - count++; - } - - ptr = tlv_get(buffer, length, 0x10, &len); - if (!ptr) - goto done; - - qmux->version_str = l_strndup(ptr + 1, *((uint8_t *) ptr)); - __debug_device(device, "version string: %s", qmux->version_str); - -done: - device->version_list = list; - device->version_count = count; - - /* if the device support the QMI call SYNC over the CTL interface */ - if ((qmux->control_major == 1 && qmux->control_minor >= 5) || - qmux->control_major > 1) { - qmi_device_sync(data->device, data); - return; - } - - if (data->func) - data->func(data->user_data); - - __qmi_device_discovery_complete(data->device, &data->super); -} - -static struct qmi_request *find_control_request(struct qmi_device *device, - uint16_t tid) -{ - struct qmi_request *req = NULL; - unsigned int _tid = tid; - - if (_tid != 0) { - req = l_queue_remove_if(device->req_queue, __request_compare, - L_UINT_TO_PTR(_tid)); - - if (!req) - req = l_queue_remove_if(device->control_queue, - __request_compare, - L_UINT_TO_PTR(_tid)); - } - - return req; -} - - -static void discover_reply_idle(struct l_idle *idle, void *user_data) -{ - struct discover_data *data = user_data; - struct qmi_device *device = data->device; - - l_idle_remove(data->idle); - data->idle = NULL; - - if (data->func) - data->func(data->user_data); - - __qmi_device_discovery_complete(device, &data->super); -} - -static void discover_reply_timeout(struct l_timeout *timeout, void *user_data) -{ - struct discover_data *data = user_data; - struct qmi_device *device = data->device; - struct qmi_request *req; - - l_timeout_remove(data->timeout); - data->timeout = NULL; - - /* remove request from queues */ - req = find_control_request(device, data->tid); - - if (data->func) - data->func(data->user_data); - - __qmi_device_discovery_complete(device, &data->super); - - if (req) - __request_free(req); -} - -bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, +int qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, void *user_data, qmi_destroy_func_t destroy) { - struct discover_data *data; - struct qmi_request *req; - if (!device) return false; - __debug_device(device, "device %p discover", device); - - data = l_new(struct discover_data, 1); - - data->super.destroy = discover_data_free; - data->device = device; - data->func = func; - data->user_data = user_data; - data->destroy = destroy; - - if (device->version_list) { - data->idle = l_idle_create(discover_reply_idle, data, NULL); - __qmi_device_discovery_started(device, &data->super); - return true; - } - - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, - QMI_CTL_GET_VERSION_INFO, - NULL, 0, discover_callback, data); - - data->tid = __request_submit(device, req); - data->timeout = l_timeout_create(5, discover_reply_timeout, data, NULL); - - __qmi_device_discovery_started(device, &data->super); + if (!device->ops->discover) + return -ENOTSUP; - return true; + return device->ops->discover(device, func, user_data, destroy); } int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, @@ -1582,6 +1418,185 @@ static void service_create_shared_data_free(gpointer user_data) l_free(data); } +static struct qmi_request *find_control_request(struct qmi_device *device, + uint16_t tid) +{ + struct qmi_request *req = NULL; + unsigned int _tid = tid; + + if (_tid != 0) { + req = l_queue_remove_if(device->req_queue, __request_compare, + L_UINT_TO_PTR(_tid)); + + if (!req) + req = l_queue_remove_if(device->control_queue, + __request_compare, + L_UINT_TO_PTR(_tid)); + } + + return req; +} + +static void qmux_discover_callback(uint16_t message, uint16_t length, + const void *buffer, void *user_data) +{ + struct discover_data *data = user_data; + struct qmi_device *device = data->device; + struct qmi_device_qmux *qmux = + l_container_of(device, struct qmi_device_qmux, super); + const struct qmi_result_code *result_code; + const struct qmi_service_list *service_list; + const void *ptr; + uint16_t len; + struct qmi_version *list; + uint8_t count; + unsigned int i; + + count = 0; + list = NULL; + + result_code = tlv_get(buffer, length, 0x02, &len); + if (!result_code) + goto done; + + if (len != QMI_RESULT_CODE_SIZE) + goto done; + + service_list = tlv_get(buffer, length, 0x01, &len); + if (!service_list) + goto done; + + if (len < QMI_SERVICE_LIST_SIZE) + goto done; + + list = l_malloc(sizeof(struct qmi_version) * service_list->count); + + for (i = 0; i < service_list->count; i++) { + uint16_t major = + L_LE16_TO_CPU(service_list->services[i].major); + uint16_t minor = + L_LE16_TO_CPU(service_list->services[i].minor); + uint8_t type = service_list->services[i].type; + const char *name = __service_type_to_string(type); + + if (name) + __debug_device(device, "found service [%s %d.%d]", + name, major, minor); + else + __debug_device(device, "found service [%d %d.%d]", + type, major, minor); + + if (type == QMI_SERVICE_CONTROL) { + qmux->control_major = major; + qmux->control_minor = minor; + continue; + } + + list[count].type = type; + list[count].major = major; + list[count].minor = minor; + list[count].name = name; + + count++; + } + + ptr = tlv_get(buffer, length, 0x10, &len); + if (!ptr) + goto done; + + qmux->version_str = l_strndup(ptr + 1, *((uint8_t *) ptr)); + __debug_device(device, "version string: %s", qmux->version_str); + +done: + device->version_list = list; + device->version_count = count; + + /* if the device support the QMI call SYNC over the CTL interface */ + if ((qmux->control_major == 1 && qmux->control_minor >= 5) || + qmux->control_major > 1) { + qmi_device_sync(data->device, data); + return; + } + + if (data->func) + data->func(data->user_data); + + __qmi_device_discovery_complete(data->device, &data->super); +} + +static void qmux_discover_reply_idle(struct l_idle *idle, void *user_data) +{ + struct discover_data *data = user_data; + struct qmi_device *device = data->device; + + l_idle_remove(data->idle); + data->idle = NULL; + + if (data->func) + data->func(data->user_data); + + __qmi_device_discovery_complete(device, &data->super); +} + +static void qmux_discover_reply_timeout(struct l_timeout *timeout, + void *user_data) +{ + struct discover_data *data = user_data; + struct qmi_device *device = data->device; + struct qmi_request *req; + + l_timeout_remove(data->timeout); + data->timeout = NULL; + + /* remove request from queues */ + req = find_control_request(device, data->tid); + + if (data->func) + data->func(data->user_data); + + __qmi_device_discovery_complete(device, &data->super); + + if (req) + __request_free(req); +} + +static int qmi_device_qmux_discover(struct qmi_device *device, + qmi_discover_func_t func, + void *user_data, + qmi_destroy_func_t destroy) +{ + struct discover_data *data; + struct qmi_request *req; + + __debug_device(device, "device %p discover", device); + + data = l_new(struct discover_data, 1); + + data->super.destroy = discover_data_free; + data->device = device; + data->func = func; + data->user_data = user_data; + data->destroy = destroy; + + if (device->version_list) { + data->idle = l_idle_create(qmux_discover_reply_idle, data, NULL); + __qmi_device_discovery_started(device, &data->super); + return 0; + } + + req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, + QMI_CTL_GET_VERSION_INFO, + NULL, 0, qmux_discover_callback, data); + + data->tid = __request_submit(device, req); + data->timeout = l_timeout_create(5, qmux_discover_reply_timeout, + data, NULL); + + __qmi_device_discovery_started(device, &data->super); + + return 0; +} + struct qmux_client_create_data { struct discovery super; struct qmi_device *device; @@ -1841,6 +1856,7 @@ static void qmi_device_qmux_destroy(struct qmi_device *device) } static const struct qmi_device_ops qmux_ops = { + .discover = qmi_device_qmux_discover, .client_create = qmi_device_qmux_client_create, .client_release = qmi_device_qmux_client_release, .shutdown = qmi_device_qmux_shutdown, diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index ef2140faad9c..6a3d3415dd35 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -86,7 +86,7 @@ void qmi_device_free(struct qmi_device *device); void qmi_device_set_debug(struct qmi_device *device, qmi_debug_func_t func, void *user_data); -bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, +int qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, void *user_data, qmi_destroy_func_t destroy); int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy); From patchwork Thu Feb 22 20:15:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13568058 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02B006E5E4 for ; Thu, 22 Feb 2024 20:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633010; cv=none; b=Nk9gPCBVQJ/RTJ1hjTDE0TqQ/bTOXNNH/Ktjq21412sCQpCm6+mPTkPlbvJSaX0q7SuzDjCm17YgEIrGTcnBRXxU7YkgV7ji8JvUwdUrXw0aQEKftOrtPJ2H4HphqSty/3hdsP8lqdF2g9wJamViU8y+ZEBwor6JiwHzkG7abng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633010; c=relaxed/simple; bh=7M/32TCdpz/4zpM2Qn4RWfPA2A2jDsXh39DyFSrVgjc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lc90mv4TpgyiSeDAJt6/+NG6X421hw+IisEmP/IyRv+4U1Cc4tLN2+CBxpUPvUOEmtNNFtHpycjGdfuyiS/HayrANkQrbopfiTTimjv7iGjRFOE9dJKSmuWYp9GQYi9T640hD2AojfWdhyqPdk+g3knS4f/vpJgPTSlp4HcINRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AkE4ZUmY; arc=none smtp.client-ip=209.85.161.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AkE4ZUmY" Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5a027fda5aeso119580eaf.1 for ; Thu, 22 Feb 2024 12:16:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708633008; x=1709237808; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vBy/eykTh1+KPm82aBg9OrTIXpz0pLXbS7OyGJP5L6g=; b=AkE4ZUmYb+plolFermMnfeFMvwnccgmAR/aNFqYRhB++x18OIzvAZE9JlZTevkm911 5rawAzB8BEMfxMEV0bqj5lhmQXPEfstn42BlfJo1ZWptxNJJDpGA7ZmLI+V2QrcOdjF4 1S7NcLTqpIiS/vI7pz/muGYKpYTEk+wtyOjd7mN6BUMJ1fAOHjzabxIMhTaPX+bewSAZ M3TeE9q0EsM/g33lH0RYtvk8E1hWmOM9BaU9N3pNP/AS57LyBGccolOWPUbpfjf0EWhj nFmDruCcEh5d8NZRdxtR6eEWpDptymS5tFHGBBJLpeSI5xLRh4ebwltNaOa4fSiJbSjr Mexg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708633008; x=1709237808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vBy/eykTh1+KPm82aBg9OrTIXpz0pLXbS7OyGJP5L6g=; b=JzJ/ha6Do3lf/DyJHngbeevbXJYYSMu3zVkR+Q/9CYChSIJx7u4IZWqJNZxE0/1eoQ Sj9/37E+P6x8riAXSbfsscfJh2kVeNMKARze9Yk2fDsRGho3vSuZiu/sv1fNQWOZWCmd UxIgbLo3E+JyidPk0dnRLwDE4QAqlTqZBCcTDHS96weqosbFWrDH6xiIjbwzLpPVVEQo Y1x6978qXVsiUIbna6w7tsGbBdGo/ebAnr8Q7vpZ+/HJ0NQ6usvo3gK007W34qs9nM51 h5lNzOoKIJG2a3uai2oG3Xs1ooUx7ByLFN2Zse7BRYw1AwSUcUkhEuTIb8yuOJeXmmQ3 SfTw== X-Gm-Message-State: AOJu0YyO49AJqrFOWF/h/v26iswP8JSpHxRk+OajAvH5vlk8YSYKkUk7 5FEnRd9s7mH6GSpP3ezjoVMRHrVcpIaSI9pCDt2PwGd1nvAi3aVuafnGZ9F8 X-Google-Smtp-Source: AGHT+IGYr6h2IVHl01485lO74GzH9f6zskCL5w9IiUH9//Ht1kXWlAzPkrStIGHsc6HyuaFKq+UdBw== X-Received: by 2002:a4a:d285:0:b0:59f:8466:5748 with SMTP id h5-20020a4ad285000000b0059f84665748mr85011oos.0.1708633007877; Thu, 22 Feb 2024 12:16:47 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id k1-20020a4a9101000000b0059a14309a29sm2472353oog.16.2024.02.22.12.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:16:47 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 2/4] gobi: heed the qmi_device_discover return Date: Thu, 22 Feb 2024 14:15:43 -0600 Message-ID: <20240222201559.1293947-2-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222201559.1293947-1-denkenz@gmail.com> References: <20240222201559.1293947-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If qmi_device_discover attempt fails, fail right away. --- plugins/gobi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 2b29afbefdbe..c4e63b7b464f 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -423,6 +423,7 @@ static int gobi_enable(struct ofono_modem *modem) { struct gobi_data *data = ofono_modem_get_data(modem); const char *device; + int r; DBG("%p", modem); @@ -437,9 +438,11 @@ static int gobi_enable(struct ofono_modem *modem) if (getenv("OFONO_QMI_DEBUG")) qmi_device_set_debug(data->device, gobi_debug, "QMI: "); - qmi_device_discover(data->device, discover_cb, modem, NULL); + r = qmi_device_discover(data->device, discover_cb, modem, NULL); + if (!r) + return -EINPROGRESS; - return -EINPROGRESS; + return r; } static void power_disable_cb(struct qmi_result *result, void *user_data) From patchwork Thu Feb 22 20:15:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13568059 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B00D76E5F0 for ; Thu, 22 Feb 2024 20:16:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633011; cv=none; b=lU9ixyiTJ5s7ORT7cv0zeEzvqJJaC1Mwsl3nAGWR/Ouh8U27GDbxCRARL2CcKnei1tVmT9Ob7dICC9YJyDNG+XzsXTrnepGcjAsMtK2YpC2iuo2bVnBchahnEFOtcv9FsdibKMYaYVCGaDhtHOpAkNLkShlEL/3MjWigtDKDlEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633011; c=relaxed/simple; bh=F/nEQB0Db8+LnqI1Ce14NlCCo9Gy/giN/SNp3ViBnLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fkZTmIHoYdlNpQDZaelFLGyhuT8rtF4qVdIsLopelLwraBEwwEPB58up8E4rH6xSy0SBDt+YscuOgNt66OGH4tKq1e//ez7H9ppEOwnu0CsALb2vmHTiTZBR0QWWzA+oaVnZRi+97jH4KEacCLO01eWW3b3DELhqqyMNQFA4ktQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LwuAtwjA; arc=none smtp.client-ip=209.85.161.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LwuAtwjA" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5a03417ec1bso105828eaf.0 for ; Thu, 22 Feb 2024 12:16:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708633009; x=1709237809; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9KhIswsVx0V1NVFMBzAZCkWObR/s7cESrjTLV1NlC+k=; b=LwuAtwjAf5fYL903iMYnAImFa9APnJeGKj/oCLBrAqCAXdlJEWkNAOSPq1f717yHqi oNKTzwFyO8yEdyGfZuI58uMVSfqsgRpM1HtiE13OrFepzwUFHNEVxGHOdaJrTSMSfBPO misfhzw1Ho6on0wdhRXxUpHui/ymBE19fHMJ7xeXPvZLO9Imh04afdc5Rq4nAwxTsWbq bslcEV308TJ2RdYwqHfadz0/T/5S4tvrtfpZG/S5yxit2kyI53TAhvHayMXAqQmVUbNp CGG+EkirB/FVuffLoUjbAbYQwnKILrPpo1Z/2HzoV/Rr8BKq99nrR9gMRtBn3430YknR t3Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708633009; x=1709237809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9KhIswsVx0V1NVFMBzAZCkWObR/s7cESrjTLV1NlC+k=; b=eKrCt/8SsFVN3BklNb1Qk5SSxWpsuXObj5yl8OdKDH0zIYzdnv6A9bu3IU1CxtbJpP so0b55I1N70s2vZJD1P5VWNEKIQRnHLwOYoUoVKXAYi+QjDS8LbAwMTFTLWtiSnPs4TP AMd+nQo9MhPX6sFjoaDRLFDPP1Blm72JVVIBWujiMFRDlW8l1leMNoT1Z8g2AGxSgorW he7oAFcgcyCnfQ00ZTtqZqdIasiRwKhOWHdEYeLO4LsEyyUV6vZpubZSL8QSnknCFXuF qlXk5QMTuZWdpIvBOYdpl8OFUm4/ZP4DGFV9qoR2mY+FPLSoONCvKcpxYjtSBLhoXmM6 /m5A== X-Gm-Message-State: AOJu0Yz2e8fzAvD8fS1OAB0+/vFaiM89MycxR00FRiApL73MZq+YVn4/ mDCk7ZPgcgmho5XSWuH0zA69Sa3JuqxZPH6YlfyU8llTkbPPz/NymJJm7gcv X-Google-Smtp-Source: AGHT+IGGyWeh50NOAC2cUDC3+sy1iQxYCh4N9R7ji9Yhbr9CAuWI/zkCpH9VNlw0OtyVwvCpZQAajw== X-Received: by 2002:a4a:851c:0:b0:59f:fc2d:8179 with SMTP id k28-20020a4a851c000000b0059ffc2d8179mr12752ooh.9.1708633008799; Thu, 22 Feb 2024 12:16:48 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id k1-20020a4a9101000000b0059a14309a29sm2472353oog.16.2024.02.22.12.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:16:48 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 3/4] qmimodem: Fail early if discovery already complete Date: Thu, 22 Feb 2024 14:15:44 -0600 Message-ID: <20240222201559.1293947-3-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222201559.1293947-1-denkenz@gmail.com> References: <20240222201559.1293947-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If discovery has been completed successfully, tell the caller right away by returning a -EALREADY return code instead of scheduling for the discover callback to be invoked via the idle callback. Such logic has no real effect as the underlying CTL service is not queried again. --- drivers/qmimodem/qmi.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 2a6e79efeed2..268db1f76cc5 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1095,7 +1095,6 @@ struct discover_data { qmi_destroy_func_t destroy; uint16_t tid; struct l_timeout *timeout; - struct l_idle *idle; }; static void discover_data_free(void *user_data) @@ -1105,9 +1104,6 @@ static void discover_data_free(void *user_data) if (data->timeout) l_timeout_remove(data->timeout); - if (data->idle) - l_idle_remove(data->idle); - if (data->destroy) data->destroy(data->user_data); @@ -1524,20 +1520,6 @@ done: __qmi_device_discovery_complete(data->device, &data->super); } -static void qmux_discover_reply_idle(struct l_idle *idle, void *user_data) -{ - struct discover_data *data = user_data; - struct qmi_device *device = data->device; - - l_idle_remove(data->idle); - data->idle = NULL; - - if (data->func) - data->func(data->user_data); - - __qmi_device_discovery_complete(device, &data->super); -} - static void qmux_discover_reply_timeout(struct l_timeout *timeout, void *user_data) { @@ -1570,6 +1552,9 @@ static int qmi_device_qmux_discover(struct qmi_device *device, __debug_device(device, "device %p discover", device); + if (device->version_list) + return -EALREADY; + data = l_new(struct discover_data, 1); data->super.destroy = discover_data_free; @@ -1578,12 +1563,6 @@ static int qmi_device_qmux_discover(struct qmi_device *device, data->user_data = user_data; data->destroy = destroy; - if (device->version_list) { - data->idle = l_idle_create(qmux_discover_reply_idle, data, NULL); - __qmi_device_discovery_started(device, &data->super); - return 0; - } - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, QMI_CTL_GET_VERSION_INFO, NULL, 0, qmux_discover_callback, data); From patchwork Thu Feb 22 20:15:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13568060 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C241E6E5E4 for ; Thu, 22 Feb 2024 20:16:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633012; cv=none; b=N8LkG32qeCP2ZpqIRhFWAxoNWYiohEPqKsc+tT5EYDysm8CWS0Mg2fv3vXrSuVPgzIUX6uZ+ArsyslSn94eQ1/Zn0gYh+imuPs0VtTlwL6Eq4mNefI3vtRqEe8DW7E8wbKjKtonP+HBdf4Uzc9s6eYC/zOahSX6aOgfa25rh2m4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633012; c=relaxed/simple; bh=gZ457g/Jl4FgaSAU2muNe4zABSqTBeScqdwIcCf2QgI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qWy3P7acvTkDnk5ZM/tRoLCHgI/6duf9Uoemf72lumh6opO+t0eG8RnvxqSCdhgHtrfsahrm1d7LZveZsvCbir5h7jHbvKit2XRDJmLoRWfWtq/k2hxPNO9VZcYKdO9vh6Q4A6L9576iH5noRnPRm3Ap1QuuuDWYA+ELiRsLmxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bM4t/sr1; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bM4t/sr1" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6ddca59e336so107916a34.0 for ; Thu, 22 Feb 2024 12:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708633009; x=1709237809; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aQ+wgljsQYGCpixLwCvaa09CjLrMwUmYdVDp6sLZGzI=; b=bM4t/sr1SPu1GtZ5o7JUkItCEzGMwo9BiWhRc8hgOzBXoSkpUTwHSwXA9BOJ4jL2vZ l3J6JiUz6ueN7T7h94bqiOWiia8P8I4ZO7WVbh1vhH2dHd1aQBc44hNXsM7gwnxR3PMl tXZQebzgWuNdMy0mstb/o9X3ZYMmlyABo7yHFbkz3zA5PluuZKw5LWuZpBMF5bLseYQR 11cZPO1CRE+WEDCHqmI2OafKxvFY5em0mUiRnVRFJHRkrBPPofrPW6v9Q4YPCyXAx5tb WUE7YCLBbFQEVIHlpJwnvN4L/ZrUDNE1Oi/UgTNoYSukyVE5xEkhSDQf3q9mq02sP4p6 d2vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708633009; x=1709237809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aQ+wgljsQYGCpixLwCvaa09CjLrMwUmYdVDp6sLZGzI=; b=SeJVwN92OhPkd0M8D7Sf9Bb0+zL66+4yKShkv/EUI+mSOTEFyTCzTHBR81N0A5vJlT E7YYipil3xx1TFNeba2GaBMh5ASrys/VgYRIocyKXQOGGWh6y07LskhNZuV9T3o5knOp XQkE1ZehtRXtUXkdiMdpQhuToTw/dhbYR0kJKis2Am7T4O0fokg8Tz0uON1Q9+PHwmcx nCSX00IHpMz+ZCIXfj40YnQNDowobLiNzLI9h/V0O6pQyWvlKeyp/gzpoh9oAGIDCWEB pYRv4VW8Rxiq8rp7MXrIKFq2TeZjtMGMSbL1IZiHUes8UkY1rrk+FiguesYccBXbRygb iRkQ== X-Gm-Message-State: AOJu0YzO0zrs+ua0i/hNL2TQycs8TZR9fLmKEz6u/eWKZGc3Gr45nTCT rrGFu5UgHnu8xuhFeDbGiTAbg/ZxF9pqKeRxDdpd7L8SNxtDqfGrwLQJfStq X-Google-Smtp-Source: AGHT+IFtJjdx6CSNOn6Dki4B9HhLzK7ZuxkTd4TGC5gvD8T/ez1p/5+9E/+/aDWDg+P7TtKqIOMKKQ== X-Received: by 2002:a05:6830:1d0:b0:6e4:53b0:5817 with SMTP id r16-20020a05683001d000b006e453b05817mr1695540ota.0.1708633009637; Thu, 22 Feb 2024 12:16:49 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id k1-20020a4a9101000000b0059a14309a29sm2472353oog.16.2024.02.22.12.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:16:49 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 4/4] gobi: Fail early if re-tried discovery fails Date: Thu, 22 Feb 2024 14:15:45 -0600 Message-ID: <20240222201559.1293947-4-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222201559.1293947-1-denkenz@gmail.com> References: <20240222201559.1293947-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- plugins/gobi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index c4e63b7b464f..99a7d5564ed8 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -406,11 +406,10 @@ static void discover_cb(void *user_data) data->features |= GOBI_VOICE; if (!(data->features & GOBI_DMS)) { - if (++data->discover_attempts < 3) { - qmi_device_discover(data->device, discover_cb, - modem, NULL); + if (++data->discover_attempts < 3 && + !qmi_device_discover(data->device, discover_cb, + modem, NULL)) return; - } shutdown_device(modem); return;