From patchwork Mon Jun 24 19:32:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13709994 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 A970B1A00EF for ; Mon, 24 Jun 2024 19:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257601; cv=none; b=V34iNhnBnlems7ZZJifKXDRvtPCn7n66MjCcTXrvUxtEpzIijE8LbtGLrxfw89VF1Lpio96UyM0x+WXDfVrjHiHtX5qIGf68GMHv1rxKuUcfarkqLuClG2ORNdOWI+/mvdsPGpCewXHi3FFQQht3UnKlurPMEtHENu6mdwuv65g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257601; c=relaxed/simple; bh=Xo2CMnnhdZCjUQ8KD72oaOqWYOQkHwkLUt1WR6/X6fs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BhtHihZvRXtnuWh24mDQCGg0fYI10TGwbVJaj0YrBIpNeqKpfxzH8C6//u9O4Dh1g0Nr8FIbBAmwKGOGUe5pCKk6LjINRjH2dtU73hpiYhUsfAPpnSev3isL9PyZ8KHwNLV+P2b+x2NU8ATN+L58g16iJ/2JJcn/FaExf2mO2cI= 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=c3NcuYdy; arc=none smtp.client-ip=209.85.161.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="c3NcuYdy" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5bfb24e338bso1880338eaf.0 for ; Mon, 24 Jun 2024 12:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257598; x=1719862398; 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=qoQMBeoAJX2jdeuccsEmvFoUIEAC93FlI9juVRlE0Zo=; b=c3NcuYdy1uQhbjB3o6in1D58+1o27CxlH7FtM+7QoeT/s5nnHrg33CRNq05zHSd7SB hM+iQbuRWookHZSbTfSz6CUpkL51XdlexfFCf/mhqBnmQ3bW4Zgto26vaUQypnGX6sVX oFf/p/HlaZm56ym5YqEj7LsBQA/40SBaPkN7/OOKXmbOfY8RRvv3PpaHMbZ2Bmu0Wi6L e1oLmWKVaj4MHFiN3MHsSVTmyqctD5dORrthC9qZqvSvguVLer0HVRKUSupNDD0qIUVD 4ZSDhkjWD4BvA9lxe3IzQL1UiLrppSztqUX2Sc04gGR8VsFC5fLVL6n9H+R+Y4P43sef Fm1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257598; x=1719862398; 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=qoQMBeoAJX2jdeuccsEmvFoUIEAC93FlI9juVRlE0Zo=; b=Wx0M5NJ9IuSgCHxmZimFype7tLeF/4Lfdw2F74dYbFJS6paSoAdpOav8TE8I7JOpsc nKsWFrjhMU9iVHw3pHL3GZsTFms+u4vQeaYruvJCjipE2tVmqpx7h2Pnbamh605jDESr AerLeJ5Zm42aWgK47kF/R4Oqz3c+Z5UgG3sK2q946AjYLrujDb3aiLZP25k4paqJ/3Ri wcMltD9kP6M6Ji2EVyTmPkq0a4g5Q8sS/5AbiBzp36tR/hfto5Fc3MoIY8Yz3hFsxf3T DHV3UwkLHu5F52cFlC799aymZtxYpKPYppqeqPPldnaYQ465BPVcNbWtZRjYByPrmPZL MPGg== X-Gm-Message-State: AOJu0YwwEkouXFDBoRjRyg8kO5sBC/W7VYDkcq/tW3sRLXqeDsV9VT8g NpjBlCzX1BcZQwIO0ja5erwXlU8FGiSTOs6cQY4JqCUSWnMGvjXlvvFhFA== X-Google-Smtp-Source: AGHT+IGmDQaOJVnJX6/5DGWFGABYKTXkp4KSa5is6qrUomtMA1mjEs75Vny7h7ND9+ZCoWzfbGtIHQ== X-Received: by 2002:a05:6870:d1c3:b0:25c:adef:2348 with SMTP id 586e51a60fabf-25cf8a3839amr2565576fac.12.1719257598299; Mon, 24 Jun 2024 12:33: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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:17 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 01/13] qmi: Introduce SERVICE_VERSION macro Date: Mon, 24 Jun 2024 14:32:44 -0500 Message-ID: <20240624193315.1164943-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 will make it easier to compare service major.minor versions in a more readable manner. --- drivers/qmimodem/qmi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index e3a8b225140f..5f29c4384803 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -36,6 +36,9 @@ l_util_debug((debug)->func, (debug)->user_data, "%s:%i " fmt, \ __func__, __LINE__, ## args) +#define SERVICE_VERSION(major, minor) \ + (((major) << 16) | (minor)) + struct qmi_device; struct qmi_request; @@ -1199,6 +1202,7 @@ static void qmux_discover_callback(struct qmi_request *req, uint16_t message, const void *ptr; uint16_t len; unsigned int i; + uint32_t control_version = 0; result_code = tlv_get(buffer, length, 0x02, &len); if (!result_code) @@ -1233,6 +1237,7 @@ static void qmux_discover_callback(struct qmi_request *req, uint16_t message, if (type == QMI_SERVICE_CONTROL) { qmux->control_major = major; qmux->control_minor = minor; + control_version = SERVICE_VERSION(major, minor); continue; } @@ -1257,8 +1262,7 @@ done: * 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) { + if (control_version >= SERVICE_VERSION(1, 5)) { struct qmi_request *req = __control_request_alloc(QMI_CTL_SYNC, NULL, 0, 0); From patchwork Mon Jun 24 19:32:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13709995 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4924B1A00F1 for ; Mon, 24 Jun 2024 19:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257601; cv=none; b=soO9OkjEOo/N78oQS5HKhdMKbc4RS3BPCGdr394ga4RBwpUw/EUPfRBZO0duYtXHu1RVdT74j4pBSj2BLrRLl6ee2RluVQUIx+S6+Ap3YpgyTUaGQ4yS9+Gu5qkbgQQAuaVobO00JRZWeuuSLzYHxJ629HA4pDGfBw1v8QV3DUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257601; c=relaxed/simple; bh=dbqjMrjUQTfCTyD3Ho8KYPphw9aERUYXc7ogkqsrMf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EoPzNvRegCZA+tKeO7w34i41QNYt55LOLuBIAEC1xECxzp3k4BK+et2mrKSpkq2aSrbTC+C4FPxuIiw4087eEyClaeD6PjfN/EcTKWzgxO+/vh6jbbwXpzQrLnh1BZJltXdOwjo2FCleEeZykTBp93PqOtL653LnepYIxYOTlZs= 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=cu3V1viY; arc=none smtp.client-ip=209.85.161.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cu3V1viY" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5bad217c51aso2527129eaf.1 for ; Mon, 24 Jun 2024 12:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257599; x=1719862399; 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=INYROVZP49t7Kd5s53aJh9lmOKM9To7nJkG2blZxgp8=; b=cu3V1viYwIn1AwspvhwYCKbcXcRyaLael+eTdhaOrWuFxVegYOAvAuF5qPUB8PKvEG loEYI40Y7PGTHY0rDxo/BMNSo5KBY7VEziSeFr4uguIGOWLkjer5GWHlcPMhlHvPeqo3 1ILxlyNKsGmU0jHpOth4pint7KMRfqizGJKZQ2gfDsB6tgcjgweTki7uAeawMpgaseZ7 SePjqJBJ7fw0xKuEkYeguuaMTESnEDaUMcBlJzn6AD7WJtM5DF2Xvj/k5/h8N+GJL9YM orDithCan23q9JNyxk2RdnnHJB9du7ryDC2jQZ7addRA6SohGRJfrHc5WI6H6Re1+bYh gk2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257599; x=1719862399; 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=INYROVZP49t7Kd5s53aJh9lmOKM9To7nJkG2blZxgp8=; b=aQjhQPCam5k/lOVHUHVCf6YU6MvRMdFDfLXBQd96WpQE283HnrsB3yKJE35hZxG4UT vgj8din56eQjZdkt3yCxGq4AxI5mlWD7+zB7RAhIRVy8eC1WJkBb+P3GO+6mVDSJR4YW jKakja6mWWulctVNCQjTUXthw2FxfdkO4hkdbLKr+2PhDB2Mt1LHK/cjiC2ypEaCGy6f xOnsJPxcLKS1jUHK0bnUgK+2NT2NFOEQQykMCkZ/1WxPvIhdBcF3h+q1htQlQWOdRNNN f1LHSd66c7j5bg4MisQxe1ayx3ymgHySXRWbWthgrDhGZ0G/cv1640NtxooNDTPeuPy4 Ubfg== X-Gm-Message-State: AOJu0YyzY7fve4nwJfGhA073JIETgKN+2AR9yQkpbDc+rDD47blhfWyL tgX6uOZoFkjxKb/etUxzMmderJmSvfH7s34S2qlS8ao5M8vx1wtfYqLCqA== X-Google-Smtp-Source: AGHT+IFZtJg9XLPx8mZ/G20pUAziajCa5i9QZw9Dsd8gAwgkJOy2hNcflUwpMkpIos+3j9aTgAW7Cw== X-Received: by 2002:a4a:91d3:0:b0:5c1:b998:a859 with SMTP id 006d021491bc7-5c1eec0a767mr5602210eaf.2.1719257598995; Mon, 24 Jun 2024 12:33: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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:18 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 02/13] qmi: Remove control_major and control_minor Date: Mon, 24 Jun 2024 14:32:45 -0500 Message-ID: <20240624193315.1164943-2-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 These attributes are no longer used, remove them. --- drivers/qmimodem/qmi.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 5f29c4384803..238039d4add7 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -100,8 +100,6 @@ struct qmi_device { struct qmi_qmux_device { struct qmi_device super; - uint16_t control_major; - uint16_t control_minor; char *version_str; struct debug_data debug; struct { @@ -1235,8 +1233,6 @@ static void qmux_discover_callback(struct qmi_request *req, uint16_t message, type, major, minor); if (type == QMI_SERVICE_CONTROL) { - qmux->control_major = major; - qmux->control_minor = minor; control_version = SERVICE_VERSION(major, minor); continue; } From patchwork Mon Jun 24 19:32:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13709996 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.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 E576619EED7 for ; Mon, 24 Jun 2024 19:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257602; cv=none; b=kR2MHElNW77cTiyB/9xQfazZuGsDak8sy0KQ2HiJRJnD++BI59gzRdJebGGZyZ4bGziGmUVd5JM5roy1+iDuIvcqwtXl60bb5RFcOwD7aC2MvjocpgV5N4qhRd6cMdAEUDFnUMkADU4HJmEj3u+hUGM5gP50nyU4ZFhpAF0aI6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257602; c=relaxed/simple; bh=1+sQ9K8OPFNJBbvDYPpjxVlqqc6+2sxYzZRnuyh8aAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qzhzYKT02vZmlBTopEeB2ObgcE76nBB6ELqgcfKjUzeIG9O24tpVpZqJ0lTtTa4uDjZQY/a+d7o+bjiflHS8hdGSy6c51fpMWQsMoQ+64XBi5jc15HtdiUyn7UoOw7D298CuxF/u3/+n1duzgyzFGm0GgcMbzOXGkbAXYXGn6R0= 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=moo987hX; arc=none smtp.client-ip=209.85.161.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="moo987hX" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5b970a97e8eso2564853eaf.1 for ; Mon, 24 Jun 2024 12:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257600; x=1719862400; 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=psw16ttjtER33796PhTeXerRJsahRiSzkaP+NSpJRiU=; b=moo987hXOdMPzJT1cS7ulZ3X3NKJUIYSGwAs/ORpXFgZ+ifiRw2JpHSOfh/Pxj2dDj sHrt1EOlVFPjGweIIOkj9NYKeG6qAdg06UBqxyZRTCSTNQsgSO0TL2LbFfdEbQcRS3Qd xuEZ/AHWd6Q9/SdihZcQh1eotmjUcJ4k2G/5sI85YiqtJa2FUlORCe/SpKubdhr93n9u QYSc9mwxs3DA2npMlEtda40fccXhKH+S5OTPBQJ85/T7RIVW2OZHORpE2TF0P1ogbxhZ JyciwBvk6B70N2Mh+avVnuqrBBkUjlibashVwNT60cEBdF3zrogntbqSVM4Ys2SweP0C cfpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257600; x=1719862400; 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=psw16ttjtER33796PhTeXerRJsahRiSzkaP+NSpJRiU=; b=TQpnFVMQS+NHrJ6srXxPJwt7keHZdFJ8TvnCQM4+MAcYsBRiQo96aE0msRfPiR2oOB 2AkxxteEeo92S4hKTu9s/p6ZDM4/D+sSbjT6FxmOyuxz6RIV7GBe3MFOlglLIRD99hld miXRDUzzeQHeaUeO3rLNk+u39Hbu1DATs0ZimyidjNexGEUeFXdOh2dQm977+xbcXjzX UmZTy69ngNhwKuqcDNCJzKez6YYMZHZD1lKqYhEvItAPxjLhJUO0Y3LjD8vLVZYkVDxv 9rvKIo3zCzboPljN5IfppdUkNueI5b2ywogJD5lpA8mJCMdynqlMRqqvonznk4TlptWn ulog== X-Gm-Message-State: AOJu0YwnvMy743MLUz93fTiJ/tHgjDQSWY0vdjTsVM6WyTVqK4nd8wMk y5eez6lFvBqObsSAn2DA0T1+dua0jEhS5ub0GvWfz59/p3d3CWen5gpikQ== X-Google-Smtp-Source: AGHT+IGa7bUvGHWG+Iu8iodwydv9FFDdXMwWQCCN6v3jeMI70K4fkjQTwpI5UKtONrIlU0uTFYNiyQ== X-Received: by 2002:a4a:2447:0:b0:5ba:e995:3efa with SMTP id 006d021491bc7-5c1eb9dc263mr6210496eaf.1.1719257599817; Mon, 24 Jun 2024 12:33: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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:19 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 03/13] qmi: Move service_handle allocation to service_family Date: Mon, 24 Jun 2024 14:32:46 -0500 Message-ID: <20240624193315.1164943-3-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A unique service handle identifiers is allocated every time a new service is created. The unique identifier is generated by qmi_device and is monotonically increasing. qmi_device has now been completely refactored out of the public API and only remains as an implementation detail. It is desirable to remove it and transform it into a QMI transport abstraction. As a first step, remove service handle id allocation from struct qmi_device and move it into struct service_family instead. As a consequence, ensure that when a request is canceled, compare both the service_handle and the service_family group_id since both are required to identify that a request belongs to a particular service. As a side effect, lightweight service handles are now not able to accidentally cancel (by tid) requests they do not own. --- drivers/qmimodem/qmi.c | 65 +++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 238039d4add7..828f62584ea0 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -90,7 +90,6 @@ struct qmi_device { struct l_queue *req_queue; struct l_queue *service_queue; unsigned int next_group_id; /* Matches requests with services */ - unsigned int next_service_handle; uint16_t next_service_tid; struct l_queue *service_infos; struct l_hashmap *family_list; @@ -129,6 +128,7 @@ struct service_family { unsigned int group_id; uint8_t client_id; uint16_t next_notify_id; + unsigned int next_service_handle; struct l_queue *notify_list; }; @@ -1140,14 +1140,13 @@ static struct service_family *service_family_create(struct qmi_device *device, static struct qmi_service *service_create(struct service_family *family) { - struct qmi_device *device = family->device; struct qmi_service *service; - if (device->next_service_handle == 0) /* 0 is reserved for control */ - device->next_service_handle = 1; + if (family->next_service_handle == 0) /* 0 is reserved for control */ + family->next_service_handle = 1; service = l_new(struct qmi_service, 1); - service->handle = device->next_service_handle++; + service->handle = family->next_service_handle++; service->family = service_family_ref(family); return service; @@ -2349,11 +2348,32 @@ uint16_t qmi_service_send(struct qmi_service *service, return __service_request_submit(device, service, &sreq->super); } +struct request_lookup { + uint16_t tid; + unsigned int service_handle; + unsigned int group_id; +}; + +static bool __request_compare_for_cancel(const void *a, const void *b) +{ + const struct qmi_request *req = a; + const struct request_lookup *lookup = b; + + if (req->service_handle != lookup->service_handle) + return false; + + if (req->group_id != lookup->group_id) + return false; + + return req->tid == lookup->tid; +} + bool qmi_service_cancel(struct qmi_service *service, uint16_t id) { struct qmi_device *device; struct qmi_request *req; struct service_family *family; + struct request_lookup lookup = { .tid = id }; if (!service || !id) return false; @@ -2367,12 +2387,15 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id) if (!device) return false; - req = l_queue_remove_if(device->req_queue, __request_compare, - L_UINT_TO_PTR(id)); + lookup.group_id = family->group_id; + lookup.service_handle = service->handle; + + req = l_queue_remove_if(device->req_queue, __request_compare_for_cancel, + &lookup); if (!req) { req = l_queue_remove_if(device->service_queue, - __request_compare, - L_UINT_TO_PTR(id)); + __request_compare_for_cancel, + &lookup); if (!req) return false; } @@ -2385,9 +2408,12 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id) static bool remove_req_if_match(void *data, void *user_data) { struct qmi_request *req = data; - unsigned int service_handle = L_PTR_TO_UINT(user_data); + struct request_lookup *lookup = user_data; - if (req->service_handle != service_handle) + if (req->service_handle != lookup->service_handle) + return false; + + if (req->group_id != lookup->group_id) return false; __request_free(req); @@ -2395,10 +2421,15 @@ static bool remove_req_if_match(void *data, void *user_data) return true; } -static void remove_client(struct l_queue *queue, unsigned int service_handle) +static void remove_client(struct l_queue *queue, unsigned int group_id, + unsigned int service_handle) { - l_queue_foreach_remove(queue, remove_req_if_match, - L_UINT_TO_PTR(service_handle)); + struct request_lookup lookup = { + .group_id = group_id, + .service_handle = service_handle, + }; + + l_queue_foreach_remove(queue, remove_req_if_match, &lookup); } static bool qmi_service_cancel_all(struct qmi_service *service) @@ -2415,8 +2446,10 @@ static bool qmi_service_cancel_all(struct qmi_service *service) if (!device) return false; - remove_client(device->req_queue, service->handle); - remove_client(device->service_queue, service->handle); + remove_client(device->req_queue, + service->family->group_id, service->handle); + remove_client(device->service_queue, + service->family->group_id, service->handle); return true; } From patchwork Mon Jun 24 19:32:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13709997 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B34111A00FC for ; Mon, 24 Jun 2024 19:33:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257603; cv=none; b=e1ewixOED3OMiSqbQanT5VnvyR0/R/OuUXxyQ7l1Z5ya7zT3Sf4gLBP2SHGenDP6NnleHtMqyiJNMJmPCZO8pFMMVIEUfU4+Pm+pd7E2cyAReiy24Hps/V6eBJ7YQu4BLCtiSgm4jmKjLGLqj/tKI198YVLg0Gq4e3u69B0V0iI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257603; c=relaxed/simple; bh=x3lulOVynjNZfS6qC1lx4Kq8eCSVP0h4tOyBr2qglqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fnmTUPt4Gx9LA995S1of5nCH315p5VhNt9fjzF0B3uPrB6xPVZhTtDwU784WW0epvTH4ZPvXpdvZ1ugNnSTNzkOixwmdI6Y4SFb6CfSh0xKpBeoVxbT6+ZWhOkgfT8MRBNYrDpjxMFG1kZxZE9JiLWW7yq8qsKJbDZMhPE4LP/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gdMW1y/K; arc=none smtp.client-ip=209.85.161.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gdMW1y/K" Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5c1b734383cso2196688eaf.3 for ; Mon, 24 Jun 2024 12:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257600; x=1719862400; 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=sMFARyTsy6XXkj+xUBaXbSXxxujjadb8XkGI0ICr1Z8=; b=gdMW1y/KXAjLC0MdGQ2NwQY8EeblIAfmgCYBltbyKTZBIxsFcgsd2tHAPMqAP36Cax wzk/1e5eJTZwJqxrwNQmtrBPMBb4hog2x1RZli0cN9pnINgC05q65t5eyz97/vjOOj2d h2hJiWI6NnJNp7lLGXwkxBsgAYd/VuoOXduFFC4XCKZ0R/DDbjd4cPN+oZRtn9HSAIJ6 oPLtyruSvyk5CW4Xueon9tG2VH1qGKhGueMyFRbrpu09E738fSipy25aqCIC94kOwUoe Yteknyu1hNJh6zTA3fojYxuAyCWvrTU4/Ijr+SUfPTkoHrXLE6H4lWxnyhNEKHJrhjY2 O6Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257600; x=1719862400; 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=sMFARyTsy6XXkj+xUBaXbSXxxujjadb8XkGI0ICr1Z8=; b=j7tZ1fc3hzCrB05gJFjfIaBziv6/qj6rSkcE+fck2McAEV1OJcvCnKQYtdUs6LPkB5 vfrA7uYKv+6sdMfCWyAV0Vs3y9VV7RdZHNOWrtBnCjvGTzWr9RkNgacRJa9Ra4yDG++3 qW8PU6si3xr8ZGm9yAg54BRV5TwyhClKrMXZDPLlHpu/zNeaGRaD1/J+PZakvAf8Edjh ki1pv0Og44dmngJlT016QgsgK4t5O7d/u98ASJxnupxTu9dDYX/1wcVrVfxq68gxIwrA 0mUHZ1cw6LhGOrdPznltIXtdv5wq+CW8oBvZfih1QQyyDdGCdrLTojBUPXNzpE8RxuKX 3RJQ== X-Gm-Message-State: AOJu0Yw/U1uio88l6rwaidwFWPv/OIt12nUlEgkYbqi5zqk9dUgT4ST/ y8/NNly35cOlKMMAL18IL6Ia3RG5G+9i//fJPGx0s90vwD9fK/qgTzuISg== X-Google-Smtp-Source: AGHT+IHRwj+UPJjSJLxOPVtT7ku7DYPN+AJn4E4oDaTQAvqqbpgHvAHOOz2VIeXk3x6b2h6QV3avzw== X-Received: by 2002:a4a:85c1:0:b0:5c1:bdf5:df22 with SMTP id 006d021491bc7-5c1eecf1addmr5338805eaf.4.1719257600562; Mon, 24 Jun 2024 12:33: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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:20 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 04/13] qmi: Move group id allocation out of qmi_device Date: Mon, 24 Jun 2024 14:32:47 -0500 Message-ID: <20240624193315.1164943-4-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As another step of removing qmi_device vestiges, move group_id allocation into qmi_qrtr_node and qmi_qmux_device classes. --- drivers/qmimodem/qmi.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 828f62584ea0..2095a952fffd 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -89,7 +89,6 @@ struct qmi_device { struct l_io *io; struct l_queue *req_queue; struct l_queue *service_queue; - unsigned int next_group_id; /* Matches requests with services */ uint16_t next_service_tid; struct l_queue *service_infos; struct l_hashmap *family_list; @@ -116,6 +115,7 @@ struct qmi_qmux_device { unsigned int release_users; } shutdown; uint8_t next_control_tid; + unsigned int next_group_id; /* Matches requests with services */ struct l_queue *control_queue; bool shutting_down : 1; bool destroyed : 1; @@ -194,6 +194,14 @@ struct qmi_tlv_hdr { } __attribute__ ((packed)); #define QMI_TLV_HDR_SIZE 3 +static unsigned int next_id(unsigned int *id) +{ + if (*id == 0) /* 0 is reserved for control */ + *id = 1; + + return *id++; +} + static bool qmi_service_info_matches(const void *data, const void *user) { const struct qmi_service_info *info = data; @@ -1119,6 +1127,7 @@ static uint8_t __ctl_request_submit(struct qmi_qmux_device *qmux, } static struct service_family *service_family_create(struct qmi_device *device, + unsigned int group_id, const struct qmi_service_info *info, uint8_t client_id) { struct service_family *family = l_new(struct service_family, 1); @@ -1127,12 +1136,7 @@ static struct service_family *service_family_create(struct qmi_device *device, family->device = device; family->client_id = client_id; family->notify_list = l_queue_new(); - - if (device->next_group_id == 0) /* 0 is reserved for control */ - device->next_group_id = 1; - - family->group_id = device->next_group_id++; - + family->group_id = group_id; memcpy(&family->info, info, sizeof(family->info)); return family; @@ -1397,7 +1401,9 @@ static void qmux_create_client_callback(struct qmi_request *r, info.major = req->major; info.minor = req->minor; - family = service_family_create(&qmux->super, &info, client_id->client); + family = service_family_create(&qmux->super, + next_id(&qmux->next_group_id), + &info, client_id->client); DEBUG(&qmux->debug, "service family created [client=%d,type=%d]", family->client_id, family->info.service_type); @@ -1614,6 +1620,7 @@ void qmi_qmux_device_set_debug(struct qmi_qmux_device *qmux, struct qmi_qrtr_node { struct qmi_device super; + unsigned int next_group_id; /* Matches requests with services */ struct debug_data debug; struct { qmi_qrtr_node_lookup_done_func_t func; @@ -1954,7 +1961,8 @@ struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, if (!info) return NULL; - family = service_family_create(device, info, 0); + family = service_family_create(device, next_id(&node->next_group_id), + info, 0); l_hashmap_insert(device->family_list, L_UINT_TO_PTR(type), family); done: return service_create(family); From patchwork Mon Jun 24 19:32:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13709998 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 690861A00F1 for ; Mon, 24 Jun 2024 19:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257604; cv=none; b=FHvMDAeEmnsqIiKEgMtrBQMcktlymt59SwSf/eO8+FGD4LTMApuTx1ktPVgv8NXJJkdjgs2/9mklrVsUsycilp/Qv1P5h5LCvBG5zMiV3+9vnxYQcPT5a0q6VJW8xIniVIKZqHS4tje+1qgVu8ZErlQSGc6rBJLFwFa8S1rur+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257604; c=relaxed/simple; bh=s+B6px07g1bh3lEsx1QEi3jgWWWeXOWOGN5/fs8wfHs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cPW0RCMdBxBoSDYE1ntyxEmNL942tVZWKxiJirfDDSVjlIDXUsmj+0nsVfvhVX6hlEJO9ry4TNwdVqPHhuKtu7MU8zUMu6ePegt1CKc2thN99tYzeJ6YQsa1i+TtNnvgcHIyrgee3OHderikoc8L10g+WHi4TyEUv8rd8cwa/jc= 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=XD0nY/fA; arc=none smtp.client-ip=209.85.161.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XD0nY/fA" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5bacd59e562so2372463eaf.2 for ; Mon, 24 Jun 2024 12:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257601; x=1719862401; 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=iB/Riy1lXURl9N0ePmpdVZLbRroi1cvFTvSj7Tpk4FM=; b=XD0nY/fAXx2FHo97K41CJmbvH6yNafXKBtJMyELeBxVE+Ae1zf+wfvqq2eKtqe4xJ9 9Jw/6yGbAxOu2htgVSwG2QDQ7LHcSGq+bLkD+3jALJX1t3BqYD8m3RwzgsdqXUV55Vtf ESTg+BddA9OoJU93NnwQccdnJwM5iHMGQptbZ+a92OIQcW04ctLZCbSK5E8uOV0Rg2pK 73witWZbiG/9TJdo+YaZCEPJk5Uq40doO/zuOgHE0PcLQ5bbeXDj7Vzry8cf3H0z8/ql sOjVtt3LUED0y2OsZV031L1946RbvCRSKEVQIL5ueIwhu9dZCdhM+I7Qk8J3xB+Du9FH fVQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257601; x=1719862401; 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=iB/Riy1lXURl9N0ePmpdVZLbRroi1cvFTvSj7Tpk4FM=; b=idcqL1mdnDGPd4QtCVuH3uKAjrIJfK7BSS6nGybzFXErLxRlKIPkIrCwxvDPWZHrfE Q4ZvwOHrh5O7nldmpQPBMs+pOtTO6u7p/mmaa8VkkGOv5C4SAStRIl150JR8j6q6TEPA BvrOrW8dYXOUZQdWITPXCDjahN4z5PxZTZA/lWZuUlpB++Y0TeHQvGVMvJtfVHkkNnav r6+wrePDx4+bLbk2KD6Z3cv7gPJ39nRMlmCrEm8c9xNEfso/kfjKRHWxlZZpedh2ndJ0 vG9kMZj3NjexeJGU9Cw5l99Yn3EcxlBhWKVY83m6Bjs7NRxlyzREXvkqo5Y82SVwXi4F U1QQ== X-Gm-Message-State: AOJu0Yz0OIQf2iLGzzc00NNJls9isEq4u42cPJx/qxCxIz5bZylRvJpW JbB1SS64fjojnmzGzgxkUObVuHUeOh+a06JKUrn0DsXc023473/8RSkP8Q== X-Google-Smtp-Source: AGHT+IFt33BXMpEHdkJC28yZPyUz7K1FU1y0tAj0r20gaZ0bQfXO3IPJxzCVfypzqrhg2Aj5QxZ/Uw== X-Received: by 2002:a4a:650a:0:b0:5bd:b378:7921 with SMTP id 006d021491bc7-5c1ebb23d96mr6231608eaf.7.1719257601359; Mon, 24 Jun 2024 12:33: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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:21 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 05/13] qmi: Move service_info management into qrtr/qmux Date: Mon, 24 Jun 2024 14:32:48 -0500 Message-ID: <20240624193315.1164943-5-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Break out service_info management from struct qmi_device into qrtr and qmux classes. This allows to optimize how service info is managed slightly: - On QMUX, the list is static and obtained during discovery. An array can be used instead of a linked list. Certain comparisons which are only relevant for QRTR can be skipped. - QRTR behavior remains the same. --- drivers/qmimodem/qmi.c | 103 ++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 2095a952fffd..cf4b6f156a5e 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -90,7 +90,6 @@ struct qmi_device { struct l_queue *req_queue; struct l_queue *service_queue; uint16_t next_service_tid; - struct l_queue *service_infos; struct l_hashmap *family_list; const struct qmi_device_ops *ops; bool writer_active : 1; @@ -98,6 +97,8 @@ struct qmi_device { struct qmi_qmux_device { struct qmi_device super; + struct qmi_service_info *service_list; + uint16_t n_services; char *version_str; struct debug_data debug; struct { @@ -219,16 +220,6 @@ static bool qmi_service_info_matches(const void *data, const void *user) return true; } -static void __qmi_service_appeared(struct qmi_device *device, - const struct qmi_service_info *info) -{ - if (l_queue_find(device->service_infos, qmi_service_info_matches, info)) - return; - - l_queue_push_tail(device->service_infos, - l_memdup(info, sizeof(struct qmi_service_info))); -} - static void *__request_alloc(uint32_t service_type, uint8_t client, uint16_t message, const void *data, uint16_t length, @@ -843,7 +834,6 @@ static int qmi_device_init(struct qmi_device *device, int fd, device->req_queue = l_queue_new(); device->service_queue = l_queue_new(); - device->service_infos = l_queue_new(); device->family_list = l_hashmap_new(); device->next_service_tid = 256; @@ -861,8 +851,6 @@ static void __qmi_device_free(struct qmi_device *device) l_io_destroy(device->io); l_hashmap_destroy(device->family_list, family_destroy); - - l_queue_destroy(device->service_infos, l_free); } void qmi_result_print_tlvs(struct qmi_result *result) @@ -905,23 +893,19 @@ static const void *tlv_get(const void *data, uint16_t size, return NULL; } -static const struct qmi_service_info *__find_service_info_by_type( - struct qmi_device *device, uint16_t type) +static const struct qmi_service_info *__qmux_service_info_find( + struct qmi_qmux_device *qmux, uint16_t type) { - const struct qmi_service_info *info = NULL; - const struct l_queue_entry *entry; + unsigned int i; - for (entry = l_queue_get_entries(device->service_infos); - entry; entry = entry->next) { - struct qmi_service_info *data = entry->data; + for (i = 0; i < qmux->n_services; i++) { + if (qmux->service_list[i].service_type != type) + continue; - if (data->service_type == type) { - info = data; - break; - } + return qmux->service_list + i; } - return info; + return NULL; } bool qmi_qmux_device_get_service_version(struct qmi_qmux_device *qmux, @@ -933,7 +917,7 @@ bool qmi_qmux_device_get_service_version(struct qmi_qmux_device *qmux, if (!qmux) return false; - info = __find_service_info_by_type(&qmux->super, type); + info = __qmux_service_info_find(qmux, type); if (!info) return false; @@ -947,7 +931,7 @@ bool qmi_qmux_device_has_service(struct qmi_qmux_device *qmux, uint16_t type) if (!qmux) return false; - return __find_service_info_by_type(&qmux->super, type); + return __qmux_service_info_find(qmux, type); } static int qmi_qmux_device_write(struct qmi_device *device, @@ -1197,7 +1181,6 @@ static void qmux_discover_callback(struct qmi_request *req, uint16_t message, uint16_t length, const void *buffer) { struct qmi_qmux_device *qmux = req->user_data; - struct qmi_device *device = &qmux->super; const struct qmi_result_code *result_code; const struct qmi_service_list *service_list; const void *ptr; @@ -1219,6 +1202,13 @@ static void qmux_discover_callback(struct qmi_request *req, uint16_t message, if (len < QMI_SERVICE_LIST_SIZE) goto done; + if (!service_list->count) + goto done; + + l_free(qmux->service_list); + qmux->n_services = 0; + qmux->service_list = l_new(struct qmi_service_info, service_list->count); + for (i = 0; i < service_list->count; i++) { uint16_t major = L_LE16_TO_CPU(service_list->services[i].major); @@ -1226,7 +1216,6 @@ static void qmux_discover_callback(struct qmi_request *req, uint16_t message, L_LE16_TO_CPU(service_list->services[i].minor); uint8_t type = service_list->services[i].type; const char *name = __service_type_to_string(type); - struct qmi_service_info info; if (name) DEBUG(&qmux->debug, "discovered service [%s %d.%d]", @@ -1240,12 +1229,10 @@ static void qmux_discover_callback(struct qmi_request *req, uint16_t message, continue; } - memset(&info, 0, sizeof(info)); - info.service_type = type; - info.major = major; - info.minor = minor; - - __qmi_service_appeared(device, &info); + qmux->service_list[qmux->n_services].service_type = type; + qmux->service_list[qmux->n_services].major = major; + qmux->service_list[qmux->n_services].minor = minor; + qmux->n_services += 1; } ptr = tlv_get(buffer, length, 0x10, &len); @@ -1304,7 +1291,7 @@ int qmi_qmux_device_discover(struct qmi_qmux_device *qmux, DEBUG(&qmux->debug, "device %p", qmux); - if (l_queue_length(qmux->super.service_infos) > 0 || qmux->discover.tid) + if (qmux->n_services || qmux->discover.tid) return -EALREADY; req = __control_request_alloc(QMI_CTL_GET_VERSION_INFO, NULL, 0, 0); @@ -1439,7 +1426,7 @@ bool qmi_qmux_device_create_client(struct qmi_qmux_device *qmux, if (service_type == QMI_SERVICE_CONTROL) return false; - info = __find_service_info_by_type(&qmux->super, service_type); + info = __qmux_service_info_find(qmux, service_type); if (!info) return false; @@ -1504,6 +1491,7 @@ static void __qmux_device_free(struct qmi_qmux_device *qmux) if (qmux->shutdown.idle) l_idle_remove(qmux->shutdown.idle); + l_free(qmux->service_list); l_free(qmux->version_str); l_free(qmux); } @@ -1621,6 +1609,7 @@ void qmi_qmux_device_set_debug(struct qmi_qmux_device *qmux, struct qmi_qrtr_node { struct qmi_device super; unsigned int next_group_id; /* Matches requests with services */ + struct l_queue *service_infos; struct debug_data debug; struct { qmi_qrtr_node_lookup_done_func_t func; @@ -1630,6 +1619,32 @@ struct qmi_qrtr_node { } lookup; }; +static const struct qmi_service_info *__qrtr_service_info_find( + struct qmi_qrtr_node *node, uint16_t type) +{ + const struct l_queue_entry *entry; + + for (entry = l_queue_get_entries(node->service_infos); + entry; entry = entry->next) { + struct qmi_service_info *info = entry->data; + + if (info->service_type == type) + return info; + } + + return NULL; +} + +static void __qrtr_service_appeared(struct qmi_qrtr_node *node, + const struct qmi_service_info *info) +{ + if (l_queue_find(node->service_infos, qmi_service_info_matches, info)) + return; + + l_queue_push_tail(node->service_infos, + l_memdup(info, sizeof(struct qmi_service_info))); +} + static void __qrtr_lookup_finished(struct qmi_qrtr_node *node) { if (!node->lookup.func) { @@ -1708,7 +1723,6 @@ static void qrtr_debug_ctrl_request(const struct qrtr_ctrl_pkt *packet, static void qrtr_received_control_packet(struct qmi_qrtr_node *node, const void *buf, size_t len) { - struct qmi_device *device = &node->super; const struct qrtr_ctrl_pkt *packet = buf; struct qmi_service_info info; uint32_t cmd; @@ -1755,7 +1769,7 @@ static void qrtr_received_control_packet(struct qmi_qrtr_node *node, info.major = version; info.instance = instance; - __qmi_service_appeared(device, &info); + __qrtr_service_appeared(node, &info); if (!node->lookup.func) return; @@ -1772,7 +1786,7 @@ static void qrtr_received_service_message(struct qmi_qrtr_node *node, const struct l_queue_entry *entry; uint32_t service_type = 0; - for (entry = l_queue_get_entries(device->service_infos); + for (entry = l_queue_get_entries(node->service_infos); entry; entry = entry->next) { struct qmi_service_info *info = entry->data; @@ -1844,6 +1858,8 @@ struct qmi_qrtr_node *qmi_qrtr_node_new(uint32_t node) return NULL; } + qrtr->service_infos = l_queue_new(); + l_io_set_read_handler(qrtr->super.io, qrtr_received_data, qrtr, NULL); return qrtr; @@ -1855,6 +1871,7 @@ void qmi_qrtr_node_free(struct qmi_qrtr_node *node) return; __qmi_device_free(&node->super); + l_queue_destroy(node->service_infos, l_free); if (node->lookup.destroy) node->lookup.destroy(node->lookup.user_data); @@ -1957,7 +1974,7 @@ struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, if (family) goto done; - info = __find_service_info_by_type(device, type); + info = __qrtr_service_info_find(node, type); if (!info) return NULL; @@ -1973,7 +1990,7 @@ bool qmi_qrtr_node_has_service(struct qmi_qrtr_node *node, uint16_t type) if (!node) return false; - return __find_service_info_by_type(&node->super, type); + return __qrtr_service_info_find(node, type); } struct qmi_param *qmi_param_new(void) From patchwork Mon Jun 24 19:32:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13709999 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3747219EED7 for ; Mon, 24 Jun 2024 19:33:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257605; cv=none; b=AqOLprm+vjlUwN0weJOKB3LeuKv2cqo7GRzKWJn8h1DZ36CJFMO1j9NZMvliK0odrGVV0omFQW1YUUEbPjE5GshnFRZF9zzqEVVKsNN5cbRxewOxtG8mf/qOdpGgMDDmMDb9PA7QfShE9srdaIqxyYuG9KHEfasTlKKXb2lEpSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257605; c=relaxed/simple; bh=t7sI12JSv3SIRA4E76xeMOWMYI6TmDukNJp/0ZlQDXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LKPTPbVePMEI4muWiv7KEICXPZn0Ymhnho1WWAL85yVD25qFm57Owbn2mGygIDQtm7dS8FDqXpqnD7Ujdl5MSur6XWhX8Bfgh0B2rAagNEtazcHin4ahDZclTu2CYIiMRSF14EjPS5XjXRkUlCqJ263LA30D+Gs0dy6IKBr1/Eo= 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=aY42tIKj; arc=none smtp.client-ip=209.85.161.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aY42tIKj" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5b9706c84e5so2661576eaf.1 for ; Mon, 24 Jun 2024 12:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257602; x=1719862402; 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=HM92eIlHtNVhq79Jh21QmwXT3uVQ/kzRHNiza1RVkh0=; b=aY42tIKjaGtRZsWu1psyr82O6UfAHaFpH/O3LHTqm6fEDt0gpPhTLW+SQhdoF1jiN1 GxVZOJrJcqMUZZVCMN867wJGOoQVWSGLrcGE0Q55aZE7QHSuyMAYqm67/a6cAvIbESTg zzPpOe1lppCLgL5HYdPozuiZr6X+jrBBD3v/in/5ctyzyB1l8lVDd2m+p+fS5gpUzAoK p8BvmP4zhaO9S9r6SadXh713wpHcYt1tA21ToPUAgHgOzExbQ62ArsjaeQJyek+w5kJ0 b7krqyfVEuZAr7taUtrL8nMBOkzWlMPwkGw4V3TJPM76dfJwT4lwiikjzMHmWt3smvJV hk/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257602; x=1719862402; 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=HM92eIlHtNVhq79Jh21QmwXT3uVQ/kzRHNiza1RVkh0=; b=AZTxzxA94KRJncIapHnG6KJnVxIiemDEDbC0fo0PqCb23pNRIahx/K8JxNAe/BaG6B zgVD8JcychgMgTw5ywWrXYH8C4OWbjVdMKrpWE/XsPSSEVw40vO61fGoGk/WN+PpMeXY yc0wO9AwdBsNujihuolPJAdmRD+sDRL3Qgn/V5qyZhSyPh+zHQYo5OoG4Zsr9JlyxB+u 5bVD08kJXiDELjKk/pAWtfeaVrI0rV4c4IIALIxyUMDlubxtKLhfTduh5g5M7kXv1AWT YWRii7X5+UORzqO8SdklxdwyqgpvtjCcO/YtDUCWF5aH9wzBgE97cFFJUWl2di+KUNgQ nChw== X-Gm-Message-State: AOJu0YzGN0Yos3lxE2kJuYDspOqunhhgdq0RkhT9Gq+X4FTjEr7ZWHb7 2jWs98G1IcmplZZgb22g+fl5lMJDutu9vbF5O7OU8soo6hYKFsD6RdBENQ== X-Google-Smtp-Source: AGHT+IGWX8J6gDkLRbm9T5Z0RLjvlSH0cYeGM1i7DaFlAveLHEgHa/CF3LLxzumnf510k6k5f7YCKg== X-Received: by 2002:a4a:6c54:0:b0:5bd:ac68:eee4 with SMTP id 006d021491bc7-5c1ebb4bdd9mr6054752eaf.8.1719257602076; Mon, 24 Jun 2024 12:33: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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:21 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 06/13] qmi: Rename qmi_device to qmi_transport Date: Mon, 24 Jun 2024 14:32:49 -0500 Message-ID: <20240624193315.1164943-6-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-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 | 233 +++++++++++++++++++++-------------------- 1 file changed, 117 insertions(+), 116 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index cf4b6f156a5e..d8fab9a34e5b 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -39,7 +39,7 @@ #define SERVICE_VERSION(major, minor) \ (((major) << 16) | (minor)) -struct qmi_device; +struct qmi_transport; struct qmi_request; typedef void (*response_func_t)(struct qmi_request *, uint16_t message, @@ -74,31 +74,31 @@ struct qmi_service_request { struct qmi_request super; }; -struct qmi_device_ops { - int (*write)(struct qmi_device *device, struct qmi_request *req); - void (*client_release)(struct qmi_device *device, - uint16_t service_type, uint16_t client_id); -}; - struct debug_data { qmi_debug_func_t func; void *user_data; }; -struct qmi_device { +struct qmi_transport_ops { + int (*write)(struct qmi_transport *transport, struct qmi_request *req); + void (*client_release)(struct qmi_transport *transport, + uint16_t service_type, uint16_t client_id); +}; + +struct qmi_transport { struct l_io *io; struct l_queue *req_queue; struct l_queue *service_queue; uint16_t next_service_tid; struct l_hashmap *family_list; - const struct qmi_device_ops *ops; + const struct qmi_transport_ops *ops; bool writer_active : 1; }; struct qmi_qmux_device { - struct qmi_device super; struct qmi_service_info *service_list; uint16_t n_services; + struct qmi_transport transport; char *version_str; struct debug_data debug; struct { @@ -124,7 +124,7 @@ struct qmi_qmux_device { struct service_family { int ref_count; - struct qmi_device *device; + struct qmi_transport *transport; struct qmi_service_info info; unsigned int group_id; uint8_t client_id; @@ -651,21 +651,21 @@ static void __qrtr_debug_msg(const char dir, const void *buf, size_t len, static bool can_write_data(struct l_io *io, void *user_data) { - struct qmi_device *device = user_data; + struct qmi_transport *transport = user_data; struct qmi_request *req; int r; - req = l_queue_pop_head(device->req_queue); + req = l_queue_pop_head(transport->req_queue); if (!req) return false; - r = device->ops->write(device, req); + r = transport->ops->write(transport, req); if (r < 0) { __request_free(req); return false; } - if (l_queue_length(device->req_queue) > 0) + if (l_queue_length(transport->req_queue) > 0) return true; return false; @@ -673,33 +673,33 @@ static bool can_write_data(struct l_io *io, void *user_data) static void write_watch_destroy(void *user_data) { - struct qmi_device *device = user_data; + struct qmi_transport *transport = user_data; - device->writer_active = false; + transport->writer_active = false; } -static void wakeup_writer(struct qmi_device *device) +static void wakeup_writer(struct qmi_transport *transport) { - if (device->writer_active) + if (transport->writer_active) return; - l_io_set_write_handler(device->io, can_write_data, device, + l_io_set_write_handler(transport->io, can_write_data, transport, write_watch_destroy); - device->writer_active = true; + transport->writer_active = true; } -static uint16_t __service_request_submit(struct qmi_device *device, +static uint16_t __service_request_submit(struct qmi_transport *transport, struct qmi_service *service, struct qmi_request *req) { struct qmi_service_hdr *hdr = (struct qmi_service_hdr *) &req->data[QMI_MUX_HDR_SIZE]; - req->tid = device->next_service_tid++; + req->tid = transport->next_service_tid++; - if (device->next_service_tid < 256) - device->next_service_tid = 256; + if (transport->next_service_tid < 256) + transport->next_service_tid = 256; req->group_id = service->family->group_id; req->service_handle = service->handle; @@ -707,8 +707,8 @@ static uint16_t __service_request_submit(struct qmi_device *device, hdr->type = 0x00; hdr->transaction = L_CPU_TO_LE16(req->tid); - l_queue_push_tail(device->req_queue, req); - wakeup_writer(device); + l_queue_push_tail(transport->req_queue, req); + wakeup_writer(transport); return req->tid; } @@ -737,7 +737,7 @@ static unsigned int family_list_create_hash(uint16_t service_type, return (service_type | (client_id << 16)); } -static void handle_indication(struct qmi_device *device, +static void handle_indication(struct qmi_transport *transport, uint32_t service_type, uint8_t client_id, uint16_t message, uint16_t length, const void *data) { @@ -755,13 +755,13 @@ static void handle_indication(struct qmi_device *device, result.length = length; if (client_id == 0xff) { - l_hashmap_foreach(device->family_list, service_notify, + l_hashmap_foreach(transport->family_list, service_notify, &result); return; } hash_id = family_list_create_hash(service_type, client_id); - family = l_hashmap_lookup(device->family_list, + family = l_hashmap_lookup(transport->family_list, L_UINT_TO_PTR(hash_id)); if (!family) @@ -770,7 +770,7 @@ static void handle_indication(struct qmi_device *device, service_notify(NULL, family, &result); } -static void __rx_message(struct qmi_device *device, +static void __rx_message(struct qmi_transport *transport, uint32_t service_type, uint8_t client_id, const void *buf) { @@ -787,12 +787,12 @@ static void __rx_message(struct qmi_device *device, tid = L_LE16_TO_CPU(service->transaction); if (service->type == 0x04) { - handle_indication(device, service_type, client_id, + handle_indication(transport, service_type, client_id, message, length, data); return; } - req = l_queue_remove_if(device->service_queue, __request_compare, + req = l_queue_remove_if(transport->service_queue, __request_compare, L_UINT_TO_PTR(tid)); if (!req) return; @@ -807,14 +807,14 @@ static void family_destroy(void *data) { struct service_family *family = data; - if (!family->device) + if (!family->transport) return; - family->device = NULL; + family->transport = NULL; } -static int qmi_device_init(struct qmi_device *device, int fd, - const struct qmi_device_ops *ops) +static int qmi_transport_open(struct qmi_transport *transport, int fd, + const struct qmi_transport_ops *ops) { long flags; @@ -829,28 +829,26 @@ static int qmi_device_init(struct qmi_device *device, int fd, return -errno; } - device->io = l_io_new(fd); - l_io_set_close_on_destroy(device->io, true); - - device->req_queue = l_queue_new(); - device->service_queue = l_queue_new(); - device->family_list = l_hashmap_new(); + transport->io = l_io_new(fd); + l_io_set_close_on_destroy(transport->io, true); - device->next_service_tid = 256; - - device->ops = ops; + transport->req_queue = l_queue_new(); + transport->service_queue = l_queue_new(); + transport->next_service_tid = 256; + transport->ops = ops; + transport->family_list = l_hashmap_new(); return 0; } -static void __qmi_device_free(struct qmi_device *device) +static void qmi_transport_close(struct qmi_transport *transport) { - l_queue_destroy(device->service_queue, __request_free); - l_queue_destroy(device->req_queue, __request_free); + l_queue_destroy(transport->service_queue, __request_free); + l_queue_destroy(transport->req_queue, __request_free); - l_io_destroy(device->io); + l_io_destroy(transport->io); - l_hashmap_destroy(device->family_list, family_destroy); + l_hashmap_destroy(transport->family_list, family_destroy); } void qmi_result_print_tlvs(struct qmi_result *result) @@ -934,15 +932,15 @@ bool qmi_qmux_device_has_service(struct qmi_qmux_device *qmux, uint16_t type) return __qmux_service_info_find(qmux, type); } -static int qmi_qmux_device_write(struct qmi_device *device, +static int qmi_qmux_device_write(struct qmi_transport *transport, struct qmi_request *req) { struct qmi_qmux_device *qmux = - l_container_of(device, struct qmi_qmux_device, super); + l_container_of(transport, struct qmi_qmux_device, transport); struct qmi_mux_hdr *hdr; ssize_t bytes_written; - bytes_written = write(l_io_get_fd(device->io), req->data, req->len); + bytes_written = write(l_io_get_fd(transport->io), req->data, req->len); if (bytes_written < 0) return -errno; @@ -957,7 +955,7 @@ static int qmi_qmux_device_write(struct qmi_device *device, if (hdr->service == QMI_SERVICE_CONTROL) l_queue_push_tail(qmux->control_queue, req); else - l_queue_push_tail(device->service_queue, req); + l_queue_push_tail(transport->service_queue, req); return 0; } @@ -981,7 +979,7 @@ static void __rx_ctl_message(struct qmi_qmux_device *qmux, length = L_LE16_TO_CPU(msg->length); if (control->type == 0x02 && control->transaction == 0x00) { - handle_indication(&qmux->super, service_type, client_id, + handle_indication(&qmux->transport, service_type, client_id, message, length, data); return; } @@ -1005,7 +1003,7 @@ static bool received_qmux_data(struct l_io *io, void *user_data) ssize_t bytes_read; uint16_t offset; - bytes_read = read(l_io_get_fd(qmux->super.io), buf, sizeof(buf)); + bytes_read = read(l_io_get_fd(qmux->transport.io), buf, sizeof(buf)); if (bytes_read < 0) return true; @@ -1042,7 +1040,7 @@ static bool received_qmux_data(struct l_io *io, void *user_data) if (hdr->service == QMI_SERVICE_CONTROL) __rx_ctl_message(qmux, hdr->service, hdr->client, msg); else - __rx_message(&qmux->super, + __rx_message(&qmux->transport, hdr->service, hdr->client, msg); offset += len; @@ -1060,28 +1058,29 @@ static struct service_family *service_family_ref(struct service_family *family) static void service_family_unref(struct service_family *family) { - struct qmi_device *device; + struct qmi_transport *transport; if (--family->ref_count) return; - device = family->device; - if (!device) + transport = family->transport; + if (!transport) goto done; if (family->client_id) { unsigned int hash_id = family_list_create_hash(family->info.service_type, family->client_id); - l_hashmap_remove(device->family_list, L_UINT_TO_PTR(hash_id)); + l_hashmap_remove(transport->family_list, L_UINT_TO_PTR(hash_id)); } - l_hashmap_remove(device->family_list, + l_hashmap_remove(transport->family_list, L_UINT_TO_PTR(family->info.service_type)); - if (device->ops->client_release) - device->ops->client_release(device, family->info.service_type, - family->client_id); + if (transport->ops->client_release) + transport->ops->client_release(transport, + family->info.service_type, + family->client_id); done: l_queue_destroy(family->notify_list, NULL); @@ -1104,20 +1103,21 @@ static uint8_t __ctl_request_submit(struct qmi_qmux_device *qmux, req->tid = hdr->transaction; req->callback = callback; - l_queue_push_tail(qmux->super.req_queue, req); - wakeup_writer(&qmux->super); + l_queue_push_tail(qmux->transport.req_queue, req); + wakeup_writer(&qmux->transport); return req->tid; } -static struct service_family *service_family_create(struct qmi_device *device, +static struct service_family *service_family_create( + struct qmi_transport *transport, unsigned int group_id, const struct qmi_service_info *info, uint8_t client_id) { struct service_family *family = l_new(struct service_family, 1); family->ref_count = 0; - family->device = device; + family->transport = transport; family->client_id = client_id; family->notify_list = l_queue_new(); family->group_id = group_id; @@ -1148,7 +1148,7 @@ static struct qmi_request *find_control_request(struct qmi_qmux_device *qmux, if (!tid) return NULL; - req = l_queue_remove_if(qmux->super.req_queue, + req = l_queue_remove_if(qmux->transport.req_queue, __request_compare, L_UINT_TO_PTR(tid)); if (req) return req; @@ -1267,9 +1267,7 @@ done: static void qmux_discover_reply_timeout(struct l_timeout *timeout, void *user_data) { - struct qmi_device *device = user_data; - struct qmi_qmux_device *qmux = - l_container_of(device, struct qmi_qmux_device, super); + struct qmi_qmux_device *qmux = user_data; struct qmi_request *req; /* remove request from queues */ @@ -1388,7 +1386,7 @@ static void qmux_create_client_callback(struct qmi_request *r, info.major = req->major; info.minor = req->minor; - family = service_family_create(&qmux->super, + family = service_family_create(&qmux->transport, next_id(&qmux->next_group_id), &info, client_id->client); DEBUG(&qmux->debug, "service family created [client=%d,type=%d]", @@ -1397,7 +1395,7 @@ static void qmux_create_client_callback(struct qmi_request *r, family = service_family_ref(family); hash_id = family_list_create_hash(family->info.service_type, family->client_id); - l_hashmap_insert(qmux->super.family_list, + l_hashmap_insert(qmux->transport.family_list, L_UINT_TO_PTR(hash_id), family); done: @@ -1461,12 +1459,12 @@ static void qmux_client_release_callback(struct qmi_request *req, qmux->shutdown.release_users--; } -static void qmi_qmux_device_client_release(struct qmi_device *device, +static void qmi_qmux_device_client_release(struct qmi_transport *transport, uint16_t service_type, uint16_t client_id) { struct qmi_qmux_device *qmux = - l_container_of(device, struct qmi_qmux_device, super); + l_container_of(transport, struct qmi_qmux_device, transport); uint8_t release_req[] = { 0x01, 0x02, 0x00, service_type, client_id }; struct qmi_request *req; @@ -1552,7 +1550,7 @@ int qmi_qmux_device_shutdown(struct qmi_qmux_device *qmux, return 0; } -static const struct qmi_device_ops qmux_ops = { +static const struct qmi_transport_ops qmux_ops = { .write = qmi_qmux_device_write, .client_release = qmi_qmux_device_client_release, }; @@ -1568,7 +1566,7 @@ struct qmi_qmux_device *qmi_qmux_device_new(const char *device) qmux = l_new(struct qmi_qmux_device, 1); - if (qmi_device_init(&qmux->super, fd, &qmux_ops) < 0) { + if (qmi_transport_open(&qmux->transport, fd, &qmux_ops) < 0) { close(fd); l_free(qmux); return NULL; @@ -1576,7 +1574,8 @@ struct qmi_qmux_device *qmi_qmux_device_new(const char *device) qmux->next_control_tid = 1; qmux->control_queue = l_queue_new(); - l_io_set_read_handler(qmux->super.io, received_qmux_data, qmux, NULL); + l_io_set_read_handler(qmux->transport.io, + received_qmux_data, qmux, NULL); return qmux; } @@ -1587,7 +1586,7 @@ void qmi_qmux_device_free(struct qmi_qmux_device *qmux) return; DEBUG(&qmux->debug, "device %p", qmux); - __qmi_device_free(&qmux->super); + qmi_transport_close(&qmux->transport); if (qmux->shutting_down) { qmux->destroyed = true; @@ -1607,7 +1606,6 @@ void qmi_qmux_device_set_debug(struct qmi_qmux_device *qmux, } struct qmi_qrtr_node { - struct qmi_device super; unsigned int next_group_id; /* Matches requests with services */ struct l_queue *service_infos; struct debug_data debug; @@ -1617,6 +1615,7 @@ struct qmi_qrtr_node { qmi_destroy_func_t destroy; struct l_timeout *timeout; } lookup; + struct qmi_transport transport; }; static const struct qmi_service_info *__qrtr_service_info_find( @@ -1661,16 +1660,16 @@ static void __qrtr_lookup_finished(struct qmi_qrtr_node *node) memset(&node->lookup, 0, sizeof(node->lookup)); } -static int qmi_qrtr_node_write(struct qmi_device *device, +static int qmi_qrtr_node_write(struct qmi_transport *transport, struct qmi_request *req) { struct qmi_qrtr_node *node = - l_container_of(device, struct qmi_qrtr_node, super); + l_container_of(transport, struct qmi_qrtr_node, transport); struct sockaddr_qrtr addr; uint8_t *data; uint16_t len; ssize_t bytes_written; - int fd = l_io_get_fd(device->io); + int fd = l_io_get_fd(transport->io); /* Skip the QMUX header */ data = req->data + QMI_MUX_HDR_SIZE; @@ -1694,7 +1693,7 @@ static int qmi_qrtr_node_write(struct qmi_device *device, __qrtr_debug_msg(' ', data, bytes_written, req->info.service_type, &node->debug); - l_queue_push_tail(device->service_queue, req); + l_queue_push_tail(transport->service_queue, req); return 0; } @@ -1782,7 +1781,7 @@ static void qrtr_received_service_message(struct qmi_qrtr_node *node, uint32_t qrtr_port, const void *buf, size_t len) { - struct qmi_device *device = &node->super; + struct qmi_transport *transport = &node->transport; const struct l_queue_entry *entry; uint32_t service_type = 0; @@ -1804,7 +1803,7 @@ static void qrtr_received_service_message(struct qmi_qrtr_node *node, } __qrtr_debug_msg(' ', buf, len, service_type, &node->debug); - __rx_message(device, service_type, 0, buf); + __rx_message(transport, service_type, 0, buf); } static bool qrtr_received_data(struct l_io *io, void *user_data) @@ -1816,7 +1815,8 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) socklen_t addr_size; addr_size = sizeof(addr); - bytes_read = recvfrom(l_io_get_fd(qrtr->super.io), buf, sizeof(buf), 0, + bytes_read = recvfrom(l_io_get_fd(qrtr->transport.io), + buf, sizeof(buf), 0, (struct sockaddr *) &addr, &addr_size); DEBUG(&qrtr->debug, "Received %zd bytes from Node: %d Port: %d", bytes_read, addr.sq_node, addr.sq_port); @@ -1836,9 +1836,8 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) return true; } -static const struct qmi_device_ops qrtr_ops = { +static const struct qmi_transport_ops qrtr_ops = { .write = qmi_qrtr_node_write, - .client_release = NULL, }; struct qmi_qrtr_node *qmi_qrtr_node_new(uint32_t node) @@ -1852,15 +1851,15 @@ struct qmi_qrtr_node *qmi_qrtr_node_new(uint32_t node) qrtr = l_new(struct qmi_qrtr_node, 1); - if (qmi_device_init(&qrtr->super, fd, &qrtr_ops) < 0) { + if (qmi_transport_open(&qrtr->transport, fd, &qrtr_ops) < 0) { close(fd); l_free(qrtr); return NULL; } qrtr->service_infos = l_queue_new(); - - l_io_set_read_handler(qrtr->super.io, qrtr_received_data, qrtr, NULL); + l_io_set_read_handler(qrtr->transport.io, + qrtr_received_data, qrtr, NULL); return qrtr; } @@ -1870,7 +1869,7 @@ void qmi_qrtr_node_free(struct qmi_qrtr_node *node) if (!node) return; - __qmi_device_free(&node->super); + qmi_transport_close(&node->transport); l_queue_destroy(node->service_infos, l_free); if (node->lookup.destroy) @@ -1914,7 +1913,7 @@ int qmi_qrtr_node_lookup(struct qmi_qrtr_node *node, DEBUG(&node->debug, "node %p", node); - fd = l_io_get_fd(node->super.io); + fd = l_io_get_fd(node->transport.io); /* * The control node is configured by the system. Use getsockname to @@ -1960,7 +1959,7 @@ int qmi_qrtr_node_lookup(struct qmi_qrtr_node *node, struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, uint32_t type) { - struct qmi_device *device = &node->super; + struct qmi_transport *transport; struct service_family *family; const struct qmi_service_info *info; @@ -1970,7 +1969,9 @@ struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, if (type == QMI_SERVICE_CONTROL) return NULL; - family = l_hashmap_lookup(device->family_list, L_UINT_TO_PTR(type)); + transport = &node->transport; + + family = l_hashmap_lookup(transport->family_list, L_UINT_TO_PTR(type)); if (family) goto done; @@ -1978,9 +1979,9 @@ struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, if (!info) return NULL; - family = service_family_create(device, next_id(&node->next_group_id), + family = service_family_create(transport, next_id(&node->next_group_id), info, 0); - l_hashmap_insert(device->family_list, L_UINT_TO_PTR(type), family); + l_hashmap_insert(transport->family_list, L_UINT_TO_PTR(type), family); done: return service_create(family); } @@ -2340,8 +2341,8 @@ uint16_t qmi_service_send(struct qmi_service *service, qmi_service_result_func_t func, void *user_data, qmi_destroy_func_t destroy) { - struct qmi_device *device; struct service_family *family; + struct qmi_transport *transport; struct qmi_service_request *sreq; struct qmi_service_info *info; @@ -2352,8 +2353,8 @@ uint16_t qmi_service_send(struct qmi_service *service, if (!family->group_id) return 0; - device = family->device; - if (!device) + transport = family->transport; + if (!transport) return 0; info = &family->info; @@ -2370,7 +2371,7 @@ uint16_t qmi_service_send(struct qmi_service *service, sreq->user_data = user_data; sreq->destroy = destroy; - return __service_request_submit(device, service, &sreq->super); + return __service_request_submit(transport, service, &sreq->super); } struct request_lookup { @@ -2395,7 +2396,7 @@ static bool __request_compare_for_cancel(const void *a, const void *b) bool qmi_service_cancel(struct qmi_service *service, uint16_t id) { - struct qmi_device *device; + struct qmi_transport *transport; struct qmi_request *req; struct service_family *family; struct request_lookup lookup = { .tid = id }; @@ -2408,17 +2409,17 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id) if (!family->client_id) return false; - device = family->device; - if (!device) + transport = family->transport; + if (!transport) return false; lookup.group_id = family->group_id; lookup.service_handle = service->handle; - req = l_queue_remove_if(device->req_queue, __request_compare_for_cancel, - &lookup); + req = l_queue_remove_if(transport->req_queue, + __request_compare_for_cancel, &lookup); if (!req) { - req = l_queue_remove_if(device->service_queue, + req = l_queue_remove_if(transport->service_queue, __request_compare_for_cancel, &lookup); if (!req) @@ -2459,7 +2460,7 @@ static void remove_client(struct l_queue *queue, unsigned int group_id, static bool qmi_service_cancel_all(struct qmi_service *service) { - struct qmi_device *device; + struct qmi_transport *transport; if (!service) return false; @@ -2467,13 +2468,13 @@ static bool qmi_service_cancel_all(struct qmi_service *service) if (!service->family->group_id) return false; - device = service->family->device; - if (!device) + transport = service->family->transport; + if (!transport) return false; - remove_client(device->req_queue, + remove_client(transport->req_queue, service->family->group_id, service->handle); - remove_client(device->service_queue, + remove_client(transport->service_queue, service->family->group_id, service->handle); return true; From patchwork Mon Jun 24 19:32:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13710000 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DD651A00FC for ; Mon, 24 Jun 2024 19:33:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257605; cv=none; b=mfGZ7ySdy3dERbarBHgN6/8fnrIDmlEhRDQUh7qjb3aBcaeZT+87UUkeeZQEhSd7MOQdoNux1jkH8cNzfB+TYnI0AUCEjR5l3rRnjmlY2MBdpcDWS6Xg9rp+MjSx5edhAvgw5QHrNnEpbGUOyirP6CJ7TBY873vcSfHUJdk2EvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257605; c=relaxed/simple; bh=2V/oC7KQKCCzTbiTvFv9wFM9B/EZpCVfUopqWN10q6Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pWbbKfNXegx4ox3fzReg+vFxByAas3Fm5ZyY9L9ALJhE9138Zt8uVECFrb/CDiDxsNc4MNH7OTJWaZaKafiiH6YVLAC56UKKgGT0ZrZQdAZ/zgEFczxJrIqpEo5nee2CyybRyasisL+NMRR0iZQrEuA4Fqkj2DELCv7/znreQis= 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=h7O2oR3z; arc=none smtp.client-ip=209.85.161.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h7O2oR3z" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5bad217c51aso2527164eaf.1 for ; Mon, 24 Jun 2024 12:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257603; x=1719862403; 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=FXNJNwOT7xDihfLcVGWEuBZkot5I4i+LRBpJ29ZOu74=; b=h7O2oR3zMbGC6k0PgJSfTfgjOGvUqcB3RJC7bqTksF/3jnNlpmEc2wZ1yHEKiGNhpb o3DscmVDTq3IFek/boWbGAXndxb3z9AsH67380cj/OtsJW0cPFSw6XWHzGoX1sn+2ZTY V30KHauT8ilNOyxMAh25/uZOIklEkvIdGZSe/R2r/+Bdsnx6M3rA/bHmxuu/gwwpRLee iv5j1XOSDNaCp7kDLcT3mDZT8NYrH9gLXVhekmDoEDkMwozvnYqAhCIOe/g8CrDFJmev cNlaBfOdGaB1r+6msUTvcQE4w1Z7C8+bFqzztTPRXvWjdFgNnw2chLgZBR/A+5iuZYIm RoGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257603; x=1719862403; 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=FXNJNwOT7xDihfLcVGWEuBZkot5I4i+LRBpJ29ZOu74=; b=oG6Z75hEzal3azFozGAF7YVl3Ho2ePjgks9ZyPTGesWzIxBf+8KzX+SCZsyIztxEsi tKFYG0y88uUSPR+3tq4GdE712lNRD8c1KeqOMtaGQ05s8c3yCv+cLm0KElqCw7vA9vbh x+xG5iPHiHVGDjVYoi+j/LumLFhudU5RLgx4bX9QtCFkOSQJjfzC3nWJh40G85A2Jq6V TJOKDAGdsr+Sg38ba40nxxMwUYCKah2OZ+6igSZxCScsFOQLbqKKaWKs5Da0NZ7doCzZ t0cs7kbI4qFoUs91MF+mKaODEnUxJgI8lFa6vjmHDDdCrVaG/MgMf0rAVlEYfdmr4g1Z 1xlg== X-Gm-Message-State: AOJu0YzMLC5xTpOCX4a5WVyl1iYrs/tslwP121b1deswZ4p7168mLU6i LrZTL0ybUTTFjkC7Po82U2jZ9OGhgaU3/fxkT8dw6c5F7NSJudMGOPBIag== X-Google-Smtp-Source: AGHT+IGbQrRWfK0GaJQ61Z9fC40RvlFn7EFde/eg67j1lxke83fQJCUv9XKOhrp1/7xLVBmYylRdtw== X-Received: by 2002:a4a:3c53:0:b0:5ba:2d65:3fa0 with SMTP id 006d021491bc7-5c1eed86fe9mr5547122eaf.6.1719257602937; Mon, 24 Jun 2024 12:33: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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:22 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 07/13] qmi: Separate transport from qmux/qrtr debugging Date: Mon, 24 Jun 2024 14:32:50 -0500 Message-ID: <20240624193315.1164943-7-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Functions that send and receive bytes on the QMI transport are quite verbose (using hexdump, etc). It might be desirable to output debug information from the internal state of qmi_qrtr_node / qmi_qmux_device without also outputing everything coming and going over the wire. Add qmi_qmux_set_io_debug and qmi_qrtr_node_set_io_debug setters for shuttling low-level transport debug information. Update lower level rx and tx path functions to use the transport debug handlers instead of the ones on struct qmi_qrtr_node / struct qmi_qmux_device. --- drivers/qmimodem/qmi.c | 54 +++++++++++++++++++++++++++++------------- drivers/qmimodem/qmi.h | 4 ++++ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index d8fab9a34e5b..de2d3410a702 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -92,6 +92,7 @@ struct qmi_transport { uint16_t next_service_tid; struct l_hashmap *family_list; const struct qmi_transport_ops *ops; + struct debug_data debug; bool writer_active : 1; }; @@ -945,10 +946,10 @@ static int qmi_qmux_device_write(struct qmi_transport *transport, return -errno; l_util_hexdump(false, req->data, bytes_written, - qmux->debug.func, qmux->debug.user_data); + transport->debug.func, transport->debug.user_data); __qmux_debug_msg(' ', req->data, bytes_written, - qmux->debug.func, qmux->debug.user_data); + transport->debug.func, transport->debug.user_data); hdr = (struct qmi_mux_hdr *) req->data; @@ -998,6 +999,7 @@ static void __rx_ctl_message(struct qmi_qmux_device *qmux, static bool received_qmux_data(struct l_io *io, void *user_data) { struct qmi_qmux_device *qmux = user_data; + struct qmi_transport *transport = &qmux->transport; struct qmi_mux_hdr *hdr; unsigned char buf[2048]; ssize_t bytes_read; @@ -1008,7 +1010,7 @@ static bool received_qmux_data(struct l_io *io, void *user_data) return true; l_util_hexdump(true, buf, bytes_read, - qmux->debug.func, qmux->debug.user_data); + transport->debug.func, transport->debug.user_data); offset = 0; @@ -1033,7 +1035,8 @@ static bool received_qmux_data(struct l_io *io, void *user_data) break; __qmux_debug_msg(' ', buf + offset, len, - qmux->debug.func, qmux->debug.user_data); + transport->debug.func, + transport->debug.user_data); msg = buf + offset + QMI_MUX_HDR_SIZE; @@ -1605,6 +1608,15 @@ void qmi_qmux_device_set_debug(struct qmi_qmux_device *qmux, __debug_data_init(&qmux->debug, func, user_data); } +void qmi_qmux_device_set_io_debug(struct qmi_qmux_device *qmux, + qmi_debug_func_t func, void *user_data) +{ + if (!qmux) + return; + + __debug_data_init(&qmux->transport.debug, func, user_data); +} + struct qmi_qrtr_node { unsigned int next_group_id; /* Matches requests with services */ struct l_queue *service_infos; @@ -1663,8 +1675,6 @@ static void __qrtr_lookup_finished(struct qmi_qrtr_node *node) static int qmi_qrtr_node_write(struct qmi_transport *transport, struct qmi_request *req) { - struct qmi_qrtr_node *node = - l_container_of(transport, struct qmi_qrtr_node, transport); struct sockaddr_qrtr addr; uint8_t *data; uint16_t len; @@ -1683,15 +1693,15 @@ static int qmi_qrtr_node_write(struct qmi_transport *transport, bytes_written = sendto(fd, data, len, 0, (struct sockaddr *) &addr, sizeof(addr)); if (bytes_written < 0) { - DEBUG(&node->debug, "sendto: %s", strerror(errno)); + DEBUG(&transport->debug, "sendto: %s", strerror(errno)); return -errno; } l_util_hexdump(false, data, bytes_written, - node->debug.func, node->debug.user_data); + transport->debug.func, transport->debug.user_data); __qrtr_debug_msg(' ', data, bytes_written, - req->info.service_type, &node->debug); + req->info.service_type, &transport->debug); l_queue_push_tail(transport->service_queue, req); @@ -1802,13 +1812,14 @@ static void qrtr_received_service_message(struct qmi_qrtr_node *node, return; } - __qrtr_debug_msg(' ', buf, len, service_type, &node->debug); + __qrtr_debug_msg(' ', buf, len, service_type, &transport->debug); __rx_message(transport, service_type, 0, buf); } static bool qrtr_received_data(struct l_io *io, void *user_data) { struct qmi_qrtr_node *qrtr = user_data; + struct debug_data *debug = &qrtr->transport.debug; struct sockaddr_qrtr addr; unsigned char buf[2048]; ssize_t bytes_read; @@ -1818,14 +1829,13 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) bytes_read = recvfrom(l_io_get_fd(qrtr->transport.io), buf, sizeof(buf), 0, (struct sockaddr *) &addr, &addr_size); - DEBUG(&qrtr->debug, "Received %zd bytes from Node: %d Port: %d", + DEBUG(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->debug.func, qrtr->debug.user_data); + l_util_hexdump(true, buf, bytes_read, debug->func, debug->user_data); if (addr.sq_port == QRTR_PORT_CTRL) qrtr_received_control_packet(qrtr, buf, bytes_read); @@ -1887,6 +1897,15 @@ void qmi_qrtr_node_set_debug(struct qmi_qrtr_node *node, __debug_data_init(&node->debug, func, user_data); } +void qmi_qrtr_node_set_io_debug(struct qmi_qrtr_node *node, + qmi_debug_func_t func, void *user_data) +{ + if (!node) + return; + + __debug_data_init(&node->transport.debug, func, user_data); +} + static void qrtr_lookup_reply_timeout(struct l_timeout *timeout, void *user_data) { @@ -1904,6 +1923,7 @@ int qmi_qrtr_node_lookup(struct qmi_qrtr_node *node, socklen_t addr_len; ssize_t bytes_written; int fd; + struct debug_data *debug = &node->transport.debug; if (!node || !func) return -EINVAL; @@ -1921,12 +1941,12 @@ int qmi_qrtr_node_lookup(struct qmi_qrtr_node *node, */ addr_len = sizeof(addr); if (getsockname(fd, (struct sockaddr *) &addr, &addr_len) < 0) { - DEBUG(&node->debug, "getsockname failed: %s", strerror(errno)); + DEBUG(debug, "getsockname failed: %s", strerror(errno)); return -errno; } if (addr.sq_family != AF_QIPCRTR || addr_len != sizeof(addr)) { - DEBUG(&node->debug, "Unexpected sockaddr family: %d size: %d", + DEBUG(debug, "Unexpected sockaddr family: %d size: %d", addr.sq_family, addr_len); return -EIO; } @@ -1939,12 +1959,12 @@ int qmi_qrtr_node_lookup(struct qmi_qrtr_node *node, sizeof(packet), 0, (struct sockaddr *) &addr, addr_len); if (bytes_written < 0) { - DEBUG(&node->debug, "sendto failed: %s", strerror(errno)); + DEBUG(debug, "sendto failed: %s", strerror(errno)); return -errno; } l_util_hexdump(false, &packet, bytes_written, - node->debug.func, node->debug.user_data); + debug->func, 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 db20280f9aa3..e61e9cc9e878 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -72,6 +72,8 @@ 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); +void qmi_qmux_device_set_io_debug(struct qmi_qmux_device *qmux, + qmi_debug_func_t func, void *user_data); 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); @@ -91,6 +93,8 @@ 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); +void qmi_qrtr_node_set_io_debug(struct qmi_qrtr_node *node, + qmi_debug_func_t func, void *user_data); 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); From patchwork Mon Jun 24 19:32:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13710001 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.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 C547D1A01A1 for ; Mon, 24 Jun 2024 19:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257606; cv=none; b=j9M+tjAtZPJ7kJL4P5oUU2TOUeBI+3zs5vvnyBhY2iILA4K9KGSYQscYw0SJmmcPJJNA2UfPlL4UWhCyjtT/DX/ekPWFlyPnTMOndzoscIeNrmAQKZLF7F4zP1JsClN0tcWMTnUkuwCk9wBXsTyiLi5YqyZ4jdLFPkjkNQFHJ6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257606; c=relaxed/simple; bh=N1uKVcD0uw4noIf+jmTYaK+rEmryhD2zpY7EGzkwxNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fx+StzP8vaboBi+iEGfhzM7jF+FT2rasyLgwu2gI4F0xhpM9Zvl+vX7UImBKWtP59RJBqm/Dv6tGeg45D7mzQmiPAwU0Kxflr4Y694NJ6KKpJqT2Z8vbfNA2B7RbXPE2Q56qgmx0fOVNM3cCIFC7LHq9RF9SKWqsz/5UaiaD2mY= 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=Pvlef8tE; arc=none smtp.client-ip=209.85.161.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="Pvlef8tE" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-5b970e90ab8so2708624eaf.3 for ; Mon, 24 Jun 2024 12:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257604; x=1719862404; 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=UeT9+Ikd9VFzsN+KD509wRzZWwFtwP5snd+Dz/9Sh+8=; b=Pvlef8tEXfG4mAToPQOvIQnGOUNVuFcE0qWkwU+RUC2DEoNMHuhz/32++HhZxJ99OY +9C/bAwXy1q2HqGeiA+nHQmHewH+56t5TDxaxkzvrpZ7AvHfslPQvCkn8XSoa38vfp4H C/sOqUMcxN8XPFYnQQCX8DXEG+MOMTXjHeVkK5Z24rAvGdiMWen7pkFtOhWRiooek7tB OBKdm7UZC7iO3eDzYa8aTwOd1YhLApoWMXAAfNioBuBpDyEAHKstm1TSVBU0953e6z7d oQ6d8HXihEqdWwplpDQ900PW+LT0iJZKqphq/faPs8j0rwq/sC6iHUGdHmidS/6uYmrY xyeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257604; x=1719862404; 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=UeT9+Ikd9VFzsN+KD509wRzZWwFtwP5snd+Dz/9Sh+8=; b=Tp5f6tzAxxS3S+WjcRGLTKD2fOPuRliSZ2PZleazfQjiahh2WJ+5VzYPLq90HDj2F3 XV1gPPhptmAMlg9vajMpiWdOiNflBxbEDscNs6cSUyjDxTja4CktRwtIulnQZdOVqrjT JIPPU+Dw9k+dc2Bhcn5Da4arQRoy4T8QDrUH5LLrql2KxCI0toyummdcw8We7m4V7zcw b1NtFX80JRJg+tXxuiIvw2F0+VAaRWF2HLeF9eE3Dq3cpPctGskn8DSEaSr1IoWOpYgo 1YdmPU4f/a+HWy0yBWGK3/rzuwcLyTdjtVAH3cpr/bQCiKdTf2ZsBcqh0W/6A/1oH/De ZErQ== X-Gm-Message-State: AOJu0YwhRu3vFAQx+7LHYR2rX2R/w0hApszPn02Ch9kkCVgDoX0qjuZN aE+WLKO0k8I+Yrd5Me5WhaLsISNp0Hdce3c23Jsl7KZy40FbyaNvFhx5KA== X-Google-Smtp-Source: AGHT+IHkTBKbaN/f67GVDWnQW1nNqNxvIce6VoD1CXkEZvCaGZbvVy017tbQywv8K4cK2cjbHYDpVw== X-Received: by 2002:a4a:8405:0:b0:5ba:e1aa:9346 with SMTP id 006d021491bc7-5c1eed10c0fmr5726037eaf.4.1719257603696; Mon, 24 Jun 2024 12:33:23 -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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:23 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 08/13] gobi: Enable io debugging only if OFONO_QMI_IO_DEBUG is set Date: Mon, 24 Jun 2024 14:32:51 -0500 Message-ID: <20240624193315.1164943-8-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 QMUX/QMI protocol details are now mostly stable to the point that hexdumping what is being sent / received over the wire is just noise. qmi_qmux_device now supports setting separate debug handlers for the underlying object and the low-level IO. If OFONO_QMI_DEBUG environment variable is set, enable debugging for core QMUX/QMI implementation but disable low-level IO debugging. If IO debugging is desired, use the OFONO_QMI_IO_DEBUG environment variable. --- plugins/gobi.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index e25807753e20..88e4c7fc4887 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -89,7 +89,14 @@ static void gobi_debug(const char *str, void *user_data) { const char *prefix = user_data; - ofono_info("%s%s", prefix, str); + ofono_debug("%s%s", prefix, str); +} + +static void gobi_io_debug(const char *str, void *user_data) +{ + const char *prefix = user_data; + + ofono_debug("%s%s", prefix, str); } /* @@ -543,7 +550,11 @@ static int gobi_enable(struct ofono_modem *modem) return -EIO; if (getenv("OFONO_QMI_DEBUG")) - qmi_qmux_device_set_debug(data->device, gobi_debug, "QMI: "); + qmi_qmux_device_set_debug(data->device, gobi_debug, ""); + + if (getenv("OFONO_QMI_IO_DEBUG")) + qmi_qmux_device_set_io_debug(data->device, + gobi_io_debug, "QMI: "); r = qmi_qmux_device_discover(data->device, discover_cb, modem, NULL); if (!r) From patchwork Mon Jun 24 19:32:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13710002 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CD4C19EED7 for ; Mon, 24 Jun 2024 19:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257606; cv=none; b=f3y3qtM+roVVZc1C2i9AZBedUuj1I+Sh9OP0qcpB0kYfha1jDAEfjkPpyZodAmFX3s1mmJnK3UVO+mfyirBrk7CwwbPlZWPtXiM59+h7TkP3Q/UIokdJi/45nl+4ODIqhDr0J6WCA+cMhrL51x8Cg+PoyUE2uEnXWw93fO5LCuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257606; c=relaxed/simple; bh=ZGtiHPN21MhCAaqJM6rSmOMD38smuTtO7u5r8aJN/JU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nuEaGsQ4CKWOTAu/FlnH2uQxW3WWJ4ZqExfKtlLx2QA0a2spqUYLI8PS3PcEOGXY9HkYKofwar6+XBnP9aIx2XsoUV/fq/Bk5pTOxGCnHUJaaSyuFFsSlHch+hLOUycOBfUx7GFOYpQlIs+ajY5V+OyurOatmWMB0agNhfuoOcQ= 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=ZDNkYc/R; arc=none smtp.client-ip=209.85.161.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZDNkYc/R" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-5baf982f56dso2369400eaf.3 for ; Mon, 24 Jun 2024 12:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257604; x=1719862404; 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=6qAO34xzasG+cTdqhTqw6kXz7aXB7KmCOSR39U9iINc=; b=ZDNkYc/RyGiEw7FQADqIkkLMOQ6aFSMTCBQ+qh0ZrrKXtV/o2BP8BjM4OyXtmh1uDI Ta5Z4ZJbfJqtBb3omSWBPasvM3FxFeM4+EUqcXws/sucnRudxEFKzv6eekWeYFnkJwvR 7NgTJSM5U5+2fPnro2iE82CF1dL0DYMpyW/I4oGmNKYFtHDfirehWV3qHsHIFno9L9bz nusiekNXmEHGMvflZjmrUb7Aj6RQQB+sgvPXL76N6GvzViKmEmjE+d4tPnmX7jUUdbHd OW/I92q+aoJ8q13x8jyqxYwT9/jadm2elYIlDnC3HnKXt1ts7rXmzQRiXr7Qop05/z+a rpZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257604; x=1719862404; 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=6qAO34xzasG+cTdqhTqw6kXz7aXB7KmCOSR39U9iINc=; b=FP9GSt2GaC+Q6d9sUCKeJute+epPUJtQe/3tCBgVNiP7zMA++18xut69s4rLzb463G 2uMK6dV9YwUEKKL1CAORdcZdh+gMOZrZUAtosD0bBQtmN4kqV8VSkOSMswFBejkaE/qh 7QLDE/ExQIRaN67uQnZaRWIUWhBAPLANOWn995SJlCdcvyz5hVGJhgGfqnVo8bSDxBiT uwd0BPAcKalWIITR5qdUEIc9kjBiVGQoM0KtyrR8vy7LNbLlmhQ9SF3GZVoG+HNVv28s jl+dSh+jX7dIXds6WRz+s0s/c2/RqfU/kZiQUHitDWA53C0ZW5ckaVa3AOgExPYVhO5V I2pg== X-Gm-Message-State: AOJu0YylGifRmrP0o1OTVgfQVmkhrj08PxbqrjgUZHZI5uu20rKzYvfu 1WGpZsi1HgLNAOTF9B66CGgr/OOF5izHEvc3Br2KRTpG0uZBlu4uxawLQg== X-Google-Smtp-Source: AGHT+IEUJpaQZEVFi4tGyeCT27/z0x8woWcRbYKtiGLbRF3rijy/DtnDaKrMty+v0CSoN8AShMwnrw== X-Received: by 2002:a4a:91d3:0:b0:5c1:b998:a859 with SMTP id 006d021491bc7-5c1eec0a767mr5602455eaf.2.1719257604598; Mon, 24 Jun 2024 12:33:24 -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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:24 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 09/13] qmiqrtr: Enable io debugging only if OFONO_QMI_IO_DEBUG is set Date: Mon, 24 Jun 2024 14:32:52 -0500 Message-ID: <20240624193315.1164943-9-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 QRTR/QMI protocol details are now mostly stable to the point that hexdumping what is being sent / received over the wire is just noise. qmi_qrtr_node now supports setting separate debug handlers for the underlying object and the low-level IO. If OFONO_QMI_DEBUG environment variable is set, enable debugging for core QRTR/QMI implementation but disable low-level IO debugging. If IO debugging is desired, use the OFONO_QMI_IO_DEBUG environment variable. --- plugins/qrtrqmi.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c index 4117cac11423..b64ab355a2e8 100644 --- a/plugins/qrtrqmi.c +++ b/plugins/qrtrqmi.c @@ -52,13 +52,20 @@ struct qrtrqmi_data { bool have_voice : 1; }; -static void qrtrqmi_debug(const char *str, void *user_data) +static void qrtrqmi_io_debug(const char *str, void *user_data) { const char *prefix = user_data; ofono_info("%s%s", prefix, str); } +static void qrtrqmi_debug(const char *str, void *user_data) +{ + const char *prefix = user_data; + + ofono_debug("%s%s", prefix, str); +} + /* * Probe the modem. The following modem properties are expected to be set * in order to initialize the driver properly: @@ -213,7 +220,11 @@ static int qrtrqmi_enable(struct ofono_modem *modem) return -EIO; if (getenv("OFONO_QMI_DEBUG")) - qmi_qrtr_node_set_debug(data->node, qrtrqmi_debug, "QRTR: "); + qmi_qrtr_node_set_debug(data->node, qrtrqmi_debug, ""); + + if (getenv("OFONO_QMI_IO_DEBUG")) + qmi_qrtr_node_set_io_debug(data->node, + qrtrqmi_io_debug, "QRTR: "); r = qmi_qrtr_node_lookup(data->node, lookup_done, modem, NULL); if (!r) From patchwork Mon Jun 24 19:32:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13710003 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 47B5D1A01A9 for ; Mon, 24 Jun 2024 19:33:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257607; cv=none; b=OrFiXLqHqeFevMapQ7Iohun4F0RjEZYTzXwZyeUVauVWDY2zUvi3vtsX8W/Hqw3SZYf8ziqZCN24yV+vmF0fKqpRri7lFFkWJHrwJH6NL7GDxieERmPPA3Tzt6Gtrf/EHwNOgKk97ewMYKQyWxEajhCuoRpDMNOhlaxP5FMVTIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257607; c=relaxed/simple; bh=q2xnZlt/m5I5YG0NKJYp1eMi2APojbTBKYtZs/5/h2I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U2mFFLxVZlB6q5FDvLSGlDH0ZvnRmml69mO5s0up4268hiDXxssyoR0S6CJuVcZwI7UF3erXuazqYAbu6HWmIT2dsxbpub1gzdX6kToP+hT4xIOlTMHW1XyTYiHsoOBiENAfWMPZ416mpzYkO+8wAcbNlW1v6ahDbYOTk14Szds= 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=MXMF86X7; arc=none smtp.client-ip=209.85.161.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="MXMF86X7" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5c1ef5ac47eso892943eaf.2 for ; Mon, 24 Jun 2024 12:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257605; x=1719862405; 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=QIOf5a18nPN8XVNLEkurhAgeKtw6Y5gH32tbhaqR5jM=; b=MXMF86X7BkqKODIUsKKkcVA5bEZ8A5wXzqjUk7wH5TYtbXEvQ3HKdbfiPEgBjD2Wbe jw1QjVMAs0nz4TUOFhUwR2bdCaDq/IuXAKaWwvWzZqPND+o0Fz6gHOAsgo325trKKmBP K172gTTile04VX6XqlOmlZsdGf/sr8m57X0GqLxWLWUJkApTE+8DjOxxCSW7GBtdANqr wOg5BaLSQPKzVz/gZ0wMTdyfnf9yrCbtKsJWq2F2OBIoqplH66Qo4KWKFAFiykFVG+e0 Hx1GipuVwSh00sQgZXEIS65dSup7frWf6I3nKzyjk/O3kudxKJvLm5CgPZH/C6Wo46az oaGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257605; x=1719862405; 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=QIOf5a18nPN8XVNLEkurhAgeKtw6Y5gH32tbhaqR5jM=; b=GSODwC1afAKiwlQzJMffgJS9dTqR9dEIFGCal5S9T3yjktkJe9AYWtUqDBIplKfNQh 5GRXsZKdtnaFVygsFBNPJ+YoKzLiWJY/8E8Ccy3j3xfv9U5b55YanaU2F1/ZQrP6bS/x UWRfJGskq/wAMjl/gUta5h9FVPBB+eAotYsGnSO4w9IwvLHtxZOxvm/6AVFGMX7XitEY 54nj4p0b3I/gbN+GfxTb7/mhV46bEDtkXGpKTGpq7gXFF+6gBwO78cKmDtENFiPU//rN zTADDdtr6zOLiazh0ot13UXj4cvIIg4QzNPJfmYHHG5/7RE9UQeVvTUC4f8icONfiDn8 Efpg== X-Gm-Message-State: AOJu0Yx6Vn2H2vXYHyF16obIoThA6AIVif2LTHChg/2FjiUEL/CGUejf fAL8oPhMmfFkShRywlTaoJhLPuVD6P1o4u3cZHlrN9sGkda1fD7Q/hKtFQ== X-Google-Smtp-Source: AGHT+IHuTWsX+tsVEMyOJaKFc/m7OdV/b4NjZX4R58tTvpti8JyKUFyxYG98dENzs/P7hhfMgAbvdw== X-Received: by 2002:a4a:92c9:0:b0:5bd:a078:aba2 with SMTP id 006d021491bc7-5c1e95e1358mr6104256eaf.2.1719257605246; Mon, 24 Jun 2024 12:33:25 -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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:25 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 10/13] qmi: Move release_client operation into service_family Date: Mon, 24 Jun 2024 14:32:53 -0500 Message-ID: <20240624193315.1164943-10-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 qmi_device has been renamed into qmi_transport which now encapsulated the details of maintaining a list of outstanding requests, active service families and low-level tx/rx details. The client_remove operation is now out of place and logically fits much better on the service_family object. Remove the release_client operation from qmi_transport_ops. Introduce two specializations of service_family for qrtr and qmux respectively. Release of QMUX clients will now be triggered when the QMUX service family object is destroyed. --- drivers/qmimodem/qmi.c | 121 +++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 47 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index de2d3410a702..7fba86eb1e29 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -81,8 +81,6 @@ struct debug_data { struct qmi_transport_ops { int (*write)(struct qmi_transport *transport, struct qmi_request *req); - void (*client_release)(struct qmi_transport *transport, - uint16_t service_type, uint16_t client_id); }; struct qmi_transport { @@ -132,6 +130,7 @@ struct service_family { uint16_t next_notify_id; unsigned int next_service_handle; struct l_queue *notify_list; + void (*free_family)(struct service_family *); }; struct qmi_service { @@ -1080,14 +1079,9 @@ static void service_family_unref(struct service_family *family) l_hashmap_remove(transport->family_list, L_UINT_TO_PTR(family->info.service_type)); - if (transport->ops->client_release) - transport->ops->client_release(transport, - family->info.service_type, - family->client_id); - done: l_queue_destroy(family->notify_list, NULL); - l_free(family); + family->free_family(family); } static uint8_t __ctl_request_submit(struct qmi_qmux_device *qmux, @@ -1112,21 +1106,18 @@ static uint8_t __ctl_request_submit(struct qmi_qmux_device *qmux, return req->tid; } -static struct service_family *service_family_create( - struct qmi_transport *transport, - unsigned int group_id, - const struct qmi_service_info *info, uint8_t client_id) +static void __service_family_init(struct service_family *family, + struct qmi_transport *transport, + unsigned int group_id, + const struct qmi_service_info *info, + uint8_t client_id) { - struct service_family *family = l_new(struct service_family, 1); - family->ref_count = 0; family->transport = transport; family->client_id = client_id; family->notify_list = l_queue_new(); family->group_id = group_id; memcpy(&family->info, info, sizeof(family->info)); - - return family; } static struct qmi_service *service_create(struct service_family *family) @@ -1310,6 +1301,50 @@ int qmi_qmux_device_discover(struct qmi_qmux_device *qmux, return 0; } +static void qmux_client_release_callback(struct qmi_request *req, + uint16_t message, uint16_t length, + const void *buffer) +{ + struct qmi_qmux_device *qmux = req->user_data; + + qmux->shutdown.release_users--; +} + +static void qmux_service_family_free(struct service_family *family) +{ + struct qmi_qmux_device *qmux = l_container_of(family->transport, + struct qmi_qmux_device, + transport); + uint8_t release_req[] = { 0x01, 0x02, 0x00, + family->info.service_type, family->client_id }; + struct qmi_request *req; + + if (family->transport) { + qmux->shutdown.release_users++; + req = __control_request_alloc(QMI_CTL_RELEASE_CLIENT_ID, + release_req, sizeof(release_req), 0); + req->user_data = qmux; + + __ctl_request_submit(qmux, req, qmux_client_release_callback); + } + + l_free(family); +} + +static struct service_family *qmux_service_family_new( + struct qmi_transport *transport, + unsigned int group_id, + const struct qmi_service_info *info, + uint8_t client_id) +{ + struct service_family *family = l_new(struct service_family, 1); + + __service_family_init(family, transport, group_id, info, client_id); + family->free_family = qmux_service_family_free; + + return family; +} + struct qmux_create_client_request { struct qmi_qmux_device *qmux; uint8_t type; @@ -1389,7 +1424,7 @@ static void qmux_create_client_callback(struct qmi_request *r, info.major = req->major; info.minor = req->minor; - family = service_family_create(&qmux->transport, + family = qmux_service_family_new(&qmux->transport, next_id(&qmux->next_group_id), &info, client_id->client); DEBUG(&qmux->debug, "service family created [client=%d,type=%d]", @@ -1453,33 +1488,6 @@ bool qmi_qmux_device_create_client(struct qmi_qmux_device *qmux, return true; } -static void qmux_client_release_callback(struct qmi_request *req, - uint16_t message, uint16_t length, - const void *buffer) -{ - struct qmi_qmux_device *qmux = req->user_data; - - qmux->shutdown.release_users--; -} - -static void qmi_qmux_device_client_release(struct qmi_transport *transport, - uint16_t service_type, - uint16_t client_id) -{ - struct qmi_qmux_device *qmux = - l_container_of(transport, struct qmi_qmux_device, transport); - uint8_t release_req[] = { 0x01, 0x02, 0x00, service_type, client_id }; - struct qmi_request *req; - - qmux->shutdown.release_users++; - - req = __control_request_alloc(QMI_CTL_RELEASE_CLIENT_ID, - release_req, sizeof(release_req), 0); - req->user_data = qmux; - - __ctl_request_submit(qmux, req, qmux_client_release_callback); -} - static void __qmux_device_free(struct qmi_qmux_device *qmux) { l_queue_destroy(qmux->control_queue, __request_free); @@ -1555,7 +1563,6 @@ int qmi_qmux_device_shutdown(struct qmi_qmux_device *qmux, static const struct qmi_transport_ops qmux_ops = { .write = qmi_qmux_device_write, - .client_release = qmi_qmux_device_client_release, }; struct qmi_qmux_device *qmi_qmux_device_new(const char *device) @@ -1672,6 +1679,25 @@ static void __qrtr_lookup_finished(struct qmi_qrtr_node *node) memset(&node->lookup, 0, sizeof(node->lookup)); } +static void qrtr_service_family_free(struct service_family *family) +{ + l_free(family); +} + +static struct service_family *qrtr_service_family_new( + struct qmi_transport *transport, + unsigned int group_id, + const struct qmi_service_info *info, + uint8_t client_id) +{ + struct service_family *family = l_new(struct service_family, 1); + + __service_family_init(family, transport, group_id, info, client_id); + family->free_family = qrtr_service_family_free; + + return family; +} + static int qmi_qrtr_node_write(struct qmi_transport *transport, struct qmi_request *req) { @@ -1999,8 +2025,9 @@ struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, if (!info) return NULL; - family = service_family_create(transport, next_id(&node->next_group_id), - info, 0); + family = qrtr_service_family_new(transport, + next_id(&node->next_group_id), + info, 0); l_hashmap_insert(transport->family_list, L_UINT_TO_PTR(type), family); done: return service_create(family); From patchwork Mon Jun 24 19:32:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13710004 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFF971A00F1 for ; Mon, 24 Jun 2024 19:33:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257608; cv=none; b=IcbdnVUVo8ODtPbBj1mPaPY5Osy6yKRBkLJLQqhxgNnbpFPxisvcmBAIeZiM7WKmKNQp/LnBWgqBoAY2F2zXmWQB+howZPVCp65kPG2VxYC+zGMk6Qo3SrUaGEjgma54YIiW8hW/0uB53w95zJtJVbYbkQiDWN+ihPm9iHW9+VQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257608; c=relaxed/simple; bh=Sf9SAntpBFui7nghYemR2jMqlLdL23TjEM13Oni+L9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LHjpAuq+8BXp9GWJDIJYAgDx9uq3xtpaWZ+e8+mWbwRt+Gq4R8xbH1pvWipq/ykOo7KRe3jwP1yCeEd1XwPYLPtcHI7aJ9Cy6TRqJz0W+FjBwmVugM2NNIIcKPSh3dErLjBxPTpk6l6Y5HOITUvuohnBdGtTX/G0yU3hKTDzJ1o= 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=RNgyvdzW; arc=none smtp.client-ip=209.85.161.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RNgyvdzW" Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5c204600d49so568963eaf.0 for ; Mon, 24 Jun 2024 12:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257606; x=1719862406; 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=GEJTUCe2wf8DQsbo+XSZs7Jrvac30T/fzttl+mCxL7Y=; b=RNgyvdzWI+zHAI2/mN1tyOjLQGZeVGxJGQZq3DWpHuZ43Md5h5+JUNcUZkEgl83B3v qyahV77RM53nxTldgtAOueF1/YDhrA2wYLuzcLA/GPyLwTd3eWP4fFclJD9ULkFWeJ6P towfRUCeShiSzjqcctIlIDT9CPwnDE8dmEUSEKudiU+viKFImCQxmSiSdB1PqSF+JDkF iiaaJwiNirkx0wBx0/wSqKzLQ+jnluGMIWQZWOnVxSOFGfLW7ohRueXYYo+ie6T6XoYV o4ubGaoo2wU2Tvb4FofWGuLLgo6gR6+ASlR2B0nMTh/naj9frPePgUT269Dsg7VYA420 98tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257606; x=1719862406; 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=GEJTUCe2wf8DQsbo+XSZs7Jrvac30T/fzttl+mCxL7Y=; b=KDQaniiuRmdSRM76G0wsk4IpY0aDIDkkpeKJohkrwFBRkDaSTgxg/MsecC+TV796Yi ylgvSMBGb3Ba4VtCwoRwuv+aHW4y6LidglczKCjAv0br/bKbxP2FedoW9unm9i7rZYTZ 4ecJJpNHS/M10/AuPiX9/SGFiwjB5oAVHvkqObWOGCLZXJ5CdGKyV3bBiaigRKysLDDb OQxsOyea1LAl1f/wQPADxfLwwBHUxcFwSFZ7kMsDihXM3ipGlAjCm0G+uKPCMFbhC7p/ N22+Bnw+GO1z4FA6QO6qyzvKubhUgWVqTuHbHwLktqteKX5GqhqiR/j+Vh/xGIx+OTMA 5KKw== X-Gm-Message-State: AOJu0Yx1Wrprkpcf6b0Zujaxuz/l5pC4ljZ313I6+lB4uHw9yA2S1KvH 8llaTm4ZNlF4eWyv38c5siQREo3i1gD95Q6i6THycLHXCVLVJ9ZU5fRhAg== X-Google-Smtp-Source: AGHT+IE/xqzQ+nHdRb52aYgjfRsLc/+HQzKBD6U0YIcKjtYHUvrluorJL8ZuOUxpVAB8K4hwySTdPQ== X-Received: by 2002:a4a:e501:0:b0:5c1:ebec:81fa with SMTP id 006d021491bc7-5c1ebec8fd8mr5932212eaf.4.1719257606038; Mon, 24 Jun 2024 12:33:26 -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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:25 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 11/13] qmi: Add dedicated service for qrtr Date: Mon, 24 Jun 2024 14:32:54 -0500 Message-ID: <20240624193315.1164943-11-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-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 | 91 ++++++++++++++++++++++++++++++++++++++++++ drivers/qmimodem/qmi.h | 3 ++ 2 files changed, 94 insertions(+) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 7fba86eb1e29..639c0c44b519 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -2041,6 +2041,97 @@ bool qmi_qrtr_node_has_service(struct qmi_qrtr_node *node, uint16_t type) return __qrtr_service_info_find(node, type); } +struct qrtr_service_family_dedicated { + struct service_family super; + struct qmi_transport transport; +}; + +static void qrtr_service_family_dedicated_free(struct service_family *family) +{ + struct qrtr_service_family_dedicated *dfamily = + l_container_of(family, + struct qrtr_service_family_dedicated, super); + + qmi_transport_close(&dfamily->transport); + l_free(dfamily); +} + +static bool qrtr_service_family_dedicated_rx(struct l_io *io, void *user_data) +{ + struct qrtr_service_family_dedicated *family = user_data; + struct debug_data *debug = &family->transport.debug; + const struct qmi_service_info *info = &family->super.info; + struct sockaddr_qrtr addr; + unsigned char buf[2048]; + ssize_t bytes_read; + socklen_t addr_size; + int fd = l_io_get_fd(family->transport.io); + + addr_size = sizeof(addr); + bytes_read = recvfrom(fd, buf, sizeof(buf), 0, + (struct sockaddr *) &addr, &addr_size); + DEBUG(debug, "fd %d Received %zd bytes from Node: %d Port: %d", + fd, bytes_read, addr.sq_node, addr.sq_port); + + if (bytes_read < 0) + return true; + + if (addr.sq_port != info->qrtr_port && addr.sq_node != info->qrtr_node) + return true; + + l_util_hexdump(true, buf, bytes_read, debug->func, debug->user_data); + __qrtr_debug_msg(' ', buf, bytes_read, info->service_type, debug); + __rx_message(&family->transport, info->service_type, 0, buf); + + return true; +} + +struct qmi_service *qmi_qrtr_node_get_dedicated_service( + struct qmi_qrtr_node *node, + uint16_t type) +{ + struct qrtr_service_family_dedicated *family; + const struct qmi_service_info *info; + int fd; + + if (!node) + return NULL; + + if (type == QMI_SERVICE_CONTROL) + return NULL; + + info = __qrtr_service_info_find(node, type); + if (!info) + return NULL; + + fd = socket(AF_QIPCRTR, SOCK_DGRAM, 0); + if (fd < 0) + return NULL; + + family = l_new(struct qrtr_service_family_dedicated, 1); + + if (qmi_transport_open(&family->transport, fd, &qrtr_ops) < 0) { + close(fd); + l_free(family); + return NULL; + } + + DEBUG(&node->debug, "Opening dedicated service for %u", type); + __service_family_init(&family->super, &family->transport, + next_id(&node->next_group_id), info, 0); + family->super.free_family = qrtr_service_family_dedicated_free; + l_hashmap_insert(family->transport.family_list, + L_UINT_TO_PTR(type), family); + + l_io_set_read_handler(family->transport.io, + qrtr_service_family_dedicated_rx, + family, NULL); + memcpy(&family->transport.debug, &node->transport.debug, + sizeof(struct debug_data)); + + return service_create(&family->super); +} + 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 e61e9cc9e878..0e48313ebb64 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -100,6 +100,9 @@ int qmi_qrtr_node_lookup(struct qmi_qrtr_node *node, void *user_data, qmi_destroy_func_t destroy); struct qmi_service *qmi_qrtr_node_get_service(struct qmi_qrtr_node *node, uint32_t type); +struct qmi_service *qmi_qrtr_node_get_dedicated_service( + struct qmi_qrtr_node *node, + uint16_t type); bool qmi_qrtr_node_has_service(struct qmi_qrtr_node *node, uint16_t type); struct qmi_param; From patchwork Mon Jun 24 19:32:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13710005 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.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 970E019EED7 for ; Mon, 24 Jun 2024 19:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257609; cv=none; b=SpXQ2Rkk6YRTiS+VbWh+Nna5GYB9DUpA/bzPaFD+ZndGiTXuOvdb1DGrEoh+sa3VWO4u9q6FZlFXqTrGLqPtP2lDJP8WjksB2693epmzfhtW/nqsJSfPLsvLEuEcQn17+xhO87bIzL865yg+EG6dhSzNsGmyssMggWik4faxdvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257609; c=relaxed/simple; bh=YTsHy/XXqQ4v/EyfUDG+UktLA74VYIXgtt7ICehFgXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O5DLgareXkHiGpDZcWQvhLHFI7A3XOqs1OGSlDtyvJ/jD1LHODOuqYVEviSlwS/m+iXXdCziWr/otTY+NStewyhLTq4PHoY6DDAGeue8WoCuxE3YUSkqgj+5fFgYfBt74f4g0pQC9z7Q4aXv0RAsjAZ1WNhKmbMdSnw80pP0cDo= 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=b27BD8Ik; arc=none smtp.client-ip=209.85.161.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="b27BD8Ik" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-5b970a97e8eso2564924eaf.1 for ; Mon, 24 Jun 2024 12:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257607; x=1719862407; 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=YHMXmRqIR3vrTAk2uMbRVffF80cd0U6xix7wu3WybSk=; b=b27BD8IkBva6h7WiT07uRWWICu0bX1lPx9nA0qKhYZueENpWXrjnYkrXMO0Tkj2Z6J hhoK4Cdk1HgjaD0Vhz4AKFKqVvdQuZGwzaEN39LvSCs1ZVoK7MqbFMq2T6q3pMW8xF2L zxZFdvZYMWyYbI5CPnP4gKlA4ngAJT2tHnLjRrGYbyK1IrQCFr9K+2FlB4dHofECtiew qV+WPqh97k+6ck9xAFEJ0sAJPe6uRbrEtV320OrwTH3rKeJ1/Iz+a/FKXPK2aHlB32+q C6RVm2odEsnfdHN+7c8NuSh5C93KVPnogKOXMERDJPIW2paq9MkOBhbKITNa3ylQnG37 wO0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257607; x=1719862407; 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=YHMXmRqIR3vrTAk2uMbRVffF80cd0U6xix7wu3WybSk=; b=PdoU4tdTH98hP1jo6XyxIy7Sga59GbkN3bNmu2SqusQMifCEJhgkBX74U9wE8ld7lN h/dJG0Se3zXCj9MxARVmuxkvsfx+Q5MqDgmO1JnhNQ54ja4FVOANCi4Q3srkFbtvZD+o 4X4xnyAH/PQfMKyKwSwYDIjS58Nfv5SNHXKSZulmKCgeGwDglqQ8Fk6AAE2AtTTh2O7V f8bCysaZ4VuM+FSi9zwR4wcC/Qlz1OLVRaoXGhIqkN4iwBCGtaZ3ULLJu12NiPYhdEG9 zWohY1II94WA5a4EeHhq36iihNialTPTVTZfB4a40V1tORP/icptGaPCgVKk+5rnU6HG AmLw== X-Gm-Message-State: AOJu0YyaND5x3z6xe3LMx04IDTjAHINcpsYtRSyFZ3ypUngpwKk7v22K iJEtzPxUluP8kk9VHwR545CzoV//LxO35tXhIAlbw29lQDLwJbskHNFKzw== X-Google-Smtp-Source: AGHT+IGd6qb3rm9Ll36tQKjakhBuI32/id58ibvwN1m++jeuC4MhxCZReF3wAtSNROKXAo1KQ9gByQ== X-Received: by 2002:a4a:2447:0:b0:5ba:e995:3efa with SMTP id 006d021491bc7-5c1eb9dc263mr6210735eaf.1.1719257606792; Mon, 24 Jun 2024 12:33:26 -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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:26 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 12/13] qmi: debug print fd that QRTR data was received on Date: Mon, 24 Jun 2024 14:32:55 -0500 Message-ID: <20240624193315.1164943-12-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similarly to qrtr_service_family_dedicated_rx(), output the fd for the rx operation. --- drivers/qmimodem/qmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 639c0c44b519..7beae9cf588d 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1850,13 +1850,13 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) unsigned char buf[2048]; ssize_t bytes_read; socklen_t addr_size; + int fd = l_io_get_fd(qrtr->transport.io); addr_size = sizeof(addr); - bytes_read = recvfrom(l_io_get_fd(qrtr->transport.io), - buf, sizeof(buf), 0, + bytes_read = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *) &addr, &addr_size); - DEBUG(debug, "Received %zd bytes from Node: %d Port: %d", - bytes_read, addr.sq_node, addr.sq_port); + DEBUG(debug, "fd %d Received %zd bytes from Node: %d Port: %d", + fd, bytes_read, addr.sq_node, addr.sq_port); if (bytes_read < 0) return true; From patchwork Mon Jun 24 19:32:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13710006 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.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 74C3B1A01B8 for ; Mon, 24 Jun 2024 19:33:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257609; cv=none; b=jgNUw52PwNYsWenJVc0vZQi5uKsyZrAmX1bYNvjKLHjuIOOPQg23OW+v+cxbu5nNqs1VDo5e9L1VBvTACNCEbW10rV4tSP2W2Swb25tLvko/2LzSGe19BPK9TCi7gUqmPUR/A7vg0EiuiQem/u8ftanwN5uiqy+n9+QaOrswwtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719257609; c=relaxed/simple; bh=DGVm8VvS+27+bhgPWtsLpz38ujd3io0EL7mOBwu273c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NSqDxZRWo/33aI1Ef9eBhNbuHORswm1ANBGQaYYJl2Cq2Lnp767XfC/CEyR6Z7QsG7rhG9bKKulCqXv5S6iIKhrcJweojERnSQmv0e9PdUyUaDV7mvFlN2qfXdM0Ca2/iIr/0PHZgEa84tkMGdoG+IbW8bheFUglFfbunOXKB3c= 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=d2axNgvI; arc=none smtp.client-ip=209.85.161.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="d2axNgvI" Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5baf982f56dso2369419eaf.3 for ; Mon, 24 Jun 2024 12:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719257607; x=1719862407; 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=YYKlqlN+OxkNKMRugood31xDBn0ycrg0fTG8TycKzzI=; b=d2axNgvIV109X7U2/ppm60OWBGbOeZnFKJqwcSNW2EC065z1ZSNVacxx2LejDBbqQ9 FdIBit0trfaFUEF0Wavp0wZ03d7ODvQFBQkxRvJgDNRBXhida5GosJwzx4CqD6hLpLvj zDA8izFpff9JyWN00ozwwA0uFDEIN7VbRbjSD0RSKRlRmUaZALFYVttmlgcHcqVdc0aE hPpSYYYIrE2e0PoKWw1tJTqFOxE1SVw6F+mql66YsCCKKOsXWOYEw69zu8TlfTgEGM/Q vsR75uI4o1y+yyq94YSb/fSr5RnjUAYy6N2R4UyRZoJpJMzK1N103I/PBTNS4pge/Lnj nEiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719257607; x=1719862407; 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=YYKlqlN+OxkNKMRugood31xDBn0ycrg0fTG8TycKzzI=; b=M6vPCE/pvZolarmjeBCHqNul45bT3oQOaQbKv6aA9Q5KkygAAeAKXsr9ykda02Jgv1 xzuW7OayHR6ye3Toe6GScb1ltoxHXDv1RcGRwtQUSB47cnxm1Ewk8TNdYzUy0Rw23mt+ 5odL8/qikXjmSqoGOr5IAEbwdBBOQ1t8lDkw+WGPsdUpEjJu2Blalj2Xk2YSgdAN7D0U 0OnBTBuGxxkSLQGo55TxuRdr2W1omfEmB6N0o8QSdjlAY81PZQXQl9SwtiuksO7nzKYO VFqcnsxeGkICPzFJ1QqYfBS3/V+I4BNIVUVd7J8L/SibogCqZSNUiI3srBS6OGNuUVgS nW4A== X-Gm-Message-State: AOJu0YwJkw/80ILdccg9bqUGKjKwL6Lxyduo7edIuIcc1FLJUEGS1Lpj P3pYZrTCkBXnRJSm+v1qqT2xUQQCouSyggIIog7+VdGq+xcxnrw4KuFjJw== X-Google-Smtp-Source: AGHT+IFr1z2BNUOvs48j/rSjq8dnXIADBIz1j0KRv4CEwL+CHhZLRCIVCDDADDQBFXwp554m1va/ww== X-Received: by 2002:a4a:354e:0:b0:5bb:294a:cb62 with SMTP id 006d021491bc7-5c201156adcmr3730780eaf.4.1719257607537; Mon, 24 Jun 2024 12:33:27 -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 006d021491bc7-5c1d54c2d44sm1480831eaf.8.2024.06.24.12.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 12:33:27 -0700 (PDT) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 13/13] unit: Add unit test for QRTR dedicated services Date: Mon, 24 Jun 2024 14:32:56 -0500 Message-ID: <20240624193315.1164943-13-denkenz@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240624193315.1164943-1-denkenz@gmail.com> References: <20240624193315.1164943-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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index 2ff981391849..f647a025474e 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -566,6 +566,32 @@ static void test_service_notification_independence(const void *data) test_cleanup(info); } +static void test_dedicated(const void *data) +{ + struct test_info *info = test_setup(); + struct l_io *io; + uint32_t service_type; + struct qmi_service *service; + + perform_lookup(info); + + service_type = unique_service_type(0); /* Use the first service */ + service = qmi_qrtr_node_get_dedicated_service(info->node, service_type); + assert(service); + + io = l_io_new(info->service_fds[0]); + assert(io); + l_io_set_read_handler(io, received_data, info, NULL); + + send_request_via_qmi(info, service); + send_response_to_client(info, io); + + l_io_destroy(io); + qmi_service_free(service); + + test_cleanup(info); +} + static void exit_if_qrtr_not_supported(void) { int fd; @@ -598,6 +624,7 @@ int main(int argc, char **argv) l_test_add("QRTR notifications", test_notifications, NULL); l_test_add("QRTR service notifications are independent", test_service_notification_independence, NULL); + l_test_add("QRTR dedicated service", test_dedicated, NULL); result = l_test_run(); __ofono_log_cleanup();