From patchwork Mon Nov 14 13:50:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13042968 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA4DCC4332F for ; Mon, 14 Nov 2022 23:53:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oujB3-0001Y4-4X; Mon, 14 Nov 2022 18:47:45 -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 1ouifE-0004Vp-EW for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:14:53 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oua1X-00024z-72 for qemu-devel@nongnu.org; Mon, 14 Nov 2022 09:01:35 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20221114135428euoutp015071fc602edc6891f40bbefeeadd1f8c~nd-H_wfSO1925119251euoutp01V for ; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20221114135428euoutp015071fc602edc6891f40bbefeeadd1f8c~nd-H_wfSO1925119251euoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1668434068; bh=iMwST7AdxVjY1n+TKgEyrOBOqDS0BGwV9ESCrr4JkOc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=n82X6nDveItyM9uBGQNMVazyczZtzq3RU/piKZ7HWpptIxl+EW7IZiDVsfxFdfuvy Ro/KDsSPeUIm4N3XeQEkOateOZd7NXJEjzREYHB+/kPqLQCVflhFSARkV/aXoPmFjh Zrbc0DyBPdEHzyQJEG1fyOPdzV/WofmvVqTRT5P8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20221114135428eucas1p2448d8cf7c00c6259737e32d2a02fa3de~nd-H4C5Hl1591315913eucas1p29; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id AB.28.10112.39842736; Mon, 14 Nov 2022 13:54:27 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221114135427eucas1p1159db5cc4719af64f8a8449853815c4b~nd-HDuhzO3270632706eucas1p1t; Mon, 14 Nov 2022 13:54:27 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221114135427eusmtrp258c9cb6c2dd8f678b05ccd659bc7a588~nd-HC8mqf0116501165eusmtrp26; Mon, 14 Nov 2022 13:54:27 +0000 (GMT) X-AuditID: cbfec7f4-cf3ff70000002780-2d-63724893dd24 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A6.D3.08916.39842736; Mon, 14 Nov 2022 13:54:27 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221114135427eusmtip126ea1ad0cc6af17c5db5acef16726016~nd-G6PZDR2644826448eusmtip1M; Mon, 14 Nov 2022 13:54:27 +0000 (GMT) Received: from localhost (106.110.32.33) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 14 Nov 2022 13:54:26 +0000 From: Joel Granados To: , , CC: Joel Granados Subject: [PATCH v2 1/3] nvme: Move adjustment of data_units{read,written} Date: Mon, 14 Nov 2022 14:50:41 +0100 Message-ID: <20221114135043.2958100-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221114135043.2958100-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.110.32.33] X-ClientProxiedBy: CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7qTPYqSDWa+0beY9a6dzeJ47w4W ByaPJ9c2MwUwRnHZpKTmZJalFunbJXBl7O5by1SwR7Dix9z7jA2Mr3m6GDk5JARMJK593MHY xcjFISSwglFi49+jbBDOF0aJ/ofPmSGcz4wS827dZIJpOfsVpmU5o8Sj1fuY4Kr6+h9DOZsZ JR7sfs8K0sImoCNx/s0dZhBbRMBHYsXstWCjmAW0JG58PsIIYgsLeEo0X3vBDmKzCKhKPF3+ hQ3E5hWwlZj/8CIrxGp5ibbr08HqOQXsJM7+3sIOUSMocXLmExaImfISzVtnM0PYEhIHX7xg huhVlNgy5zvUnFqJB296wH6TEFjLIbG57QlUkYtE98SvULawxKvjEAskBGQk/u+cD/V/tsTO KbugagokZp2cCnQoB5BtLdF3Jgci7Cix4fAGdogwn8SNt4IQ5/BJTNo2nRkizCvR0SY0gVFl FpIHZiF5YBaSBxYwMq9iFE8tLc5NTy02ykst1ytOzC0uzUvXS87P3cQITAun/x3/soNx+auP eocYmTgYDzFKcDArifDOk8lPFuJNSaysSi3Kjy8qzUktPsQozcGiJM7LNkMrWUggPbEkNTs1 t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QidPlB5u3Noeoftbce3TF4nvrjx6TYzZ490vVLODLxEl3rKWLFOoW PTZolEjpnFHza+Lm5NgLVnuX6Fjp7r7w+e+MV4XN5qd7Sj9zaDXb7M+b9ChewL98ziSDE/Nc 4pSClib1zZrDl+XYcf3LqiVzLPL+/n3gbrdtZkHE86Uhbgorf7qmsrtPbwgzurN4h9DbFZ1i KV2Ji7/p7ayJbRdyaUv4WDnHpG/30bKA2oyjZYey+A8+W5u+/W/DvieCi9W2Wj1dJpAh0TAn 6efFpprTtkcf3Y9e+XRHydSeJNc1nOKBjtGNkdNtjiuxFGckGmoxFxUnAgDtrl1XJAMAAA== X-CMS-MailID: 20221114135427eucas1p1159db5cc4719af64f8a8449853815c4b X-Msg-Generator: CA X-RootMTR: 20221114135427eucas1p1159db5cc4719af64f8a8449853815c4b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221114135427eucas1p1159db5cc4719af64f8a8449853815c4b References: <20221114135043.2958100-1-j.granados@samsung.com> Received-SPF: pass client-ip=210.118.77.11; envelope-from=j.granados@samsung.com; helo=mailout1.w1.samsung.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 14 Nov 2022 18:47:40 -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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In order to return the units_{read/written} required by the SMART log we need to shift the number of bytes value by BDRV_SECTORS_BITS and multiply by 1000. This is a prep patch that moves this adjustment to where the SMART log is calculated in order to use the stats struct for calculating OCP extended smart log values. Signed-off-by: Joel Granados Reviewed-by: Klaus Jensen --- hw/nvme/ctrl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 87aeba0564..220683201a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4449,8 +4449,8 @@ static void nvme_set_blk_stats(NvmeNamespace *ns, struct nvme_stats *stats) { BlockAcctStats *s = blk_get_stats(ns->blkconf.blk); - stats->units_read += s->nr_bytes[BLOCK_ACCT_READ] >> BDRV_SECTOR_BITS; - stats->units_written += s->nr_bytes[BLOCK_ACCT_WRITE] >> BDRV_SECTOR_BITS; + stats->units_read += s->nr_bytes[BLOCK_ACCT_READ]; + stats->units_written += s->nr_bytes[BLOCK_ACCT_WRITE]; stats->read_commands += s->nr_ops[BLOCK_ACCT_READ]; stats->write_commands += s->nr_ops[BLOCK_ACCT_WRITE]; } @@ -4490,10 +4490,12 @@ static uint16_t nvme_smart_info(NvmeCtrl *n, uint8_t rae, uint32_t buf_len, trans_len = MIN(sizeof(smart) - off, buf_len); smart.critical_warning = n->smart_critical_warning; - smart.data_units_read[0] = cpu_to_le64(DIV_ROUND_UP(stats.units_read, - 1000)); - smart.data_units_written[0] = cpu_to_le64(DIV_ROUND_UP(stats.units_written, - 1000)); + smart.data_units_read[0] = cpu_to_le64(DIV_ROUND_UP( + stats.units_read >> BDRV_SECTOR_BITS, + 1000)); + smart.data_units_written[0] = cpu_to_le64(DIV_ROUND_UP( + stats.units_written >> BDRV_SECTOR_BITS, + 1000)); smart.host_read_commands[0] = cpu_to_le64(stats.read_commands); smart.host_write_commands[0] = cpu_to_le64(stats.write_commands); From patchwork Mon Nov 14 13:50:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13043021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78976C433FE for ; Tue, 15 Nov 2022 00:39:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oujAz-0001Re-VC; Mon, 14 Nov 2022 18:47:41 -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 1ouifG-00039s-0W for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:14:54 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouZv1-000826-ST for qemu-devel@nongnu.org; Mon, 14 Nov 2022 08:54:47 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20221114135429euoutp027dc2b4a5f8006258b32069c4b5d46a63~nd-It66JE0551305513euoutp02Q for ; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20221114135429euoutp027dc2b4a5f8006258b32069c4b5d46a63~nd-It66JE0551305513euoutp02Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1668434069; bh=FpL2SdcOPTGCpkLrCwzoyO4Cb+Y+WVVFyQmEBREwVjg=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=CDa81j/It4G435vp4T3eoRMMvoLPApkJwuaaBGAWvSRB+00B6H+k5TfxvoPi3pCiD rd01jgffCelEi/EnCU5kVtyUuE/YTrcEFRaszzpNYOTPuD9gCyEoPMoWE1sFErw0g3 fSoO2yPY7Frj+whlXyQky39E5WBDiS+J+SS8NZ2Y= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20221114135428eucas1p1bb3b0d42a2f653185be196be0177c4eb~nd-ImtZBu2218122181eucas1p1k; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id EE.28.10112.49842736; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221114135428eucas1p194fe5bc5c35783e4340ea89ebf4325fb~nd-IUe3WA2219722197eucas1p1z; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221114135428eusmtrp23bd2b15f8be18bf3e2bd6cf2bb3b2b58~nd-IT3eQW0116501165eusmtrp2A; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) X-AuditID: cbfec7f4-d09ff70000002780-32-6372489432a9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A7.D3.08916.49842736; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221114135428eusmtip129dc322c677928272c09275bfe79ed97~nd-III56D2870628706eusmtip1z; Mon, 14 Nov 2022 13:54:28 +0000 (GMT) Received: from localhost (106.110.32.33) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 14 Nov 2022 13:54:27 +0000 From: Joel Granados To: , , CC: Joel Granados Subject: [PATCH v2 2/3] nvme: Add ocp to the subsys Date: Mon, 14 Nov 2022 14:50:42 +0100 Message-ID: <20221114135043.2958100-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221114135043.2958100-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.110.32.33] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87pTPIqSDbZ/MrKY9a6dzeJ47w4W ByaPJ9c2MwUwRnHZpKTmZJalFunbJXBlfNq5mqXgLmfFtxlTWRoYX7N3MXJySAiYSJzsb2Ts YuTiEBJYwSjx/fY2NgjnC6PEt75+qMxnRom1F/azwLQ0936HqlrOKHHgwxuEqhXzbkI5mxkl jt4CKePkYBPQkTj/5g4ziC0i4COxYvZaJhCbWUBL4sbnI4wgtrCAscT+1k9gNouAqkTbwTtg F/IK2EpsubiYFWK1vETb9elgNZwCdhJnf2+BqhGUODnzCQvETHmJ5q2zmSFsCYmDL14wQ/Qq SmyZ8x1qTq3E2mNn2EEOlRBYyCHRsOEwE0TCRWLCpj9QtrDEq+NboMEkI/F/53yoeLbEzim7 oIYWSMw6ORXoSQ4g21qi70wORNhRovNJDzNEmE/ixltBiHP4JCZtmw4V5pXoaBOawKgyC8kD s5A8MAvJAwsYmVcxiqeWFuempxYb5aWW6xUn5haX5qXrJefnbmIEpoXT/45/2cG4/NVHvUOM TByMhxglOJiVRHjnyeQnC/GmJFZWpRblxxeV5qQWH2KU5mBREudlm6GVLCSQnliSmp2aWpBa BJNl4uCUamCK+le9VeylxsGJmy5dqH7tvG9NiWD10SmXFKwOvxZo2Kix7dNLjXtpIUc+1x1V Cld5uOi0alen8w8zt5XuAatZWf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OO1mdDL3T/f/rL1n7Rjkvbn3X+cfLS 6tdu/pD8OCfydtVtQ65NKZV+Urv/8rU0b1RUD+OXZP1/19orhFX2Y3C26eEV2XFder8vrQ3o PMQot/Ukb/O5Nh3dNbs5RQVvekqt/3EzXfnyK/Z/9Z3MjIwBFx6uyWKeNCvkbdvvB9n7Eh3n KX2V+FnGfttk1YG2iR/rNjp/0Xv1w7C+RImlOCPRUIu5qDgRAKXXHKEkAwAA X-CMS-MailID: 20221114135428eucas1p194fe5bc5c35783e4340ea89ebf4325fb X-Msg-Generator: CA X-RootMTR: 20221114135428eucas1p194fe5bc5c35783e4340ea89ebf4325fb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221114135428eucas1p194fe5bc5c35783e4340ea89ebf4325fb References: <20221114135043.2958100-1-j.granados@samsung.com> Received-SPF: pass client-ip=210.118.77.12; envelope-from=j.granados@samsung.com; helo=mailout2.w1.samsung.com X-Spam_score_int: -70 X-Spam_score: -7.1 X-Spam_bar: ------- X-Spam_report: (-7.1 / 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_HI=-5, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 14 Nov 2022 18:47:40 -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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The Open Compute Project defines a Datacenter NVMe SSD Spec that sits on top of the NVMe spec. Additional commands and NVMe behaviors specific for the Datacenter. This is a preparation patch that introduces an argument to activate OCP in nvme. Signed-off-by: Joel Granados --- hw/nvme/nvme.h | 1 + hw/nvme/subsys.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 79f5c281c2..aa99c0c57c 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -56,6 +56,7 @@ typedef struct NvmeSubsystem { struct { char *nqn; + bool ocp; } params; } NvmeSubsystem; diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index 9d2643678b..ecca28449c 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -129,8 +129,8 @@ static void nvme_subsys_realize(DeviceState *dev, Error **errp) static Property nvme_subsystem_props[] = { DEFINE_PROP_STRING("nqn", NvmeSubsystem, params.nqn), - DEFINE_PROP_END_OF_LIST(), -}; + DEFINE_PROP_BOOL("ocp", NvmeSubsystem, params.ocp, false), + DEFINE_PROP_END_OF_LIST(), }; static void nvme_subsys_class_init(ObjectClass *oc, void *data) { From patchwork Mon Nov 14 13:50:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13043020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD2DDC433FE for ; Tue, 15 Nov 2022 00:38:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oujAz-0001QI-8n; Mon, 14 Nov 2022 18:47:41 -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 1ouifF-0004ue-RF for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:14:55 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouZv1-00082M-RI for qemu-devel@nongnu.org; Mon, 14 Nov 2022 08:54:47 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20221114135430euoutp01ef2437ac44d6eba16e00125ea5c6f0fa~nd-JvcoPJ1806718067euoutp011 for ; Mon, 14 Nov 2022 13:54:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20221114135430euoutp01ef2437ac44d6eba16e00125ea5c6f0fa~nd-JvcoPJ1806718067euoutp011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1668434070; bh=J5neq/3VGBv3J/aVyB/eTxtZGVyl7Zip/hruMvvXq3g=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=tNdX+Ms8851IeRhqyEPRuzjUXKIz1qVAcDfL87EAChk+cRb5AYQRQos88VH+lVdjy RwLsr7ubHXt3UgNv4zpHlflmrY5PwTiAuQU1bHFPBUIxCqjaDBs7VCjNds8HWfVM6B OLMZv1+xd67tnjnBnc/FHKOA/gZRHWQDrzAI69mA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20221114135429eucas1p2f5457110590aa9147ddb0e40e2d39576~nd-JnPq3-1384613846eucas1p2L; Mon, 14 Nov 2022 13:54:29 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 86.CB.09549.59842736; Mon, 14 Nov 2022 13:54:29 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20221114135429eucas1p26370f7dd286e514105ae1173bfcc066f~nd-JQMvK11991919919eucas1p2t; Mon, 14 Nov 2022 13:54:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221114135429eusmtrp24ad5d89881e54f9b334b030bf6dd2e93~nd-JPlZKD0116501165eusmtrp2H; Mon, 14 Nov 2022 13:54:29 +0000 (GMT) X-AuditID: cbfec7f5-f5dff7000000254d-58-63724895dd51 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F8.D3.08916.59842736; Mon, 14 Nov 2022 13:54:29 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221114135429eusmtip2df3732169e73f0a225317759a30b3544~nd-JDuEth1578415784eusmtip2Z; Mon, 14 Nov 2022 13:54:29 +0000 (GMT) Received: from localhost (106.110.32.33) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 14 Nov 2022 13:54:28 +0000 From: Joel Granados To: , , CC: Joel Granados Subject: [PATCH v2 3/3] nvme: Add physical writes/reads from OCP log Date: Mon, 14 Nov 2022 14:50:43 +0100 Message-ID: <20221114135043.2958100-4-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221114135043.2958100-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.110.32.33] X-ClientProxiedBy: CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87pTPYqSDe6dN7OY9a6dzeJ47w4W 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lqQqZOQXl9gqRRtaGOkZWlroGZlY6hkam8daGZkq6dvZpKTmZJal FunbJehlPO/tYi64ZFDx+9VV5gbG7SpdjJwcEgImEjtOfWftYuTiEBJYyihxYMstNoiEjMSn Kx/ZIWxhiT/Xutggij4yShxacBbK2cwoMf38FWaQKjYBHYnzb+6A2SICPhIrZq9lArGZBbQk bnw+wghiCwu4SPxceIEVxGYRUJXoXbsMrJ5XwFZicvMmFoht8hJt16eD1XMK2Emc/b0F7Aoh oJot93dB1QtKnJz5hAVivrxE89bZzBC2hMTBFy+YIeYoSmyZ850Vwq6V2PR6PdMERpFZSNpn IWmfhaR9ASPzKkaR1NLi3PTcYkO94sTc4tK8dL3k/NxNjMC42Xbs5+YdjPNefdQ7xMjEwXiI UYKDWUmEd55MfrIQb0piZVVqUX58UWlOavEhRlOgPycyS4km5wMjN68k3tDMwNTQxMzSwNTS zFhJnNezoCNRSCA9sSQ1OzW1ILUIpo+Jg1OqgSn/5uaSxtr9j0xWV3O3/Sl5su24ZEqA+0Gt m1f2b/fxEA7et2v99KQnG7Q/F7c3Nd290N1v/W5litT2yhWpymo2fde5fkTe3tTg5njy1wPO jgkWm83aTfbuPXfi0N87af8lvfRdQ/82zP2hkVcV/MRk+mrZJ1/z6xUPXG2xSukpuSUgxxLv MVHS59PTvYcO7cvpOFX8w0CyQfw45/NVKybkxSrNU/q2+dr/vCf/JevfpjUdehFeLhhfr5E3 Sb1r/yrmlfeq7a5o8+netpO5qrn6Ats6Nd+TEV0PPXY81zH5JqTVyqxluu9HVla87e+o81fs +zy2fDF4ltvHt7KWIZx9+6RehryEd87666qLNJVYijMSDbWYi4oTAak+6iEkAwAA X-CMS-MailID: 20221114135429eucas1p26370f7dd286e514105ae1173bfcc066f X-Msg-Generator: CA X-RootMTR: 20221114135429eucas1p26370f7dd286e514105ae1173bfcc066f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221114135429eucas1p26370f7dd286e514105ae1173bfcc066f References: <20221114135043.2958100-1-j.granados@samsung.com> Received-SPF: pass client-ip=210.118.77.11; envelope-from=j.granados@samsung.com; helo=mailout1.w1.samsung.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 14 Nov 2022 18:47:40 -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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In order to evaluate write amplification factor (WAF) within the storage stack it is important to know the number of bytes written to the controller. The existing SMART log value of Data Units Written is too coarse (given in units of 500 Kb) and so we add the SMART health information extended from the OCP specification (given in units of bytes). To accomodate different vendor specific specifications like OCP, we add a multiplexing function (nvme_vendor_specific_log) which will route to the different log functions based on arguments and log ids. We only return the OCP extended smart log when the command is 0xC0 and ocp has been turned on in the args. Though we add the whole nvme smart log extended structure, we only populate the physical_media_units_{read,written}, log_page_version and log_page_uuid. Signed-off-by: Joel Granados squash with main Signed-off-by: Joel Granados --- hw/nvme/ctrl.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ include/block/nvme.h | 36 ++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 220683201a..5e6a8150a2 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4455,6 +4455,42 @@ static void nvme_set_blk_stats(NvmeNamespace *ns, struct nvme_stats *stats) stats->write_commands += s->nr_ops[BLOCK_ACCT_WRITE]; } +static uint16_t nvme_ocp_extended_smart_info(NvmeCtrl *n, uint8_t rae, + uint32_t buf_len, uint64_t off, + NvmeRequest *req) +{ + NvmeNamespace *ns = NULL; + NvmeSmartLogExtended smart_ext = { 0 }; + struct nvme_stats stats = { 0 }; + uint32_t trans_len; + + if (off >= sizeof(smart_ext)) { + return NVME_INVALID_FIELD | NVME_DNR; + } + + // Accumulate all stats from all namespaces + for (int i = 1; i <= NVME_MAX_NAMESPACES; i++) { + ns = nvme_ns(n, i); + if (ns) + { + nvme_set_blk_stats(ns, &stats); + } + } + + smart_ext.physical_media_units_written[0] = cpu_to_le32(stats.units_written); + smart_ext.physical_media_units_read[0] = cpu_to_le32(stats.units_read); + smart_ext.log_page_version = 0x0003; + smart_ext.log_page_uuid[0] = 0xA4F2BFEA2810AFC5; + smart_ext.log_page_uuid[1] = 0xAFD514C97C6F4F9C; + + if (!rae) { + nvme_clear_events(n, NVME_AER_TYPE_SMART); + } + + trans_len = MIN(sizeof(smart_ext) - off, buf_len); + return nvme_c2h(n, (uint8_t *) &smart_ext + off, trans_len, req); +} + static uint16_t nvme_smart_info(NvmeCtrl *n, uint8_t rae, uint32_t buf_len, uint64_t off, NvmeRequest *req) { @@ -4642,6 +4678,24 @@ static uint16_t nvme_cmd_effects(NvmeCtrl *n, uint8_t csi, uint32_t buf_len, return nvme_c2h(n, ((uint8_t *)&log) + off, trans_len, req); } +static uint16_t nvme_vendor_specific_log(uint8_t lid, NvmeCtrl *n, uint8_t rae, + uint32_t buf_len, uint64_t off, + NvmeRequest *req) +{ + NvmeSubsystem *subsys = n->subsys; + switch (lid) { + case NVME_LOG_VENDOR_START: + if (subsys->params.ocp) { + return nvme_ocp_extended_smart_info(n, rae, buf_len, off, req); + } + break; + /* Add a case for each additional vendor specific log id */ + } + + trace_pci_nvme_err_invalid_log_page(nvme_cid(req), lid); + return NVME_INVALID_FIELD | NVME_DNR; +} + static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req) { NvmeCmd *cmd = &req->cmd; @@ -4683,6 +4737,8 @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req) return nvme_error_info(n, rae, len, off, req); case NVME_LOG_SMART_INFO: return nvme_smart_info(n, rae, len, off, req); + case NVME_LOG_VENDOR_START...NVME_LOG_VENDOR_END: + return nvme_vendor_specific_log(lid, n, rae, len, off, req); case NVME_LOG_FW_SLOT_INFO: return nvme_fw_log_info(n, len, off, req); case NVME_LOG_CHANGED_NSLIST: diff --git a/include/block/nvme.h b/include/block/nvme.h index 8027b7126b..2ab0dca529 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -978,6 +978,40 @@ typedef struct QEMU_PACKED NvmeSmartLog { uint8_t reserved2[320]; } NvmeSmartLog; +typedef struct QEMU_PACKED NvmeSmartLogExtended { + uint64_t physical_media_units_written[2]; + uint64_t physical_media_units_read[2]; + uint64_t bad_user_blocks; + uint64_t bad_system_nand_blocks; + uint64_t xor_recovery_count; + uint64_t uncorrectable_read_error_count; + uint64_t soft_ecc_error_count; + uint64_t end2end_correction_counts; + uint8_t system_data_percent_used; + uint8_t refresh_counts[7]; + uint64_t user_data_erase_counts; + uint16_t thermal_throttling_stat_and_count; + uint16_t dssd_spec_version[3]; + uint64_t pcie_correctable_error_count; + uint32_t incomplete_shutdowns; + uint32_t reserved0; + uint8_t percent_free_blocks; + uint8_t reserved1[7]; + uint16_t capacity_health; + uint8_t nvme_errata_ver; + uint8_t reserved2[5]; + uint64_t unaligned_io; + uint64_t security_ver_num; + uint64_t total_nuse; + uint64_t plp_start_count[2]; + uint64_t endurance_estimate[2]; + uint64_t pcie_retraining_count; + uint64_t power_state_change_count; + uint8_t reserved3[286]; + uint16_t log_page_version; + uint64_t log_page_uuid[2]; +} NvmeSmartLogExtended; + #define NVME_SMART_WARN_MAX 6 enum NvmeSmartWarn { NVME_SMART_SPARE = 1 << 0, @@ -1010,6 +1044,8 @@ enum NvmeLogIdentifier { NVME_LOG_FW_SLOT_INFO = 0x03, NVME_LOG_CHANGED_NSLIST = 0x04, NVME_LOG_CMD_EFFECTS = 0x05, + NVME_LOG_VENDOR_START = 0xC0, + NVME_LOG_VENDOR_END = 0xFF, }; typedef struct QEMU_PACKED NvmePSD {