From patchwork Tue Apr 16 22:12:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13632677 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B04B178C7F for ; Tue, 16 Apr 2024 22:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713305843; cv=none; b=TTR/hPmsVPBY3KNb9JRsh/cMdTQhzTOoLPa6c46FUmQEslOBdbnx6ipesuvlguZ8U55LQXiyH7Nc1x65Elt7VR/Os1NjXBYG0SuoSrV0EoLANgRdafNwq00iaYoD9RgNF19RP+fA78S57NzAwXpzskXDymQpRmmKOoj1i1GCQuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713305843; c=relaxed/simple; bh=MhrtDgpd1+EJdqX1O2FIQI0UzRmLlLwnVp0ArCw7d58=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=LvY6aSQBdkMUgf1uq15NPkBToigiTVizaIcX2pwmiKmicI6a0LXIlnGM3LeIaH/YwEH2R/qCFFoVOZvpjiL33iAEf/K+0pJqCqiH8sppFitSxPVPl3z8PjbPH65EXlB1b9q88scVA2XZxY8x6gXc85tAOsWlHGHZXtG0h4RPQoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=YkHKljk3; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=ry9LfmTb; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="YkHKljk3"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="ry9LfmTb" Received: from pps.filterd (m0286621.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43GDC3pW014242 for ; Tue, 16 Apr 2024 15:13:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:mime-version:content-type; s=ppemail; bh=5eVeN6jH8ksnb0mEnVpH/v9ZiS2ZariNA7Uiwa3ybsw=; b=Y kHKljk3YJtY/CJH2N6wngEIT8ynsD3rO00hezXv5c2pZrpENbznq8au6JEWNN0Fs KbKEhzbIck4b6/qNsQ3cuvcqmsdhSKKu1iVbiSqgmamKcpnZOMiGcEcDUt3g9BX3 Popmksv6TihAgIFD+zMmpz3nNb9Mk5E1XF1yscxcARRZ5Un5lSW46LYX5vshKsTF ZO1NRIXMUFrBFNeuzo56f38LZVLao8jR0WI+OeiZolfAiRP7aSrwPGpVdLroYLoE wNbWpBrd+Je5GPFyLsDj3cfp4fbSwePF8SIlnGCHmzg3+5SfCZfe6yoRtY40lkZk +rKBij5dtOzypKorDZBKQ== Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3xfs4dtjp1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 16 Apr 2024 15:13:47 -0700 (PDT) Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-7e7b784d6b2so2763393241.0 for ; Tue, 16 Apr 2024 15:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1713305626; x=1713910426; darn=lists.linux.dev; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=5eVeN6jH8ksnb0mEnVpH/v9ZiS2ZariNA7Uiwa3ybsw=; b=ry9LfmTbtIlK7B5txZNtFbyv0ereTSe3oyBe4yRmEGfLtlXAJ6Hah2Fr22jwGIx2sA Eg9QMRdeVJBWSep98UtbvXycXu3+uBPR0xXYFxDPq2P2SXqwKGSDCjuaC4DPQaYZKlVn xTBkkuslZSu18HdAzaadmOmOW/kYa3t5HhCtFXFf9YiVxQpuPaB+gFpalUAbzJvRp7dV oEbBj9fk0bMvXOcLBHp4PkY4w1OwL3lg9CaqXnGVxRvlXAQmZ+kcAHWPHHrsaWpotRZN 094YVdrMqPMd9G8t5OBDL/tmi9c88jswnlM1ZZU+AYcUHail4U3IZE3+5AFX5LUTB7mB Wngg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713305626; x=1713910426; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5eVeN6jH8ksnb0mEnVpH/v9ZiS2ZariNA7Uiwa3ybsw=; b=dkxazZMC77W4nacdjqcB5sVaohygSqsf7P07PiIKj1Dd7qH2QqKdSJI//s2VTxFqLd +PzOIACOvyvISxQhAbypuLH5NTnPojOpzxl/BIih3Lr3Wwg1aLSePoiiRcvn2Rx3euDR 4hoS58g0WEtca4EGL9fOqfEs5wskCSBm4+rIdmGr2Gru0xUEndNhs1ugbPAx37+nHYh0 IdQfecO47wF1vT5WEfRsvdM3VUuqfkdYi80KatbS5jsahbdGo0xnKJmp1Ttx+Ry5XsLx B8BiVuamilWBZdMqpv+IS53TkYJfU3t3G72TqjjU8dYNo6JKqy+Mlr7aWpXBR43nBypk Ismg== X-Gm-Message-State: AOJu0Ywm9pW70SerlC6x1dgfSSM0s6aAXpgaody8OwTBBhhSrNEqYLX3 5JdVLP2Vibh27ty6fTBtDFEWWSocuIuzzAUCcvnnw0lv727lpASlNLezSSE32JKet6aH5qkO2rY L7cHBYaqTCVQP0afKaM2fcHwbNZUu61q15PVvPjlzgQBek/hOT6HNzrmZ2RRfrF4xeMxiWw+XR5 zbY2izV6S4meUnv3wzVWkRY7OAPVVGwDMc2EYQE3lMkcJ0Dow= X-Received: by 2002:a05:6102:3f15:b0:47a:9436:2b76 with SMTP id k21-20020a0561023f1500b0047a94362b76mr14411321vsv.31.1713305626539; Tue, 16 Apr 2024 15:13:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHr3ucK+EKvcTF+Nlr32daoiELU3FwQF6t3N/EQsdzZYEeoYllE/8ddfafusY5PUx1fThP2RA== X-Received: by 2002:a05:6102:3f15:b0:47a:9436:2b76 with SMTP id k21-20020a0561023f1500b0047a94362b76mr14411299vsv.31.1713305626138; Tue, 16 Apr 2024 15:13:46 -0700 (PDT) Received: from localhost.localdomain ([140.141.181.78]) by smtp.gmail.com with ESMTPSA id f6-20020a056214164600b0069b10d78445sm7654028qvw.142.2024.04.16.15.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 15:13:45 -0700 (PDT) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH 1/3] gobi: Do not wait for timeout to shutdown Date: Tue, 16 Apr 2024 22:12:31 +0000 Message-Id: <20240416221233.404872-1-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: _vXUKYsmCkYtWrL3I6wGo74czb4xmmin X-Proofpoint-ORIG-GUID: _vXUKYsmCkYtWrL3I6wGo74czb4xmmin X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-16_18,2024-04-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 malwarescore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404160143 Now the qmi_device_shutdown() function can return a failure. It will do this if the qmi_device type does not support shutdown. When this happens gobi should immediately proceed with shutdown instead of waiting until the timeout occurs. --- plugins/gobi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/gobi.c b/plugins/gobi.c index 431df17e2332..9ab561010912 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -174,7 +174,8 @@ static void shutdown_device(struct ofono_modem *modem) cleanup_services(data); - qmi_device_shutdown(data->device, shutdown_cb, modem, NULL); + if (qmi_device_shutdown(data->device, shutdown_cb, modem, NULL) < 0) + shutdown_cb(modem); } static void power_reset_cb(struct qmi_result *result, void *user_data) From patchwork Tue Apr 16 22:12:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13632692 Received: from mx0a-003ede02.pphosted.com (mx0a-003ede02.pphosted.com [205.220.169.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA48217736 for ; Tue, 16 Apr 2024 22:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.169.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713306336; cv=none; b=FPk3zS8ZX5LO3iYtjDOsV7v1UVLcdskqHLUNwQrr6iJMBThnxB6O8Hq+SMkFcABbJBYWMKgEQCopBXK7dpUv4eJhD6nFSXRUlzoidhtSeR03YZ2q63HV8MDPoHhKp8B7D91oAyVh65EOYVpKqySQhZllnUzSLzhZawzenA8QfT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713306336; c=relaxed/simple; bh=OZ48uyG14Egd8KpTKkHvMRjfBvUdg01y3Fv8puC32I4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=c+UH/6vmnTAHINO092pmS7eREghSu+QMmVS20kCod2/lUyENVVFuYB7DO9/Ma9nEPa3jAtS9ryJYZ7TTKwuS4TL1sNOijshJdSYjmn59R92HZau8IxGUgTVGF7PcDHxzHfFy1PQUZcJlThyqsLxV5xxab4/v4Jml39whbTgsWgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=plClSBG1; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=g2yPKAuQ; arc=none smtp.client-ip=205.220.169.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="plClSBG1"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="g2yPKAuQ" Received: from pps.filterd (m0286614.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43GEjE4C010846 for ; Tue, 16 Apr 2024 15:13:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=Dn6I95OgI4jWekHVORLBsP 32aGqlwtFqvaXzvxIJiMo=; b=plClSBG1Vk1dSbzDWHw8K3MIzPXgxnUOjv8iGJ pfW1xL7+fbIMgtYATirwqZxseefsI1/Cpm0ZF+UsvDZayEYaYle1XTnOkMAUrRqv Gy79VPuSoiWx4bHpPC3Khm7C55HAjO7QNckZ8aUYJL+9DsUHmuAi49+GM5/i0gKT EQSLqlm4u4dS2OMPXJzXEp4Kuye5jWSfhKtBD0av1PjTNNwhbW627U1oHILI+pFi zBb+ggM+EpLxkT6eP+Ondv/Ro8M+nSUqAibVfoNqKQbmRXf5CDu6gY99MTgLhKTN VWrqu4LREmnJQKuVgTqT6Kzzu8NyKoxBALtU6nO7kkkNTWgA== Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3xhub9rgn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 16 Apr 2024 15:13:48 -0700 (PDT) Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-69b0fdb7f0cso42691156d6.1 for ; Tue, 16 Apr 2024 15:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1713305627; x=1713910427; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Dn6I95OgI4jWekHVORLBsP32aGqlwtFqvaXzvxIJiMo=; b=g2yPKAuQT9mFa6j/dgzzwWH7UfM+YM7c72GDrCJd1mG5Ga9I6t3Od71NXbWPncHbcS PTAtuzZq10lDkL2uoaAdpFztY1Y+zQDMe/6w2GS3gQFN8yRkoeE/yMVcf6cPYVRuSH8p +aRHc5GiyQIZgqyZtzba5y3VxsvaDfdTT4F95zaq7QKltFEZfiBcbvT6QnU5ztIaz/nN kw7aYIKuWJfhXJV98YGhRj3hO09SzuTnFlsLEYVgrfi2ByFX/GPIrNCrjwmkvdma5/2t gw08cd0HYWISKFo2va1Mhz7mAk6xr2k3GmZze4/9DvCQM9L2NKHxcK7lTdpeq+3DR6bH 5m5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713305627; x=1713910427; h=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=Dn6I95OgI4jWekHVORLBsP32aGqlwtFqvaXzvxIJiMo=; b=VXIAko8XttsdU4XEv+HWfK4H4b/39hs/u7qdxc8nkwIwVhIVAJn9vvoS7SUZ3UhSVL U8zp5QMyWcdI3z9gHC3aVD3oJC/eXEiE/IKkTlHyIjWCVFfK9CG/PACobWA5/7eh5R59 95Yt/pG1POKEUnlfcLx1kJ4Kz9pIViI1EnHofjIchAr8gaKw1243ED+lCd0o0faXgvQm oanKLdRc1H6dNEaOVupz8P+MEjkq3tGpU+/bjfX+qOuwblIDxw/fEEy506WXkPZllKro u92pwTCM9ye84We1pVCAJ0Jbh7lRX0usTAi9pNI2gtv1rlYx+c61RMBSS2BY+vfRnZIi NDdw== X-Gm-Message-State: AOJu0YyVhS+sr6IAPdmI6j7Ww8py3W9LRj6LsEp4OFiJV+ZCN0J48Oc2 QOQGVkybDdZZfFM7NE6o14125Kn3qDqJm5zMEvCsXM5isjc8XtrKZpGsfDTP/ka/M18jIh00WX+ K9a0F44dopMKPToZEgL8/usQUNpDYKZbgUJKf+gVD/T12Y7fTZrQy+9WHnElTdOC7Eh78mjx/b5 wtAVdYW0oDcdLlqf/pdU9RMIJNgRV57x3KhgrwQMs1PHANuhA= X-Received: by 2002:ad4:4ee7:0:b0:69b:79e5:fdae with SMTP id dv7-20020ad44ee7000000b0069b79e5fdaemr10452959qvb.60.1713305627155; Tue, 16 Apr 2024 15:13:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsq2WRKqCQvYLNO14rXnpljgetMC+wsJpjQr0rNRDe65gk68UwWyHOwTg6Qdu+oLkYjpQMVg== X-Received: by 2002:ad4:4ee7:0:b0:69b:79e5:fdae with SMTP id dv7-20020ad44ee7000000b0069b79e5fdaemr10452938qvb.60.1713305626726; Tue, 16 Apr 2024 15:13:46 -0700 (PDT) Received: from localhost.localdomain ([140.141.181.78]) by smtp.gmail.com with ESMTPSA id f6-20020a056214164600b0069b10d78445sm7654028qvw.142.2024.04.16.15.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 15:13:46 -0700 (PDT) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH 2/3] qmi unit: Make test service sends more generic Date: Tue, 16 Apr 2024 22:12:32 +0000 Message-Id: <20240416221233.404872-2-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240416221233.404872-1-steve.schrock@getcruise.com> References: <20240416221233.404872-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 0T9f0G8YloSSRS9wVnshl6zBRSkDnX2y X-Proofpoint-GUID: 0T9f0G8YloSSRS9wVnshl6zBRSkDnX2y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-16_18,2024-04-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 clxscore=1015 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404160143 Clean up the functions so that they can be used to send indications in addition to responses in the future. --- unit/test-qmimodem-qmi.c | 68 ++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index d04f50041c51..7826ab671239 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -283,8 +283,9 @@ static bool received_data(struct l_io *io, void *user_data) return true; } -#define TEST_TLV_TYPE 21 /* Its data value is 1 byte */ -#define TEST_DATA_VALUE 0x89 +#define TEST_TLV_TYPE 0x21 /* Its data value is 1 byte */ +#define TEST_REQ_DATA_VALUE 0x89 +#define TEST_RESP_DATA_VALUE 0x8A static void send_test_data_cb(struct qmi_result *result, void *user_data) { @@ -294,7 +295,7 @@ static void send_test_data_cb(struct qmi_result *result, void *user_data) assert(!qmi_result_set_error(result, NULL)); assert(qmi_result_get_uint8(result, TEST_TLV_TYPE, &data)); - assert(data == TEST_DATA_VALUE); + assert(data == TEST_RESP_DATA_VALUE); info->service_send_callback_called = true; } @@ -308,6 +309,12 @@ static void send_test_data_cb(struct qmi_result *result, void *user_data) #define TEST_RESP_MESSAGE_ID 43 #define QMI_HDR_SIZE 7 +enum qmi_message_type { + QMI_MESSAGE_TYPE_REQ = 0x00, + QMI_MESSAGE_TYPE_RESP = 0x02, + QMI_MESSAGE_TYPE_IND = 0x04, +}; + struct qmi_test_service_request { uint8_t type; uint16_t transaction; @@ -338,7 +345,7 @@ static void send_request_via_qmi(struct test_info *info, struct qmi_param *param; param = qmi_param_new(); - qmi_param_append_uint8(param, TEST_TLV_TYPE, TEST_DATA_VALUE); + qmi_param_append_uint8(param, TEST_TLV_TYPE, TEST_REQ_DATA_VALUE); assert(qmi_service_send(service, TEST_REQ_MESSAGE_ID, param, send_test_data_cb, info, NULL)); @@ -346,11 +353,36 @@ static void send_request_via_qmi(struct test_info *info, l_main_iterate(-1); } -static void send_response_via_socket(struct test_info *info, struct l_io *io) +static void send_message_to_client(struct sockaddr_qrtr *dest, struct l_io *io, + uint8_t type, uint16_t transaction, + uint16_t message, uint8_t data_value) { - const struct qmi_test_service_request *request; struct qmi_test_service_response response; + /* + * Now echo it back to the qrtr client. The qmi_service send callback + * will validate that the client processed this response correctly. + */ + memset(&response, 0, sizeof(response)); + response.type = type; + response.transaction = transaction; + response.message = L_CPU_TO_LE16(message); + response.length = L_CPU_TO_LE16(sizeof(response) - QMI_HDR_SIZE); + response.error_type = 2; + response.error_length = L_CPU_TO_LE16(4); + response.data_type = TEST_TLV_TYPE; + response.data_length = 1; + response.data_value = data_value; + + sendto(l_io_get_fd(io), &response, sizeof(response), 0, + (struct sockaddr *) dest, + sizeof(*dest)); +} + +static void send_response_to_client(struct test_info *info, struct l_io *io) +{ + const struct qmi_test_service_request *request; + /* First validate that the qrtr code sent the qmi request properly. */ assert(info->received_len == sizeof(*request)); request = info->received; @@ -360,26 +392,16 @@ static void send_response_via_socket(struct test_info *info, struct l_io *io) sizeof(*request) - QMI_HDR_SIZE)); assert(request->data_type == TEST_TLV_TYPE); assert(request->data_length == L_CPU_TO_LE16(1)); - assert(request->data_value == TEST_DATA_VALUE); + assert(request->data_value == TEST_REQ_DATA_VALUE); /* - * Now echo it back to the qrtr client. The qmi_service send callback + * Now respond to the qrtr client. The qmi_service send callback * will validate that the client processed this response correctly. */ - memset(&response, 0, sizeof(response)); - response.type = 0x02; - response.transaction = request->transaction; - response.message = L_CPU_TO_LE16(TEST_RESP_MESSAGE_ID); - response.length = L_CPU_TO_LE16(sizeof(response) - QMI_HDR_SIZE); - response.error_type = 2; - response.error_length = L_CPU_TO_LE16(4); - response.data_type = request->data_type; - response.data_length = request->data_length; - response.data_value = request->data_value; - - sendto(l_io_get_fd(io), &response, sizeof(response), 0, - (struct sockaddr *) &info->sender, - sizeof(info->sender)); + send_message_to_client(&info->sender, io, QMI_MESSAGE_TYPE_RESP, + request->transaction, + TEST_RESP_MESSAGE_ID, + TEST_RESP_DATA_VALUE); while (!info->service_send_callback_called) l_main_iterate(-1); @@ -410,7 +432,7 @@ static void test_send_data(const void *data) l_io_set_read_handler(io, received_data, info, NULL); send_request_via_qmi(info, service); - send_response_via_socket(info, io); + send_response_to_client(info, io); l_io_destroy(io); qmi_service_unref(service); From patchwork Tue Apr 16 22:12:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13632678 Received: from mx0a-003ede02.pphosted.com (mx0a-003ede02.pphosted.com [205.220.169.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF81913281F for ; Tue, 16 Apr 2024 22:19:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.169.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713305978; cv=none; b=SDqJbm7JMltd/oeIVVSqAFHeIYKLB5o5jUOwwbV28xHQ8SKrqFji9xipKG3IEhtcx7vnOCrjGRWyM514C3FfEQMT9/lSVi7+LZToiZbfVyoYAk5JmmZcjqyAZa7aZzis5EO0EgzkFJf2Fu1ERpR23DJJrhvLpxiFl8FB2DAw9+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713305978; c=relaxed/simple; bh=1O/ZZGVQgH9DYMWv7KP3EjueuIgp9G0LH4qD4poBhlU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=f4wU7ZQHuM4JjPU6c7no+ypboiIUzZ7mATivUc0V00lnqqazG4sJO00KqTrU7QSqYORMVItQbrTNdgNVmybXs9ThctnGv1ZuAt+smHVU3P9XZcU2ziR6zu7cRBlluhHjLxKucmondY323JSWvbFc3FZjWfAPDa65TM4rpO8hIm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=WkcQNpeI; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=SjPlKzac; arc=none smtp.client-ip=205.220.169.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="WkcQNpeI"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="SjPlKzac" Received: from pps.filterd (m0286615.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43GDFDap015765 for ; Tue, 16 Apr 2024 15:13:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=C8g3V7la4bNIj8265bV1b7 7QXncTtN9+UOIL9Tw2T8k=; b=WkcQNpeI+dEYAr0A+vvvqCUbQ7Dj3OptgcG83t idwkufiq3oqwtkYd0R+GqGyQWSDKBue0IOmQDM1jN9BqzWHWVdnO2Em6kfk104dJ gZsoIfZVIl35CMNyBDb2qtBqqKhBX7TCgkaX5deojRisQcCmPdaE46crwmUdXZ9z dKbVDrPO+hyOzqulSwUf//FqelSfXzSqf2MbxiT3guuQHyTyZF+2awPn/+/9AzbB MRrPfD5QlTBm5uGDGxFfHweL3ZwhQc1GeWjp0sF7SD6Pl2hRBxxRO4oQHyk1V4rc F0+vqYjCb+T54MZrhPFC98HWgz4ZF7pcwbBvHuMRlRs8h44A== Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3xfp8hjmxh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 16 Apr 2024 15:13:49 -0700 (PDT) Received: by mail-vs1-f69.google.com with SMTP id ada2fe7eead31-47b61811775so1347308137.3 for ; Tue, 16 Apr 2024 15:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1713305628; x=1713910428; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=C8g3V7la4bNIj8265bV1b77QXncTtN9+UOIL9Tw2T8k=; b=SjPlKzac0slIrPO18gQRWYBdgEvrv86K6T632qpM5E7dP+9/WlmFluNjKeiqghV1x0 tfDLaye9ZeLeSzwBmG2IdjOV1UiiKvpQfluS945gM/uHPU+97ywBGwt0WCbc8lgxmpNU EGZPlCSblU71OhZMQVZcAsdxH9cY7JdlAucPaGwO/LyJpjnOXCYeQI2GxmALzi7EW+o1 O5MT39BfDup7LE/gQU06cGQBJM7nzY4SjGMhP3iUXaUTeef4b8VE3yIzsI9LyIh/Gnh8 vdPzrSH7gKT9aT7EGZ5eLQVWV4sw1r78TtNNV9kmRthe4Ln5CQaFEhtZ6Xhdkk6fcYYp KvNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713305628; x=1713910428; h=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=C8g3V7la4bNIj8265bV1b77QXncTtN9+UOIL9Tw2T8k=; b=HFLtMilkH4NBepWqPuWXNutoCMvmPC0fEvA/CgV6xSMABEbe39e1JzQ5YbNzY8PT01 vCG4m27m79nZwHwfS4qJ1CjcaQojttvWhqHV+zIuw40V62GrgEq1ztcisdynJz199rH7 bN/zn5UmHKS8muOKOOWObuyegDx74l4/uUCEohV0+CR6iTAH8ByBQJEjpkBJ9GsPgNlY N0pYDOmdi2fmdsY4ITeSD/T2bqeJmFD7NJtFroYYS0821Q4iBkpQZkVFOcax3MzEVw9d MUqoW+cyiQItgmrVOv4jAz7S1ju2U8zEQwB0cPAE/kmjCWDKPW18PvBwGfOnqwaqpNCi OdAw== X-Gm-Message-State: AOJu0YyU2d1zwYfsMm8ncIqcNV4hY+kXB7VdcFYdBV+LnSYUyVINPCtr yafEeYM3O9AEwq4f3AOe9I4UYcTEJ4Gn8JzRSxcrsZC4BisPH2rBTGVj0i6Qx+p053Aj/OI+ggY avDZd9MMFW7D1vRvYgOoCc8Pz1A2izz95M8FANXGBlOL5ZeDsbu11tR5NONKec3cBqcc5YUdJK6 BnruXW9dPEdSleanEUX1yp9Hh0zfr7lMJ+rOvIeP3tPXHRo94= X-Received: by 2002:a05:6102:148c:b0:47b:6b98:e9ae with SMTP id d12-20020a056102148c00b0047b6b98e9aemr12658389vsv.33.1713305627797; Tue, 16 Apr 2024 15:13:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEZBUBElKWS2IXG3aS/S8g3rx6ZQz8uDq7hgsLISr9+tsWaBK0y97ZpHo4GW3IbDdGH30vRQ== X-Received: by 2002:a05:6102:148c:b0:47b:6b98:e9ae with SMTP id d12-20020a056102148c00b0047b6b98e9aemr12658366vsv.33.1713305627330; Tue, 16 Apr 2024 15:13:47 -0700 (PDT) Received: from localhost.localdomain ([140.141.181.78]) by smtp.gmail.com with ESMTPSA id f6-20020a056214164600b0069b10d78445sm7654028qvw.142.2024.04.16.15.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 15:13:47 -0700 (PDT) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH 3/3] qmi unit: Add notification registration test Date: Tue, 16 Apr 2024 22:12:33 +0000 Message-Id: <20240416221233.404872-3-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240416221233.404872-1-steve.schrock@getcruise.com> References: <20240416221233.404872-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: C_3nhsX6HrBJJxNDKL7E6b2NYHGpO3u6 X-Proofpoint-GUID: C_3nhsX6HrBJJxNDKL7E6b2NYHGpO3u6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-16_18,2024-04-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 clxscore=1015 spamscore=0 malwarescore=0 impostorscore=0 suspectscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404160143 --- unit/test-qmimodem-qmi.c | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/unit/test-qmimodem-qmi.c b/unit/test-qmimodem-qmi.c index 7826ab671239..0e15f898f845 100644 --- a/unit/test-qmimodem-qmi.c +++ b/unit/test-qmimodem-qmi.c @@ -36,6 +36,7 @@ struct test_info { bool discovery_callback_called : 1; bool service_send_callback_called : 1; + bool notify_callback_called : 1; }; static uint32_t unique_service_type(uint32_t index) @@ -286,6 +287,7 @@ static bool received_data(struct l_io *io, void *user_data) #define TEST_TLV_TYPE 0x21 /* Its data value is 1 byte */ #define TEST_REQ_DATA_VALUE 0x89 #define TEST_RESP_DATA_VALUE 0x8A +#define TEST_IND_DATA_VALUE 0x8B static void send_test_data_cb(struct qmi_result *result, void *user_data) { @@ -307,6 +309,7 @@ static void send_test_data_cb(struct qmi_result *result, void *user_data) #define TEST_REQ_MESSAGE_ID 42 #define TEST_RESP_MESSAGE_ID 43 +#define TEST_IND_MESSAGE_ID 44 #define QMI_HDR_SIZE 7 enum qmi_message_type { @@ -440,6 +443,57 @@ static void test_send_data(const void *data) test_cleanup(info); } + +static void notify_cb(struct qmi_result *result, void *user_data) +{ + struct test_info *info = user_data; + uint8_t data; + + assert(!qmi_result_set_error(result, NULL)); + assert(qmi_result_get_uint8(result, TEST_TLV_TYPE, &data)); + assert(data == TEST_IND_DATA_VALUE); + + info->notify_callback_called = true; +} + +static void test_notifications(const void *data) +{ + struct test_info *info = test_setup(); + struct l_io *io; + uint32_t service_type; + struct qmi_service *service; + + perform_discovery(info); + + service_type = unique_service_type(0); /* Use the first service */ + assert(qmi_service_create(info->device, service_type, + create_service_cb, info, NULL)); + perform_all_pending_work(); + service = l_queue_pop_head(info->services); + 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); + + qmi_service_register(service, TEST_IND_MESSAGE_ID, notify_cb, info, + NULL); + send_message_to_client(&info->sender, io, QMI_MESSAGE_TYPE_IND, 0, + TEST_IND_MESSAGE_ID, + TEST_IND_DATA_VALUE); + + while (!info->notify_callback_called) + l_main_iterate(-1); + + l_io_destroy(io); + qmi_service_unref(service); + + test_cleanup(info); +} + static void exit_if_qrtr_not_supported(void) { int fd; @@ -469,6 +523,7 @@ int main(int argc, char **argv) l_test_add("QRTR discovery", test_discovery, NULL); l_test_add("QRTR services may be created", test_create_services, NULL); l_test_add("QRTR service sends/responses", test_send_data, NULL); + l_test_add("QRTR notifications", test_notifications, NULL); result = l_test_run(); __ofono_log_cleanup();