From nobody Tue Nov 26 13:31:37 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1707949467; cv=none; d=zohomail.com; s=zohoarc; b=RDNK4UZalzkkqjY0UW743fPlqulscl7uyn1Wba8P6B+28nSbUjUYcuup4E+ZyuS4WRTtLAHF/L9RNUHO84OeQtZnX+hKsaMn0NY3WLzdwbKD2aQaX+ROGWepAjzA5JDghAsV/Iq4gDomyPKe0pcaAXVjUHfGGbMIlA0+2cBeZUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707949467; h=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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=js9MPuxE6HDFGb/bm1Qi8CQe6wvYU0HraTNqQ6YK0o4=; b=hF8Uv972zcGhN/TR+IS4BHCSBDNaYmICnjdK6mlYOmELMrWBJbVe8A6TFCk6Gz86z0s0fvrxk0dmIIVD7HvRh+gkc5Qz6of6OWqEgjvD3PZ5fPg7emOrGVQrN/44/zrtI7lmg8e0Hmfe2jOwsibrSjH0F1FvFbWa8oh6IoqMJ+4= 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 1707949467082854.6799364131066; Wed, 14 Feb 2024 14:24:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raNfT-0002yt-Iv; Wed, 14 Feb 2024 17:23:51 -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 1raNfP-0002yC-DP; Wed, 14 Feb 2024 17:23:47 -0500 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raNfN-0004LC-Sl; Wed, 14 Feb 2024 17:23:47 -0500 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6e104a8e3f7so284070b3a.1; Wed, 14 Feb 2024 14:23:45 -0800 (PST) Received: from localhost ([116.121.76.56]) by smtp.gmail.com with ESMTPSA id t27-20020a62d15b000000b006e03a640007sm10215269pfl.71.2024.02.14.14.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 14:23:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707949424; x=1708554224; darn=nongnu.org; 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=js9MPuxE6HDFGb/bm1Qi8CQe6wvYU0HraTNqQ6YK0o4=; b=Ay9qMNrYgER2xOMZL+vJZOksnwalFAA73ji2cdpZxtz3CZ6RtJTUJT+PtaysKdWct5 qYpe4gwK22ceeV8LygmGRMQNmZnW/vP2xgnp8vWkiDGEXhYVSQJsUqD9EsMke/OM8/eP 4amCbDb2PSevNR75kMgUz4W1gsdLU3VFYgoxYF0VrRxktTR0TBK8on3AkiIKC4LLy4UD bNN3Xy83zAL/NtA2HDgS2OzoPRaPDIba9J6E9QbuY7KZ8qNCuQLFFwttiYraxkgpkPU3 AhjeH5cW7/znayBMhu5QuoFQiXbx8r4P4yQnNbmjLzC/o1tcOcji11PArpLatMbIujWr 3G1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707949424; x=1708554224; 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=js9MPuxE6HDFGb/bm1Qi8CQe6wvYU0HraTNqQ6YK0o4=; b=UtpqusBnWVV8zFbNKCwLixLwU2uObMb+5hBbR1m2TTC2ufgzNKzWHiDbKYdge3tmdx DBeuClTrFZ/UQH4D3xYD3Ij6c1N+kQEyD59CJ4dIQiv/dgqZQwiqgoaQsqCkrOKHzM6Y YEGyQR4zhas+gEGK1ZsQr6KgQfUNPFIP2l4F3I6h5tx33OAu9Zz33xQKRvrYceb6ePe4 yIBwF8FcQhf/YMqPN4HNIpAMuSNuqMUez/Tvhyt5qx5KT8bDEy1jHTrM+lcf9tmlmfgk EQk5SmlyX4Tn4q8hCYWH1hzyRT+0s2wClUgeehQNNqqO3pV+Edj0ysV0CsR9Nqu4sECM r/Sw== X-Forwarded-Encrypted: i=1; AJvYcCWbajInvIaiOT7FD5/B7axHErBEbFK+R25OZ4EoAi4XI/h0dt6eQHQ1MPxXXGuoIZpKKxGjaKnwKWoS3r9A16dLQVfudmQ= X-Gm-Message-State: AOJu0YwcDFfMRYkiFZK3j3/yTYRXXngWqvaEfE2i1dKMDxaxfwVhIWuX 2mkwNnBgawb0FkgG1XcyDc5UmgbnsKAa5uVd3zP1rK0gEryngJXOiF8lRFHYGM8= X-Google-Smtp-Source: AGHT+IGjqh0+2tP17eVBq7c1nX/+GlZ5zdJ4IsNWQw8zJ16xuLByBCHpRakHmYfe5OdE8oaCDFVYEw== X-Received: by 2002:a05:6a00:1995:b0:6e0:e618:7eb0 with SMTP id d21-20020a056a00199500b006e0e6187eb0mr216238pfl.8.1707949424231; Wed, 14 Feb 2024 14:23:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWuNLFg88Ex74oHJDi16aHb3teNa0ZVrj9kTmQXtICY886iND3h/U0xWUcMqM9HfV1wvLtnXEwT04jMa9/tEd61efPHSwHKfIQ3v12Yrn3QFNVAD5wEnw+uJylTvhW+SW5TQZ/8rMJjXZJi3i6/L7GfTPgldZ+r84thnqHrJka1F9YdLbJS From: Minwoo Im To: Keith Busch , Klaus Jensen Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Minwoo Im , Klaus Jensen Subject: [PATCH 1/3] hw/nvme: add Identify Endurance Group List Date: Thu, 15 Feb 2024 07:23:35 +0900 Message-Id: <20240214222337.5699-2-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214222337.5699-1-minwoo.im.dev@gmail.com> References: <20240214222337.5699-1-minwoo.im.dev@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::42e; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pf1-x42e.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1707949468381100007 Content-Type: text/plain; charset="utf-8" From: Minwoo Im Commit 73064edfb864 ("hw/nvme: flexible data placement emulation") intorudced NVMe FDP feature to nvme-subsys and nvme-ctrl with a single endurance group #1 supported. This means that controller should return proper identify data to host with Identify Endurance Group List (CNS 19h). But, yes, only just for the endurance group #1. This patch allows host applications to ask for which endurance group is available and utilize FDP through that endurance group. Signed-off-by: Minwoo Im Reviewed-by: Klaus Jensen --- hw/nvme/ctrl.c | 22 ++++++++++++++++++++++ include/block/nvme.h | 1 + 2 files changed, 23 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f026245d1e9e..cfe53a358871 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5629,6 +5629,26 @@ static uint16_t nvme_identify_nslist_csi(NvmeCtrl *n= , NvmeRequest *req, return nvme_c2h(n, list, data_len, req); } =20 +static uint16_t nvme_endurance_group_list(NvmeCtrl *n, NvmeRequest *req) +{ + uint16_t list[NVME_CONTROLLER_LIST_SIZE] =3D {}; + uint16_t *nr_ids =3D &list[0]; + uint16_t *ids =3D &list[1]; + uint16_t endgid =3D le32_to_cpu(req->cmd.cdw11) & 0xffff; + + /* + * The current nvme-subsys only supports Endurance Group #1. + */ + if (!endgid) { + *nr_ids =3D 1; + ids[0] =3D 1; + } else { + *nr_ids =3D 0; + } + + return nvme_c2h(n, list, sizeof(list), req); +} + static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req) { NvmeNamespace *ns; @@ -5732,6 +5752,8 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeReques= t *req) return nvme_identify_nslist(n, req, false); case NVME_ID_CNS_CS_NS_ACTIVE_LIST: return nvme_identify_nslist_csi(n, req, true); + case NVME_ID_CNS_ENDURANCE_GROUP_LIST: + return nvme_endurance_group_list(n, req); case NVME_ID_CNS_CS_NS_PRESENT_LIST: return nvme_identify_nslist_csi(n, req, false); case NVME_ID_CNS_NS_DESCR_LIST: diff --git a/include/block/nvme.h b/include/block/nvme.h index bb231d0b9ad0..7c77d38174a7 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -1074,6 +1074,7 @@ enum NvmeIdCns { NVME_ID_CNS_CTRL_LIST =3D 0x13, NVME_ID_CNS_PRIMARY_CTRL_CAP =3D 0x14, NVME_ID_CNS_SECONDARY_CTRL_LIST =3D 0x15, + NVME_ID_CNS_ENDURANCE_GROUP_LIST =3D 0x19, NVME_ID_CNS_CS_NS_PRESENT_LIST =3D 0x1a, NVME_ID_CNS_CS_NS_PRESENT =3D 0x1b, NVME_ID_CNS_IO_COMMAND_SET =3D 0x1c, --=20 2.34.1