From patchwork Tue Jun 18 20:01: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: 13702908 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 3EE0B1C2A8 for ; Tue, 18 Jun 2024 20:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740956; cv=none; b=JInXobTn7cjAFEY1xF/IpeVQLAyDmxf8nHzug82web7W3a9EDBoe5fK9Enzc7xL/YJC7KR4r9mfYYvx5yo+hrtWKa5VNAYAqjW5zwl4F0z+htihi+8ONCPuwgvZHVA2GlKD/rqXLbqRv9SClvODbQm/5yyawcokL1cJdASW3xFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740956; c=relaxed/simple; bh=HUU3sUQwdUaQObDoIMlsAJAGfuur9LlGmMKFRvkjIlA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=riOjRLI/O1ZVwFwe0DF3sMcv4rhgBwz7mWa47m89qiO2tc8+uWa2V1SDGt1ZBtMPSd2I+aecost+8ZbKmUjEzX2NDnaozGUQ+TVVKw6k2btQ6DudSDWi4Xexnb2CcPZ1LCQlPt4SaZHphj3P8umhJdpT9qx1SBUS6hu7xWstTFQ= 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=H2KjP+V3; arc=none smtp.client-ip=209.85.210.53 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="H2KjP+V3" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6f986b92acaso3374299a34.2 for ; Tue, 18 Jun 2024 13:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740954; x=1719345754; 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=ku0cRHSkqfHg1v79ZIDpC0B8jaIvjzt5KGSfHCSRpGk=; b=H2KjP+V3G76Zg91X94IXXIlEicCsaxZMgM/ePpdBxANa3zFBh05R1t2r+XSd+8VBW5 OGsgQpPgc/pRpHPrRrcm7lFZOeZwv98bLwQqQ7urINj8mGbJqiyIlgbdrAoIpUBwHnX6 ewzQoNhAy8hWL8w287XCr+SxAVAgY7i2uYcFIapxCEiIC4WVx7097zjiTKG+GYt6HJBp uNXdppb/flQl3dnEfOtA9xQ3evAXdYCnY/uXwfL4Enz22rg6/i/huJ9HfVZB2GxRB+8X lK/KVY5JPjrYGOUzLJRb5KCPdT7OXv199Kxl27NvXHbDN6dYghTO98w1QEHnfdbzOvhm 5djQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740954; x=1719345754; 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=ku0cRHSkqfHg1v79ZIDpC0B8jaIvjzt5KGSfHCSRpGk=; b=KB7+k4Ntiox/MnikhqQUPXBU0/bl539jwEWjEXbh82Ilsi+YHTFfQ1YFik3GR234WA k0GvcU8ftO0kG1/bgnL7zDJO5EP0/WMe96zdhyesmFkcHbxsAqSMA2knxJermnvKKbGR 5vf4ZbEOaRptdS98oeYR8lSORq7pRrKxZKi3HEW9PbQGGqJpbhAIs7bjqXNW934Ido8D fuoTC/4FB6oJOErPjpccC9DHAUYfBfLmN9wfUxdWbRCySR1yvkCk+U39qSbLSQN6PpF7 ohf9n22fG7rsKan31QB8jcrmoF/mr48Nsm14rFhroRoXq5xNk5Q4qeNqftZ7jV6aESAC 0OHw== X-Gm-Message-State: AOJu0YzXusKcLoPgplyjr0RzMr6pZ3ac0J9Qkwd9Bh9nbZFBsWPI10wA M3HquHu/jVovLes4IYaku3TOAZNvtlgA5+mRS4aY4eMRc5YnePWeUH+4bw== X-Google-Smtp-Source: AGHT+IGHplshEvyEV8QL+7RDqsxK+zM4tJ0mgPsKf8ComYBV5v2K1DMcG3ew5+xVVXE+sb+AWBjtoA== X-Received: by 2002:a05:6870:330a:b0:254:a7ef:b714 with SMTP id 586e51a60fabf-25c94d743e9mr930434fac.58.1718740953832; Tue, 18 Jun 2024 13:02:33 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:33 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 01/33] qmi: Remove qmi_free() Date: Tue, 18 Jun 2024 15:01:43 -0500 Message-ID: <20240618200231.1129282-1-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This was just a simple wrapper around l_free, get rid of it. --- drivers/qmimodem/devinfo.c | 8 ++++---- drivers/qmimodem/qmi.c | 5 ----- drivers/qmimodem/qmi.h | 2 -- drivers/qmimodem/sim-legacy.c | 6 +++--- drivers/qmimodem/sim.c | 2 +- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/qmimodem/devinfo.c b/drivers/qmimodem/devinfo.c index 2e514cfa3265..fd1ca3ceb2dd 100644 --- a/drivers/qmimodem/devinfo.c +++ b/drivers/qmimodem/devinfo.c @@ -45,7 +45,7 @@ static void string_cb(struct qmi_result *result, void *user_data) CALLBACK_WITH_SUCCESS(cb, str, cbd->data); - qmi_free(str); + l_free(str); } static void qmi_query_manufacturer(struct ofono_devinfo *devinfo, @@ -136,9 +136,9 @@ static void get_ids_cb(struct qmi_result *result, void *user_data) else CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); - qmi_free(esn); - qmi_free(imei); - qmi_free(meid); + l_free(esn); + l_free(imei); + l_free(meid); } static void qmi_query_serial(struct ofono_devinfo *devinfo, diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 91469dc2e00c..632f647e5ea7 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -181,11 +181,6 @@ struct qmi_tlv_hdr { } __attribute__ ((packed)); #define QMI_TLV_HDR_SIZE 3 -void qmi_free(void *ptr) -{ - l_free(ptr); -} - static bool qmi_service_info_matches(const void *data, const void *user) { const struct qmi_service_info *info = data; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 821e54443658..de6238f25e62 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -56,8 +56,6 @@ enum qmi_data_endpoint_type { QMI_DATA_ENDPOINT_TYPE_BAM_DMUX = 0x05, }; -void qmi_free(void *ptr); - typedef void (*qmi_destroy_func_t)(void *user_data); diff --git a/drivers/qmimodem/sim-legacy.c b/drivers/qmimodem/sim-legacy.c index 1feaf86976c6..4c909f7f4ae4 100644 --- a/drivers/qmimodem/sim-legacy.c +++ b/drivers/qmimodem/sim-legacy.c @@ -71,14 +71,14 @@ static void get_iccid_cb(struct qmi_result *result, void *user_data) len = strlen(str); if (len > 20) { - qmi_free(str); + l_free(str); CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data); return; } sim_encode_bcd_number(str, iccid); iccid_len = len / 2; - qmi_free(str); + l_free(str); CALLBACK_WITH_SUCCESS(cb, iccid, iccid_len, cbd->data); } @@ -128,7 +128,7 @@ static void get_imsi_cb(struct qmi_result *result, void *user_data) CALLBACK_WITH_SUCCESS(cb, str, cbd->data); - qmi_free(str); + l_free(str); } static void qmi_read_imsi(struct ofono_sim *sim, diff --git a/drivers/qmimodem/sim.c b/drivers/qmimodem/sim.c index 876274fa87b4..1fffae27f63e 100644 --- a/drivers/qmimodem/sim.c +++ b/drivers/qmimodem/sim.c @@ -427,7 +427,7 @@ static void get_imsi_cb(struct qmi_result *result, void *user_data) CALLBACK_WITH_SUCCESS(cb, str, cbd->data); - qmi_free(str); + l_free(str); } static void qmi_read_imsi(struct ofono_sim *sim, From patchwork Tue Jun 18 20:01: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: 13702909 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (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 EC4BD28DCC for ; Tue, 18 Jun 2024 20:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740957; cv=none; b=AwXc+slNkZyfiNmC6OvDBwLMMqDPlOdNG92P7ycXy4b4zPQZyJjOT6AYzeBtN10EJvCa3Z4sbgmWfG1CEu1jEa6zFvZ+TB8Z26veNlP9C46jyIT5foLdI/jLjK4dq6MGVvVIrzctVrKfm6MAUqs+yqCGzzbE4M/sSRZ/VvtOWXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740957; c=relaxed/simple; bh=AqmRSXpqsa74kzD6L/BnSNSpMChihtQQEBU2ZB4UNWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V5+7DzdfqNiQLZ4Y8YM9wOmXS/wipyB4wQ84xr9r07oZnVHZJyf/9PHH3r9WE+K8PVewfEZQuk6Y/MIn3wpin8nshLcRtp5dSzUW55w80Nmg1eAY08LcmjBIbmUcUmY8bAEwmcJbdE7QssIjVwM2UOz7Sh4nhBfn9gaDKw6WHSk= 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=Ij+SWUHf; arc=none smtp.client-ip=209.85.160.41 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="Ij+SWUHf" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-2597922eb9eso592170fac.3 for ; Tue, 18 Jun 2024 13:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740955; x=1719345755; 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=UO1bu6fwYoOWz/p7z1OTd1k5bj+RKcc08WulqJPLBMU=; b=Ij+SWUHf+yXi1vq+18QYfcFNglKyTtGhR1iNxN8CvAKgUpWpbZWXUoikuzaI1pQIup 58HvwCQCPHbmQ0ONAcyrG+kcIyJAXYkZR61f4RPlI0+OmiF5RzEzv8CH21XvzABRsohi pv2C41uscb/igOkf6rio7pzjhBCgaudaY4Tg4WvNKpF+RVsKXeUWYZfu/iNXafwSf+pZ AY9JlS2aoVXufDQhxH8d93eIpbBl8KOYX7/4mwidg6pNNwADLnwm/ju1qAoaf/AcptfU K54N/kADbg8rG9ARZ3nh3HtiMC6oYBNHUlwmDBKrrTVhc9D0CXdfzbtkWhQIC5cgFF/G OqUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740955; x=1719345755; 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=UO1bu6fwYoOWz/p7z1OTd1k5bj+RKcc08WulqJPLBMU=; b=XS4CRi3U99ZRWLa3ZTFXTcA3Td1vICwc6nyXk9WOkB9c7wldCR7bgJVFim4RucWIfI HsUB7WLgtsKclbfpAHfvtRMtKI1KPK0iE8ypDo/O+PkgMccgdpP+WZ/QQcrcqsz295QD hvw69IVFE6HmPZy/Hg0pXsdM4xpIaHkgf7NYxhhntZhNdAEWJ4/8dKUD9UjJp65smlIe 4gPRCNW6OtC1MUgH5rhcwJb4eFdBlYdgWLVHlvUx8/Pu9z1BzbN34FPXgbubHuGJ7sRy H+4m8OsHVk1lYWbgNeDi7W0B05GSx8388/bPCIc/6H79cu9JHUdho2i2ovTU9oJlkWJ/ VPxQ== X-Gm-Message-State: AOJu0YyWOQm0Gm6O2h1cehp61IZ3x39H28SMDxryLpip4mAMvJO2Sqaf SbNqNfXGCpaUjwQfw6Z4MJxHHShTojH9xd7fN/1ofW5+2XaAlqEXvMd34w== X-Google-Smtp-Source: AGHT+IHrV2NpK9zCMyvpBjnVNT0KEV7tBgcGHhsy0FyA1xgDiTVabhkpl0hhgsYr+F14Jcr0JdKKXg== X-Received: by 2002:a05:6870:a101:b0:254:ad5e:da49 with SMTP id 586e51a60fabf-25c94d05a5cmr839246fac.41.1718740954608; Tue, 18 Jun 2024 13:02:34 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:34 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 02/33] qmi: Rename qmi_result_func_t Date: Tue, 18 Jun 2024 15:01:44 -0500 Message-ID: <20240618200231.1129282-2-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 to qmi_service_result_func_t to be more consistent. --- drivers/qmimodem/call-settings.c | 2 +- drivers/qmimodem/qmi.c | 8 ++++---- drivers/qmimodem/qmi.h | 12 +++++------- drivers/qmimodem/sms.c | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/qmimodem/call-settings.c b/drivers/qmimodem/call-settings.c index 3611c98894a0..8a65217aceb0 100644 --- a/drivers/qmimodem/call-settings.c +++ b/drivers/qmimodem/call-settings.c @@ -24,7 +24,7 @@ struct call_settings_data { }; static void query_status(struct ofono_call_settings *cs, uint16_t message, - qmi_result_func_t fn, + qmi_service_result_func_t fn, ofono_call_settings_status_cb_t cb, void *data) { struct call_settings_data *csd = ofono_call_settings_get_data(cs); diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 632f647e5ea7..c5a4a37b917d 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -141,7 +141,7 @@ struct qmi_notify { uint16_t id; uint16_t message; unsigned int service_handle; - qmi_result_func_t callback; + qmi_service_result_func_t callback; void *user_data; qmi_destroy_func_t destroy; }; @@ -2678,7 +2678,7 @@ bool qmi_service_get_version(struct qmi_service *service, } struct service_send_data { - qmi_result_func_t func; + qmi_service_result_func_t func; void *user_data; qmi_destroy_func_t destroy; }; @@ -2722,7 +2722,7 @@ done: uint16_t qmi_service_send(struct qmi_service *service, uint16_t message, struct qmi_param *param, - qmi_result_func_t func, + qmi_service_result_func_t func, void *user_data, qmi_destroy_func_t destroy) { struct qmi_device *device; @@ -2838,7 +2838,7 @@ static bool qmi_service_cancel_all(struct qmi_service *service) } uint16_t qmi_service_register(struct qmi_service *service, - uint16_t message, qmi_result_func_t func, + uint16_t message, qmi_service_result_func_t func, void *user_data, qmi_destroy_func_t destroy) { struct qmi_notify *notify; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index de6238f25e62..3e532ec25abd 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -60,11 +60,14 @@ typedef void (*qmi_destroy_func_t)(void *user_data); struct qmi_device; +struct qmi_result; typedef void (*qmi_debug_func_t)(const char *str, void *user_data); typedef void (*qmi_shutdown_func_t)(void *user_data); typedef void (*qmi_discover_func_t)(void *user_data); +typedef void (*qmi_service_result_func_t)(struct qmi_result *, void *); + void qmi_device_free(struct qmi_device *device); void qmi_device_set_debug(struct qmi_device *device, @@ -105,9 +108,6 @@ struct qmi_param *qmi_param_new_uint8(uint8_t type, uint8_t value); struct qmi_param *qmi_param_new_uint16(uint8_t type, uint16_t value); struct qmi_param *qmi_param_new_uint32(uint8_t type, uint32_t value); - -struct qmi_result; - bool qmi_result_set_error(struct qmi_result *result, uint16_t *error); const char *qmi_result_get_error(struct qmi_result *result); @@ -130,8 +130,6 @@ int qmi_error_to_ofono_cme(int qmi_error); struct qmi_service; -typedef void (*qmi_result_func_t)(struct qmi_result *result, void *user_data); - typedef void (*qmi_create_func_t)(struct qmi_service *service, void *user_data); bool qmi_service_create_shared(struct qmi_device *device, @@ -146,11 +144,11 @@ bool qmi_service_get_version(struct qmi_service *service, uint16_t qmi_service_send(struct qmi_service *service, uint16_t message, struct qmi_param *param, - qmi_result_func_t func, + qmi_service_result_func_t func, void *user_data, qmi_destroy_func_t destroy); bool qmi_service_cancel(struct qmi_service *service, uint16_t id); uint16_t qmi_service_register(struct qmi_service *service, - uint16_t message, qmi_result_func_t func, + uint16_t message, qmi_service_result_func_t func, void *user_data, qmi_destroy_func_t destroy); bool qmi_service_unregister(struct qmi_service *service, uint16_t id); diff --git a/drivers/qmimodem/sms.c b/drivers/qmimodem/sms.c index 4238665a5e8d..2ac06a40bdd6 100644 --- a/drivers/qmimodem/sms.c +++ b/drivers/qmimodem/sms.c @@ -353,7 +353,7 @@ static void delete_msg(struct ofono_sms *sms, uint8_t tag) { struct sms_data *data = ofono_sms_get_data(sms); struct qmi_param *param; - qmi_result_func_t func = NULL; + qmi_service_result_func_t func = NULL; DBG(""); From patchwork Tue Jun 18 20:01: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: 13702910 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 76675143876 for ; Tue, 18 Jun 2024 20:02:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740957; cv=none; b=tj+52z4iL23JZJbQrwoH/IhP4WDMc28EG3KCt9/DrsV1eAKMg+8CF5CNAVOH1nbh7X6I9FhikQJLrkOowh+Ahad0UNTzjztAWTJk46JIoJnnGLf5PJJpS8p440pSmIp4x/FJnE6ojKZtQGLnjDw7pHWn1DUUI/QlIjfeodppIf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740957; c=relaxed/simple; bh=jhZSc7mmecQDcJyyp7Wo7xsMqmbFD4HSRjTKXpfRInk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oflVndQWfXWaQsRihEWwuWSnsO5WWdDV53tYyoXs+/MHdwg5TCsXb+dg5QU8B62Eam7rLUBMlAnwEq1OngePhNtMhi/zkzQCv+FWCxSfwgyH6SRFTPRZD+oh2UDuhqBKkr8Kte+FglqSRzZSH6u6BQogiR5eIs5KxB+kgkGfLXc= 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=YQt68dee; arc=none smtp.client-ip=209.85.161.46 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="YQt68dee" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-5ba090b0336so2828593eaf.1 for ; Tue, 18 Jun 2024 13:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740955; x=1719345755; 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=/a5GQJiVGU59uFyb+ZmHYVCwEBORjMl826K6459n2W4=; b=YQt68deeAv7h7GnokEpOt/tE2WGUZrqWAFTXjxAne/4P7winLusbUvmYwmA3NJIu9B FsUMeX5Coz6k02qVOA9QMyVwKSuhsDCt9uMqq19fxRuECdPKqEmsqxOeBzkvKJDr+56S +gWkda1ajLEzhguc2rWbSq31ndZSD483T3LC90TV2uBXrYMEvZt+rtPJSelVs5FfPxfp LYDO3R7zprc2lLsvpcc/bfLIOIiEd6kDroT56GVOvpbdWhVMv1IRfQ1I/10yeH72t5Xz ueZZZimMoCpzyv987IzVPR0ROYYVbXn+rfVlfW7lgRqSlbN014WAB2yWZKW66qnFLa+q jfcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740955; x=1719345755; 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=/a5GQJiVGU59uFyb+ZmHYVCwEBORjMl826K6459n2W4=; b=VcnTc7iTdh0MbuSfuxq4UTxwniO7dUZyeX5E/W3e9JnKNLPKy3MLG5yovL80+e+HiY 8w4NsSUkF6i/9p2+5pw02Ctk+bEhFrPV6zRNboE3+YHGnuMKSY6zxG9vbIzrWertVmpt f3vyFm/Fi9A1oaszP66sdbTCTo/CFTEW16bvPtJsQQlxM5lkn0Eg2yambnjI8g8wvZA1 6kaySCIvAskp1EqjmpVOZkLpBJNqmmlxSNfmDivpRFkeMeCv/NpD6TedG9/hi3Mx07nE WFTvz1xisa94rRC/iKCPzjz+DP5CR8m3VPqTZFXVrEv4UFH9UpDYUk2VLPQQDfWL7Nv1 w2PQ== X-Gm-Message-State: AOJu0Yx8wf2N4fL3ix7mqtTv8wHaQqIreh0sHBjNmDKiYI+X7U/7Atno N/R1CHyUjY8bdt3pmQqBe3cDbdHt+5VKJGYbseqTpDtVS3PKHuEYvaX0Fw== X-Google-Smtp-Source: AGHT+IHa+mG7OGVgoo0zktNfJmiuTwTYEd0WGJ7vV/cZ8nWCmBM3nTrzo6iTullch0y+Q5rkATxgew== X-Received: by 2002:a05:6871:5209:b0:254:b3cc:a6d8 with SMTP id 586e51a60fabf-25c94a200famr944778fac.32.1718740955149; Tue, 18 Jun 2024 13:02:35 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:34 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 03/33] qmi: Drop unused major/minor information Date: Tue, 18 Jun 2024 15:01:45 -0500 Message-ID: <20240618200231.1129282-3-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 QMI radio-settings, ussd and voicecall atoms request and store the service version major/minor numbers, but never use this information. Remove this functionality until needed. --- drivers/qmimodem/radio-settings.c | 4 ---- drivers/qmimodem/ussd.c | 3 --- drivers/qmimodem/voicecall.c | 4 ---- 3 files changed, 11 deletions(-) diff --git a/drivers/qmimodem/radio-settings.c b/drivers/qmimodem/radio-settings.c index 8463c84bf1ed..cf0b747eb681 100644 --- a/drivers/qmimodem/radio-settings.c +++ b/drivers/qmimodem/radio-settings.c @@ -21,8 +21,6 @@ struct settings_data { struct qmi_service *nas; struct qmi_service *dms; - uint16_t major; - uint16_t minor; }; static void get_system_selection_pref_cb(struct qmi_result *result, @@ -211,8 +209,6 @@ static int qmi_radio_settings_probev(struct ofono_radio_settings *rs, data->dms = dms; data->nas = nas; - qmi_service_get_version(data->nas, &data->major, &data->minor); - ofono_radio_settings_set_data(rs, data); return 0; diff --git a/drivers/qmimodem/ussd.c b/drivers/qmimodem/ussd.c index 6637ae759c55..51c3aaef7a19 100644 --- a/drivers/qmimodem/ussd.c +++ b/drivers/qmimodem/ussd.c @@ -24,8 +24,6 @@ struct ussd_data { struct qmi_service *voice; - uint16_t major; - uint16_t minor; }; static int validate_ussd_data(const struct qmi_ussd_data *data, uint16_t size) @@ -156,7 +154,6 @@ static int qmi_ussd_probe(struct ofono_ussd *ussd, data = l_new(struct ussd_data, 1); data->voice = voice; - qmi_service_get_version(data->voice, &data->major, &data->minor); qmi_service_register(data->voice, QMI_VOICE_USSD_IND, async_ind, ussd, NULL); qmi_service_register(data->voice, QMI_VOICE_ASYNC_ORIG_USSD, diff --git a/drivers/qmimodem/voicecall.c b/drivers/qmimodem/voicecall.c index c7a5230f9680..aed662da7ef6 100644 --- a/drivers/qmimodem/voicecall.c +++ b/drivers/qmimodem/voicecall.c @@ -24,8 +24,6 @@ struct voicecall_data { struct qmi_service *voice; - uint16_t major; - uint16_t minor; struct l_queue *call_list; struct ofono_phone_number dialed; char *full_dtmf; @@ -721,8 +719,6 @@ static int qmi_voicecall_probe(struct ofono_voicecall *vc, data->voice = voice; data->call_list = l_queue_new(); - qmi_service_get_version(data->voice, &data->major, &data->minor); - qmi_service_register(data->voice, QMI_VOICE_ALL_CALL_STATUS_IND, all_call_status_ind, vc, NULL); From patchwork Tue Jun 18 20:01:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702911 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (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 EADD81C2A8 for ; Tue, 18 Jun 2024 20:02:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740958; cv=none; b=KpQMoqzJU5ihdkPrePi8BaKsOGZk4VwnO+w/LGkpSmr2zVQMrCdKYc97GkcvaZa4d+8TRBNEzRiswlEIY148WPFuW730J5d+lHIkTEiF5fpZ4fg+TV1Bf2QSFXTL1hB7Pae/JldDmBARpM5AugqqTQQESp/1uo664DfZB0RtemM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740958; c=relaxed/simple; bh=cvtgdm1y3G36NkEXoYKr7nrLcI+ssUA9k2ctylwZ3dk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=befDO3dCuOmtlkyUwRetTeaJttrwuUbLjVdd8pCxwbaitITCyXxucmIQZWlBxOuceH2A1KtH1+/pLUbL/k7C2x4P2MppvyVB+ZWZxJdb62NMHkg6HHUZxZfeUI/QY6PhIxQoJnvhrtRvHD8n97tk0/W8IMstac4WKbZlcc2mjBo= 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=MfFl2lDz; arc=none smtp.client-ip=209.85.160.44 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="MfFl2lDz" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-25957dfd971so1341910fac.0 for ; Tue, 18 Jun 2024 13:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740956; x=1719345756; 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=f5bZSi5L/Rb3uzEjv2RqXCaHnwLky7slVhKdTDg/n/Q=; b=MfFl2lDzFfmoaO/ZLRAPGd/V1zWRpaqnpFQ9xckZdjlauiagmI/zOHHXHKzGXeusCT JHqOMBulKOBglDkGUmIeCQICgYn9JsJzC+AkejP7WfZpfxpZs8uNXr2GwsFf6W01gYIb GWyMU4/iFRpN0jprlg3Q2UGHhx9ZNKTaK9c6GkaFlBUmVTAaMbBx2aH5inThVN+mrv4V TNau+gomFu6txLxJUPIEQqnlR1Rpp1ILFEq+rpPCDDC6u7bYTq2nOnYZWTUdS/EL72U+ h8I4pjTDugCN16E6RoNp7LZTsEU+DAW/GGLKb+sUmmUZTCXBi8d28zyoqS8p1ozQIro3 YLww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740956; x=1719345756; 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=f5bZSi5L/Rb3uzEjv2RqXCaHnwLky7slVhKdTDg/n/Q=; b=QGquk3TiuDYmkfaG65k0IpEkmSJAJtmT9m5DrqGJEFAcCaDdzLj/XCUpH8NpehvPH8 l6hBQTaZLIHqYsnvudq9927Inc4E8ZqdiqrPqUOJEFJ8LmMYdpxZQAwgC5AFRp/c6+aA rb2PePX+Jjd13wwOmd/u1v0zZToxi2XmWUwm8l9QbsEb/RbljQhSVV7oXeKBbJ3GR04W 93ziE4dTSti3R0XcmpUhPqq8SuZ6MSH8HYWeqlwFmxqI6y4/XrTLR5auhoqLZ1jbZT0e q2JhCsfxJu5SxMPKSsTdPJqQtH02vxQ/j7nJLZFoA9YCHdcmI7f1Ru2jceHrBXMetg1E ZZrA== X-Gm-Message-State: AOJu0YyljVat0N6vAb/DBUa7Wc5GfsL2+Val+ONvtY1l/3K4d8NTJ/5+ Wo4kx+Jj5S+/oYRGWZw2DsQn9m8QaYQ5DCZ4Wobem+ETgFCg8RmTz8E8Lg== X-Google-Smtp-Source: AGHT+IGHh7YIEdiSZZ8SrjrTJhOpn5p2FzXh61eBy/xrj5Ye0ILz8Ij6BSgWSvzqbiVGdXx4EwSeLA== X-Received: by 2002:a05:6870:6593:b0:254:ab8e:471b with SMTP id 586e51a60fabf-25c94e48921mr1008807fac.50.1718740955889; Tue, 18 Jun 2024 13:02:35 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:35 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 04/33] qmi: Add qmi_qrtr_node_get_service Date: Tue, 18 Jun 2024 15:01:46 -0500 Message-ID: <20240618200231.1129282-4-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce a new method that will return a qmi_service object handle immediately, if possible. This allows the lightweight service handles to be obtained without requiring the caller to provide a callback function and waiting for the event loop to invoke it. On QRTR, the underlying socket can access all services directly without needing to exchange any messages to allocate a client for that service first, as done by QMUX using QMI_CTL_GET_CLIENT_ID. --- drivers/qmimodem/qmi.c | 26 ++++++++++++++++++++++++++ drivers/qmimodem/qmi.h | 7 ++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index c5a4a37b917d..c3b1f7fef64f 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -2332,6 +2332,32 @@ struct qmi_device *qmi_device_new_qrtr(void) return &qrtr->super; } +struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, + uint32_t type) +{ + struct service_family *family; + const struct qmi_service_info *info; + + if (!device) + return NULL; + + if (type == QMI_SERVICE_CONTROL) + return NULL; + + family = l_hashmap_lookup(device->family_list, L_UINT_TO_PTR(type)); + if (family) + goto done; + + info = __find_service_info_by_type(device, type); + if (!info) + return NULL; + + family = service_family_create(device, info, 0); + l_hashmap_insert(device->family_list, L_UINT_TO_PTR(type), family); +done: + return service_create(family); +} + struct qmi_param *qmi_param_new(void) { return l_new(struct qmi_param, 1); diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 3e532ec25abd..604e4e7e8659 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -58,9 +58,9 @@ enum qmi_data_endpoint_type { typedef void (*qmi_destroy_func_t)(void *user_data); - struct qmi_device; struct qmi_result; +struct qmi_service; typedef void (*qmi_debug_func_t)(const char *str, void *user_data); typedef void (*qmi_shutdown_func_t)(void *user_data); @@ -90,6 +90,9 @@ bool qmi_device_set_expected_data_format(struct qmi_device *device, struct qmi_device *qmi_device_new_qmux(const char *device); struct qmi_device *qmi_device_new_qrtr(void); +struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, + uint32_t type); + struct qmi_param; struct qmi_param *qmi_param_new(void); @@ -128,8 +131,6 @@ void qmi_result_print_tlvs(struct qmi_result *result); int qmi_error_to_ofono_cme(int qmi_error); -struct qmi_service; - typedef void (*qmi_create_func_t)(struct qmi_service *service, void *user_data); bool qmi_service_create_shared(struct qmi_device *device, From patchwork Tue Jun 18 20:01:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702913 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (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 2F07C143876 for ; Tue, 18 Jun 2024 20:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740960; cv=none; b=F5kDAZahe3zIcP87K7szhVcjo1suSHiDOI5lWLdszCS/7n4yVHxmSUflPD49qgBU0u0noB8DSXRimNzi9DErlde578FuyzqrP2TxN+6QM6tHDcGz7R2e2QjGtbt/Y3rdd+ZZI34XNJLO3tOlU/mOG0KVLLiLGuKATobwR+8BG4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740960; c=relaxed/simple; bh=xCPRcOMir23ErzpMFbLAKCc68Fb6zC7MqsoGs7cmpaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BbNsos6PVtXnjNzTfsJLtX6BVtMn+nIgQOuKy/stRz4tmIdZ5WPp473rnV8bAcOa4XRiGGPI16hsyyvkc+aMndfwTlN/9N8rHGRaQGamoDr7WD6u8cRKtV4S2lt4u3wGgGGMO/upsEv4pIE/H7hZAhBLKl1UheQJu5V5qCmyhq4= 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=IJyQdrwK; arc=none smtp.client-ip=209.85.160.51 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="IJyQdrwK" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-2550aa6f994so3591969fac.3 for ; Tue, 18 Jun 2024 13:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740957; x=1719345757; 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=oHH0FPmnVXc1se3cvpEwERue28eWfxm8kHgTHoIviMA=; b=IJyQdrwKM3QJ1ioErkA+YDguuEggASqn59ivCuS0m9oWg7AWZvcItR4Qjc0DWA5WrT ZcykNGhf8eh8bubc2wJmpEhk/Lv3U+9BfKibxmRBZdN3ip6PYsH4KnorlGtOdBDfuXua znBy+CK/eZqotk2ENYQEqXV6V0v5hACuuB9xDOKJxcZLx85fleK9qr42v5Jynn1fNdBK M76kZdbNjJU4PzCwD9B+wEtBDlOokLl7ZyXhQDVTS46+5f7EB5mOJIxP6mYX2+gnLaEp CZx7/1ZSOrv34LeaQnsKxOiUrnk6BHsvy4l40Jrx8UUBqBSGuuGSOGIYHk79qNeuhGGl F83A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740957; x=1719345757; 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=oHH0FPmnVXc1se3cvpEwERue28eWfxm8kHgTHoIviMA=; b=SVsnKMYgJR1yRlXmkBS70JtNMlg13VWiaVxG/HfGZ4vFhombDBg2jmFoi+FI9P2T2N 744BOekhLMyuNpSYvugoTz0UTBDZaMN1ycM94d6DQ6qrwLwUyIUrfhM4YwFmTFOPR1xX JjSm0eVxpHRrWSgizxK5Kas7pTCOXHikaJiaABHzk5F+p981a3+FOXrFspI4Cv4UEXO/ jWvhEFkpjE9aDUiOY6qNMtz3Nj1BuPG5rTuDlFaowSGPP+QM+3i8sK0k6z3z7yneUy// UIz66eii7wU42SopgAh/2ziRiYa6qxGb9rxjFeqhSsCPToowMfIZGXohbkyu5NIgv/lZ K4qQ== X-Gm-Message-State: AOJu0YzbvoeY+virTEfJV+7X2TA4xRuUQOUua6z9woWRzItVG+AQK/UI yzKeQvx2NuV8p/nl1B85c0tBqitE7Q1SKPMqeqXVU9xw6VAJ9PCmZmw/oQ== X-Google-Smtp-Source: AGHT+IH7uhTFT9Vda1qxQAZjuHY2W9qYqjhsRMW1uTj6FvbNkZNScUs0144vzPhVxV7XSqxbbnSrJg== X-Received: by 2002:a05:6870:718c:b0:258:3455:4b37 with SMTP id 586e51a60fabf-25c94e50b1bmr821318fac.59.1718740956778; Tue, 18 Jun 2024 13:02:36 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:36 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 05/33] plugins: Add new qrtrqmi modem driver Date: Tue, 18 Jun 2024 15:01:47 -0500 Message-ID: <20240618200231.1129282-5-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This driver will be used for QRTR based devices (MHI bus and SoC) --- Makefile.am | 1 + plugins/qrtrqmi.c | 430 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 431 insertions(+) create mode 100644 plugins/qrtrqmi.c diff --git a/Makefile.am b/Makefile.am index d904dd95c761..d379201d362b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -387,6 +387,7 @@ builtin_sources += $(qmi_sources) \ drivers/qmimodem/call-forwarding.c builtin_sources += plugins/gobi.c +builtin_sources += plugins/qrtrqmi.c endif if MBIMMODEM diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c new file mode 100644 index 000000000000..f75742f98508 --- /dev/null +++ b/plugins/qrtrqmi.c @@ -0,0 +1,430 @@ +/* + * oFono - Open Source Telephony + * Copyright (C) 2008-2012 Intel Corporation + * Copyright (C) 2024 Cruise, LLC + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +#define OFONO_API_SUBJECT_TO_CHANGE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +struct qrtrqmi_data { + struct qmi_device *node; + struct qmi_service *dms; + int main_net_ifindex; + char main_net_name[IFNAMSIZ]; + bool have_voice : 1; +}; + +static void qrtrqmi_debug(const char *str, void *user_data) +{ + const char *prefix = user_data; + + ofono_info("%s%s", prefix, str); +} + +/* + * Probe the modem. The following modem properties are expected to be set + * in order to initialize the driver properly: + * + * NetworkInterface + * The string that contains the 'main' network device. This can be + * "rmnet_ipa" on SoC systems, or "wwan0" for upstream linux systems. + * + * NetworkInterfaceIndex + * The index of the main interface given by NetworkInterface + * + * NetworkInterfaceKernelDriver + * The kernel driver that is being used by the main network device. + * + * Bus + * The bus of the modem. Values can be "embedded", or "pci" + */ +static int qrtrqmi_probe(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data; + const char *if_driver; + const char *ifname; + int ifindex; + const char *bus; + + DBG("%p", modem); + + if_driver = ofono_modem_get_string(modem, + "NetworkInterfaceKernelDriver"); + ifname = ofono_modem_get_string(modem, "NetworkInterface"); + ifindex = ofono_modem_get_integer(modem, "NetworkInterfaceIndex"); + bus = ofono_modem_get_string(modem, "Bus"); + + DBG("net: %s[%s](%d) %s", ifname, if_driver, ifindex, bus); + + if (!if_driver || !ifname || !ifindex || !bus) + return -EPROTO; + + data = l_new(struct qrtrqmi_data, 1); + data->main_net_ifindex = + ofono_modem_get_integer(modem, "NetworkInterfaceIndex"); + l_strlcpy(data->main_net_name, + ofono_modem_get_string(modem, "NetworkInterface"), + sizeof(data->main_net_name)); + ofono_modem_set_data(modem, data); + ofono_modem_set_capabilities(modem, OFONO_MODEM_CAPABILITY_LTE); + + return 0; +} + +static void qrtrqmi_deinit(struct qrtrqmi_data *data) +{ + qmi_service_free(data->dms); + data->dms = NULL; + qmi_device_free(data->node); + data->node = NULL; +} + +static void qrtrqmi_remove(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + + DBG("%p", modem); + + ofono_modem_set_data(modem, NULL); + + qrtrqmi_deinit(data); + l_free(data); +} + +static void power_reset_cb(struct qmi_result *result, void *user_data) +{ + struct ofono_modem *modem = user_data; + + DBG(""); + + if (qmi_result_set_error(result, NULL)) { + qrtrqmi_deinit(ofono_modem_get_data(modem)); + ofono_modem_set_powered(modem, FALSE); + return; + } + + ofono_modem_set_powered(modem, TRUE); +} + +static void get_oper_mode_cb(struct qmi_result *result, void *user_data) +{ + struct ofono_modem *modem = user_data; + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_param *param; + uint8_t mode; + + DBG(""); + + if (qmi_result_set_error(result, NULL)) + goto error; + + if (!qmi_result_get_uint8(result, QMI_DMS_RESULT_OPER_MODE, &mode)) + goto error; + + switch (mode) { + case QMI_DMS_OPER_MODE_ONLINE: + param = qmi_param_new_uint8(QMI_DMS_PARAM_OPER_MODE, + QMI_DMS_OPER_MODE_LOW_POWER); + + if (qmi_service_send(data->dms, QMI_DMS_SET_OPER_MODE, param, + power_reset_cb, modem, NULL) > 0) + return; + + break; + default: + ofono_modem_set_powered(modem, TRUE); + return; + } + +error: + qrtrqmi_deinit(data); +} + +static void lookup_done(void *user_data) +{ + struct ofono_modem *modem = user_data; + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_device *node = data->node; + + DBG(""); + + if (!qmi_device_has_service(node, QMI_SERVICE_DMS) || + !qmi_device_has_service(node, QMI_SERVICE_UIM) || + !qmi_device_has_service(node, QMI_SERVICE_WDS) || + !qmi_device_has_service(node, QMI_SERVICE_NAS)) + goto error; + + data->dms = qmi_qrtr_node_get_service(node, QMI_SERVICE_DMS); + if (qmi_service_send(data->dms, QMI_DMS_GET_OPER_MODE, NULL, + get_oper_mode_cb, modem, NULL) > 0) + return; +error: + qrtrqmi_deinit(data); + ofono_modem_set_powered(modem, FALSE); +} + +static int qrtrqmi_enable(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + int r; + + DBG("%p", modem); + + data->node = qmi_device_new_qrtr(); + if (!data->node) + return -EIO; + + if (getenv("OFONO_QMI_DEBUG")) + qmi_device_set_debug(data->node, qrtrqmi_debug, "QRTR: "); + + r = qmi_device_discover(data->node, lookup_done, modem, NULL); + if (!r) + return -EINPROGRESS; + + return r; +} + +static void power_disable_cb(struct qmi_result *result, void *user_data) +{ + struct ofono_modem *modem = user_data; + + DBG(""); + + qrtrqmi_deinit(ofono_modem_get_data(modem)); + ofono_modem_set_powered(modem, FALSE); +} + +static int qrtrqmi_disable(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_param *param; + + DBG("%p", modem); + + param = qmi_param_new_uint8(QMI_DMS_PARAM_OPER_MODE, + QMI_DMS_OPER_MODE_LOW_POWER); + + if (qmi_service_send(data->dms, QMI_DMS_SET_OPER_MODE, param, + power_disable_cb, modem, NULL)) + return -EINPROGRESS; + + qmi_param_free(param); + qrtrqmi_deinit(data); + return -EIO; +} + +static void set_online_cb(struct qmi_result *result, void *user_data) +{ + struct cb_data *cbd = user_data; + ofono_modem_online_cb_t cb = cbd->cb; + + DBG(""); + + if (qmi_result_set_error(result, NULL)) + CALLBACK_WITH_FAILURE(cb, cbd->data); + else + CALLBACK_WITH_SUCCESS(cb, cbd->data); +} + +static void qrtrqmi_set_online(struct ofono_modem *modem, ofono_bool_t online, + ofono_modem_online_cb_t cb, void *user_data) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct cb_data *cbd = cb_data_new(cb, user_data); + struct qmi_param *param; + + DBG("%p %s", modem, online ? "online" : "offline"); + + param = qmi_param_new_uint8(QMI_DMS_PARAM_OPER_MODE, + online ? QMI_DMS_OPER_MODE_ONLINE : + QMI_DMS_OPER_MODE_LOW_POWER); + + if (qmi_service_send(data->dms, QMI_DMS_SET_OPER_MODE, param, + set_online_cb, cbd, l_free) > 0) + return; + + qmi_param_free(param); + l_free(cbd); +} + +static void qrtrqmi_pre_sim(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_device *node = data->node; + struct qmi_service *voice; + + DBG("%p", modem); + + ofono_devinfo_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_DMS)); + + ofono_sim_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_DMS), + qmi_qrtr_node_get_service(node, QMI_SERVICE_UIM)); + + voice = qmi_qrtr_node_get_service(node, QMI_SERVICE_VOICE); + if (voice) { + data->have_voice = true; + ofono_voicecall_create(modem, 0, "qmimodem", voice); + } +} + +static int setup_gprs_context(uint8_t mux_id, const char *interface, + struct ofono_gprs *gprs) +{ + struct ofono_modem *modem = ofono_gprs_get_modem(gprs); + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_qrtr_node *node = data->node; + struct ofono_gprs_context *gc; + + gc = ofono_gprs_context_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_WDS)); + if (!gc) { + ofono_warn("Unable to create gprs-context for: %s, %s[%hhu]", + ofono_modem_get_path(modem), interface, mux_id); + return -ENOPKG; + } + + ofono_gprs_add_context(gprs, gc); + ofono_gprs_context_set_interface(gc, interface); + return 0; +} + +static void setup_gprs(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_qrtr_node *node = data->node; + int n_premux = ofono_modem_get_integer(modem, "NumPremuxInterfaces"); + struct ofono_gprs *gprs; + const char *interface; + char buf[256]; + int i; + + gprs = ofono_gprs_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_WDS), + qmi_qrtr_node_get_service(node, QMI_SERVICE_NAS)); + if (!gprs) { + ofono_warn("Unable to create gprs for: %s", + ofono_modem_get_path(modem)); + return; + } + + for (i = 0; i < n_premux; i++) { + int mux_id; + + sprintf(buf, "PremuxInterface%dMuxId", i + 1); + mux_id = ofono_modem_get_integer(modem, buf); + + sprintf(buf, "PremuxInterface%d", i + 1); + interface = ofono_modem_get_string(modem, buf); + + setup_gprs_context(mux_id, interface, gprs); + } +} + +static void qrtrqmi_post_sim(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_device *node = data->node; + struct qmi_service *wms; + + DBG("%p", modem); + + ofono_lte_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_WDS)); + + ofono_radio_settings_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_DMS), + qmi_qrtr_node_get_service(node, QMI_SERVICE_NAS)); + + wms = qmi_qrtr_node_get_service(node, QMI_SERVICE_WMS); + if (wms) { + struct ofono_message_waiting *mw = NULL; + + ofono_sms_create(modem, 0, "qmimodem", wms); + + if (qmi_device_has_service(node, QMI_SERVICE_UIM)) + mw = ofono_message_waiting_create(modem); + + if (mw) + ofono_message_waiting_register(mw); + } + + setup_gprs(modem); +} + +static void qrtrqmi_post_online(struct ofono_modem *modem) +{ + struct qrtrqmi_data *data = ofono_modem_get_data(modem); + struct qmi_device *node = data->node; + + DBG("%p", modem); + + ofono_netreg_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_NAS)); + ofono_netmon_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_NAS)); + + if (!data->have_voice) + return; + + ofono_ussd_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_VOICE)); + ofono_call_settings_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_VOICE)); + ofono_call_barring_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_VOICE)); + ofono_call_forwarding_create(modem, 0, "qmimodem", + qmi_qrtr_node_get_service(node, QMI_SERVICE_VOICE)); +} + +static struct ofono_modem_driver qrtrqmi_driver = { + .probe = qrtrqmi_probe, + .remove = qrtrqmi_remove, + .enable = qrtrqmi_enable, + .disable = qrtrqmi_disable, + .set_online = qrtrqmi_set_online, + .pre_sim = qrtrqmi_pre_sim, + .post_sim = qrtrqmi_post_sim, + .post_online = qrtrqmi_post_online, +}; + +OFONO_MODEM_DRIVER_BUILTIN(qrtrqmi, &qrtrqmi_driver) From patchwork Tue Jun 18 20:01:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702912 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (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 9340E1C2A8 for ; Tue, 18 Jun 2024 20:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740959; cv=none; b=VnoeAKvWMMdrIyU9+wuLym2EAmliFSHZu52AYAx5XAo9HXpJpN/aROE7PGdWULHiq5caIEzzgJdHjK/7QR4aaiVcVkYApnxeWunjlGTtV9XgfJGa+Q7VzSge5m63oI7nFl/jNciSWv96LubrCHDRk2UAZj8bb3rZcZvliZFHJTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740959; c=relaxed/simple; bh=SFF15oEOE/+E0tbwO5fuCPcKrHEuiMdsM/IAIgKDYR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fPb0OTCgDLdQ+3vTkbcQJWzn8L/hmEKGXedjNxKJS7SOyQ4gfSraNSJm9kVgYtFoAOfmyAEPZTFqA5ZILKvoHrlex8dieUNThLE4RTCMBdd/To5QAlSDrpT5LbN7tSOIjd/tXHf9E1CNN+PmuZ7GhOnR63dM6kRZTNG12+4j5Iw= 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=JqLbCdBs; arc=none smtp.client-ip=209.85.160.53 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="JqLbCdBs" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-25c9af0102cso9968fac.0 for ; Tue, 18 Jun 2024 13:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740957; x=1719345757; 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=kl+oU570NwiMyhYtTo8ADyrZCetA3v81aYfFwn6Tyew=; b=JqLbCdBsIPiVBFQaAYZnkyi2LHRDH+NMA9gghabMvdWpFkdWyIDQrENitzhYNPcRFR os47KEZKOuZ4B0vaALDNBpvvJd9WTVjY6z0iB7APsqMidgDzcbQW3VhIi0rOb/XE4lwd n+05lIhicCMNmWwvQYbEHkh9KaycXZB62WT085VPF7ZdENnI76+gWSXkYrglmsYxmdUF P/5VfLyivuLIzFo2WDB88iJyOvmiWS7P19sSfWAEztNPphyVaCWjfaOPBU/H4DZhmJld SBM/2gZHEuGPVcw6FdWTxAxf7UUgEgl1cbdO1Ns5sPiTYTlY3IBSwLBqpD8BMS0xdjY4 yF1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740957; x=1719345757; 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=kl+oU570NwiMyhYtTo8ADyrZCetA3v81aYfFwn6Tyew=; b=Swn+A1lbJwmVvtxSYaSfeVg26dtpVvqyB6v3ItltRjvIeJBmZ2TqMDC7vX/WeuVSmk WCJp7PmvyIT9Lh7CW8O4h66TUIiC3exbVBnRznKcZd0n/cbe3FKCGXdfnez+4XHz9xcM zWrGAP58urwefxI4t71gCT3aWq++OcTgej/1wWjZLMw+wqwLZxG+3dE8rYUdLVjukuMs Bg2dNLANXHUQD7FtZRrz0yHHUTf+TW8sxomjZUecuLW2JWAU1O0HSa9YJ3ZLzKuy0CzX +4ARl//yG98ps8WUTDbxMcZh/hoFhXSfbvMYS0iNfMfTKfkAsAmynvuxIMs0ueX8G+yd mpuQ== X-Gm-Message-State: AOJu0YyRknhOrLWIRJHoxZrpPnU6nQTb5AE04UidiS+N643NnSdzicTS oAQsPFwNgWTeTfXUpQCp2Sz7GjA7T3xI0i5u0xtg/kpSBtCSmcY1Ut6juQ== X-Google-Smtp-Source: AGHT+IHJo2OEpyR9ZGxRFsdTvKNkmeKVScp/c+mI6kaod6OE9UZ3cY7PdW2dbLo51zGgx+E8fQd8kQ== X-Received: by 2002:a05:6870:b489:b0:250:876d:2a74 with SMTP id 586e51a60fabf-25c94a0e5c5mr974151fac.30.1718740957458; Tue, 18 Jun 2024 13:02:37 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:37 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 06/33] gobi: Use correct attribute name in docs Date: Tue, 18 Jun 2024 15:01:48 -0500 Message-ID: <20240618200231.1129282-6-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The name should be NetworkInterfaceKernelDriver, not NetworkInterfaceDriver. Fixes: b3ff67d78830 ("gobi: ensure required properties are provided") --- plugins/gobi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 5402bedcc22e..d8fd90153054 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -112,7 +112,7 @@ static void gobi_debug(const char *str, void *user_data) * NetworkInterfaceIndex * The index of the main interface given by NetworkInterface * - * NetworkInterfaceDriver + * NetworkInterfaceKernelDriver * The kernel driver that is being used by the main network device. Certain * drivers such as 'qmi_wwan' or 'qmi_wwan_q' are treated specifically. * From patchwork Tue Jun 18 20:01:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702914 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.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 3388F15E5C2 for ; Tue, 18 Jun 2024 20:02:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740960; cv=none; b=jKvr7KBCPBGWdUsBva7iO9FzfuWPPCV583CH7EXjwZGikeottL0R/wuj+EoHzwgLEIbVdVl9N/YVB97wCNyDK6EjeIAEggQDFKUlb2Je5hq7XyY1lISOBFhKq5oK45ZNPWcE2W1IMa7znOKvdtF6LD5d2c8k1u/ieIKgyFQl61E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740960; c=relaxed/simple; bh=/bJIVDzUX2e5StEymqjn7ZCFKph0WNy6h/8JY7C7LB0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TUO6ZGEEG/YTHrtEjCCs5+jZ8S3Tkts4m6z8zyL9MuiD5wHrGE15ScSBmlxwbg6GI50AZgg3yBPIx8eI6k9JfoJ36piLuXznQ6btRmj4KwzMA/Bt9BM7Ml3ozxwxed5Z+GUr0tJgOHIB2hvQiOYTOkApeYCQCI6gNf6aSAcVDjQ= 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=QW/IexrO; arc=none smtp.client-ip=209.85.160.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="QW/IexrO" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-24c9f628e71so3037609fac.1 for ; Tue, 18 Jun 2024 13:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740958; x=1719345758; 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=Eh4nL2Xqu/H5NtYMM7qVpf7I932OuBKzjLpQY+cEmLY=; b=QW/IexrOuQtBWRrXS9hY6zRYBNMcG+z5wX/j9FTidqipSVK2tve0RfewJs201tvAD6 xKMaIR2AJSpjdeARYykZ7erbJV8mVNnB3eNF5IOHTW2tiHSXJJ/ghFLhtiqh60D3i0H4 FyDCmk5tKAVYDUlVJs+eo1phXeYXjWIxKptvRrFlsn08bb14d76jdvtouehfraJn1v7a ItpU3LDEUeg6SaC41EuZz/iaRQOSQtIOpnkbDpIigXbZkNbSLhG7h6L9GGz0Z08IHx76 HG3qqp5ajhpOj8hAsImtSoH1v/4sNZ5g1SLSDBDDi0w9c4f7PuRStUnrlm03DlXOlgD7 Ip3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740958; x=1719345758; 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=Eh4nL2Xqu/H5NtYMM7qVpf7I932OuBKzjLpQY+cEmLY=; b=CrTbkhGUUk1wxzRCnI0rbKULZ8yyXGT6F9z/SdKrUBOwtn+Cs8N3aI4CNRxFKZixd0 Y7jO9OH5AcjnoE1MaKM3PJwZHrxL7MXTDTMa5np+4As9He1yaBdrFY4GicWs11uVQb3B jXW8u1ricq7BLN0mR4gkBM+r6LotSvTvi31InvS+Ok7ESxj+JZycxSouxIPpZ/xkh6/t qMlOOJcFIEDqQiCQY+YyaaxkouLXC2W71u156TobMMkdWYfMi45UL0c7Zq0cS4DpL2m0 y6ohAji43nxr5S8Pm5uMm/6k59A3VasPbuEUgEJX87pfU9NoNu2GD9ZseF0Dd02xKTMG 1mmw== X-Gm-Message-State: AOJu0Ywz8lb+slSqK0RnT6Bu04DtNkMHfI3M5HCawfG2CskaTLH8I6By HifaVfXkoV0EkSFUDBp0ZrrmbETfoaPWlPx4FPcF+z1Vt5679jOlKuV+4Q== X-Google-Smtp-Source: AGHT+IGH5kdRP1yVlE7OWpDRYbq//G2o0Bk8IOn36Oj2bDxPj7USRapXJhRVfXD8rRrHGEbnocfCgw== X-Received: by 2002:a05:6870:f114:b0:259:ae42:ae33 with SMTP id 586e51a60fabf-25c94a05cdamr946147fac.24.1718740958144; Tue, 18 Jun 2024 13:02:38 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:37 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 07/33] udevng: Use new qrtrqmi driver for MHI and SoC modems Date: Tue, 18 Jun 2024 15:01:49 -0500 Message-ID: <20240618200231.1129282-7-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The new qrtrqmi driver only supports QRTR based devices, so drop the use of DeviceProtocol modem attribute. --- plugins/udevng.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/udevng.c b/plugins/udevng.c index 0b3b9686166b..5ef0bc253562 100644 --- a/plugins/udevng.c +++ b/plugins/udevng.c @@ -278,8 +278,7 @@ static int setup_qmi_qrtr(struct modem_info *modem, return -ENOTSUP; } - ofono_modem_set_driver(modem->modem, "gobi"); - ofono_modem_set_string(modem->modem, "DeviceProtocol", "qrtr"); + ofono_modem_set_driver(modem->modem, "qrtrqmi"); return setup_qmi_netdev(modem, net); } @@ -309,7 +308,7 @@ static gboolean setup_gobi_qrtr_premux(struct modem_info *modem, return TRUE; } -static gboolean setup_gobi_qrtr(struct modem_info *modem) +static gboolean setup_qrtrsoc(struct modem_info *modem) { const struct device_info *ipa_info = NULL; int premux_count = 0; @@ -1798,7 +1797,7 @@ static struct { { "wavecom", setup_wavecom }, { "tc65", setup_tc65 }, { "ehs6", setup_ehs6 }, - { "gobiqrtr", setup_gobi_qrtr }, + { "qrtrsoc", setup_qrtrsoc }, { "mhi", setup_mhi }, { } }; @@ -2487,7 +2486,7 @@ static void check_net_device(struct udev_device *device) /* Collect all rmnet devices with this iflink under a common path. */ sprintf(path, "/embedded/qrtr/%s", iflink); - add_device(path, NULL, "gobiqrtr", NULL, NULL, MODEM_TYPE_EMBEDDED, + add_device(path, NULL, "qrtrsoc", NULL, NULL, MODEM_TYPE_EMBEDDED, device, "qrtr"); } From patchwork Tue Jun 18 20:01:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702915 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (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 22ABB1C2A8 for ; Tue, 18 Jun 2024 20:02:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740961; cv=none; b=XRFsFJDbtrH21LUG9+C/N+fJUzXikWw2NJuXZTb8LPzc8nXW/ZAzsjH/5LA19c1JpLX6Jfc+3GdtBgav1JUvhRP5/MC5n/6RDq5dglxsCw0YSnVfpqy07PLjZiH0DSiom7ys3Jfjt5IJ7RfkFopsWdm5Ky7mN0e9JOB07le6Xzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740961; c=relaxed/simple; bh=aOiIF2qWhosuhySXMbzaARIfXrdtQwwPTF1EeT6t4JU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DcxBJf6C+QeJqiCwBrh5NWk57v4zhrwiaWhDv+gLhgZeZ9Ka139ElLjXzj3NqfSRG5878KwKpG9OOYkL2GK1Br14bgbhuqLB7KX8/7rmg1iuE1r9cVcaRJSzorEqkEcuZXkgmisMR6q88wizp4RmKHe7jqtnE/HnsxSHzqSqzys= 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=Y3tDJMsJ; arc=none smtp.client-ip=209.85.160.48 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="Y3tDJMsJ" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-25c9af0102cso9980fac.0 for ; Tue, 18 Jun 2024 13:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740959; x=1719345759; 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=qFznyV02qpqrwykiXcHYRRv4uVXbs4n0PtmvjIgp3qE=; b=Y3tDJMsJYpLpUBoFydSmyjDphNU3xcbl7z9md1HIl9DPiuPO4O+KLT1Tur7pAS+qYL wO4piPZ40kpdi9G44b7ElRUcUltY5Zke1X+pdPShGovNDy+Box3mTxcyu0JeclLc2+Rb AEaxw64bJmmBr2qM1cR9l8amNBdbIfTNStmr6PsGmsPJNF5kxWWwRkC5UauCEysgeCzY TrhY34iIZStEl0QAnq7lEW5BwmNbfd1s8jySFceFGWWqh5Mlsiwtll0LVzKOuD5zFC4t 8F23GGQKBXvQjraV4PuatcdggwsJUhDgfR+dG4S9UkHTK/jFptv0XGcCvPFZ6PTba2Xs asbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740959; x=1719345759; 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=qFznyV02qpqrwykiXcHYRRv4uVXbs4n0PtmvjIgp3qE=; b=xKPJqng4agN+CMIp9HwgVVpphHxhuTKdpS0en6ZFsK+62kRGyDpi6lFS4AJ/EWd33l 8J7epg30H7JIGjE0SsgezyzZE70GRWU6dB9wxmkekzvrFM79GDzSyz5WxxgbLNNYEJS0 NUHSwKu/fnvjMKWx1YsjOLRLOX8Ml6tDf9MKN3FjMpOLZklfYNBHr19GYL6r/cr8rqPH oQV6o5HM7GXqMVbz+gzTJaTqCsGlmimixCEJh0I7BamAu0o5D1YCba0EDhnENHjco8S5 iAgHaxNZPAF6NIDqf4saZT+EzNjkqeR7tPSyMNntb8BTP1cWa+TrL3tICUbOzmY8q2qz DyAA== X-Gm-Message-State: AOJu0YwfOwEAy8R8ivimljpARW3S0z5SwObX+ujbhr6gJqXU3QxZbFlK rCilnCuBhQcUNpCn2O/8EcOajcOw8z3GYy7OdG94PruIn1R4weNdObjMVw== X-Google-Smtp-Source: AGHT+IEaN0ehWBuN2SOhMbojdbxs3BLrMXJI27dnLabtt6kgSpJZcVssxHaYf8mqScO+6m1Rtof/yQ== X-Received: by 2002:a05:6870:1705:b0:254:9c46:8877 with SMTP id 586e51a60fabf-25c9499a393mr828942fac.16.1718740958863; Tue, 18 Jun 2024 13:02:38 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:38 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 08/33] gobi: Remove qrtr support Date: Tue, 18 Jun 2024 15:01:50 -0500 Message-ID: <20240618200231.1129282-8-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 QRTR based devices will now be managed by the qrtrqmi driver. --- plugins/gobi.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index d8fd90153054..d1da5fbc366b 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -55,11 +55,6 @@ #define GOBI_VOICE (1 << 6) #define GOBI_WDA (1 << 7) -enum qmi_protocol { - QMI_PROTOCOL_QMUX, - QMI_PROTOCOL_QRTR, -}; - struct service_request { struct qmi_service **member; uint32_t service_type; @@ -87,7 +82,6 @@ struct gobi_data { char main_net_name[IFNAMSIZ]; uint32_t max_aggregation_size; uint32_t set_powered_id; - enum qmi_protocol protocol; }; static void gobi_debug(const char *str, void *user_data) @@ -101,10 +95,6 @@ static void gobi_debug(const char *str, void *user_data) * Probe the modem. The following modem properties are expected to be set * in order to initialize the driver properly: * - * DeviceProtocol - * Can be "qrtr" or "qmux", tells the driver which QMI encapsulation protocol - * is being used. - * * NetworkInterface * The string that contains the 'main' network device. This can be * "rmnet_ipa" on SoC systems, or "wwan0" for upstream linux systems. @@ -122,8 +112,6 @@ static void gobi_debug(const char *str, void *user_data) static int gobi_probe(struct ofono_modem *modem) { struct gobi_data *data; - const char *value; - enum qmi_protocol protocol; const char *if_driver; const char *ifname; int ifindex; @@ -131,15 +119,6 @@ static int gobi_probe(struct ofono_modem *modem) DBG("%p", modem); - value = ofono_modem_get_string(modem, "DeviceProtocol"); - - if (l_streq0(value, "qrtr")) - protocol = QMI_PROTOCOL_QRTR; - else if (l_streq0(value, "qmux")) - protocol = QMI_PROTOCOL_QMUX; - else - return -EPROTO; - if_driver = ofono_modem_get_string(modem, "NetworkInterfaceKernelDriver"); ifname = ofono_modem_get_string(modem, "NetworkInterface"); @@ -152,7 +131,6 @@ static int gobi_probe(struct ofono_modem *modem) return -EPROTO; data = l_new(struct gobi_data, 1); - data->protocol = protocol; if (!strcmp(if_driver, "qmi_wwan_q")) data->using_qmi_wwan_q = true; @@ -519,19 +497,11 @@ static int gobi_enable(struct ofono_modem *modem) DBG("%p", modem); - switch (data->protocol) { - case QMI_PROTOCOL_QRTR: - data->device = qmi_device_new_qrtr(); - break; - case QMI_PROTOCOL_QMUX: - device = ofono_modem_get_string(modem, "Device"); - if (!device) - return -EINVAL; - - data->device = qmi_device_new_qmux(device); - break; - } + device = ofono_modem_get_string(modem, "Device"); + if (!device) + return -EINVAL; + data->device = qmi_device_new_qmux(device); if (!data->device) return -EIO; From patchwork Tue Jun 18 20:01:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702916 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 978C616DC1E for ; Tue, 18 Jun 2024 20:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740961; cv=none; b=lN+pDhgZz1uuPCvubTFWs+0+u2C9nhOONETVygyVlW9Usju2pOEDJ3UR56vUE99QOS9l4tfMrwFGCBf+McD4K3AhcDUj2S734zm5KLs7PfE7OhGJGLbtZkAPEJmCdlLouVzoJpOincp/mpVBD/LPitcp2cazax27SXqepZECxfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740961; c=relaxed/simple; bh=Y1PdZud7erIXoShijODcPVTJniAFQD+o57VgIzmdn1E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EShtXqaKa5EjTzr3HgVqgCHS0l0llrFgxcyxICH0QXcO2r8AbSTO1WNfflRL7FXzan0cPY8YUbpFUzlMfRlGhictWt5vj1Xbu5BuzBO7EV0Pf2U0t8B7Xk8wEGKoECsCsUgLQXAki5mx0W16mdeH0ippsA8LJbk1inyfbFRtSB4= 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=DWsaBRc9; arc=none smtp.client-ip=209.85.160.47 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="DWsaBRc9" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-2597922eb9eso592439fac.3 for ; Tue, 18 Jun 2024 13:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740959; x=1719345759; 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=NMJ76HT01RXhDJay/m4oOJX4o+vlJaUvm7hJAa6MQ2I=; b=DWsaBRc9RQDg5DdbUWQYPA3FP0NA2Kk5glZO2LBXPtmol4GwNN5tCdSvoh8w/Aczz3 KSpJgSmopW4w90ou2JfM4kQlNbm4/DIvRYlVjAYlQwzMAhe+V3mFX90yPXCbSue7tPcj U2DqsydxI6CtOQ71fLRPcll8FvTPegYWsrHDAZs9ocFYSuq8a5Vid8N7jZDOjWffSWgd cP67454SrWV+3vszbsll5nl/q/9eTsWIvUNFRTvP6CICSdTfs1fGwQbkAN8Ds9qdLIFC AwQ4+TTXpud1tQKpVPvyIh6karvneQRcJ1MVpnulAQmMQ9XiX+ySJ16ico0Eg38DTQt2 7NvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740959; x=1719345759; 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=NMJ76HT01RXhDJay/m4oOJX4o+vlJaUvm7hJAa6MQ2I=; b=mJRIKdn17qd38zObAepaJnBKKpfg6S3tjIW7KnD9mgG2dKfGgISz47TFFsP5F+nvop 90TGjdo7urqfQtLE9udBdl0Viqu6MFnV3RDcmgUQaG3+U9kJgAk7Y3hsxJvotjUwBZZ5 ZbsC6M+uYY+uz7mpgb0NFlLKUha58EbrrEZliZ5RU3smcT6tGOrJpl6G6Kf6g4VhLZjt 93PlI7mfNfZBy0XGrP8jMBgJvxOK+L5UjNhBZk7VK/LLkhLnmjXeGYcUwoBCnFjTO+30 fJFlddE7KzzBNtwSqNs5AZcCV647Otjj/+74v+L0OzrRhuildkn3k+8qPwB6M+QlQ7hr Df8g== X-Gm-Message-State: AOJu0YypXaD74l4n2SJUKbUeePH17wUFeFJKqkb3gncGLskJcy/YJ97m RG7htWyvNQT91G0LiVsjeOsA0Qq6PUqhz0jilvucxZZutsEoaIXyYa3FBw== X-Google-Smtp-Source: AGHT+IGzlILCVZ21hNGBx7YzkVFXGCPmOhIbzjLkqd0JyiOe0nYbn0Ns6MCmm1xUgM5oUg+VPwalfw== X-Received: by 2002:a05:6870:218d:b0:254:b6f0:21b6 with SMTP id 586e51a60fabf-25c948edb19mr941847fac.10.1718740959486; Tue, 18 Jun 2024 13:02:39 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:39 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 09/33] udevng: Do not set DeviceProtocol Date: Tue, 18 Jun 2024 15:01:51 -0500 Message-ID: <20240618200231.1129282-9-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This attribute is no longer used by the gobi driver. --- plugins/udevng.c | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/udevng.c b/plugins/udevng.c index 5ef0bc253562..864f9c12b9c2 100644 --- a/plugins/udevng.c +++ b/plugins/udevng.c @@ -252,7 +252,6 @@ static int setup_qmi_qmux(struct modem_info *modem, ofono_modem_set_driver(modem->modem, "gobi"); ofono_modem_set_string(modem->modem, "Device", qmi->devnode); - ofono_modem_set_string(modem->modem, "DeviceProtocol", "qmux"); ofono_modem_set_string(modem->modem, "InterfaceNumber", net->number); ofono_modem_set_string(modem->modem, "Bus", "usb"); From patchwork Tue Jun 18 20:01:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702917 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 35F1B15E5C2 for ; Tue, 18 Jun 2024 20:02:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740962; cv=none; b=qvd7BCOqUgQMGLchNZBnQ0se5f+/cAMiIfAFD0BghNTSg5MNF3RmD6zAvBZ5LiO+nKYN4+xwQRSGbloOGI0w59A2uIrF1AZL9+EFQid3LKc3gor1Xjxv2ICqlv8jF14REdTEs4YeqqroJIbb3Ke3COEAWDvKUyB/4b939Ti9djM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740962; c=relaxed/simple; bh=rPM/i4e7JNbB0GoUVEilA/feGaIkpNm+nSVtOMNo4+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=meS9/46lAC/RcdbjbfXrhbTTltz6dqdn2SmvhXugs9LeT/o4IKwY9mSTYhqf7HLCLNLCQqPkpQiI+GEPL2fsWF4ib7v3JPcgBr2yySm1+5MYAS1eydU19tc+QTXFyrgqcslvkEwgH9/6Ma+/tT78tLbS9Js1VWpsSKpwWrHH6no= 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=W2u0kEnt; arc=none smtp.client-ip=209.85.161.46 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="W2u0kEnt" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-5bad217c51aso3162022eaf.1 for ; Tue, 18 Jun 2024 13:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740960; x=1719345760; 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=2EDL8Ih8ViGlHl/Bpn1rDCvC2MR4b8VD2nremi7vdg4=; b=W2u0kEntNU8Z13L9Htp/GdOfA17P7QF/+VlFS/EDdyqdJUcn5jsXrXYjdAeG87681+ t+DnVXegMKJp0jTEPWoEQ5YNMF3cXLk7RZTPMBhQYZsrZw/btNavNC93vWCfXRkxJ5AO /sM/A3S5fkZiV318KB8tkOMXKWtzFGsIwF5LEG4nVcdngoeztThiu6qcQbZj8LtCc3sb /RNig+CpLkqdGMde1dQ/hz00Y5mNZ6pQfitQ3dQ/AZOpKzDAWILrAJEq4RnmHxggEXDv NW+TdZcit+BV5cVIBkiM5s5AXml6Gxxy2y9Fnkczk8uikEE1AE1s7R/zkz5R2wPfO2Ep X7Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740960; x=1719345760; 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=2EDL8Ih8ViGlHl/Bpn1rDCvC2MR4b8VD2nremi7vdg4=; b=k/+KGPug3uS/mV2RBX3RScOI5QZ/XEjFhvmcp/1MCQhc8/CtNkKSRG/BNJzx4PH++K Jo9cOnjf/iqAk/X4ojDx1ou4aI71si05RMtMWpBblZ9sKWejrmxaO2izTMDfZBcE7vmf bUFewNUZAJ1T/XHAc+jLAahy2SCa2oWO1D2VOeK8wMwOyDdj3fhGa0B14x3g7Ji6dCJL olYerKLKzaw+oE55QRYVTQcxJGqewzoyAWdlZlxrQ+PMoTj/XNPdYq3ScK0S7cHJmpsH RHIDiWNO7zIzB56M+1ktsbSAi3rFBEpKyoWkKHTtqUgIZTK+KZfKjayGCvDdGZitFI+x 8/Zg== X-Gm-Message-State: AOJu0YzfGrqBKShy9X7dqbI+oe+aPVa5xAXC9FPLducXlPYL8yY6qXxR KdRZXgGaf4V7BZzcp0hVRzdovk2ngHVII3LRQLAovvLKvBKQK/uktsEkWA== X-Google-Smtp-Source: AGHT+IEhatvLTYBr6tOGhFd3GJ6NwKhO9zJAsMlalP2HxDz1dp3ORi8CJRQt9yX6akRXJNZ6yNTxmg== X-Received: by 2002:a05:6871:554:b0:24f:e832:de19 with SMTP id 586e51a60fabf-25c94d02f56mr819918fac.47.1718740960121; Tue, 18 Jun 2024 13:02:40 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:39 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 10/33] unit: Rename device to node Date: Tue, 18 Jun 2024 15:01:52 -0500 Message-ID: <20240618200231.1129282-10-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This better reflects the terminology on the QRTR bus --- unit/test-qmimodem-qmi.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index c7db6a053ef5..07560aadcc49 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -32,7 +32,7 @@ struct test_info { int service_fds[TEST_SERVICE_COUNT]; - struct qmi_device *device; + struct qmi_device *node; struct l_timeout *timeout; struct l_queue *services; @@ -153,11 +153,11 @@ static struct test_info *test_setup(void) info = l_new(struct test_info, 1); setup_test_qrtr_services(info); - info->device = qmi_device_new_qrtr(); - assert(info->device); + info->node = qmi_device_new_qrtr(); + assert(info->node); /* Enable ofono logging */ - qmi_device_set_debug(info->device, debug_log, NULL); + qmi_device_set_debug(info->node, debug_log, NULL); info->services = l_queue_new(); info->timeout = l_timeout_create(TEST_TIMEOUT, test_timeout_cb, info, @@ -174,7 +174,7 @@ static void test_cleanup(struct test_info *info) l_timeout_remove(info->timeout); l_queue_destroy(info->services, (l_queue_destroy_func_t) qmi_service_free); - qmi_device_free(info->device); + qmi_device_free(info->node); /* The qrtr services will be destroyed automatically. */ for (i = 0; i < TEST_SERVICE_COUNT; ++i) @@ -185,7 +185,7 @@ static void test_cleanup(struct test_info *info) l_main_exit(); } -static void test_create_qrtr_device(const void *data) +static void test_create_qrtr_node(const void *data) { struct test_info *info = test_setup(); @@ -201,7 +201,7 @@ static void discovery_complete_cb(void *user_data) static void perform_discovery(struct test_info *info) { - qmi_device_discover(info->device, discovery_complete_cb, info, NULL); + qmi_device_discover(info->node, discovery_complete_cb, info, NULL); while (!info->discovery_callback_called) l_main_iterate(-1); @@ -246,7 +246,7 @@ static void test_create_services(const void *data) uint16_t major, minor; service_type = unique_service_type(i); - assert(qmi_service_create_shared(info->device, service_type, + assert(qmi_service_create_shared(info->node, service_type, create_service_cb, info, NULL)); perform_all_pending_work(); @@ -266,7 +266,7 @@ static void test_create_services(const void *data) * call the callback. */ service_type = unique_service_type(TEST_SERVICE_COUNT); - assert(!qmi_service_create_shared(info->device, service_type, + assert(!qmi_service_create_shared(info->node, service_type, create_service_cb, info, NULL)); perform_all_pending_work(); assert(l_queue_isempty(info->services)); @@ -275,7 +275,7 @@ static void test_create_services(const void *data) service_type = unique_service_type(0); for (i = 0; i < L_ARRAY_SIZE(services); i++) { - assert(qmi_service_create_shared(info->device, service_type, + assert(qmi_service_create_shared(info->node, service_type, create_service_cb, info, NULL)); perform_all_pending_work(); @@ -455,7 +455,7 @@ static void test_send_data(const void *data) perform_discovery(info); service_type = unique_service_type(0); /* Use the first service */ - assert(qmi_service_create_shared(info->device, service_type, + assert(qmi_service_create_shared(info->node, service_type, create_service_cb, info, NULL)); perform_all_pending_work(); service = l_queue_pop_head(info->services); @@ -505,7 +505,7 @@ static void test_notifications(const void *data) perform_discovery(info); service_type = unique_service_type(0); /* Use the first service */ - assert(qmi_service_create_shared(info->device, service_type, + assert(qmi_service_create_shared(info->node, service_type, create_service_cb, info, NULL)); perform_all_pending_work(); service = l_queue_pop_head(info->services); @@ -567,7 +567,7 @@ static void test_service_notification_independence(const void *data) l_io_set_read_handler(io, received_data, info, NULL); for (i = 0; i < L_ARRAY_SIZE(services); i++) { - assert(qmi_service_create_shared(info->device, service_type, + assert(qmi_service_create_shared(info->node, service_type, create_service_cb, info, NULL)); perform_all_pending_work(); services[i] = l_queue_pop_head(info->services); @@ -623,7 +623,7 @@ int main(int argc, char **argv) __ofono_log_init(argv[0], "*", FALSE); l_test_init(&argc, &argv); - l_test_add("QRTR device creation", test_create_qrtr_device, NULL); + l_test_add("QRTR node creation", test_create_qrtr_node, NULL); l_test_add("QRTR discovery", test_discovery, NULL); l_test_add("QRTR services may be created", test_create_services, NULL); l_test_add("QRTR service sends/responses", test_send_data, NULL); From patchwork Tue Jun 18 20:01:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702918 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.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 E465E15E5C2 for ; Tue, 18 Jun 2024 20:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740965; cv=none; b=Ipqy+gcs1wIM2E24By6rMDzWffEytXxICtRJoAarmMePW+n8gxkLdw9MNck4eFiQd5YkvlAhblvseTLmAjLrBO3K2ld/VTal9WN66/eFIn9ergBlrUu6ziiC0DlLISJT45MHCmUunyvl4oPQSQ+kvQVbYiccPKuzrIYfmpExGcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740965; c=relaxed/simple; bh=PUqciVf6SyF29ynkB5ohCCJxvD+yzNgmrz+ZPf4RSbw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fw0CqgcL11BxT9w5ZbLqCoHurrCpY80XaUHJ/lzIOUOPalI1Yebt46nZ3qyutWdYsoEvbdRKVdA1v1fGiOk8ypC5/8tRSkf+fsRADlLorlXLFvTYidKbnEbmKBWTolpSfpz7nE9yN+A30eSFJHrFFWmKB+erwzbQ6QK060rbDn4= 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=AuyezpTO; arc=none smtp.client-ip=209.85.160.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="AuyezpTO" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-25982aa59efso384595fac.3 for ; Tue, 18 Jun 2024 13:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740963; x=1719345763; 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=anqT9mrgm63Yh56RVd+qcXTDOPv5O3/l9gYFo2LaGVE=; b=AuyezpTOOHd/ho+/tI3NRcQzGkQsBfGq21c/iSFvpeYcjFuX4VPwwdiegVNd+BZvOA V9PzN35sCgLDzKyh29UUlp18BW+4zwCIy+OoEb5hz/T6BMO2P7u3hDn97Ovpnw4Uh+Rg HvzF4AbWprJIRakbpJoqbyz4DiG0CRRHB+qOTPX/EvxE6w9/8D059GHO0d8PE4kdB8lq A5plWNkfjm4Qo0aK9ywftTJTbzgU8lTRibBXM4MAlOc7Uakq3F7NBEq3Js29gIg/UZf2 t2yR7TUptsRa71JQbXxkeCDGT2mUtrPW9xnAA/ZnNcPDx2vJKlZiw58dKc88NmyBhpR8 q4ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740963; x=1719345763; 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=anqT9mrgm63Yh56RVd+qcXTDOPv5O3/l9gYFo2LaGVE=; b=I5pxAQaGAFGagquq57x7NOnku5GNGW1rZ79PobEJzUIMP7WrhEj16DQVQSCxTfx6Ih iQgKIEee2d6XGl93YyAuG8ROmYuwX9RVL5HhCiXstc3xwwu6phL80yq9ZKZUh0LN/fJZ tyjqyBJi9+1rF5yc2/KO0sQEJiZLPZwDDRqsa81FqP1XzfMxkY+YDwpDeZHwqq8Nyt22 0gsQWGq2LPt9qj50JIkSOM84cbbvKouoNpqv0vwX2UNkE//lXongWhwkgox/Uk/Iaofu hNUja0/G9HFr6Jnjjya/OalrszwtQSVZ5LzvYNhYpvxkljPvK1X45wo1d0O/bLAajvyd rIhw== X-Gm-Message-State: AOJu0YyPj1yI/bV5rUbWdv129wUvCJR0IYmtaekxBkNZ8wf2dz2lqXMf qbEPf0Fxr4T16IHb+LV/M4Q2vMKnJIegPul8MfDPDRP+4si4bWXX3YOh6A== X-Google-Smtp-Source: AGHT+IELhTyF8vOkGHukTFUGjqRcqPvA6kfghFvWHwdRrKROHt8121o69P4qtLfMbJrqODoMI8vqRw== X-Received: by 2002:a05:6870:1608:b0:254:b781:2f71 with SMTP id 586e51a60fabf-25c94d7349cmr904056fac.57.1718740960768; Tue, 18 Jun 2024 13:02:40 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:40 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 11/33] qmi: Rename qmi_device_new_qrtr to qmi_qrtr_node_new Date: Tue, 18 Jun 2024 15:01:53 -0500 Message-ID: <20240618200231.1129282-11-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This better reflects the terminology used on the QRTR bus. A 'node' parameter is introduced. It is currently unused, but in the future will be used to specify which node is being addressed by the created object. --- drivers/qmimodem/qmi.c | 2 +- drivers/qmimodem/qmi.h | 2 +- plugins/qrtrqmi.c | 2 +- unit/test-qmimodem-qmi.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index c3b1f7fef64f..a845e3809090 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -2310,7 +2310,7 @@ static const struct qmi_device_ops qrtr_ops = { .destroy = qmi_device_qrtr_destroy, }; -struct qmi_device *qmi_device_new_qrtr(void) +struct qmi_device *qmi_qrtr_node_new(uint32_t node) { struct qmi_device_qrtr *qrtr; int fd; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 604e4e7e8659..10202fba6128 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -88,8 +88,8 @@ bool qmi_device_set_expected_data_format(struct qmi_device *device, enum qmi_device_expected_data_format format); struct qmi_device *qmi_device_new_qmux(const char *device); -struct qmi_device *qmi_device_new_qrtr(void); +struct qmi_device *qmi_qrtr_node_new(uint32_t node); struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, uint32_t type); diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index f75742f98508..adf6625e2824 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -208,7 +208,7 @@ static int qrtrqmi_enable(struct ofono_modem *modem) DBG("%p", modem); - data->node = qmi_device_new_qrtr(); + data->node = qmi_qrtr_node_new(0); if (!data->node) return -EIO; diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index 07560aadcc49..0fedd9803bb5 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -153,7 +153,7 @@ static struct test_info *test_setup(void) info = l_new(struct test_info, 1); setup_test_qrtr_services(info); - info->node = qmi_device_new_qrtr(); + info->node = qmi_qrtr_node_new(0); assert(info->node); /* Enable ofono logging */ From patchwork Tue Jun 18 20:01:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702919 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 5D64716DC1B for ; Tue, 18 Jun 2024 20:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740965; cv=none; b=ANK0GpdcO1ViASER+0qgHAOQO0wl1AB/u1Z5ou5jXNf2rRCYHqPixYQ7oZ89JeT2cwsD5QArB0gNNm4HNXR/W6yGbGE1+xilx8gmNYm3uUNw6ARSZb0uldtvk+RSU8cJRTc7fb2iPW/OrJ+PubxiX18RY0yHw+GufjkfCM+DV1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740965; c=relaxed/simple; bh=ckvNClCkY8uqwNMkaBkcQ/Dv+40u6hUo0a6BgUt+mCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m6heomTgBlYWAqnG2Ex8Cl6ezbr6r4aFd4Aj236lwjuuz/O0qkMRajCzelTOXSjx3XKZVW9kMQJkkOWjuNwJAw/0d+wVWZKNYadPmuF5Q8kngAzWYuDcz+xmKFCa0L+1xwlMnZDcdOntahrcAeLoq6T9C/WUGdVRVMo8TvU198M= 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=I/OS2Q6o; arc=none smtp.client-ip=209.85.160.45 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="I/OS2Q6o" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-2598f517a33so378221fac.1 for ; Tue, 18 Jun 2024 13:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740963; x=1719345763; 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=l0LW8jWwDVbJfyz4Pq2lQKVb+OW0QTh8Ef+fpjZXzDw=; b=I/OS2Q6o91QjGP0iAMyBtvmfDbvv4AZgj7qjtTN3+1RvEFkAraoU6S1Ebl3RSQZx9m Fz5CFhMyELOOEWjkKVc0EQGGehvTtas+c3RKjIAiVelDcbq7lFutohx2F5y/HedD0jQW nDDO8W5haIC2ARaxm91QfHzPAB3bBfK2g6Lw0nYdlTLQLdU6UdiTXdzLkMuU1/TBZ8e/ +/ORS3l8gBT3vMg2uAqXkt6uTRaDvOFDnGOfmaVCj62RWWhhQA/5tvqixdoR0hlh+uCt L3Dm+6x060mE5vYjsxYIDruKSVYKIVcdpQMQEu9T31D6zUPA81XdWcqHQaWEpAbnR7lo ZDwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740963; x=1719345763; 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=l0LW8jWwDVbJfyz4Pq2lQKVb+OW0QTh8Ef+fpjZXzDw=; b=QDakuEB3FdTnPfmE8XMU9Lk+vkVQvnloltkNwYroKCVoizqOkWdhJtz5850lQ3NYBp O3rG0Sqo65idlcDl4onadkR2QlbWUcIedh6l4cfWzU3plW97EQpk6+jewSL9h7axTEO9 SEitHAP2p4P2+TfrbJ7/KclhNKiutjQPhtH/JO9rIlEONj9fjdTGg4/un98HatdN4xwd lj3Fa5+m7IgSA8mgMiSXLHUoc30PfRP2tx5CMQ1MFvCvPPs0odMoltbGJabgt9YqjM4h JM1xfx5MEoGl1wKmPI03IpR7lUtEXuLsEb/Q6joKz3is5iGbvznMA5zcqrorKt13mURr GhAg== X-Gm-Message-State: AOJu0YyL/lMZicWZ8DZ+VpVwXskO6m2uPP6YAxSHE30KBlfe9AnYwX7G 4lvDTKWDx1IyCxuTx3VUahm3SuJa2oCp18UZEQWUBt4PEcyWRDOEIpoieg== X-Google-Smtp-Source: AGHT+IEZ2NX00qxuM7rUAYGf+FVDQqvScxNTd0+EPh1sJ6vx7w0+q7R5mpduusxPqok1YRSWV6h5Yg== X-Received: by 2002:a05:6870:a11e:b0:254:a3b9:9756 with SMTP id 586e51a60fabf-25c94a212e1mr925387fac.32.1718740963399; Tue, 18 Jun 2024 13:02:43 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:43 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 12/33] qmi: Rename qmi_device_new_qmux to qmi_qmux_device_new Date: Tue, 18 Jun 2024 15:01:54 -0500 Message-ID: <20240618200231.1129282-12-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- drivers/qmimodem/qmi.c | 2 +- drivers/qmimodem/qmi.h | 3 +-- plugins/gobi.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index a845e3809090..9fdc209edf7c 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1991,7 +1991,7 @@ static const struct qmi_device_ops qmux_ops = { .destroy = qmi_device_qmux_destroy, }; -struct qmi_device *qmi_device_new_qmux(const char *device) +struct qmi_device *qmi_qmux_device_new(const char *device) { struct qmi_device_qmux *qmux; int fd; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 10202fba6128..966d4f354d6e 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -68,6 +68,7 @@ typedef void (*qmi_discover_func_t)(void *user_data); typedef void (*qmi_service_result_func_t)(struct qmi_result *, void *); +struct qmi_device *qmi_qmux_device_new(const char *device); void qmi_device_free(struct qmi_device *device); void qmi_device_set_debug(struct qmi_device *device, @@ -87,8 +88,6 @@ enum qmi_device_expected_data_format qmi_device_get_expected_data_format( bool qmi_device_set_expected_data_format(struct qmi_device *device, enum qmi_device_expected_data_format format); -struct qmi_device *qmi_device_new_qmux(const char *device); - struct qmi_device *qmi_qrtr_node_new(uint32_t node); struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, uint32_t type); diff --git a/plugins/gobi.c b/plugins/gobi.c index d1da5fbc366b..5463a46edecb 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -501,7 +501,7 @@ static int gobi_enable(struct ofono_modem *modem) if (!device) return -EINVAL; - data->device = qmi_device_new_qmux(device); + data->device = qmi_qmux_device_new(device); if (!data->device) return -EIO; From patchwork Tue Jun 18 20:01:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702920 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (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 0E5D916DC21 for ; Tue, 18 Jun 2024 20:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740966; cv=none; b=XK2cqfegXCsvt3q0fyEgpr0IIVUGQzldIbVmkheM6xX882dew3ISB+bR1E2h/KgxrTQuVhZAmKaN0qeW/jfM368a+RtnSt8xZZ4MuqkOJWq24QmKV/dpONySk+ZrrDg3/QjgmLzuccf+Fyml73Y7Uksn5w4VOfcWVJPmrg+ljXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740966; c=relaxed/simple; bh=+zhDgJw/D82iGKx28eTwBX4xQruzeo5sOR/AkeOGjoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AFJyaHcX6xl2UOOWon7E86vPWtrG+NW2WkV3rjUl4eNLYJ3fQPA2R3NzJgEmqoocYkxXodD09hpB9g7pcHVv58anosR1uw92aK4kdZL33RNxCTfX6AzcIUBr+aMfzYzVV9y/PardYmS4O0Lc73WX9tp3lI1c4ycA6TxHEJAbaas= 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=dYlLURId; arc=none smtp.client-ip=209.85.160.44 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="dYlLURId" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-254c8e27c80so3184584fac.2 for ; Tue, 18 Jun 2024 13:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740964; x=1719345764; 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=J9fNNbSfh2WeZGPLrsfMCew1Ljg+9Wq+JnyF3lhrH44=; b=dYlLURId8fglPyqKAzQ7fazrD+rUe17ZyFTQ4AVJ4EztMGV4dv8+LxhxQBEewcO7uP l4nQYdwD+oF/inChF/eIPsJPf1Y+3qXEA3c0auj5Veg9cchA8moeTmU6bsCAvY4H7SpT sLDcdgSe7qIwIl3CAIsQurDJhnHR6/Fip9uaVRrZS0iD9+cuZOgMtORbhkiEXMf+t9f+ buQbAkISv25oNT5UQ6/13guOqg7sAslptvEzkXGbRR1yfvzKU3Gcv3JRFxyZvMTPwCAm SfHKRVvEV0kjdbF9FK4Q+dIOAxTtfQAA/DeKG6oaE1tS7fo9MG1NmKkcyO0jDVtjlyW1 dhRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740964; x=1719345764; 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=J9fNNbSfh2WeZGPLrsfMCew1Ljg+9Wq+JnyF3lhrH44=; b=mi683IgKcEAYRtOiQSamLh40mcBZGtOOM8I+S5UdER0gcpAia/rcJ9XH9PF5rhbMSe mfKyKVZrFs6yBRvjCpQRvTpwnQ/4CZolqGDiZXu3ZpA3yS5sTsSD/a9KoFWgDYaMd7J4 N76YOW0kN63qufQUbpnA+FA36i3/oUplC5fwNsezOgBVWkgwGBvtkRZgl91GdYQedHM5 G3TWhQRWqj+Voulumng+dCs9EAVRm+WUg6C4q0lTY+weAk1Bz+4GOiwRjHQsHX0s3DC1 f/NBsOXEnJV1/+x5Uw6UWrSSjsQlLUTuqVYXF8OJGZbMKeJYWxdNGRXacrDa26hkF/Vw +McQ== X-Gm-Message-State: AOJu0YyGBDx44w8BT+eYokNCeQzF6divdWMT20D5u67X1EkeCFrFCHJu cq90bnBZKFmns6OOx+9VyWKKLvzJb5/BXKS0kXSDWRvPT2Dp3cbI1z9+jA== X-Google-Smtp-Source: AGHT+IGiYvXz+Bh4dySsEV1yDWH0NOIMqerhcTEZ0u0F/FpYpdZ7okpicbWz41n9aCOoP0aJwOpMDw== X-Received: by 2002:a05:6870:d889:b0:254:c617:a9a0 with SMTP id 586e51a60fabf-25c94d713eemr919841fac.50.1718740964010; Tue, 18 Jun 2024 13:02:44 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:43 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 13/33] unit: Drop use of qmi_service_create_shared Date: Tue, 18 Jun 2024 15:01:55 -0500 Message-ID: <20240618200231.1129282-13-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- unit/test-qmimodem-qmi.c | 47 +++++++--------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index 0fedd9803bb5..c40e9bb1d8af 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -34,7 +34,6 @@ struct test_info { int service_fds[TEST_SERVICE_COUNT]; struct qmi_device *node; struct l_timeout *timeout; - struct l_queue *services; /* Data sent to our test service */ struct sockaddr_qrtr sender; @@ -159,7 +158,6 @@ static struct test_info *test_setup(void) /* Enable ofono logging */ qmi_device_set_debug(info->node, debug_log, NULL); - info->services = l_queue_new(); info->timeout = l_timeout_create(TEST_TIMEOUT, test_timeout_cb, info, NULL); @@ -172,8 +170,6 @@ static void test_cleanup(struct test_info *info) l_free(info->received); l_timeout_remove(info->timeout); - l_queue_destroy(info->services, - (l_queue_destroy_func_t) qmi_service_free); qmi_device_free(info->node); /* The qrtr services will be destroyed automatically. */ @@ -216,13 +212,6 @@ static void test_discovery(const void *data) test_cleanup(info); } -static void create_service_cb(struct qmi_service *service, void *user_data) -{ - struct test_info *info = user_data; - - l_queue_push_tail(info->services, service); -} - /* Callbacks could queue other callbacks so continue until there are no more. */ static void perform_all_pending_work(void) { @@ -246,12 +235,7 @@ static void test_create_services(const void *data) uint16_t major, minor; service_type = unique_service_type(i); - assert(qmi_service_create_shared(info->node, service_type, - create_service_cb, info, NULL)); - perform_all_pending_work(); - - assert(l_queue_length(info->services) == 1); - service = l_queue_pop_head(info->services); + service = qmi_qrtr_node_get_service(info->node, service_type); assert(service); assert(qmi_service_get_version(service, &major, &minor)); @@ -266,21 +250,14 @@ static void test_create_services(const void *data) * call the callback. */ service_type = unique_service_type(TEST_SERVICE_COUNT); - assert(!qmi_service_create_shared(info->node, service_type, - create_service_cb, info, NULL)); - perform_all_pending_work(); - assert(l_queue_isempty(info->services)); + assert(!qmi_qrtr_node_get_service(info->node, service_type)); /* Confirm that multiple services may be created for the same type */ service_type = unique_service_type(0); for (i = 0; i < L_ARRAY_SIZE(services); i++) { - assert(qmi_service_create_shared(info->node, service_type, - create_service_cb, info, NULL)); - perform_all_pending_work(); - - assert(l_queue_length(info->services) == 1); - services[i] = l_queue_pop_head(info->services); + services[i] = qmi_qrtr_node_get_service(info->node, + service_type); assert(services[i]); } @@ -455,10 +432,7 @@ static void test_send_data(const void *data) perform_discovery(info); service_type = unique_service_type(0); /* Use the first service */ - assert(qmi_service_create_shared(info->node, service_type, - create_service_cb, info, NULL)); - perform_all_pending_work(); - service = l_queue_pop_head(info->services); + service = qmi_qrtr_node_get_service(info->node, service_type); assert(service); io = l_io_new(info->service_fds[0]); @@ -505,10 +479,7 @@ static void test_notifications(const void *data) perform_discovery(info); service_type = unique_service_type(0); /* Use the first service */ - assert(qmi_service_create_shared(info->node, service_type, - create_service_cb, info, NULL)); - perform_all_pending_work(); - service = l_queue_pop_head(info->services); + service = qmi_qrtr_node_get_service(info->node, service_type); assert(service); io = l_io_new(info->service_fds[0]); @@ -567,10 +538,8 @@ static void test_service_notification_independence(const void *data) l_io_set_read_handler(io, received_data, info, NULL); for (i = 0; i < L_ARRAY_SIZE(services); i++) { - assert(qmi_service_create_shared(info->node, service_type, - create_service_cb, info, NULL)); - perform_all_pending_work(); - services[i] = l_queue_pop_head(info->services); + services[i] = qmi_qrtr_node_get_service(info->node, + service_type); assert(services[i]); send_request_via_qmi(info, services[i]); From patchwork Tue Jun 18 20:01:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702921 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (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 D4CF916DC2E for ; Tue, 18 Jun 2024 20:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740967; cv=none; b=Tbk7m11LgTZVancXbt0ZvoQN8f37smXnyIheX2Pgd245KAmohf2z6WPDcsSHmgWz60Gq/Jm4LLfaNQDg5mMrfg1j0IGOw4iMzENvtcRtvm01sRjehDxLVnrsxiwCIKXNiXeRyP52+qDHY7mqc4rY0cWG1au0mEmCxvACsCTiHOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740967; c=relaxed/simple; bh=guMbeyQHTt3Yhsyhs5yd106/04urQkLuDKC+L31Jasw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OhNOxTlrZDlO6jjwI8qrmY9SAq99hyEezZXmvygHhnHq5blO60BssdB1WbJ1TXODNOR/hidsZXKb/a53TX14lWSvIJhPyFDmu+zoeDk1kxjtq2gQ+3b+lzM8rt+sqXn3t9wdSiKVQ1R0ls6TKFTJiUUEvGjWOBBe9UVc/+41guQ= 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=lqC//q9B; arc=none smtp.client-ip=209.85.160.46 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="lqC//q9B" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-250c0555a63so2892591fac.1 for ; Tue, 18 Jun 2024 13:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740965; x=1719345765; 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=4jLKnyWSbEnLm4HoUDKHbHoRajOmpNoERvnKnRZIt6Q=; b=lqC//q9BAf1+MvJp4E4AUwBTVVgNLDfKbua4qK3R/4LbZnGdFGijVO1ujQxGTWghIr FKXvPwPDIjLB8YanYuFGlx+PQ4ctKUQj5n9huGKoo04upEGsQ+Q97kNZWPSoZhHMzsME K+NwNp6LjeTvqXxDGIfJtjVvyTrcw4OGt1pY9YYH3ryikxP+zsj0M1YpADzvt16OhZ7R QGIF2mgMc+3fZoD0p0rJ8+J0c/QfJHZkpddC+3qFB5qSQeXbLuvI1EgD+AyDHg+ulL+N 85Mr+pWP7BatqtHTd3fYG8ZMQGEoLTPStU/9gIgWrHDM1l6mWSvvYH42sTsU1gt3Paij y2eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740965; x=1719345765; 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=4jLKnyWSbEnLm4HoUDKHbHoRajOmpNoERvnKnRZIt6Q=; b=QIjnyWlHjUrYZn9HJeu8VsqSBRTv34JCn2e5zadnvtDnatljGn1NTyUECteR89cUrf yV6fZu7g91SQXM1PyAYJmgNH7mv4Gr5Zv+nZf9BqbHTzZtvrhWU1mgJ9Xc/11nHyrqdH 0z8tFV1RV8M8qcGF5zeB62Vt5Awsx9fxmPbAvqgJES9RDQ0kwYsN6/0kNYEzWi7Wf3ug St8TTAFpbvakJfqX16YEfYKgAg9J+4Ex29l0iKv8echno0PJj8vpKZ21KuhGXS8oTYxq od3QWiUHSUznZ/kdMCl/t9zB8HOsJjxBZeP5XfgurYLevB1hd3qkIKaQHHQOeKPzi1AQ NXNw== X-Gm-Message-State: AOJu0YzEh2xzdsrzQLmOXBOwv8HmzEF5fckcSIJ7jOwEYcOpFetE3jkt k7oXCNU/aA2EnXqE41ULziO3A8IdGIEnM8TbGndpLf+jY1prdL6WB+WSdQ== X-Google-Smtp-Source: AGHT+IF3GCKrOeXrEml124Fg4TeHK9knM5tFlTag5Knqh41H6DdoZMgOSVl3/fHTIsalEsqxLW3ZLA== X-Received: by 2002:a05:6870:7192:b0:24c:bb91:df59 with SMTP id 586e51a60fabf-25c94a236a1mr857270fac.35.1718740964728; Tue, 18 Jun 2024 13:02:44 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:44 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 14/33] qmi: qmux: Make shared service creation generic Date: Tue, 18 Jun 2024 15:01:56 -0500 Message-ID: <20240618200231.1129282-14-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The underlying QMUX protocol does not have a concept of a shared or non-shared service. Services are accessed via clients, with each client having its own state tracked by the service implementation. Some state is shared amongst all clients. The shared service concept was local to the qmi_device implementation, enabling multiple atom drivers to request a handle to a given service, and for that handle to share the client service handle at the protocol level. Services meant to be shared are now created and managed at the modem driver level. Services that require a dedicated service client handle (such as in the case of gprs_context atom driver) will obtain such handles from the modem driver in the future. Remove qmi_service_create_shared() API and introduce a QMUX specific qmux_device_create_client() API in its stead. The new API will generically handle creation of new service clients at the QMUX protocol level. While here, also remove the now unused client_create method from the qmi_device_ops structure and rename qmux_client_create_reply() to qmux_client_create_timeout() --- drivers/qmimodem/qmi.c | 233 ++++++++--------------------------------- drivers/qmimodem/qmi.h | 12 ++- plugins/gobi.c | 6 +- 3 files changed, 51 insertions(+), 200 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 9fdc209edf7c..89645c1d6704 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -64,10 +64,6 @@ 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, - void *user, qmi_destroy_func_t destroy); void (*client_release)(struct qmi_device *device, uint16_t service_type, uint16_t client_id); int (*shutdown)(struct qmi_device *device, @@ -106,7 +102,6 @@ struct qmi_device_qmux { unsigned int release_users; uint8_t next_control_tid; struct l_queue *control_queue; - struct l_queue *pending_families; }; struct service_family { @@ -1410,17 +1405,6 @@ done: l_free(family); } -struct service_create_shared_data { - struct discovery super; - uint16_t service_type; - struct service_family *family; - struct qmi_device *device; - qmi_create_func_t func; - void *user_data; - qmi_destroy_func_t destroy; - struct l_idle *idle; -}; - static uint8_t __ctl_request_submit(struct qmi_device_qmux *qmux, struct qmi_request *req) { @@ -1484,79 +1468,6 @@ static struct qmi_service *service_create(struct service_family *family) return service; } -static void service_create_shared_idle_cb(struct l_idle *idle, void *user_data) -{ - struct service_create_shared_data *data = user_data; - struct qmi_service *service = service_create(data->family); - - DISCOVERY_DONE(data, service, data->user_data); -} - -static void service_create_shared_reply(struct service_create_shared_data *data, - struct service_family *family) -{ - struct qmi_service *service = NULL; - - if (family) - service = service_create(family); - - DISCOVERY_DONE(data, service, data->user_data); -} - -static bool pending_family_match(const void *data, const void *user_data) -{ - const struct service_create_shared_data *shared_data = data; - uint16_t service_type = L_PTR_TO_UINT(user_data); - - return shared_data->service_type == service_type; -} - -struct pending_family_reply_if_match_info { - uint16_t service_type; - struct service_family *family; -}; - -static bool pending_family_reply_if_match(void *data, void *user_data) -{ - struct service_create_shared_data *shared_data = data; - const struct pending_family_reply_if_match_info *info = user_data; - - if (pending_family_match(data, L_UINT_TO_PTR(info->service_type))) { - service_create_shared_reply(shared_data, info->family); - return true; - } - - return false; -} - -static void service_create_shared_pending_reply(struct qmi_device_qmux *qmux, - uint16_t service_type, - struct service_family *family) -{ struct pending_family_reply_if_match_info info = { - .service_type = service_type, - .family = family, - }; - - l_queue_foreach_remove(qmux->pending_families, - pending_family_reply_if_match, &info); -} - -static void service_create_shared_data_free(void *user_data) -{ - struct service_create_shared_data *data = user_data; - - if (data->idle) - l_idle_remove(data->idle); - - if (data->family) - service_family_unref(data->family); - - if (data->destroy) - data->destroy(data->user_data); - - l_free(data); -} - static struct qmi_request *find_control_request(struct qmi_device_qmux *qmux, uint16_t tid) { @@ -1737,7 +1648,9 @@ struct qmux_client_create_data { uint8_t type; uint16_t major; uint16_t minor; - qmi_create_func_t func; + qmi_qmux_device_create_client_func_t func; + void *user_data; + qmi_destroy_func_t destroy; struct l_timeout *timeout; uint16_t tid; }; @@ -1749,10 +1662,14 @@ static void qmux_client_create_data_free(void *user_data) if (data->timeout) l_timeout_remove(data->timeout); + if (data->destroy) + data->destroy(data->user_data); + l_free(data); } -static void qmux_client_create_reply(struct l_timeout *timeout, void *user_data) +static void qmux_client_create_timeout(struct l_timeout *timeout, + void *user_data) { struct qmux_client_create_data *data = user_data; struct qmi_device *device = data->device; @@ -1760,20 +1677,17 @@ static void qmux_client_create_reply(struct l_timeout *timeout, void *user_data) l_container_of(device, struct qmi_device_qmux, super); struct qmi_request *req; - DBG(""); - - service_create_shared_pending_reply(qmux, data->type, NULL); - - /* remove request from queues */ - req = find_control_request(qmux, data->tid); + __debug_device(device, "client creation timed out"); l_timeout_remove(data->timeout); data->timeout = NULL; - DISCOVERY_DONE(data, NULL, NULL); - + /* remove request from queues */ + req = find_control_request(qmux, data->tid); if (req) __request_free(req); + + DISCOVERY_DONE(data, NULL, data->user_data); } static void qmux_client_create_callback(uint16_t message, uint16_t length, @@ -1781,9 +1695,8 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length, { struct qmux_client_create_data *data = user_data; struct qmi_device *device = data->device; - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); struct service_family *family = NULL; + struct qmi_service *service = NULL; struct qmi_service_info info; const struct qmi_result_code *result_code; const struct qmi_client_id *client_id; @@ -1817,72 +1730,63 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length, hash_id = family_list_create_hash(family->info.service_type, family->client_id); l_hashmap_insert(device->family_list, L_UINT_TO_PTR(hash_id), family); - l_hashmap_insert(device->family_list, - L_UINT_TO_PTR(family->info.service_type), - family); + done: - service_create_shared_pending_reply(qmux, data->type, family); if (family) - service_family_unref(family); + service = service_create(family); + + DISCOVERY_DONE(data, service, data->user_data); - DISCOVERY_DONE(data, NULL, NULL); + if (family) + service_family_unref(family); } -static int qmi_device_qmux_client_create(struct qmi_device *device, - uint16_t service_type, - qmi_create_func_t func, void *user_data, - qmi_destroy_func_t destroy) +bool qmi_qmux_device_create_client(struct qmi_device *device, + uint16_t service_type, + qmi_qmux_device_create_client_func_t func, + void *user_data, qmi_destroy_func_t destroy) { - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); unsigned char client_req[] = { 0x01, 0x01, 0x00, service_type }; + const struct qmi_service_info *info; + struct qmi_device_qmux *qmux; struct qmi_request *req; - struct service_create_shared_data *shared_data; struct qmux_client_create_data *create_data; - bool create_in_progress; - if (!l_queue_length(device->service_infos)) - return -ENOENT; + if (!device || !func) + return false; - create_in_progress = l_queue_find(qmux->pending_families, - pending_family_match, - L_UINT_TO_PTR(service_type)); + if (service_type == QMI_SERVICE_CONTROL) + return false; - shared_data = l_new(struct service_create_shared_data, 1); - shared_data->super.destroy = service_create_shared_data_free; - shared_data->service_type = service_type; - shared_data->device = device; - shared_data->func = func; - shared_data->user_data = user_data; - shared_data->destroy = destroy; - l_queue_push_tail(qmux->pending_families, shared_data); + info = __find_service_info_by_type(device, service_type); + if (!info) + return false; - if (create_in_progress) - return 0; + qmux = l_container_of(device, struct qmi_device_qmux, super); create_data = l_new(struct qmux_client_create_data, 1); create_data->super.destroy = qmux_client_create_data_free; create_data->device = device; create_data->type = service_type; + create_data->major = info->major; + create_data->minor = info->minor; + create_data->func = func; + create_data->user_data = user_data; + create_data->destroy = destroy; __debug_device(device, "service create [type=%d]", service_type); - qmi_device_get_service_version(device, create_data->type, - &create_data->major, - &create_data->minor); - req = __control_request_alloc(QMI_CTL_GET_CLIENT_ID, client_req, sizeof(client_req), qmux_client_create_callback, create_data); create_data->tid = __ctl_request_submit(qmux, req); - create_data->timeout = l_timeout_create(8, qmux_client_create_reply, + create_data->timeout = l_timeout_create(8, qmux_client_create_timeout, create_data, NULL); __qmi_device_discovery_started(device, &create_data->super); - - return 0; + return true; } static void qmux_client_release_callback(uint16_t message, uint16_t length, @@ -1971,8 +1875,6 @@ static void qmi_device_qmux_destroy(struct qmi_device *device) struct qmi_device_qmux *qmux = l_container_of(device, struct qmi_device_qmux, super); - l_queue_destroy(qmux->pending_families, - (l_queue_destroy_func_t) service_create_shared_data_free); l_queue_destroy(qmux->control_queue, __request_free); if (qmux->shutdown_idle) @@ -1985,7 +1887,6 @@ static void qmi_device_qmux_destroy(struct qmi_device *device) static const struct qmi_device_ops qmux_ops = { .write = qmi_device_qmux_write, .discover = qmi_device_qmux_discover, - .client_create = qmi_device_qmux_client_create, .client_release = qmi_device_qmux_client_release, .shutdown = qmi_device_qmux_shutdown, .destroy = qmi_device_qmux_destroy, @@ -2010,7 +1911,6 @@ struct qmi_device *qmi_qmux_device_new(const char *device) qmux->next_control_tid = 1; qmux->control_queue = l_queue_new(); - qmux->pending_families = l_queue_new(); l_io_set_read_handler(qmux->super.io, received_qmux_data, qmux, NULL); return &qmux->super; @@ -2304,7 +2204,6 @@ static void qmi_device_qrtr_destroy(struct qmi_device *device) static const struct qmi_device_ops qrtr_ops = { .write = qmi_device_qrtr_write, .discover = qmi_device_qrtr_discover, - .client_create = NULL, .client_release = NULL, .shutdown = NULL, .destroy = qmi_device_qrtr_destroy, @@ -2630,56 +2529,6 @@ bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type, return true; } -bool qmi_service_create_shared(struct qmi_device *device, uint16_t type, - qmi_create_func_t func, void *user_data, - qmi_destroy_func_t destroy) -{ - struct service_create_shared_data *data; - struct service_family *family; - - if (!device || !func) - return false; - - if (type == QMI_SERVICE_CONTROL) - return false; - - family = l_hashmap_lookup(device->family_list, L_UINT_TO_PTR(type)); - if (!family) { - const struct qmi_service_info *info; - - if (device->ops->client_create) { - int r; - - r = device->ops->client_create(device, type, func, - user_data, destroy); - return r == 0; - } - - info = __find_service_info_by_type(device, type); - if (!info) - return false; - - family = service_family_create(device, info, 0); - l_hashmap_insert(device->family_list, L_UINT_TO_PTR(type), - family); - } - - data = l_new(struct service_create_shared_data, 1); - - data->super.destroy = service_create_shared_data_free; - data->device = device; - data->func = func; - data->user_data = user_data; - data->destroy = destroy; - data->family = service_family_ref(family); - data->idle = l_idle_create(service_create_shared_idle_cb, data, NULL); - - /* Not really discovery... just tracking the idle callback. */ - __qmi_device_discovery_started(device, &data->super); - - return true; -} - const char *qmi_service_get_identifier(struct qmi_service *service) { if (!service) diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 966d4f354d6e..90e83a4dbebd 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -65,12 +65,19 @@ struct qmi_service; typedef void (*qmi_debug_func_t)(const char *str, void *user_data); typedef void (*qmi_shutdown_func_t)(void *user_data); typedef void (*qmi_discover_func_t)(void *user_data); +typedef void (*qmi_qmux_device_create_client_func_t)(struct qmi_service *, + void *user_data); typedef void (*qmi_service_result_func_t)(struct qmi_result *, void *); struct qmi_device *qmi_qmux_device_new(const char *device); void qmi_device_free(struct qmi_device *device); +bool qmi_qmux_device_create_client(struct qmi_device *device, + uint16_t service_type, + qmi_qmux_device_create_client_func_t func, + void *user_data, qmi_destroy_func_t destroy); + void qmi_device_set_debug(struct qmi_device *device, qmi_debug_func_t func, void *user_data); @@ -130,11 +137,6 @@ void qmi_result_print_tlvs(struct qmi_result *result); int qmi_error_to_ofono_cme(int qmi_error); -typedef void (*qmi_create_func_t)(struct qmi_service *service, void *user_data); - -bool qmi_service_create_shared(struct qmi_device *device, - uint16_t type, qmi_create_func_t func, - void *user_data, qmi_destroy_func_t destroy); struct qmi_service *qmi_service_clone(struct qmi_service *service); void qmi_service_free(struct qmi_service *service); diff --git a/plugins/gobi.c b/plugins/gobi.c index 5463a46edecb..23d16e251196 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -419,7 +419,7 @@ static void request_service_cb(struct qmi_service *service, void *user_data) if (data->cur_service_request == data->num_service_requests) { DBG("All services requested, proceeding to create WDA"); - if (qmi_service_create_shared(data->device, QMI_SERVICE_WDA, + if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_WDA, create_wda_cb, modem, NULL)) return; @@ -429,7 +429,7 @@ static void request_service_cb(struct qmi_service *service, void *user_data) req = &data->service_requests[data->cur_service_request]; DBG("Requesting: %u", req->service_type); - if (qmi_service_create_shared(data->device, req->service_type, + if (qmi_qmux_device_create_client(data->device, req->service_type, request_service_cb, modem, NULL)) return; @@ -482,7 +482,7 @@ static void discover_cb(void *user_data) if (data->features & GOBI_UIM) add_service_request(data, &data->uim, QMI_SERVICE_UIM); - if (qmi_service_create_shared(data->device, QMI_SERVICE_DMS, + if (qmi_qmux_device_create_client(data->device, QMI_SERVICE_DMS, request_service_cb, modem, NULL) > 0) return; error: From patchwork Tue Jun 18 20:01:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702922 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 8B40516DC1B for ; Tue, 18 Jun 2024 20:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740967; cv=none; b=r9BSgxe7ziZTcdLBXzhRxJ/JAqT+Jr92XJcORwV9Aw7GXm7/RQXAcmElBSgcfIXU5Q+FsLpTWdmnWL3ojNgKLl1LpqEihX/T3lKjb1loH1qntcrgEmzBPVeWFJHz8GYi7cGrvpsa8wsfdAK9eXvxeAIxsBtUl52GjfpysAdF0/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740967; c=relaxed/simple; bh=GAqRu0UuVLiqGXJEiwY1oyEPTDDwCivuH3oQ7lf4cMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n+S292Po5SJjROETtc6bFFFbriZbovVq5lpcWmmzF2tq0L9Km9Z7FN1XUfdcY6fcDW8A88d3hxyzi0XkuEgOxBJYDMvo2ZZxRcf6BxaMywa0JSHCyEQaU2b/Hunw9S8b6xMX87woWHC7/T4hk3QLsTW8hpnYVGiKn8BYHupqehY= 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=H9MsoHu6; arc=none smtp.client-ip=209.85.160.47 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="H9MsoHu6" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-25c4d8ae511so220503fac.2 for ; Tue, 18 Jun 2024 13:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740965; x=1719345765; 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=EdvBzpreMqSB4QFmQSbJhuOcwt1m+b92CFyWwcvJqak=; b=H9MsoHu6+NZqpttljectNhRkdfu0aqDq+Wrme5GHg/MX81FC92v/MPDqPAH903QOoP y6ZTKmF46N7fKB7j+nhRfeyVeqEe6ow/gDSzk2eBpN5+nPQrDUrD70M5u16ZVmbAOVvd tZjM9jWdJqjrrH9HaOBfAlv0kBQjIq2AYoCksZarLdC8Dp7hR06Br+WNEMtGHPy0+NH2 MBI58Sc6qXAjKzBJXbA7Iv28gxyFZXoK6EGl/qFxQkQVNXdPJpOjh0DqhmrI6sYI9LcI iUfAkBhFIArTPX6+m1r+Oa6NNgtdHTrm2XWtpQ9Gx+BaStB0mrCOIAJvqI1SJaTDs4lj 38fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740965; x=1719345765; 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=EdvBzpreMqSB4QFmQSbJhuOcwt1m+b92CFyWwcvJqak=; b=SIGCifUEXjvNu13CCDRPFII9J30020VvAxqUgP9ZbFcnczNDzUZCCtqjMSRJ/90XLU JqYfFUpFMfCuC7h+e+p0y04sYFN3pD5NnpfxyMxjHes1kZ4tL3IHXVjmbazJ+6E3lWKU 3UcZ+S0vW4jlPPLCYfq8Kuv+6OBnI4rmOARNyXVzX9vzVprZICdnOILlQb7nKMTgkept 8XctGRdSa3fot4k2z4ajufd+aJmcFfNM4ElQG1zaqX5Je/uAI2dtoEqBFTZhg50imthh cZ08pNMp2iCrTGIbhuUIJn8OZ/mqQxBUeMGMfucGlzux2PAvsmdkwbTiIu6phHwYMNyl VM+A== X-Gm-Message-State: AOJu0YzPHROaVugjVnvghA5Rh4cNiczqeveOgHdoOfKAqCms7tLk3WHr 8v/+ZXMhzLOqkbFndEOdWnFTjfZBH23fhp2UY9Aytgn0Lzu9n5h9MnwrDw== X-Google-Smtp-Source: AGHT+IEEtn15J9j1lGPnXOI9eqmfNK6gxaGHxYgDGUOK+7gdE7nqraGQBv6Xgst7S1GNTwUJX9Fc+w== X-Received: by 2002:a05:6870:b620:b0:259:859e:a080 with SMTP id 586e51a60fabf-25c948eda9dmr934898fac.9.1718740965528; Tue, 18 Jun 2024 13:02:45 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:45 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 15/33] qmi: Rename qmi_device_get_service_version Date: Tue, 18 Jun 2024 15:01:57 -0500 Message-ID: <20240618200231.1129282-15-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This makes it more explicit that major/minor attributes are only supported by QMUX. --- drivers/qmimodem/qmi.c | 3 ++- drivers/qmimodem/qmi.h | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 89645c1d6704..a56e5588c698 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -988,7 +988,8 @@ static const struct qmi_service_info *__find_service_info_by_type( return info; } -bool qmi_device_get_service_version(struct qmi_device *device, uint16_t type, +bool qmi_qmux_device_get_service_version(struct qmi_device *device, + uint16_t type, uint16_t *major, uint16_t *minor) { const struct qmi_service_info *info; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 90e83a4dbebd..da245e50ea50 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -77,6 +77,9 @@ bool qmi_qmux_device_create_client(struct qmi_device *device, uint16_t service_type, qmi_qmux_device_create_client_func_t func, void *user_data, qmi_destroy_func_t destroy); +bool qmi_qmux_device_get_service_version(struct qmi_device *device, + uint16_t type, + uint16_t *major, uint16_t *minor); void qmi_device_set_debug(struct qmi_device *device, qmi_debug_func_t func, void *user_data); @@ -87,8 +90,6 @@ int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy); bool qmi_device_has_service(struct qmi_device *device, uint16_t type); -bool qmi_device_get_service_version(struct qmi_device *device, uint16_t type, - uint16_t *major, uint16_t *minor); enum qmi_device_expected_data_format qmi_device_get_expected_data_format( struct qmi_device *device); From patchwork Tue Jun 18 20:01:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702923 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 3BC1F16DC21 for ; Tue, 18 Jun 2024 20:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740968; cv=none; b=Odd5GtJflagA99RCaYZUYNVe2zyoS33wO/JylIbrqCOS8iaj4IjeyIysq8al8IOFIf5tqOtNcs5celG+TXwLr+IvCt3D+xhupsaNnGV8Nrwjfj3W7DVqPxc2bQpRvQGD4vOw3GaI/GzYLsoMsa6eKnud2fqf6hf1n340Y7bqyfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740968; c=relaxed/simple; bh=mbGPjn8vEREaGryrfwrAFP197XAHAet6GON6MNGWSw0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pGalu96rhn+NdCdfiSaF4xbd4+/WXFka+qRqDF6ia5ciqXJVudj9pUYjcdvp08z1FyomepuXj2Hkd0HGjsYr24GNMI71rNCCV0BYZRlIjhbrJb53UTj4EHEbkNVbAthAAULm1G5X8j5R9+bDnXvMwFpHkWNrUK/ogA+/xbiuAUA= 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=JUQSL6M0; arc=none smtp.client-ip=209.85.160.50 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="JUQSL6M0" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-254e42df409so3652558fac.0 for ; Tue, 18 Jun 2024 13:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740966; x=1719345766; 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=9U2l8mxFICX6hZ5C5qX4FKms7BlvGzmOmlHfLDlvOCc=; b=JUQSL6M0pxCu99gVFSBy0w/4FKAz8n+bGEv6NRQ5A5V+UMm1TDuopuzm2wYgpBIueQ II8x/anj1jszPJvk06jNX/P8I6mIm60Wxe3PhZyJss79eE4LaAr1Xp8Kg2wSIrpP7CNj gtBNhjhkvvfhGMavxuPIu9Nhwxm25k0ps4kWSR+lnBgW66v2qp5b6RDNs3AKLsrMKGlJ W2ttfSEiGLn0ySMB6K9AGVigV0GZgg+0lA5aaAV7TTgYe9hxYP1R1JEGT7o8TtYoVxM9 JSSueYKiXYGoAQM44N64Z1OPC/h7f+6Uycxo8YLZ6sVZhEGuywLSNmBZhacVEu8LvgMw Ou1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740966; x=1719345766; 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=9U2l8mxFICX6hZ5C5qX4FKms7BlvGzmOmlHfLDlvOCc=; b=svJr1aPXnXjF0QSFBr0RNxv+TVd4Hn4l8Shj9hLomgyf5SuX0Sj9vmVemGDIJbHAZ+ iRzz3+GTJhm2w550LkcwayxBEpXy0/8fZeDjn+/MEHfyFyxfQIHM6VD9gcJXH85/rkXm 8024vz0e7L4lX3drci2mvYspBcCUOim7ClProv14AqkfGLREHjLOpSCxLArb8Ds9QBoc UcMoJywfLzPuJ4yVcmBUvuudegzjScm+EFDuvuAkNhv2m4n49TjnpDbVJ22Csd43ursy hk1CRMGk2uum3+DXyA+58WKMIEl07nBVHglYEch/1sX3efL4O2kwNxLLXjYMp4Q3ytxN MuTg== X-Gm-Message-State: AOJu0YwH96/97zybnzEMdepL4cR/EisKpzIU97+UjYBJKRLVIVSC6HCu XJBN1oosxt3p6A/1EelIp6twmC7iNbFPEApW9UWxQMG1qn/i4dS7dFUbHA== X-Google-Smtp-Source: AGHT+IHJayD/c8hUBgqIfAqQz1GEqKeKBfNIAv/d+YwG/ivpTRqgdLSRS9ZZuovfVWyn3HWwK3Hcpg== X-Received: by 2002:a05:6870:c796:b0:254:9ec6:c8cc with SMTP id 586e51a60fabf-25c94dac897mr617719fac.48.1718740966234; Tue, 18 Jun 2024 13:02:46 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:45 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 16/33] qmi: sms: Require at WMS version 1.2+ Date: Tue, 18 Jun 2024 15:01:58 -0500 Message-ID: <20240618200231.1129282-16-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the version check from the SMS atom driver to the gobi modem driver. Do not request WMS unless version 1.2 is supported. --- drivers/qmimodem/sms.c | 12 ------------ plugins/gobi.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/qmimodem/sms.c b/drivers/qmimodem/sms.c index 2ac06a40bdd6..3e2bef6e38b7 100644 --- a/drivers/qmimodem/sms.c +++ b/drivers/qmimodem/sms.c @@ -22,8 +22,6 @@ struct sms_data { struct qmi_service *wms; - uint16_t major; - uint16_t minor; struct qmi_wms_read_msg_id rd_msg_id; struct qmi_wms_result_msg_list *msg_list; uint32_t rd_msg_num; @@ -263,16 +261,11 @@ static void qmi_bearer_query(struct ofono_sms *sms, DBG(""); - if (data->major < 1 || (data->major == 1 && data->minor < 2)) - goto error; - if (qmi_service_send(data->wms, QMI_WMS_GET_DOMAIN_PREF, NULL, get_domain_pref_cb, cbd, l_free) > 0) return; -error: CALLBACK_WITH_FAILURE(cb, -1, cbd->data); - l_free(cbd); } @@ -301,9 +294,6 @@ static void qmi_bearer_set(struct ofono_sms *sms, int bearer, DBG("bearer %d", bearer); - if (data->major < 1 || (data->major == 1 && data->minor < 2)) - goto error; - domain = bearer_to_domain(bearer); param = qmi_param_new_uint8(QMI_WMS_PARAM_DOMAIN, domain); @@ -314,7 +304,6 @@ static void qmi_bearer_set(struct ofono_sms *sms, int bearer, qmi_param_free(param); -error: CALLBACK_WITH_FAILURE(cb, cbd->data); l_free(cbd); } @@ -747,7 +736,6 @@ static int qmi_sms_probe(struct ofono_sms *sms, data->wms = wms; memset(&data->rd_msg_id, 0, sizeof(data->rd_msg_id)); data->msg_mode = QMI_WMS_MESSAGE_MODE_GSMWCDMA; - qmi_service_get_version(data->wms, &data->major, &data->minor); qmi_service_register(data->wms, QMI_WMS_EVENT, event_notify, sms, NULL); ofono_sms_set_data(sms, data); diff --git a/plugins/gobi.c b/plugins/gobi.c index 23d16e251196..63eb847eb680 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -441,6 +441,8 @@ static void discover_cb(void *user_data) { struct ofono_modem *modem = user_data; struct gobi_data *data = ofono_modem_get_data(modem); + uint16_t major; + uint16_t minor; DBG(""); @@ -448,8 +450,6 @@ static void discover_cb(void *user_data) data->features |= GOBI_DMS; if (qmi_device_has_service(data->device, QMI_SERVICE_NAS)) data->features |= GOBI_NAS; - if (qmi_device_has_service(data->device, QMI_SERVICE_WMS)) - data->features |= GOBI_WMS; if (qmi_device_has_service(data->device, QMI_SERVICE_WDS)) data->features |= GOBI_WDS; if (qmi_device_has_service(data->device, QMI_SERVICE_WDA)) @@ -461,6 +461,15 @@ static void discover_cb(void *user_data) if (qmi_device_has_service(data->device, QMI_SERVICE_VOICE)) data->features |= GOBI_VOICE; + if (qmi_qmux_device_get_service_version(data->device, QMI_SERVICE_WMS, + &major, &minor)) { + if (major < 1 || (major == 1 && minor < 2)) + ofono_warn("unsupported WMS version: %u.%u, need: 1.2", + major, minor); + else + data->features |= GOBI_WMS; + } + if (!(data->features & GOBI_DMS)) { if (++data->discover_attempts < 3 && !qmi_device_discover(data->device, discover_cb, From patchwork Tue Jun 18 20:01:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702924 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (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 1DE8216DC1B for ; Tue, 18 Jun 2024 20:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740969; cv=none; b=NWvFrKXTRd6lDrDLnQK4NnaGvIscoJ09t80Xf0M18tC6gJwi56ksh3eey5oExeD31GcH12yHugDi0V49vuWP7S+sBD8RY192o1hevLGZl1z62Rw3KYd+cgaizEkQCwdYOwC+tbv+XEFG9TeYnTKF8jPPJY777eyhiVQl3nRrVz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740969; c=relaxed/simple; bh=IiJTpDFWVszkMs9yutzu4PpAAP2PVhhzrk0UUQ0VA/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S5PkaYYPZlJXJMPmvec3sA0DIp3nY0H1ICmyW67SR3jZNXw/d3wbfvlmQvyuqGTvr3/yhP1WcbOdxkTn9pam0n4idqj6xwagjPl5lFPMMfNwQOzjz6H+CkWozB3nP2x5xB2OcQSbkgxoi3OJuXlUVjYjZnc6691ZNsxTv+tbHlM= 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=CI6sWrV9; arc=none smtp.client-ip=209.85.160.48 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="CI6sWrV9" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-24c9f73ccaaso3337385fac.1 for ; Tue, 18 Jun 2024 13:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740967; x=1719345767; 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=PyUF7wR+m1/dSK2kCnd4OkrUNVmnVUjk6Mt59JyOg58=; b=CI6sWrV9QTt2rkvCDMwzN5o4GfXfFaoP+I4z+TwGX660DCZYfp793ARPOZwfQTLhKH LgjSqOU5DJceFV5YZZoCDxopSFmcIiJa2LmgEBZsy+jY4w87F5VIUjNCP5ROdKB8n9J+ Z6OwYrRbYf0GuLesD9GhtAIoV0Zu1GIX9Q5wECqZfPzTtEcJ40mohCg0/uITuxjkWw1s 3VvZCnJuAQSYO9uPK3DvzYXBVomTDgmJOjKuBpuTEfqnP/kokkVANCJU/7YUgMbWTShI GPvJ/dpWj4CjNS4mbo9mgXKUNM1eV/2oCkRL1iBZ4Q2Saz5WryDkc+k0xBLqHyv4bz0F iVug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740967; x=1719345767; 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=PyUF7wR+m1/dSK2kCnd4OkrUNVmnVUjk6Mt59JyOg58=; b=UyvfLs9jDZTg1tAGX6Qc5qlnRsHisiHei2tRcXen8oUe3Nr2IqLR0GAX1mN6XZqpZL TfEDXwTquHIu6bIFRwUPQUzMARVOyUBd302cnhinDcSV2w6FPDYWt4gokJVhMZkzXzyy hzsWrm563GV67gDFAqhqa84P4DGI4NOGUqd0amnXOsrofKxpG0c0JeYyF+58McHe7eiw iVfznXRxmFJHfM6PszxKXxB4bRtx1Zf3unZYXDWXmyCr1pbZe/E/bTp/JPbCwQAc/b42 zAeocuA53M7tPRmX0qEx8OgJrspC5W+erO/zo4lmj7schjMDAiQKySjgg+gP/FBbrye/ XMGQ== X-Gm-Message-State: AOJu0YyLMDRxCXeN3KGFcrjM4klKdeX4PEaxiPexEiM8JFnGzx9CpMiu ZUY6GsfSVI0cdowj7xUx8uNHVoyeBG61dqpnBHiRPRQkz7mGPpHX6GHDKw== X-Google-Smtp-Source: AGHT+IHu0JY8S85frnkzlvO+f+EZQ2j2bzVQhgM/hy7JSxW4zyjVzLF/qtGvVzU/FkfF83xgxrzAGA== X-Received: by 2002:a05:6870:51c8:b0:251:2755:5a33 with SMTP id 586e51a60fabf-25c94d058d8mr907299fac.39.1718740967043; Tue, 18 Jun 2024 13:02:47 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:46 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 17/33] qmi: Rework qmi_service_get_version Date: Tue, 18 Jun 2024 15:01:59 -0500 Message-ID: <20240618200231.1129282-17-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 With the introduction of QRTR support, qmi_service_get_version became somewhat confusing. It still returns the minor version, however QRTR does not have such a concept. Additionally, QRTR is limited to 8 bit service versions. Rework qmi_service_get_version API to make this clearer. While here, add some documentation and update the unit test to the new API. --- drivers/qmimodem/qmi.c | 22 +++++++++++++++------- drivers/qmimodem/qmi.h | 3 +-- unit/test-qmimodem-qmi.c | 7 +++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index a56e5588c698..6d605d58ad65 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -2538,17 +2538,25 @@ const char *qmi_service_get_identifier(struct qmi_service *service) return __service_type_to_string(service->family->info.service_type); } -bool qmi_service_get_version(struct qmi_service *service, - uint16_t *major, uint16_t *minor) +/** + * qmi_service_get_version: + * @service: lightweight service handle + * @out_version: version output + * + * Returns the version of the service this handle is currently referring to. + * On QMUX this corresponds to the 'major' version of the service. On QRTR, + * this corresponds to the lower 8 bits of the 'instance' attribute and is thus + * limited to uint8_t. + * + * Returns: #false if the service handle is NULL, #true on success. + */ +bool qmi_service_get_version(struct qmi_service *service, uint8_t *out_version) { if (!service) return false; - if (major) - *major = service->family->info.major; - - if (minor) - *minor = service->family->info.minor; + if (out_version) + *out_version = service->family->info.major; return true; } diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index da245e50ea50..4de9d7bd0037 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -142,8 +142,7 @@ struct qmi_service *qmi_service_clone(struct qmi_service *service); void qmi_service_free(struct qmi_service *service); const char *qmi_service_get_identifier(struct qmi_service *service); -bool qmi_service_get_version(struct qmi_service *service, - uint16_t *major, uint16_t *minor); +bool qmi_service_get_version(struct qmi_service *service, uint8_t *out_version); uint16_t qmi_service_send(struct qmi_service *service, uint16_t message, struct qmi_param *param, diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index c40e9bb1d8af..4ea9c736c284 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -232,15 +232,14 @@ static void test_create_services(const void *data) for (i = 0; i < TEST_SERVICE_COUNT; i++) { struct qmi_service *service; - uint16_t major, minor; + uint8_t version; service_type = unique_service_type(i); service = qmi_qrtr_node_get_service(info->node, service_type); assert(service); - assert(qmi_service_get_version(service, &major, &minor)); - assert(major == unique_service_version(i)); - assert(minor == 0); + assert(qmi_service_get_version(service, &version)); + assert(version == unique_service_version(i)); qmi_service_free(service); } From patchwork Tue Jun 18 20:02:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702925 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 BAFA816DC3C for ; Tue, 18 Jun 2024 20:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740970; cv=none; b=Fxs6C2lWIgKOxU1i7piZe2ybcm5GlipZ7dEd33AL8dTLVAYx4dYnGBO9K9xKiCPobslfYI/Gkov/7nQEAqmpG03CXBUAY0gZ02Tzapvw0xRCRuFzFQ3VW3A0e8sBMwL9LZpultr8tAyq4Ti7U2k52znWutaak9lQZ4c2Y5tvh6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740970; c=relaxed/simple; bh=8APWFakeWhbAhQ0r1ltM3ev+xps7sQiz4exXK7H5Fw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MuajgVVMnF222UFXA14Xdr6NuJQi1w2D9SODg7l8M2cVaAbXocwywpGnPFV6OhlxiVIyLOulr4JH/Ny5uiICo2o09i8mOjcgbOM7nZydOPV6c8HkuErVErJc+OxGBzcRxXdDqK094sraMnWpC1crF4eahT39AOOmNztMaAH+H74= 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=OcM6D8wM; arc=none smtp.client-ip=209.85.160.47 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="OcM6D8wM" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-25c9af0102cso10079fac.0 for ; Tue, 18 Jun 2024 13:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740968; x=1719345768; 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=1UABKOq6ybuakyd5rbD6BhHRw+cJrtUDWhdxBaCGDQI=; b=OcM6D8wM2xicl71uwNSLRIyHVHgih6C03cMI8IMzpPR6uU1XM0XcrIBtHjIGCp2TqM Yn42Kvhm4dAN3AaGKu2a4wKw/7u7UV1iiN0h7KQmeo6oiQt6c4TMwPfKzTtfyjMb5UKN xwuI6X6r3Zs+anTDYW+z3AqCaLKywBfdIziycp/GsfIY2T0wXW9qCbJUq74XNOQL5jgO MsUgNm6XFJb0utqjjKBvpid4N2zX6Lm7cAgNy1xOV3NVopP2OAFHhczo0UMkNtqZ6JtY hO2KtG47QoHCIc1ZRqFwNLIV9+O8PAv6+Bjjpt5wD08YCOMyHkAY9he/P4jw/LZURXvN 5yMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740968; x=1719345768; 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=1UABKOq6ybuakyd5rbD6BhHRw+cJrtUDWhdxBaCGDQI=; b=BpSXCzI9zGFOaXlz2aqgp+FGJxMfvj1j4ryZcfPf7t9WIu+zgzSXnDT9PFZ6IFxB17 D9awd5LbA+ZdY3kybGvbV5lcOXtIqK3vQmrl3RN7BWfdL3NDizFrR845NMbup81Fqqd8 yqRYiVzYQRIrdmyGhj8m4yCKakQ5liRg2+MqpoVEw9EEj86lgamUmjKShtGNg+3cchjN PmCXiLKb7dbTYsdcEKpbkm/F/gRBfGrUbMowQD4X7CptDsShaZvCUnzXmq5vlQMWxMOI s27df8aP19kTy/l+wl0idMh9FVejCP0AvTwiO4CP7zQlzd/A50B4rlOSg+9W8lCM1mQ7 VZag== X-Gm-Message-State: AOJu0YyQhiHlkAy3RHnPkR0Hr16B0OqOAB1igcBEVGw17BkmT+zRdXHX aJ7GqfSEFBgYDB32VdPv5bj0PWQZDLzQIFWKXRRCBjRqTNTWVkqHmBy3Jw== X-Google-Smtp-Source: AGHT+IFTKPGul1m0Y/QxLq19pirc3QqVPpsnGDmSMcUBsbgFULciaYxyjZZfwGpjOrngPBcQidzUzQ== X-Received: by 2002:a05:6870:8181:b0:254:b3cc:a6da with SMTP id 586e51a60fabf-25c94a14f35mr860979fac.29.1718740967745; Tue, 18 Jun 2024 13:02:47 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:47 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 18/33] qmi: break up qmi_device_free into qrtr & qmux variants Date: Tue, 18 Jun 2024 15:02:00 -0500 Message-ID: <20240618200231.1129282-18-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce qmi_qrtr_node_free() that will deallocate a qrtr node object and qmi_qmux_device_free() that will deallocate a qmux device object. This removes the need for the .destroy method inside qmi_device_ops, so get rid of that as well. Since qrtr has no concept of shutting down (this is accomplished immediately using close() on the qrtr socket), move the relevant variables into the qmux specific structure. The destroy operation inside qmi_device_ops is no longer used, remove it. --- drivers/qmimodem/qmi.c | 94 +++++++++++++++++++++------------------- drivers/qmimodem/qmi.h | 3 +- plugins/gobi.c | 4 +- plugins/qrtrqmi.c | 2 +- unit/test-qmimodem-qmi.c | 2 +- 5 files changed, 55 insertions(+), 50 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 6d605d58ad65..509f3dda5945 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -69,7 +69,6 @@ struct qmi_device_ops { int (*shutdown)(struct qmi_device *device, qmi_shutdown_func_t shutdown_func, void *user, qmi_destroy_func_t destroy); - void (*destroy)(struct qmi_device *device); }; struct qmi_device { @@ -86,8 +85,6 @@ struct qmi_device { struct l_hashmap *family_list; const struct qmi_device_ops *ops; bool writer_active : 1; - bool shutting_down : 1; - bool destroyed : 1; }; struct qmi_device_qmux { @@ -102,6 +99,8 @@ struct qmi_device_qmux { unsigned int release_users; uint8_t next_control_tid; struct l_queue *control_queue; + bool shutting_down : 1; + bool destroyed : 1; }; struct service_family { @@ -890,17 +889,8 @@ static int qmi_device_init(struct qmi_device *device, int fd, return 0; } -static void __qmi_device_shutdown_finished(struct qmi_device *device) +static void __qmi_device_free(struct qmi_device *device) { - if (device->destroyed) - device->ops->destroy(device); -} - -void qmi_device_free(struct qmi_device *device) -{ - if (!device) - return; - __debug_device(device, "device %p free", device); l_queue_destroy(device->service_queue, __request_free); @@ -912,11 +902,6 @@ void qmi_device_free(struct qmi_device *device) l_hashmap_destroy(device->family_list, family_destroy); l_queue_destroy(device->service_infos, l_free); - - if (device->shutting_down) - device->destroyed = true; - else - device->ops->destroy(device); } void qmi_device_set_debug(struct qmi_device *device, @@ -1816,6 +1801,17 @@ static void qmi_device_qmux_client_release(struct qmi_device *device, __ctl_request_submit(qmux, req); } +static void __qmux_device_free(struct qmi_device_qmux *qmux) +{ + l_queue_destroy(qmux->control_queue, __request_free); + + if (qmux->shutdown_idle) + l_idle_remove(qmux->shutdown_idle); + + l_free(qmux->version_str); + l_free(qmux); +} + static void qmux_shutdown_destroy(void *user_data) { struct qmi_device_qmux *qmux = user_data; @@ -1825,7 +1821,8 @@ static void qmux_shutdown_destroy(void *user_data) qmux->shutdown_idle = NULL; - __qmi_device_shutdown_finished(&qmux->super); + if (qmux->destroyed) + __qmux_device_free(qmux); } static void qmux_shutdown_callback(struct l_idle *idle, void *user_data) @@ -1835,12 +1832,12 @@ static void qmux_shutdown_callback(struct l_idle *idle, void *user_data) if (qmux->release_users > 0) return; - qmux->super.shutting_down = true; + qmux->shutting_down = true; if (qmux->shutdown_func) qmux->shutdown_func(qmux->shutdown_user_data); - qmux->super.shutting_down = false; + qmux->shutting_down = false; l_idle_remove(qmux->shutdown_idle); } @@ -1871,26 +1868,11 @@ static int qmi_device_qmux_shutdown(struct qmi_device *device, return 0; } -static void qmi_device_qmux_destroy(struct qmi_device *device) -{ - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); - - l_queue_destroy(qmux->control_queue, __request_free); - - if (qmux->shutdown_idle) - l_idle_remove(qmux->shutdown_idle); - - l_free(qmux->version_str); - l_free(qmux); -} - static const struct qmi_device_ops qmux_ops = { .write = qmi_device_qmux_write, .discover = qmi_device_qmux_discover, .client_release = qmi_device_qmux_client_release, .shutdown = qmi_device_qmux_shutdown, - .destroy = qmi_device_qmux_destroy, }; struct qmi_device *qmi_qmux_device_new(const char *device) @@ -1917,6 +1899,24 @@ struct qmi_device *qmi_qmux_device_new(const char *device) return &qmux->super; } +void qmi_qmux_device_free(struct qmi_device *device) +{ + struct qmi_device_qmux *qmux; + + if (!device) + return; + + __qmi_device_free(device); + + qmux = l_container_of(device, struct qmi_device_qmux, super); + if (qmux->shutting_down) { + qmux->destroyed = true; + return; + } + + __qmux_device_free(qmux); +} + struct qmi_device_qrtr { struct qmi_device super; }; @@ -2194,20 +2194,11 @@ error: return rc; } -static void qmi_device_qrtr_destroy(struct qmi_device *device) -{ - struct qmi_device_qrtr *qrtr = - l_container_of(device, struct qmi_device_qrtr, super); - - l_free(qrtr); -} - static const struct qmi_device_ops qrtr_ops = { .write = qmi_device_qrtr_write, .discover = qmi_device_qrtr_discover, .client_release = NULL, .shutdown = NULL, - .destroy = qmi_device_qrtr_destroy, }; struct qmi_device *qmi_qrtr_node_new(uint32_t node) @@ -2232,6 +2223,19 @@ struct qmi_device *qmi_qrtr_node_new(uint32_t node) return &qrtr->super; } +void qmi_qrtr_node_free(struct qmi_device *device) +{ + struct qmi_device_qrtr *node; + + if (!device) + return; + + __qmi_device_free(device); + + node = l_container_of(device, struct qmi_device_qrtr, super); + l_free(node); +} + struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, uint32_t type) { diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 4de9d7bd0037..54661bf44d91 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -71,7 +71,7 @@ typedef void (*qmi_qmux_device_create_client_func_t)(struct qmi_service *, typedef void (*qmi_service_result_func_t)(struct qmi_result *, void *); struct qmi_device *qmi_qmux_device_new(const char *device); -void qmi_device_free(struct qmi_device *device); +void qmi_qmux_device_free(struct qmi_device *device); bool qmi_qmux_device_create_client(struct qmi_device *device, uint16_t service_type, @@ -97,6 +97,7 @@ bool qmi_device_set_expected_data_format(struct qmi_device *device, enum qmi_device_expected_data_format format); struct qmi_device *qmi_qrtr_node_new(uint32_t node); +void qmi_qrtr_node_free(struct qmi_device *device); struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, uint32_t type); diff --git a/plugins/gobi.c b/plugins/gobi.c index 63eb847eb680..3ab2efc39186 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -188,7 +188,7 @@ static void gobi_remove(struct ofono_modem *modem) cleanup_services(data); - qmi_device_free(data->device); + qmi_qmux_device_free(data->device); l_free(data); } @@ -217,7 +217,7 @@ static void shutdown_cb(void *user_data) data->discover_attempts = 0; - qmi_device_free(data->device); + qmi_qmux_device_free(data->device); data->device = NULL; ofono_modem_set_powered(modem, FALSE); diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index adf6625e2824..d25fd050eb88 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -113,7 +113,7 @@ static void qrtrqmi_deinit(struct qrtrqmi_data *data) { qmi_service_free(data->dms); data->dms = NULL; - qmi_device_free(data->node); + qmi_qrtr_node_free(data->node); data->node = NULL; } diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index 4ea9c736c284..4c035db3c9c9 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -170,7 +170,7 @@ static void test_cleanup(struct test_info *info) l_free(info->received); l_timeout_remove(info->timeout); - qmi_device_free(info->node); + qmi_qrtr_node_free(info->node); /* The qrtr services will be destroyed automatically. */ for (i = 0; i < TEST_SERVICE_COUNT; ++i) From patchwork Tue Jun 18 20:02:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702926 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.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 B9D1116DED1 for ; Tue, 18 Jun 2024 20:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740971; cv=none; b=AaWvqwxq5nHmFz2nU2jyWjC/01GV253ow/A/IS98c6fM9kxK3Rp58LPM+6t9qL5/CtCy665gQ6FMBUtUrSyWQ4tGrWetMQSkCS2Pf00o2VdFMwghdMHpstYPQaFK9Tyk0vTvYHLeAtCJr6RbucA8ljKcwvI3KjxbuvwDnQ01+Mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740971; c=relaxed/simple; bh=pc7fpAsAsiuZxj7t5AR0cYq1vzfBL8gcVddY2nGjWy0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EfJnynKi4D+GKJfeOyENVgUcJBP/W8uH0nuhlietixFkWZ+J4pK1bZJZjBv019WYVu+wu12fCDI2nV9+0s5qgeoBdjtnnCKowGxfgQw/kKUY7ZcPLQpNuC6GfevHOx3XVT1jzavNicNFO07MxNEvC+Kpj8tm+0k4p5WfuQZwJU4= 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=PB+cpYeN; arc=none smtp.client-ip=209.85.160.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="PB+cpYeN" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-2506fc3a6cfso2841648fac.2 for ; Tue, 18 Jun 2024 13:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740969; x=1719345769; 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=ypAt5+8b2tJbJH16Wx1FjGcxMq4OFcsPPY9I+akKiwI=; b=PB+cpYeNzyQ6JhcrLS5e0D1IRje9eBVedjInvUpCg3NxofT52C+09bpkuxhN1V6pxK JcjTJWPc20PE7Dvw1A8kTfOw8fDSFIPzStd4Br+nRYqABeQ8ERl0D/YD5OIuHfOlHIEi +L/nrFGecWVb9gJCKQVOK1qpTt0M1C5bFfjutiOtmzOVj1/jfv0ow/0pMyHf1x2UZWTY HGH6DlSduO2IHVKqHfWSy1njTVYOKkJCaT4XScfQh6/dSX3505jxqNIC5lU4ic38QeXM +hoATtCwo45S+vXuAohDN8Ea9Js0joupLW+Z+qOvnhAnTT/LEN8F7tQ73pIqkNXWBv0o UjNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740969; x=1719345769; 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=ypAt5+8b2tJbJH16Wx1FjGcxMq4OFcsPPY9I+akKiwI=; b=Fv0hL6cY2NH98uq5FsqI2Ubf5vCsC5HGrkHlevxAo+HYW90Os/199+y04EjlkOO0CA ZzEkRqmERHLGr2T3uy0n3e49nANaLs4MgQrX0WfjpsBeZIqyBA9KcWPOzn7aYeptGCg0 am4E6RzAITnpVOSY5SfaEtAMevBq7e/Qc7SlU7KQMct4mKDNDbznG/wGJUxYBdeo58uw YvntGU/5pRL9aGVNwMpySa9QQmChaN2QFhgCfRiLkUUf6fa0baD7zmTv+hv5urLd+cqj g3I8V/FkLF8yQ+Aja4mbnYwmxeglW7DpY+hG2ijpnKnIagTCfcCCfsFbc3ily5LwKUye BiJA== X-Gm-Message-State: AOJu0YzlVWPLSb1ORZLaJSaz3/Vx52L+sgdl1UaCJp4no0122AQcQZ6s SACM47u/qaOw81OH12HsrjYhuE2a0mjAfvS3neeMMkV0xv8GyGV4y0VY+Q== X-Google-Smtp-Source: AGHT+IH3Y8qAVJlw4tcP8C8YNTeaIol9tLX3tIKHkWFWKxeBCvJsPebGOZUqsjAoNYRhf3gxtCV80w== X-Received: by 2002:a05:6871:3a23:b0:259:8aef:db3a with SMTP id 586e51a60fabf-25c94a0e4d9mr931201fac.29.1718740968462; Tue, 18 Jun 2024 13:02:48 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:48 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 19/33] qmi: Convert DBG statements to __debug_device Date: Tue, 18 Jun 2024 15:02:01 -0500 Message-ID: <20240618200231.1129282-19-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- drivers/qmimodem/qmi.c | 53 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 509f3dda5945..d0f8a56f1461 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1942,7 +1942,7 @@ static int qmi_device_qrtr_write(struct qmi_device *device, bytes_written = sendto(fd, data, len, 0, (struct sockaddr *) &addr, sizeof(addr)); if (bytes_written < 0) { - DBG("Failure sending data: %s", strerror(errno)); + __debug_device(device, "sendto: %s", strerror(errno)); return -errno; } @@ -1990,20 +1990,19 @@ static void qrtr_received_control_packet(struct qmi_device *device, uint32_t type; uint32_t instance; uint32_t version; - uint32_t node; - uint32_t port; + uint32_t qrtr_node; + uint32_t qrtr_port; if (len < sizeof(*packet)) { - DBG("qrtr packet is too small"); + __debug_device(device, "qrtr packet is too small"); return; } - qrtr_debug_ctrl_request(packet, device->debug_func, - device->debug_data); + qrtr_debug_ctrl_request(packet, device->debug_func, device->debug_data); cmd = L_LE32_TO_CPU(packet->cmd); if (cmd != QRTR_TYPE_NEW_SERVER) { - DBG("Unknown command: %d", cmd); + __debug_device(device, "Unknown command: %d", cmd); return; } @@ -2011,7 +2010,8 @@ static void qrtr_received_control_packet(struct qmi_device *device, if (!packet->server.service && !packet->server.instance && !packet->server.node && !packet->server.port) { - DBG("Initial service discovery has completed"); + __debug_device(device, + "Initial service discovery has completed"); if (data) DISCOVERY_DONE(data, data->user_data); @@ -2025,16 +2025,17 @@ static void qrtr_received_control_packet(struct qmi_device *device, version = L_LE32_TO_CPU(packet->server.instance) & 0xff; instance = L_LE32_TO_CPU(packet->server.instance) >> 8; - node = L_LE32_TO_CPU(packet->server.node); - port = L_LE32_TO_CPU(packet->server.port); + qrtr_node = L_LE32_TO_CPU(packet->server.node); + qrtr_port = L_LE32_TO_CPU(packet->server.port); - DBG("New server: Type: %d Version: %d Instance: %d Node: %d Port: %d", - type, version, instance, node, port); + __debug_device(device, + "New server: %d Version: %d Node/Port: %d/%d", + type, version, qrtr_node, qrtr_port); memset(&info, 0, sizeof(info)); info.service_type = type; - info.qrtr_port = port; - info.qrtr_node = node; + info.qrtr_port = qrtr_port; + info.qrtr_node = qrtr_node; info.major = version; info.instance = instance; @@ -2049,7 +2050,8 @@ static void qrtr_received_control_packet(struct qmi_device *device, } static void qrtr_received_service_message(struct qmi_device *device, - uint32_t node, uint32_t port, + uint32_t qrtr_node, + uint32_t qrtr_port, const void *buf, size_t len) { const struct l_queue_entry *entry; @@ -2059,15 +2061,16 @@ static void qrtr_received_service_message(struct qmi_device *device, entry; entry = entry->next) { struct qmi_service_info *info = entry->data; - if (info->qrtr_node == node && info->qrtr_port == port) { + if (info->qrtr_node == qrtr_node && + info->qrtr_port == qrtr_port) { service_type = info->service_type; break; } } if (!service_type) { - DBG("Received msg from unknown service on node: %d, port: %d", - node, port); + __debug_device(device, "Message from unknown at node/port %d/%d", + qrtr_node, qrtr_port); return; } @@ -2088,8 +2091,8 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) addr_size = sizeof(addr); bytes_read = recvfrom(l_io_get_fd(qrtr->super.io), buf, sizeof(buf), 0, (struct sockaddr *) &addr, &addr_size); - DBG("Received %zd bytes from Node: %d Port: %d", bytes_read, - addr.sq_node, addr.sq_port); + __debug_device(&qrtr->super, "Received %zd bytes from Node: %d Port: %d", + bytes_read, addr.sq_node, addr.sq_port); if (bytes_read < 0) return true; @@ -2152,14 +2155,15 @@ static int qmi_device_qrtr_discover(struct qmi_device *device, addr_len = sizeof(addr); rc = getsockname(fd, (struct sockaddr *) &addr, &addr_len); if (rc) { - DBG("getsockname failed: %s", strerror(errno)); + __debug_device(device, "getsockname failed: %s", + strerror(errno)); rc = -errno; goto error; } if (addr.sq_family != AF_QIPCRTR || addr_len != sizeof(addr)) { - DBG("Unexpected sockaddr from getsockname. family: %d size: %d", - addr.sq_family, addr_len); + __debug_device(device, "Unexpected sockaddr family: %d size: %d", + addr.sq_family, addr_len); rc = -EIO; goto error; } @@ -2172,7 +2176,8 @@ static int qmi_device_qrtr_discover(struct qmi_device *device, sizeof(packet), 0, (struct sockaddr *) &addr, addr_len); if (bytes_written < 0) { - DBG("Failure sending data: %s", strerror(errno)); + __debug_device(device, "Failure sending data: %s", + strerror(errno)); rc = -errno; goto error; } From patchwork Tue Jun 18 20:02:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702927 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 9E99E16DC3A for ; Tue, 18 Jun 2024 20:02:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740972; cv=none; b=BhaSDhT+bGbdwQbMfi278HKKXfYyNBmWGQI/vn7PzfGojrksQzvXo2OMfTyMG4HKeJ6pEiQRAoX2ern5Zyqwsc/3GjOlu4af8y229N40efbxVtUwBrAOPjBBGvSvlaicboLzAz+3NuGMzs/Z460kLKx0CmHqnEyp/8AxWbM7emo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740972; c=relaxed/simple; bh=A8iREZdrCqBveJt9ecwMwPAkmiXgAx6aqeLrGcM9wSk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bUq6SpJgQ0U6U1jOVpi8TpUNCcNn9oVonQ9Q/tmG9pz9QZiqxZfw/n7olt+h4Z3X0qS/WXAUTQ74YDAlAAUr2+2tWI+QxCs488bg9wzkWzHDU3N/IrO4iqa+RYHfVF2DpnkaslHnwql+wrS5I64S1bPk7JsuHxtsZqYjSAhFDK4= 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=GuiRzgCD; arc=none smtp.client-ip=209.85.161.47 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="GuiRzgCD" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-5ba090b0336so2828721eaf.1 for ; Tue, 18 Jun 2024 13:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740969; x=1719345769; 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=hFDXm1Uhu1jeY4p1G0RBdCPHc+vjwxqTBXvNvIPL7Nw=; b=GuiRzgCDMjuxwTeVbGvm4eO4kdhHjnRctR0rC1HdgtK6AhQCW33O7Ux2n2x4+pbJMl z5H1551jYykpNl7BpUluhPIIiF80p7tXDRPH8JaG4enbLK78KIEJ7JFf8Af5MF7PTEcq /9roIPyTk3oE/+WEKa0YxXyB5+6pwnFshqH9yn5Mf9D8uFv31mYvkHEMZSq4IpX7u+ZV ErzVawuYqNiS4VdBxA5NkpV4F/vNZzDcljDnMr0fHgbubmoW9cDlLo/W7XMOXQH8jHyB 57TYkxdbUfMzqDFqfUJXeZc0OXszirAvUpwzwG45ncb/wFC0/zRnWm8nhVUObMN9yt/A FZwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740969; x=1719345769; 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=hFDXm1Uhu1jeY4p1G0RBdCPHc+vjwxqTBXvNvIPL7Nw=; b=fxnG/toZAWEI2XgCakeNc1e+zySb2RwcBKudVUzss/QUIO+FgAtm5sEikKcCOI/Lkh IWIi86Ik4lyjLFY4+l06LxZCOONTV0eUuf8sl+b28cMUPuAOC6Lvlgxxf+g4PVu3UuBt qJKORXQjep2YRg+6XKJ2q4NusT/5kbHgwS7Q2aH+mYrZGSVldPyvyzZ+ww9OZqQn7SIh mX7Cp+hCHcVuFkyIS9Ksvem0eRTj+U0bkdK/eikbvbHDFAodkL4qXpxi/QDS8tY4Ocpc vl+QcQWgHQjdih73mChTDzMKnfqaAUWgbj5+3rYrzSIh0FuHUUAR8VzwnpzTgl9FKNwj kg6g== X-Gm-Message-State: AOJu0YyhVQmYrtfzaX9+u7aL3rY8+wtBDxoydQCtX+1z0qlncVTE1WEd kCm3PvixwEgwM/Fw4WYVS/mSoud6VDjPZYunbzoapLSVxmF+jHe9K6h95A== X-Google-Smtp-Source: AGHT+IEnpzPksBDYn0emncLSMpUWwS/yRL7hMGeCHincE3OUrak8DNkZVL9mW2bDHeJrtppdfswJPQ== X-Received: by 2002:a05:6871:5824:b0:254:a89e:acca with SMTP id 586e51a60fabf-25c94404277mr986933fac.0.1718740969520; Tue, 18 Jun 2024 13:02:49 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:49 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 20/33] qmi: introduce qmi_qrtr_node_lookup Date: Tue, 18 Jun 2024 15:02:02 -0500 Message-ID: <20240618200231.1129282-20-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Service discovery on QRTR is accomplished using a QRTR NEW_LOOKUP control message. Utilize this terminology and introduce a QRTR specific qmi_qrtr_node_lookup method. This method replaces qmi_device_discover(). Update the qrtr unit tests to use the new API. Refactor the lookup implementation to not use struct discover_data or the discovery queue. Use a dedicated 'lookup' structure instead. Change the -EINPROGRESS error returned from qmi_qrtr_node_lookup to -EALREADY to better reflect that the operation has already started. -EINPROGRESS is frequently used in other drivers to notify the caller that the operation will complete asynchronously, with the 0 result meaning that the operation is already complete. --- drivers/qmimodem/qmi.c | 193 +++++++++++++++++++-------------------- drivers/qmimodem/qmi.h | 4 + plugins/qrtrqmi.c | 2 +- unit/test-qmimodem-qmi.c | 26 +++--- 4 files changed, 114 insertions(+), 111 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index d0f8a56f1461..f1b2247b4178 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1919,8 +1919,30 @@ void qmi_qmux_device_free(struct qmi_device *device) struct qmi_device_qrtr { struct qmi_device super; + struct { + qmi_qrtr_node_lookup_done_func_t func; + void *user_data; + qmi_destroy_func_t destroy; + struct l_timeout *timeout; + } lookup; }; +static void __qrtr_lookup_finished(struct qmi_device_qrtr *node) +{ + if (!node->lookup.func) { + __debug_device(&node->super, "No lookup in progress"); + return; + } + + l_timeout_remove(node->lookup.timeout); + node->lookup.func(node->lookup.user_data); + + if (node->lookup.destroy) + node->lookup.destroy(node->lookup.user_data); + + memset(&node->lookup, 0, sizeof(node->lookup)); +} + static int qmi_device_qrtr_write(struct qmi_device *device, struct qmi_request *req) { @@ -1980,11 +2002,11 @@ static void qrtr_debug_ctrl_request(const struct qrtr_ctrl_pkt *packet, function(strbuf, user_data); } -static void qrtr_received_control_packet(struct qmi_device *device, +static void qrtr_received_control_packet(struct qmi_device_qrtr *node, const void *buf, size_t len) { + struct qmi_device *device = &node->super; const struct qrtr_ctrl_pkt *packet = buf; - struct discover_data *data; struct qmi_service_info info; uint32_t cmd; uint32_t type; @@ -2006,18 +2028,11 @@ static void qrtr_received_control_packet(struct qmi_device *device, return; } - data = l_queue_peek_head(device->discovery_queue); - if (!packet->server.service && !packet->server.instance && !packet->server.node && !packet->server.port) { __debug_device(device, "Initial service discovery has completed"); - - if (data) - DISCOVERY_DONE(data, data->user_data); - else - DBG("discovery_queue is empty"); /* likely a timeout */ - + __qrtr_lookup_finished(node); return; } @@ -2041,12 +2056,10 @@ static void qrtr_received_control_packet(struct qmi_device *device, __qmi_service_appeared(device, &info); - if (!data) { - DBG("discovery_queue is empty"); /* likely a timeout */ + if (!node->lookup.func) return; - } - l_timeout_modify(data->timeout, DISCOVER_TIMEOUT); + l_timeout_modify(node->lookup.timeout, DISCOVER_TIMEOUT); } static void qrtr_received_service_message(struct qmi_device *device, @@ -2101,7 +2114,7 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) qrtr->super.debug_data); if (addr.sq_port == QRTR_PORT_CTRL) - qrtr_received_control_packet(&qrtr->super, buf, bytes_read); + qrtr_received_control_packet(qrtr, buf, bytes_read); else qrtr_received_service_message(&qrtr->super, addr.sq_node, addr.sq_port, buf, bytes_read); @@ -2109,42 +2122,78 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) return true; } -static void qrtr_discover_reply_timeout(struct l_timeout *timeout, - void *user_data) +static const struct qmi_device_ops qrtr_ops = { + .write = qmi_device_qrtr_write, + .client_release = NULL, + .shutdown = NULL, +}; + +struct qmi_device *qmi_qrtr_node_new(uint32_t node) { - struct discover_data *data = user_data; + struct qmi_device_qrtr *qrtr; + int fd; - l_timeout_remove(data->timeout); - data->timeout = NULL; + fd = socket(AF_QIPCRTR, SOCK_DGRAM, 0); + if (fd < 0) + return NULL; - DISCOVERY_DONE(data, data->user_data); + qrtr = l_new(struct qmi_device_qrtr, 1); + + if (qmi_device_init(&qrtr->super, fd, &qrtr_ops) < 0) { + close(fd); + l_free(qrtr); + return NULL; + } + + l_io_set_read_handler(qrtr->super.io, qrtr_received_data, qrtr, NULL); + + return &qrtr->super; } -static int qmi_device_qrtr_discover(struct qmi_device *device, - qmi_discover_func_t func, - void *user_data, - qmi_destroy_func_t destroy) +void qmi_qrtr_node_free(struct qmi_device *device) { - struct discover_data *data; + struct qmi_device_qrtr *node; + + if (!device) + return; + + __qmi_device_free(device); + + node = l_container_of(device, struct qmi_device_qrtr, super); + + if (node->lookup.destroy) + node->lookup.destroy(node->lookup.user_data); + + l_free(node); +} + +static void qrtr_lookup_reply_timeout(struct l_timeout *timeout, + void *user_data) +{ + struct qmi_device_qrtr *node = user_data; + + __qrtr_lookup_finished(node); +} + +int qmi_qrtr_node_lookup(struct qmi_device *device, + qmi_qrtr_node_lookup_done_func_t func, + void *user_data, qmi_destroy_func_t destroy) +{ + struct qmi_device_qrtr *node; struct qrtr_ctrl_pkt packet; struct sockaddr_qrtr addr; socklen_t addr_len; - int rc; ssize_t bytes_written; int fd; - __debug_device(device, "device %p discover", device); - - if (l_queue_length(device->discovery_queue) > 0) - return -EINPROGRESS; + if (!device || !func) + return -EINVAL; - data = l_new(struct discover_data, 1); + node = l_container_of(device, struct qmi_device_qrtr, super); + if (node->lookup.func) + return -EALREADY; - data->super.destroy = discover_data_free; - data->device = device; - data->func = func; - data->user_data = user_data; - data->destroy = destroy; + __debug_device(device, "node %p discover", node); fd = l_io_get_fd(device->io); @@ -2153,19 +2202,16 @@ static int qmi_device_qrtr_discover(struct qmi_device *device, * get its value. */ addr_len = sizeof(addr); - rc = getsockname(fd, (struct sockaddr *) &addr, &addr_len); - if (rc) { + if (getsockname(fd, (struct sockaddr *) &addr, &addr_len) < 0) { __debug_device(device, "getsockname failed: %s", strerror(errno)); - rc = -errno; - goto error; + return -errno; } if (addr.sq_family != AF_QIPCRTR || addr_len != sizeof(addr)) { __debug_device(device, "Unexpected sockaddr family: %d size: %d", addr.sq_family, addr_len); - rc = -EIO; - goto error; + return -EIO; } addr.sq_port = QRTR_PORT_CTRL; @@ -2178,67 +2224,20 @@ static int qmi_device_qrtr_discover(struct qmi_device *device, if (bytes_written < 0) { __debug_device(device, "Failure sending data: %s", strerror(errno)); - rc = -errno; - goto error; + return -errno; } l_util_hexdump(false, &packet, bytes_written, device->debug_func, device->debug_data); - data->timeout = l_timeout_create(DISCOVER_TIMEOUT, - qrtr_discover_reply_timeout, - data, NULL); - - __qmi_device_discovery_started(device, &data->super); + node->lookup.func = func; + node->lookup.user_data = user_data; + node->lookup.destroy = destroy; + node->lookup.timeout = l_timeout_create(DISCOVER_TIMEOUT, + qrtr_lookup_reply_timeout, + node, NULL); return 0; - -error: - __discovery_free(&data->super); - - return rc; -} - -static const struct qmi_device_ops qrtr_ops = { - .write = qmi_device_qrtr_write, - .discover = qmi_device_qrtr_discover, - .client_release = NULL, - .shutdown = NULL, -}; - -struct qmi_device *qmi_qrtr_node_new(uint32_t node) -{ - struct qmi_device_qrtr *qrtr; - int fd; - - fd = socket(AF_QIPCRTR, SOCK_DGRAM, 0); - if (fd < 0) - return NULL; - - qrtr = l_new(struct qmi_device_qrtr, 1); - - if (qmi_device_init(&qrtr->super, fd, &qrtr_ops) < 0) { - close(fd); - l_free(qrtr); - return NULL; - } - - l_io_set_read_handler(qrtr->super.io, qrtr_received_data, qrtr, NULL); - - return &qrtr->super; -} - -void qmi_qrtr_node_free(struct qmi_device *device) -{ - struct qmi_device_qrtr *node; - - if (!device) - return; - - __qmi_device_free(device); - - node = l_container_of(device, struct qmi_device_qrtr, super); - l_free(node); } struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 54661bf44d91..2b6a4edb8b85 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -67,6 +67,7 @@ typedef void (*qmi_shutdown_func_t)(void *user_data); typedef void (*qmi_discover_func_t)(void *user_data); typedef void (*qmi_qmux_device_create_client_func_t)(struct qmi_service *, void *user_data); +typedef void (*qmi_qrtr_node_lookup_done_func_t)(void *); typedef void (*qmi_service_result_func_t)(struct qmi_result *, void *); @@ -98,6 +99,9 @@ bool qmi_device_set_expected_data_format(struct qmi_device *device, struct qmi_device *qmi_qrtr_node_new(uint32_t node); void qmi_qrtr_node_free(struct qmi_device *device); +int qmi_qrtr_node_lookup(struct qmi_device *device, + qmi_qrtr_node_lookup_done_func_t func, + void *user_data, qmi_destroy_func_t destroy); struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, uint32_t type); diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index d25fd050eb88..31c02b1cd981 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -215,7 +215,7 @@ static int qrtrqmi_enable(struct ofono_modem *modem) if (getenv("OFONO_QMI_DEBUG")) qmi_device_set_debug(data->node, qrtrqmi_debug, "QRTR: "); - r = qmi_device_discover(data->node, lookup_done, modem, NULL); + r = qmi_qrtr_node_lookup(data->node, lookup_done, modem, NULL); if (!r) return -EINPROGRESS; diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index 4c035db3c9c9..b6537629f86d 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -40,7 +40,7 @@ struct test_info { size_t received_len; void *received; - bool discovery_callback_called : 1; + bool lookup_callback_called : 1; bool service_send_callback_called : 1; bool internal_timeout_callback_called : 1; bool notify_callback_called : 1; @@ -188,26 +188,26 @@ static void test_create_qrtr_node(const void *data) test_cleanup(info); } -static void discovery_complete_cb(void *user_data) +static void lookup_complete_cb(void *user_data) { struct test_info *info = user_data; - info->discovery_callback_called = true; + info->lookup_callback_called = true; } -static void perform_discovery(struct test_info *info) +static void perform_lookup(struct test_info *info) { - qmi_device_discover(info->node, discovery_complete_cb, info, NULL); + qmi_qrtr_node_lookup(info->node, lookup_complete_cb, info, NULL); - while (!info->discovery_callback_called) + while (!info->lookup_callback_called) l_main_iterate(-1); } -static void test_discovery(const void *data) +static void test_lookup(const void *data) { struct test_info *info = test_setup(); - perform_discovery(info); + perform_lookup(info); test_cleanup(info); } @@ -228,7 +228,7 @@ static void test_create_services(const void *data) uint32_t service_type; size_t i; - perform_discovery(info); + perform_lookup(info); for (i = 0; i < TEST_SERVICE_COUNT; i++) { struct qmi_service *service; @@ -428,7 +428,7 @@ static void test_send_data(const void *data) uint32_t service_type; struct qmi_service *service; - perform_discovery(info); + perform_lookup(info); service_type = unique_service_type(0); /* Use the first service */ service = qmi_qrtr_node_get_service(info->node, service_type); @@ -475,7 +475,7 @@ static void test_notifications(const void *data) struct qmi_service *service; struct l_timeout *receive_timeout; - perform_discovery(info); + perform_lookup(info); service_type = unique_service_type(0); /* Use the first service */ service = qmi_qrtr_node_get_service(info->node, service_type); @@ -528,7 +528,7 @@ static void test_service_notification_independence(const void *data) struct qmi_service *services[2]; size_t i; - perform_discovery(info); + perform_lookup(info); service_type = unique_service_type(0); /* Use the first service */ @@ -592,7 +592,7 @@ int main(int argc, char **argv) l_test_init(&argc, &argv); l_test_add("QRTR node creation", test_create_qrtr_node, NULL); - l_test_add("QRTR discovery", test_discovery, NULL); + l_test_add("QRTR lookup", test_lookup, NULL); l_test_add("QRTR services may be created", test_create_services, NULL); l_test_add("QRTR service sends/responses", test_send_data, NULL); l_test_add("QRTR notifications", test_notifications, NULL); From patchwork Tue Jun 18 20:02:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702928 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (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 4762F16DC3C for ; Tue, 18 Jun 2024 20:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740972; cv=none; b=UCtISohupfHXL+ai9Xp/Zd9/rvkRDBu9/MHPjteSMENrQX5PWSjS7Q0zzjQsxbOEaCj9r0slkAWNsJGeXW929CleFPWU5vKAVGeuJTN3Iex/gDUPkQ269bzA0rLkuOyaJ9J8l+d/D+CeiK5F5z8dpkajyqTw/R1Suup3i12xJqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740972; c=relaxed/simple; bh=6dq4bavJ1om0VXsee4PAdABfdZL7XD9OlXZuhL+HQCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TOSKnT9oD/OYndVlgNeMlW3h6oB80mrSGK2HPQY4z9WPeJHhs1s1cNt6ISeECLaLJwXJZCb6wJHNnwWZyQ0E/Dwxf2CF/KR58RBHJgwLcPoWtcFHUuSLhnYBrLKjXftj8j5BZxDKjR938zBdp38/Sr26vKDrH3otjDbA02++YTs= 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=Bea6tAiJ; arc=none smtp.client-ip=209.85.160.51 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="Bea6tAiJ" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-2550aa6f994so3592103fac.3 for ; Tue, 18 Jun 2024 13:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740970; x=1719345770; 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=eIsgHn3lNx3+Rn+eb9tzPvQN8z07VPYftJj2ND4AnLA=; b=Bea6tAiJWqPFWp8/I3P2haSYyDWuhYipBNOs2AZRKZ9PfyS7BR1PCmSA/2NSEylXtB JxA8KnMzJ+7V71/sDzXpUiuCZa//vK/wxJnWKhoNMOQTmp2VFHyEiDNfse2FrP3sKXTp iepop7FO2J+UzoyHN2GLV/6I0YR9jSoOpkpqdiDnU+sV4TRvnYXMLtEeiuXQlGYzhA1E NqTOrc0oFZXQPMQimCwIGLq4jaPP6zk8UKZmc1UM8h04AEczW+nXO9HxeMrhuJjY0cn8 ZoHiyBbFveYHLKNdHwC/B5JIbRdB0D+2xhtXWNRKYA019f9VHBqpCKc1DUcVqwSoZtcn ikqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740970; x=1719345770; 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=eIsgHn3lNx3+Rn+eb9tzPvQN8z07VPYftJj2ND4AnLA=; b=feKJ8RmHAR6sppxAll+w7oHXVHBapyfJ21HflTdWad6edTZmMXm23mXXrYe/WNxo12 j2tDlvKveXjwr95tl4qHUOEdWagq2Dslnj9cNepVsBBOqeq6RlK1UaJpun4YNBBSK2MF t7u+ax3btEcHvpdQIXHv8gt8NPhyiBXyJVSWLT0xqqT3HRtjPUjk7LsdZys0fBBZEuMJ p4GM5sJywPYTj+J4ghWfJi2YBqegRKW1jUdfEekl3zqpxePrEnf/w+DcXTtSuOYEee1F yMtp47d8stFVjirsG1obkSNWFKMrrOFLlRt6NS+Cv7x5B1m4exaEzcQ6EYVzhMF1yKmU e3bQ== X-Gm-Message-State: AOJu0YyWM1D/uIdgeBKAI5W0SJrD/ryZcnUwDDOLsnISpUR3lsCZjkft dyEvObAPCjtrXKbvXn9C4aCY1Zw+6Pf++nDvSaFJH4jnxsLPxXqK262ocQ== X-Google-Smtp-Source: AGHT+IFYhesGJsVyh658OoruQJGWym1Shh0EkcX0skvPthAO14xVA2JHjJnVArR+up5AIS9urH+RAA== X-Received: by 2002:a05:6870:5247:b0:254:adee:216a with SMTP id 586e51a60fabf-25c94dfe3d4mr1000105fac.41.1718740970289; Tue, 18 Jun 2024 13:02:50 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:49 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 21/33] qmi: split qmi_device_has_service into QRTR and QMUX version Date: Tue, 18 Jun 2024 15:02:03 -0500 Message-ID: <20240618200231.1129282-21-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- drivers/qmimodem/qmi.c | 13 ++++++++++++- drivers/qmimodem/qmi.h | 4 ++-- plugins/gobi.c | 14 +++++++------- plugins/qrtrqmi.c | 10 +++++----- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index f1b2247b4178..f4d32bd702b1 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -988,8 +988,11 @@ bool qmi_qmux_device_get_service_version(struct qmi_device *device, return true; } -bool qmi_device_has_service(struct qmi_device *device, uint16_t type) +bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type) { + if (!device) + return false; + return __find_service_info_by_type(device, type); } @@ -2266,6 +2269,14 @@ done: return service_create(family); } +bool qmi_qrtr_node_has_service(struct qmi_device *device, uint16_t type) +{ + if (!device) + return false; + + return __find_service_info_by_type(device, type); +} + struct qmi_param *qmi_param_new(void) { return l_new(struct qmi_param, 1); diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 2b6a4edb8b85..ef0a8b14c0ef 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -81,6 +81,7 @@ bool qmi_qmux_device_create_client(struct qmi_device *device, bool qmi_qmux_device_get_service_version(struct qmi_device *device, uint16_t type, uint16_t *major, uint16_t *minor); +bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type); void qmi_device_set_debug(struct qmi_device *device, qmi_debug_func_t func, void *user_data); @@ -90,8 +91,6 @@ int qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy); -bool qmi_device_has_service(struct qmi_device *device, uint16_t type); - enum qmi_device_expected_data_format qmi_device_get_expected_data_format( struct qmi_device *device); bool qmi_device_set_expected_data_format(struct qmi_device *device, @@ -104,6 +103,7 @@ int qmi_qrtr_node_lookup(struct qmi_device *device, void *user_data, qmi_destroy_func_t destroy); struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, uint32_t type); +bool qmi_qrtr_node_has_service(struct qmi_device *device, uint16_t type); struct qmi_param; diff --git a/plugins/gobi.c b/plugins/gobi.c index 3ab2efc39186..d37829204464 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -446,19 +446,19 @@ static void discover_cb(void *user_data) DBG(""); - if (qmi_device_has_service(data->device, QMI_SERVICE_DMS)) + if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_DMS)) data->features |= GOBI_DMS; - if (qmi_device_has_service(data->device, QMI_SERVICE_NAS)) + if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_NAS)) data->features |= GOBI_NAS; - if (qmi_device_has_service(data->device, QMI_SERVICE_WDS)) + if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_WDS)) data->features |= GOBI_WDS; - if (qmi_device_has_service(data->device, QMI_SERVICE_WDA)) + if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_WDA)) data->features |= GOBI_WDA; - if (qmi_device_has_service(data->device, QMI_SERVICE_PDS)) + if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_PDS)) data->features |= GOBI_PDS; - if (qmi_device_has_service(data->device, QMI_SERVICE_UIM)) + if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_UIM)) data->features |= GOBI_UIM; - if (qmi_device_has_service(data->device, QMI_SERVICE_VOICE)) + if (qmi_qmux_device_has_service(data->device, QMI_SERVICE_VOICE)) data->features |= GOBI_VOICE; if (qmi_qmux_device_get_service_version(data->device, QMI_SERVICE_WMS, diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index 31c02b1cd981..745cfd760029 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -186,10 +186,10 @@ static void lookup_done(void *user_data) DBG(""); - if (!qmi_device_has_service(node, QMI_SERVICE_DMS) || - !qmi_device_has_service(node, QMI_SERVICE_UIM) || - !qmi_device_has_service(node, QMI_SERVICE_WDS) || - !qmi_device_has_service(node, QMI_SERVICE_NAS)) + if (!qmi_qrtr_node_has_service(node, QMI_SERVICE_DMS) || + !qmi_qrtr_node_has_service(node, QMI_SERVICE_UIM) || + !qmi_qrtr_node_has_service(node, QMI_SERVICE_WDS) || + !qmi_qrtr_node_has_service(node, QMI_SERVICE_NAS)) goto error; data->dms = qmi_qrtr_node_get_service(node, QMI_SERVICE_DMS); @@ -381,7 +381,7 @@ static void qrtrqmi_post_sim(struct ofono_modem *modem) ofono_sms_create(modem, 0, "qmimodem", wms); - if (qmi_device_has_service(node, QMI_SERVICE_UIM)) + if (qmi_qrtr_node_has_service(node, QMI_SERVICE_UIM)) mw = ofono_message_waiting_create(modem); if (mw) From patchwork Tue Jun 18 20:02:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702929 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 35ECE16DC3B for ; Tue, 18 Jun 2024 20:02:52 +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=1718740974; cv=none; b=XAzLBqyZOW5PsVDGPniYnAckq2ImuDvfn9MNTRg3fCEXJDyg+FXTdyZRutGRlicunmfUR7+dOSe+SVlpd8KV27j4a8bZKbj/yuHiIjsRUKDgwT7zDwbS1TQfbZL9S49spUPGUGNilhSN7pSC76RTUq2GS1pXpPf5bXUdAn/lHpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740974; c=relaxed/simple; bh=W06XLNhpiTBTJmuAYxArtrDG1IpMqIi1ztIs1Ml610c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rgN7Fl9KuZ5pCEjsfQFcypFTI5ySX99scul0+qxX5btA8UVwmNlCWKH1MwNk8Lqe6aIaXGHoCjZhHyenVjnX9Uo1pZZyGPuI9HbsgzDcqsKgjugSqq6uazMAHk7u7Sfcphq3kuGHFHIcRaVVAo2QR7pTLWWLNccG7MO78oSxfoQ= 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=JRD7yk66; 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="JRD7yk66" Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5b9778bb7c8so2951068eaf.3 for ; Tue, 18 Jun 2024 13:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740971; x=1719345771; 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=CkTVzFYT7NqBOxTtHexukyKlEpKXywdPqaFPVp0UycA=; b=JRD7yk66df/x+ZKIThgKBg2NLOf6FR1EbPJhWT+aNAGIrrBMTK2hPn0Qd19Er+w6jQ umOCmj3di2izP95lrghO47V3dj7Vc7G/Mw7YeMwdPRNyMiJbeu8Fq3UVLnDKSdQt+HX5 +iEHeB+Kehe/3WGl+xuDFCw7ilMKTNCfxPIxYKtQe2WjgojD3mICgARiCFfJvbiuz0iH k3zOl/RnKYNqHUbkn0lkDTQ4Qa/yOM9marUBNtd0I/6b+sBjOiEFMh3EPMyYAyiLPO9V rNdZVxIiEzo6xAN2AtBF+waPxKIys5RGif0l2Hg8bj673cMYd9EUiaWG9RT0QzNGqVKx BtHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740971; x=1719345771; 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=CkTVzFYT7NqBOxTtHexukyKlEpKXywdPqaFPVp0UycA=; b=wcbOebRzZbKzFbqJ+DSlP9zYt90jlpd1Fqnna3LRwML0erL/m1CX2B2NB4134FdDy0 k6ewGGy9Yw74ZAYCjb1pgwDTgNo4UhzXwC/jPoMZu6gSmbwzU991a4IKzQB9AhZYm9R6 Zvsnax2tMkrwkMeMGDJG/gAENqooWR2UMR/WumdupJelQkFvOnKLpUrbYOMFARgMBi5V O3nFqV4UIsAXKgE5bNbiX4Ivc/VlWi2VfvkpwLOcSlyLrsbF0gVVO80ZSbc61Kcxr+eF RWSTkZWd9f+cUTKzMI7iQ8PwubWM2zbWcEulg+4TkfTE3F37kSdN1aOo2/ycivyE/DTb XNzQ== X-Gm-Message-State: AOJu0YzCBubRY4RKvdbYSC9/qKzqZSN31glPNCrmPdbVJ1wy5DF+u6uI daHLgwRhc9iZ7fN1f59keUkrbCUqm1/leDOUFIj6HBDG9kVJsaBEkl22ug== X-Google-Smtp-Source: AGHT+IEF5ICh2dXEdZMt8EYdADvrZqVFef5pia0PNf2hb2ca6l/eyRcF5v/dOHcOqUqkVUWG5oOzxw== X-Received: by 2002:a05:6870:d8c6:b0:250:8769:4d5c with SMTP id 586e51a60fabf-25c94db7da5mr860764fac.53.1718740971100; Tue, 18 Jun 2024 13:02:51 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:50 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 22/33] qmi: split qmi_device_set_debug into QRTR and QMUX versions Date: Tue, 18 Jun 2024 15:02:04 -0500 Message-ID: <20240618200231.1129282-22-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 While here, rework how debugging works by introducing an auxiliary structure to house debug callback and user_data. Replace __debug_device with a DEBUG macro that uses l_util_debug. The use of this macro allows function and line information to be automagically included in the debug output. --- drivers/qmimodem/qmi.c | 177 ++++++++++++++++++++------------------- drivers/qmimodem/qmi.h | 8 +- plugins/gobi.c | 2 +- plugins/qrtrqmi.c | 2 +- unit/test-qmimodem-qmi.c | 2 +- 5 files changed, 97 insertions(+), 94 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index f4d32bd702b1..b5fb27c51a31 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -31,6 +31,10 @@ #define DISCOVER_TIMEOUT 5 +#define DEBUG(debug, fmt, args...) \ + l_util_debug((debug)->func, (debug)->user_data, "%s:%i " fmt, \ + __func__, __LINE__, ## args) + typedef void (*qmi_message_func_t)(uint16_t message, uint16_t length, const void *buffer, void *user_data); @@ -71,6 +75,11 @@ struct qmi_device_ops { void *user, qmi_destroy_func_t destroy); }; +struct debug_data { + qmi_debug_func_t func; + void *user_data; +}; + struct qmi_device { struct l_io *io; struct l_queue *req_queue; @@ -79,8 +88,6 @@ struct qmi_device { unsigned int next_group_id; /* Matches requests with services */ unsigned int next_service_handle; uint16_t next_service_tid; - qmi_debug_func_t debug_func; - void *debug_data; struct l_queue *service_infos; struct l_hashmap *family_list; const struct qmi_device_ops *ops; @@ -92,6 +99,7 @@ struct qmi_device_qmux { uint16_t control_major; uint16_t control_minor; char *version_str; + struct debug_data debug; qmi_shutdown_func_t shutdown_func; void *shutdown_user_data; qmi_destroy_func_t shutdown_destroy; @@ -501,6 +509,13 @@ int qmi_error_to_ofono_cme(int qmi_error) } } +static void __debug_data_init(struct debug_data *debug, + qmi_debug_func_t func, void *user_data) +{ + debug->func = func; + debug->user_data = user_data; +} + static void __debug_msg(char dir, const struct qmi_message_hdr *msg, uint32_t service_type, uint8_t transaction_type, uint16_t tid, uint8_t client, uint16_t overall_length, @@ -630,7 +645,7 @@ static void __qmux_debug_msg(const char dir, const void *buf, size_t len, static void __qrtr_debug_msg(const char dir, const void *buf, size_t len, uint32_t service_type, - qmi_debug_func_t function, void *user_data) + const struct debug_data *debug) { const struct qmi_service_hdr *srv; const struct qmi_message_hdr *msg; @@ -645,23 +660,7 @@ static void __qrtr_debug_msg(const char dir, const void *buf, size_t len, tid = L_LE16_TO_CPU(srv->transaction); __debug_msg(dir, msg, service_type, srv->type >> 1, tid, 0, len, - function, user_data); -} - -static void __debug_device(struct qmi_device *device, - const char *format, ...) -{ - char strbuf[72 + 16]; - va_list ap; - - if (!device->debug_func) - return; - - va_start(ap, format); - vsnprintf(strbuf, sizeof(strbuf), format, ap); - va_end(ap); - - device->debug_func(strbuf, device->debug_data); + debug->func, debug->user_data); } static bool can_write_data(struct l_io *io, void *user_data) @@ -860,8 +859,6 @@ static int qmi_device_init(struct qmi_device *device, int fd, { long flags; - __debug_device(device, "device %p new", device); - flags = fcntl(fd, F_GETFL, NULL); if (flags < 0) return -EIO; @@ -891,8 +888,6 @@ static int qmi_device_init(struct qmi_device *device, int fd, static void __qmi_device_free(struct qmi_device *device) { - __debug_device(device, "device %p free", device); - l_queue_destroy(device->service_queue, __request_free); l_queue_destroy(device->req_queue, __request_free); l_queue_destroy(device->discovery_queue, __discovery_free); @@ -904,16 +899,6 @@ static void __qmi_device_free(struct qmi_device *device) l_queue_destroy(device->service_infos, l_free); } -void qmi_device_set_debug(struct qmi_device *device, - qmi_debug_func_t func, void *user_data) -{ - if (device == NULL) - return; - - device->debug_func = func; - device->debug_data = user_data; -} - void qmi_result_print_tlvs(struct qmi_result *result) { const void *ptr = result->data; @@ -1253,10 +1238,10 @@ static int qmi_device_qmux_write(struct qmi_device *device, return -errno; l_util_hexdump(false, req->data, bytes_written, - device->debug_func, device->debug_data); + qmux->debug.func, qmux->debug.user_data); __qmux_debug_msg(' ', req->data, bytes_written, - device->debug_func, device->debug_data); + qmux->debug.func, qmux->debug.user_data); hdr = (struct qmi_mux_hdr *) req->data; @@ -1316,7 +1301,7 @@ static bool received_qmux_data(struct l_io *io, void *user_data) return true; l_util_hexdump(true, buf, bytes_read, - qmux->super.debug_func, qmux->super.debug_data); + qmux->debug.func, qmux->debug.user_data); offset = 0; @@ -1341,7 +1326,7 @@ static bool received_qmux_data(struct l_io *io, void *user_data) break; __qmux_debug_msg(' ', buf + offset, len, - qmux->super.debug_func, qmux->super.debug_data); + qmux->debug.func, qmux->debug.user_data); msg = buf + offset + QMI_MUX_HDR_SIZE; @@ -1431,10 +1416,6 @@ static struct service_family *service_family_create(struct qmi_device *device, memcpy(&family->info, info, sizeof(family->info)); - __debug_device(device, "service family created [client=%d,type=%d]", - family->client_id, - family->info.service_type); - return family; } @@ -1450,10 +1431,6 @@ static struct qmi_service *service_create(struct service_family *family) service->handle = device->next_service_handle++; service->family = service_family_ref(family); - __debug_device(device, "service created [client=%d,type=%d]", - family->client_id, - family->info.service_type); - return service; } @@ -1489,7 +1466,7 @@ static bool qmi_device_qmux_sync(struct qmi_device_qmux *qmux, { struct qmi_request *req; - __debug_device(&qmux->super, "Sending sync to reset QMI"); + DEBUG(&qmux->debug, "Sending sync to reset QMI"); req = __control_request_alloc(QMI_CTL_SYNC, NULL, 0, qmux_sync_callback, data); @@ -1536,10 +1513,10 @@ static void qmux_discover_callback(uint16_t message, uint16_t length, struct qmi_service_info info; if (name) - __debug_device(device, "found service [%s %d.%d]", + DEBUG(&qmux->debug, "discovered service [%s %d.%d]", name, major, minor); else - __debug_device(device, "found service [%d %d.%d]", + DEBUG(&qmux->debug, "discovered service [%d %d.%d]", type, major, minor); if (type == QMI_SERVICE_CONTROL) { @@ -1561,7 +1538,7 @@ static void qmux_discover_callback(uint16_t message, uint16_t length, goto done; qmux->version_str = l_strndup(ptr + 1, *((uint8_t *) ptr)); - __debug_device(device, "version string: %s", qmux->version_str); + DEBUG(&qmux->debug, "version string: %s", qmux->version_str); done: /* if the device support the QMI call SYNC over the CTL interface */ @@ -1605,7 +1582,7 @@ static int qmi_device_qmux_discover(struct qmi_device *device, struct discover_data *data; struct qmi_request *req; - __debug_device(device, "device %p discover", device); + DEBUG(&qmux->debug, "device %p", qmux); if (l_queue_length(device->service_infos) > 0) return -EALREADY; @@ -1666,7 +1643,7 @@ static void qmux_client_create_timeout(struct l_timeout *timeout, l_container_of(device, struct qmi_device_qmux, super); struct qmi_request *req; - __debug_device(device, "client creation timed out"); + DEBUG(&qmux->debug, ""); l_timeout_remove(data->timeout); data->timeout = NULL; @@ -1684,6 +1661,8 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length, { struct qmux_client_create_data *data = user_data; struct qmi_device *device = data->device; + struct qmi_device_qmux *qmux = + l_container_of(device, struct qmi_device_qmux, super); struct service_family *family = NULL; struct qmi_service *service = NULL; struct qmi_service_info info; @@ -1715,6 +1694,9 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length, info.minor = data->minor; family = service_family_create(device, &info, client_id->client); + DEBUG(&qmux->debug, "service family created [client=%d,type=%d]", + family->client_id, family->info.service_type); + family = service_family_ref(family); hash_id = family_list_create_hash(family->info.service_type, family->client_id); @@ -1763,7 +1745,7 @@ bool qmi_qmux_device_create_client(struct qmi_device *device, create_data->user_data = user_data; create_data->destroy = destroy; - __debug_device(device, "service create [type=%d]", service_type); + DEBUG(&qmux->debug, "creating client [type=%d]", service_type); req = __control_request_alloc(QMI_CTL_GET_CLIENT_ID, client_req, sizeof(client_req), @@ -1856,7 +1838,7 @@ static int qmi_device_qmux_shutdown(struct qmi_device *device, if (qmux->shutdown_idle) return -EALREADY; - __debug_device(&qmux->super, "device %p shutdown", &qmux->super); + DEBUG(&qmux->debug, "device %p", &qmux); qmux->shutdown_idle = l_idle_create(qmux_shutdown_callback, qmux, qmux_shutdown_destroy); @@ -1909,9 +1891,10 @@ void qmi_qmux_device_free(struct qmi_device *device) if (!device) return; + qmux = l_container_of(device, struct qmi_device_qmux, super); + DEBUG(&qmux->debug, "device %p", qmux); __qmi_device_free(device); - qmux = l_container_of(device, struct qmi_device_qmux, super); if (qmux->shutting_down) { qmux->destroyed = true; return; @@ -1920,8 +1903,21 @@ void qmi_qmux_device_free(struct qmi_device *device) __qmux_device_free(qmux); } +void qmi_qmux_device_set_debug(struct qmi_device *device, + qmi_debug_func_t func, void *user_data) +{ + struct qmi_device_qmux *qmux; + + if (device == NULL) + return; + + qmux = l_container_of(device, struct qmi_device_qmux, super); + __debug_data_init(&qmux->debug, func, user_data); +} + struct qmi_device_qrtr { struct qmi_device super; + struct debug_data debug; struct { qmi_qrtr_node_lookup_done_func_t func; void *user_data; @@ -1933,7 +1929,7 @@ struct qmi_device_qrtr { static void __qrtr_lookup_finished(struct qmi_device_qrtr *node) { if (!node->lookup.func) { - __debug_device(&node->super, "No lookup in progress"); + DEBUG(&node->debug, "No lookup in progress"); return; } @@ -1949,6 +1945,8 @@ static void __qrtr_lookup_finished(struct qmi_device_qrtr *node) static int qmi_device_qrtr_write(struct qmi_device *device, struct qmi_request *req) { + struct qmi_device_qrtr *node = + l_container_of(device, struct qmi_device_qrtr, super); struct sockaddr_qrtr addr; uint8_t *data; uint16_t len; @@ -1967,16 +1965,15 @@ static int qmi_device_qrtr_write(struct qmi_device *device, bytes_written = sendto(fd, data, len, 0, (struct sockaddr *) &addr, sizeof(addr)); if (bytes_written < 0) { - __debug_device(device, "sendto: %s", strerror(errno)); + DEBUG(&node->debug, "sendto: %s", strerror(errno)); return -errno; } l_util_hexdump(false, data, bytes_written, - device->debug_func, device->debug_data); + node->debug.func, node->debug.user_data); __qrtr_debug_msg(' ', data, bytes_written, - req->info.service_type, device->debug_func, - device->debug_data); + req->info.service_type, &node->debug); l_queue_push_tail(device->service_queue, req); @@ -1984,13 +1981,12 @@ static int qmi_device_qrtr_write(struct qmi_device *device, } static void qrtr_debug_ctrl_request(const struct qrtr_ctrl_pkt *packet, - qmi_debug_func_t function, - void *user_data) + const struct debug_data *debug) { char strbuf[72 + 16], *str; const char *type; - if (!function) + if (!debug->func) return; str = strbuf; @@ -2002,7 +1998,7 @@ static void qrtr_debug_ctrl_request(const struct qrtr_ctrl_pkt *packet, str += sprintf(str, "%s cmd=%d", type, L_LE32_TO_CPU(packet->cmd)); - function(strbuf, user_data); + debug->func(strbuf, debug->user_data); } static void qrtr_received_control_packet(struct qmi_device_qrtr *node, @@ -2019,22 +2015,21 @@ static void qrtr_received_control_packet(struct qmi_device_qrtr *node, uint32_t qrtr_port; if (len < sizeof(*packet)) { - __debug_device(device, "qrtr packet is too small"); + DEBUG(&node->debug, "packet is too small"); return; } - qrtr_debug_ctrl_request(packet, device->debug_func, device->debug_data); + qrtr_debug_ctrl_request(packet, &node->debug); cmd = L_LE32_TO_CPU(packet->cmd); if (cmd != QRTR_TYPE_NEW_SERVER) { - __debug_device(device, "Unknown command: %d", cmd); + DEBUG(&node->debug, "Unknown command: %d", cmd); return; } if (!packet->server.service && !packet->server.instance && !packet->server.node && !packet->server.port) { - __debug_device(device, - "Initial service discovery has completed"); + DEBUG(&node->debug, "Service lookup complete"); __qrtr_lookup_finished(node); return; } @@ -2046,8 +2041,7 @@ static void qrtr_received_control_packet(struct qmi_device_qrtr *node, qrtr_node = L_LE32_TO_CPU(packet->server.node); qrtr_port = L_LE32_TO_CPU(packet->server.port); - __debug_device(device, - "New server: %d Version: %d Node/Port: %d/%d", + DEBUG(&node->debug, "New server: %d Version: %d Node/Port: %d/%d", type, version, qrtr_node, qrtr_port); memset(&info, 0, sizeof(info)); @@ -2065,11 +2059,12 @@ static void qrtr_received_control_packet(struct qmi_device_qrtr *node, l_timeout_modify(node->lookup.timeout, DISCOVER_TIMEOUT); } -static void qrtr_received_service_message(struct qmi_device *device, +static void qrtr_received_service_message(struct qmi_device_qrtr *node, uint32_t qrtr_node, uint32_t qrtr_port, const void *buf, size_t len) { + struct qmi_device *device = &node->super; const struct l_queue_entry *entry; uint32_t service_type = 0; @@ -2085,14 +2080,12 @@ static void qrtr_received_service_message(struct qmi_device *device, } if (!service_type) { - __debug_device(device, "Message from unknown at node/port %d/%d", + DEBUG(&node->debug, "Message from unknown at node/port %d/%d", qrtr_node, qrtr_port); return; } - __qrtr_debug_msg(' ', buf, len, service_type, - device->debug_func, device->debug_data); - + __qrtr_debug_msg(' ', buf, len, service_type, &node->debug); __rx_message(device, service_type, 0, buf); } @@ -2107,19 +2100,19 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) addr_size = sizeof(addr); bytes_read = recvfrom(l_io_get_fd(qrtr->super.io), buf, sizeof(buf), 0, (struct sockaddr *) &addr, &addr_size); - __debug_device(&qrtr->super, "Received %zd bytes from Node: %d Port: %d", + DEBUG(&qrtr->debug, "Received %zd bytes from Node: %d Port: %d", bytes_read, addr.sq_node, addr.sq_port); if (bytes_read < 0) return true; - l_util_hexdump(true, buf, bytes_read, qrtr->super.debug_func, - qrtr->super.debug_data); + l_util_hexdump(true, buf, bytes_read, + qrtr->debug.func, qrtr->debug.user_data); if (addr.sq_port == QRTR_PORT_CTRL) qrtr_received_control_packet(qrtr, buf, bytes_read); else - qrtr_received_service_message(&qrtr->super, addr.sq_node, + qrtr_received_service_message(qrtr, addr.sq_node, addr.sq_port, buf, bytes_read); return true; @@ -2170,6 +2163,18 @@ void qmi_qrtr_node_free(struct qmi_device *device) l_free(node); } +void qmi_qrtr_node_set_debug(struct qmi_device *device, + qmi_debug_func_t func, void *user_data) +{ + struct qmi_device_qrtr *node; + + if (device == NULL) + return; + + node = l_container_of(device, struct qmi_device_qrtr, super); + __debug_data_init(&node->debug, func, user_data); +} + static void qrtr_lookup_reply_timeout(struct l_timeout *timeout, void *user_data) { @@ -2196,7 +2201,7 @@ int qmi_qrtr_node_lookup(struct qmi_device *device, if (node->lookup.func) return -EALREADY; - __debug_device(device, "node %p discover", node); + DEBUG(&node->debug, "node %p", node); fd = l_io_get_fd(device->io); @@ -2206,13 +2211,12 @@ int qmi_qrtr_node_lookup(struct qmi_device *device, */ addr_len = sizeof(addr); if (getsockname(fd, (struct sockaddr *) &addr, &addr_len) < 0) { - __debug_device(device, "getsockname failed: %s", - strerror(errno)); + DEBUG(&node->debug, "getsockname failed: %s", strerror(errno)); return -errno; } if (addr.sq_family != AF_QIPCRTR || addr_len != sizeof(addr)) { - __debug_device(device, "Unexpected sockaddr family: %d size: %d", + DEBUG(&node->debug, "Unexpected sockaddr family: %d size: %d", addr.sq_family, addr_len); return -EIO; } @@ -2225,13 +2229,12 @@ int qmi_qrtr_node_lookup(struct qmi_device *device, sizeof(packet), 0, (struct sockaddr *) &addr, addr_len); if (bytes_written < 0) { - __debug_device(device, "Failure sending data: %s", - strerror(errno)); + DEBUG(&node->debug, "sendto failed: %s", strerror(errno)); return -errno; } l_util_hexdump(false, &packet, bytes_written, - device->debug_func, device->debug_data); + node->debug.func, node->debug.user_data); node->lookup.func = func; node->lookup.user_data = user_data; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index ef0a8b14c0ef..c85699d0e76f 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -73,7 +73,8 @@ typedef void (*qmi_service_result_func_t)(struct qmi_result *, void *); struct qmi_device *qmi_qmux_device_new(const char *device); void qmi_qmux_device_free(struct qmi_device *device); - +void qmi_qmux_device_set_debug(struct qmi_device *device, + qmi_debug_func_t func, void *user_data); bool qmi_qmux_device_create_client(struct qmi_device *device, uint16_t service_type, qmi_qmux_device_create_client_func_t func, @@ -83,9 +84,6 @@ bool qmi_qmux_device_get_service_version(struct qmi_device *device, uint16_t *major, uint16_t *minor); bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type); -void qmi_device_set_debug(struct qmi_device *device, - qmi_debug_func_t func, void *user_data); - 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, @@ -98,6 +96,8 @@ bool qmi_device_set_expected_data_format(struct qmi_device *device, struct qmi_device *qmi_qrtr_node_new(uint32_t node); void qmi_qrtr_node_free(struct qmi_device *device); +void qmi_qrtr_node_set_debug(struct qmi_device *device, + qmi_debug_func_t func, void *user_data); int qmi_qrtr_node_lookup(struct qmi_device *device, qmi_qrtr_node_lookup_done_func_t func, void *user_data, qmi_destroy_func_t destroy); diff --git a/plugins/gobi.c b/plugins/gobi.c index d37829204464..cd740a7f5b6f 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -515,7 +515,7 @@ static int gobi_enable(struct ofono_modem *modem) return -EIO; if (getenv("OFONO_QMI_DEBUG")) - qmi_device_set_debug(data->device, gobi_debug, "QMI: "); + qmi_qmux_device_set_debug(data->device, gobi_debug, "QMI: "); r = qmi_device_discover(data->device, discover_cb, modem, NULL); if (!r) diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index 745cfd760029..f112043a1596 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -213,7 +213,7 @@ static int qrtrqmi_enable(struct ofono_modem *modem) return -EIO; if (getenv("OFONO_QMI_DEBUG")) - qmi_device_set_debug(data->node, qrtrqmi_debug, "QRTR: "); + qmi_qrtr_node_set_debug(data->node, qrtrqmi_debug, "QRTR: "); r = qmi_qrtr_node_lookup(data->node, lookup_done, modem, NULL); if (!r) diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index b6537629f86d..12fab71ba271 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -156,7 +156,7 @@ static struct test_info *test_setup(void) assert(info->node); /* Enable ofono logging */ - qmi_device_set_debug(info->node, debug_log, NULL); + qmi_qrtr_node_set_debug(info->node, debug_log, NULL); info->timeout = l_timeout_create(TEST_TIMEOUT, test_timeout_cb, info, NULL); From patchwork Tue Jun 18 20:02:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702930 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 B1C1816DC3A for ; Tue, 18 Jun 2024 20:02:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740974; cv=none; b=oipf1MX4zdnRp0cRmns2ULshNpkJeJJo3W4CAn99rYsXxiZD8c7KtJDaPqN2ol98lOgJcFF8LNzavrfMgMAzhZIvhLpKDeC0uNMdRgXNl4BAwgeI2xpNkUgrEnRUk80jZGB2pcFsSZp93SHI0471GXvHc4zHghltshlIEYXWS90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740974; c=relaxed/simple; bh=c+ISnDayuuXGeIoFjdCD46rwDEvlyAWEQLDJu69jD8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LdGVbz4dPMsupuzK44RPBb8uHRClOpnj/Nj7qQKXkP67fhhNfmUNvJ6KVTmll3ZApwG/U0QfMhwnmJvJ/6b9r7oAftkFUK7frSJfMk6ScpcyT4BxDimf1O6RoGM8axB/sabZXHBjBXlw0pvgRHdMyMaU/EJBIZ/gKTrp500w0Rs= 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=XRTVQmYd; arc=none smtp.client-ip=209.85.160.47 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="XRTVQmYd" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-2598a57b2c1so314304fac.0 for ; Tue, 18 Jun 2024 13:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740972; x=1719345772; 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=RGUpZHRIRvxK0pNl0wDhivLPtVbaekEl0KqbXtilTKA=; b=XRTVQmYdowsNDYLAG9/UVwgo6vKzH6sdEgznXE7cnv36rWazAIDj0shV+LBNLgM2pm j5X7iVVRqWQxj7gBalp8/o7jMP7KM0iBHXpQMwCpQlsTQaVw+2SR6uhqoj4Jh9cAGcml davU9kzXV9wpEWYxK3DsyHGdawwxV821lipWEcT33OXaidMA0nva8I5EobLB0EdzCede QOivAVikO1s5sxKX8941Gih2Y5heeRr2nWG7brygzTYQkRRMrQkN5yTTtl8A7XxMtDnn bt5lhTo6/IqH8gj/t7Szrwung9cnvRkXGEKFuyBh1i4NbdumgSQgeOrOcHY4aRhKIKKz DhIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740972; x=1719345772; 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=RGUpZHRIRvxK0pNl0wDhivLPtVbaekEl0KqbXtilTKA=; b=cLmJmQp7Rm6qQ8a2f8Vo+n7NmTKW+8vuWZzh/p78zdICYW0EQxDA2I/sWKkxF7DuGh Znfrrw6HiXmuK+0SiHQMlXARRymBnZx2206Nk6P6z1eSRRkpl9jDQTssFRzhxFRx1t3E N9RauoA3o1yKOAg5Ft/rKYPZH+ZgQ9PXK59RTyeyIqwoj7N5ZicJYbtkKMAl5bIZuJgG eJabJxgtuPj42GCLdFqW9gEsukn4BXZCGHfEUTlkR3NUv1OClmUwT7y0SaqSF3EGpCqM 3PiN/SEKuPn0KMouGNwbjB7hWllfdqTnByyYXEKkWetCGKPnPcluguOhoKMmIMmAqKe0 a1Xw== X-Gm-Message-State: AOJu0YyKihCh/P2+FOV4NciqfwT8g9R/nrr+u1aqYzEydgIA/FtaluNO 4R6XMoUmEd5iP9DpAzOPiX7lzoJ1sd1I+/pAbfVLre9qImiuVawcAvxHhw== X-Google-Smtp-Source: AGHT+IF5zLlR0+F2iOwoQxWkhk+X0Y6/A6w3CvCl86q38WnxYfh2KCBUophjCR+QJhqAsJHrydyYvQ== X-Received: by 2002:a05:6870:1018:b0:257:ea15:b72b with SMTP id 586e51a60fabf-25c948f40fbmr693037fac.9.1718740971678; Tue, 18 Jun 2024 13:02:51 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:51 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 23/33] qmi: Make qmi_qrtr_node methods take struct qmi_qrtr_node Date: Tue, 18 Jun 2024 15:02:05 -0500 Message-ID: <20240618200231.1129282-23-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- drivers/qmimodem/qmi.c | 64 ++++++++++++++++++---------------------- drivers/qmimodem/qmi.h | 12 ++++---- plugins/qrtrqmi.c | 10 +++---- unit/test-qmimodem-qmi.c | 2 +- 4 files changed, 40 insertions(+), 48 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index b5fb27c51a31..4dba8186c09d 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1915,7 +1915,7 @@ void qmi_qmux_device_set_debug(struct qmi_device *device, __debug_data_init(&qmux->debug, func, user_data); } -struct qmi_device_qrtr { +struct qmi_qrtr_node { struct qmi_device super; struct debug_data debug; struct { @@ -1926,7 +1926,7 @@ struct qmi_device_qrtr { } lookup; }; -static void __qrtr_lookup_finished(struct qmi_device_qrtr *node) +static void __qrtr_lookup_finished(struct qmi_qrtr_node *node) { if (!node->lookup.func) { DEBUG(&node->debug, "No lookup in progress"); @@ -1942,11 +1942,11 @@ static void __qrtr_lookup_finished(struct qmi_device_qrtr *node) memset(&node->lookup, 0, sizeof(node->lookup)); } -static int qmi_device_qrtr_write(struct qmi_device *device, +static int qmi_qrtr_node_write(struct qmi_device *device, struct qmi_request *req) { - struct qmi_device_qrtr *node = - l_container_of(device, struct qmi_device_qrtr, super); + struct qmi_qrtr_node *node = + l_container_of(device, struct qmi_qrtr_node, super); struct sockaddr_qrtr addr; uint8_t *data; uint16_t len; @@ -2001,7 +2001,7 @@ static void qrtr_debug_ctrl_request(const struct qrtr_ctrl_pkt *packet, debug->func(strbuf, debug->user_data); } -static void qrtr_received_control_packet(struct qmi_device_qrtr *node, +static void qrtr_received_control_packet(struct qmi_qrtr_node *node, const void *buf, size_t len) { struct qmi_device *device = &node->super; @@ -2059,7 +2059,7 @@ static void qrtr_received_control_packet(struct qmi_device_qrtr *node, l_timeout_modify(node->lookup.timeout, DISCOVER_TIMEOUT); } -static void qrtr_received_service_message(struct qmi_device_qrtr *node, +static void qrtr_received_service_message(struct qmi_qrtr_node *node, uint32_t qrtr_node, uint32_t qrtr_port, const void *buf, size_t len) @@ -2091,7 +2091,7 @@ static void qrtr_received_service_message(struct qmi_device_qrtr *node, static bool qrtr_received_data(struct l_io *io, void *user_data) { - struct qmi_device_qrtr *qrtr = user_data; + struct qmi_qrtr_node *qrtr = user_data; struct sockaddr_qrtr addr; unsigned char buf[2048]; ssize_t bytes_read; @@ -2119,21 +2119,21 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) } static const struct qmi_device_ops qrtr_ops = { - .write = qmi_device_qrtr_write, + .write = qmi_qrtr_node_write, .client_release = NULL, .shutdown = NULL, }; -struct qmi_device *qmi_qrtr_node_new(uint32_t node) +struct qmi_qrtr_node *qmi_qrtr_node_new(uint32_t node) { - struct qmi_device_qrtr *qrtr; + struct qmi_qrtr_node *qrtr; int fd; fd = socket(AF_QIPCRTR, SOCK_DGRAM, 0); if (fd < 0) return NULL; - qrtr = l_new(struct qmi_device_qrtr, 1); + qrtr = l_new(struct qmi_qrtr_node, 1); if (qmi_device_init(&qrtr->super, fd, &qrtr_ops) < 0) { close(fd); @@ -2143,19 +2143,15 @@ struct qmi_device *qmi_qrtr_node_new(uint32_t node) l_io_set_read_handler(qrtr->super.io, qrtr_received_data, qrtr, NULL); - return &qrtr->super; + return qrtr; } -void qmi_qrtr_node_free(struct qmi_device *device) +void qmi_qrtr_node_free(struct qmi_qrtr_node *node) { - struct qmi_device_qrtr *node; - - if (!device) + if (!node) return; - __qmi_device_free(device); - - node = l_container_of(device, struct qmi_device_qrtr, super); + __qmi_device_free(&node->super); if (node->lookup.destroy) node->lookup.destroy(node->lookup.user_data); @@ -2163,47 +2159,42 @@ void qmi_qrtr_node_free(struct qmi_device *device) l_free(node); } -void qmi_qrtr_node_set_debug(struct qmi_device *device, +void qmi_qrtr_node_set_debug(struct qmi_qrtr_node *node, qmi_debug_func_t func, void *user_data) { - struct qmi_device_qrtr *node; - - if (device == NULL) + if (!node) return; - node = l_container_of(device, struct qmi_device_qrtr, super); __debug_data_init(&node->debug, func, user_data); } static void qrtr_lookup_reply_timeout(struct l_timeout *timeout, void *user_data) { - struct qmi_device_qrtr *node = user_data; + struct qmi_qrtr_node *node = user_data; __qrtr_lookup_finished(node); } -int qmi_qrtr_node_lookup(struct qmi_device *device, +int qmi_qrtr_node_lookup(struct qmi_qrtr_node *node, qmi_qrtr_node_lookup_done_func_t func, void *user_data, qmi_destroy_func_t destroy) { - struct qmi_device_qrtr *node; struct qrtr_ctrl_pkt packet; struct sockaddr_qrtr addr; socklen_t addr_len; ssize_t bytes_written; int fd; - if (!device || !func) + if (!node || !func) return -EINVAL; - node = l_container_of(device, struct qmi_device_qrtr, super); if (node->lookup.func) return -EALREADY; DEBUG(&node->debug, "node %p", node); - fd = l_io_get_fd(device->io); + fd = l_io_get_fd(node->super.io); /* * The control node is configured by the system. Use getsockname to @@ -2246,13 +2237,14 @@ int qmi_qrtr_node_lookup(struct qmi_device *device, return 0; } -struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, +struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, uint32_t type) { + struct qmi_device *device = &node->super; struct service_family *family; const struct qmi_service_info *info; - if (!device) + if (!node) return NULL; if (type == QMI_SERVICE_CONTROL) @@ -2272,12 +2264,12 @@ done: return service_create(family); } -bool qmi_qrtr_node_has_service(struct qmi_device *device, uint16_t type) +bool qmi_qrtr_node_has_service(struct qmi_qrtr_node *node, uint16_t type) { - if (!device) + if (!node) return false; - return __find_service_info_by_type(device, type); + return __find_service_info_by_type(&node->super, type); } struct qmi_param *qmi_param_new(void) diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index c85699d0e76f..6e6fc6912622 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -94,16 +94,16 @@ enum qmi_device_expected_data_format qmi_device_get_expected_data_format( bool qmi_device_set_expected_data_format(struct qmi_device *device, enum qmi_device_expected_data_format format); -struct qmi_device *qmi_qrtr_node_new(uint32_t node); -void qmi_qrtr_node_free(struct qmi_device *device); -void qmi_qrtr_node_set_debug(struct qmi_device *device, +struct qmi_qrtr_node *qmi_qrtr_node_new(uint32_t node); +void qmi_qrtr_node_free(struct qmi_qrtr_node *node); +void qmi_qrtr_node_set_debug(struct qmi_qrtr_node *node, qmi_debug_func_t func, void *user_data); -int qmi_qrtr_node_lookup(struct qmi_device *device, +int qmi_qrtr_node_lookup(struct qmi_qrtr_node *node, qmi_qrtr_node_lookup_done_func_t func, void *user_data, qmi_destroy_func_t destroy); -struct qmi_service *qmi_qrtr_node_get_service(struct qmi_device *device, +struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, uint32_t type); -bool qmi_qrtr_node_has_service(struct qmi_device *device, uint16_t type); +bool qmi_qrtr_node_has_service(struct qmi_qrtr_node *node, uint16_t type); struct qmi_param; diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index f112043a1596..51e682f7e87c 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -45,7 +45,7 @@ #include struct qrtrqmi_data { - struct qmi_device *node; + struct qmi_qrtr_node *node; struct qmi_service *dms; int main_net_ifindex; char main_net_name[IFNAMSIZ]; @@ -182,7 +182,7 @@ static void lookup_done(void *user_data) { struct ofono_modem *modem = user_data; struct qrtrqmi_data *data = ofono_modem_get_data(modem); - struct qmi_device *node = data->node; + struct qmi_qrtr_node *node = data->node; DBG(""); @@ -288,7 +288,7 @@ static void qrtrqmi_set_online(struct ofono_modem *modem, ofono_bool_t online, static void qrtrqmi_pre_sim(struct ofono_modem *modem) { struct qrtrqmi_data *data = ofono_modem_get_data(modem); - struct qmi_device *node = data->node; + struct qmi_qrtr_node *node = data->node; struct qmi_service *voice; DBG("%p", modem); @@ -363,7 +363,7 @@ static void setup_gprs(struct ofono_modem *modem) static void qrtrqmi_post_sim(struct ofono_modem *modem) { struct qrtrqmi_data *data = ofono_modem_get_data(modem); - struct qmi_device *node = data->node; + struct qmi_qrtr_node *node = data->node; struct qmi_service *wms; DBG("%p", modem); @@ -394,7 +394,7 @@ static void qrtrqmi_post_sim(struct ofono_modem *modem) static void qrtrqmi_post_online(struct ofono_modem *modem) { struct qrtrqmi_data *data = ofono_modem_get_data(modem); - struct qmi_device *node = data->node; + struct qmi_qrtr_node *node = data->node; DBG("%p", modem); diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index 12fab71ba271..2ff981391849 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -32,7 +32,7 @@ struct test_info { int service_fds[TEST_SERVICE_COUNT]; - struct qmi_device *node; + struct qmi_qrtr_node *node; struct l_timeout *timeout; /* Data sent to our test service */ From patchwork Tue Jun 18 20:02:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702931 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 5DC8F16DC3C for ; Tue, 18 Jun 2024 20:02:53 +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=1718740975; cv=none; b=frptila5ShbvW0C6+7Gz1O1pzTdYrNTv0xvuJHlLjNe+RaJuQST34+WKuPYp9wMMe8OIxErLsnulbU2tPLBUVjlYwKwspsUxsg29ff+VnTRird3xm5wrzQbAeta5WDzCKbKI4B35FUw7ms+oarUAGgfgaC2mz/PtXuCjKvWbJL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740975; c=relaxed/simple; bh=2Wuo2H4uW10SGkoxfVOHIIyd4V9tJAWoZ+ylIolJprc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z5r5BVSGnY62vwIsOd+629Vpyy+52GktfO7pKMh7+5JBJxWS7muwTy1dpqUc28tX1BnRZKaI92Esm6qzBft984Q/+SiWd0RDRr2xVzyUW5TNZniiethbX/abR1LO7v2JiEOxK/jFei+luHiQu3qtS54xvp7TIaLYv8NPNaIcnl0= 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=NECFJVJ9; 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="NECFJVJ9" Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5c1adbcaad3so87824eaf.1 for ; Tue, 18 Jun 2024 13:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740972; x=1719345772; 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=3rGSV/QTbvGJi49PTqC3UjUvGPRyxvWmblgbTvNr5QA=; b=NECFJVJ9vIx5YEghmSQWlM77f1MTuwjNO6V1MmSMgrzZcdsBWJzsTZG2tpX1cQ+pvt IqfVXrt3lQIaqb7g3fuIwQLUxwfAn9bPt7+OdPwvdBnEcc9ZL0iL4p+rkaoVpyEcZ1rg JH8q0yQUbACegy8DX27LKfuItNcDwx0c4XHyg0264GSJClDbFRNH7NMHdIl9FNFMxKyj zMw//Xtb3jLLzMsr7E2nl881KaA0+lO0w7DX50UhUwad9Y65Q8nbC9BhGKjlX9mLUeBw yR48us8skG6JtoOYlZs7nQyDOIfAefdwEMrqzJz9r7ONvjdpIDIoTuOTpK0TH3Z4bqc5 HykA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740972; x=1719345772; 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=3rGSV/QTbvGJi49PTqC3UjUvGPRyxvWmblgbTvNr5QA=; b=Lre9YhBYwKOOmAzYN3+0DPJjFPbAGbYRLOot/HmdjcHU/C12bwnDJKX3YelhLTuZAO t0K5Vwl46Ml5KWr4w2/vU+yB50q3vsbL6Atz36y0tLqwufMFim3pIcve/PPwYNZfaI0x LCovGqB2exHkzXIZvAWumw5s6gQUAj16uUT2gMjUT4fIGshDf+CQNGpmyh2kRWv7EYc9 Euac4vmwgvT1Ep5bWWkpnV8dya6q1I5rvu3vEmrmDxJFuFJ48Af1KfbIzLZ+v7yMp8Zf BkD8hSDRewpbcs9VCHyx113j4CZoOfNNHeIEr7WQooRRYf2wrXAb382tWozJosK8hOS9 EBPA== X-Gm-Message-State: AOJu0YyO4YqcA28PRI3bn1Xd5iXYTO4tNmw3UOp2lAV2R4K5A43/MqIp NhYdaCv8PtppXtwY2hPfWCdat1VR2YS+deVVtrZ+AgS2a0yPiQHxuMC8XQ== X-Google-Smtp-Source: AGHT+IE4lVa66goo7pxNZTaol43DlVLpDi51QLOoDcxJ6IXPB2uToR0DWemZEoPtMMOmnml8fGUIUw== X-Received: by 2002:a05:6871:511:b0:24f:e15a:6536 with SMTP id 586e51a60fabf-25972fc5035mr1649134fac.18.1718740972371; Tue, 18 Jun 2024 13:02:52 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:52 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 24/33] qmi: Move expected data format handling into gobi Date: Tue, 18 Jun 2024 15:02:06 -0500 Message-ID: <20240618200231.1129282-24-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The expected data format logic inside qmi_device was specific to the qmi_wwan driver used for USB QMI (QMUX) devices. Move it to the gobi modem driver that manages such devices. The code is greatly simplified since 'gobi' knows about the network interface name directly. --- drivers/qmimodem/qmi.c | 197 ----------------------------------------- drivers/qmimodem/qmi.h | 11 --- plugins/gobi.c | 67 +++++++++----- 3 files changed, 47 insertions(+), 228 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 4dba8186c09d..306ca6092e5c 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1028,203 +1028,6 @@ int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, return device->ops->shutdown(device, func, user_data, destroy); } -static bool get_device_file_name(struct qmi_device *device, - char *file_name, int size) -{ - pid_t pid; - char temp[100]; - ssize_t result; - int fd = l_io_get_fd(device->io); - - if (size <= 0) - return false; - - pid = getpid(); - - snprintf(temp, 100, "/proc/%d/fd/%d", (int) pid, fd); - temp[99] = 0; - - result = readlink(temp, file_name, size - 1); - - if (result == -1 || result >= size - 1) { - DBG("Error %d in readlink", errno); - return false; - } - - file_name[result] = 0; - - return true; -} - -static char *get_first_dir_in_directory(char *dir_path) -{ - DIR *dir; - struct dirent *dir_entry; - char *dir_name = NULL; - - dir = opendir(dir_path); - - if (!dir) - return NULL; - - dir_entry = readdir(dir); - - while ((dir_entry != NULL)) { - if (dir_entry->d_type == DT_DIR && - strcmp(dir_entry->d_name, ".") != 0 && - strcmp(dir_entry->d_name, "..") != 0) { - dir_name = l_strdup(dir_entry->d_name); - break; - } - - dir_entry = readdir(dir); - } - - closedir(dir); - return dir_name; -} - -static char *get_device_interface(struct qmi_device *device) -{ - char * const driver_names[] = { "usbmisc", "usb" }; - unsigned int i; - char file_path[PATH_MAX]; - const char *file_name; - char *interface = NULL; - - if (!get_device_file_name(device, file_path, sizeof(file_path))) - return NULL; - - file_name = l_basename(file_path); - - for (i = 0; i < L_ARRAY_SIZE(driver_names) && !interface; i++) { - char *sysfs_path; - - sysfs_path = l_strdup_printf("/sys/class/%s/%s/device/net/", - driver_names[i], file_name); - interface = get_first_dir_in_directory(sysfs_path); - l_free(sysfs_path); - } - - return interface; -} - -enum qmi_device_expected_data_format qmi_device_get_expected_data_format( - struct qmi_device *device) -{ - char *sysfs_path = NULL; - char *interface = NULL; - int fd = -1; - char value; - enum qmi_device_expected_data_format expected = - QMI_DEVICE_EXPECTED_DATA_FORMAT_UNKNOWN; - - if (!device) - goto done; - - interface = get_device_interface(device); - - if (!interface) { - DBG("Error while getting interface name"); - goto done; - } - - /* Build sysfs file path and open it */ - sysfs_path = l_strdup_printf("/sys/class/net/%s/qmi/raw_ip", interface); - - fd = open(sysfs_path, O_RDONLY); - if (fd < 0) { - /* maybe not supported by kernel */ - DBG("Error %d in open(%s)", errno, sysfs_path); - goto done; - } - - if (read(fd, &value, 1) != 1) { - DBG("Error %d in read(%s)", errno, sysfs_path); - goto done; - } - - if (value == 'Y') - expected = QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP; - else if (value == 'N') - expected = QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3; - else - DBG("Unexpected sysfs file contents"); - -done: - if (fd >= 0) - close(fd); - - if (sysfs_path) - l_free(sysfs_path); - - if (interface) - l_free(interface); - - return expected; -} - -bool qmi_device_set_expected_data_format(struct qmi_device *device, - enum qmi_device_expected_data_format format) -{ - bool res = false; - char *sysfs_path = NULL; - char *interface = NULL; - int fd = -1; - char value; - - if (!device) - goto done; - - switch (format) { - case QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3: - value = 'N'; - break; - case QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP: - value = 'Y'; - break; - default: - DBG("Unhandled format: %d", (int) format); - goto done; - } - - interface = get_device_interface(device); - - if (!interface) { - DBG("Error while getting interface name"); - goto done; - } - - /* Build sysfs file path and open it */ - sysfs_path = l_strdup_printf("/sys/class/net/%s/qmi/raw_ip", interface); - - fd = open(sysfs_path, O_WRONLY); - if (fd < 0) { - /* maybe not supported by kernel */ - DBG("Error %d in open(%s)", errno, sysfs_path); - goto done; - } - - if (write(fd, &value, 1) != 1) { - DBG("Error %d in write(%s)", errno, sysfs_path); - goto done; - } - - res = true; - -done: - if (fd >= 0) - close(fd); - - if (sysfs_path) - l_free(sysfs_path); - - if (interface) - l_free(interface); - - return res; -} - static int qmi_device_qmux_write(struct qmi_device *device, struct qmi_request *req) { diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 6e6fc6912622..1158600989c5 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -41,12 +41,6 @@ #define QMI_SERVICE_RMS 225 /* Remote management service */ #define QMI_SERVICE_OMA 226 /* OMA device management service */ -enum qmi_device_expected_data_format { - QMI_DEVICE_EXPECTED_DATA_FORMAT_UNKNOWN, - QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3, - QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP, -}; - enum qmi_data_endpoint_type { QMI_DATA_ENDPOINT_TYPE_UNKNOWN = 0x00, QMI_DATA_ENDPOINT_TYPE_HSIC = 0x01, @@ -89,11 +83,6 @@ int qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy); -enum qmi_device_expected_data_format qmi_device_get_expected_data_format( - struct qmi_device *device); -bool qmi_device_set_expected_data_format(struct qmi_device *device, - enum qmi_device_expected_data_format format); - struct qmi_qrtr_node *qmi_qrtr_node_new(uint32_t node); void qmi_qrtr_node_free(struct qmi_qrtr_node *node); void qmi_qrtr_node_set_debug(struct qmi_qrtr_node *node, diff --git a/plugins/gobi.c b/plugins/gobi.c index cd740a7f5b6f..7570a7db3876 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -76,12 +76,13 @@ struct gobi_data { unsigned long features; unsigned int discover_attempts; uint8_t oper_mode; - bool using_mux; - bool using_qmi_wwan_q; int main_net_ifindex; char main_net_name[IFNAMSIZ]; uint32_t max_aggregation_size; uint32_t set_powered_id; + bool using_mux : 1; + bool using_qmi_wwan : 1; + bool using_qmi_wwan_q : 1; }; static void gobi_debug(const char *str, void *user_data) @@ -134,6 +135,8 @@ static int gobi_probe(struct ofono_modem *modem) if (!strcmp(if_driver, "qmi_wwan_q")) data->using_qmi_wwan_q = true; + else if (!strcmp(if_driver, "qmi_wwan")) + data->using_qmi_wwan = true; data->main_net_ifindex = ofono_modem_get_integer(modem, "NetworkInterfaceIndex"); @@ -332,12 +335,49 @@ error: shutdown_device(modem); } +static void setup_qmi_wwan(const char *interface, uint32_t llproto) +{ + char raw_ip; + char new_raw_ip; + + if (l_sysctl_get_char(&raw_ip, "/sys/class/net/%s/qmi/raw_ip", + interface) < 0) { + DBG("Couldn't query raw_ip setting"); + return; + } + + if (raw_ip != 'Y' && raw_ip != 'N') { + DBG("Unexpected value: %c", raw_ip); + return; + } + + switch (llproto) { + case QMI_WDA_DATA_LINK_PROTOCOL_802_3: + new_raw_ip = 'N'; + break; + case QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP: + new_raw_ip = 'Y'; + break; + default: + DBG("Unknown WDA Link Protocol"); + return; + } + + DBG("raw_ip: %c, want: %c", raw_ip, new_raw_ip); + + if (raw_ip == new_raw_ip) + return; + + if (l_sysctl_set_char(new_raw_ip, "/sys/class/net/%s/qmi/raw_ip", + interface) < 0) + DBG("Fail to set raw_ip to %c", new_raw_ip); +} + static void get_data_format_cb(struct qmi_result *result, void *user_data) { struct ofono_modem *modem = user_data; struct gobi_data *data = ofono_modem_get_data(modem); uint32_t llproto; - enum qmi_device_expected_data_format expected_llproto; DBG(""); @@ -347,24 +387,11 @@ static void get_data_format_cb(struct qmi_result *result, void *user_data) if (!qmi_result_get_uint32(result, QMI_WDA_LL_PROTOCOL, &llproto)) goto done; - expected_llproto = qmi_device_get_expected_data_format(data->device); + if (data->using_qmi_wwan) { + const char *interface = + ofono_modem_get_string(modem, "NetworkInterface"); - if ((llproto == QMI_WDA_DATA_LINK_PROTOCOL_802_3) && - (expected_llproto == - QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP)) { - if (!qmi_device_set_expected_data_format(data->device, - QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3)) - DBG("Fail to set expected data to 802.3"); - else - DBG("expected data set to 802.3"); - } else if ((llproto == QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP) && - (expected_llproto == - QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3)) { - if (!qmi_device_set_expected_data_format(data->device, - QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP)) - DBG("Fail to set expected data to raw-ip"); - else - DBG("expected data set to raw-ip"); + setup_qmi_wwan(interface, llproto); } done: From patchwork Tue Jun 18 20:02:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702932 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 3236916DED1 for ; Tue, 18 Jun 2024 20:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740975; cv=none; b=ZFlOxGM3TyXiTyXUDIjSmKgsL2uCurvg4lW2xnGFsoxh17I+nelEpyt9xA1FZUCcBjTDNHUYn4OTro0us0ZlX6uPgMWQOUxT07bn1TBxQaxGSk83c7Sv14fH9DPq02AV/vmu2KHYdpZ+4WVtvW8FZjOn7L2aq38tO9PDZOxvHg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740975; c=relaxed/simple; bh=M3FSWRd4WUybbVJVhwwTq766oEYyHQOzwxsTlYnmMww=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GznvqeiHfjpSoFctv9ILYNB7xpVsh92um0RfEUPzdYY5zhOdIsSS3IdCrJGsBLabUhL6mH0e2gY1Gt0UtQEaucpEWOTPjWLBZXuxYtcSoMha6HEs434OUHbdYc0AE8iAtnqf4uumW9wiOV2Oqh2oGWI0lFY+9ll6QAWhxcSPTCo= 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=FFuGCaZm; arc=none smtp.client-ip=209.85.160.43 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="FFuGCaZm" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-254e42df409so3652611fac.0 for ; Tue, 18 Jun 2024 13:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740973; x=1719345773; 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=P9vAusJEn0byCJUc2wyhItz7xUsaB/1WRDdM1+7MwVM=; b=FFuGCaZmIztP1lJbjXrmVWd9TIXdtxMZZ6s0KHguJmc+mo7LWtuE3FY6jtJeNGaSuS MI90VDoSa1Sw7Xui4/u+Ay4fiSzjhhuLcqaOIHu3q+D5SC9d/YiV3BprJJW1EKeRGmb5 huX2mdT+g+ozjS9h4dGTLiZic38NqXGMqeN1ZZhkpKdRNJKFWn1lYDsSbUuBrS+q2nCo PS1SZFLmTLUF/F98Bw70WfDW0VFRt4pF2CT4tG85ZkhAq6cYVrrycItFE29ARE25E0uK X0HSXYCupUZyxCfOtBj0unSsUJYptxzVzc0XOiKSpkRzoocCt7az7ahcwRXAV0vT+zcI jpPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740973; x=1719345773; 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=P9vAusJEn0byCJUc2wyhItz7xUsaB/1WRDdM1+7MwVM=; b=bkDY/DtBk2fImTR/MHoo4SHyweYp5L7f3H78Kd1p9Iob51nazJFEDVqBg+Wg4NMX/b lMwI+dpugB1/H4rbMgN92Mo26kZLv3Zc5Xs1VUWdHqFGdVSzV5sLP6cofnfwKfS4pF0S Gu7hO3osLRcf6Q6poRj8PEkAmshiGO9pay8NyfyRROzxieIbAfanOjqX/t4N3DlpTyek rkLzPNkwxlh0wKC8SV89CULeJ40yKKTNV6WpOM7g13XRMNYNRyjgy7eTVvD7u92tTS5E 1XMD0wLIiayuPULPBD5yogxGCuXV2ANIMihqQ0Bd/9xPh+yW0aIlR5NU0ivnIb9/D8Rp Mz4g== X-Gm-Message-State: AOJu0YzaA/ReiFNKz0vl1f1ezTNohhhEJpio46RcCa4X8SBwTZuSKydy y4u2ggg5+jYGp4e6sA7Xs79rd9XIvbBY3IT4BIEXSFTUzWDiZAhnkNGrRw== X-Google-Smtp-Source: AGHT+IFfHC46GgxmoGElCTK0qXNmQB+q+I9YEas/kwq7brfebgZiJCSq5t1bpSwvHR4dHvZqIqxCSQ== X-Received: by 2002:a05:6870:7681:b0:24c:5bd5:1934 with SMTP id 586e51a60fabf-25c94d5bfbcmr665444fac.39.1718740973129; Tue, 18 Jun 2024 13:02:53 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:52 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 25/33] qmi: Rename and refactor qmi_device_discover Date: Tue, 18 Jun 2024 15:02:07 -0500 Message-ID: <20240618200231.1129282-25-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor the discover implementation to not use struct discover_data or the discovery queue. Use a dedicated 'discover' structure instead. Remove the now unused discover() method from qmi_device_ops. --- drivers/qmimodem/qmi.c | 153 ++++++++++++++++------------------------- drivers/qmimodem/qmi.h | 7 +- plugins/gobi.c | 5 +- 3 files changed, 66 insertions(+), 99 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 306ca6092e5c..2aebb197fac0 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -65,9 +65,6 @@ struct qmi_request { struct qmi_device_ops { int (*write)(struct qmi_device *device, struct qmi_request *req); - int (*discover)(struct qmi_device *device, - qmi_discover_func_t discover_func, - void *user, qmi_destroy_func_t destroy); void (*client_release)(struct qmi_device *device, uint16_t service_type, uint16_t client_id); int (*shutdown)(struct qmi_device *device, @@ -105,6 +102,13 @@ struct qmi_device_qmux { qmi_destroy_func_t shutdown_destroy; struct l_idle *shutdown_idle; unsigned int release_users; + struct { + qmi_qmux_device_discover_func_t func; + void *user_data; + qmi_destroy_func_t destroy; + struct l_timeout *timeout; + uint16_t tid; + } discover; uint8_t next_control_tid; struct l_queue *control_queue; bool shutting_down : 1; @@ -981,41 +985,6 @@ bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type) return __find_service_info_by_type(device, type); } -struct discover_data { - struct discovery super; - struct qmi_device *device; - qmi_discover_func_t func; - void *user_data; - qmi_destroy_func_t destroy; - uint16_t tid; - struct l_timeout *timeout; -}; - -static void discover_data_free(void *user_data) -{ - struct discover_data *data = user_data; - - if (data->timeout) - l_timeout_remove(data->timeout); - - if (data->destroy) - data->destroy(data->user_data); - - l_free(data); -} - -int qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, - void *user_data, qmi_destroy_func_t destroy) -{ - if (!device) - return -EINVAL; - - if (!device->ops->discover) - return -ENOTSUP; - - return device->ops->discover(device, func, user_data, destroy); -} - int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy) { @@ -1255,37 +1224,30 @@ static struct qmi_request *find_control_request(struct qmi_device_qmux *qmux, return req; } -static void qmux_sync_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) +static void __qmux_discovery_finished(struct qmi_device_qmux *qmux) { - struct discover_data *data = user_data; + l_timeout_remove(qmux->discover.timeout); + qmux->discover.func(qmux->discover.user_data); - DISCOVERY_DONE(data, data->user_data); + if (qmux->discover.destroy) + qmux->discover.destroy(qmux->discover.user_data); + + memset(&qmux->discover, 0, sizeof(qmux->discover)); } -/* sync will release all previous clients */ -static bool qmi_device_qmux_sync(struct qmi_device_qmux *qmux, - struct discover_data *data) +static void qmux_sync_callback(uint16_t message, uint16_t length, + const void *buffer, void *user_data) { - struct qmi_request *req; - - DEBUG(&qmux->debug, "Sending sync to reset QMI"); - - req = __control_request_alloc(QMI_CTL_SYNC, NULL, 0, - qmux_sync_callback, data); - - __ctl_request_submit(qmux, req); + struct qmi_device_qmux *qmux = user_data; - return true; + __qmux_discovery_finished(qmux); } 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); + struct qmi_device_qmux *qmux = user_data; + struct qmi_device *device = &qmux->super; const struct qmi_result_code *result_code; const struct qmi_service_list *service_list; const void *ptr; @@ -1344,69 +1306,68 @@ static void qmux_discover_callback(uint16_t message, uint16_t length, DEBUG(&qmux->debug, "version string: %s", qmux->version_str); done: - /* if the device support the QMI call SYNC over the CTL interface */ + /* + * If the device support the QMI call SYNC over the CTL interface, + * invoke it to reset the state, including release all previously + * allocated clients + */ if ((qmux->control_major == 1 && qmux->control_minor >= 5) || qmux->control_major > 1) { - qmi_device_qmux_sync(qmux, data); + struct qmi_request *req = + __control_request_alloc(QMI_CTL_SYNC, NULL, 0, + qmux_sync_callback, qmux); + + DEBUG(&qmux->debug, "Sending sync to reset QMI"); + qmux->discover.tid = __ctl_request_submit(qmux, req); return; } - DISCOVERY_DONE(data, data->user_data); + __qmux_discovery_finished(qmux); } 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_device *device = user_data; struct qmi_device_qmux *qmux = l_container_of(device, struct qmi_device_qmux, super); struct qmi_request *req; - l_timeout_remove(data->timeout); - data->timeout = NULL; - /* remove request from queues */ - req = find_control_request(qmux, data->tid); - - DISCOVERY_DONE(data, data->user_data); - + req = find_control_request(qmux, qmux->discover.tid); if (req) __request_free(req); + + __qmux_discovery_finished(qmux); } -static int qmi_device_qmux_discover(struct qmi_device *device, - qmi_discover_func_t func, - void *user_data, - qmi_destroy_func_t destroy) +int qmi_qmux_device_discover(struct qmi_device *device, + qmi_qmux_device_discover_func_t func, + void *user_data, qmi_destroy_func_t destroy) { - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); - struct discover_data *data; + struct qmi_device_qmux *qmux; struct qmi_request *req; - DEBUG(&qmux->debug, "device %p", qmux); + if (!device) + return -EINVAL; - if (l_queue_length(device->service_infos) > 0) - return -EALREADY; + qmux = l_container_of(device, struct qmi_device_qmux, super); - data = l_new(struct discover_data, 1); + DEBUG(&qmux->debug, "device %p", qmux); - data->super.destroy = discover_data_free; - data->device = device; - data->func = func; - data->user_data = user_data; - data->destroy = destroy; + if (l_queue_length(device->service_infos) > 0 || qmux->discover.tid) + return -EALREADY; req = __control_request_alloc(QMI_CTL_GET_VERSION_INFO, NULL, 0, - qmux_discover_callback, data); - - data->tid = __ctl_request_submit(qmux, req); - data->timeout = l_timeout_create(DISCOVER_TIMEOUT, - qmux_discover_reply_timeout, - data, NULL); + qmux_discover_callback, qmux); - __qmi_device_discovery_started(device, &data->super); + qmux->discover.func = func; + qmux->discover.user_data = user_data; + qmux->discover.destroy = destroy; + qmux->discover.tid = __ctl_request_submit(qmux, req); + qmux->discover.timeout = + l_timeout_create(DISCOVER_TIMEOUT, qmux_discover_reply_timeout, + qmux, NULL); return 0; } @@ -1593,6 +1554,11 @@ static void __qmux_device_free(struct qmi_device_qmux *qmux) { l_queue_destroy(qmux->control_queue, __request_free); + l_timeout_remove(qmux->discover.timeout); + + if (qmux->discover.destroy) + qmux->discover.destroy(qmux->discover.user_data); + if (qmux->shutdown_idle) l_idle_remove(qmux->shutdown_idle); @@ -1658,7 +1624,6 @@ static int qmi_device_qmux_shutdown(struct qmi_device *device, static const struct qmi_device_ops qmux_ops = { .write = qmi_device_qmux_write, - .discover = qmi_device_qmux_discover, .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 1158600989c5..152ebf1eb14b 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -58,7 +58,7 @@ struct qmi_service; typedef void (*qmi_debug_func_t)(const char *str, void *user_data); typedef void (*qmi_shutdown_func_t)(void *user_data); -typedef void (*qmi_discover_func_t)(void *user_data); +typedef void (*qmi_qmux_device_discover_func_t)(void *user_data); typedef void (*qmi_qmux_device_create_client_func_t)(struct qmi_service *, void *user_data); typedef void (*qmi_qrtr_node_lookup_done_func_t)(void *); @@ -69,6 +69,9 @@ struct qmi_device *qmi_qmux_device_new(const char *device); void qmi_qmux_device_free(struct qmi_device *device); void qmi_qmux_device_set_debug(struct qmi_device *device, qmi_debug_func_t func, void *user_data); +int qmi_qmux_device_discover(struct qmi_device *device, + qmi_qmux_device_discover_func_t func, + void *user_data, qmi_destroy_func_t destroy); bool qmi_qmux_device_create_client(struct qmi_device *device, uint16_t service_type, qmi_qmux_device_create_client_func_t func, @@ -78,8 +81,6 @@ bool qmi_qmux_device_get_service_version(struct qmi_device *device, uint16_t *major, uint16_t *minor); bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type); -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); diff --git a/plugins/gobi.c b/plugins/gobi.c index 7570a7db3876..e39ea6c4ed0e 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -499,7 +499,8 @@ static void discover_cb(void *user_data) if (!(data->features & GOBI_DMS)) { if (++data->discover_attempts < 3 && - !qmi_device_discover(data->device, discover_cb, + !qmi_qmux_device_discover(data->device, + discover_cb, modem, NULL)) return; @@ -544,7 +545,7 @@ static int gobi_enable(struct ofono_modem *modem) if (getenv("OFONO_QMI_DEBUG")) qmi_qmux_device_set_debug(data->device, gobi_debug, "QMI: "); - r = qmi_device_discover(data->device, discover_cb, modem, NULL); + r = qmi_qmux_device_discover(data->device, discover_cb, modem, NULL); if (!r) return -EINPROGRESS; From patchwork Tue Jun 18 20:02:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702933 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 D940016DC3A for ; Tue, 18 Jun 2024 20:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740976; cv=none; b=eUGWnbEm5cprzAbjCqfd1VfgGOyY6uut0Xfh2W3Ik9/kcX05DQH24tEHS1QZ24RcodQxkIw/DU6Nx+UQx407WIINIJc+co/AOyb35jenr2navEWpdepCJmXWFecjLtdKO7t4VC4UrvpMPzss8KroEoShAghgQ8Bi7oowb2qDako= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740976; c=relaxed/simple; bh=z68cc1ur7gn19+lZinUu8Xy5LUEFQexcoWZq1I3K8XE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y3wKgYjIk5egR0h4XHBv2EzC7BAe2SpVW/1fqvaie/p+0y0y8hcj/3lKRFi88eB/YAI5n2oEGViQMfpmpYjXDb8jh4ofIX4a9Zt8CXQGfCYMHpj5qyUDMvBqmxm+n0nf/UgUZ0Ti8xP2F7FwvLI9vkeHY3TRLlueYvO6LKjuq+k= 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=RVOprjAd; arc=none smtp.client-ip=209.85.160.43 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="RVOprjAd" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-250ca14422aso3230244fac.0 for ; Tue, 18 Jun 2024 13:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740974; x=1719345774; 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=BM7YwLgeUpHVqmQLbUop8RywvbnihGeAaoAyFJzEgKE=; b=RVOprjAd2dn3RvoAcVLDPYIDEF+8eC1Y0xFHALmDrO+NuVRcmHZYw0LwiZAYOnbv5S Xgd5S6QvEKV7INWdEy73iTrzqrasaKlfIQ+GVesd5NChkwGobJquI4x3fKHvPBMkTCux uI2eJnS/kQl4BcOdJDHgpFoQ4DwG5/6/Ii/pimb/HwYoLVSjTY7FXSWPpEf8BrmNgBCf cARKf7vCv2ZAUzqMOxFb4GptMfvE3ImCiD0r3BymAFmTnPtf+nVxlbwkSSeFXQRQ2FS+ +B3MFBYD2XKkju7QVU2jMV6pTFkOEycjgRSkQzI8HsDYFGFnrpEJLIsXSJ0MfkhsV6PW UBxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740974; x=1719345774; 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=BM7YwLgeUpHVqmQLbUop8RywvbnihGeAaoAyFJzEgKE=; b=kV/ir6ehPzYvI9EEdWS8Wy8FVpJYzgReBCX48wv2tRekzpAGmH5BbrcbCxsdcfJOiX VHg8Azc3ZzNA3owX1JnbLemtCRbk5EyHutdo9lv14W37WWV0GbljKe66Ge2btEMOw2zt xuyq7rwaaE2ssHr0Sb1gSOqayuyXqq+D7TYn/Qknt2HVHnZrh2rnantbaCUCoo6Whv1y U44KuPKj6Sf/P0EU5GmLRtOaAV2wk35lXCXB2mSSClT4yKPJ4CNAKWZLRYUAn2kI2gmD SatBN7hLudnOj605l2R5vfAuUlSeTVXsQGk0Cm5RmlbFZwj4qTszXFNXXkfJ7p+VSFbV cGxQ== X-Gm-Message-State: AOJu0YzWMtRHp1ZeFqpCxZ5v+CIl6G4UbKUy/hF4JuNrJhV50cJwcCSq e3nrD++0ZZG4vO7CUnVxJqKIjfBanAouVAknkOeZca87One4yEgoZ6mhSQ== X-Google-Smtp-Source: AGHT+IFAj1NjYiMvSzjIlbGU6sEFL0Sfv2NaH3yoS61tR2bCzhJi76cpm2H8yzsoiQJM7eqhoR6jzg== X-Received: by 2002:a05:6871:58a8:b0:24f:dad3:97c with SMTP id 586e51a60fabf-25c94d05a4bmr935699fac.46.1718740973801; Tue, 18 Jun 2024 13:02:53 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:53 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 26/33] qmi: Rename qmi_device_shutdown Date: Tue, 18 Jun 2024 15:02:08 -0500 Message-ID: <20240618200231.1129282-26-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename qmi_device_shutdown to qmi_qmux_device_shutdown to make it clear that only the QMUX implementation requires this operation. Remove the shutdown() method from qmi_device_ops since it is no longer needed. While here, move shutdown operation related members to a dedicated 'shutdown' structure inside qmi_device_qmux. This makes it more consistent with how discovery related members are setup. --- drivers/qmimodem/qmi.c | 75 ++++++++++++++++++------------------------ drivers/qmimodem/qmi.h | 6 ++-- plugins/gobi.c | 2 +- 3 files changed, 36 insertions(+), 47 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 2aebb197fac0..2844ea9f06f6 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -67,9 +67,6 @@ struct qmi_device_ops { int (*write)(struct qmi_device *device, struct qmi_request *req); void (*client_release)(struct qmi_device *device, uint16_t service_type, uint16_t client_id); - int (*shutdown)(struct qmi_device *device, - qmi_shutdown_func_t shutdown_func, - void *user, qmi_destroy_func_t destroy); }; struct debug_data { @@ -97,11 +94,6 @@ struct qmi_device_qmux { uint16_t control_minor; char *version_str; struct debug_data debug; - qmi_shutdown_func_t shutdown_func; - void *shutdown_user_data; - qmi_destroy_func_t shutdown_destroy; - struct l_idle *shutdown_idle; - unsigned int release_users; struct { qmi_qmux_device_discover_func_t func; void *user_data; @@ -109,6 +101,13 @@ struct qmi_device_qmux { struct l_timeout *timeout; uint16_t tid; } discover; + struct { + qmi_qmux_device_shutdown_func_t func; + void *user_data; + qmi_destroy_func_t destroy; + struct l_idle *idle; + unsigned int release_users; + } shutdown; uint8_t next_control_tid; struct l_queue *control_queue; bool shutting_down : 1; @@ -985,18 +984,6 @@ bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type) return __find_service_info_by_type(device, type); } -int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, - void *user_data, qmi_destroy_func_t destroy) -{ - if (!device) - return -EINVAL; - - if (!device->ops->shutdown) - return -ENOTSUP; - - return device->ops->shutdown(device, func, user_data, destroy); -} - static int qmi_device_qmux_write(struct qmi_device *device, struct qmi_request *req) { @@ -1529,7 +1516,7 @@ static void qmux_client_release_callback(uint16_t message, uint16_t length, { struct qmi_device_qmux *qmux = user_data; - qmux->release_users--; + qmux->shutdown.release_users--; } static void qmi_device_qmux_client_release(struct qmi_device *device, @@ -1541,7 +1528,7 @@ static void qmi_device_qmux_client_release(struct qmi_device *device, uint8_t release_req[] = { 0x01, 0x02, 0x00, service_type, client_id }; struct qmi_request *req; - qmux->release_users++; + qmux->shutdown.release_users++; req = __control_request_alloc(QMI_CTL_RELEASE_CLIENT_ID, release_req, sizeof(release_req), @@ -1559,8 +1546,8 @@ static void __qmux_device_free(struct qmi_device_qmux *qmux) if (qmux->discover.destroy) qmux->discover.destroy(qmux->discover.user_data); - if (qmux->shutdown_idle) - l_idle_remove(qmux->shutdown_idle); + if (qmux->shutdown.idle) + l_idle_remove(qmux->shutdown.idle); l_free(qmux->version_str); l_free(qmux); @@ -1570,10 +1557,10 @@ static void qmux_shutdown_destroy(void *user_data) { struct qmi_device_qmux *qmux = user_data; - if (qmux->shutdown_destroy) - qmux->shutdown_destroy(qmux->shutdown_user_data); + if (qmux->shutdown.destroy) + qmux->shutdown.destroy(qmux->shutdown.user_data); - qmux->shutdown_idle = NULL; + qmux->shutdown.idle = NULL; if (qmux->destroyed) __qmux_device_free(qmux); @@ -1583,41 +1570,45 @@ static void qmux_shutdown_callback(struct l_idle *idle, void *user_data) { struct qmi_device_qmux *qmux = user_data; - if (qmux->release_users > 0) + if (qmux->shutdown.release_users > 0) return; qmux->shutting_down = true; - if (qmux->shutdown_func) - qmux->shutdown_func(qmux->shutdown_user_data); + if (qmux->shutdown.func) + qmux->shutdown.func(qmux->shutdown.user_data); qmux->shutting_down = false; - l_idle_remove(qmux->shutdown_idle); + l_idle_remove(qmux->shutdown.idle); } -static int qmi_device_qmux_shutdown(struct qmi_device *device, - qmi_shutdown_func_t func, +int qmi_qmux_device_shutdown(struct qmi_device *device, + qmi_qmux_device_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy) { - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); + struct qmi_device_qmux *qmux; + + if (!device) + return -EINVAL; + + qmux = l_container_of(device, struct qmi_device_qmux, super); - if (qmux->shutdown_idle) + if (qmux->shutdown.idle) return -EALREADY; DEBUG(&qmux->debug, "device %p", &qmux); - qmux->shutdown_idle = l_idle_create(qmux_shutdown_callback, qmux, + qmux->shutdown.idle = l_idle_create(qmux_shutdown_callback, qmux, qmux_shutdown_destroy); - if (!qmux->shutdown_idle) + if (!qmux->shutdown.idle) return -EIO; - qmux->shutdown_func = func; - qmux->shutdown_user_data = user_data; - qmux->shutdown_destroy = destroy; + qmux->shutdown.func = func; + qmux->shutdown.user_data = user_data; + qmux->shutdown.destroy = destroy; return 0; } @@ -1625,7 +1616,6 @@ static int qmi_device_qmux_shutdown(struct qmi_device *device, static const struct qmi_device_ops qmux_ops = { .write = qmi_device_qmux_write, .client_release = qmi_device_qmux_client_release, - .shutdown = qmi_device_qmux_shutdown, }; struct qmi_device *qmi_qmux_device_new(const char *device) @@ -1889,7 +1879,6 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) static const struct qmi_device_ops qrtr_ops = { .write = qmi_qrtr_node_write, .client_release = NULL, - .shutdown = NULL, }; struct qmi_qrtr_node *qmi_qrtr_node_new(uint32_t node) diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 152ebf1eb14b..64eebc27c17c 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -57,10 +57,10 @@ struct qmi_result; struct qmi_service; typedef void (*qmi_debug_func_t)(const char *str, void *user_data); -typedef void (*qmi_shutdown_func_t)(void *user_data); typedef void (*qmi_qmux_device_discover_func_t)(void *user_data); typedef void (*qmi_qmux_device_create_client_func_t)(struct qmi_service *, void *user_data); +typedef void (*qmi_qmux_device_shutdown_func_t)(void *user_data); typedef void (*qmi_qrtr_node_lookup_done_func_t)(void *); typedef void (*qmi_service_result_func_t)(struct qmi_result *, void *); @@ -80,8 +80,8 @@ bool qmi_qmux_device_get_service_version(struct qmi_device *device, uint16_t type, uint16_t *major, uint16_t *minor); bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type); - -int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, +int qmi_qmux_device_shutdown(struct qmi_device *device, + qmi_qmux_device_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy); struct qmi_qrtr_node *qmi_qrtr_node_new(uint32_t node); diff --git a/plugins/gobi.c b/plugins/gobi.c index e39ea6c4ed0e..74df3c360c96 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -234,7 +234,7 @@ static void shutdown_device(struct ofono_modem *modem) cleanup_services(data); - if (qmi_device_shutdown(data->device, shutdown_cb, modem, NULL) < 0) + if (qmi_qmux_device_shutdown(data->device, shutdown_cb, modem, NULL) < 0) shutdown_cb(modem); } From patchwork Tue Jun 18 20:02:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702934 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (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 B4B2E16DC3C for ; Tue, 18 Jun 2024 20:02:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740977; cv=none; b=frExu9Vjx+TYYGvNFr/noXyDYZ4L/rOdLlnT107+15jjphnp0C6R18txrXUG5EBSJHUUTuOkyLySUrCU/I2T1FV+bx+4ck9NAREhKgF7YDB1vXD6h010bH11DJBJK0EjNvKsHAR0uVaaFHgsYZdsrJGzD3poLY3wSMb2xlIasCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740977; c=relaxed/simple; bh=1ByNebelWl9f4YdnvJ3Bax8lqU/4oSH9sh6q4mjNkHU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K3lva6XObDwtE3XD6MHWHYyg3aepIrpOJOkhMQ8PsxgHg533UIcTeerAJNT0ICA6k6eVKrvQRLE9aK3QLV07drCgLadOxHKuz1hD6PXdBNaZBBF71MHrn9czgHJ5cHjgX3g5VvFk1D1eY4xNfb8Q6HsSH2lUtQ5YZlxYP8zrpbc= 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=F78wceID; arc=none smtp.client-ip=209.85.160.53 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="F78wceID" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-254871388d3so3048294fac.1 for ; Tue, 18 Jun 2024 13:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740975; x=1719345775; 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=udO/L9DMI2zI7TIPMBxhylWJvX/iPlh3ntGUU1b17lg=; b=F78wceIDs2aXJ218EVo58Di8XgM3uE7VkT/6qcL1RVhGIUwXHnERaFbC7RopZq+VxD gWSfWIwXRlXSaB+QZnm+tQtj7YoDdzkdj7MOoGS4SrrgTgEIPqIioka3KNZasX78Lv7s VIec5iGJ971zb9QjSmvAQDjB6A2stMAouGPz2B+HX57/P0rO74h6U90Tjjcw1124JB0o X93D+wl4GACBZhrCBc5Fgv9QnIsjf+wQaw5WZYxavLqGrglOdkUAQvx6ISynUENOoJ0v WPuPYfVUspvKp9/W7ExUh1CYzG+2rCMwFICMijn5IwEpgyy6tHKgQbPY3h+owRehG4Ll 9AOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740975; x=1719345775; 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=udO/L9DMI2zI7TIPMBxhylWJvX/iPlh3ntGUU1b17lg=; b=FCSyUop3DxeBCpekrpD8ocbYfNfvVYbIzZTuLpOy1yUdCKXRaKmhb1gwwNtElBs+yo k2QSzbBm+k1OjOATRtPUK9jGPYQjQG8S6ASIE0lsfhYmwYVGNutQ0njEFlPoLhOCg0D+ 9vS8+CDQGEDt2VrvLVYJtIsw2r1YzfxIML4hPEb7JJML6cB5eN9uCCOauvotGatPRyPr Q6z3hPpZWkXhIcVuv+SuNcUnkEzcvwbQNlVapY7Mzb8h6/B/mugwi03fz0qoNXVljBv4 NGqSd2muo1A3LcWnEc+yZZ6cHZmehLrASHZRzXluYgJTPunqofqw1lQV767oHVGiVDVl 5NDw== X-Gm-Message-State: AOJu0YwNkSLnukndW8c/G8oueaQgfuH63NRHRp+zb0GFTfoRc8J8BI7K End8ws2weZFHTfuACefJjNYLQeNriPoeTTnyD17ucDK4vg8gAKxK82kgTA== X-Google-Smtp-Source: AGHT+IGtPlSJU/LK/nm8fX4nvY810gTbphDDwDdKf9xS6jsiLJwRpFpiozvppg99d+2ZjZ8hm/87EA== X-Received: by 2002:a05:6870:d60a:b0:258:38d5:6518 with SMTP id 586e51a60fabf-25c948e3e2amr926036fac.4.1718740974509; Tue, 18 Jun 2024 13:02:54 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:54 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 27/33] qmi: Rename qmi_device_qmux to qmi_qmux_device Date: Tue, 18 Jun 2024 15:02:09 -0500 Message-ID: <20240618200231.1129282-27-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- drivers/qmimodem/qmi.c | 76 +++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 2844ea9f06f6..0d67b07fa729 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -88,7 +88,7 @@ struct qmi_device { bool writer_active : 1; }; -struct qmi_device_qmux { +struct qmi_qmux_device { struct qmi_device super; uint16_t control_major; uint16_t control_minor; @@ -984,11 +984,11 @@ bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type) return __find_service_info_by_type(device, type); } -static int qmi_device_qmux_write(struct qmi_device *device, +static int qmi_qmux_device_write(struct qmi_device *device, struct qmi_request *req) { - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); + struct qmi_qmux_device *qmux = + l_container_of(device, struct qmi_qmux_device, super); struct qmi_mux_hdr *hdr; ssize_t bytes_written; @@ -1012,7 +1012,7 @@ static int qmi_device_qmux_write(struct qmi_device *device, return 0; } -static void __rx_ctl_message(struct qmi_device_qmux *qmux, +static void __rx_ctl_message(struct qmi_qmux_device *qmux, uint8_t service_type, uint8_t client_id, const void *buf) { @@ -1049,7 +1049,7 @@ static void __rx_ctl_message(struct qmi_device_qmux *qmux, static bool received_qmux_data(struct l_io *io, void *user_data) { - struct qmi_device_qmux *qmux = user_data; + struct qmi_qmux_device *qmux = user_data; struct qmi_mux_hdr *hdr; unsigned char buf[2048]; ssize_t bytes_read; @@ -1138,7 +1138,7 @@ done: l_free(family); } -static uint8_t __ctl_request_submit(struct qmi_device_qmux *qmux, +static uint8_t __ctl_request_submit(struct qmi_qmux_device *qmux, struct qmi_request *req) { struct qmi_control_hdr *hdr = @@ -1193,7 +1193,7 @@ static struct qmi_service *service_create(struct service_family *family) return service; } -static struct qmi_request *find_control_request(struct qmi_device_qmux *qmux, +static struct qmi_request *find_control_request(struct qmi_qmux_device *qmux, uint16_t tid) { struct qmi_request *req; @@ -1211,7 +1211,7 @@ static struct qmi_request *find_control_request(struct qmi_device_qmux *qmux, return req; } -static void __qmux_discovery_finished(struct qmi_device_qmux *qmux) +static void __qmux_discovery_finished(struct qmi_qmux_device *qmux) { l_timeout_remove(qmux->discover.timeout); qmux->discover.func(qmux->discover.user_data); @@ -1225,7 +1225,7 @@ static void __qmux_discovery_finished(struct qmi_device_qmux *qmux) static void qmux_sync_callback(uint16_t message, uint16_t length, const void *buffer, void *user_data) { - struct qmi_device_qmux *qmux = user_data; + struct qmi_qmux_device *qmux = user_data; __qmux_discovery_finished(qmux); } @@ -1233,7 +1233,7 @@ static void qmux_sync_callback(uint16_t message, uint16_t length, static void qmux_discover_callback(uint16_t message, uint16_t length, const void *buffer, void *user_data) { - struct qmi_device_qmux *qmux = user_data; + struct qmi_qmux_device *qmux = user_data; struct qmi_device *device = &qmux->super; const struct qmi_result_code *result_code; const struct qmi_service_list *service_list; @@ -1316,8 +1316,8 @@ static void qmux_discover_reply_timeout(struct l_timeout *timeout, void *user_data) { struct qmi_device *device = user_data; - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); + struct qmi_qmux_device *qmux = + l_container_of(device, struct qmi_qmux_device, super); struct qmi_request *req; /* remove request from queues */ @@ -1332,13 +1332,13 @@ int qmi_qmux_device_discover(struct qmi_device *device, qmi_qmux_device_discover_func_t func, void *user_data, qmi_destroy_func_t destroy) { - struct qmi_device_qmux *qmux; + struct qmi_qmux_device *qmux; struct qmi_request *req; if (!device) return -EINVAL; - qmux = l_container_of(device, struct qmi_device_qmux, super); + qmux = l_container_of(device, struct qmi_qmux_device, super); DEBUG(&qmux->debug, "device %p", qmux); @@ -1390,8 +1390,8 @@ static void qmux_client_create_timeout(struct l_timeout *timeout, { struct qmux_client_create_data *data = user_data; struct qmi_device *device = data->device; - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); + struct qmi_qmux_device *qmux = + l_container_of(device, struct qmi_qmux_device, super); struct qmi_request *req; DEBUG(&qmux->debug, ""); @@ -1412,8 +1412,8 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length, { struct qmux_client_create_data *data = user_data; struct qmi_device *device = data->device; - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); + struct qmi_qmux_device *qmux = + l_container_of(device, struct qmi_qmux_device, super); struct service_family *family = NULL; struct qmi_service *service = NULL; struct qmi_service_info info; @@ -1470,7 +1470,7 @@ bool qmi_qmux_device_create_client(struct qmi_device *device, { unsigned char client_req[] = { 0x01, 0x01, 0x00, service_type }; const struct qmi_service_info *info; - struct qmi_device_qmux *qmux; + struct qmi_qmux_device *qmux; struct qmi_request *req; struct qmux_client_create_data *create_data; @@ -1484,7 +1484,7 @@ bool qmi_qmux_device_create_client(struct qmi_device *device, if (!info) return false; - qmux = l_container_of(device, struct qmi_device_qmux, super); + qmux = l_container_of(device, struct qmi_qmux_device, super); create_data = l_new(struct qmux_client_create_data, 1); create_data->super.destroy = qmux_client_create_data_free; @@ -1514,17 +1514,17 @@ bool qmi_qmux_device_create_client(struct qmi_device *device, static void qmux_client_release_callback(uint16_t message, uint16_t length, const void *buffer, void *user_data) { - struct qmi_device_qmux *qmux = user_data; + struct qmi_qmux_device *qmux = user_data; qmux->shutdown.release_users--; } -static void qmi_device_qmux_client_release(struct qmi_device *device, +static void qmi_qmux_device_client_release(struct qmi_device *device, uint16_t service_type, uint16_t client_id) { - struct qmi_device_qmux *qmux = - l_container_of(device, struct qmi_device_qmux, super); + struct qmi_qmux_device *qmux = + l_container_of(device, struct qmi_qmux_device, super); uint8_t release_req[] = { 0x01, 0x02, 0x00, service_type, client_id }; struct qmi_request *req; @@ -1537,7 +1537,7 @@ static void qmi_device_qmux_client_release(struct qmi_device *device, __ctl_request_submit(qmux, req); } -static void __qmux_device_free(struct qmi_device_qmux *qmux) +static void __qmux_device_free(struct qmi_qmux_device *qmux) { l_queue_destroy(qmux->control_queue, __request_free); @@ -1555,7 +1555,7 @@ static void __qmux_device_free(struct qmi_device_qmux *qmux) static void qmux_shutdown_destroy(void *user_data) { - struct qmi_device_qmux *qmux = user_data; + struct qmi_qmux_device *qmux = user_data; if (qmux->shutdown.destroy) qmux->shutdown.destroy(qmux->shutdown.user_data); @@ -1568,7 +1568,7 @@ static void qmux_shutdown_destroy(void *user_data) static void qmux_shutdown_callback(struct l_idle *idle, void *user_data) { - struct qmi_device_qmux *qmux = user_data; + struct qmi_qmux_device *qmux = user_data; if (qmux->shutdown.release_users > 0) return; @@ -1588,12 +1588,12 @@ int qmi_qmux_device_shutdown(struct qmi_device *device, void *user_data, qmi_destroy_func_t destroy) { - struct qmi_device_qmux *qmux; + struct qmi_qmux_device *qmux; if (!device) return -EINVAL; - qmux = l_container_of(device, struct qmi_device_qmux, super); + qmux = l_container_of(device, struct qmi_qmux_device, super); if (qmux->shutdown.idle) return -EALREADY; @@ -1614,20 +1614,20 @@ int qmi_qmux_device_shutdown(struct qmi_device *device, } static const struct qmi_device_ops qmux_ops = { - .write = qmi_device_qmux_write, - .client_release = qmi_device_qmux_client_release, + .write = qmi_qmux_device_write, + .client_release = qmi_qmux_device_client_release, }; struct qmi_device *qmi_qmux_device_new(const char *device) { - struct qmi_device_qmux *qmux; + struct qmi_qmux_device *qmux; int fd; fd = open(device, O_RDWR | O_NONBLOCK | O_CLOEXEC); if (fd < 0) return NULL; - qmux = l_new(struct qmi_device_qmux, 1); + qmux = l_new(struct qmi_qmux_device, 1); if (qmi_device_init(&qmux->super, fd, &qmux_ops) < 0) { close(fd); @@ -1644,12 +1644,12 @@ struct qmi_device *qmi_qmux_device_new(const char *device) void qmi_qmux_device_free(struct qmi_device *device) { - struct qmi_device_qmux *qmux; + struct qmi_qmux_device *qmux; if (!device) return; - qmux = l_container_of(device, struct qmi_device_qmux, super); + qmux = l_container_of(device, struct qmi_qmux_device, super); DEBUG(&qmux->debug, "device %p", qmux); __qmi_device_free(device); @@ -1664,12 +1664,12 @@ void qmi_qmux_device_free(struct qmi_device *device) void qmi_qmux_device_set_debug(struct qmi_device *device, qmi_debug_func_t func, void *user_data) { - struct qmi_device_qmux *qmux; + struct qmi_qmux_device *qmux; if (device == NULL) return; - qmux = l_container_of(device, struct qmi_device_qmux, super); + qmux = l_container_of(device, struct qmi_qmux_device, super); __debug_data_init(&qmux->debug, func, user_data); } From patchwork Tue Jun 18 20:02:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702935 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (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 1F5BB16DED1 for ; Tue, 18 Jun 2024 20:02:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740977; cv=none; b=tkp1ysPxpoATRJNm4DrOOuCMqA6VeBwARs5sjK0aVNcAJoiRHJYzbVjZt5llH2LgFCnaRZRyhoGR2tmLGroPFJQm8V7Siq9M3Ww1gClB+Kxl28YTNzGRh3autnDx/TNK6KFZ5FUW1Pi+eji5pHpXFL0nC/ZUGltgtbGq+cmBLDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740977; c=relaxed/simple; bh=vALwEXGnKaUaWGin0BX40qNkKZqU1PtcNNQkIM7hnhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uFjc9zdtzlZHI5iIBQuktdJn/o7Cl35k+XTFYcIjmym7XrEYI32b54BR1vDWZbJR/F/4khWGe7KVDEfIDW9ywAnES11vpB/f5kyXr28okOrTTt9slT4is6OST7GdA06z9fX+mkTOiujg6oCv65A6D2ltWswg8gL4lZIWKVwlX4s= 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=ZNI3vvZn; arc=none smtp.client-ip=209.85.160.51 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="ZNI3vvZn" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-254a2d8485eso2825438fac.0 for ; Tue, 18 Jun 2024 13:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740975; x=1719345775; 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=HDle5sLaDG156djjYdNfiUQ4KGhnaUyZOKGc/MznpDM=; b=ZNI3vvZnZMxjf78gbgkTJbefdpO3OC1h2sNlV/M/xXxo8nQQ9JuseS+DJPegR2sDw0 U1iP9aMNMjjhfhP6YocF0C6Bj346xc+91WGhSpMYAfxXzbgeYk0sdFvZ7RAZ/Lh0mCMs pZSGLS/NqijLZ21wd4IQay4suVgSbDOwdlGhj6kXmdgV+aXY9zSzkqAtNRgXxZqUzMsA Xx9EekGe+S1qYvo0MKhB8yS/GzS07XLf9QnENclVbt5nh0JC5A0MDhTvSRpf+SSzGUq0 gezadLy4CLPevWwlN45u3PlSPtcmEenGRhzS9j5J1gLwmAqYK20y+2/Fdc0DxA0ZFULv 0mRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740975; x=1719345775; 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=HDle5sLaDG156djjYdNfiUQ4KGhnaUyZOKGc/MznpDM=; b=A2o6IeAlz/0uxiQ15vppE2ZYYieN0U8C53kE1ExZ3lObNDqlHt8i/HO6Ic2E7covHG hzUSNMsVxriAnkOLbMMPfcx9KwbgkoPAJNt+2fRt7N+z5qiT8yNK+ZJ316usa3sagOVu VODXO9X0Ypi5M7Oaqt9tU3HtBNcBQoUApIDjH06rG2RstFcGny58AgS8GbT6gN8n30kf 5qfXSHb4GGycdvQaG9tcmUTYTq+rMG0kH12qRqU/yU9mZ5C0LltRafrlUOQ5ma4yNuAF TKmnTRIs+yGtUvq8128spfa1b3CEC7rB1Z8+h+xTxGxgFuIYBCMQtTqoBc1QmZ6Q8T2c JlDA== X-Gm-Message-State: AOJu0Yyu4pCOhU6dcRi9gGzGPztHMZh8nH92KOiMFS1fR56Cua/lEgYI gtiIGWmKP4jC2UyJqW2nQ/Gs/qEPXDZ2HdlTDV7VO4qGovNvk5gJYWJwiw== X-Google-Smtp-Source: AGHT+IH6F8FpRKEzVEFVUp801iDsjCWTYc1TkufKYRFdjZzgOH7wj/o4wBpJpaKsyLloTKs//ym4Hw== X-Received: by 2002:a05:6871:1ce:b0:24f:e09d:3c83 with SMTP id 586e51a60fabf-25c94cfcea0mr1034594fac.36.1718740975138; Tue, 18 Jun 2024 13:02:55 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:54 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 28/33] qmi: Make qmux methods operate on 'qmi_qmux_device' Date: Tue, 18 Jun 2024 15:02:10 -0500 Message-ID: <20240618200231.1129282-28-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- drivers/qmimodem/qmi.c | 70 ++++++++++++++++++------------------------ drivers/qmimodem/qmi.h | 19 ++++++------ plugins/gobi.c | 2 +- 3 files changed, 40 insertions(+), 51 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 0d67b07fa729..6e66060b1d3c 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -38,6 +38,8 @@ typedef void (*qmi_message_func_t)(uint16_t message, uint16_t length, const void *buffer, void *user_data); +struct qmi_device; + struct discovery { qmi_destroy_func_t destroy; }; @@ -961,13 +963,16 @@ static const struct qmi_service_info *__find_service_info_by_type( return info; } -bool qmi_qmux_device_get_service_version(struct qmi_device *device, +bool qmi_qmux_device_get_service_version(struct qmi_qmux_device *qmux, uint16_t type, uint16_t *major, uint16_t *minor) { const struct qmi_service_info *info; - info = __find_service_info_by_type(device, type); + if (!qmux) + return false; + + info = __find_service_info_by_type(&qmux->super, type); if (!info) return false; @@ -976,12 +981,12 @@ bool qmi_qmux_device_get_service_version(struct qmi_device *device, return true; } -bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type) +bool qmi_qmux_device_has_service(struct qmi_qmux_device *qmux, uint16_t type) { - if (!device) + if (!qmux) return false; - return __find_service_info_by_type(device, type); + return __find_service_info_by_type(&qmux->super, type); } static int qmi_qmux_device_write(struct qmi_device *device, @@ -1328,21 +1333,18 @@ static void qmux_discover_reply_timeout(struct l_timeout *timeout, __qmux_discovery_finished(qmux); } -int qmi_qmux_device_discover(struct qmi_device *device, +int qmi_qmux_device_discover(struct qmi_qmux_device *qmux, qmi_qmux_device_discover_func_t func, void *user_data, qmi_destroy_func_t destroy) { - struct qmi_qmux_device *qmux; struct qmi_request *req; - if (!device) + if (!qmux) return -EINVAL; - qmux = l_container_of(device, struct qmi_qmux_device, super); - DEBUG(&qmux->debug, "device %p", qmux); - if (l_queue_length(device->service_infos) > 0 || qmux->discover.tid) + if (l_queue_length(qmux->super.service_infos) > 0 || qmux->discover.tid) return -EALREADY; req = __control_request_alloc(QMI_CTL_GET_VERSION_INFO, NULL, 0, @@ -1444,14 +1446,15 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length, info.major = data->major; info.minor = data->minor; - family = service_family_create(device, &info, client_id->client); + family = service_family_create(&qmux->super, &info, client_id->client); DEBUG(&qmux->debug, "service family created [client=%d,type=%d]", family->client_id, family->info.service_type); family = service_family_ref(family); hash_id = family_list_create_hash(family->info.service_type, family->client_id); - l_hashmap_insert(device->family_list, L_UINT_TO_PTR(hash_id), family); + l_hashmap_insert(qmux->super.family_list, + L_UINT_TO_PTR(hash_id), family); done: if (family) @@ -1463,32 +1466,29 @@ done: service_family_unref(family); } -bool qmi_qmux_device_create_client(struct qmi_device *device, +bool qmi_qmux_device_create_client(struct qmi_qmux_device *qmux, uint16_t service_type, qmi_qmux_device_create_client_func_t func, void *user_data, qmi_destroy_func_t destroy) { unsigned char client_req[] = { 0x01, 0x01, 0x00, service_type }; const struct qmi_service_info *info; - struct qmi_qmux_device *qmux; struct qmi_request *req; struct qmux_client_create_data *create_data; - if (!device || !func) + if (!qmux || !func) return false; if (service_type == QMI_SERVICE_CONTROL) return false; - info = __find_service_info_by_type(device, service_type); + info = __find_service_info_by_type(&qmux->super, service_type); if (!info) return false; - qmux = l_container_of(device, struct qmi_qmux_device, super); - create_data = l_new(struct qmux_client_create_data, 1); create_data->super.destroy = qmux_client_create_data_free; - create_data->device = device; + create_data->device = &qmux->super; create_data->type = service_type; create_data->major = info->major; create_data->minor = info->minor; @@ -1507,7 +1507,7 @@ bool qmi_qmux_device_create_client(struct qmi_device *device, create_data->timeout = l_timeout_create(8, qmux_client_create_timeout, create_data, NULL); - __qmi_device_discovery_started(device, &create_data->super); + __qmi_device_discovery_started(&qmux->super, &create_data->super); return true; } @@ -1583,18 +1583,14 @@ static void qmux_shutdown_callback(struct l_idle *idle, void *user_data) l_idle_remove(qmux->shutdown.idle); } -int qmi_qmux_device_shutdown(struct qmi_device *device, +int qmi_qmux_device_shutdown(struct qmi_qmux_device *qmux, qmi_qmux_device_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy) { - struct qmi_qmux_device *qmux; - - if (!device) + if (!qmux) return -EINVAL; - qmux = l_container_of(device, struct qmi_qmux_device, super); - if (qmux->shutdown.idle) return -EALREADY; @@ -1618,7 +1614,7 @@ static const struct qmi_device_ops qmux_ops = { .client_release = qmi_qmux_device_client_release, }; -struct qmi_device *qmi_qmux_device_new(const char *device) +struct qmi_qmux_device *qmi_qmux_device_new(const char *device) { struct qmi_qmux_device *qmux; int fd; @@ -1639,19 +1635,16 @@ struct qmi_device *qmi_qmux_device_new(const char *device) qmux->control_queue = l_queue_new(); l_io_set_read_handler(qmux->super.io, received_qmux_data, qmux, NULL); - return &qmux->super; + return qmux; } -void qmi_qmux_device_free(struct qmi_device *device) +void qmi_qmux_device_free(struct qmi_qmux_device *qmux) { - struct qmi_qmux_device *qmux; - - if (!device) + if (!qmux) return; - qmux = l_container_of(device, struct qmi_qmux_device, super); DEBUG(&qmux->debug, "device %p", qmux); - __qmi_device_free(device); + __qmi_device_free(&qmux->super); if (qmux->shutting_down) { qmux->destroyed = true; @@ -1661,15 +1654,12 @@ void qmi_qmux_device_free(struct qmi_device *device) __qmux_device_free(qmux); } -void qmi_qmux_device_set_debug(struct qmi_device *device, +void qmi_qmux_device_set_debug(struct qmi_qmux_device *qmux, qmi_debug_func_t func, void *user_data) { - struct qmi_qmux_device *qmux; - - if (device == NULL) + if (!qmux) return; - qmux = l_container_of(device, struct qmi_qmux_device, super); __debug_data_init(&qmux->debug, func, user_data); } diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 64eebc27c17c..966f99f114fe 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -52,9 +52,8 @@ enum qmi_data_endpoint_type { typedef void (*qmi_destroy_func_t)(void *user_data); -struct qmi_device; -struct qmi_result; struct qmi_service; +struct qmi_result; typedef void (*qmi_debug_func_t)(const char *str, void *user_data); typedef void (*qmi_qmux_device_discover_func_t)(void *user_data); @@ -65,22 +64,22 @@ typedef void (*qmi_qrtr_node_lookup_done_func_t)(void *); typedef void (*qmi_service_result_func_t)(struct qmi_result *, void *); -struct qmi_device *qmi_qmux_device_new(const char *device); -void qmi_qmux_device_free(struct qmi_device *device); -void qmi_qmux_device_set_debug(struct qmi_device *device, +struct qmi_qmux_device *qmi_qmux_device_new(const char *device); +void qmi_qmux_device_free(struct qmi_qmux_device *qmux); +void qmi_qmux_device_set_debug(struct qmi_qmux_device *qmux, qmi_debug_func_t func, void *user_data); -int qmi_qmux_device_discover(struct qmi_device *device, +int qmi_qmux_device_discover(struct qmi_qmux_device *qmux, qmi_qmux_device_discover_func_t func, void *user_data, qmi_destroy_func_t destroy); -bool qmi_qmux_device_create_client(struct qmi_device *device, +bool qmi_qmux_device_create_client(struct qmi_qmux_device *qmux, uint16_t service_type, qmi_qmux_device_create_client_func_t func, void *user_data, qmi_destroy_func_t destroy); -bool qmi_qmux_device_get_service_version(struct qmi_device *device, +bool qmi_qmux_device_get_service_version(struct qmi_qmux_device *qmux, uint16_t type, uint16_t *major, uint16_t *minor); -bool qmi_qmux_device_has_service(struct qmi_device *device, uint16_t type); -int qmi_qmux_device_shutdown(struct qmi_device *device, +bool qmi_qmux_device_has_service(struct qmi_qmux_device *qmux, uint16_t type); +int qmi_qmux_device_shutdown(struct qmi_qmux_device *qmux, qmi_qmux_device_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy); diff --git a/plugins/gobi.c b/plugins/gobi.c index 74df3c360c96..d24b95fffc91 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -61,7 +61,7 @@ struct service_request { }; struct gobi_data { - struct qmi_device *device; + struct qmi_qmux_device *device; struct qmi_service *dms; struct qmi_service *wda; struct qmi_service *nas; From patchwork Tue Jun 18 20:02:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702936 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 DA1DF16DC3A for ; Tue, 18 Jun 2024 20:02:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740978; cv=none; b=XnruwC+uFtDPP9CG/oBA/XCZj+6tyQTyBoFohjrH7z/nqpqkEbyp/eqC7whpZ7VOo5BS4Rv1mZfLtt2uEwWXNZ6SbNq0ar8vVOJH7tOrKDTUO9BKLLuQCNhhE9YFq1E3O8whvNcTRtinbBz4PxFbyRsRfQ9bRU3pOybXvJ0KPxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740978; c=relaxed/simple; bh=U+peojbnu1k6q75LXI5k3vZfdNuC+ooo2jo7B+/NZ08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XEVOwops9myjYbtapSCR+R0/P7I62TtR4hpDMn7Di4ErNiErpwohwbNnUn/VfXMQ29DH2fxD7PI5eWCxJv89HzLAyFS3sM5t2mkO1AMvlh+VOp/2sHpHM89x9kpU8rSVeDOdfAh5VUFgNIGe1+SsqDexaMu+KSuIwfudKnIZmuw= 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=ksBqCIyq; arc=none smtp.client-ip=209.85.160.47 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="ksBqCIyq" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-25c95299166so166091fac.3 for ; Tue, 18 Jun 2024 13:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740976; x=1719345776; 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=9VNQjO4dvYVwxmdLCHVnJaHkQJpsvDJRxhitap70k/I=; b=ksBqCIyqCLq4WyVpuYB+YWM1JleL7iCVbuA1EXbfDaOQGvN3cgJQ39aHxyF2ZgJ7TI vKIRpLjoid0dHYmT6uZBtNiMFt/tdQavA24QwRRrY6Pg9nLdMRYdYECHeNYfVcSxMmS3 zhtieSv2hdmO4O5IZiixHG+x2RSjO4NTNt/TwgGAw7HAJPQuIB+aIN6M6EKXYmoF/hKl l4iltHWhWK2yaYP6zG2bfiW+FXVA1KT7fZLGX3z26+e3uyaoueOxRM+76lWdgUEYgYoo rGFTvnIGD6V8yjOkA5I3578XJgt9Dwt8WDlfIAhen1OaXc34DiouZX8qQREI8qaUTMY+ vqwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740976; x=1719345776; 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=9VNQjO4dvYVwxmdLCHVnJaHkQJpsvDJRxhitap70k/I=; b=FSRx438i4nsFk1KUlcfWzIaUwtH8Y6INeFsTXnTa7Vu3rBTFl9iLpxWCnIxTgwknOv GtSUOMWV8aysK6t1dIDFXYoWBJ4A+NJybG2MWrU+KL+BIwswtjYBGVERVhmHICmOT7jk CNFwAOBYUPL+NtN8QPuXY+qgTC+qg/7nIEUHtqknxs7MEaf/ux9M6k+j4WMJ+3CR1lQb b3FX+Qxf0HSHJVXvvqxWsztJhYRvAKkB7n5SEWfWA4/FCR1YUZ0ThvH2WckWbada+Z6v tdLR4j8qPGkyNkGGA4uJqTD52AydPEWqKD2o0/eaTuReWxqxt5ZB3IbIfVwFslu/mRY/ H5fw== X-Gm-Message-State: AOJu0Yzt+ukmlzgEM9NLzKDcvtRf0IZi3nte88TlWglDzoFvWyDVyKN5 KfaVMFEHmaM0JrXPtKQzXgGKjfxUOkLXuCNROeUOzQYDShRIRez22A/Y5w== X-Google-Smtp-Source: AGHT+IEO7XQDl/2fQ6GUkvlkzdY4ALE9sa4k8IhRRqY8Gkg8Jcg66aEJmjUZLe7iTQr/LEF+P4GRGw== X-Received: by 2002:a05:6870:ec8e:b0:258:7bca:3289 with SMTP id 586e51a60fabf-25c94d6d83amr782799fac.51.1718740975747; Tue, 18 Jun 2024 13:02:55 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:55 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 29/33] qmi: combine service_send_data into qmi_request Date: Tue, 18 Jun 2024 15:02:11 -0500 Message-ID: <20240618200231.1129282-29-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of allocating a separate service_send_data structure for each request, simply extend the qmi_request structure with the needed parameters. This saves an extra memory allocation since service_send_data lifetime was already tied to the qmi_request lifetime. While here, remove __service_request_alloc function. This helper was used in a single location and is unlikely to be used elsewhere. --- drivers/qmimodem/qmi.c | 194 +++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 102 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 6e66060b1d3c..3742e8fc4b73 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -10,6 +10,7 @@ #endif #define _GNU_SOURCE +#include #include #include #include @@ -35,10 +36,11 @@ l_util_debug((debug)->func, (debug)->user_data, "%s:%i " fmt, \ __func__, __LINE__, ## args) -typedef void (*qmi_message_func_t)(uint16_t message, uint16_t length, - const void *buffer, void *user_data); - struct qmi_device; +struct qmi_request; + +typedef void (*response_func_t)(struct qmi_request *, uint16_t message, + uint16_t length, const void *buffer); struct discovery { qmi_destroy_func_t destroy; @@ -59,12 +61,20 @@ struct qmi_request { unsigned int service_handle; /* Always 0 for control */ uint8_t client; /* Always 0 for control and qrtr */ struct qmi_service_info info; /* Not used for control requests */ - qmi_message_func_t callback; void *user_data; + response_func_t callback; + void (*free_request)(struct qmi_request *req); uint16_t len; uint8_t data[]; }; +struct qmi_service_request { + qmi_service_result_func_t func; + void *user_data; + qmi_destroy_func_t destroy; + struct qmi_request super; +}; + struct qmi_device_ops { int (*write)(struct qmi_device *device, struct qmi_request *req); void (*client_release)(struct qmi_device *device, @@ -215,12 +225,12 @@ static void __qmi_service_appeared(struct qmi_device *device, l_memdup(info, sizeof(struct qmi_service_info))); } -static struct qmi_request *__request_alloc(uint32_t service_type, - uint8_t client, uint16_t message, - const void *data, - uint16_t length, qmi_message_func_t func, - void *user_data) +static void *__request_alloc(uint32_t service_type, + uint8_t client, uint16_t message, + const void *data, uint16_t length, + size_t offset) { + void *mem; struct qmi_request *req; struct qmi_mux_hdr *hdr; struct qmi_message_hdr *msg; @@ -233,10 +243,9 @@ static struct qmi_request *__request_alloc(uint32_t service_type, hdrlen += QMI_SERVICE_HDR_SIZE; msglen = hdrlen + QMI_MESSAGE_HDR_SIZE + length; - req = l_malloc(sizeof(struct qmi_request) + msglen); - req->tid = 0; - req->group_id = 0; - req->service_handle = 0; + mem = l_malloc(offset + sizeof(struct qmi_request) + msglen); + req = mem + offset; + memset(req, 0, sizeof(struct qmi_request)); req->len = msglen; req->client = client; @@ -256,40 +265,24 @@ static struct qmi_request *__request_alloc(uint32_t service_type, if (data && length > 0) memcpy(req->data + hdrlen + QMI_MESSAGE_HDR_SIZE, data, length); - req->callback = func; - req->user_data = user_data; - - return req; + return mem; } static struct qmi_request *__control_request_alloc(uint16_t message, - const void *data, uint16_t length, - qmi_message_func_t func, void *user_data) + const void *data, uint16_t length) { return __request_alloc(QMI_SERVICE_CONTROL, 0x00, message, - data, length, func, user_data); -} - -static struct qmi_request *__service_request_alloc( - struct qmi_service_info *info, - uint8_t client, uint16_t message, - const void *data, uint16_t length, - qmi_message_func_t func, void *user_data) -{ - struct qmi_request *req; - - req = __request_alloc(info->service_type, client, message, - data, length, func, user_data); - memcpy(&req->info, info, sizeof(req->info)); - - return req; + data, length, 0); } static void __request_free(void *data) { struct qmi_request *req = data; - l_free(req); + if (req->free_request) + req->free_request(req); + else + l_free(req); } static bool __request_compare(const void *a, const void *b) @@ -817,7 +810,7 @@ static void __rx_message(struct qmi_device *device, return; if (req->callback) - req->callback(message, length, data, req->user_data); + req->callback(req, message, length, data); __request_free(req); } @@ -1047,7 +1040,7 @@ static void __rx_ctl_message(struct qmi_qmux_device *qmux, return; if (req->callback) - req->callback(message, length, data, req->user_data); + req->callback(req, message, length, data); __request_free(req); } @@ -1144,7 +1137,8 @@ done: } static uint8_t __ctl_request_submit(struct qmi_qmux_device *qmux, - struct qmi_request *req) + struct qmi_request *req, + response_func_t callback) { struct qmi_control_hdr *hdr = (struct qmi_control_hdr *) &req->data[QMI_MUX_HDR_SIZE]; @@ -1156,6 +1150,7 @@ static uint8_t __ctl_request_submit(struct qmi_qmux_device *qmux, qmux->next_control_tid = 1; req->tid = hdr->transaction; + req->callback = callback; l_queue_push_tail(qmux->super.req_queue, req); wakeup_writer(&qmux->super); @@ -1227,18 +1222,18 @@ static void __qmux_discovery_finished(struct qmi_qmux_device *qmux) memset(&qmux->discover, 0, sizeof(qmux->discover)); } -static void qmux_sync_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) +static void qmux_sync_callback(struct qmi_request *req, uint16_t message, + uint16_t length, const void *buffer) { - struct qmi_qmux_device *qmux = user_data; + struct qmi_qmux_device *qmux = req->user_data; __qmux_discovery_finished(qmux); } -static void qmux_discover_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) +static void qmux_discover_callback(struct qmi_request *req, uint16_t message, + uint16_t length, const void *buffer) { - struct qmi_qmux_device *qmux = user_data; + struct qmi_qmux_device *qmux = req->user_data; struct qmi_device *device = &qmux->super; const struct qmi_result_code *result_code; const struct qmi_service_list *service_list; @@ -1306,11 +1301,14 @@ done: if ((qmux->control_major == 1 && qmux->control_minor >= 5) || qmux->control_major > 1) { struct qmi_request *req = - __control_request_alloc(QMI_CTL_SYNC, NULL, 0, - qmux_sync_callback, qmux); + __control_request_alloc(QMI_CTL_SYNC, NULL, 0); + + req->user_data = qmux; DEBUG(&qmux->debug, "Sending sync to reset QMI"); - qmux->discover.tid = __ctl_request_submit(qmux, req); + qmux->discover.tid = __ctl_request_submit(qmux, req, + qmux_sync_callback); + return; } @@ -1347,13 +1345,14 @@ int qmi_qmux_device_discover(struct qmi_qmux_device *qmux, if (l_queue_length(qmux->super.service_infos) > 0 || qmux->discover.tid) return -EALREADY; - req = __control_request_alloc(QMI_CTL_GET_VERSION_INFO, NULL, 0, - qmux_discover_callback, qmux); + req = __control_request_alloc(QMI_CTL_GET_VERSION_INFO, NULL, 0); + req->user_data = qmux; qmux->discover.func = func; qmux->discover.user_data = user_data; qmux->discover.destroy = destroy; - qmux->discover.tid = __ctl_request_submit(qmux, req); + qmux->discover.tid = __ctl_request_submit(qmux, req, + qmux_discover_callback); qmux->discover.timeout = l_timeout_create(DISCOVER_TIMEOUT, qmux_discover_reply_timeout, qmux, NULL); @@ -1409,10 +1408,11 @@ static void qmux_client_create_timeout(struct l_timeout *timeout, DISCOVERY_DONE(data, NULL, data->user_data); } -static void qmux_client_create_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) +static void qmux_client_create_callback(struct qmi_request *req, + uint16_t message, uint16_t length, + const void *buffer) { - struct qmux_client_create_data *data = user_data; + struct qmux_client_create_data *data = req->user_data; struct qmi_device *device = data->device; struct qmi_qmux_device *qmux = l_container_of(device, struct qmi_qmux_device, super); @@ -1499,11 +1499,11 @@ bool qmi_qmux_device_create_client(struct qmi_qmux_device *qmux, DEBUG(&qmux->debug, "creating client [type=%d]", service_type); req = __control_request_alloc(QMI_CTL_GET_CLIENT_ID, - client_req, sizeof(client_req), - qmux_client_create_callback, - create_data); + client_req, sizeof(client_req)); + req->user_data = create_data; - create_data->tid = __ctl_request_submit(qmux, req); + create_data->tid = __ctl_request_submit(qmux, req, + qmux_client_create_callback); create_data->timeout = l_timeout_create(8, qmux_client_create_timeout, create_data, NULL); @@ -1511,10 +1511,11 @@ bool qmi_qmux_device_create_client(struct qmi_qmux_device *qmux, return true; } -static void qmux_client_release_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) +static void qmux_client_release_callback(struct qmi_request *req, + uint16_t message, uint16_t length, + const void *buffer) { - struct qmi_qmux_device *qmux = user_data; + struct qmi_qmux_device *qmux = req->user_data; qmux->shutdown.release_users--; } @@ -1531,10 +1532,10 @@ static void qmi_qmux_device_client_release(struct qmi_device *device, qmux->shutdown.release_users++; req = __control_request_alloc(QMI_CTL_RELEASE_CLIENT_ID, - release_req, sizeof(release_req), - qmux_client_release_callback, qmux); + release_req, sizeof(release_req)); + req->user_data = qmux; - __ctl_request_submit(qmux, req); + __ctl_request_submit(qmux, req, qmux_client_release_callback); } static void __qmux_device_free(struct qmi_qmux_device *qmux) @@ -2322,24 +2323,22 @@ bool qmi_service_get_version(struct qmi_service *service, uint8_t *out_version) return true; } -struct service_send_data { - qmi_service_result_func_t func; - void *user_data; - qmi_destroy_func_t destroy; -}; - -static void service_send_free(struct service_send_data *data) +static void qmi_service_request_free(struct qmi_request *req) { - if (data->destroy) - data->destroy(data->user_data); + struct qmi_service_request *sreq = l_container_of(req, + struct qmi_service_request, super); - l_free(data); + if (sreq->destroy) + sreq->destroy(sreq->user_data); + + l_free(sreq); } -static void service_send_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) +static void service_send_callback(struct qmi_request *req, uint16_t message, + uint16_t length, const void *buffer) { - struct service_send_data *data = user_data; + struct qmi_service_request *sreq = l_container_of(req, + struct qmi_service_request, super); const struct qmi_result_code *result_code; uint16_t len; struct qmi_result result; @@ -2359,10 +2358,8 @@ static void service_send_callback(uint16_t message, uint16_t length, result.error = L_LE16_TO_CPU(result_code->error); done: - if (data->func) - data->func(&result, data->user_data); - - service_send_free(data); + if (sreq->func) + sreq->func(&result, sreq->user_data); } uint16_t qmi_service_send(struct qmi_service *service, @@ -2372,15 +2369,13 @@ uint16_t qmi_service_send(struct qmi_service *service, { struct qmi_device *device; struct service_family *family; - struct service_send_data *data; - struct qmi_request *req; - uint16_t tid; + struct qmi_service_request *sreq; + struct qmi_service_info *info; if (!service) return 0; family = service->family; - if (!family->group_id) return 0; @@ -2388,23 +2383,21 @@ uint16_t qmi_service_send(struct qmi_service *service, if (!device) return 0; - data = l_new(struct service_send_data, 1); - - data->func = func; - data->user_data = user_data; - data->destroy = destroy; - - req = __service_request_alloc(&family->info, - family->client_id, message, - param ? param->data : NULL, - param ? param->length : 0, - service_send_callback, data); - + info = &family->info; + sreq = __request_alloc(info->service_type, family->client_id, message, + param ? param->data : NULL, + param ? param->length : 0, + offsetof(struct qmi_service_request, super)); qmi_param_free(param); - tid = __service_request_submit(device, service, req); + memcpy(&sreq->super.info, info, sizeof(*info)); + sreq->super.callback = service_send_callback; + sreq->super.free_request = qmi_service_request_free; + sreq->func = func; + sreq->user_data = user_data; + sreq->destroy = destroy; - return tid; + return __service_request_submit(device, service, &sreq->super); } bool qmi_service_cancel(struct qmi_service *service, uint16_t id) @@ -2435,8 +2428,6 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id) return false; } - service_send_free(req->user_data); - __request_free(req); return true; @@ -2450,7 +2441,6 @@ static bool remove_req_if_match(void *data, void *user_data) if (req->service_handle != service_handle) return false; - service_send_free(req->user_data); __request_free(req); return true; From patchwork Tue Jun 18 20:02:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702937 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 96B0916DC3C for ; Tue, 18 Jun 2024 20:02:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740979; cv=none; b=OAlpCUoNzof3LAO50BtNwmwz2wEaTtQR6DFDaecIR6n0awtudXF8cokMu+gYrWXCdQJAEXY1d9TqgSAu+vXf6avtNQ2oI+F+PBcd8n9KVqn/usZe3zP9wRwnfE51OcPiY8EP1osHVPbkwA4Zss+uCv/QYbpvRF4sb9SpQ3TNEi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740979; c=relaxed/simple; bh=ct6NBoejunpbdL+Y28R2VpykRFG30hZW+BMxLKieUbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X/gH3iewnUElKw9iHRHEqY8fJGlv6KsQQDFsU3E9XpDXcxvYltVrL/koStTcTUaOnTFLtEPdFOqH68yu8vGeSrp4ssvIOcK+yGr0BOm2t4Pf86KOuSBmUYaKUDPbkvLLo1wMt/B3Z61lbit8BTTVndseFzXwDXw/dJ7q3SlYX18= 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=VeQZeex4; arc=none smtp.client-ip=209.85.161.49 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="VeQZeex4" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-5b9794dad09so2696168eaf.3 for ; Tue, 18 Jun 2024 13:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740976; x=1719345776; 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=BHhgRNI//pbHnUOtJhh2c15VzZvNnAL1vsZ9a8EnmmA=; b=VeQZeex4ZX8M0GhQBLvoDpVS0mXGAiGLZpIqIzXvHaaIfwCgHSXOGKVkupFCjZw0NY xFqSbXftmsPeZ4ep1RMp2w9WHWsCpOu9VxGxRcip0fVD9xbk9jnpxu9cCE1mBEh38by4 wdeS/ZroeYoHghMtvPzSvanVS+jjJVJnRMhiKxI39cd+sAshHwpfQE5rSUra4Pa5L7KR 9/9/X3XXaOb7LPEh8a1WmIKgu1AaXs3WvirvVJhp8KJUROn9bQvGmPHEmXmcf+yPUfUn khxiFQa5hSiSUeWgGE8Ywlshxzt9UNCO7iFd1Ug5fFer/0jlTj+JaxKPR/jRw4h70j4q wnOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740976; x=1719345776; 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=BHhgRNI//pbHnUOtJhh2c15VzZvNnAL1vsZ9a8EnmmA=; b=tY8cC6U+Cu7B9G8egW/5dZoCb2327HVURWEq2RyJBFDoQgK5xiKGL0orA6BuAza48F DHwMJswjeGt4+cVixjLPI0FC5JqM6h1OK3HkXw4JL7vZVUQn8r8ikcpH20l5pqSbvsog pzM41EJvQWwU7frWwIvjV4x019kGkBS7QSgYVSF1rCT3SJARg8miXxPe/tEbTLTWW7uw QhWe5qyqfrwPCIgVekiRJg6B/8o5X1gGghgWfRUORjA4UOYtS+hLnz8+N2tPPToACE9s wNRl5EDuYRkwn28Lfaq8lVi+Saq3oDC789MHamZClm6BdpagEy/7WKUPbFhCLnCMohi/ iyuQ== X-Gm-Message-State: AOJu0Yx2gcFuwvLnjlWLtZUAp9x1E1LIeVDUWMzHKvcg2DpRNki/TH0+ SjkMn2oGzdmeaXagODZgZj2ScZtAXR0pC4rFKdESZeJZbtGobhsr152YHA== X-Google-Smtp-Source: AGHT+IFOLfbzQskesuDVQswnYWrSwJa3ZgXF0Y7QnkFzkruEjcjMeT4+LaJ5yoDEakq32mZrZpIETQ== X-Received: by 2002:a05:6870:c10c:b0:254:7936:e1df with SMTP id 586e51a60fabf-25c949b0885mr1066414fac.22.1718740976493; Tue, 18 Jun 2024 13:02:56 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:56 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 30/33] qmi: combine qmux_client_create_data into qmi_request Date: Tue, 18 Jun 2024 15:02:12 -0500 Message-ID: <20240618200231.1129282-30-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similarly to the previous commit, do not allocate a separate data structure to hold client creation details, and instead allocate it as a qmi_request specialization. Since the lifetime of struct qmux_client_create_data was already tied to the lifetime of the request (and vice-versa), this change allows the extra allocation to be optimized away. While here, remove all vestiges of discovery and discovery_queue. This functionality is no longer needed since any data associated with the request will be freed when struct qmi_request is freed. --- drivers/qmimodem/qmi.c | 153 ++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 102 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 3742e8fc4b73..e3a8b225140f 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -42,10 +42,6 @@ struct qmi_request; typedef void (*response_func_t)(struct qmi_request *, uint16_t message, uint16_t length, const void *buffer); -struct discovery { - qmi_destroy_func_t destroy; -}; - struct qmi_service_info { uint32_t service_type; uint32_t qrtr_port; /* Always 0 on qmux */ @@ -90,7 +86,6 @@ struct qmi_device { struct l_io *io; struct l_queue *req_queue; struct l_queue *service_queue; - struct l_queue *discovery_queue; unsigned int next_group_id; /* Matches requests with services */ unsigned int next_service_handle; uint16_t next_service_tid; @@ -268,11 +263,12 @@ static void *__request_alloc(uint32_t service_type, return mem; } -static struct qmi_request *__control_request_alloc(uint16_t message, - const void *data, uint16_t length) +static void *__control_request_alloc(uint16_t message, + const void *data, uint16_t length, + size_t offset) { return __request_alloc(QMI_SERVICE_CONTROL, 0x00, message, - data, length, 0); + data, length, offset); } static void __request_free(void *data) @@ -293,14 +289,6 @@ static bool __request_compare(const void *a, const void *b) return req->tid == tid; } -static void __discovery_free(void *data) -{ - struct discovery *d = data; - qmi_destroy_func_t destroy = d->destroy; - - destroy(d); -} - static void __notify_free(void *data) { struct qmi_notify *notify = data; @@ -815,33 +803,6 @@ static void __rx_message(struct qmi_device *device, __request_free(req); } -static void __qmi_device_discovery_started(struct qmi_device *device, - struct discovery *d) -{ - l_queue_push_tail(device->discovery_queue, d); -} - -static void __qmi_device_discovery_complete(struct qmi_device *device, - struct discovery *d) -{ - if (!l_queue_remove(device->discovery_queue, d)) - return; -} - -/* - * Prevents re-entrancy problems by removing the entry from the discovery_queue - * before calling the callback. - */ -#define DISCOVERY_DONE(data, ...)\ -do {\ - __qmi_device_discovery_complete(data->device, &data->super);\ -\ - if (data->func)\ - data->func(__VA_ARGS__);\ -\ - __discovery_free(&data->super);\ -} while (0) - static void family_destroy(void *data) { struct service_family *family = data; @@ -873,7 +834,6 @@ static int qmi_device_init(struct qmi_device *device, int fd, device->req_queue = l_queue_new(); device->service_queue = l_queue_new(); - device->discovery_queue = l_queue_new(); device->service_infos = l_queue_new(); device->family_list = l_hashmap_new(); @@ -888,7 +848,6 @@ static void __qmi_device_free(struct qmi_device *device) { l_queue_destroy(device->service_queue, __request_free); l_queue_destroy(device->req_queue, __request_free); - l_queue_destroy(device->discovery_queue, __discovery_free); l_io_destroy(device->io); @@ -1301,7 +1260,7 @@ done: if ((qmux->control_major == 1 && qmux->control_minor >= 5) || qmux->control_major > 1) { struct qmi_request *req = - __control_request_alloc(QMI_CTL_SYNC, NULL, 0); + __control_request_alloc(QMI_CTL_SYNC, NULL, 0, 0); req->user_data = qmux; @@ -1345,7 +1304,7 @@ int qmi_qmux_device_discover(struct qmi_qmux_device *qmux, if (l_queue_length(qmux->super.service_infos) > 0 || qmux->discover.tid) return -EALREADY; - req = __control_request_alloc(QMI_CTL_GET_VERSION_INFO, NULL, 0); + req = __control_request_alloc(QMI_CTL_GET_VERSION_INFO, NULL, 0, 0); req->user_data = qmux; qmux->discover.func = func; @@ -1360,9 +1319,8 @@ int qmi_qmux_device_discover(struct qmi_qmux_device *qmux, return 0; } -struct qmux_client_create_data { - struct discovery super; - struct qmi_device *device; +struct qmux_create_client_request { + struct qmi_qmux_device *qmux; uint8_t type; uint16_t major; uint16_t minor; @@ -1370,52 +1328,46 @@ struct qmux_client_create_data { void *user_data; qmi_destroy_func_t destroy; struct l_timeout *timeout; - uint16_t tid; + struct qmi_request super; }; -static void qmux_client_create_data_free(void *user_data) +static void qmux_create_client_request_free(struct qmi_request *r) { - struct qmux_client_create_data *data = user_data; + struct qmux_create_client_request *req = + l_container_of(r, struct qmux_create_client_request, super); - if (data->timeout) - l_timeout_remove(data->timeout); + if (req->timeout) + l_timeout_remove(req->timeout); - if (data->destroy) - data->destroy(data->user_data); + if (req->destroy) + req->destroy(req->user_data); - l_free(data); + l_free(req); } -static void qmux_client_create_timeout(struct l_timeout *timeout, +static void qmux_create_client_timeout(struct l_timeout *timeout, void *user_data) { - struct qmux_client_create_data *data = user_data; - struct qmi_device *device = data->device; - struct qmi_qmux_device *qmux = - l_container_of(device, struct qmi_qmux_device, super); - struct qmi_request *req; + struct qmux_create_client_request *req = user_data; + struct qmi_qmux_device *qmux = req->qmux; DEBUG(&qmux->debug, ""); - l_timeout_remove(data->timeout); - data->timeout = NULL; + l_timeout_remove(req->timeout); + req->timeout = NULL; /* remove request from queues */ - req = find_control_request(qmux, data->tid); - if (req) - __request_free(req); - - DISCOVERY_DONE(data, NULL, data->user_data); + find_control_request(qmux, req->super.tid); + __request_free(&req->super); } -static void qmux_client_create_callback(struct qmi_request *req, +static void qmux_create_client_callback(struct qmi_request *r, uint16_t message, uint16_t length, const void *buffer) { - struct qmux_client_create_data *data = req->user_data; - struct qmi_device *device = data->device; - struct qmi_qmux_device *qmux = - l_container_of(device, struct qmi_qmux_device, super); + struct qmux_create_client_request *req = + l_container_of(r, struct qmux_create_client_request, super); + struct qmi_qmux_device *qmux = req->qmux; struct service_family *family = NULL; struct qmi_service *service = NULL; struct qmi_service_info info; @@ -1438,13 +1390,13 @@ static void qmux_client_create_callback(struct qmi_request *req, if (len != QMI_CLIENT_ID_SIZE) goto done; - if (client_id->service != data->type) + if (client_id->service != req->type) goto done; memset(&info, 0, sizeof(family->info)); - info.service_type = data->type; - info.major = data->major; - info.minor = data->minor; + info.service_type = req->type; + info.major = req->major; + info.minor = req->minor; family = service_family_create(&qmux->super, &info, client_id->client); DEBUG(&qmux->debug, "service family created [client=%d,type=%d]", @@ -1460,7 +1412,8 @@ done: if (family) service = service_create(family); - DISCOVERY_DONE(data, service, data->user_data); + if (req->func) + req->func(service, req->user_data); if (family) service_family_unref(family); @@ -1473,8 +1426,7 @@ bool qmi_qmux_device_create_client(struct qmi_qmux_device *qmux, { unsigned char client_req[] = { 0x01, 0x01, 0x00, service_type }; const struct qmi_service_info *info; - struct qmi_request *req; - struct qmux_client_create_data *create_data; + struct qmux_create_client_request *req; if (!qmux || !func) return false; @@ -1486,28 +1438,25 @@ bool qmi_qmux_device_create_client(struct qmi_qmux_device *qmux, if (!info) return false; - create_data = l_new(struct qmux_client_create_data, 1); - create_data->super.destroy = qmux_client_create_data_free; - create_data->device = &qmux->super; - create_data->type = service_type; - create_data->major = info->major; - create_data->minor = info->minor; - create_data->func = func; - create_data->user_data = user_data; - create_data->destroy = destroy; - DEBUG(&qmux->debug, "creating client [type=%d]", service_type); req = __control_request_alloc(QMI_CTL_GET_CLIENT_ID, - client_req, sizeof(client_req)); - req->user_data = create_data; - - create_data->tid = __ctl_request_submit(qmux, req, - qmux_client_create_callback); - create_data->timeout = l_timeout_create(8, qmux_client_create_timeout, - create_data, NULL); + client_req, sizeof(client_req), + offsetof(struct qmux_create_client_request, + super)); + req->super.free_request = qmux_create_client_request_free; + req->qmux = qmux; + req->type = service_type; + req->major = info->major; + req->minor = info->minor; + req->func = func; + req->user_data = user_data; + req->destroy = destroy; + req->timeout = l_timeout_create(8, qmux_create_client_timeout, + req, NULL); + + __ctl_request_submit(qmux, &req->super, qmux_create_client_callback); - __qmi_device_discovery_started(&qmux->super, &create_data->super); return true; } @@ -1532,7 +1481,7 @@ static void qmi_qmux_device_client_release(struct qmi_device *device, qmux->shutdown.release_users++; req = __control_request_alloc(QMI_CTL_RELEASE_CLIENT_ID, - release_req, sizeof(release_req)); + release_req, sizeof(release_req), 0); req->user_data = qmux; __ctl_request_submit(qmux, req, qmux_client_release_callback); From patchwork Tue Jun 18 20:02:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702938 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 27B6516DED1 for ; Tue, 18 Jun 2024 20:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740979; cv=none; b=e1PMibJEdDsM2G+Pr6L0xjTDVT4vMRtV9tgxsi8g4SEUWbuIzPK/YbqtG07CGw5bp9Y4WIjrokHWutLSi4dm6fIVnXoVvOdLr7CjlmYw5aLdD64xDjM7XaWRzwF4CckAjcjpOhrixORwqSGkgE1Juy4ET0zkdfSJMF59+/5sSO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740979; c=relaxed/simple; bh=yCASfTUa+mVbFQpxIgvKw6xLhMDlWjmwUkHHvr0CTFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PsI1vmmGNACF46Tt5DKxM0nzdS/2tOHzuaF2+6KsrYBwCoW9+0ZWixCBHw/e+2uWbjoM2SJWPCZzPOjhFF431XYKs1cdY3u1LULk26Yi6H1y1D4yKbFOP7WYwMZthCOtLmCZ/tR1h5imNn2a0KkqlX+yqdvNC/7aQdlkN6LWNGc= 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=Sc7O6FYu; arc=none smtp.client-ip=209.85.160.43 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="Sc7O6FYu" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-254a7fe21aeso92453fac.0 for ; Tue, 18 Jun 2024 13:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740977; x=1719345777; 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=3wIy4qRUI1gV6a2AuRMXprV+NjXE4khA/yj+e1Qp8qQ=; b=Sc7O6FYuCnj9QdcbWVQeNwoiTrMXDbMRwR/RhoQ6lfDPXbjYQldRP8vyyaNqULPoAx 3evgrKKMbpMeIR3aK7t0ZRNA2isD7Y34jVA8uqk77dpV8GFhi0FIt1xaVuG0pjUvq4mN SmSgJstlPBQbLKsccsChWCjQ3Mqpj4Lzx2V2H39lP46w8tZWZRD6TVtmKp3/FjjFd+H7 iOM8qZ2cPojqm5OVpzMCDXf4HBCnPu4BYAb+gqx4Gptqg4Xcre89xCEFjLmjel15JJ2Z vPtWQ5pnGGWVzHJpTqcI7AQXONGe9mVXFOxoqk7bLp0tgg6jSDjQ9oQD8J7oKIiOdKeh FH1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740977; x=1719345777; 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=3wIy4qRUI1gV6a2AuRMXprV+NjXE4khA/yj+e1Qp8qQ=; b=WjfbynY41q57m5eueeYx1HajZjjWrTSvvAfoGL809RxLdmmVEUDaO02C9DedKpPzge WeXzD3hYfUnMPvz8XLwAbDKesdcQY6YtH7ofKL8siCWjAH+U9hY3DRYqLJVu7fZVtkKA v5DdATtMTcf6zxmPMfY67+NeBo2jwpWAe6YlGtEoZ7dige+Eolz/4aYJzUiiOcBJ6VPc yrADb4Kusd85uzDJ5N5bOsiAk4IEsqISzHvpia0BYIKuB8yipMuPa+pi2tEOBtghdZcm rbccyV4j0kBYUeiVWdaZ7Ubb62BHWS7tqFsBEmQkyZP0SExjuFBs/f9uLNhrl6SpmfZk OTQg== X-Gm-Message-State: AOJu0YwcUfZCIeb26xE5C9qpXH27JLxuBM+OxV8Z3qQGIVmGjFUYMwwg zYkbsD7C5RVce2vjU8JvnuR9Sosje9VWQKxov2J/KVYopRevAWv367vwAg== X-Google-Smtp-Source: AGHT+IFGXEmrGTigwVEaFla9iEq5iGAdZRVidCKNrtejqSJcoqEkGDFzEke0QBCHUDJ3Gpl9Q+XQLA== X-Received: by 2002:a05:6870:f14e:b0:259:7767:3767 with SMTP id 586e51a60fabf-259776737edmr1378362fac.8.1718740977161; Tue, 18 Jun 2024 13:02:57 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:56 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 31/33] gprs: Fix memory leak Date: Tue, 18 Jun 2024 15:02:13 -0500 Message-ID: <20240618200231.1129282-31-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As reported by lsan: ==1120532==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x761c0dadf359 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x9ae9b9 in l_malloc ell/util.c:49 #2 0x9f41a7 in l_uintset_new_from_range ell/uintset.c:181 #3 0x8e486f in ofono_gprs_set_cid_range src/gprs.c:2669 #4 0x55b8d0 in get_default_profile_number_cb drivers/qmimodem/gprs.c:399 #5 0x52f822 in service_send_callback drivers/qmimodem/qmi.c:2311 #6 0x51f461 in __rx_message drivers/qmimodem/qmi.c:801 #7 0x521d22 in received_qmux_data drivers/qmimodem/qmi.c:1052 #8 0x9da348 in io_callback ell/io.c:105 #9 0x9d5077 in l_main_iterate ell/main.c:461 #10 0x7811df in event_check src/main.c:182 #11 0x761c0e1260ed (/usr/lib/libglib-2.0.so.0+0x5b0ed) (BuildId: e717410de6953d0e1e85882d796204ca2675f1d4) #12 0x7ffe00000000 () Indirect leak of 8 byte(s) in 1 object(s) allocated from: #0 0x761c0dadf359 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x9ae9b9 in l_malloc ell/util.c:49 #2 0x9f4211 in l_uintset_new_from_range ell/uintset.c:182 #3 0x8e486f in ofono_gprs_set_cid_range src/gprs.c:2669 #4 0x55b8d0 in get_default_profile_number_cb drivers/qmimodem/gprs.c:399 #5 0x52f822 in service_send_callback drivers/qmimodem/qmi.c:2311 #6 0x51f461 in __rx_message drivers/qmimodem/qmi.c:801 #7 0x521d22 in received_qmux_data drivers/qmimodem/qmi.c:1052 #8 0x9da348 in io_callback ell/io.c:105 #9 0x9d5077 in l_main_iterate ell/main.c:461 #10 0x7811df in event_check src/main.c:182 #11 0x761c0e1260ed (/usr/lib/libglib-2.0.so.0+0x5b0ed) (BuildId: e717410de6953d0e1e85882d796204ca2675f1d4) #12 0x7ffe00000000 () The cid range can be set by the driver at any time. If the gprs atom is removed prior to being registered, the memory is not freed. Fix that by moving uintset deallocation to the remove method. --- src/gprs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gprs.c b/src/gprs.c index 57b823b0f1c6..97d6f382e87d 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -3014,9 +3014,6 @@ static void gprs_unregister(struct ofono_atom *atom) free_contexts(gprs); - l_uintset_free(gprs->used_cids); - gprs->used_cids = NULL; - if (gprs->netreg_watch) { if (gprs->status_watch) { __ofono_netreg_remove_status_watch(gprs->netreg, @@ -3055,6 +3052,9 @@ static void gprs_remove(struct ofono_atom *atom) if (gprs->suspend_timeout) g_source_remove(gprs->suspend_timeout); + l_uintset_free(gprs->used_cids); + gprs->used_cids = NULL; + l_uintset_free(gprs->used_pids); gprs->used_pids = NULL; From patchwork Tue Jun 18 20:02:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702939 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (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 B50DF16EB4E for ; Tue, 18 Jun 2024 20:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740980; cv=none; b=QtGC1zCPsBRi1/XHMEHhvL61B+9Zg7Jgm5LyQn/OPrEogWcb8pAJMLaPKvf0jTRNJ9kRbgR+tuh3giWU0rmFz3lHaJUb71gH3XeG+dFb1e1URmpTAodGHZSS/DR1GF20yEPxCzHc9qyTnfenw4DC+5ifWfur/Hlg7vkrmZW05qg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740980; c=relaxed/simple; bh=PHRFImjLI9jAlflntOrvaWQbxtJQhUwxaPki5M0DYgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LnU4shtnGueNQBWLVRZ3YUhw5FRkQkqok3asuD1cniR+6Ah/fc21UziZYAMBQKY7rvXDb9TSFLuKhoc57KscGibTgSMCR5LmxvZlLrecFnd2pbDJnFgVFKWohXwwKpsWQHkHD45j/1hhsxUbKCKnd/khVo/iMnvZd1zqOrkWrfE= 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=VCUX3VC7; arc=none smtp.client-ip=209.85.160.41 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="VCUX3VC7" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-2547e1c7bbeso3080990fac.2 for ; Tue, 18 Jun 2024 13:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740978; x=1719345778; 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=g0aurGGIaUBvp/K0HPX3fLYIhmruLRueL24gkxt4kTA=; b=VCUX3VC78tw2pyeBAiJ4nxMicIQPZ//ktl9rNvKndZ8VebIZT97+yAUDn3zTqFH0B/ rL1jwR4Dd1EHoaUQvWrtoiCeOjsM1GPPV2JT5i+/mYMyCX3Ew1IFgKlT/KUuXROA9iXw +V2FER1q4siGX3dsCrMY5LA+9vGHILtmQVT6wWX8Ne3uXmFj2/QTPvflGxnrMVqOU/Df mL1jF0XDDR4HPfPjDEH1tdNKyBbPQjskgUjD1tHS8/1ditFR/A3/YJCgY5E5hR6QX88D +15uBJmeV/o0T/LmfNwBNsbjIGveXYMBShZCcpOJquhDYQ6C4wfiA1Trtjl+BDMUre2l Q6qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740978; x=1719345778; 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=g0aurGGIaUBvp/K0HPX3fLYIhmruLRueL24gkxt4kTA=; b=DvxoXnwkvl/a9UJeU32bMXz67BTcRrIMapW4/pIkU+9rdSq0TlWAlwP17wdyTidAqp TiHj/Hfr1mM5urSUxzjDgi6aY4irArVXz0PEYDOKtGAHECZIO+g6DfXxsDnGaGLioeHq XiqDCQKO1fXfuLmynCHVp5VzhVzQ7d+Usv+KgDlXz0+w97Ng3FUfl3w295s6KpkyiLDT eAhDBEp4jqVE1YtyWkl3IOGKwpFUD57DlOE4awOslFRaWtkU79J6A5ga5gf9TKnncuUP q0twz7Vdx8nWyluP2kh4dwi3FzhKLMVnZb1+ew8XTvTSTaboGdTsR/zmqwjjy6NAemw8 dYyA== X-Gm-Message-State: AOJu0YySUU/BpGiRZzOVEyHn9Znrb1WSu5Pu6camz+90G0+v7QEoXk+9 I3lcjKW53nJBy/ip07djW/bKzh1mBMsOSQAbOKBZKa5dzaUCAb7W9TgIrg== X-Google-Smtp-Source: AGHT+IERBhETjElw98muddGtAMw6vTzKtZpFAKUh4Nc/tLF5oAgMB9kGsZaijxCkgLP8by7+KO9Rrw== X-Received: by 2002:a05:6871:5c9:b0:254:6e4e:23d7 with SMTP id 586e51a60fabf-25c94d722a6mr926966fac.50.1718740977731; Tue, 18 Jun 2024 13:02:57 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:57 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 32/33] qmi:gprs: Don't fail on unsupported INDICATION_REGISTER Date: Tue, 18 Jun 2024 15:02:14 -0500 Message-ID: <20240618200231.1129282-32-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some modems (like Sierra MC7710) seemingly do not support INDICATION_REGISTER request on WDS. Do not fail gprs atom registration if so. Only indications of interest are currently used only for informational output to syslog. ofonod[1120532]: drivers/qmimodem/gprs.c:set_event_report_cb() ofonod[1120532]: drivers/qmimodem/lte.c:modify_profile_cb() ofonod[1120532]: drivers/qmimodem/gprs.c:indication_register_cb() ofonod[1120532]: indication_register_cb: 71 ofonod[1120532]: src/gprs.c:gprs_remove() atom: 0x504000022a90 ofonod[1120532]: drivers/qmimodem/gprs.c:qmi_gprs_remove() --- drivers/qmimodem/gprs.c | 8 ++++++-- drivers/qmimodem/qmi.h | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/qmimodem/gprs.c b/drivers/qmimodem/gprs.c index da7ad63c49cb..51aa722a89c1 100644 --- a/drivers/qmimodem/gprs.c +++ b/drivers/qmimodem/gprs.c @@ -279,8 +279,12 @@ static void indication_register_cb(struct qmi_result *result, void *user_data) DBG(""); if (qmi_result_set_error(result, &error)) { - ofono_error("indication_register_cb: %hd", error); - goto error; + ofono_error("indication_register_cb: %s(%hd)", + qmi_result_get_error(result), error); + + /* Some modems do not support indications, ignore */ + if (error != QMI_ERROR_INVALID_QMI_COMMAND) + goto error; } /* diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 966f99f114fe..db20280f9aa3 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -50,6 +50,10 @@ enum qmi_data_endpoint_type { QMI_DATA_ENDPOINT_TYPE_BAM_DMUX = 0x05, }; +enum qmi_error { + QMI_ERROR_INVALID_QMI_COMMAND = 71, +}; + typedef void (*qmi_destroy_func_t)(void *user_data); struct qmi_service; From patchwork Tue Jun 18 20:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13702940 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 4FDB116EB57 for ; Tue, 18 Jun 2024 20:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740980; cv=none; b=r/qCbjN9a0ZpCaHUueJfz1Zkq21ff4j2mjGt/VX/zcj7zeL7Kxi0KqvZ/oK0wCYLvXmEbARoJcjEDgW4aJCysPV4UvIz9OYgsWyLvg2EJEePShZ+meA9qxe3h3x93oyCDtBCLyocyaRrELgW9POrGia70rCzhyOJNiUJoYTd7bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718740980; c=relaxed/simple; bh=CslnnGa1m9DfUWAjjHEotmzteKzeUqGJLcAA1PuLjOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OdtykDl0qnED/0NT0UVnc02NqLOu6zlx86oHj/95B/o7qbQymxgKKwIxSv4C8zZXyvwN6+e094L6xin/YRm2DZmrHBU3W1WwaaGV7azm/G7c5PKtxBQfxYdi79VLMqY2bEBEKYJviXwYyS46wL3tIij93zSm7u2p7RLgmmXahlA= 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=UKO98hun; arc=none smtp.client-ip=209.85.160.50 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="UKO98hun" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-2598a57b2c1so314384fac.0 for ; Tue, 18 Jun 2024 13:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718740978; x=1719345778; 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=ud+nxUAFMEuWeebql4YXA4OOlpC4063orE/63Kn5S28=; b=UKO98hunwVMnVu0lfETdjphXMq8QXudIan0zVH0b5Fs2cjz0511w+gvADFFEfOmV1N 14NK5zYSursrcMgFDVOMaolDmPID8/BPamJntdiMpjU/A5/7popJZZZbfUoX7f/KmBB/ n2Jq7iH9+92sECY+YK+9TGCR1kSMvLXKIgNvbkFiOD8SNewSF2qGLL7XyfIcroQ16kJZ n1pxXSrRD2LXg5pKNOuW1U/gbsXlrG4se9FbvYbDm1Mqq5EGtsdfhELVYiKAMZsMLksE ffbpFjqqGGWmZV7KbcmFwmHWYBGxFkPjfxv/3x/hsyUF5uLE4FULBFZBkoTKZiFrSEB+ Bu9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718740978; x=1719345778; 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=ud+nxUAFMEuWeebql4YXA4OOlpC4063orE/63Kn5S28=; b=fw368JnnoiyGokDndH7Uehju68ojovPbzT6sBIDIyMIAi6LJp8zF1mUAT/eg+E+BQ6 auZiO+QN82x0p8T1V6h5FF/P/48rC4dMyynYyWAEOg2Zr84xVA/3sHfksHwQ6yf/2JuY PCdaDRsesiLEBmVzT6yRAgd2j26Z/bBmIhvbim3vXNxCsUpjbQOBkXEbox4AxF1aBymO wba5z2Z6W1r1wzGRPAXSO0/NXQNjVzRG+mQ8yRksIFY/I3r3tHg0Hi0Z4I8j/gXxW4R0 n05Udr0tYiCDnO3zBqG5ljKaktglC2RbjrJcQULW3P5uNA0b4EBL81hzsmIc20YtD6so 5a0w== X-Gm-Message-State: AOJu0YzSNgWwIYCs9QLJ1PmneUFpD68vkmy6bz9c+pyqx3iyWx3HhFm3 r7laY3NNySLM2zBhwdzAucRrBTOdAL2zKlVCxD2Dgm63tjHyQlUPeQqBoA== X-Google-Smtp-Source: AGHT+IF8M/ONfU3R/fmLkP0zY/0RYpQY2D8WGclxQfXjXqrjeT55smXLJg3mIywx4dbW9+EXb1pyog== X-Received: by 2002:a05:6870:9121:b0:259:89cc:d80b with SMTP id 586e51a60fabf-25c94a0e4cemr855006fac.32.1718740978453; Tue, 18 Jun 2024 13:02:58 -0700 (PDT) Received: from localhost.localdomain (syn-070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7d31sm3305744fac.14.2024.06.18.13.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 13:02:58 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 33/33] qmi: non-premultiplexed MHI devices Date: Tue, 18 Jun 2024 15:02:15 -0500 Message-ID: <20240618200231.1129282-33-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240618200231.1129282-1-denkenz@gmail.com> References: <20240618200231.1129282-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 MHI devices by default create a single main interface and support a single bearer over it. However, this requires a WDS Bind Data Mux command to be issued with 'mux_id' 0. Update the qmi gprs_context atom driver to support multiple arguments, one of them being the mux_id and the other being the WDS service lightweight handle. If mux_id is -1, then the WDS Bind Data Mux command is skipped. Update gobi and qrtrqmi drivers to the new API. --- drivers/qmimodem/gprs-context.c | 15 ++++++++------- plugins/gobi.c | 4 ++-- plugins/qrtrqmi.c | 9 ++++++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index aae058f35a9b..3c18476142ea 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -550,16 +550,17 @@ static int qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc, return -EIO; } -static int qmi_gprs_context_probe(struct ofono_gprs_context *gc, - unsigned int vendor, void *user_data) +static int qmi_gprs_context_probev(struct ofono_gprs_context *gc, + unsigned int vendor, va_list args) { - struct qmi_service *wds = user_data; + int mux_id = va_arg(args, int); + struct qmi_service *wds = va_arg(args, struct qmi_service *); struct gprs_context_data *data; DBG(""); - if (vendor) { - int r = qmi_gprs_context_bind_mux(gc, wds, vendor); + if (mux_id != -1) { + int r = qmi_gprs_context_bind_mux(gc, wds, mux_id); if (r < 0) { qmi_service_free(wds); @@ -569,7 +570,7 @@ static int qmi_gprs_context_probe(struct ofono_gprs_context *gc, data = l_new(struct gprs_context_data, 1); data->wds = wds; - data->mux_id = vendor; + data->mux_id = mux_id; qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS, pkt_status_notify, gc, NULL); @@ -593,7 +594,7 @@ static void qmi_gprs_context_remove(struct ofono_gprs_context *gc) static const struct ofono_gprs_context_driver driver = { .flags = OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE, - .probe = qmi_gprs_context_probe, + .probev = qmi_gprs_context_probev, .remove = qmi_gprs_context_remove, .activate_primary = qmi_activate_primary, .deactivate_primary = qmi_deactivate_primary, diff --git a/plugins/gobi.c b/plugins/gobi.c index d24b95fffc91..7cdab3dda5f5 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -762,7 +762,7 @@ static void gobi_setup_gprs(struct ofono_modem *modem) if (n_premux == 0) { interface = ofono_modem_get_string(modem, "NetworkInterface"); - gc = ofono_gprs_context_create(modem, 0, "qmimodem", + gc = ofono_gprs_context_create(modem, 0, "qmimodem", -1, qmi_service_clone(data->wds)); if (!gc) { ofono_warn("Unable to create gprs-context for: %s", @@ -788,7 +788,7 @@ static void gobi_setup_gprs(struct ofono_modem *modem) sprintf(buf, "PremuxInterface%dMuxId", i + 1); mux_id = ofono_modem_get_integer(modem, buf); - gc = ofono_gprs_context_create(modem, mux_id, "qmimodem", + gc = ofono_gprs_context_create(modem, 0, "qmimodem", mux_id, qmi_service_clone(data->wds)); if (!gc) { diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index 51e682f7e87c..cc335546caff 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -315,7 +315,7 @@ static int setup_gprs_context(uint8_t mux_id, const char *interface, struct qmi_qrtr_node *node = data->node; struct ofono_gprs_context *gc; - gc = ofono_gprs_context_create(modem, 0, "qmimodem", + gc = ofono_gprs_context_create(modem, 0, "qmimodem", mux_id, qmi_qrtr_node_get_service(node, QMI_SERVICE_WDS)); if (!gc) { ofono_warn("Unable to create gprs-context for: %s, %s[%hhu]", @@ -347,6 +347,13 @@ static void setup_gprs(struct ofono_modem *modem) return; } + /* Upstream driver default, single interface, single context */ + if (!n_premux) { + interface = ofono_modem_get_string(modem, "NetworkInterface"); + setup_gprs_context(0, interface, gprs); + return; + } + for (i = 0; i < n_premux; i++) { int mux_id;