All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] qmi: Create a method to find a service by type
@ 2024-02-29 15:31 Steve Schrock
  2024-02-29 15:31 ` [PATCH v2 2/4] qmi: Add more service info to qmi_service Steve Schrock
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Steve Schrock @ 2024-02-29 15:31 UTC (permalink / raw)
  To: ofono; +Cc: Steve Schrock

---
 drivers/qmimodem/qmi.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index ffb26326..d65a1c15 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -953,39 +953,42 @@ static const void *tlv_get(const void *data, uint16_t size,
 	return NULL;
 }
 
-bool qmi_device_get_service_version(struct qmi_device *device, uint16_t type,
-					uint16_t *major, uint16_t *minor)
+static const struct qmi_service_info *__find_service_info_by_type(
+				struct qmi_device *device, uint16_t type)
 {
+	const struct qmi_service_info *info = NULL;
 	const struct l_queue_entry *entry;
 
 	for (entry = l_queue_get_entries(device->service_infos);
 						entry; entry = entry->next) {
-		const struct qmi_service_info *info = entry->data;
-
-		if (info->service_type != type)
-			continue;
+		struct qmi_service_info *data = entry->data;
 
-		*major = info->major;
-		*minor = info->minor;
-		return true;
+		if (data->service_type == type) {
+			info = data;
+			break;
+		}
 	}
 
-	return false;
+	return info;
 }
 
-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)
 {
-	const struct l_queue_entry *entry;
+	const struct qmi_service_info *info;
 
-	for (entry = l_queue_get_entries(device->service_infos);
-						entry; entry = entry->next) {
-		const struct qmi_service_info *info = entry->data;
+	info = __find_service_info_by_type(device, type);
+	if (!info)
+		return false;
 
-		if (info->service_type == type)
-			return true;
-	}
+	*major = info->major;
+	*minor = info->minor;
+	return true;
+}
 
-	return false;
+bool qmi_device_has_service(struct qmi_device *device, uint16_t type)
+{
+	return __find_service_info_by_type(device, type);
 }
 
 struct discover_data {
-- 
2.43.2


-- 


*Confidentiality Note:* We care about protecting our proprietary 
information, confidential material, and trade secrets. This message may 
contain some or all of those things. Cruise will suffer material harm if 
anyone other than the intended recipient disseminates or takes any action 
based on this message. If you have received this message (including any 
attachments) in error, please delete it immediately and notify the sender 
promptly.

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/4] qmi: Add more service info to qmi_service
  2024-02-29 15:31 [PATCH v2 1/4] qmi: Create a method to find a service by type Steve Schrock
@ 2024-02-29 15:31 ` Steve Schrock
  2024-02-29 15:31 ` [PATCH v2 3/4] qmi: Allow for 16-bit service types in the type hash Steve Schrock
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Steve Schrock @ 2024-02-29 15:31 UTC (permalink / raw)
  To: ofono; +Cc: Steve Schrock

QRTR will need to know the node and port for writes.
---
 drivers/qmimodem/qmi.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index d65a1c15..d2f28bec 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -118,9 +118,7 @@ struct qmi_device_qmux {
 struct qmi_service {
 	int ref_count;
 	struct qmi_device *device;
-	uint8_t type;
-	uint16_t major;
-	uint16_t minor;
+	struct qmi_service_info info;
 	uint8_t client_id;
 	uint16_t next_notify_id;
 	struct l_queue *notify_list;
@@ -315,7 +313,7 @@ static void __service_find_by_type(const void *key, void *value,
 	if (L_PTR_TO_UINT(key) & 0x80000000)
 		return;
 
-	if (service->type == data->type)
+	if (service->info.service_type == data->type)
 		data->found_service = service;
 }
 
@@ -1687,17 +1685,18 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length,
 	service->ref_count = 1;
 	service->device = data->device;
 
-	service->type = data->type;
-	service->major = data->major;
-	service->minor = data->minor;
+	service->info.service_type = data->type;
+	service->info.major = data->major;
+	service->info.minor = data->minor;
 
 	service->client_id = client_id->client;
 	service->notify_list = l_queue_new();
 
 	__debug_device(device, "service created [client=%d,type=%d]",
-					service->client_id, service->type);
+					service->client_id,
+					service->info.service_type);
 
-	hash_id = service->type | (service->client_id << 8);
+	hash_id = service->info.service_type | (service->client_id << 8);
 
 	l_hashmap_replace(device->service_list, L_UINT_TO_PTR(hash_id),
 				service, (void **) &old_service);
@@ -2526,12 +2525,12 @@ void qmi_service_unref(struct qmi_service *service)
 	qmi_service_cancel_all(service);
 	qmi_service_unregister_all(service);
 
-	hash_id = service->type | (service->client_id << 8);
+	hash_id = service->info.service_type | (service->client_id << 8);
 
 	l_hashmap_remove(device->service_list, L_UINT_TO_PTR(hash_id));
 
 	if (device->ops->client_release)
-		device->ops->client_release(device, service->type,
+		device->ops->client_release(device, service->info.service_type,
 							service->client_id);
 
 	l_free(service);
@@ -2542,7 +2541,7 @@ const char *qmi_service_get_identifier(struct qmi_service *service)
 	if (!service)
 		return NULL;
 
-	return __service_type_to_string(service->type);
+	return __service_type_to_string(service->info.service_type);
 }
 
 bool qmi_service_get_version(struct qmi_service *service,
@@ -2552,10 +2551,10 @@ bool qmi_service_get_version(struct qmi_service *service,
 		return false;
 
 	if (major)
-		*major = service->major;
+		*major = service->info.major;
 
 	if (minor)
-		*minor = service->minor;
+		*minor = service->info.minor;
 
 	return true;
 }
@@ -2629,7 +2628,7 @@ uint16_t qmi_service_send(struct qmi_service *service,
 	data->user_data = user_data;
 	data->destroy = destroy;
 
-	req = __request_alloc(service->type, service->client_id,
+	req = __request_alloc(service->info.service_type, service->client_id,
 				message,
 				param ? param->data : NULL,
 				param ? param->length : 0,
-- 
2.43.2


-- 


*Confidentiality Note:* We care about protecting our proprietary 
information, confidential material, and trade secrets. This message may 
contain some or all of those things. Cruise will suffer material harm if 
anyone other than the intended recipient disseminates or takes any action 
based on this message. If you have received this message (including any 
attachments) in error, please delete it immediately and notify the sender 
promptly.

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/4] qmi: Allow for 16-bit service types in the type hash
  2024-02-29 15:31 [PATCH v2 1/4] qmi: Create a method to find a service by type Steve Schrock
  2024-02-29 15:31 ` [PATCH v2 2/4] qmi: Add more service info to qmi_service Steve Schrock
@ 2024-02-29 15:31 ` Steve Schrock
  2024-02-29 15:31 ` [PATCH v2 4/4] qmi: Enable basic client creation if it is not subclassed Steve Schrock
  2024-02-29 16:40 ` [PATCH v2 1/4] qmi: Create a method to find a service by type patchwork-bot+ofono
  3 siblings, 0 replies; 5+ messages in thread
From: Steve Schrock @ 2024-02-29 15:31 UTC (permalink / raw)
  To: ofono; +Cc: Steve Schrock

Only QMUX has client ids and they fit into 8 bits.
---
 drivers/qmimodem/qmi.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index d2f28bec..acb10d6b 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -734,6 +734,11 @@ static void service_notify(const void *key, void *value, void *user_data)
 				result);
 }
 
+static unsigned int service_list_create_hash(uint16_t service_type, uint8_t client_id)
+{
+	return (service_type | (client_id << 16));
+}
+
 static void handle_indication(struct qmi_device *device,
 			uint8_t service_type, uint8_t client_id,
 			uint16_t message, uint16_t length, const void *data)
@@ -757,8 +762,7 @@ static void handle_indication(struct qmi_device *device,
 		return;
 	}
 
-	hash_id = service_type | (client_id << 8);
-
+	hash_id = service_list_create_hash(service_type, client_id);
 	service = l_hashmap_lookup(device->service_list,
 					L_UINT_TO_PTR(hash_id));
 
@@ -1696,8 +1700,8 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length,
 					service->client_id,
 					service->info.service_type);
 
-	hash_id = service->info.service_type | (service->client_id << 8);
-
+	hash_id = service_list_create_hash(service->info.service_type,
+							service->client_id);
 	l_hashmap_replace(device->service_list, L_UINT_TO_PTR(hash_id),
 				service, (void **) &old_service);
 
@@ -2525,8 +2529,8 @@ void qmi_service_unref(struct qmi_service *service)
 	qmi_service_cancel_all(service);
 	qmi_service_unregister_all(service);
 
-	hash_id = service->info.service_type | (service->client_id << 8);
-
+	hash_id = service_list_create_hash(service->info.service_type,
+							service->client_id);
 	l_hashmap_remove(device->service_list, L_UINT_TO_PTR(hash_id));
 
 	if (device->ops->client_release)
-- 
2.43.2


-- 


*Confidentiality Note:* We care about protecting our proprietary 
information, confidential material, and trade secrets. This message may 
contain some or all of those things. Cruise will suffer material harm if 
anyone other than the intended recipient disseminates or takes any action 
based on this message. If you have received this message (including any 
attachments) in error, please delete it immediately and notify the sender 
promptly.

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 4/4] qmi: Enable basic client creation if it is not subclassed
  2024-02-29 15:31 [PATCH v2 1/4] qmi: Create a method to find a service by type Steve Schrock
  2024-02-29 15:31 ` [PATCH v2 2/4] qmi: Add more service info to qmi_service Steve Schrock
  2024-02-29 15:31 ` [PATCH v2 3/4] qmi: Allow for 16-bit service types in the type hash Steve Schrock
@ 2024-02-29 15:31 ` Steve Schrock
  2024-02-29 16:40 ` [PATCH v2 1/4] qmi: Create a method to find a service by type patchwork-bot+ofono
  3 siblings, 0 replies; 5+ messages in thread
From: Steve Schrock @ 2024-02-29 15:31 UTC (permalink / raw)
  To: ofono; +Cc: Steve Schrock

QRTR does not require client ID allocation requests.
---
 drivers/qmimodem/qmi.c | 81 +++++++++++++++++++++++++++++++++---------
 1 file changed, 64 insertions(+), 17 deletions(-)

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index acb10d6b..58400aaf 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -1386,6 +1386,25 @@ static uint8_t __ctl_request_submit(struct qmi_device_qmux *qmux,
 	return req->tid;
 }
 
+static struct qmi_service *service_create(struct qmi_device *device,
+			const struct qmi_service_info *info, uint8_t client_id)
+{
+	struct qmi_service *service = l_new(struct qmi_service, 1);
+
+	service->ref_count = 1;
+	service->device = device;
+	service->client_id = client_id;
+	service->notify_list = l_queue_new();
+
+	memcpy(&service->info, info, sizeof(service->info));
+
+	__debug_device(device, "service created [client=%d,type=%d]",
+					service->client_id,
+					service->info.service_type);
+
+	return service;
+}
+
 static void service_create_shared_reply(struct l_idle *idle, void *user_data)
 {
 	struct service_create_shared_data *data = user_data;
@@ -1662,6 +1681,7 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length,
 	struct qmi_device *device = data->device;
 	struct qmi_service *service = NULL;
 	struct qmi_service *old_service = NULL;
+	struct qmi_service_info info;
 	const struct qmi_result_code *result_code;
 	const struct qmi_client_id *client_id;
 	uint16_t len;
@@ -1684,21 +1704,12 @@ static void qmux_client_create_callback(uint16_t message, uint16_t length,
 	if (client_id->service != data->type)
 		goto done;
 
-	service = l_new(struct qmi_service, 1);
-
-	service->ref_count = 1;
-	service->device = data->device;
-
-	service->info.service_type = data->type;
-	service->info.major = data->major;
-	service->info.minor = data->minor;
+	memset(&info, 0, sizeof(service->info));
+	info.service_type = data->type;
+	info.major = data->major;
+	info.minor = data->minor;
 
-	service->client_id = client_id->client;
-	service->notify_list = l_queue_new();
-
-	__debug_device(device, "service created [client=%d,type=%d]",
-					service->client_id,
-					service->info.service_type);
+	service = service_create(device, &info, client_id->client);
 
 	hash_id = service_list_create_hash(service->info.service_type,
 							service->client_id);
@@ -2441,6 +2452,45 @@ bool qmi_service_create_shared(struct qmi_device *device, uint16_t type,
 	if (type == QMI_SERVICE_CONTROL)
 		return false;
 
+	if (!device->ops->client_create) {
+		struct service_create_shared_data *data;
+
+		/*
+		 * The hash id is simply the service type in this case. There
+		 * is no "pending" state for discovery and no client id.
+		 */
+		service = l_hashmap_lookup(device->service_list,
+						L_UINT_TO_PTR(type_val));
+		if (!service) {
+			const struct qmi_service_info *info;
+
+			info = __find_service_info_by_type(device, type);
+			if (!info)
+				return false;
+
+			service = service_create(device, info, 0);
+			l_hashmap_insert(device->service_list,
+					L_UINT_TO_PTR(type_val), service);
+		}
+
+		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->service = qmi_service_ref(service);
+		data->idle = l_idle_create(service_create_shared_reply,
+							data, NULL);
+
+		/* Not really discovery... just tracking the idle callback. */
+		__qmi_device_discovery_started(device, &data->super);
+
+		return true;
+	}
+
 	shared = l_hashmap_lookup(device->service_list,
 					L_UINT_TO_PTR(type_val | 0x80000000));
 
@@ -2484,9 +2534,6 @@ bool qmi_service_create_shared(struct qmi_device *device, uint16_t type,
 		return true;
 	}
 
-	if (!device->ops->client_create)
-		return -ENOTSUP;
-
 	r = device->ops->client_create(device, type, func, user_data, destroy);
 	return r == 0;
 }
-- 
2.43.2


-- 


*Confidentiality Note:* We care about protecting our proprietary 
information, confidential material, and trade secrets. This message may 
contain some or all of those things. Cruise will suffer material harm if 
anyone other than the intended recipient disseminates or takes any action 
based on this message. If you have received this message (including any 
attachments) in error, please delete it immediately and notify the sender 
promptly.

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/4] qmi: Create a method to find a service by type
  2024-02-29 15:31 [PATCH v2 1/4] qmi: Create a method to find a service by type Steve Schrock
                   ` (2 preceding siblings ...)
  2024-02-29 15:31 ` [PATCH v2 4/4] qmi: Enable basic client creation if it is not subclassed Steve Schrock
@ 2024-02-29 16:40 ` patchwork-bot+ofono
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+ofono @ 2024-02-29 16:40 UTC (permalink / raw)
  To: Steve Schrock; +Cc: ofono

Hello:

This series was applied to ofono.git (master)
by Denis Kenzior <denkenz@gmail.com>:

On Thu, 29 Feb 2024 09:31:38 -0600 you wrote:
> ---
>  drivers/qmimodem/qmi.c | 41 ++++++++++++++++++++++-------------------
>  1 file changed, 22 insertions(+), 19 deletions(-)

Here is the summary with links:
  - [v2,1/4] qmi: Create a method to find a service by type
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=fa411b89f282
  - [v2,2/4] qmi: Add more service info to qmi_service
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=8cdc1511f519
  - [v2,3/4] qmi: Allow for 16-bit service types in the type hash
    (no matching commit)
  - [v2,4/4] qmi: Enable basic client creation if it is not subclassed
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=03160ab1fc34

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-29 16:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 15:31 [PATCH v2 1/4] qmi: Create a method to find a service by type Steve Schrock
2024-02-29 15:31 ` [PATCH v2 2/4] qmi: Add more service info to qmi_service Steve Schrock
2024-02-29 15:31 ` [PATCH v2 3/4] qmi: Allow for 16-bit service types in the type hash Steve Schrock
2024-02-29 15:31 ` [PATCH v2 4/4] qmi: Enable basic client creation if it is not subclassed Steve Schrock
2024-02-29 16:40 ` [PATCH v2 1/4] qmi: Create a method to find a service by type patchwork-bot+ofono

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.