From patchwork Sun Jan 17 14:53:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F47DC433E6 for ; Sun, 17 Jan 2021 14:55:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BB5DD22262 for ; Sun, 17 Jan 2021 14:55:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB5DD22262 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19TA-00065q-QU for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 09:55:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RE-0004Nx-Sh; Sun, 17 Jan 2021 09:53:56 -0500 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:36565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RC-00040e-7D; Sun, 17 Jan 2021 09:53:56 -0500 Received: by mail-pf1-x42e.google.com with SMTP id b3so8669587pft.3; Sun, 17 Jan 2021 06:53:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RxdKtO/FiMxWvfgiYYveWU7zuT36I4thGWqj5spF5yg=; b=iwE64ANQ4rHSvcH4cl/gfvZHG1FOS2wbR+16/MKdz6zz/IlRPzPMqYqecFUrQTYR1n 6xk7IVTZIt5fDfn5yIoL1VGJCp9zqKHN9OBjf9/KZrvE45CB+C9fF4QPZmgt9Om8BCEh OtmUPCUga5I3qhM1XKMkGzFC/Brjvr7c6k/CtzaPoi5AKstGVytN/LKxjrglwgxt9Yjc 10/YVzdpTz//8kTT5h/t6LxMklOW3A6zSTY6wjVTTWc4C7/gnuwP7sqWtzzfgg0wwvG1 HOgPlWsjIST7cfGq5RgNzbn6JeDzOTnve3gV9Duap/jszzDO+o2ezQws502eexeHl3Va UMvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RxdKtO/FiMxWvfgiYYveWU7zuT36I4thGWqj5spF5yg=; b=bEMma+Mx+yC66xUlYrqQmmQHBuNoy4vY5MNhfzN03cAPMj4yTsx88z3E24/2qX/SRw zQ0CrPYP6lFavSrgmI1EfI/xJE0L/w2oC9zUVrqiX330Tt7WMeZvtzBPBuKMilCXtrDe 2M7ePOwfCHXaR+IhEhGE+EM1doy50h1c34ZFowlm+tqBfWEYnVknU2f5Y01AlBa3Ie/r wtnQagMnKFgXglJOVgYgqwcxl7+U+ufdVfCVTewCNKD+P6AASi4e6aDPMdvwLFaXmPKU h5YRtFpQQfuQswKOtdKm9AHq9qXSwTBpNX0BWnQukQ5LtXD0rfgCsPw1PY49rTSye67n vAXA== X-Gm-Message-State: AOAM530j/ixKeD49lRkyPRodykTFWQl7SMug7ZkHpohv/E94EZOv5Kro urL4zHQ/3GNXIHzOHOwz+kFsQwv2Va2sxw== X-Google-Smtp-Source: ABdhPJw6jnsd985Kan/DovP6vTL0xXtp3VdAYjUcGwMFLBYbGg4LzstHb1MBhYHsu2qK9edRUsZmaw== X-Received: by 2002:aa7:84d5:0:b029:19d:da20:73fe with SMTP id x21-20020aa784d50000b029019dda2073femr21894055pfn.16.1610895232434; Sun, 17 Jan 2021 06:53:52 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:53:52 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 01/11] hw/block/nvme: remove unused argument in nvme_ns_init_zoned Date: Sun, 17 Jan 2021 23:53:31 +0900 Message-Id: <20210117145341.23310-2-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_ns_init_zoned() has no use for given NvmeCtrl object. Signed-off-by: Minwoo Im Reviewed-by: Klaus Jensen --- hw/block/nvme-ns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index 274eaf61b721..32662230130b 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -204,7 +204,7 @@ static void nvme_ns_zoned_init_state(NvmeNamespace *ns) } } -static void nvme_ns_init_zoned(NvmeCtrl *n, NvmeNamespace *ns, int lba_index) +static void nvme_ns_init_zoned(NvmeNamespace *ns, int lba_index) { NvmeIdNsZoned *id_ns_z; @@ -321,7 +321,7 @@ int nvme_ns_setup(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) if (nvme_ns_zoned_check_calc_geometry(ns, errp) != 0) { return -1; } - nvme_ns_init_zoned(n, ns, 0); + nvme_ns_init_zoned(ns, 0); } if (nvme_register_namespace(n, ns, errp)) { From patchwork Sun Jan 17 14:53:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F097C433DB for ; Sun, 17 Jan 2021 14:56:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 11F8921D81 for ; Sun, 17 Jan 2021 14:56:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11F8921D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19TY-0006J2-SX for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 09:56:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RG-0004PV-A0; Sun, 17 Jan 2021 09:53:58 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:33766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RE-00041s-Ms; Sun, 17 Jan 2021 09:53:58 -0500 Received: by mail-pl1-x62d.google.com with SMTP id b8so7225507plx.0; Sun, 17 Jan 2021 06:53:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ePUqokcNCu1135M5rENh02CwQRe25aSU4ChI3LMevlI=; b=oVFDahcwk/VlgBvGHute5RnyZCJHUtHYwD5hDY74wTaZi7d6/bWX3jqzPmI3mBPIv5 ZiLPgsRUDvT0eNlqsKWgeNK5FHF8rfT/wvcx3XQL/MUSdbMteBSWrQJ4/eU8pOLSXJQl lpAj8d31UbIpcNvfElFFsWg6AFU6N01+OFc90DthGWfSWYU/nvv6OkG2JzPkSkTR4/SP 3k04ZIC+b6vnL8tGZLlj4QeKpJXEjNokofIINRX+tEGscxMl/aKMqcAUSVMMHYVCZ6dM YLHAULGzmSQNH2+JIxylfUhSOTnMoWHRsAF2nPja9FQYidyjpn6+91uifnB0TZHza0w3 tBFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ePUqokcNCu1135M5rENh02CwQRe25aSU4ChI3LMevlI=; b=tsh1pAqALg4q5l3X59CJM975fcalLIMDp5EVt5/0UNcz489A6nkXwJEmrsNfMN7+Ny DHWZQQ8bR55H8nf25DFrKI9pcq/WUHLmZfc9lxACFyycqtgKzWLlIzKx+T3tN8gaiE23 vG1Ap3AQysJo6bFXmt+1r2z4J7bTWFCTI9e0q4sDfHCI1c5M+FsTBkKHPOKbGAFlekqf B2xB6VEeZUq2CCLXj8I0TyRZM7FTy1kN9I/dzvho3HLoznpzIAEActsMJsr9CJY2pMiL k8vC/U97jwahL3UQbkPWSfakbdrfnBKxuWw3dQgD/w/viL9APBhbk4tX3kYSoaRYrxMv 8Jsg== X-Gm-Message-State: AOAM530EUyoWlLa1jHWU6hI5mYkXmzJahbRxIem/C9flyogwUoQGugP2 n91VVB6A8t2pmKjZzFlSb+IN6JOR8Z+fSA== X-Google-Smtp-Source: ABdhPJyybzm15A2qGJrFId73tfi/KdkvUyFjOu3w+w901eDtchGm1Prd9k7CPCJLnzkYgZ2kLVfDuw== X-Received: by 2002:a17:90a:a415:: with SMTP id y21mr21537663pjp.88.1610895234823; Sun, 17 Jan 2021 06:53:54 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:53:54 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 02/11] hw/block/nvme: open code for volatile write cache Date: Sun, 17 Jan 2021 23:53:32 +0900 Message-Id: <20210117145341.23310-3-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pl1-x62d.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Volatile Write Cache(VWC) feature is set in nvme_ns_setup() in the initial time. This feature is related to block device backed, but this feature is controlled in controller level via Set/Get Features command. This patch removed dependency between nvme and nvme-ns to manage the VWC flag value. Also, it open coded the Get Features for VWC to check all namespaces attached to the controller, and if false detected, return directly false. Signed-off-by: Minwoo Im Reviewed-by: Klaus Jensen --- hw/block/nvme-ns.c | 4 ---- hw/block/nvme.c | 15 ++++++++++++--- hw/block/nvme.h | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index 32662230130b..c403cd36b6bd 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -89,10 +89,6 @@ static int nvme_ns_init_blk(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) return -1; } - if (blk_enable_write_cache(ns->blkconf.blk)) { - n->features.vwc = 0x1; - } - return 0; } diff --git a/hw/block/nvme.c b/hw/block/nvme.c index cf0fe28fe6eb..b2a9c48a9d81 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -3033,6 +3033,7 @@ static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeRequest *req) NvmeGetFeatureSelect sel = NVME_GETFEAT_SELECT(dw10); uint16_t iv; NvmeNamespace *ns; + int i; static const uint32_t nvme_feature_default[NVME_FID_MAX] = { [NVME_ARBITRATION] = NVME_ARB_AB_NOLIMIT, @@ -3108,7 +3109,17 @@ static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeRequest *req) result = ns->features.err_rec; goto out; case NVME_VOLATILE_WRITE_CACHE: - result = n->features.vwc; + for (i = 1; i <= n->num_namespaces; i++) { + ns = nvme_ns(n, i); + if (!ns) { + continue; + } + + result = blk_enable_write_cache(ns->blkconf.blk); + if (!result) { + break; + } + } trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); goto out; case NVME_ASYNCHRONOUS_EVENT_CONF: @@ -3271,8 +3282,6 @@ static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeRequest *req) ns->features.err_rec = dw11; break; case NVME_VOLATILE_WRITE_CACHE: - n->features.vwc = dw11 & 0x1; - for (i = 1; i <= n->num_namespaces; i++) { ns = nvme_ns(n, i); if (!ns) { diff --git a/hw/block/nvme.h b/hw/block/nvme.h index b7fbcca39d9f..5ba83ee77841 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -117,7 +117,6 @@ typedef struct NvmeFeatureVal { uint16_t temp_thresh_low; }; uint32_t async_config; - uint32_t vwc; } NvmeFeatureVal; typedef struct NvmeCtrl { From patchwork Sun Jan 17 14:53:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025423 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76FA1C433E0 for ; Sun, 17 Jan 2021 14:59:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0130B21D81 for ; Sun, 17 Jan 2021 14:59:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0130B21D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19WA-0001Up-3l for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 09:59:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RI-0004QZ-Lm; Sun, 17 Jan 2021 09:54:00 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:39263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RG-00042q-Ti; Sun, 17 Jan 2021 09:54:00 -0500 Received: by mail-pj1-x102b.google.com with SMTP id u4so8049924pjn.4; Sun, 17 Jan 2021 06:53:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LPwEuV0/04eVLqoLUFPzyx3q6xjC8+PXkwPXg+pptj4=; b=byfhCWBSdqF5R6vdqmx/S05qNCC3AWQ9oePLjRmHjV7Xe5uYCww3sDqOe8FaJjH91P 7q/BWlYVk6bnRoyd8U9Il0p4dUcQ4UsmtfNI6vhe3LudY1ss3j4nWO6YG+BBDUErqZ+f xhINovf+lmGrSD+SohsalO4gh/w4X+FddzVBZuaBbNGdLFa92AACL5DeYhkJfAHa2q3C HOYZB5tdQOa5GlqukghRdvweApdGHnVj7eezru3DaaBnL69IZp8gI5cTjHQw54Tai3Y9 z1xaZZawZp+DLkBOkwcXLkF31ztYC2zG0WCNPnIqkoXzpEu0yPVc0U7tET2LN5FhpOyl dI3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LPwEuV0/04eVLqoLUFPzyx3q6xjC8+PXkwPXg+pptj4=; b=ah8tQjDgbbZTrGip/bIUUPGQBgcUS+/q8qLaUo8x4DrfxNQnQuv/zA7R5P9YLDvT1e XommEju9KQ/ghy0ARfq8FaWptHRAyeeMrb1sflR/Z8fHc1a4+KGe76dhsXeZ5mfQufyB rkvxPoIDyReD9M+3zGnyftEsmdOx50koMo59EC3W5zr0fLnj6w13eadgkOzToXLGJokO Qjwfch3RjMSj2vrsI3+90q4Y//w0pKIZbXTkKTScWtFgI7vclhMBGBIEWT8ir8yKQJBj a3c3//PFCiFR64TPzPxrWeCM/6HPMI/FbjCYREwieKyPvIDrmXTV+LxPkTMRzyYOC97E 5BwQ== X-Gm-Message-State: AOAM5312Hhh89vgCZZGwXdM112LdCbAvAW6VzWAn92LK5BrkIqXwBRHW yqPy6A8hg6za739+lnwFWg4g4eCcOVpYgQ== X-Google-Smtp-Source: ABdhPJxhhz9LCy77eyWRjQFyJJDMPo7BHNb80WR6nPRpXwLjx6NRkSFp5uknaE/p64LYZq5qm39a7w== X-Received: by 2002:a17:90a:a60d:: with SMTP id c13mr21587281pjq.11.1610895237212; Sun, 17 Jan 2021 06:53:57 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:53:56 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 03/11] hw/block/nvme: remove unused argument in nvme_ns_init_blk Date: Sun, 17 Jan 2021 23:53:33 +0900 Message-Id: <20210117145341.23310-4-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pj1-x102b.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Removed no longer used aregument NvmeCtrl object in nvme_ns_init_blk(). Signed-off-by: Minwoo Im Reviewed-by: Klaus Jensen --- hw/block/nvme-ns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index c403cd36b6bd..fc42ae184e01 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -66,7 +66,7 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) return 0; } -static int nvme_ns_init_blk(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) +static int nvme_ns_init_blk(NvmeNamespace *ns, Error **errp) { if (!blkconf_blocksizes(&ns->blkconf, errp)) { return -1; @@ -306,7 +306,7 @@ int nvme_ns_setup(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) return -1; } - if (nvme_ns_init_blk(n, ns, errp)) { + if (nvme_ns_init_blk(ns, errp)) { return -1; } From patchwork Sun Jan 17 14:53:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B303AC433DB for ; Sun, 17 Jan 2021 14:59:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5672521D81 for ; Sun, 17 Jan 2021 14:59:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5672521D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19W9-0001TB-Di for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 09:59:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RM-0004SE-CZ; Sun, 17 Jan 2021 09:54:04 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:38462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RJ-00044A-7y; Sun, 17 Jan 2021 09:54:04 -0500 Received: by mail-pl1-x634.google.com with SMTP id d4so7211937plh.5; Sun, 17 Jan 2021 06:54:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rE9OF6JGzyy16WYqRAitzHWBoYb2h0+LL0UAOO+IgQA=; b=n2ZCE2VbEJo0yWkAsvoS7iZNFQR1KmXMc79WBpNjpLyrZZSHuQUc71xF/Z0MRU9Xps I6Vttgjba7b1Gdxb7PjUlEPcNVPnh93dp9PfH7Tj7BryPgAIJ5lb+/+XnVWwzlRpE4Y+ QIEo7/jyKXYnbowvFHGJmjob13UzjMu0SwpeplMz8UvIXC7hBvhXwlL1O2MmCXgqbWSr xYo5+dNJ8rnxZbEItuvjVxcxfRMyH3U3IqqrSX/oO1feoPZzEu3JvBTRFd9k5ib7j88Z XX3wRWx1gADnhk+4+gi0WYMvPuK48lDcKVO+vSUigNVStfiKBnuwjsm2IV/j4yvMpdeE pzgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rE9OF6JGzyy16WYqRAitzHWBoYb2h0+LL0UAOO+IgQA=; b=IcPuGlC0cYcwCf+9ReeQL+bJ292wIvj36Gi1gvprYxNTmhi+BFztv33jJrdKnBaUwn LZUG8Pa2DQwEn89h75K4fkk8Z+1Ym0jOBPdB6lz+GFIS/8Kfwv6LN+twI+LFy6U1afcZ ULRueIya1nSFu6kFHjCVqwGHqguJkFXMsT7kFon45V5YO+7TUdtwGPGQRsGz0xGxxsio 2WmW+heuUsOj01FomE4LsbNzHItptnD7kZsnpaMlb1Ts5Oe6jgEo0WW+/XAukCQDIUy8 aAHPwGO9HFfPeQy3oBL6Sojq+cc/aLUjOIKbV8KDSrL/+cWi6HpWrhwUNr3k1PW3XiVu fyDA== X-Gm-Message-State: AOAM530RhaWx1N4hNR2YYl9+7p240Z126dG3XxqRzHt4837zvBLhZFG9 i9uKo34SywQ+W7g7H7I/3xf4SpIbvF/Z1A== X-Google-Smtp-Source: ABdhPJxDCaCozuJzKgS/cCseiAVFoGqIbT5mv4HTAg+5SseqjMQxaLRYSUC1KIbC/PLrmdv6i4e02A== X-Received: by 2002:a17:90b:1014:: with SMTP id gm20mr15745347pjb.5.1610895239574; Sun, 17 Jan 2021 06:53:59 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:53:59 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 04/11] hw/block/nvme: split setup and register for namespace Date: Sun, 17 Jan 2021 23:53:34 +0900 Message-Id: <20210117145341.23310-5-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pl1-x634.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In NVMe, namespace is being attached to process I/O. We register NVMe namespace to a controller via nvme_register_namespace() during nvme_ns_setup(). This is main reason of receiving NvmeCtrl object instance to this function to map the namespace to a controller. To make namespace instance more independent, it should be split into two parts: setup and register. This patch split them into two differnt parts, and finally nvme_ns_setup() does not have nothing to do with NvmeCtrl instance at all. This patch is a former patch to introduce NVMe subsystem scheme to the existing design especially for multi-path. In that case, it should be split into two to make namespace independent from a controller. Signed-off-by: Minwoo Im Reviewed-by: Klaus Jensen --- hw/block/nvme-ns.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index fc42ae184e01..3f0e4e461420 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -320,10 +320,6 @@ int nvme_ns_setup(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) nvme_ns_init_zoned(ns, 0); } - if (nvme_register_namespace(n, ns, errp)) { - return -1; - } - return 0; } @@ -361,6 +357,13 @@ static void nvme_ns_realize(DeviceState *dev, Error **errp) "could not setup namespace: "); return; } + + if (nvme_register_namespace(n, ns, errp)) { + error_propagate_prepend(errp, local_err, + "could not register namespace: "); + return; + } + } static Property nvme_ns_props[] = { From patchwork Sun Jan 17 14:53:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FFC9C433DB for ; Sun, 17 Jan 2021 14:57:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E34E921D81 for ; Sun, 17 Jan 2021 14:57:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E34E921D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19UX-0007Zk-2L for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 09:57:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RQ-0004VM-3o; Sun, 17 Jan 2021 09:54:09 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:38463) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RM-00044c-Fm; Sun, 17 Jan 2021 09:54:07 -0500 Received: by mail-pl1-x635.google.com with SMTP id d4so7211969plh.5; Sun, 17 Jan 2021 06:54:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aclMKN2i9RpYbDHlyEF8ouvTN8y3ptaLtduB2besBSc=; b=fTS+m3dQnk71GBJVmcuWE4yMoOeWlaRfgSjNpDB4eQHJ5bmIFrSYI8ANatlGJEwCum TBaMBNYd6IDamd2QHANJp4ruWCiynV/cj63hI+xQvOocxafPibhmhXF9lbqBMu61AU0N ZAnYhxnT8RbIQgezfbBKX1Oj06LFEOilj3Hyhhy3q1R/p83vr/vZdDZk7rgqZaapvZR4 UIjneai5/52L40kHMGUU7PbEbCf9Fk8kCC9bgim/y79E5i1yZDs8tURF/ZsTBbrXGiyH 8/LMtnYbyckAXh9mUVxqi6GD7SMU+v32f9cKbyX8g2OZdvFIT/ReN/mDFPk3EdL2FqvY IESg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aclMKN2i9RpYbDHlyEF8ouvTN8y3ptaLtduB2besBSc=; b=c9cgmrroYdYR2z0d4vb7S1zQ7609E/O43tnFcn6283kYQFhoGrcTQKyq3xi+53cTZq aNIMaIySV5lRpp/gBaFFVQv91l3fDIAE0tGaieg+eDUt10u0FwUVi9tSiOd+b8ynhYLo Wf0eJz7BA+MOH8L5XQOG26aH6oQOEk2dZ7YLJLUmARM1ifp4A7odPWKe7gUC5UFzQnj/ xh3nWZM20ylilkKRLPVBpWBewdd4oX31nwoLojds1qZ+G28Tz9mlhKAg/eLYMF3sSvCs t6shM/7HiMYdFctHzUUAOQAeOplPzsT8mjcaxNCsfW8LI5b8ZYzM+JIC7IOugay0a4sz C1Zg== X-Gm-Message-State: AOAM533MiAkUE0z6mI9I1TO/Xww/GmnQDLv5k5/eKVWGBBNk3m0FXrzI nwtV6qnqW0YTiZt/BwvX/6aYG26DmxVGjw== X-Google-Smtp-Source: ABdhPJyJDpUKOcpGfxC7uqhOLMCBA3HgZ/mwSBKGNVGf9ELtAPQXHvZkK2k9WkxbuvWHxCHlKpk+lA== X-Received: by 2002:a17:90a:7e90:: with SMTP id j16mr20992578pjl.163.1610895242016; Sun, 17 Jan 2021 06:54:02 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:54:01 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 05/11] hw/block/nvme: remove unused argument in nvme_ns_setup Date: Sun, 17 Jan 2021 23:53:35 +0900 Message-Id: <20210117145341.23310-6-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pl1-x635.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_ns_setup() finally does not have nothing to do with NvmeCtrl instance. Signed-off-by: Minwoo Im Reviewed-by: Klaus Jensen --- hw/block/nvme-ns.c | 4 ++-- hw/block/nvme-ns.h | 2 +- hw/block/nvme.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index 3f0e4e461420..c8b75fa02138 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -300,7 +300,7 @@ static int nvme_ns_check_constraints(NvmeNamespace *ns, Error **errp) return 0; } -int nvme_ns_setup(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) +int nvme_ns_setup(NvmeNamespace *ns, Error **errp) { if (nvme_ns_check_constraints(ns, errp)) { return -1; @@ -352,7 +352,7 @@ static void nvme_ns_realize(DeviceState *dev, Error **errp) NvmeCtrl *n = NVME(s->parent); Error *local_err = NULL; - if (nvme_ns_setup(n, ns, &local_err)) { + if (nvme_ns_setup(ns, &local_err)) { error_propagate_prepend(errp, local_err, "could not setup namespace: "); return; diff --git a/hw/block/nvme-ns.h b/hw/block/nvme-ns.h index f8f3c28c360b..d87c025b0ab6 100644 --- a/hw/block/nvme-ns.h +++ b/hw/block/nvme-ns.h @@ -174,7 +174,7 @@ static inline void nvme_aor_dec_active(NvmeNamespace *ns) assert(ns->nr_active_zones >= 0); } -int nvme_ns_setup(NvmeCtrl *n, NvmeNamespace *ns, Error **errp); +int nvme_ns_setup(NvmeNamespace *ns, Error **errp); void nvme_ns_drain(NvmeNamespace *ns); void nvme_ns_shutdown(NvmeNamespace *ns); void nvme_ns_cleanup(NvmeNamespace *ns); diff --git a/hw/block/nvme.c b/hw/block/nvme.c index b2a9c48a9d81..9e890ce84f5e 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -4313,7 +4313,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) ns = &n->namespace; ns->params.nsid = 1; - if (nvme_ns_setup(n, ns, errp)) { + if (nvme_ns_setup(ns, errp)) { return; } } From patchwork Sun Jan 17 14:53:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF8DDC433DB for ; Sun, 17 Jan 2021 14:59:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 855B8206EC for ; Sun, 17 Jan 2021 14:59:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 855B8206EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19Ww-0002e1-Ho for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 09:59:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RT-0004WS-UL; Sun, 17 Jan 2021 09:54:13 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:45654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RO-00045e-CU; Sun, 17 Jan 2021 09:54:11 -0500 Received: by mail-pg1-x530.google.com with SMTP id v19so9288582pgj.12; Sun, 17 Jan 2021 06:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=irCLzdheyHgAvUXH0lTbNeucJOlBrP6V6dPKx7Uh3NU=; b=OTjwrwjdDyOYgE2McBQPJRnEqascMifoPWbbGa56DNx/QgZicj/iQZ0G8acquoP+Vf /oeD11RPq8w7hHAPLdgi7MBnuEVOT661fThNcpIkOiPgHfnjC53jczcN3km7fyAYuTL3 VLysQoc1cYJHQNvlBMAXFClyQ0p3VsJ3vDq30hi0PtMKpIEONkH3agCnYSwvaAGfRJKK jxKJEvDHchrHUjQuPK8x1pCx9NIE+Q0QnVLDxnXLlr7ujIxZqm7EoTYU9Dy/WKhftx+2 PQ+2NeTU5R9JttCL3aJg32xFHcBMOwkwrZOR0xDCNDjZuRCbchaKq6nrs0O8oAiSXfmk u5Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=irCLzdheyHgAvUXH0lTbNeucJOlBrP6V6dPKx7Uh3NU=; b=oi8T7oAsA0bL0lETJLzX2tbl7Mu10i96NRu0G65E3JZt5pTWWWAJ1DIVO+mcJYCDqE pMZalRhvZ0SDz7TDZalkJ38APCtC3G1Cr0hmqbd0KYVewwMv4amLsQFWN8Vew3IxLE4X WsoAmWugMgJ68o8XS3XQu6SYCNy5Bx5cPJCAVgdY6hCFONoKGm2uSsZqz/axOxgJBxID FeTVF3Tf1LpLKE4Cb8u/MB9V93flmKy8BhJmKHXhPHyVw36V5HeWBFRhGjiPcdTMhCJv je5xD4u+6hhCGjftImfRogk79BpAyX0l+9u4a3inp4rJZYnVfoYXkk/+J9ZGe7dwBUmq tYTQ== X-Gm-Message-State: AOAM531aQnaV7Nyi1b0nFpYl0i5BXO+TVf/pnzClAMdwkkMNrTik3lXb rYIUZWAKTbF9StrwSNfvjt2WnAtQSWWu+g== X-Google-Smtp-Source: ABdhPJxZugfc2E3cj36iMn3tNQkh1AbZ1xyzofQeEtK8JE4u5O5bCXG2j4gjABuAxJ96NuyNGHEIzQ== X-Received: by 2002:a63:5a08:: with SMTP id o8mr22094843pgb.118.1610895244434; Sun, 17 Jan 2021 06:54:04 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:54:04 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 06/11] hw/block/nvme: introduce nvme-subsys device Date: Sun, 17 Jan 2021 23:53:36 +0900 Message-Id: <20210117145341.23310-7-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pg1-x530.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To support multi-path in QEMU NVMe device model, We need to have NVMe subsystem hierarchy to map controllers and namespaces to a NVMe subsystem. This patch introduced a simple nvme-subsys device model. The subsystem will be prepared with subsystem NQN with provided in nvme-subsys device: ex) -device nvme-subsys,id=subsys0: nqn.2019-08.org.qemu:subsys0 Signed-off-by: Minwoo Im --- hw/block/meson.build | 2 +- hw/block/nvme-subsys.c | 63 ++++++++++++++++++++++++++++++++++++++++++ hw/block/nvme-subsys.h | 25 +++++++++++++++++ hw/block/nvme.c | 3 ++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 hw/block/nvme-subsys.c create mode 100644 hw/block/nvme-subsys.h diff --git a/hw/block/meson.build b/hw/block/meson.build index 602ca6c8541d..83ea2d37978d 100644 --- a/hw/block/meson.build +++ b/hw/block/meson.build @@ -13,7 +13,7 @@ softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80.c')) softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c')) softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c')) softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('tc58128.c')) -softmmu_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('nvme.c', 'nvme-ns.c')) +softmmu_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('nvme.c', 'nvme-ns.c', 'nvme-subsys.c')) specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c')) specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c')) diff --git a/hw/block/nvme-subsys.c b/hw/block/nvme-subsys.c new file mode 100644 index 000000000000..f1dc71d588d9 --- /dev/null +++ b/hw/block/nvme-subsys.c @@ -0,0 +1,63 @@ +/* + * QEMU NVM Express Subsystem: nvme-subsys + * + * Copyright (c) 2021 Minwoo Im + * + * This code is licensed under the GNU GPL v2. Refer COPYING. + */ + +#include "qemu/units.h" +#include "qemu/osdep.h" +#include "qemu/uuid.h" +#include "qemu/iov.h" +#include "qemu/cutils.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-core.h" +#include "hw/block/block.h" +#include "block/aio.h" +#include "block/accounting.h" +#include "sysemu/sysemu.h" +#include "hw/pci/pci.h" +#include "nvme.h" +#include "nvme-subsys.h" + +static void nvme_subsys_setup(NvmeSubsystem *subsys) +{ + char *subnqn; + + subnqn = g_strdup_printf("nqn.2019-08.org.qemu:%s", subsys->parent_obj.id); + strpadcpy((char *)subsys->subnqn, sizeof(subsys->subnqn), subnqn, '\0'); + g_free(subnqn); +} + +static void nvme_subsys_realize(DeviceState *dev, Error **errp) +{ + NvmeSubsystem *subsys = NVME_SUBSYS(dev); + + nvme_subsys_setup(subsys); +} + +static void nvme_subsys_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); + + dc->realize = nvme_subsys_realize; + dc->desc = "Virtual NVMe subsystem"; +} + +static const TypeInfo nvme_subsys_info = { + .name = TYPE_NVME_SUBSYS, + .parent = TYPE_DEVICE, + .class_init = nvme_subsys_class_init, + .instance_size = sizeof(NvmeSubsystem), +}; + +static void nvme_subsys_register_types(void) +{ + type_register_static(&nvme_subsys_info); +} + +type_init(nvme_subsys_register_types) diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h new file mode 100644 index 000000000000..40f06a4c7db0 --- /dev/null +++ b/hw/block/nvme-subsys.h @@ -0,0 +1,25 @@ +/* + * QEMU NVM Express Subsystem: nvme-subsys + * + * Copyright (c) 2021 Minwoo Im + * + * This code is licensed under the GNU GPL v2. Refer COPYING. + */ + +#ifndef NVME_SUBSYS_H +#define NVME_SUBSYS_H + +#define TYPE_NVME_SUBSYS "nvme-subsys" +#define NVME_SUBSYS(obj) \ + OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS) + +#define NVME_SUBSYS_MAX_CTRLS 32 + +typedef struct NvmeCtrl NvmeCtrl; +typedef struct NvmeNamespace NvmeNamespace; +typedef struct NvmeSubsystem { + DeviceState parent_obj; + uint8_t subnqn[256]; +} NvmeSubsystem; + +#endif /* NVME_SUBSYS_H */ diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 9e890ce84f5e..dde83aafc33d 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -25,6 +25,7 @@ * mdts=,zoned.append_size_limit= \ * -device nvme-ns,drive=,bus=,nsid=,\ * zoned= + * -device nvme-subsys,id= * * Note cmb_size_mb denotes size of CMB in MB. CMB is assumed to be at * offset 0 in BAR2 and supports only WDS, RDS and SQS for now. @@ -37,6 +38,8 @@ * -object memory-backend-file,id=,share=on,mem-path=, \ * size= .... -device nvme,...,pmrdev= * + * To place controller(s) and namespace(s) to a subsystem, then provide + * nvme-subsys device as above. * * nvme device parameters * ~~~~~~~~~~~~~~~~~~~~~~ From patchwork Sun Jan 17 14:53:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E7B7C433DB for ; Sun, 17 Jan 2021 15:03:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6B56821D81 for ; Sun, 17 Jan 2021 15:03:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B56821D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19aU-0004xX-57 for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 10:03:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RX-0004Ys-Vy; Sun, 17 Jan 2021 09:54:16 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:34091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RR-00047Y-NN; Sun, 17 Jan 2021 09:54:15 -0500 Received: by mail-pf1-x429.google.com with SMTP id m6so8664133pfk.1; Sun, 17 Jan 2021 06:54:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zlpwnwAv5g9ETjdNtjndtNHZTjD++61r7danBZbY8Uw=; b=iL/hLv/maP5dF406Ex+jVh2bIbIgPS/KUMO5jA5Or9lEXtO7owV2cjgTbCMy78I+NQ WSUKW6n5vUhFcfwtL1hJx7rAsK1kHdi3oyhsqzODvafcOTJi4eqVLkdJfaaVKAh48nwc 4W9WX4cxauo1wxGWyJTi+Z9e/Z9z0QUqdsw0Ww4A8BdF+UkOAMGGePihnMlHb5xMJYnv a2bYGGCWSSNFDoMdRgyrXtGCm/f5NbpNRDEY9UII5wVInzXeTXYUvzDxWA4TKMN9gqRd gM81DRWsP5NEjvgtlizKFeBFXfn9lGOsND+49YAXyTiH9SjV502BDzRh8xt/2nrxUjDE QiDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zlpwnwAv5g9ETjdNtjndtNHZTjD++61r7danBZbY8Uw=; b=ONOWbl9DAHSPGdQSut/HysyGGax7P4dyiTOC8uddhd7vLVI8yprqlsHIqa2eVUb1C0 7og3++br2FnbKETU5CSb2n3Nn+SN2kUQ4hMSHn/RjrqG90JqUOqxnVUkoePboiz8tZxb 1M0lvmnEHC4xW+Bj+UtlRzC24Rfx0WumMlkg5e0vEJRvLb/tArn31M0dbL1iLGtmDpsP L0I9ik9d7NZUAiifLNdKcO2qdPuydLAm8mzjPfSQcVbAI/tLPPlr+MHD25MNsZc5HQBe YXVCjoPpCzic7oK2Y5PqPnot2Hi5UGMmkfEtWd26MnreMyV70FQVVB97txrRmBeaqjHQ 9uEg== X-Gm-Message-State: AOAM532go4hgibLuphZJLd2Ks+4nMHbNrHfYMvkYS52Akps44CmbRm1I ZVUrQHsMXglu00FR/2cRbFQLTF4yQZzBkQ== X-Google-Smtp-Source: ABdhPJzi8YpjV12cGnRPEZksxwTJGLoK2iuJeiSZpRIkCI9TzstJbEt2szMoCCmmc0oNcO9C7zOgXQ== X-Received: by 2002:a63:a556:: with SMTP id r22mr22185686pgu.296.1610895246838; Sun, 17 Jan 2021 06:54:06 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:54:06 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 07/11] hw/block/nvme: support to map controller to a subsystem Date: Sun, 17 Jan 2021 23:53:37 +0900 Message-Id: <20210117145341.23310-8-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pf1-x429.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme controller(nvme) can be mapped to a NVMe subsystem(nvme-subsys). This patch maps a controller to a subsystem by adding a parameter 'subsys' to the nvme device. To map a controller to a subsystem, we need to put nvme-subsys first and then maps the subsystem to the controller: -device nvme-subsys,id=subsys0 -device nvme,serial=foo,id=nvme0,subsys=subsys0 If 'subsys' property is not given to the nvme controller, then subsystem NQN will be created with serial (e.g., 'foo' in above example), Otherwise, it will be based on subsys id (e.g., 'subsys0' in above example). Signed-off-by: Minwoo Im --- hw/block/nvme.c | 30 ++++++++++++++++++++++++++---- hw/block/nvme.h | 3 +++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index dde83aafc33d..af5b2162e2b5 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -23,6 +23,7 @@ * max_ioqpairs=, \ * aerl=, aer_max_queued=, \ * mdts=,zoned.append_size_limit= \ + * ,subsys= \ * -device nvme-ns,drive=,bus=,nsid=,\ * zoned= * -device nvme-subsys,id= @@ -43,6 +44,13 @@ * * nvme device parameters * ~~~~~~~~~~~~~~~~~~~~~~ + * - `subsys` + * NVM Subsystem device. If given, a subsystem NQN will be initialized with + * given. Otherwise, will be taken for subsystem NQN. + * Also, it will enable multi controller capability represented in Identify + * Controller data structure in CMIC (Controller Multi-path I/O and Namesapce + * Sharing Capabilities), if given. + * * - `aerl` * The Asynchronous Event Request Limit (AERL). Indicates the maximum number * of concurrently outstanding Asynchronous Event Request commands support @@ -4219,11 +4227,25 @@ static int nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) return 0; } +static void nvme_init_subnqn(NvmeCtrl *n) +{ + NvmeSubsystem *subsys = n->subsys; + NvmeIdCtrl *id = &n->id_ctrl; + char *subnqn; + + if (!subsys) { + subnqn = g_strdup_printf("nqn.2019-08.org.qemu:%s", n->params.serial); + strpadcpy((char *)id->subnqn, sizeof(id->subnqn), subnqn, '\0'); + g_free(subnqn); + } else { + pstrcpy((char *)id->subnqn, sizeof(id->subnqn), (char*)subsys->subnqn); + } +} + static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) { NvmeIdCtrl *id = &n->id_ctrl; uint8_t *pci_conf = pci_dev->config; - char *subnqn; id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID)); id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID)); @@ -4269,9 +4291,7 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) id->sgls = cpu_to_le32(NVME_CTRL_SGLS_SUPPORT_NO_ALIGN | NVME_CTRL_SGLS_BITBUCKET); - subnqn = g_strdup_printf("nqn.2019-08.org.qemu:%s", n->params.serial); - strpadcpy((char *)id->subnqn, sizeof(id->subnqn), subnqn, '\0'); - g_free(subnqn); + nvme_init_subnqn(n); id->psd[0].mp = cpu_to_le16(0x9c4); id->psd[0].enlat = cpu_to_le32(0x10); @@ -4355,6 +4375,8 @@ static void nvme_exit(PCIDevice *pci_dev) static Property nvme_props[] = { DEFINE_BLOCK_PROPERTIES(NvmeCtrl, namespace.blkconf), + DEFINE_PROP_LINK("subsys", NvmeCtrl, subsys, TYPE_NVME_SUBSYS, + NvmeSubsystem *), DEFINE_PROP_LINK("pmrdev", NvmeCtrl, pmrdev, TYPE_MEMORY_BACKEND, HostMemoryBackend *), DEFINE_PROP_STRING("serial", NvmeCtrl, params.serial), diff --git a/hw/block/nvme.h b/hw/block/nvme.h index 5ba83ee77841..2061e53e2cee 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -2,6 +2,7 @@ #define HW_NVME_H #include "block/nvme.h" +#include "nvme-subsys.h" #include "nvme-ns.h" #define NVME_MAX_NAMESPACES 256 @@ -154,6 +155,8 @@ typedef struct NvmeCtrl { uint8_t zasl; + NvmeSubsystem *subsys; + NvmeNamespace namespace; NvmeNamespace *namespaces[NVME_MAX_NAMESPACES]; NvmeSQueue **sq; From patchwork Sun Jan 17 14:53:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D3E4C433E0 for ; Sun, 17 Jan 2021 15:04:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EE3BF21D81 for ; Sun, 17 Jan 2021 15:04:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE3BF21D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19b3-0005ZU-VR for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 10:04:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RY-0004aY-Gj; Sun, 17 Jan 2021 09:54:16 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:37003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RT-00047n-AH; Sun, 17 Jan 2021 09:54:16 -0500 Received: by mail-pg1-x535.google.com with SMTP id z21so9325050pgj.4; Sun, 17 Jan 2021 06:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z7ODT9lj0kxOdBE+83aVpPvzwDiEUWaBf6IRt28xomQ=; b=VKDfQqQk1d8+CJp/HAfu/ofh74fG8iP/qLxI31yIr0jo3ydd/YDQKQ1I7MuPQ7LZIq WsZqUpzvk+1zX+cT3XjVkTzN5lIGlk3hREkzpOOKKpKadPIJWK/Iq6oScSdHwd1Q/qsC sGh6OQaNv4208QRhKov3wlxXkuwMfI2gJzcJzZuE5GkyMYIxABtcwWk3vfIWTuo/M9ei 4XZfzZVCQgQ4FtQZ+eOkBHc8kFQ/U6RqhT1D6vloLrQ3oNpH0YSvohVaozlrDLvT8L5g mtQNTSnkce01pQjuvPyJSiN8mYB+IkFoTectNx1jdztDlhthFTvvFS6MKwgeChvm/YSL 8Ouw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z7ODT9lj0kxOdBE+83aVpPvzwDiEUWaBf6IRt28xomQ=; b=fX1+L/K8l9mmcUST26i/Aax7GJZuz1Kqy9Q3WP9CkMhdnBnm2rQCt6gdNrKhgyUmEc n8mrL5mZ+yVw2oj4m9nhQa7rojln/BfIJEfhOmh5ViGIw400NaQ6pAFky/u1/aXFsItS BkX7t5GFWS02dOkjFPJjT4LWpAICpUmf8FZJtR3T1GC9LZ5elWYqdGYNwpNn1K959SxL nURQrKLtCGcHqIHwcBL8TfvNPXFS/aWgkozU6t77dq1KPVA0Y+zpBnjrwHy78FpPhT6Y 4ubKYneYwhfAMFisEqWBO/sQFy+t7n6Tp16W+nk7LTxi59z+c8YUr8W/UjXsl4iWBxmr HB4Q== X-Gm-Message-State: AOAM533QPq12y6l7G27MYtymVPqBHWHeC550nUOMEi2svYOKUgIh9Ri9 SC9uFEJqo6dngxdjthQ97mxAzHTy1eGpFw== X-Google-Smtp-Source: ABdhPJwsiCvEgt1NIF+OI+pKQyr6ZN1Vf2hBJn3uCIeLze+7ZrcHuEpSTnmzfI+p5T6YVnHrQBFSIQ== X-Received: by 2002:a63:4559:: with SMTP id u25mr21740238pgk.306.1610895249199; Sun, 17 Jan 2021 06:54:09 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:54:08 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 08/11] hw/block/nvme: add CMIC enum value for Identify Controller Date: Sun, 17 Jan 2021 23:53:38 +0900 Message-Id: <20210117145341.23310-9-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pg1-x535.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Added Controller Multi-path I/O and Namespace Sharing Capabilities (CMIC) field to support multi-controller in the following patches. This field is in Identify Controller data structure in [76]. Signed-off-by: Minwoo Im --- include/block/nvme.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/block/nvme.h b/include/block/nvme.h index 9494246f1f59..e83ec1e124c6 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -941,6 +941,10 @@ enum NvmeIdCtrlLpa { NVME_LPA_EXTENDED = 1 << 2, }; +enum NvmeIdCtrlCmic { + NVME_CMIC_MULTI_CTRL = 1 << 1, +}; + #define NVME_CTRL_SQES_MIN(sqes) ((sqes) & 0xf) #define NVME_CTRL_SQES_MAX(sqes) (((sqes) >> 4) & 0xf) #define NVME_CTRL_CQES_MIN(cqes) ((cqes) & 0xf) From patchwork Sun Jan 17 14:53:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B13A8C433E0 for ; Sun, 17 Jan 2021 15:05:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3855121D81 for ; Sun, 17 Jan 2021 15:05:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3855121D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19co-0007h3-6U for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 10:05:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RY-0004aD-Cy; Sun, 17 Jan 2021 09:54:16 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:38835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RW-000498-4K; Sun, 17 Jan 2021 09:54:16 -0500 Received: by mail-pf1-x429.google.com with SMTP id y205so2830398pfc.5; Sun, 17 Jan 2021 06:54:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1Cm/Y/wHV6XDVnBidszQS9hCYZA9+sK+hHU3IgmkQuk=; b=V1fFgzqDUaF7t5+I5CQJTxyFgCFLPny7M27dFIovuGnI/n1fOFk+9hs9zU6IbgBvCY pYNNOZQ1zc2beJUyOnhrQgUYJcmupb7hTy34jdPqtr9o8M69FRR7moJNE3xddxM+uadW c8EicjGbqm0h9HBXjXK83Qhz45h1XTyY89EM+XUrn6poh9BXhYaZr5Zld0wx6k8cofua h22M+PELHre67bEGppVq81aCCUbZlLv7fX+avda7V5X2VfthhbUjKt90+hvaie+31X3K 1TVQmK+2FDGbtKsRNwNlCCDbdT6rf1MuIdeauZ+N8WoSVU1nvzUlAbm1ar6uGf1OTS6M EAbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1Cm/Y/wHV6XDVnBidszQS9hCYZA9+sK+hHU3IgmkQuk=; b=ewOABZ8TUIyxL7CcpylPW9Ikgxt9rMdtGaGOGaSST38ToSOmwGqw4YwRzZTcar18Tk iif5odkYM7wNRvUWEyLYKvQwhEPD3d6bGPNsCcIKemcObMh74hcxMnkRca7hQ7Fy77+C KXMYr/lMiGyAdNYBWH6/vsdZY0qop84T/z1vM8EcWf8kp+oLZRIrgzhZhoEtwodHBuKw HbYznfJewrYVMXSymyCYsUQLj8wsFJiWtDsZcScwVuNTA6P4b2J+0WQO2X/j8v5/ej7O 83wiKlk8jqgsPqgey/djerL9H4nIYQ6JQjVbtz4CKcXoz7IkW7zNwqLcOhziL6tjiUgG JZvQ== X-Gm-Message-State: AOAM533Rq92QVPh+5Ki6r7uxZIfCGseovWpdz2sqxLDew5i38GsF/xxg 7grIyFHO7dnlVieiEvTvbnREWZp/qLpt3A== X-Google-Smtp-Source: ABdhPJyZXzKk/7U/JjkbYl1uKZ3GWZYyX/vyOcg8B18Z5Rw4ZOncaHS1E7Azdpl1bB8A+qZPr5Zpaw== X-Received: by 2002:a62:5383:0:b029:1b6:20bf:e5a1 with SMTP id h125-20020a6253830000b02901b620bfe5a1mr5695472pfb.58.1610895251614; Sun, 17 Jan 2021 06:54:11 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:54:11 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 09/11] hw/block/nvme: support for multi-controller in subsystem Date: Sun, 17 Jan 2021 23:53:39 +0900 Message-Id: <20210117145341.23310-10-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pf1-x429.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We have nvme-subsys and nvme devices mapped together. To support multi-controller scheme to this setup, controller identifier(id) has to be managed. Earlier, cntlid(controller id) used to be always 0 because we didn't have any subsystem scheme that controller id matters. This patch introduced 'cntlid' attribute to the nvme controller instance(NvmeCtrl) and make it allocated by the nvme-subsys device mapped to the controller. If nvme-subsys is not given to the controller, then it will always be 0 as it was. Added 'ctrls' array in the nvme-subsys instance to manage attached controllers to the subsystem with a limit(32). This patch didn't take list for the controllers to make it seamless with nvme-ns device. Signed-off-by: Minwoo Im --- hw/block/nvme-subsys.c | 21 +++++++++++++++++++++ hw/block/nvme-subsys.h | 4 ++++ hw/block/nvme.c | 32 ++++++++++++++++++++++++++++++-- hw/block/nvme.h | 1 + 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme-subsys.c b/hw/block/nvme-subsys.c index f1dc71d588d9..a01003136b12 100644 --- a/hw/block/nvme-subsys.c +++ b/hw/block/nvme-subsys.c @@ -22,6 +22,27 @@ #include "nvme.h" #include "nvme-subsys.h" +int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) +{ + NvmeSubsystem *subsys = n->subsys; + int cntlid; + + for (cntlid = 0; cntlid < ARRAY_SIZE(subsys->ctrls); cntlid++) { + if (!subsys->ctrls[cntlid]) { + break; + } + } + + if (cntlid == ARRAY_SIZE(subsys->ctrls)) { + error_setg(errp, "no more free controller id"); + return -1; + } + + subsys->ctrls[cntlid] = n; + + return cntlid; +} + static void nvme_subsys_setup(NvmeSubsystem *subsys) { char *subnqn; diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h index 40f06a4c7db0..4eba50d96a1d 100644 --- a/hw/block/nvme-subsys.h +++ b/hw/block/nvme-subsys.h @@ -20,6 +20,10 @@ typedef struct NvmeNamespace NvmeNamespace; typedef struct NvmeSubsystem { DeviceState parent_obj; uint8_t subnqn[256]; + + NvmeCtrl *ctrls[NVME_SUBSYS_MAX_CTRLS]; } NvmeSubsystem; +int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp); + #endif /* NVME_SUBSYS_H */ diff --git a/hw/block/nvme.c b/hw/block/nvme.c index af5b2162e2b5..2aeb164dd508 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -4242,7 +4242,7 @@ static void nvme_init_subnqn(NvmeCtrl *n) } } -static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) +static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t cntlid) { NvmeIdCtrl *id = &n->id_ctrl; uint8_t *pci_conf = pci_dev->config; @@ -4252,6 +4252,9 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) strpadcpy((char *)id->mn, sizeof(id->mn), "QEMU NVMe Ctrl", ' '); strpadcpy((char *)id->fr, sizeof(id->fr), "1.0", ' '); strpadcpy((char *)id->sn, sizeof(id->sn), n->params.serial, ' '); + + id->cntlid = cntlid; + id->rab = 6; id->ieee[0] = 0x00; id->ieee[1] = 0x02; @@ -4297,6 +4300,10 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) id->psd[0].enlat = cpu_to_le32(0x10); id->psd[0].exlat = cpu_to_le32(0x4); + if (n->subsys) { + id->cmic |= NVME_CMIC_MULTI_CTRL; + } + NVME_CAP_SET_MQES(n->bar.cap, 0x7ff); NVME_CAP_SET_CQR(n->bar.cap, 1); NVME_CAP_SET_TO(n->bar.cap, 0xf); @@ -4309,11 +4316,28 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) n->bar.intmc = n->bar.intms = 0; } +static int nvme_init_subsys(NvmeCtrl *n, Error **errp) +{ + int cntlid; + + if (!n->subsys) { + return 0; + } + + cntlid = nvme_subsys_register_ctrl(n, errp); + if (cntlid < 0) { + return -1; + } + + return cntlid; +} + static void nvme_realize(PCIDevice *pci_dev, Error **errp) { NvmeCtrl *n = NVME(pci_dev); NvmeNamespace *ns; Error *local_err = NULL; + int cntlid; nvme_check_constraints(n, &local_err); if (local_err) { @@ -4329,7 +4353,11 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) return; } - nvme_init_ctrl(n, pci_dev); + cntlid = nvme_init_subsys(n, errp); + if (cntlid < 0) { + return; + } + nvme_init_ctrl(n, pci_dev, cntlid); /* setup a namespace if the controller drive property was given */ if (n->namespace.blkconf.blk) { diff --git a/hw/block/nvme.h b/hw/block/nvme.h index 2061e53e2cee..329902a9fc04 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -129,6 +129,7 @@ typedef struct NvmeCtrl { NvmeBus bus; BlockConf conf; + uint16_t cntlid; bool qs_created; uint32_t page_size; uint16_t page_bits; From patchwork Sun Jan 17 14:53:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BBFCC433E0 for ; Sun, 17 Jan 2021 15:07:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CD96B21D81 for ; Sun, 17 Jan 2021 15:07:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD96B21D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19eK-0000TB-TH for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 10:07:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19RZ-0004dq-JE; Sun, 17 Jan 2021 09:54:17 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:35939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19RY-0004A9-1N; Sun, 17 Jan 2021 09:54:17 -0500 Received: by mail-pg1-x52c.google.com with SMTP id c132so9331093pga.3; Sun, 17 Jan 2021 06:54:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZuENl38Uj1XXvlGTRP6SwNgsA5uXW6rACpRQwgn9cKc=; b=LPHq9b3ntPwr2s3QXirNh98Yn+z9E0brZR+0LHdTZUIKeLDJiS8zZ7q/xYATev+TaZ Ej0rF7DGYt1YTYmHppg0enXgc7ymvOUz/MKo7JF+BhK8SEweEYW3R5PZotIJVjLXU1Iv mP+9s3qc5BmLBLZUM2pg6USpf9L7FVqRy+Uce5MMX1SuVrq7N7zj1DZXAGO5B2m1JWzx 7UX3vozSuWpi63J6Ot7G+m14HAPNH+D4VqceK+tbpw8N2Lip6OFJyUMbrsSX1q0Gxh3d IKzLhbx1hlFikydBizyNGsl57azdtunDHZAz+6yUTDSNLnB0npIEKX7nqE16qhmoj6pA 39Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZuENl38Uj1XXvlGTRP6SwNgsA5uXW6rACpRQwgn9cKc=; b=BlVWWEHWsBh897C82e9QRAXdo9lFifxPS8O+nryCEygc0/Vw+YwcXCPZGjQLgvBBv6 YdBu3hpVxDPMGRW1c3zFyDVPF47B0pCJytkw5Zmv1xwl3DjBsMQ/xdAG7IB7PX4jpP9o Rhfiz9KNYlIfUb1Zy53RS2q68IuLnqNBsMLbZmDPNBzSOQlP439tIfmBXn8I/buuB/DA +I4ynKtVsneq+ZiWQ4RqdkpZEHifMDMqXWtvVytDI1f9eHiz0be+Lcs1/DyJ4TY2Qega SATFYyQFBeXv/+kqn8jivAPzy9cK3yW+ANicyTd3r9uRi5JO0uGB7U4hGRhqQTJ0tdDz DdSA== X-Gm-Message-State: AOAM533GgTTcT7dMKjcSQtoZGyxu7FjlzN9EH8Q0RSTD94BAoVBxB18G w5Tioki0mpD9ot9BEsJsMPWzj6OIjZjJbg== X-Google-Smtp-Source: ABdhPJyqrWp7jxMi9P0v8scUxfQKszMCLgdr/fIo6jRM4HbV9qKT40k8f56SHZ5aq+YKmlh/PAzZ2A== X-Received: by 2002:a63:4346:: with SMTP id q67mr21852626pga.223.1610895253999; Sun, 17 Jan 2021 06:54:13 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:54:13 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 10/11] hw/block/nvme: add NMIC enum value for Identify Namespace Date: Sun, 17 Jan 2021 23:53:40 +0900 Message-Id: <20210117145341.23310-11-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pg1-x52c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Added Namespace Multi-path I/O and Namespace Sharing Capabilities (NMIC) field to support shared namespace from controller(s). This field is in Identify Namespace data structure in [30]. Signed-off-by: Minwoo Im --- include/block/nvme.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/block/nvme.h b/include/block/nvme.h index e83ec1e124c6..dd7b5ba9ef4c 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -1110,6 +1110,10 @@ enum NvmeNsIdentifierType { NVME_NIDT_CSI = 0x04, }; +enum NvmeNsNmic { + NVME_NMIC_NS_SHARED = 1 << 0, +}; + enum NvmeCsi { NVME_CSI_NVM = 0x00, NVME_CSI_ZONED = 0x02, From patchwork Sun Jan 17 14:53:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12025459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 207A5C433DB for ; Sun, 17 Jan 2021 15:08:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AC58D21D81 for ; Sun, 17 Jan 2021 15:08:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC58D21D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l19fX-0001Ot-Ii for qemu-devel@archiver.kernel.org; Sun, 17 Jan 2021 10:08:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l19Rc-0004lO-79; Sun, 17 Jan 2021 09:54:20 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:36335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l19Ra-0004B8-7J; Sun, 17 Jan 2021 09:54:19 -0500 Received: by mail-pj1-x102f.google.com with SMTP id l23so8061015pjg.1; Sun, 17 Jan 2021 06:54:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1adku/pHb++alGro7InJn/589lc64ALQiCpCtiUx3Y4=; b=ORjp7DmZMnrS+gxTClBVyxqmA00WD9TDP/eUEpqvvAVSqgtR8h4nCNKZZ8isT4QklD 03aPMq08tkrmIiRqdZv71oV5Y9aHUqM9XhRal5MgjxnX4URAPkpy7KeUHfCErjY9hUgI 9JaEqfvLvwfXWGJe/0MAwJRlThe7/tzhJ9zMTQ0TPyYtq+e/nxYd5YD05Es9uZazI2bi upObj4vClmuSQnXmk2vcpj5nAdXSxpGutTui4vT+tgLlAkUQNFdw2E0iBPdUyhF1tsko hxsGs/+zLwLu0p4dVi5v/b0zxKfYYkVCsPdqfufvhd3oJ4q3M61wES2etZc4Knwnx5tA Ol0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1adku/pHb++alGro7InJn/589lc64ALQiCpCtiUx3Y4=; b=icBbpimNwDQDmcbMdtPlM4X4I+fLwu10u48CThGTmHiA03SpYiZJS8tJnKBHOTxtLN 4eSYS68rjUssVFO9u4jnSr2RLqOS/VWrtwP912eodQRmPquxElhAUOmv45wTu3DcTCOi p5T3weqjzcacv/2DQqjZv20rupRlKkt7ZcpeTMDWmXQTg/MLrDR4iM+oaorBit00DFVf QqJr9dkWpaKl4PXr/g4zgIP4FVSo+UM/fUH37ZT11lDwFskqP2movWT/EqvMc74wneNA ZlAEdwD4Fmxsni8ev8Nol9Exj25jhA+pErMSd56nVbFSOu7dubu1sXb9xtx9mKDu99Nw XJkg== X-Gm-Message-State: AOAM533LSaYzo8wS977BmmCCe6Nsdj00r3/QkErmtTrnMQUSSEk4TyFf JUHvWIArH674nRPyIm9DoKlGz3Kmb/csAg== X-Google-Smtp-Source: ABdhPJyIXaeySUwiF05F5KbqrwDluIManZLoT/oAjEAVBXL59A6JNodOMXPHoHsaFoIsFi67LdWLbg== X-Received: by 2002:a17:90a:c787:: with SMTP id gn7mr17803613pjb.222.1610895256377; Sun, 17 Jan 2021 06:54:16 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id x127sm13143583pfb.74.2021.01.17.06.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 06:54:15 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [RFC PATCH V2 11/11] hw/block/nvme: support for shared namespace in subsystem Date: Sun, 17 Jan 2021 23:53:41 +0900 Message-Id: <20210117145341.23310-12-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210117145341.23310-1-minwoo.im.dev@gmail.com> References: <20210117145341.23310-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pj1-x102f.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme-ns device is registered to a nvme controller device during the initialization in nvme_register_namespace() in case that 'bus' property is given which means it's mapped to a single controller. This patch introduced a new property 'subsys' just like the controller device instance did to map a namespace to a NVMe subsystem. If 'subsys' property is given to the nvme-ns device, it will belong to the specified subsystem and will be attached to all controllers in that subsystem by enabling shared namespace capability in NMIC(Namespace Multi-path I/O and Namespace Capabilities) in Identify Namespace. Usage: -device nvme-subsys,id=subsys0 -device nvme,serial=foo,id=nvme0,subsys=subsys0 -device nvme,serial=bar,id=nvme1,subsys=subsys0 -device nvme,serial=baz,id=nvme2,subsys=subsys0 -device nvme-ns,id=ns1,drive=,nsid=1,subsys=subsys0 # Shared -device nvme-ns,id=ns2,drive=,nsid=2,bus=nvme2 # Non-shared In the above example, 'ns1' will be shared to 'nvme0' and 'nvme1' in the same subsystem. On the other hand, 'ns2' will be attached to the 'nvme2' only as a private namespace in that subsystem. Signed-off-by: Minwoo Im --- hw/block/nvme-ns.c | 23 ++++++++++++++++++----- hw/block/nvme-ns.h | 7 +++++++ hw/block/nvme-subsys.c | 17 +++++++++++++++++ hw/block/nvme-subsys.h | 1 + hw/block/nvme.c | 10 +++++++++- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index c8b75fa02138..073f65e49cac 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -63,6 +63,10 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) id_ns->npda = id_ns->npdg = npdg - 1; + if (nvme_ns_shared(ns)) { + id_ns->nmic |= NVME_NMIC_NS_SHARED; + } + return 0; } @@ -358,16 +362,25 @@ static void nvme_ns_realize(DeviceState *dev, Error **errp) return; } - if (nvme_register_namespace(n, ns, errp)) { - error_propagate_prepend(errp, local_err, - "could not register namespace: "); - return; + if (ns->subsys) { + if (nvme_subsys_register_ns(ns, errp)) { + error_propagate_prepend(errp, local_err, + "could not setup namespace to subsys: "); + return; + } + } else { + if (nvme_register_namespace(n, ns, errp)) { + error_propagate_prepend(errp, local_err, + "could not register namespace: "); + return; + } } - } static Property nvme_ns_props[] = { DEFINE_BLOCK_PROPERTIES(NvmeNamespace, blkconf), + DEFINE_PROP_LINK("subsys", NvmeNamespace, subsys, TYPE_NVME_SUBSYS, + NvmeSubsystem *), DEFINE_PROP_UINT32("nsid", NvmeNamespace, params.nsid, 0), DEFINE_PROP_UUID("uuid", NvmeNamespace, params.uuid), DEFINE_PROP_BOOL("zoned", NvmeNamespace, params.zoned, false), diff --git a/hw/block/nvme-ns.h b/hw/block/nvme-ns.h index d87c025b0ab6..3fc7262a7915 100644 --- a/hw/block/nvme-ns.h +++ b/hw/block/nvme-ns.h @@ -47,6 +47,8 @@ typedef struct NvmeNamespace { const uint32_t *iocs; uint8_t csi; + NvmeSubsystem *subsys; + NvmeIdNsZoned *id_ns_zoned; NvmeZone *zone_array; QTAILQ_HEAD(, NvmeZone) exp_open_zones; @@ -77,6 +79,11 @@ static inline uint32_t nvme_nsid(NvmeNamespace *ns) return -1; } +static inline bool nvme_ns_shared(NvmeNamespace *ns) +{ + return !!ns->subsys; +} + static inline NvmeLBAF *nvme_ns_lbaf(NvmeNamespace *ns) { NvmeIdNs *id_ns = &ns->id_ns; diff --git a/hw/block/nvme-subsys.c b/hw/block/nvme-subsys.c index a01003136b12..d67160a0ed6f 100644 --- a/hw/block/nvme-subsys.c +++ b/hw/block/nvme-subsys.c @@ -43,6 +43,23 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) return cntlid; } +int nvme_subsys_register_ns(NvmeNamespace *ns, Error **errp) +{ + NvmeSubsystem *subsys = ns->subsys; + NvmeCtrl *n; + int i; + + for (i = 0; i < ARRAY_SIZE(subsys->ctrls); i++) { + n = subsys->ctrls[i]; + + if (n && nvme_register_namespace(n, ns, errp)) { + return -1; + } + } + + return 0; +} + static void nvme_subsys_setup(NvmeSubsystem *subsys) { char *subnqn; diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h index 4eba50d96a1d..cae0fbd464e2 100644 --- a/hw/block/nvme-subsys.h +++ b/hw/block/nvme-subsys.h @@ -25,5 +25,6 @@ typedef struct NvmeSubsystem { } NvmeSubsystem; int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp); +int nvme_subsys_register_ns(NvmeNamespace *ns, Error **errp); #endif /* NVME_SUBSYS_H */ diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 2aeb164dd508..7869bd95b099 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -25,7 +25,8 @@ * mdts=,zoned.append_size_limit= \ * ,subsys= \ * -device nvme-ns,drive=,bus=,nsid=,\ - * zoned= + * zoned=, \ + * subsys= * -device nvme-subsys,id= * * Note cmb_size_mb denotes size of CMB in MB. CMB is assumed to be at @@ -69,6 +70,13 @@ * data size being in effect. By setting this property to 0, users can make * ZASL to be equal to MDTS. This property only affects zoned namespaces. * + * nvme namespace device parameters + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * - `subsys` + * NVM Subsystem device. If given, this namespace will be attached to all + * controllers in the subsystem. Otherwise, `bus` must be given to attach + * this namespace to a specified single controller as a non-shared namespace. + * * Setting `zoned` to true selects Zoned Command Set at the namespace. * In this case, the following namespace properties are available to configure * zoned operation: