From patchwork Fri Jun 14 18:52: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: 13699047 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.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 787911A01C1 for ; Fri, 14 Jun 2024 18:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391184; cv=none; b=cd7OTzbahGO95pp4NQTbfy8jE7kGco7Q9+ZTBTPxOctIxSkwM6bfimfhZzRQJ+9qftCMKQJZEn6ZkwgnD672tpkGWV+KxL15BePUnKwrbD7B4b1bgF/JxWiXptZePxIhhUQNC3RpUorlqI38/QP64OjePptizw9kQxwLjCaiFmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391184; c=relaxed/simple; bh=HUU3sUQwdUaQObDoIMlsAJAGfuur9LlGmMKFRvkjIlA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DfPNPp7b3HulRufq7f3k3EV8Pdnp4PfMCX1YVz8/XRYS9vENnbSvWhoeXnnViMQECmD3K/PYtiUOPpJr8njRLoRCuH2sbodg4Opy4oO/pDkaNPtNWUGiYf2C0liw9ova0y04xuTBBvQZ+oNGUCdSe4HqxwaIc46ngn9RzkeN8E8= 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=l3YHHqTs; arc=none smtp.client-ip=209.85.210.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="l3YHHqTs" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6f980c89db8so1347360a34.1 for ; Fri, 14 Jun 2024 11:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391182; x=1718995982; 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=l3YHHqTsh2FuMC7N8I2zLSCOWgDX/Gr37zzAYIv4E0fBzSgj99trTwOUzVbErvJh6P CNFzgDiZUFiDx4612Jr32+JwrVpptqb3wxcsoKsS82Ya7mwiPl2gK3bDCe4qVLQyVjNz m0Sch6qo8LyXuEbouAx1TYINxFCBreA0WwzuaCAFv/MblhQFdumWSGo1eCkIld72vYNV o06AaYVhfnDKRVLi98/BlwgyUpCGG+qk96fwc6cJvJDyKAlDm9++RzFtBScF8Pnldt4y K8aCZKGdY6Q4lSctz7gnKARX0QslABdKx0sM1FoowQBeZhKFTNSNizBbwu2j9LDQfpdG iybg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391182; x=1718995982; 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=HtGhaq5lpk1r96k/FxlspznybU6wFhf+eVUY3DYq0E5uiTrCx8ehf+av62sZSK6Ckw 2RfCdQsBwYirp9eGiCrop5ajhRVUHpZX8vObyFBktZPm+CnhVW7E4XiBi0M0GX3bRJrn +YqFeVshctH3kNrXIQE7rTG3kpLbtQStHY5z3nUH29ufpb1KosziHME3EisaapsNhz9T Ti+zvAU/EMrVOJqq2pvSbS8exViH9OU/Aoga2ozW3Wgaoq2Ln7Tg5cgsc68lQSvNPcsL clLEWRr9QNPPzfpSgTYl5hf+KVwzGMQ7pmA1wLXOuviEa0vzmPHD71wKdtGfcobcsAtc b2dA== X-Gm-Message-State: AOJu0YwBtQ8zH+BXlahYz2dWmUkGxDVnzkJecd5qU8pyoklX+pAOrbSy 8l/zs5WjB7AB5q09KuEg329WGX1WhMdZh9JOElkD9615tRgHvIsQHuSO7Q== X-Google-Smtp-Source: AGHT+IHJBc53o6CHUPAc9eSi+LTsWzuHu/brI243sKxcC8t7blsFXb4Et3acU/8+huDB9EYTbamc0g== X-Received: by 2002:a05:6870:e9a2:b0:24f:c892:d02b with SMTP id 586e51a60fabf-2584256ea77mr3941713fac.0.1718391182394; Fri, 14 Jun 2024 11:53:02 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:02 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 01/27] qmi: Remove qmi_free() Date: Fri, 14 Jun 2024 13:52:13 -0500 Message-ID: <20240614185300.1086701-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 Fri Jun 14 18:52: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: 13699050 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.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 3B63A1A0AFE for ; Fri, 14 Jun 2024 18:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391188; cv=none; b=r2aQdgY8CUmj3ij0FO79tFn3SJDXSKApq9OoOEUU1UiQPMnncf4xwJR1/4jMcjyxBSuzPkQaT6Jkn8qLiQ2PIITHN0Q/02e6TDZ1dNGTbD7JUYG+cTaBlY8+lhCUUAiVBXnWhgJ6vzhjCk9Z2tE1b0ILJIxvF5AuF7MV7uM7wCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391188; c=relaxed/simple; bh=AqmRSXpqsa74kzD6L/BnSNSpMChihtQQEBU2ZB4UNWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oTOpIwNxmk/fSWreWeYRnb6cdVqOrsKdWwgh5dLy0p+6qMVY+7ThElHsQR5BMESOhvaP0qO+4Tkkxe4+dqwrFufl8PXTy1DBg/KWV9DHNz9MekEghTd3/EdNOJjdqPxnviJAjbyDFcQSKl6RTFAXmkygOxKaRVJOfTlGCdaVfks= 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=N/W3SFVs; arc=none smtp.client-ip=209.85.161.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="N/W3SFVs" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-5b96b249d56so1709342eaf.1 for ; Fri, 14 Jun 2024 11:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391183; x=1718995983; 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=N/W3SFVseKo0JooPMt7lsEyH23xJ9VWCRgP1nCVQ0x79I69Gkwj4h6HhiaPhPF50Nf uc/DXW4+j9IQtNnvJuYCqtVIWXGBmolQTlezwCX+zieFitwDRifk3sU1dhDLBGS3sIw4 FaEUivXChTwC177uYFxsSLLU/VwxamInJJQMbh1ApDfQSthu94jritXI2uBNuMOCintZ 71M4U/94CZM5maGhEcfPurD00TveGfqbqTPrqDhTWe4i0oBGbhbBf8IQ6zkxo6a38R86 Aqi9ecPN9KJxg3ny6SYdto4x/om3CJapSMdQbUMYX5Xfwkx1Pfz+oSquGCucXelQsMDC +aAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391183; x=1718995983; 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=LwftswFqwFQ7IugTldRjvRdLtlLBKUQKINJH+PqiqciLxRkm7vFxuyA0JBFya/lxQS Cohfexxi1nTVYF9P3yLo++DERp6XqewNA++EUbH3rMTru/zO33puUWVny8X90SN/Qz+Q sg+96yAXfqWDnotRZtocO5yQSMw8W40WUxgt0UG+xDCihDp+3tqtwo/ndH4YW2aMOlxO e+nGONqaC6OOfmlXuKgcbFhqVT9TEMsAQRvi2MTKff6RPanPjDScsvY2HParZVdrKMj5 1w28PO67NquDzcpXla57t2y4ijH0jVCGZ5jACy3yoMbKmoU/deFQ1yvpLX1DQSJuVbG2 CNMQ== X-Gm-Message-State: AOJu0YwteRYNz2tyNgjXDUd6d3qgEqUV7e+QyGYfQAPJTg+VvaA7MwLj IsvFIYvdLhsWSuKmHLIZeCCzeqXtDtDrmaS/EPOOb/ZwtG/A48e8EVcqcA== X-Google-Smtp-Source: AGHT+IGZ7twnZ4tG6EpX79UO5QyYxSMzEBd0B22d95vtFCS1EaUfKYyKuOyiM4rz+xiNBXtYi2ubsw== X-Received: by 2002:a05:6870:a452:b0:258:3455:4b2f with SMTP id 586e51a60fabf-25840ffe483mr1540334fac.17.1718391183041; Fri, 14 Jun 2024 11:53:03 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:02 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 02/27] qmi: Rename qmi_result_func_t Date: Fri, 14 Jun 2024 13:52:14 -0500 Message-ID: <20240614185300.1086701-2-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 Fri Jun 14 18:52: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: 13699048 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 B45D01A01C5 for ; Fri, 14 Jun 2024 18:53:04 +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=1718391186; cv=none; b=cufRcYuL1pyrTWtfCFgYdNS0SuLXSerNoJ4mPEZXB3eaeCm43R2ldqVR3GFJfi7tJsjQ1iZ0v68aIOQ/fHMAg+rOGTtA2bqJd8UI1pRIfumyXggWXMX5gsJCi5TL/6UXKGwZVoOjLL5wHRLPZ8Hnc9s38ya6PI3XdGNrUZfj5jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391186; c=relaxed/simple; bh=jhZSc7mmecQDcJyyp7Wo7xsMqmbFD4HSRjTKXpfRInk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FT06tJZ8NmP9dsV5D8iYYF0HjLQWmHqb0fxtLHlPkubJNi7Xelu0LHdbBcWMIi6H7EBMBWGYqyrvEpMxC+iVxemmsagyZmsgNYRwwWI49Rhv5w1L9Sr2P2dV1zBsIqM6x3vgh0SO+RsEPkND1Zs/jdO4WGulSVcyoomZlioFUS8= 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=GV105X8K; 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="GV105X8K" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-24c9f6338a4so1179606fac.1 for ; Fri, 14 Jun 2024 11:53:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391184; x=1718995984; 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=GV105X8KyOoxD7LkgUBJeKKG2Bm6ZHnB/+eAu89F+A3etGa5XTl682u2hFDoGuejWs BtWr7OZDxrYr078/r7+NCzxrDuPru32VJ+4aWq76O7BPJFDmtEFF9DUrO6gK4zSaaZeb UH9a0yAWkTmmk3VzEgxAtILNHyNvnMEdHN+Y1jlg14hexNHjrWSL2K7k3qKiAG/Dxerg FVVPIGz3TpmqwXvaVwkeTkft3Gf0uInBbEiTTGiZaBotmVOyoChQ3QZqyo2cxmfGrTIz ISRey9gIlLlv3uIDeN/oT059aQ7SaToEQHrmgOqUsqUyr6YA+UviaTURV1tqXTNZlv3Q mGwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391184; x=1718995984; 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=pSFMSmcF3tYe/b3jX0VburCbCfTYTPp6Bji876Nz26RK1C90bDkKKoU8M017+phvXo iKug8EcKsN1SaCFu3DHcTKyoZte7TSeyRSngYPDe9PpcJl4ab9EzNroi7IPoqGCYRirH v1rkhBYCAm/nLtCN+tdApbfH9gufhdP4pbv59uGJJsj1OFUoxSIcg0HULyT1uLAwsr2r CkND6e4ECGdOfdGEA+hBH69Cx5SLIX08vFHRUlt4t14AX3WhnpJeKw0Fmd8hJJb5NDZM r9uNzxgqzLixQkLZIk4NEuQufBRhitomT/aex10lcVUawE3GIFQCdnBYdGidE1k0v6IZ 11Ng== X-Gm-Message-State: AOJu0YyJEjCOLFPSskrL0unD6bDXKJzjdP9SVP+OwMjLILfnOSRD7Nx8 ImvDDYB+gtTj9POlLg8t8sUFcxhUd9rdF+b3kafH1jQg3Fl/2/8XJ8fYRQ== X-Google-Smtp-Source: AGHT+IFj/ncJyVNvnrrNxeodLABnEozDz17p8yE7m1l0NinU9g9x1mJBvfQ+7ZEeTlVmVlTlVOhw7g== X-Received: by 2002:a05:6870:7b41:b0:258:5143:a21a with SMTP id 586e51a60fabf-2585143a77emr1461199fac.13.1718391183730; Fri, 14 Jun 2024 11:53:03 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:03 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 03/27] qmi: Drop unused major/minor information Date: Fri, 14 Jun 2024 13:52:15 -0500 Message-ID: <20240614185300.1086701-3-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 Fri Jun 14 18:52:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699049 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.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 398F01A2C0A for ; Fri, 14 Jun 2024 18:53:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391188; cv=none; b=HT4mSHwcudy8HqePBxrOOgyfKzL9EViAmcSKH6/yXRhjZc2C1M/UGjFopzpti9bmj7eZf2lfwjforbPDi/iJPMOWZ0qxkSopLmd0fJIvsD9uNgvShFIuEui8OYJ9zrCYKuHvXjbYXlVcK3IaoGQiyNU63xFZp3Te7mciO6dXUho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391188; c=relaxed/simple; bh=cvtgdm1y3G36NkEXoYKr7nrLcI+ssUA9k2ctylwZ3dk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qqX//+I5Gm0JIcTOHKxXqQ2bzVWdw7I5a3sLruUjsGfQE6ogcM5vrBQvtQnxZNbD5zcGpbF8o2/AEE2sNIKTQ8EAq5P/444784t3A80eLg8/Kj5OIC6z/FKiJDh+g759lSBX+oOVo9+53S0S5ncKeWbYMfspQtNEjJyBmBYbPn0= 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=NxfrYdEM; arc=none smtp.client-ip=209.85.161.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="NxfrYdEM" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5bafe063f35so1490088eaf.0 for ; Fri, 14 Jun 2024 11:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391186; x=1718995986; 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=NxfrYdEMaDddzcDqalG57H9lGJ52pYzvjK4l4ljelOM+/WzcvI7Myw7KUbq0PrJKkI MzkfUrY+WhVDnqdJBG4VawtzQ6Nx0YxHR+GFkwc8lfS4Klc2kG+tjD7z6jO1EYVXJaQc 55e07asZIXfxsi2jWYiwvanVXkDFAVQTaj5xChIz/yjRKEDqIgyKfJ656LrcUvbwQySE o4+n1fkvbMzuePZi+V0yeZlwZFKm7yof2X/irC58i9snPe7svRePgF78CaY1JwVWWfo0 WL7PeTpS3RYIPvBNmaeacC/JzTzZwP+HUABycG28bHGLpPhAYe+R/FU8o6b2FvPqbSNl phng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391186; x=1718995986; 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=mDAZa7thq7+AAriUVxSuWPxXxQw0QesHUSbjZ+VoejS7XoF2hweagF4iCeI3o58hPy JoQ1JWbWPKRmTNAzdXvu3dMgOBQWrlub41SSDVInuMwhHFkHkmVRsiVrG5hg/xcoOsB+ RfYlzEnTTSxa7j37XX8tTPwDHRl4Zr4D96JkC0/+P9G9Iz3ea7F6LKAZvGTg9ulOekyO ueUmy5/0q97+XzKJVLfrJYJlj/OLUmzjZVS3lG/rZRRt4VzPbLBMmLaSbcKXrX7yMDXS 3mOCL98yrvYChmFv7QkMbLTOG/ey25LNidgPL96NhoBWn4mr70lNM8/v2e5+nrmcFRhS IPGg== X-Gm-Message-State: AOJu0YyFWy2wfkhS7wWvDoi82J2Pl1zDLPm5OfFxcJuhvBJ8Ythkgh/4 8zrvkRPyAUeDOvQ2JYS0jIVlzBpFIWre0es+TVPziAvDjjyAT0pSxkYkhw== X-Google-Smtp-Source: AGHT+IEnROC1hLIhreDUlAE0o08GTkmRJTv/KNy9qqq5TQV+B3vXE3shSbjz7UqwEMS2gsy+ETzRCQ== X-Received: by 2002:a05:6870:93c3:b0:254:a218:89e6 with SMTP id 586e51a60fabf-2552b3b455fmr3450714fac.23.1718391184297; Fri, 14 Jun 2024 11:53:04 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:04 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 04/27] qmi: Add qmi_qrtr_node_get_service Date: Fri, 14 Jun 2024 13:52:16 -0500 Message-ID: <20240614185300.1086701-4-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 Fri Jun 14 18:52:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699051 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 2AEB219AA6E for ; Fri, 14 Jun 2024 18:53:07 +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=1718391189; cv=none; b=BDmISYadM9JCFC299o1ry6X8SMPGRA1vLRhEK2+442Q+9mo2esbnpGfRod4Tj+BRiflJ3HgJGun4haM72aU5L6im3vuktX88x3cgu//2R5Uf3B7QW8c5f7aZTUJZ+5FJyzlMrsNR3LTrHX4vfKYa6ySzwWZL746qXYf+qc7R62o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391189; c=relaxed/simple; bh=4q16BbxO6fjed1dn2u2AdrpC3TVwO+3TrN7X+C2ZKGU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EOkYSGoe+gakE83Uq3PpX16hg2BqqQDvmUw+VINUiaR65rVqRqwlqRTMPKhX58vLDBawdSvFSrBdYeL8vIuND/G56SSK7nB3kVyDgV7Ro6oTtPO9pSzJWX78aPEEptVghksCofNt6to4a5TDuzC3uXWvhKEpy5j3mzTZLleW/rQ= 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=dGOlLDCy; 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="dGOlLDCy" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-254aec5a084so1092651fac.3 for ; Fri, 14 Jun 2024 11:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391187; x=1718995987; 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=KAl9n1dEHVUscam0/QnIgDrTL+qOS224dgWo4XfdiT4=; b=dGOlLDCyDNVeSfSQd8Guc/echAuroPHGIUo4eEYVCaiMe6U4+bu+N6ucvgUOD0F6fI bNZwNmSLZdOsNRDRQEpEoUqi56UrbcAPgcEdgla/zNPjc/9sVoLNJYG5vEChRPj2ejTV oWQJPVEXzvQAyApUdD9+slC/x4tIAwq+yqF6M9JusL89wCwcGceTaA3Ryp4TY1UhaQWO ZJzKChK+dq+S7ayqDinOU8VunZMVksdlwaL4m//GY/mwiWtAcxAN4bZ1kBDx4oDts/sQ sJ4m4G4EZsiV7eWB1U40Ex+eKK/bKRovOkTksg37MpeG3xubgoAVR3ImWEiqNW1tFxNO 4q5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391187; x=1718995987; 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=KAl9n1dEHVUscam0/QnIgDrTL+qOS224dgWo4XfdiT4=; b=WkSz3iLx+1q5rydEYagYBhPSmY6ravz3C4c8ZxJfC5ccAZ445ShEF5Ac7dfX0yq/pt bSGfFZ+Evzne8NM8tJc7nzMQFDpwPIuqiJk24kVku501kj5c8ALFZ4xVaGzzPL9WLWWY QccO0y6xsb8bvLbwjnxPAd6mhk9HTab07sjvAppb7iwDcq9lQqTAOsqNaJ8OqiXwAFyv h0eHC9mv49jnpoZIY8Hf+KaGgKv6GlW0cf7n6DS6QBpgaBjLkq+Th4nOR5weudpUOYpV 1JQNaiDiMNZiBlV0tyP0v+jqEJtHrh27FkobP/NE5djOP61kG60wlYb/dkXXtMgbTLrE pySQ== X-Gm-Message-State: AOJu0YwuW3yb2nqbR1AO7cbP3FRWRO/gC6jnJn02deALHoO00T23r6k2 spUjpbsccPjS2uj5nMQcXlO7+0wda7Om/cM+nB/D6FkuP0TEncOhakz/bw== X-Google-Smtp-Source: AGHT+IGEmQX5vmy0rdheCsAW1Qxt1duMexVvWY+cKGeluwV51myqdu/asWngldXJFDmsPAXPngkChw== X-Received: by 2002:a05:6870:8a10:b0:258:7bca:3275 with SMTP id 586e51a60fabf-2587bca389fmr1790243fac.45.1718391187012; Fri, 14 Jun 2024 11:53:07 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:06 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 05/27] plugins: Add new qrtrqmi modem driver Date: Fri, 14 Jun 2024 13:52:17 -0500 Message-ID: <20240614185300.1086701-5-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 | 370 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 371 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..9ea87ba67c9d --- /dev/null +++ b/plugins/qrtrqmi.c @@ -0,0 +1,370 @@ +/* + * 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 + +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 + * + * NetworkInterfaceDriver + * 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, 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; +} + +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 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); + } +} + +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 Fri Jun 14 18:52:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699052 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 D24368C07 for ; Fri, 14 Jun 2024 18:53:08 +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=1718391190; cv=none; b=JJLfUaYYXatLe00BVBmhRgR5OoLcJAjR50DstLT94+Y0HwIG4Nz+HWSidYg6UxhihKn93QODe4iFk6eWctRcDRkkG6rmdFm9Csfud91GdIWivTLx9daDztfDymUUgKSX1biX9ArphuP/Z+dE+996msOsqWQLNlM1jEGCis+JftE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391190; c=relaxed/simple; bh=/bJIVDzUX2e5StEymqjn7ZCFKph0WNy6h/8JY7C7LB0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mlnAoj6EGBL/F9ANEDSqO9lJdMLcbb5hByo/aKR8nhOtguiEGA/ZYfoJfOKk+9mIWwwd/yh6DAKid8n8T+F/Zh2pnsckHi82wjXi8J8V4bLybnq9a0o0lxFC4cwifXqwE3824uXP9LILmks9BSOZ7LYE5/hjPhy6hgHxuitWXHU= 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=e9n8+hT9; 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="e9n8+hT9" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-254a2d8485eso1132102fac.0 for ; Fri, 14 Jun 2024 11:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391188; x=1718995988; 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=e9n8+hT9nQvdrLnpGHuxAKH9Arb2P8mXaEORHVAIKdA+mniusQqVXoABuuUHpjouLW IYd76aLv4aM8U6/FXMCz2P2bLm8xa8XazJtZKY83ONV1MIWMg672NQ47ZhaltDfaWrMh /n2ie0YULVMTTknJBErtl7hPEMA51/5rtKviJeqEKNLQizN81O1is6Wq5qSXtAzouymr AktcQpUKqtAGVPheLlHM5uyVkJE1i7sHspMJsM7pTpks9NmxNlUynM8CaR+GmaRPwu0n ws+/3iHjIrzPvFpcvwXAa7yf3g8WY6tc7QI6vC2WplFK7X+DZWoJ6PtVo/crbUkt9E3W JAZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391188; x=1718995988; 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=uYKwH6rIqIgP10R2R4+gAxVLwIkLfGPfMP2XIMUKJO2Frup0GyQQC4GGX7MTMsUJ2Q VvqOVQuAaA2JbPzta1UPgAA1v4VRzDA7yC7p1fMW+YsYnfmjJTZ26295agIo4KHR19x0 YSb3iRy5Y/r/RtzYMXWtws3zipozYHAafaCOvwATNtgTUXiUiz9YWCsQs3c2i8unW6Fj gBSj4jvjEnzNH55bqZwpiNZDrY2Xu1/U6nvvvEmQqq5oq7OL4kf0L0DFtlDkUmlVlmOq jxBfemn5oryh/vNQsd4BU22Z5e9wKutjaWbkK3n3s6vJKD7dEa2LqdJLsWfWFXCrnGkC iUdw== X-Gm-Message-State: AOJu0Yxqp+7KcpxEhMVutBz6Avv7D4u+yzyuZbAXQGb0+kLImQzxS1Ho agen0i1ubvio4cbgsnwYV/sQgkQh9g+xz7FIy/BDh0UcM8IntF7PohOVQA== X-Google-Smtp-Source: AGHT+IHD1bB6nLIykTakQpfHg4qj5ut6/EwmcQj1QQYgq7Lrdgxae75+Xita4QYp/AuTX8ZzkTbP0w== X-Received: by 2002:a05:6871:3a06:b0:258:365d:b964 with SMTP id 586e51a60fabf-2584287edf4mr3854899fac.11.1718391187693; Fri, 14 Jun 2024 11:53:07 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:07 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 06/27] udevng: Use new qrtrqmi driver for MHI and SoC modems Date: Fri, 14 Jun 2024 13:52:18 -0500 Message-ID: <20240614185300.1086701-6-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 Fri Jun 14 18:52:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699053 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 6C5351A01C8 for ; Fri, 14 Jun 2024 18:53:09 +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=1718391190; cv=none; b=hJroA2exkjRhdN2wW+7dB+uKUP/SJAexGiYLjPeC4F49mH+bi/hHvIWflMwsObpX0pvj3tuefXC/EMohIjkdyaas5JBRdCxMhMH6b6j7mO80kI2NKWHvh3BxU5o0ZLDsWos8Em7b9OrK34UHsHroZxn5JYlvS+YpzGwLnkf5U5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391190; c=relaxed/simple; bh=unJKtq2Z5x6N/Jk8IKUvMvgj4e7dYZCWPtDChk+1UUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G+SkkHLS1HD+7ZuWmdPOHW/0uBjBMG0snQi55CLE+3ATp4kxHODcxjfk/DrYOg+2D6FUZym6qcMcrQxruh7XPQklQwA4bxjWo6BqpOv40j3GpxEcueWAm11qd/llPi1TI8/Mar4vLNTzhooGv4npST4cfn4eLZQMwTTrSFOZfmY= 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=IxHMs8WR; 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="IxHMs8WR" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-24c9f628e71so1197738fac.1 for ; Fri, 14 Jun 2024 11:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391188; x=1718995988; 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=vuZHh0M1cxFsKwrdJ9/jNYZOjq41OL8YScOg/IM1mOs=; b=IxHMs8WRZWEnY977EKwq/0n/CybmqKU2rKKf1AnXHdWJDybjNl93q5sJEWRFSqK3lB X6cAYUAbi0FuBDk4J83WThV8tWfErpM9Cxg2HR8VZS6dTqVJp+7EI1XDufjJpDXSNRN6 RVlrhifSMcrN+lhgftDDXqY2S1+bkdhs8VsfMK0pQzgPbeQRlWD+WzjtSDRWBBKNvrho ULM3CtVowRdsoy6ZZ4gqDBylW7zh2k4IwX/M/EVqbiLy4T97CJmCPXieh8fAKgI0r68i qdMpK3nnUZ7ccl7d2/2+nD9qaKY15zZteqpwoL2tV97QsfGFROxXDQtxfZdo3hE6v+Qb o8/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391188; x=1718995988; 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=vuZHh0M1cxFsKwrdJ9/jNYZOjq41OL8YScOg/IM1mOs=; b=i8wVVm/Bj2S/dvgpi7aKQB4HHKzaOdAZUrfp3eCq4Qcqt7FwOeW6Zl8d0RJ4y6zZMj nRv8J7TK6f/uxEhzbJQEv+yqavA6AnniNC9MtXMf3sGomLt6yZDkY3zWIBXei58BYDmT 1teH2gEOeiS7EN1L02AH9HEbu8Y+8zd8Be57xrw1cTVhhikdhnEPElLlf/pGAYL55GvN mz85IzPRT0aHXxDWTIHcv8ZHVskjou/r39bAtgTEKjSqk7ZPQpD1tb7wN9knAdRJDRPB /S3vncifbawNxqt8KNaQaBYvuZYgC+45B2NqxQq1AA0BatwbkqSq58m4daWPDT/A9rsr k8FA== X-Gm-Message-State: AOJu0YxO6x2+43HLOV4ch1bwLuoZam0ppw55THHTxSzliU7Fe1gSFLOL ZQKwJX3CYTbAc3MFFlVpX6WHpttE87JAS3OGVTO0lDdvTWM782ktYrMx4g== X-Google-Smtp-Source: AGHT+IGCcVjOUoaq52ykqUR5tw5RdMq8ujWIt6cH7ncgsABPhapA49R0F+odcNdjvLvrX2RUpeD7sA== X-Received: by 2002:a05:6870:1c6:b0:24c:a547:7b5a with SMTP id 586e51a60fabf-258428b6ce7mr4265337fac.14.1718391188449; Fri, 14 Jun 2024 11:53:08 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:08 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 07/27] gobi: Remove qrtr support Date: Fri, 14 Jun 2024 13:52:19 -0500 Message-ID: <20240614185300.1086701-7-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 5402bedcc22e..f1a7df447a89 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 Fri Jun 14 18:52:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699054 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.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 41EA91A0B06 for ; Fri, 14 Jun 2024 18:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391191; cv=none; b=MYgFqwJwkPivpbvSXW0/wZN8b/VkmVNfWl9HgDie1NxpNq9W5JEszYS4GokKXO4+10JTEe9sV8LqofTrxAz+Lw2g13lwSaUG4XQMBgWliBsKKYdTYM5jOmEXuMfcl5HA8s2Wvugb7Arcgz5+oKHzip8Kk4MW4Y343gi4pm0bSgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391191; c=relaxed/simple; bh=Y1PdZud7erIXoShijODcPVTJniAFQD+o57VgIzmdn1E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qofefEi0KmJY18uiiiAg+a4kxvL0LcT+pXbI1jiZaufopi2hDGIUOVvDycEMNP4bNKd43vH2AJB/y0wVw2yTRByfhz02xOiLtOg0dpVvA8Pn3UQXzxkvWO66NPhHg1OnJeoFF/Rm5blqvR6n8f5KGHbEtvNPNqf12/j/zQAiroQ= 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=Gftwm8Kl; arc=none smtp.client-ip=209.85.161.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="Gftwm8Kl" Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5bafe063f35so1490108eaf.0 for ; Fri, 14 Jun 2024 11:53:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391189; x=1718995989; 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=Gftwm8Kld/VFc6grK5evWR0RQINsPhzFWnbXxGr/V/jybfBEHDTWLCL5rnjF4i1/tl VvTEsH3ndYrcZjnqjgGashnZZXF88bucwbexlkEru0dsD3p62GlH8pR60fVrA/XdC391 jnlGwYC6ek3Z2RK5VFLjRh7Kz06zudlNC2KsQI9BjoB0+uJNHUozhoUuof8TU1D0/fRr icyn9xlpbPcaYJCSSSUqE3yRHrLx1HuVEDptRhnghtiMKOF5+1gSHeInRHApDfoLV6cg z4ryx0kHBkpWFUJKyvLpIn/deihQTedYmwDbrG3gMkktj2/znifcOX70gk71YB5xQhuD 8njA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391189; x=1718995989; 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=wCZ5kBZDAQDfYWmIPFSxf11rudmiX7UJsVgANGo1BeJOt7b4BoStuCvS55/4jx8Ux4 bXTGC9ZHH7kNH6usJbubVDt1aQBPqBy7YvmADhQ1qq7eBqnh6uZhOIQNh9Jr4kxQRgT+ zQsIW2kL87yHpsEnAAExR6WT4HIZ3zk4x0UMIlkm1pU71kfejDotkvbpvuSbPXBuEFQk 0P5/nLiogX8Gp/aal0vtulUM/Z+tFaJ0Z19lsKRzgOzpjWxJSCnjaTRAa69+ElFhWsXj A4cz4rvqEUw4ogKHVwbexDn0l2HmaTsrIIbTf9NNGWZ0fAmj0P4bJ+VU/oBKmzW/onwR E53A== X-Gm-Message-State: AOJu0YxtL7nVlmC39ha1WTa/sMNenjhjSvT4fHlDD1np5YrOM09dq7Su nJy1I84HInG7ha7hr8WpREpTjHQ7sP5FHDQMDQSLPADqn9Ya7g7WqVwyig== X-Google-Smtp-Source: AGHT+IFTfoigqcPyGynZC1K7DscIars2g6PBg+hlNsGgFPVcSKE2OZsSahsdohlWCh7wvhGu4ApnOQ== X-Received: by 2002:a05:6870:c084:b0:254:a2c2:d3bf with SMTP id 586e51a60fabf-25841169f9dmr1980170fac.28.1718391189144; Fri, 14 Jun 2024 11:53:09 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:08 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 08/27] udevng: Do not set DeviceProtocol Date: Fri, 14 Jun 2024 13:52:20 -0500 Message-ID: <20240614185300.1086701-8-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 Fri Jun 14 18:52:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699055 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 123711A2C0D for ; Fri, 14 Jun 2024 18:53:10 +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=1718391192; cv=none; b=LuOPE5MmoTindvu5EiBhnek9fHjins26QAwI9uq3dVHAdnc+d4brjTOjtrpGYNXYeq7rMvKbOFHHvxO3TocQ8hA2annzxT7kIQkm7z8khoUX3BzLe/q6SUoSoJwiHdP/uhJgFj+o3wecKe8HtfmOxg5lndq/LKHv6oC0fpm0S7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391192; c=relaxed/simple; bh=rPM/i4e7JNbB0GoUVEilA/feGaIkpNm+nSVtOMNo4+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=akBh8/ZTtncALNXpdIzNHqKB5EcrGD0amwmIBKi/7Ny3YBDmyrA1wOZ9X5S0lxOFE48XBNNwvcsI4lePKf2SJCBCjchqbwa5WeEZS42E3j8aoM8QXeqfQzgG7uNLwRSPeWWKqTwnwUWjKMxp6+heLd26bQszclU3E/AiHNu6YdU= 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=OwR6go8m; 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="OwR6go8m" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-254c8e27c80so1312039fac.2 for ; Fri, 14 Jun 2024 11:53:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391190; x=1718995990; 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=OwR6go8mO38FcSsBg8B+9pjrHtoraQOf+oQ0vfaSiWmycThRXpzyxut59KKuLqwYkc ZV5urCyfv8CH/r3pOEUzsdqqW0P1/K0fUPd6GaOal9cVfIASpmAPx0Mpvc/IfUhcxz7q 1j2WAuL4aBicCLQMyZz6fk/ShfKe6kzXOMXycfD27dYfkBKx2YQoUWoYpewxar9rGfAu UHsfivYIty37nZ8WR7lCPY4YfeNfyC6EaAZZ9wDQnHe/e2CJRNQh9NAXN5LLHEgGSTn8 p+61Vyn8rutftVfss6FUbKjGl4sYAPdzTICJ/r1aknb7/z6G+URwQcCvXodXpEhzIwxL ulTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391190; x=1718995990; 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=GkTF2dAdXs1LhwtJllTzSqpDi0JzwJEO9oeOUgusr5fPzNMIaBkg+fgrHcgshMPjwV DTdPwAlc9Vsk/lq2Qve+gLju4IBj5Bp8wPXsFG0z+ET89DFQvC52zZoJ1DjvjfYX0tkW F4h/DkTGV6IDACTa9dIN7Oii9cjCNjNLAqbGho0SGG/H9PUptNKAw0FFOzjmMVcJ1zNE BqB27AlOP/i60bwt28dEkxolxZg1MO2h1wDPPPoVCgkN3BDSPGOoTKN6XB9c58ZVizCR z/Ty8/E4dz1Qf9TUfkx+rO8l2eMPwypE0rJlUJFcEeoTTEcqYOpoLQWKIXCLR3BMHRQw gJ8g== X-Gm-Message-State: AOJu0YyB+HhAbeCvJncC9HMJeq6k27aiu/shLyyLDTRT+cBnESOC3JjE 5ztQfMu4Sncec+wkYO3+th6CrCuS4JSKWstPQyqifSEnKFlhpCNaYp8rjg== X-Google-Smtp-Source: AGHT+IEkYaBEgx4nNXv7vT21qBL3v63Nt1rTqELFToR/svkmcjVQZoMJZYn3LsdCtBBAhKTbjW5evQ== X-Received: by 2002:a05:6870:6391:b0:254:c8ad:7355 with SMTP id 586e51a60fabf-25842911546mr3688111fac.22.1718391189901; Fri, 14 Jun 2024 11:53:09 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:09 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 09/27] unit: Rename device to node Date: Fri, 14 Jun 2024 13:52:21 -0500 Message-ID: <20240614185300.1086701-9-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 Fri Jun 14 18:52:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699056 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 92AD91A01C8 for ; Fri, 14 Jun 2024 18:53:11 +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=1718391193; cv=none; b=m5hy81JRKY33UqYpf1ExFDZMLTSlLx+vipKVNvJMnzqExt1iH8TEpuKZHK995Ge4HZnx+qSfN8uGSOfRWV/OAhWBaRSf9Eb838ujgW46oBIpnmQFBcTv4XBOj9NAE181JJ8wLXs2LGfnZ3JJAHHZ7DlgVmLr/NCEW9zg01wzpt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391193; c=relaxed/simple; bh=CnaUHbd+gHYm6psoDf5u7ar4m1Serw4kpQI5Z7uweg4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bchqa4nFGHPRg8cNd61axEDCuH6GhoESFJ2BGJRCTF6ghNTqFUAGdpMWgvjh+U0nYT5EOtqsmedxlIyyURRzhVe7DhW8YgdV+3szNxcFJt+Fvg0XmXq8FWZKZ6Rg9gfWivlgKGJHagLOgZrBewQiJJh2NGxqh1RXOqb+jqXcnA8= 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=P2GsPQHy; 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="P2GsPQHy" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-25837a78858so974513fac.2 for ; Fri, 14 Jun 2024 11:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391190; x=1718995990; 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=RLpspu/j8y9gKGIWMaeZiP8O4CXBeT4ATAY1Sfxgiok=; b=P2GsPQHy2oIF4qMHJ35r+Z3Iak8yn497kCW028wpANTHCuf01ULGXRXi/QaKpoe6eM 6lvKG4eCYZaN6YxiVPLBuXOSXhSD4UFPonXkhmj5avKfSL8TnSlLetNzxZNaPvsv+dUg ljbKpqm4yopd6XAFJHF+bOp2xBvH4g4RXK/ZU7qpAa9O1pdsKOHwZ2JCjpDjzUlfm5cn /q+TpfKtM1fqTR90Dh54AE54irxIwNX/2GFG1RY3RGaNw5B9UrCZmWqMKMWtx/dOWHp7 yjczYq6bP0Tom5pJa+kwWLjOQB3oizN4+tDjAIcEsgmJuREpBjqD44RJKIQuHQbSaElo vUAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391190; x=1718995990; 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=RLpspu/j8y9gKGIWMaeZiP8O4CXBeT4ATAY1Sfxgiok=; b=FVjIH6Y8hGtfEMk91GMGy5g1rdkQrme4tVaTqu57GTMwGlbCjvBO/jAaZ7yLiXlk/a GlxEwzc09QWr0QyInNoZhQjygRiAajdjLoT05nwr+r6QqVE0Sqo4vcCO7NLKwPT+yZbF lIdXh2x1kEi1RLUWGmc31KDjJbXacfpLjOodtD6SPRjoEZ6W7+EL50VqLm44QUbQ3WKQ UhCgQRSvLKspBvEm49ib0ZCMwvd3SG7w8ut/wHzRnXQCdAVlhoUXSG0sA726mP/sXNd+ 0erIgcsmIm4aQQ5P+nP5eV+kfmAh13m+urOrfEaWSkaOnkp1htitJZk8gah3nfRa5xvC cyKQ== X-Gm-Message-State: AOJu0YzQuv26vvpmCCcgWvsykExVvKFmsI3bOHiZS3swlCz4pyxGg05w NA/x7abHy4MnHNQPdFtbEXzZprVD1S98ZPCgsJdZQO5ExBMkmZTnR2b3HA== X-Google-Smtp-Source: AGHT+IG4DH+p81Wo4xh/91HuU6lrIzVsqu/KUyy/9E2r6cVeVrQWMNYSPAWf0Ut49ReOFpF+gadUmg== X-Received: by 2002:a05:6870:5e4b:b0:254:b455:2bf6 with SMTP id 586e51a60fabf-25842b83883mr3578164fac.53.1718391190562; Fri, 14 Jun 2024 11:53:10 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:10 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 10/27] qmi: Rename qmi_device_new_qrtr to qmi_qrtr_node_new Date: Fri, 14 Jun 2024 13:52:22 -0500 Message-ID: <20240614185300.1086701-10-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 9ea87ba67c9d..1c503c2d6cde 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -206,7 +206,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 Fri Jun 14 18:52:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699057 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 3506219AA6E for ; Fri, 14 Jun 2024 18:53:12 +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=1718391193; cv=none; b=Rb+X5WdqYl1KMUUsLXFpku+dqvFeUMLkCzep/XBSF+nPy61I3H9mJnsFskQs5cq8qB2gUaiyQxnr2iJOMJLb1GkqipYU7xtR/yKGVNBX/Xr2KE6x9vCUpaqSDvjCwuraSuE8dh1JVXg4L3XWrmlxk4DEkmKq1c1oM89r25w4n+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391193; c=relaxed/simple; bh=KO0TMU8GKGboG1T+32gX+hOuvWlXrIOh5uVrj3vo/yM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NcU+LXukMtAoE+Xyauc24QZ9iKWIacTQuWDXVqayhFkNXqC6ooSP187MxfpxzUQusKa/mjP4/iaC5H4Uf3hSsv1b6KocFa5ME20saLxR9GzGHdqkvTqgQIRKrcHig0+BIJf4mSt984QJ4KH0dDY2aFS3d7SevDqTcC0GJnD/mmM= 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=QrQQuTi9; 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="QrQQuTi9" Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5b9a5be6668so1305878eaf.1 for ; Fri, 14 Jun 2024 11:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391191; x=1718995991; 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=PwkZ84I3GxsG5ccjbIaHjk3a2DD6fG6gmqg9Dv4D9Is=; b=QrQQuTi9nLQfXOC2xT/jFP6CjK90VwU8gzPu+nVrAMQvxdavX7ucs/s5i1hyqJsR/B NxCdld4jz3n7tUkf+RPTYungaF95raPbVuugnfZA7aaMSw3uwpW9nkJFPYfy8CCzkQ4Y q1fjHs9GvzPlgsgpo1azkDj7g+jNjN0Gjt2UzhJG+RNecT8qBWTkbz79pk83JgMBRABt RMPqKD7mPVoJun0T7Y++Y8J94PWqOq25sR26zLFfjXPjStZz2fSC8hUPpglD8hGdW7Lv q9HiVASU2C5VAfr35jBTB/VZM5RUBlWwx+c5N6PH3F7kg2mUocKyz4+tFm/GoFPnoHA8 FxFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391191; x=1718995991; 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=PwkZ84I3GxsG5ccjbIaHjk3a2DD6fG6gmqg9Dv4D9Is=; b=pHi25BM8ZaVkIdWOqF3bsHJFwSkxt0cxuX2lfbeqN/8GwLDfoHw8JoUHi2njswafgk gCJhfqV/Jbc8sJN9wxJij3EvRr4U8PY6VwTZnoRoQVoh80PfpzuzI8+H/W5RCL5dKuFf MZbnuyYiKiFxSQmSBLQII8Kn1yBhasrzHIDChNYMcAj+zeN9bbPjrDKkamGGF2p/Gl5Y 3PlJ37lHeu1lq2IF8G8SkONfOj0P3YmcH9rObpK6BEyddx0nGXdz5hxJqCAjBjCnQVU8 n8d2KCIvmkp0BgBpuIz3zwvirX8llZ+n57jkfmVE+mNRYRnzn6vMgVJHS4NTJQtLO88S hqyw== X-Gm-Message-State: AOJu0YwsngYBC8sgSJEJMh3MomdrXR1N0uRGnjm5Dl39vvYHOcARdbfl wPDBeHgE0y3WOnwlfChRnoriBtb24TslYu1cUJLUad0EPmiwWnVumFytGA== X-Google-Smtp-Source: AGHT+IG8PxDH3e/Jvx+4u5F9C5yu/T4M5EIjmZPNCLKW9ddxYQosyF6SWIT2Sm1j6iYxZSKuuyo//g== X-Received: by 2002:a05:6870:9589:b0:254:7f9f:3f21 with SMTP id 586e51a60fabf-258429989dcmr3933815fac.27.1718391191232; Fri, 14 Jun 2024 11:53:11 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:10 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 11/27] qmi: Rename qmi_device_new_qmux to qmi_qmux_device_new Date: Fri, 14 Jun 2024 13:52:23 -0500 Message-ID: <20240614185300.1086701-11-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 f1a7df447a89..cbdf5adb16be 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 Fri Jun 14 18:52:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699058 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 CEE761A2C0A for ; Fri, 14 Jun 2024 18:53:12 +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=1718391194; cv=none; b=Ksh8gQekz8ZWmY/NXB/YS/ocSI4vNfQpk6nvLLp3mlCCeXkmYzFFrgh6jNuIDpe0LNMNfePumctccfl09tEyuPiRmqnkGP14Gye2cGn08uUyuAiyxRUWd+KfcLd1PrLZ4Tpu2RX3Iq2L3cZiTYmPVjFA3arKhOzPAUBbJfhOVcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391194; c=relaxed/simple; bh=+zhDgJw/D82iGKx28eTwBX4xQruzeo5sOR/AkeOGjoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U6tY5EH6xnYWDs1hQzz5bgcdw0o+DoenEWE5MJtC+9cXBfXdRYpiSDdLEKkaY0RsOL8/5RUvuR7FBvgOLqEa2qQ7drohThBfYaS0JKl1KtPFHJJ2X42kVlBVUC8Gk+rhfJ6q63a15TDM5Ygbx50v8lHLbhHWwE0RRkBL8SZ5Ytg= 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=XGaYP2PR; 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="XGaYP2PR" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-254c56efe06so1221031fac.2 for ; Fri, 14 Jun 2024 11:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391192; x=1718995992; 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=XGaYP2PR86V5OisMxLGDd5qeOMI0FYx6okzvpsULt6feWLLTj29XyrMWgO6Caz1FaD Xs+sYPJZmWum6UHfXnNsQQQJsye/C2/SWR57nvRMzvQeXw+xS798yO2agvhbfk6bYAlg tQd+no+iuitX/YdBwELQC8C0zr+KIVXleq3/7ilquDkxQPKK4r9v4RqMx5Dj0oFBkvRc JSNYu/W6qEzDQgLt5OZZvkO2TK/Lu6ggwGeFtJAKGgh5EPMQhS7XutnZKYe58IXSeZuP /q/wWA+49867f+VY73+gQ6qfnLWKCSKmMVV8DdKlUA/jw99di/sZ9wSQp4+9rDUev2g8 qD9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391192; x=1718995992; 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=pJ7vWJug6zxYEsuChC8u6BrD0y2xbUf/iuDYxB2mzKn9tk4Hse0VP154zf7ybxquXc sXV9wemMp00qCicNz52y0jgqAleYySs7y1fZaYgbqwlAMgBkFjH5cwShwS9LHJl+Xmx7 l2WjfrqencSNUxlDXAJrS3nU87LHcBRx6ueKz5f76djmKVbiwArnufjnidR/lyQlyfQz Tnc9ZqyhoHD0uVJaJpwaxEsAWC/299ZdtYi4Awx1Z51WkImIGymVvn5nnOTs/rPBQajz 9T3+NX/s1gBOM0GL2ubbFUjOsZBBqGCxqhiT3BLfVlXStUOFNunBEojZuo3raSuv5rjG s0/Q== X-Gm-Message-State: AOJu0Yw4mDZfUoHqirXqBw1f+E7VVQvdoGMPTRP2JJUMiOBHSSXyl1Wg 4pk7fJagNULUthjaglJ47Mbx4PO1RBsd5FuhoHNVTzY4dNfZrvGBCBd2wg== X-Google-Smtp-Source: AGHT+IHZ0yPZ5l8sJdDD/qr4Qq6nShKewCFixIT4UXuoWDSTZwRA8nah6vsml5tVARaj5DL4iK5Vqg== X-Received: by 2002:a05:6870:8185:b0:254:ad5e:da48 with SMTP id 586e51a60fabf-25842b2503emr3868460fac.42.1718391191839; Fri, 14 Jun 2024 11:53:11 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:11 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 12/27] unit: Drop use of qmi_service_create_shared Date: Fri, 14 Jun 2024 13:52:24 -0500 Message-ID: <20240614185300.1086701-12-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 Fri Jun 14 18:52:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699060 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 DB6061A2549 for ; Fri, 14 Jun 2024 18:53:13 +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=1718391195; cv=none; b=DYUbcVdN2CSo1xXjNI+DrzcdWY7YJjdaQx6ohr226DwpErl/aKPMqnfTzS27T84YOBxlJPdfAdx0gS5uQdasz+NJ8A0BZGwPpdsxx9OW18CYc/yGnP840YbN6yYPzE8eXV8IVrsLtbOmT6nF3xRa5o1VnUyY08wPAkOYbpYuczY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391195; c=relaxed/simple; bh=ImzsCDzqyGgN65A3OmXCqFhOzLU69YxsmyQBNU5hV2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bntulfeX4c4nMhTz+o1pFIfy5b9R86D9uUNFT49weReKdI2KPe/xBGYNjhRym2yogg415l3XjvvhF8DWOGP+G1JaNymQjzxOMj7CxmWMEIPo6i/GdVWW7j/r4h+KH4agH2tqbx9wwbJ9k1v+A2odzSLssyZ2uSN/5cyznmTT7WI= 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=TMiadOJ+; 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="TMiadOJ+" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-24c9f630e51so1185038fac.1 for ; Fri, 14 Jun 2024 11:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391193; x=1718995993; 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=rQCVF47WQhcxxbQVDpW5yEFLnoYVuAx7597UdxxAoU0=; b=TMiadOJ+JvWgOMSaD8jkvx5PPsniMAciiXv5nCwQ7opvHQpI4P3FysWKmGjkJUEH0l /4RFyScjhhqKWbCRFMMSia/B+iBIgQg7ENvWuT4iKXe1tN+WFtxUVrt4IFDcRb5Xy0Os e+XAEOpW1eKPWgBbYd26cLN6TkT0+auqPnBnFB762CKgHvvoWipqXR0T9GKPI/0CXU3l fk0H+HoNU1K0OYZF50f+aTfi9aTJQn4lUCRrDG6SYkc4b2nJUAljdfW666oB+VrGSNO7 Plhh9crgnNazSniuG/JNEQbxdBiZuS8CCYcscxT0DZ9V1P7/MZjG64XTm8YXqlAy++jO ++5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391193; x=1718995993; 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=rQCVF47WQhcxxbQVDpW5yEFLnoYVuAx7597UdxxAoU0=; b=IwhqzFox89Dk0VuhPNdd7nQ/WL1vHM//SJN+TU9V3nEdAiV5K14CDMhvb2QpYL2SXW 5zS5yFmXVWwKZFgrv5Amuu7xLoXfrJXixpKblUkegXmheZaSVpNxgjP4mDdxBZo0cPgj d+iXNKvMsIJEwZvqky+obkV7q+bdh4bx9I6NiRp3MqFl7FfkUw1J77Kx9pZVRLv+w7HT GfAiknGmKLO578CpF26uQtZnqBsqS5WctoyjokaumoOgRLDbtY8EWrOFuTMWyDUtFzKU k+ASSsxXuPm3JpHeqqX2v0qdV2MjUy7M+vnp8aOY/hcIB2n+q8Od9UXFmcK5dWtZK6l6 wB+w== X-Gm-Message-State: AOJu0YzREXskaNWtMDEtDFUti4qEw8KS3OmWGJngqQWan9Gg0hzBCijS HUCHuzw2iAf4BLQqRiEVdWmLLjqRfuVKVCRn7O1XhZPSsNOF5QA+4crwpw== X-Google-Smtp-Source: AGHT+IF+zORtYsKbKBiFTpzOfQJqdj1CqBqfmkHm+HVw9W4GfhXjfk/hw3HZIc1zDPDhdOgnhwD1wQ== X-Received: by 2002:a05:6870:459f:b0:24c:4c82:4f15 with SMTP id 586e51a60fabf-2584297b8a4mr3995689fac.24.1718391192540; Fri, 14 Jun 2024 11:53:12 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:12 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 13/27] qmi: qmux: Make shared service creation generic Date: Fri, 14 Jun 2024 13:52:25 -0500 Message-ID: <20240614185300.1086701-13-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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..625771d986d5 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 *); 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 cbdf5adb16be..56245a496bcc 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 Fri Jun 14 18:52:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699059 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 2C3FB1A0B06 for ; Fri, 14 Jun 2024 18:53:14 +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=1718391195; cv=none; b=XIxux1w8R5EfYWIwJSMrIqKK7u7ij4ZuwOJbRfNiWbexA/6tg8rfGbCLNnhelf8YPL0R7yLGysDsQ2r+LAOGDSdvFeu1W+FXcZNt3T9QourTsFfpflCLqmIspA9Nh8EX30XZtuamasBnhQEp/GOgby4ax454wXhwlkqVIRE2gwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391195; c=relaxed/simple; bh=OAIVS8QwqGVIeKGqP7rMgVdWxTgRaJ3OdwBOvMSArrg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CfKT5AOqF3GLFPYBXFUchs+Sguan9Ek6ZNgO6wfvZI4gc8SwfFx+ZRrlcHcebysB1LJjHBzYQbho61nz/MUol/Wc2alqcSOmGyCR44qrowT8nBzrJtme862+jHaIRjXKB+wkDeWg+7bdWtiCS9BjrqyyoVUCBVCirPMeNTQ4ypg= 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=UmriTxsA; 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="UmriTxsA" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-25496642859so1244391fac.0 for ; Fri, 14 Jun 2024 11:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391193; x=1718995993; 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=ubk5uOl+PM1LNRYmeGTECHF8NNImlpu65iiTeF6gQI0=; b=UmriTxsAbyWwBPhs+UA/xmzdzjLTTgGZbmidO5G0ZoDWqaaSu57B+oLlmTJHSRUzbh 9zEeYl/vce6SRmjy3h82RBCtL6JuLOhhMnnurYHUAHzGJMq7t5cFmsVyO1Ac0p5QqpIN ggg8cp/iDlBZPkZ95w2/95+3gsNzSfZxEgSe0gEaZOo5ndkeyBqh0PA6yvKhhIba+FGi abfOfJUQc1FDDskpn1fRR/YtHk/hych8CehyvWXgZYhcUq/r7LMeKHADqnZnJB+pbeZG 5FWGJRZsRCFi2OmZcRG64o8/mQs2DSv57ihez6xqVkdcLk6u7WRLU9SJ59AIB5/Xwk0b PB/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391193; x=1718995993; 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=ubk5uOl+PM1LNRYmeGTECHF8NNImlpu65iiTeF6gQI0=; b=wYUVWAS9Hxty6XK26awBKB5XQmgUDA8g8z8URlf+vryJLt3FApBSK3ctZ20959sLyZ eMeWdwv0/50346/APSG2IXQC7HJXG3pjqa+0SH/N3ffTdozwgFYB7LvkjhEOOvxkF5iC JqF0ttCswFzsAx92f1ILw6HiPSW6DdRtYC3ePVs+lusHUb6O+XPDJmG49ffgwTBeZ7z4 hHIaKAb6ShjBcX6NNk/PAdBcOBtcEqh9JXnXNFdow2BwbNhya22rqN6Fp6aYg0L42Jz5 YXxUzontMVf/0Y4ilhyF7rsE01vJculAi/o2On/1m1B1jYnEZ1z0K9vqijjfzvK6WG9S fPZw== X-Gm-Message-State: AOJu0Yw2Q2juD6IOPN399+kNwX11ENvo2xkLhhmb8Msg92sKlhTvFT0R 4Pp5MU5YFFJ0ieszo5GmEPjrOzsyVydNVmntdlLWGYklK/mKt/JcgNzRjw== X-Google-Smtp-Source: AGHT+IGkH0TM9HYkaEuZZ47R8MX/SM2Ygtij7f01Y4NPjwVe+q0mCn7kZWKigUJLMHP1Pdm9uunqLw== X-Received: by 2002:a05:6870:891f:b0:254:8666:cded with SMTP id 586e51a60fabf-2584288e4fdmr3662553fac.11.1718391193198; Fri, 14 Jun 2024 11:53:13 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:12 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 14/27] qmi: Rename qmi_device_get_service_version Date: Fri, 14 Jun 2024 13:52:26 -0500 Message-ID: <20240614185300.1086701-14-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 625771d986d5..65fe0d56e4bc 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 Fri Jun 14 18:52:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699061 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 253B51A2C0D for ; Fri, 14 Jun 2024 18:53:15 +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=1718391196; cv=none; b=X1WSuLjzzV8URNqILoO8MMvzcgWKL7peNwjo/lOROiry9GBWZ5wzzirxVEzp6+Jfs6FnegqtOXaI4ngTpLQmrCRL+yQPWCexsuo9rQDPCnyNmy6RxoD/7iF74JSWeEU4do3dadh8imUkTgFqTYgcy06ap5ArPFi/9h02kMpeHgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391196; c=relaxed/simple; bh=I1CQjNSKE1xedYxPd1hRE1/8IHQ1KxbrVocsu63+LlY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CJf2SMxkeWQNIu5MvJhjjlM+eBuPYsaZjd9Ys6kWlGp3P4NmR1B/uMJkWLI5vOKmA71+1ejpaIU1HfQSatpBkzkH9l3+qMgt4jZpXHayzvecQcTTTm/LCKAuZeRuVswe8VQcwnSRUArmO9oRRyXcJSg8aU0CNmMMYIOOwKl68Z0= 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=lWcjMCnv; 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="lWcjMCnv" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-2547e1c7bbeso1251983fac.2 for ; Fri, 14 Jun 2024 11:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391194; x=1718995994; 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=jNzPk/sIxYazZyUBDJ20Joqqf1efnIiXezANz7ujrfk=; b=lWcjMCnvOOl7+fjRgHaLHkN/FRQuiXLqBWOJq0UE+DbchwoslbmAZaYArKvNLDrbs0 U03XyCJm5ywTyVv4K3bvCBWdEehPzV2dMxlj437uXTxBMpDuDX+kTc5WcEx1SV1LtROd KZKBRjpwDLu1ai4/9OS70oPgUE8RadH8NuyUtJ9I8lxxEMIiKbA8zi05ipB/WxWaAX0G OZIzFXCzve9+/QVIiFhTsd6u4rpWSrqM6R5yGvogmIZyrDrz5tXpE01L9iopbF4VVOOA 5Zy5a3hjeF/Gi98HLpPUtm5uOyduEoJXOoflD5d18C+iKF8+8bf6rYuC4p9VauGLr7Dz LCPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391194; x=1718995994; 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=jNzPk/sIxYazZyUBDJ20Joqqf1efnIiXezANz7ujrfk=; b=rBqU0O/zghYgxt/bbzH3hklytym5A5hE+UH/n7VD1p+QciKmOgO1MmV5SrvhcSnUQm x/9Y4jwlXvKiq34LbyjXpo/s7ick252UZ9yEsRMjjV1H/cqz7uYAgwtMHwWy/mrD3RfC Bu6bCmqid2+quXbcnB9rF5Qea8cX0KJlV8FlsIImdS6jvFmiDvDrApHne+7Flsijh1f8 vY+aYCdvMsTOY6uGivuZfcCXxe+FYUldHCdlp9qiWE22DLLlAx0MtB/Lbwyv1CSfPxBs MHuDJwcazXgnnL6NrDBkj+uEePAIkWFG5q2rjMOBqjw8WP2RyHY2UyYmN1dkdd2mcSqj fXvw== X-Gm-Message-State: AOJu0YzDd7RSx2t3199Y7BoQCL8Xz81qiqQVvTdE4sLcl+p83v+G+Uby IErFicIyqbEM/PENhJNwM7ckBPA6rLnjzqgbrkYoVw4oU2TmyIiwC/Y2pQ== X-Google-Smtp-Source: AGHT+IE1sYPt5/pi3pM6phmQntUoO1PFPq8pQChC85EEngNGG9FdXXenLivkmepJ+ZzNfqIJUF1dog== X-Received: by 2002:a05:6870:1586:b0:24f:e427:f684 with SMTP id 586e51a60fabf-2584288bcc9mr3656311fac.8.1718391194131; Fri, 14 Jun 2024 11:53:14 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:13 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 15/27] qmi: sms: Require at WMS version 1.2+ Date: Fri, 14 Jun 2024 13:52:27 -0500 Message-ID: <20240614185300.1086701-15-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 56245a496bcc..59b459beb995 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 Fri Jun 14 18:52:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699062 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 087FF1A2549 for ; Fri, 14 Jun 2024 18:53:15 +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=1718391197; cv=none; b=B2pAMlGr/BNlhueLVdvdmpstos03Lrbr7I2CXRW/Zfnb5ZocSKiMja+ZwYsi8Hu/xP9zdaLFezfXGlddhZj0JEGAMEvMB5EyjZtmzjr1iIQksEiJ6iidgoqorOj8BDoslK+pk0P1wuFIFampFS+qn1OTywtqBEpy5mOnfcJaBy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391197; c=relaxed/simple; bh=/mi4MGlLF8/XlsUgO17PUk4L8xiJsC0dn9+1Zui2Wrs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IL17nfTZqFamy5u5OVAP+x9OSgxHenxcKeWc6E9nDtqWTtzroWeIc4164/bnncWPi5dxTTkAMgnFEwgfJEEbqwSX6BtFwJQM1D1LLpW/i6D3yfXDSCFv5T6WkUEdcv0NVn11t/nmfKEzpbQ3cwU5UxhOVc5bDftemDdNsJHL/kE= 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=i2T9wJ+a; 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="i2T9wJ+a" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-24c9f91242dso1043080fac.2 for ; Fri, 14 Jun 2024 11:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391195; x=1718995995; 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=VNlPm4zwFTGp7ZIoWdhV6v3B9oY3qoHoJqVIz/U4NKM=; b=i2T9wJ+aX2EumDmn6wH8K/yFSnsHTfAiOlq+dPQauZgM+iys+U8CoEEyVyIrAobtxF wlg8jfLXggcWqeelQNT430C/KP05jPHi/y1uSul22CyHuselcg/6r8pzRiTstV5Ksoyw 4rR7F+PgkqXvUC+W8PEmVadyHE6+2Bi+VhNCVRtaN1iv3wWM7csbzGglSIeJ02WMLxfv SBdrdLVp61sIEqEj5ZcVpxcO/cxYj8CkF+nYbkuVuNChZB/xObhJtt3aJKC7IduGFGQw p9W/7TcH+saHp4Vlhs0eCBUmLkdwYjAKbDRiyioICtU+4vIx13ee0byzQGKMpSkEqihJ ElRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391195; x=1718995995; 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=VNlPm4zwFTGp7ZIoWdhV6v3B9oY3qoHoJqVIz/U4NKM=; b=qcrGoqyQ8yTdamUc6rhc/kmXbcAON/0iRgX3EU6MNIWsWZmhTd6RlkeJT2SY+xqKvT 2KQIQHkmXFunHvLtnx1rx+tc4LFRHsptf4Q67pRB0gkggT+h1+ghMStJHUFWoy76dUki DWkFoJtxD1eudo0qOeO4Ff+lf8hNdO4GvbW0TjQGEj82x4utN/biEm5yIu0I51ux3kMx kQf57f7XoqB4IKVr6ZNNpcsZMxI0dBVCtHKVBpmfBEQJ0+tWFME3OGkhOz2H0eYQHUOb y7tJqknzGc0VCXuGLXbugCuY08zSBbe97XmgghtjjWIPDC19WAyc1ZjrkI5IE7yH49Ar oEdQ== X-Gm-Message-State: AOJu0Yxy2BOQwGisVT+e7cJIohABA5kZaQF/m0cwlzfIuomo9Vg7ekJE BfsDW2JPER8KriFai3DZm533z3j37NNQKw6H3sTUV4LqnWJoV9x7dhYy3g== X-Google-Smtp-Source: AGHT+IF/6sgZCq0aC8fDxJLqI1gyTjl/bTk99r0xYiE+YCycL9NemwxEqiE84bc3VXZe0wpYeUPB9A== X-Received: by 2002:a05:6870:452:b0:254:a386:f029 with SMTP id 586e51a60fabf-25842b79513mr3604628fac.37.1718391194925; Fri, 14 Jun 2024 11:53:14 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:14 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 16/27] qmi: Rework qmi_service_get_version Date: Fri, 14 Jun 2024 13:52:28 -0500 Message-ID: <20240614185300.1086701-16-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 65fe0d56e4bc..0d2ffb61fdea 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 Fri Jun 14 18:52:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699063 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 D375A1A2C0D for ; Fri, 14 Jun 2024 18:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391198; cv=none; b=bvxDjNzHtxybzjV1qmggBrRRQ6v47ofvoJCfRUrPEUbGCsDnOH8utKzhHy/WGrx/oULi4KjvHy11Wn4IPaCvPWGNwAE07yintm68wDcW88Ca2asEJNjUXhb2TN9auJmAncJncK5pOVQ8220zz1jNfUGsKYjvDGhdH5CWR1NL6ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391198; c=relaxed/simple; bh=dTKmPOhj1w1qTStuL9Eg35eghgMqPlj+0vy+Ev6cEpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s0sNkbyQ2vRX+J4TudJRh9EzZriSvcxiSTphFI1EKe3iY07SLRxQvWQxb5eZAUFWfJ1kFYYurIgLnb7qyh8qGSgKyozKn3KvcJhUHwFmLj0lAEa9qWFKOnZ/k0MILm7dqwo7ddGmOQLB47cwJ/j/ePT70aBuKHLW3Y6uSCaX4E8= 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=QoETcK5q; arc=none smtp.client-ip=209.85.167.176 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="QoETcK5q" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3d1d08c7c8aso1398367b6e.2 for ; Fri, 14 Jun 2024 11:53:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391196; x=1718995996; 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=OhygGDyOl6XKQmM7dvIsidsD2U4HXrcOkyr1vR4I8+0=; b=QoETcK5qR/E4X9qfJb4naF22oz/yA2MIDxf2udE4Ls2ZpBd+8wFj6r7fy89E7/lTTq GBmQHfTo0s9OsqRkW0IPP5BoMlNT+BSvQGUZ77RukZ+zpt7CRT23wcxOs4CA+rqqLXR1 dWB0lCsZlNr9kPJnmC1o1lgPEqPJ7LHwvxoH8Qdc0uQkYBQJv6NLj4OfjeFOFEPQs9xd nOiW4FwLXHGnGmaE1QeQDgkaRgoqB9Gb6fFZ4xDmaH5+tHzdLYQ+vNQ4WgVxfITtOQJ2 LTiicYNIGf/NMVOHJNkAT47ZPC2sxIix26T/bCa/UQqwCfpCZ+rIvuoDo3/wxlVtRPjA rICw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391196; x=1718995996; 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=OhygGDyOl6XKQmM7dvIsidsD2U4HXrcOkyr1vR4I8+0=; b=q9CtgW4KX/pHv0V7SZbteISGCc761wPyVPu3eCAhsspiEfW2kf7bIap2MNKEfCYmH0 ONmdBFIjk+QdDmNJHaDjv0r08hKGIcUVDUkJhOO9JQP6MEuNjXiBo+3BdtzfhwW15lIx klLk9FZ6bK8wl7ALJrFQLpyYNlEhsMqCPvDM30SBZ3W4Coz+cZj4i5K2eW8nStsTvrSp hAf+4Oqzagh6tpZmHFV7YAQ4qPMuyk4XoPbmp9sxXLg92cf5aOfl8W9lypfUMGjpiPur cOxu6rtdGlnhrT00ddsCgK/xe20vKCGNk4dHFIyw882G3phfA/cpd0p5xUh2XdJzPBs0 WvWw== X-Gm-Message-State: AOJu0YwG3Q0MSNzpyPLCxcxTBuOAJ15qkkxpSq+23jyAhzchSxdQNsaG C80hEhBSnhaeJ8bSIUBNyrZW+NRLFnpYcS1cofI7gi0KdQMpCE2Kymqakg== X-Google-Smtp-Source: AGHT+IFXKbnhT0rANyakY0IIIS/N/xF9JaGSLAi4+oFZE8The647T895LWTodQD38UussA0dfAJWSQ== X-Received: by 2002:a05:6870:fba9:b0:254:9625:79b with SMTP id 586e51a60fabf-258428de103mr3619169fac.20.1718391195678; Fri, 14 Jun 2024 11:53:15 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:15 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 17/27] qmi: break up qmi_device_free into qrtr & qmux variants Date: Fri, 14 Jun 2024 13:52:29 -0500 Message-ID: <20240614185300.1086701-17-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 0d2ffb61fdea..35ff62ff5a31 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 59b459beb995..49d3ae2d304e 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 1c503c2d6cde..23fd6e165bf4 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -111,7 +111,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 Fri Jun 14 18:52:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699064 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.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 8F5CF1A2C12 for ; Fri, 14 Jun 2024 18:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391199; cv=none; b=V+xeXSFCPNYx1u6NwiWm2j8ZGj913qZXCixaS/3Izll0GH2yUU4BN9ROm+2YKCJjC9uRo38K419I3Lodh64oOUhBeG/ywpSiSbCeE9TeprPzG0Ibg9em1fVVF0K6DN+bSV/iRvrfrUuwL9Lwyz5ioNr9hz+vAtUjQRRXdieypu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391199; c=relaxed/simple; bh=pc7fpAsAsiuZxj7t5AR0cYq1vzfBL8gcVddY2nGjWy0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XmiIXvs0RaiF95T1xrmiCvmjFmz33Hkml364ykm4tgdkvsLbbFSibQcw9QxkWxlDB3rrsiwxKwlAXnTjureapcSwM7Bl00eUWPPvcE5Hr/EuoyRMKORk+dq7wPl2jSIzMeMojc5IDOJhrN+4SYH+/bJGBh0c/P1fHWMshEzc9rA= 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=FEXEfh1i; arc=none smtp.client-ip=209.85.210.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="FEXEfh1i" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6f971cb3c9cso1315378a34.1 for ; Fri, 14 Jun 2024 11:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391196; x=1718995996; 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=FEXEfh1izyllIxjxMAJm5XLNIYQR9wlvynhgitNaGiqRE6npMzeh2z6x844avJ3OF2 cXgJDDbfOGPSOi0HggDeJm47coPKzCOc+Sz++WtbwNG2btG6XnR6HkK1BFIaASFONK6a zX6FgxZMX+Y4ii5YFi1bONp1p1SAJHYzyxd5q1EuW04HUyzCNljGg0tI5qIHQI/1Ku9U 1FNPMNfQGJQOiTX74uX6ta91WjRHI5QLvIPux1VqI+y1ZKO9l26tXj1bletAUyG06PCm Gn3iVuZFOsXSbujPYvRsChkuXdr8ciQDSD0B80pBNCBwO0L38Qqet6RonEfZQiMhpSXa OcLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391196; x=1718995996; 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=kx8UEi8/t7wslhKhdu4AX4ZDeU89iKyDVbH4skjQ9TSbWEc/DO0a1FyFcot+R0FZ32 Zio7892Q0aj/RyTQE5268NZ+yEt3I6DYRoyRC8q5bbUeIiqIRqkQeBZR6Ewh2ED94Q5U 32GHvvIyP7v4tEgDwaqZQyrtmAbPikbVowrFSFL/vm/KbPwIp11DIIsaOl2HKQxLH00B rGVyADu/5RKHMlvQQSwveJTvAXTXcFcZfNfQPwZ7fmIT7DXjDCN22YpdddK9fFTq0td4 eolSnqJspJjtSoY57qPZ0DYTtAGuqYagUdENWdQD+y3gE0OW2Qk75XDhdW6gzfCAmmAB zXMQ== X-Gm-Message-State: AOJu0Yw7YoO8l7XMMUGq/nh3usXF2MNvhI7HNE5IRFSNcHwRzkhJsRPd mQfafqloEiJSFhHW6OWGLrXqliioMSN5hMmS9t8PDWGwhiZdjPHs9bg1QA== X-Google-Smtp-Source: AGHT+IE5Kf6WIWw0mi01BfYYlhyxv1kqYKNB7Qm5Kydcu9AByiKsAFjZsSORFO88nIRCfI8j0jDYiw== X-Received: by 2002:a05:6870:1494:b0:254:b1b1:7ea4 with SMTP id 586e51a60fabf-25842893a01mr3813727fac.12.1718391196565; Fri, 14 Jun 2024 11:53:16 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:16 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 18/27] qmi: Convert DBG statements to __debug_device Date: Fri, 14 Jun 2024 13:52:30 -0500 Message-ID: <20240614185300.1086701-18-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 Fri Jun 14 18:52:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699065 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 755BE1A2549 for ; Fri, 14 Jun 2024 18:53:18 +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=1718391200; cv=none; b=bZS8JEjKLBSqPBTPdNezuE50pJFPJsyxsy4z1mJ7kpr43M8PeenJvjRKalNFt/uqKyQETmZTJY9u+kSSYEaz06WwpPE3Ik7Aq/PM8FgAQhfXb0jR0n9XgBb2q+wBBnFwB0OUuixV7nSoPIWCJA9JeFkVF9HnKkwldYC2JZ6ls0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391200; c=relaxed/simple; bh=IOSSPEsrM/OLITmDh2NTBxrbpPDfJKakZCCI0xeT88w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rOrvfr20UpCdTtY0PxGoms1kzGTBjBid+qbOOHRMSxS96fxh0rMHinv0Ay8iwfICedl4ZbwG4lnP0d4GHlcRTcYHFofqsXJSE9GHOaQSr+jKjZo+3uoDvNigpYCbu2k/PHc8GN5ATz03ljoMryA8lwg1IAzi7uJn3yBsxip1dyU= 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=Oe6U+c+N; 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="Oe6U+c+N" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-254871388d3so1308070fac.1 for ; Fri, 14 Jun 2024 11:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391197; x=1718995997; 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=VVHycapvYITiiND0J/6/uj9vqdmYFePERDiu/TLhv1w=; b=Oe6U+c+N7lD5R5ueiTCyzo9WvQK2QmwE5+qg/UTvdbwyoeJhxIzHJOHPVXN7xwwgtT w/ynRc4Dj8J1IFp3i8lJOO0dkINLrYl4lJEh8VOV5smOD/Aom0BzI5DXTW0qLrA76EGV XBezTMr5wovhTZ5kXpkPvy5G9Rx9GPgcHeNWw/q4+puCqIWkx6j9Q91h2oTudR3UxIwH DzZ++A2WtpnUi76igi+IaCvkp1AYY1gi8qM6Qy2rqOUgeuIG55OfQrCz6eq1hBsUZVgu k7z+h+4NFZWbOpt69UEd1FpGpdGbzfMW24GO1hvhwhsZzvMhMOiTf6uMsZCVJmyiO3dg jVFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391197; x=1718995997; 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=VVHycapvYITiiND0J/6/uj9vqdmYFePERDiu/TLhv1w=; b=QAOXWzEjhdKmRXfL48P5v0cc7IJoj3UGA+rUkdkjN7LRYnPql33Hy6MDBR2KFvokQF Zh734xtDUiEI9TuOIhaGRpMbwUq8XOty5ohCFSa3l6YiFy23A5UTLUKStG3+5KcJm9/s O/uiTu8hTUkLcqvu7y0Y4HrNQ9CyGQSSsKVLJK0kMPKjbGyqH0KuU82ThbYcHyh0Q1cG 0qYrOtfnV3naH8Z0XS9m2zERhUPx4uMwdNacscB9JFOCSIue6H8O1+c5gUJOrykaWha9 R/XGVo20QLTenMdLy+087MCfb3FwILQn0GoCmnAqLFY9CyV5GXYyJbesadjibGsvM1Bt FD+g== X-Gm-Message-State: AOJu0Yzt70rJU/f9lize1HTOYfiXqgQOorypn8oG2bK4Hj1jI6WDbGrj Us+DCiqdUZAIjHrQ+yNkRdH1J4M5q79sHd0dn60qtB10K8gVpElUemIMVA== X-Google-Smtp-Source: AGHT+IF809N7bxPsBHnFR80y9qmwAn/JSfYgbnyxRcNsQrMTInNLiKWGCBm1l4wMe6/jRi2iaZO6Fg== X-Received: by 2002:a05:6870:14cf:b0:250:8141:9210 with SMTP id 586e51a60fabf-2584288feffmr3502033fac.9.1718391197208; Fri, 14 Jun 2024 11:53:17 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:16 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 19/27] qmi: introduce qmi_qrtr_node_lookup Date: Fri, 14 Jun 2024 13:52:31 -0500 Message-ID: <20240614185300.1086701-19-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 35ff62ff5a31..68d5cca6d9d2 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 *); +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 23fd6e165bf4..6765f0644e98 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -213,7 +213,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 Fri Jun 14 18:52:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699066 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.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 477C81A2C12 for ; Fri, 14 Jun 2024 18:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391200; cv=none; b=VEVXv+BWk/vs+/WQZbut7gcXmF+wFtGfPIaSDBc6z49V4b667YR9jzppDG1afIfx+twUqiyLcyYMfzbI334xX2pltueeaDDWQxFcQdysXR8Lzgq6oxUrw1qubjR+xIhmRARJc26C2cjEBtSNPMGhsIkssgxrM/de7G2nzEciWUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391200; c=relaxed/simple; bh=VzB/c1omH9XA1ThUVtQupOYmQCyr+02h11Mqfw/kLC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FWRpp7k8MEtvoOvAiEJ9a/tvMV2g0aH8oyU9LIlq44O7Nkl8X5wwtgPCIj/Mkc2P8DxgofB6AcjZ/+32YUiCZ+kaisU/BVGCU7hCiHB9+987cSXWDHwB4DobCF1uhKZ2iQ8VnAijdO5SdUrpoXQsl88GkfoQOMdG2deba4wUTXg= 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=U5Vmg8si; arc=none smtp.client-ip=209.85.210.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="U5Vmg8si" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6f97a4c4588so1418942a34.2 for ; Fri, 14 Jun 2024 11:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391198; x=1718995998; 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=bL74BORxDwFs5wgKMHrIl90ZJbffbgaf2EFTPeePqC0=; b=U5Vmg8siMVFcX3g5MFlzwRL6Plk7b0dR0NUgJgRsjqalymMMx/5qLm6lhEszogK9HJ j7YSLelqVh+7kwzPxiA+2QzslbrRRlLQUqHwraE2XpM+44bh/r9mZtEROsYRTS9gOiHo Ao7IIjJ/fO6K94MoIq+aRvkz3Qa2GNkB7PYZzDQ3kiftvAnxtD9SYeNoNSoCJwl1N6kR NpCSqIeG6a5LiRXKwswA9Fd1+ybLDyR1HrsCmkW86FqUFUk5Vs10kH1FzEiSazKM7d3Z wFJcOojMRnDUjIiZ0KxkSbrxNzGW7IwebwPpYVdbrRDmhBPiYTpDbxHQms/BKAQ2Uy2B jdjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391198; x=1718995998; 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=bL74BORxDwFs5wgKMHrIl90ZJbffbgaf2EFTPeePqC0=; b=LHsYbxOuSTRJeBjF9xvf5eZht8Wg4F5/SaSOAjnXnQ42loCSHT/xncSMcsvINRjwuR l7f8a0ea1ylU07jHykCBBLZe+chXZtI8Tb6ZwKv6bKLwCc47A+8Z88ETCzwodWJCxf4q 8MWYnPeZl3fvK7gihbhlaKQC53aCGhUSXEeLen4c+tf8ac9rqrT0HPvEYk7LDk3Ap9Ip zmYIQ49I89mgk3WRpr2TFFCHFSQLvp0cs7y7EBRznbG1rKBXArs4U2gtN762giYhM+Bw W+M7hxSg7Fn2eRAYoFUeSumdsWpcU7iLxTenLx4dSYXas+sNZeS0khdi1pMDa57VTW9d Qysw== X-Gm-Message-State: AOJu0YxX7wnzL5ymHMvFhF7q8HHfyo4Tsn1ymUfaW8NfFQiJTbEb7rk1 sT02y253YtZvRUNqp2hltSuFad95mQ0et2PB7ZCZ4yH2C6tlpc8G+sarBQ== X-Google-Smtp-Source: AGHT+IE1EzWkDon2HLlfcW4GaS9O7+1v1uz3GT7BlSYV+xQDOl4k0JUIactn/2gTDYrW7Z8muIdDRg== X-Received: by 2002:a05:6870:f69f:b0:258:42bd:d916 with SMTP id 586e51a60fabf-25842be0213mr3969438fac.14.1718391197797; Fri, 14 Jun 2024 11:53:17 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:17 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 20/27] qmi: split qmi_device_has_service into QRTR and QMUX version Date: Fri, 14 Jun 2024 13:52:32 -0500 Message-ID: <20240614185300.1086701-20-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 68d5cca6d9d2..b255d9b83a3e 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 49d3ae2d304e..bb972977ce0a 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 6765f0644e98..d3aee5f4f4ff 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -184,10 +184,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); @@ -323,7 +323,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 Fri Jun 14 18:52:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699067 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 DF81A1A2FA3 for ; Fri, 14 Jun 2024 18:53:19 +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=1718391202; cv=none; b=BnajxQUa5/nAMI3Wild+9p1bK6xwrviVaGOuV6Sq2Lv9/rIhk5S8vc4Uac//yFZ44eqFwUJEav0iEUGIlGWDGSbA6wqr5q7sVE0w3xmhPIyYacx4V6vBGWOMZeo/FCnVWS7icuIZsBTHSVfMycbN1ITHWQFCqmazupSjKVY+hLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391202; c=relaxed/simple; bh=zPDlb02fJL/DD9cwHwetPEFmWq6xL/Voz5O6BZIEIy8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MyNQ5TZWvbE4Wieo04c71/BDy8fgqW2xY1gcoys2jcnRbKQvxSfDBeJEQ0Fl10UELfg/zLL7AjNiLCdduUeWODD73UDbk/45vrKonTCW9Jl/qaWUyqbXVL8e1dkruzpvgp5TwI2lLAx2eZ13CeP8UwNTvPWPM0kq/36BA73RmIc= 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=frK0W0Ix; 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="frK0W0Ix" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-25528eb4078so1319203fac.0 for ; Fri, 14 Jun 2024 11:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391199; x=1718995999; 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=bshcXeXSDhZFRgatMw1P004sdpU765Buy+jcTDZJ0qY=; b=frK0W0Ixi26ArR9f0qGyIuYkpCk5+uVsVy5lucynqgXW0Q+n76TsYOdHA307Cfn11Z 2Ac7f5vabYpMGwPMbYuY6F98cvTQjCMuHeqfbw048S0A+NOnlXMC8Ofn5LC3nRVpm/jM XWKAFmCx2CK67RHQVL5KyWnFajvoUgkxea7SQTVUjlazzqexs3c+1YajigNiVIHLF1RY KuhB26Elm0nag7uVaq+1sMEqcV93jyjjVobg5dTgpS6140B8TC02Aa84zf9rlq75uL8b AgSFGiK0N0LM8vln3iF/4JUHOcEXAwzKfmDMtI0vfPgX38gpUhc9vxil0G9ZD3EA88TO SNKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391199; x=1718995999; 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=bshcXeXSDhZFRgatMw1P004sdpU765Buy+jcTDZJ0qY=; b=egFf6GQK2DqMrmhiWCuk553ljyIvrLypGlj4YLB+0NGPEMBFE19hBK0hg0I9XYkO5i 35NgTKm2pNHc1KfFhmRQ/gwThl6RtB72Nqn0J8ejvrdfBMW3N7Gvj6qej2uAqFsUAGyK Ed6uq3sL94VEDDkaa4tfDviscLgPZWzmlBEXPOTOeqFt78kFumSRMU+dtkSTcKYylFVI wyGuebo9rF3vNRuScN12csnhsha3KFMTpwkXei/UUPGLzrOC73sEN8JfFEjHGn061Y7g puPEKqyWSKxXINbhpxzCfFjTRukAQp39QGw/TgrWD00N4Q5uMOV1x0HXZeCq7ICt4pEu KdXA== X-Gm-Message-State: AOJu0YxOoG+mbRfC9uv7w2bpT4P82vFSaptjlU47qLYNKl/N/rXip2Nu 2NGBbyfgy48TSNECPuI04zU6EJixVpMe4izB/jYeCgz+2JXqWkBOQhaiYA== X-Google-Smtp-Source: AGHT+IFjF/d7Lex2uD3/+BmweNYqXt0bP85pwnqmBgvufkvZQNPitAJ0MBD2LHIwcG4q2LyOYd3xAQ== X-Received: by 2002:a05:6871:295:b0:254:ccac:133c with SMTP id 586e51a60fabf-25842ba2085mr3796419fac.41.1718391198598; Fri, 14 Jun 2024 11:53:18 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:18 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 21/27] qmi: split qmi_device_set_debug into QRTR and QMUX versions Date: Fri, 14 Jun 2024 13:52:33 -0500 Message-ID: <20240614185300.1086701-21-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 alows 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 b255d9b83a3e..9f782478311d 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 bb972977ce0a..422a853c4c7f 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 d3aee5f4f4ff..6a7d2687791d 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -211,7 +211,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 Fri Jun 14 18:52:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699068 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 68A931A2FAE for ; Fri, 14 Jun 2024 18:53:20 +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=1718391202; cv=none; b=eeUAtNBHGK+3o4Aoj6k0GdNGhZ6fsrvuN11keAuPBUUHCEJhJwkYCK4KKWCrzItiF9lfxU6v897ltNVnsIaBUTaynqpQl9E2Z+06twhu1lDvKD3pzAH6zFLHmv2DSIbtUM4/uLs2dcbNUVDvyhFKHB4KVHBYlrRa6KZsp05T5Nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391202; c=relaxed/simple; bh=hOuBVc5SYYpWBWRPdxImhF/TDsHped4gL2RV6xjl4sc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OdmIHt0jF7ziWAba4NtSeg88hQyAfojQhexzErHhQT6XXr2nNbTvEgNuWU1TCFg5H8urLpHwYzyUIt+Yy6cP+RzVNDvBhGvAltcjbOcI3bHOKjTJGHfq9dPdTEMYrVF7moHzQX1pSUsMX6A3EFHAYPNJwiGt7yXNqm8sXWbyiEA= 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=Xza1B13V; 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="Xza1B13V" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-25606692f1bso1199856fac.3 for ; Fri, 14 Jun 2024 11:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391199; x=1718995999; 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=ujlbPzvyWCWqEcJwPfjmvZTtdTRap+qKFDHWAAKS/oE=; b=Xza1B13VxO6/Mjk8NIF1KSg5MwlRjXDo1m+lp7ePeiTCUrIqScruLYq1kF1DmdwhXz LWxWN/13Jj6Hu8fH1v5rDFC+8OHSwxm8tffYg99HbVhT5D5WeBdTXg30dv8kql+Yin2j GFKpRO11oyEZvyKjbUYzUjO1+YfCq2SLkFlIuYGfRzVyJjCcYbIhLYRKc77KjPG8L2dK 5aeLJ1AxBJFYHfr2sSY83QHYD2j975AvyFFlervbR1DVEn6TtDzxYdjzaZXZT7qy7Y6U et7ure6WIjD3LNofwX4ZetZREFN3YUoFg43Y86ZCHnFB040hsrP65nh7DLT4D90p8zKk +K6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391199; x=1718995999; 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=ujlbPzvyWCWqEcJwPfjmvZTtdTRap+qKFDHWAAKS/oE=; b=aEwIWFlxVNMDAr4JOiSKeXF/hkdp2AM5IWFAjL40L+gIdsQMKf4dGPgHSh6dNYrWJe /NCa530Vi4EPXqzy2EN7iehEdgf26mDwNY8RDv1wFumrLY+KF+KXZ21ENvjPKY7KtMfn 2UtQVX2tW5TVVHXChB/OkUiYlsIAJZlD2y2ucyjO91mzCBlDS4SWY8L5bCtJEE52qZmw UUcWfYpYKHoZQrVH7qP8aNbvSk4LGj5mQUkbHyV1nOKJnMKKuFFPU0WtNqp0Dqi7RLZt n3y2vGCfkhNy4qYfyq+jfQz82PcNYQdQE4FR0iNSC0YHfAI+9MsUGl2LykFkPreu/h0D 4QPw== X-Gm-Message-State: AOJu0Yy0ck7k+dfhSX7S1Kxxehv2YeXutVG6K38ncX7lrYJyzuNGgJW/ cdRAuRhqS6cOWsS7KYPfRpyx+5dNcYCs7wJmnrzeEkF/4T2qn5R1LPwXyA== X-Google-Smtp-Source: AGHT+IGn+v2OdOZgMz6VVl0xvbfiplmviNWhN73nRdVB2/IEcvYl4jG95YwmCgzvy7Bs5+hUUcLYNw== X-Received: by 2002:a05:6871:294:b0:254:c842:46f0 with SMTP id 586e51a60fabf-25842c3d914mr3542371fac.59.1718391199243; Fri, 14 Jun 2024 11:53:19 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:19 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 22/27] qmi: Make qmi_qrtr_node methods take struct qmi_qrtr_node Date: Fri, 14 Jun 2024 13:52:34 -0500 Message-ID: <20240614185300.1086701-22-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 9f782478311d..02924f805bba 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 6a7d2687791d..b389631502b2 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -43,7 +43,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]; @@ -180,7 +180,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(""); @@ -283,7 +283,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); @@ -305,7 +305,7 @@ static void qrtrqmi_pre_sim(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); @@ -334,7 +334,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 Fri Jun 14 18:52:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699069 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B5D11A2549 for ; Fri, 14 Jun 2024 18:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391203; cv=none; b=HByBwD7pV1ctnp4MrsdQd5Z/hQKNGOvE/ysRgTEb3SVVQYUz2ai9p49L52Cm+OKP8u4uhhyNObbHdmMSLYhYPgf972HuysmzgLCw8ttYB5+Qt0v0szVLyX3/C8qWsNd2SeL1JAAf/UphUgbhAqMUyHsxlrqtmnCVKIolUxPVLOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391203; c=relaxed/simple; bh=WBE9HPbSajYoDJgDK5MzFtluRBmbO0zG7WgoWBQpGrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rZA1+rgmdA40feSnDoH1pR0Ho9TY2/FtkNdU592YqCF6pWw93B3QbzuM+oGPg8w6v+8xAnGvHd4gosYlSjqKugdySLRheUOK0l2WV6Ia9F488Dgd9ZD0rE2AqmDuX3qeN/n0f+H66HaDPii5Eni9V+ZIwtOw2JX28I8uHAD00v4= 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=UnMyci7X; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UnMyci7X" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6f9603730d5so1338362a34.1 for ; Fri, 14 Jun 2024 11:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391200; x=1718996000; 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=VJQUzN4O/NLx7GggDayONSbQhWY+6wzApJP6fwYg/Ec=; b=UnMyci7Xq2ibupprSDP5huMcbzfcwLr61faYsyRsiXwfDoUuRcpPP4qVdpcuRMy0/5 Y5V/rwk1e+Kvl/AQo9avh2tmVPdJJUbha7jvlMBo19zZNnyopP3B1r0xiC3K1rq6w/cM 4RjJR2U8F0G7giSMFXLSPb7YLPycHDGm2YhiQXANrX9vIFh6yVbeRCnVRBD3k/p4X3d0 Cv1HpXPNC22KWDijdsir5xNGA8II9jOHKCiOS3YELeyYYudWpmjSx1NsZoARfZ8QoyR9 JtsDI1lrcFiivChggzcLbzqY/DudyxsHlOmUG5b6O/w8uSUMRHhaVJNvW78AqVYsPELT b4mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391200; x=1718996000; 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=VJQUzN4O/NLx7GggDayONSbQhWY+6wzApJP6fwYg/Ec=; b=TThjblzW/dTVsAlI0pINBesnZ8DQ27dq4zD4jebqTMWwg6hT59rpVDmIHpcw1czGbo IMxRoUEJDAGsoCyfgkvVdXXgg/79PXkAoiVehhor4IJwMIGsl22lVxlalNBK1FPXytp2 pmxWLDuy+FNBLB+oDxIt1RrN7cLDX4M8KknM2WCaq0PSseUotpfb604BzIDVUHxqVqRu wFakmuQmHFAinCIXd6ttChCtgWJjpXlCpwwtWyHuruDhKrBGAfoQVTdqiDdHSjxU9u8k 6QgaUU22vjxr3ulYPxhiVN/FkCjX3U+wcmG/R4qws66zqoxXtUMlMCzHotaokR0fZiYM c8Ng== X-Gm-Message-State: AOJu0YxdR357vUPGqusSbmXz3zd73MGS2uYu7F+6xz9ULv0Pb8P2y6S+ Yth4MU0x0tH4a2WRhtz2yiEjMIRNDNzC+k5I/jd1Z1iBsVn/Xtjl871sEQ== X-Google-Smtp-Source: AGHT+IEJhBTjK9i34YF8XZhp2WTO6QsnzsVWIwxIRqehh3H74msiPKt2LBEFy46+oseshXPphakzJA== X-Received: by 2002:a05:6870:c095:b0:254:7cd4:9092 with SMTP id 586e51a60fabf-258428eb176mr3626654fac.20.1718391199942; Fri, 14 Jun 2024 11:53:19 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:19 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 23/27] qmi: Move expected data format handling into gobi Date: Fri, 14 Jun 2024 13:52:35 -0500 Message-ID: <20240614185300.1086701-23-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 02924f805bba..702e8c5006b5 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 422a853c4c7f..9c44c887b08d 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 Fri Jun 14 18:52:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699070 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.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 A8CAE1A0AF5 for ; Fri, 14 Jun 2024 18:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391203; cv=none; b=b+pcXQhaC5/5OPQDukDypPBT6V7s4Yyte3zbqZ03Hcw7FyKBSCfybIcqQ4Qe2mQOPHtNEWjTjX6LFHbyrNUkfqXC1apt95mFx0cPCUYvtW5NQ9ae2Qxvm5gbUqJdPVJzk+BB7+WtHZYHFe6eGghe7hUcJz+Lxej8dHvmlpgenpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391203; c=relaxed/simple; bh=ZJxt1JkN3G3NHq/Fc8wZAVKaIQoi2Pl08EGPBCj2768=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XykL2L0YMLV7wZ6wZHVk+MNJ7tiJCZ5YMBNipnLmkF7qy47F6PJ3ssL05Z4pzXVXYwjrtWjrqfbZetbI9OBLQz64/BJHMlvTm3IwPx0dXTSeAIxQBoCr1MwlfGM6ABXP4gCcabvpReto3zkUV4erc/0LVye/Tnsl3gjnetY4lRU= 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=PdvP/v6S; arc=none smtp.client-ip=209.85.210.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="PdvP/v6S" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6f9398390fcso876075a34.3 for ; Fri, 14 Jun 2024 11:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391201; x=1718996001; 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=I5X0oV+jFH7Tq49MDbeHyB5hDlVv1wpG74hFAgCd7+E=; b=PdvP/v6SeoYEm5q5r9LtTaHRlS/L3bn/wZsj9Of91vW0RUnsHKtYlO/6i2xa9WF8Av eyc5892YUk1/7UMzrADB1BGfyw8vKoeEEcaNYzbmdIx3ZPzX4Gf12r0R2xaB574OXM+Y w//QI/kk+QW5hwDBIZFI2CX450ny7lB8JGmssiBDnZ0a2EQdg9b4BUtJ/m9O+sOyaGwQ 0MtF9lh4gZaSlPBGEYoiz+NCZauEoHnzzxMEWTjJGK55mjwYRahQxNFKYFHRtgtgqURn CTvE7qQISWPzy7aOu+JNX1/JH9z0Qq9aiFe/bN7Y3aHmPfnJsrY597ECyJAs4O45g3mp f1LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391201; x=1718996001; 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=I5X0oV+jFH7Tq49MDbeHyB5hDlVv1wpG74hFAgCd7+E=; b=Pmk1kXu2xGYiL+1u8WjINUYTAlKKr4YPo599IHGkXJ3YTepBig8VELwXvJCYc1Ip3w h0aMcD0lHkSeLdH0z5uO0Z4A9McWbmTRHx/lfzO749UctxQJcLkVTOcoVsiEESZbGDVX cS9CBPLfiydE2ufDSc9P5UenqsEXft3DE4YfS/4Qq5jLg69j7zRU4Pi/T2DIYsn+yI9X yuljJs6+j72z53ilAdUKGmoI8CzlPHyiJnbedY8ivmzftLHfNd7S20YSqcw4aIPiYCQb ZSGlLdW/jUthHYl6DIF6cUvnBKEnKhDxuZU0AO+/biW9pzSZ6ZAiywMnPHZCjl4rn8il 0XNg== X-Gm-Message-State: AOJu0YzNV/XsvaT2Y+/n23eMjiaA0zVy2v4twbIRCygVWM10heTWoe+v ppqRL83/j1xDzvh9e0VYLLOSVRf2yc1Lsbxdobtfy6eo6Hv/5rB++xALrQ== X-Google-Smtp-Source: AGHT+IEdwRQkePNcjVE6WNoL/2/i6k1nX5pwF4ekCtMQJ+brQqFV2nN5JfeS1RZoXYKGP+eT4EiNIA== X-Received: by 2002:a05:6870:c095:b0:254:7cd4:9092 with SMTP id 586e51a60fabf-258428eb176mr3626675fac.20.1718391200636; Fri, 14 Jun 2024 11:53:20 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:20 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 24/27] qmi: Rename and refactor qmi_device_discover Date: Fri, 14 Jun 2024 13:52:36 -0500 Message-ID: <20240614185300.1086701-24-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 | 152 ++++++++++++++++------------------------- drivers/qmimodem/qmi.h | 7 +- plugins/gobi.c | 5 +- 3 files changed, 65 insertions(+), 99 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 306ca6092e5c..5576c520bb08 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,31 @@ 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); -/* sync will release all previous clients */ -static bool qmi_device_qmux_sync(struct qmi_device_qmux *qmux, - struct discover_data *data) -{ - struct qmi_request *req; - - DEBUG(&qmux->debug, "Sending sync to reset QMI"); + memset(&qmux->discover, 0, sizeof(qmux->discover)); +} - req = __control_request_alloc(QMI_CTL_SYNC, NULL, 0, - qmux_sync_callback, data); - __ctl_request_submit(qmux, req); +static void qmux_sync_callback(uint16_t message, uint16_t length, + const void *buffer, void *user_data) +{ + 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 +1307,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); + qmux_discover_callback, qmux); - data->tid = __ctl_request_submit(qmux, req); - data->timeout = l_timeout_create(DISCOVER_TIMEOUT, - qmux_discover_reply_timeout, - data, NULL); - - __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 +1555,9 @@ static void __qmux_device_free(struct qmi_device_qmux *qmux) { l_queue_destroy(qmux->control_queue, __request_free); + if (qmux->discover.destroy) + qmux->discover.destroy(qmux->discover.user_data); + if (qmux->shutdown_idle) l_idle_remove(qmux->shutdown_idle); @@ -1658,7 +1623,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 702e8c5006b5..e5c99ab8b674 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 *); 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 9c44c887b08d..483495972843 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 Fri Jun 14 18:52:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699071 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 AAC331A01CD for ; Fri, 14 Jun 2024 18:53:22 +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=1718391204; cv=none; b=c2pml7RCBvV39gq2d3Zsbg8O4hCI2tycg0ilCA4M8FpEdwXbKRGWP8O+55kshhtBr31ZsM/3LZD5iLUfUvu6QB4TEpt6GNdrXFBDlbk3JgAR7gZzRGmeJ6RUJG7yqKDQYEVRfpFEPgA4GU00I/c4D6PYva+ANYAfTxvRVDxy1Fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391204; c=relaxed/simple; bh=I/GnzEojX7m3CBDzhJSB4Lb6fCN+4ddKa+QODpVZWF4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cxZVqb8HJqUod+a2RJrkp76OZynl0vgfOpHEVHC9bhgxZODTu7obSbamZmrr2iTMmGtWKNJJphbwI+mFDjoPrFwBQDRlU2MImlWLxjj0PkM8WKbGtaWag4GfzPvE2AGZ1cmcEJ2CfOLl/Mz7s/eCgSrIRPAFSTO77dg5dMswa2s= 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=U3DZoDwR; 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="U3DZoDwR" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-2508320e62dso1185386fac.3 for ; Fri, 14 Jun 2024 11:53:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391201; x=1718996001; 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=pbkw3gfBa7pDv5LtwL2F58xHAeTu0x1hEm/aJcvSENY=; b=U3DZoDwRzVtRkDBKAFich/HEGU/NxGA44Sm2VgmhM7hn3JbOS4osvlAGppmAa8O9HY xwO9RBFaIuXv5NlPYQc6SQkhkOLSmKKuWJ6jmov3ATouZVRNDKLAJns+c+Mo/NENBH8x ikHGYRyjEoZuf231MXbIZxAR3P1hPMicroiu3EXuU2VqM5DXigo21ICXc8LrFQr8jJRe +oJ3JKxF/XrXeJPdtL+ryAH2tN5/lAvVhKK84A1ep99MW2f+6c6LPzenX3IB5BICzC8Y h8Hcl2ra2mbroxnfeA9N+vVtVLzpQHF52Y+1WgWaTk2SULqg0ZFH5KZtq5LqDmlthwoi EBMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391201; x=1718996001; 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=pbkw3gfBa7pDv5LtwL2F58xHAeTu0x1hEm/aJcvSENY=; b=jNdttNVkpfWgwr3NUSl5b00vnlY8EaK2dH/vWvP9mmID9ESqRYmznjshuPyJaHh4rC GyCgMNM1Q4brT6cpnMth6UIPndg/7CyDMPfRkSC0zVZYaEFQbeQYy9XVqPxoqvTJIIzv QgmmRbTrRX2R+PI0mI2yX3nGhNsgKjROfRogmL/5BZNv8Mnh4fnLHHurEOiTtiVzy1Sm kMhQPD56kNwxtXhxUymT3e6Rs67Z+Qt5+bEKAZE9HAfDn8+3iChM/meMAsCNLe3zsFcz fVbgmtQNAOUUsyxtfSjDb8E2XM1FO0TZDcFdIROyEipvKVhJOEmKiLGLaspV/r3ckQZs MpLw== X-Gm-Message-State: AOJu0YzIBaG7cdjL+z70RG9Y4c5A6hc1pYGPrFd73FkbQgWEI/2tikow DYQsykxSAI488JEJwUJSpikvQmFKzoD+3todTXmqlf6LDBztkncECmqGMA== X-Google-Smtp-Source: AGHT+IE60EvG/GAO1afRK1hYUy/0WBkrUDyIEUcEI2a2BuGgS9HmXsDkzh2reRJcKNo6oYp5N6WpWw== X-Received: by 2002:a05:6870:1586:b0:254:a1a8:8501 with SMTP id 586e51a60fabf-25842b79405mr3916268fac.43.1718391201380; Fri, 14 Jun 2024 11:53:21 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:21 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 25/27] qmi: Rename qmi_device_shutdown Date: Fri, 14 Jun 2024 13:52:37 -0500 Message-ID: <20240614185300.1086701-25-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 5576c520bb08..d9b888380456 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) { @@ -1530,7 +1517,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, @@ -1542,7 +1529,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), @@ -1558,8 +1545,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); @@ -1569,10 +1556,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); @@ -1582,41 +1569,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; } @@ -1624,7 +1615,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) @@ -1888,7 +1878,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 e5c99ab8b674..26ef8c72f9df 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 *); +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 483495972843..091e5f08ea5d 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 Fri Jun 14 18:52:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699072 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 1F8271A2FA8 for ; Fri, 14 Jun 2024 18:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391204; cv=none; b=poxqeQKDEY6qo+jkinA6MLwiYRSBvAmCUq1vmet+cdX+pUitW0sYnqDG/bQpBxaZ7QTRi8LZNVJDJTqG/y7CemKmZSJAOFIX8GA1mwkgFpRyEY4K/R/thOn6kB6YZXy6AioI92rZVhkSGUOecBcfdcK3UpH7FLtm3A3BnxDRWNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391204; c=relaxed/simple; bh=A3D5OFMMiBYDVA3hZ56PFrmbe/IGABLTe5qQ1xW9Nxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rDCuM9BbV/DA+N3T6Jp1xqtAT7Gp5SJ7qRDLzVWJn/MlMIBnlHI47rc1XJftJHNXLN8l0qHGH0+JKZI/SUDXHE2vwCbN2yFwT1LXfuc3aMkjWRz2gXIp99G2IpqD55ZArU8bPOP/bg3GGGxXGktkTGCnEaLb5RNERs7Tfv1zwaA= 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=KpgdXeJl; arc=none smtp.client-ip=209.85.167.177 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="KpgdXeJl" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3d227b1f4f0so1292248b6e.3 for ; Fri, 14 Jun 2024 11:53:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391202; x=1718996002; 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=g1FdxVo1nAkLjNNBMKJmVUFiBBHGx93b6MmsA6SserQ=; b=KpgdXeJldAwkxJ7EAtuq98tOrR5ZF3o+dClKVMb0J83alqcXlVcJgNwT7xlEjHntCE YDJ2Qzf0q6s+Uh82A7Gmz2Ymt4Drxus19Eyah6uQG6v35i44yoDCGlPp3jhb9AjtJXlc MwK+QgsQmRyaKKgYbs7YD0Qe5Ktp5Y6UkTfXMv6Yqr6U0FJoA+qtu0erJbQ/M/kA8+Qk 6Zv4V5ufpmxUJORBmV2WBpQLUYN1vZvxXtsoUfK/1sCjTmxxJ5CFROaRSROcbUS7LKJs tLAkxVjQx/bSLxgN9pwR2f6W4FFvo61SuzsG+eycGt2ETXgxbD36SI+SpujoGSduOYyv iKXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391202; x=1718996002; 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=g1FdxVo1nAkLjNNBMKJmVUFiBBHGx93b6MmsA6SserQ=; b=rtVXofDUMrz067fPbH+ozHtXcK8Qi9R6gBcEYYqL3v9/JI8lkx26u7/hAVlWv+GvH4 rJVKvub7dkDS+Hlx8LBG+jv8g5mRFfOOQY4OSRU4b6ddqNuem8uAcL/ZVD6sw68eSnEA FsQr+1AX8XqtlMVI0JpNCTfYYIpm5DpiWKXT6lyw56LicdpX76h0Al/CmlkBZhGmT64p uLZBCb8oKLPE6aeccCRoyPBJL8oFk0syX6rodQVOj3pPW39Tif3miAFQVoqyXSm6EikV tkJX2eISULo9r4qa67od4sL/vCo7RH6udVSGDDLo55eZAls6ixcO5kIJdbp4EacMkpwR hLYg== X-Gm-Message-State: AOJu0YytiBVwcURSAiyQZtO2paYgkyJGStuM1K7XNPnUwapP4jP9BNOo T2KbYiagXEVBxQ032/fQWsh2MzNU8UjbaZXrliVVDAmKQk89V/TNZ2Wl6g== X-Google-Smtp-Source: AGHT+IHD9fgYrX9J4OWq/f0eIUAOzzpiL0VpTiL6oC9G3qHX2NZR0JMb2mJq2aFM3J3hgvFbjaC/rQ== X-Received: by 2002:a05:6870:1696:b0:254:783d:aeb4 with SMTP id 586e51a60fabf-25842a20260mr3566593fac.35.1718391201973; Fri, 14 Jun 2024 11:53:21 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:21 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 26/27] qmi: Rename qmi_device_qmux to qmi_qmux_device Date: Fri, 14 Jun 2024 13:52:38 -0500 Message-ID: <20240614185300.1086701-26-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 d9b888380456..2c2be04c1593 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); @@ -1226,7 +1226,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); } @@ -1234,7 +1234,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; @@ -1317,8 +1317,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 */ @@ -1333,13 +1333,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); @@ -1391,8 +1391,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, ""); @@ -1413,8 +1413,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; @@ -1471,7 +1471,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; @@ -1485,7 +1485,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; @@ -1515,17 +1515,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; @@ -1538,7 +1538,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); @@ -1554,7 +1554,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); @@ -1567,7 +1567,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; @@ -1587,12 +1587,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; @@ -1613,20 +1613,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); @@ -1643,12 +1643,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); @@ -1663,12 +1663,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 Fri Jun 14 18:52:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13699073 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 AE16E1A01B6 for ; Fri, 14 Jun 2024 18:53:23 +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=1718391205; cv=none; b=nzXttmsNl2HeMCzqg/E0HtHC/52vd5xr9Yel8rDQ2Wg7NXTOY5xGigWf8UBEhu2wP7Sg9Q/AJ99yCJ8ukvEL69fLyqCoUfN4SfettyrEin7SFGbzCEAHCj5RdjsTdjiac7XG7h7WnTdH+WvTgC+1jU1pFV6XLYCHGH1uQsryGpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718391205; c=relaxed/simple; bh=S++E0RX5PVoXJY5HaJLV1pqA47zbOxH++i4VWRT/mr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z0bFM8WYzJYblbMLqKlQHMxUpMxP554dgmKuNPITnKD/yWXQium4meFRqN6yt/4MXAjxUF90W95j2f0hHXdkzhkS+gzNY2T0ZyNAnHMjlApyY36ysksDgRf2eP541u3Zb1rUuNU6NyxwlEi2AnIpHw6PMgWE/sluWLxFWQWYp2w= 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=VseVA/Yt; 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="VseVA/Yt" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-254efc9ca45so1626160fac.3 for ; Fri, 14 Jun 2024 11:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718391202; x=1718996002; 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=ugbpFhjKwDNfXPVXhfs+40yagMN/CSbumoTOvLcEct4=; b=VseVA/YtsgzqfD2qTO95rAacmEKycfCB6DoNIb4PwTI9JHszEZWc/eQaMgxrdw2Q8C aFZ44pOsiJIBu+3ffvQ0WV1unRzMSe+okTg3cEnczetJaENXXtWaeKb5KAWvswZhfgPh 5nDx4A6DIlmaqP1avu7Wi+ngBJVB2Q644+LylBKSg9DGHbXhRuITnZc0EiDZh8uQNORE +QQIodMenR0sf2xT6pauq1raTBo3wKKik5svunIQnOOMQRZ6c2c9lRFFQ5qpaaB3el5j SQoDEJIHdmyyBaJuRxVaV4TZUyI5lbIvvFjDSF8z+QqOro0/dz8jYHv35ei69NuLgwRa PItA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718391202; x=1718996002; 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=ugbpFhjKwDNfXPVXhfs+40yagMN/CSbumoTOvLcEct4=; b=PVsm4o0nLQJmUAavhlHk7fzQyngqjF2R24rOb8wB1+7oqtF1JF0lAHGqNCoQk8Z9ag uU7P38PmbH+kimWUFuODcsCsjCfDXICRjrwQxTei8nMz4+05hzNdZTwoAJza3kAwdh1+ xrRaUmaW35dzg1fBYzt4mY/GW4HM3LFRpCJSCX4B8gqzWtKnwy83ngTN7h9WhJ34ao2b SG1/Oc6vUwfhB8jrmcBnZHdf7ybPDTWRsAtPSVPLHRIUPVgQfTzSGcrd/+tSzB+OO6dz BMxyNbL27MyhE5LRZDDtCUEYqTy75cWehU7ie8BjXsvp55VeHdfn81EoX5C/F1z3pmhI +gzw== X-Gm-Message-State: AOJu0Yz3j3q01fH9UCV20U+Fx8SMCsseFR786NE8wAM/VWRQojFcQGbT 3DoJyrF+XQDm1JRYycQhULk7npRx1mGret1GPyQHUvkFj6X6MsrtWhtYpQ== X-Google-Smtp-Source: AGHT+IEZBJpMZe+MxHxrvDCJxaFkMu9Ex8gyG8p1XScBDwuLEyTyPwcJEQr/oPKrtgJBeZWrK04R6w== X-Received: by 2002:a05:6870:618d:b0:254:a233:3d11 with SMTP id 586e51a60fabf-258429a4ce3mr3139017fac.30.1718391202513; Fri, 14 Jun 2024 11:53:22 -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-2569934cf6fsm1095763fac.47.2024.06.14.11.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 11:53:22 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 27/27] qmi: Make qmux methods operate on 'qmi_qmux_device' Date: Fri, 14 Jun 2024 13:52:39 -0500 Message-ID: <20240614185300.1086701-27-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614185300.1086701-1-denkenz@gmail.com> References: <20240614185300.1086701-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 2c2be04c1593..e8fcb97b2ca2 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, @@ -1329,21 +1334,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, @@ -1445,14 +1447,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) @@ -1464,32 +1467,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; @@ -1508,7 +1508,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; } @@ -1582,18 +1582,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; @@ -1617,7 +1613,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; @@ -1638,19 +1634,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; @@ -1660,15 +1653,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 26ef8c72f9df..441f7b72f3bf 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 091e5f08ea5d..e5ebec44ebc7 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;