From nobody Wed Nov 27 03:47:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=samsung.com ARC-Seal: i=1; a=rsa-sha256; t=1702045131; cv=none; d=zohomail.com; s=zohoarc; b=F/Yi5vjma3YtQo2kyeStK3c57esivh/lequ6bHMIA73wNMEMXdZx5ltbHv53+yYLWTUH2Mi4pXjk742ZBq5bYRVBEZdy/cPPDo86rZ6gHKHg6sZf58ksT1LlIRugh8GJlM4ZAVi+HaNOtBZ5RYNaPIRuW/5AGvOv+/JueC4M5AA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702045131; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=/VizRhPWdnwEHZarvVnucnLBlD129cCfPeJvOcB7GSg=; b=ToRdTVNN7v4CpnslNNfjLITH5m7rMTCQCyJdadlTm/3HGmZCMCu3CJEUDPJrvojHUneq5hRk9snuGMBYyPSU4rE0jdbhe2Y8nsjsIE7djVaLGjj83bimWXSm1PWLukD3oxK3QBb/nW+e8FJG9oi080VDAL5dJpd/ZnjpdfiHdno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702045131927985.9711977870793; Fri, 8 Dec 2023 06:18:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBbg7-0005sk-F0; Fri, 08 Dec 2023 09:18:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBUGX-0007ug-Kj for qemu-devel@nongnu.org; Fri, 08 Dec 2023 01:23:13 -0500 Received: from mailout4.samsung.com ([203.254.224.34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBUGR-0000oM-91 for qemu-devel@nongnu.org; Fri, 08 Dec 2023 01:23:13 -0500 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20231208062303epoutp0450b910a17627a0f8be3cdae0377a4a08~exxCqSt8t2409024090epoutp04P for ; Fri, 8 Dec 2023 06:23:03 +0000 (GMT) Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20231208062303epcas2p1713f4c6e37e394d013eea66e477cbec2~exxCIdft31119911199epcas2p1w; Fri, 8 Dec 2023 06:23:03 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.70]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Smh061bRfz4x9QD; Fri, 8 Dec 2023 06:23:02 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 94.E6.09607.646B2756; Fri, 8 Dec 2023 15:23:02 +0900 (KST) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20231208062303epoutp0450b910a17627a0f8be3cdae0377a4a08~exxCqSt8t2409024090epoutp04P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1702016583; bh=/VizRhPWdnwEHZarvVnucnLBlD129cCfPeJvOcB7GSg=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=WoCGe6H2MlUbRHy0N939vHSaf/H/uOn1jlfSj8AjF9J8TcD8mMTENDgLhPCu+amlD E5lS3GYMQ0oDiqNaPjDPBaOwb62K93U4gnRpNSUXIzOQu4URBnwX5JQnQGHcjWmKu4 9SFyHj5PdreTbFda7VjPKV+6yDHJeXmZmfzdz3AU= X-AuditID: b6c32a48-963ff70000002587-33-6572b646bdba Mime-Version: 1.0 Subject: [PATCH 3/3] tests/qtest: Add tests for Zoned UFS From: Daejun Park To: "thuth@redhat.com" , "lvivier@redhat.com" , Jeuk Kim , "pbonzini@redhat.com" , "qemu-devel@nongnu.org" , Daejun Park CC: Seokhwan Kim , Yonggil Song , JinHwan Park X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20231208062200epcms2p7de0f3ab428a85eff0280225dbd1b1f37@epcms2p7> Date: Fri, 08 Dec 2023 15:22:00 +0900 X-CMS-MailID: 20231208062200epcms2p7de0f3ab428a85eff0280225dbd1b1f37 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnk+LIzCtJLcpLzFFi42LZdljTVNdtW1GqwdHfHBYvD2larHoQbnF/ 6zVGi/5/7SwWnxqkLPZv+8dqcbx3B4vFqo65jBYrj9lYTD1/hMmBy+PJtc1MHu/3XWXz6Nuy ijGAOSrbJiM1MSW1SCE1Lzk/JTMv3VbJOzjeOd7UzMBQ19DSwlxJIS8xN9VWycUnQNctMwfo ECWFssScUqBQQGJxsZ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fefbddaf16a7f3f2758cf218ba References: <20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.254.224.34; envelope-from=daejun7.park@samsung.com; helo=mailout4.samsung.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 08 Dec 2023 09:17:31 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: daejun7.park@samsung.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @samsung.com) X-ZM-MESSAGEID: 1702045134054100001 This patch includes the following tests Test VPD page and report zones Test write and unaligned write error Signed-off-by: Daejun Park Reviewed-by: Jeuk Kim --- tests/qtest/ufs-test.c | 178 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/tests/qtest/ufs-test.c b/tests/qtest/ufs-test.c index 5daf8c9c49..798035f45b 100644 --- a/tests/qtest/ufs-test.c +++ b/tests/qtest/ufs-test.c @@ -27,6 +27,11 @@ #define UTP_RESPONSE_UPIU_OFFSET 1024 #define UTP_PRDT_UPIU_OFFSET 2048 =20 +#define ZONE_SIZE (2 * 1024 * 1024) +#define MAX_OPEN_ZONE 6 +#define NUM_ZONES (TEST_IMAGE_SIZE / ZONE_SIZE) +#define REPORT_ZONES_DESC_HD_SIZE 64 + typedef struct QUfs QUfs; =20 struct QUfs { @@ -534,6 +539,160 @@ static void ufstest_read_write(void *obj, void *data,= QGuestAllocator *alloc) ufs_exit(ufs, alloc); } =20 +static void ufstest_zufs_init(void *obj, void *data, QGuestAllocator *allo= c) +{ + QUfs *ufs =3D obj; + const int test_lun =3D 2; + + uint8_t buf[4096] =3D { 0 }; + const uint8_t request_sense_cdb[UFS_CDB_SIZE] =3D { + REQUEST_SENSE, + 0x01, + 0x00, + 0x00, + }; + /* VPD 0x00 page */ + const uint8_t inquiry_vpd_00_cdb[UFS_CDB_SIZE] =3D { + INQUIRY, + 0x01, /* EVPD */ + 0x00, /* page code */ + 0x00, 0x40, /* length */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + /* VPD 0xb6 page */ + const uint8_t inquiry_vpd_b6_cdb[UFS_CDB_SIZE] =3D { + INQUIRY, 0x01, /* EVPD */ + 0xb6, /* page code */ + 0x00, 0x40, /* length */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + /* Report zones */ + const uint8_t report_zones_cdb[UFS_CDB_SIZE] =3D { + ZBC_IN, ZI_REPORT_ZONES, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* LBA */ + 0x00, 0x00, 0x02, 0x00, /* length */ + 0x00, 0x00 + }; + UtpTransferReqDesc utrd; + UtpUpiuRsp rsp_upiu; + uint32_t zone_list_len; + + ufs_init(ufs, alloc); + + /* Clear Unit Attention */ + ufs_send_scsi_command(ufs, 0, test_lun, request_sense_cdb, NULL, 0, bu= f, + sizeof(buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, CHECK_CONDITION); + + /* Inquiry VPD page: 0x00 */ + ufs_send_scsi_command(ufs, 0, test_lun, inquiry_vpd_00_cdb, NULL, 0, b= uf, + sizeof(buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + g_assert_cmpuint(buf[0], =3D=3D, TYPE_ZBC); + g_assert_cmpuint(buf[7], =3D=3D, 0xb6); + + /* Inquiry VPD page: 0xb6 */ + ufs_send_scsi_command(ufs, 0, test_lun, inquiry_vpd_b6_cdb, NULL, 0, b= uf, + sizeof(buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + g_assert_cmpuint(buf[0], =3D=3D, TYPE_ZBC); + /* ZBC device characteristics */ + g_assert_cmpuint(buf[1], =3D=3D, 0xb6); + /* Number of max open zones */ + g_assert_cmpuint(buf[19], =3D=3D, MAX_OPEN_ZONE); + + /* Report zones */ + ufs_send_scsi_command(ufs, 0, test_lun, report_zones_cdb, NULL, 0, buf, + sizeof(buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + zone_list_len =3D ldl_be_p(&buf[0]); + g_assert_cmpuint(zone_list_len, =3D=3D, REPORT_ZONES_DESC_HD_SIZE * NU= M_ZONES); + + ufs_exit(ufs, alloc); +} + +static void ufstest_zufs_write(void *obj, void *data, QGuestAllocator *all= oc) +{ + QUfs *ufs =3D obj; + uint8_t read_buf[4096] =3D { 0 }; + uint8_t write_buf[4096] =3D { 0 }; + const uint8_t read_capacity_cdb[UFS_CDB_SIZE] =3D { + /* allocation length 4096 */ + SERVICE_ACTION_IN_16, + SAI_READ_CAPACITY_16, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00 + }; + const uint8_t request_sense_cdb[UFS_CDB_SIZE] =3D { + REQUEST_SENSE, + }; + const uint8_t write_cdb[UFS_CDB_SIZE] =3D { + /* WRITE(16) to LBA 0, transfer length 1 */ + WRITE_16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 + }; + uint32_t block_size; + UtpTransferReqDesc utrd; + UtpUpiuRsp rsp_upiu; + const int test_lun =3D 2; + + ufs_init(ufs, alloc); + + /* Clear Unit Attention */ + ufs_send_scsi_command(ufs, 0, test_lun, request_sense_cdb, NULL, 0, + read_buf, sizeof(read_buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, CHECK_CONDITION); + + /* Read capacity */ + ufs_send_scsi_command(ufs, 0, test_lun, read_capacity_cdb, NULL, 0, + read_buf, sizeof(read_buf), &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + block_size =3D ldl_be_p(&read_buf[8]); + g_assert_cmpuint(block_size, =3D=3D, 4096); + + /* Write data */ + memset(write_buf, 0xab, block_size); + ufs_send_scsi_command(ufs, 0, test_lun, write_cdb, write_buf, block_si= ze, + NULL, 0, &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, + UFS_COMMAND_RESULT_SUCCESS); + + /* Unaligned write error */ + ufs_send_scsi_command(ufs, 0, test_lun, write_cdb, write_buf, block_si= ze, + NULL, 0, &utrd, &rsp_upiu); + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), =3D=3D, UFS_OCS_SUC= CESS); + g_assert_cmpuint(rsp_upiu.header.scsi_status, =3D=3D, CHECK_CONDITION); + /* asc =3D=3D 0x21 */ + g_assert_cmpint(rsp_upiu.sr.sense_data[12], =3D=3D, 0x21); + /* ascq =3D=3D 0x04 */ + g_assert_cmpint(rsp_upiu.sr.sense_data[13], =3D=3D, 0x04); + + ufs_exit(ufs, alloc); +} + static void drive_destroy(void *path) { unlink(path); @@ -569,6 +728,19 @@ static void *ufs_blk_test_setup(GString *cmd_line, voi= d *arg) return arg; } =20 +static void *ufs_zufs_test_setup(GString *cmd_line, void *arg) +{ + char *tmp_path =3D drive_create(); + + g_string_append_printf(cmd_line, + " -blockdev file,filename=3D%s,node-name=3Ddrv2= " + "-device ufs-lu,bus=3Dufs0,drive=3Ddrv2,lun=3D2= ," + "zoned=3Don,zoned.max_open=3D%d,zoned.zone_size= =3D%d", + tmp_path, MAX_OPEN_ZONE, ZONE_SIZE); + + return arg; +} + static void ufs_register_nodes(void) { const char *arch; @@ -582,6 +754,10 @@ static void ufs_register_nodes(void) .before =3D ufs_blk_test_setup, }; =20 + QOSGraphTestOptions zufs_io_test_opts =3D { + .before =3D ufs_zufs_test_setup, + }; + add_qpci_address(&edge_opts, &(QPCIAddress){ .devfn =3D QPCI_DEVFN(4, = 0) }); =20 qos_node_create_driver("ufs", ufs_create); @@ -601,6 +777,8 @@ static void ufs_register_nodes(void) } qos_add_test("init", "ufs", ufstest_init, NULL); qos_add_test("read-write", "ufs", ufstest_read_write, &io_test_opts); + qos_add_test("zufs-init", "ufs", ufstest_zufs_init, &zufs_io_test_opts= ); + qos_add_test("zufs-write", "ufs", ufstest_zufs_write, &zufs_io_test_op= ts); } =20 libqos_init(ufs_register_nodes); --=20 2.25.1