From nobody Fri Apr 4 05:05:41 2025 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 ARC-Seal: i=1; a=rsa-sha256; t=1740648682; cv=none; d=zohomail.com; s=zohoarc; b=CCPEzAliVTjy6/x/U4rflU4vcnXkddTRxSIsSGcP0fXmcEo3j1HKFUjDHVwvjGyb6zJGSNMAUiMQ24M4Hfo1tc1SFwHStbm7Zi45cOzYhMFeK1PTL3+fDS4IHNOhLLJ6Da9yXBndG0Z0AXJWnANTK/JNNn60+/8j5FjM/ue55HY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740648682; 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=/mc3xBeqRFRxpB4/dFAIRqOEU9FtF9Vd+rUYFybqzVk=; b=HsNfgNdAdJrj/LK9wn1+zAe9R8Sj1zULvgWaTnQFaxP4KXpxNA+0p3fq7kNbTJu8Kz05/53mGkAQY7nA1MB8j2dYkPp+SxAfTBWco4pWOsqc1hpAEdhL+9wnkIAHolUm5B1aJW9WmhQJNCfWneKkJrxVeSiYdTiYYkbBinQZgfg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17406486824971000.8156052831717; Thu, 27 Feb 2025 01:31:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnaEC-00081q-TZ; Thu, 27 Feb 2025 04:30:49 -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 1tnaDy-0007lZ-57; Thu, 27 Feb 2025 04:30:36 -0500 Received: from fout-a6-smtp.messagingengine.com ([103.168.172.149]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnaDv-0008Fk-FT; Thu, 27 Feb 2025 04:30:33 -0500 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 5867C1382F7E; Thu, 27 Feb 2025 04:30:30 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Thu, 27 Feb 2025 04:30:30 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Feb 2025 04:30:28 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1740648630; x= 1740735030; bh=/mc3xBeqRFRxpB4/dFAIRqOEU9FtF9Vd+rUYFybqzVk=; b=G /xg9IiC8plS3JeLqFv2nx2gkuAAX+CMjPNKGCNc+eyvxyJAUMEeQnEV9x/4ooGDr 57h/4R6enWeCFSZem/Lb1fYcywQIDjxhBGSRq91sm/j0/rf0xHOOaMXjanrN7qxB dQOrDjlpNGM9em/XQUdRdGHMwfltmWB1fobGvxy/VO6Et2Vfe/TnM+7S6hwz8NKl xPq7Y7aVaE4GUVhJQQCSAxkDTyQMv+ImIjI35/GwCEW1LO1H3GOVsDwhXZRMzzkO ChWkAG8GJC/Ot9mr8zcUBLQdTe1jRJJ0QmcIm3HJ57IPGL7Kx9fERAbMzDWWwSPp mDDwphhspre0NOwnTEs1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1740648630; x=1740735030; bh=/ mc3xBeqRFRxpB4/dFAIRqOEU9FtF9Vd+rUYFybqzVk=; b=GckOcuKxAbBCBS1TP qjztyjMn0iX4IBjmMdcZcV1QF2JjyyZwFNujixc9O+4lLIyLOnbEa0sklpFpkFS/ Ghkh+V27pPNZjmYFOiIrKayGLetaW0mna4nfXYzQ2tK91diCviFGCf0USHZqvJDQ VxcipGEP8+UABz01kPsA0Isg5jvTA3akLPXxekahTRfpE2XWJhbx8ENpl/6C0C4u nyN8faJE9EUNeFIIRh3M0NNF2WDRYJNKp+JDVLmHD2yoqPR7FM58StY9t2/o9AVQ RCkVl0RVpQ8WY8k4xofLHQUm5p3jQsATzse7ipW/tMLyE6PWFxSm/+nrFzE1Kxhx NkunA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekjeduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpefmlhgruhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnth drughkqeenucggtffrrghtthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefg heefgfejjeehffefgedujedugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughkpdhnsggprhgtphht thhopeduvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepqhgvmhhuqdguvghvvg hlsehnohhnghhnuhdrohhrghdprhgtphhtthhopehpvghtvghrrdhmrgihuggvlhhlsehl ihhnrghrohdrohhrghdprhgtphhtthhopehkrdhjvghnshgvnhesshgrmhhsuhhnghdrtg homhdprhgtphhtthhopehfohhsshesuggvfhhmrggtrhhordhithdprhgtphhtthhopehk sghushgthheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepihhtshesihhrrhgvlhgvvh grnhhtrdgukhdprhgtphhtthhopehsthgvfhgrnhhhrgesrhgvughhrghtrdgtohhmpdhr tghpthhtohepfhgrmhesvghuphhhohhnrdhnvghtpdhrtghpthhtohepphhhihhlmhguse hlihhnrghrohdrohhrgh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: qemu-devel@nongnu.org Cc: Peter Maydell , Klaus Jensen , Jesper Wendel Devantier , Keith Busch , Klaus Jensen , Stefan Hajnoczi , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 03/10] hw/nvme: make oacs dynamic Date: Thu, 27 Feb 2025 10:30:10 +0100 Message-ID: <20250227093018.11262-4-its@irrelevant.dk> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250227093018.11262-1-its@irrelevant.dk> References: <20250227093018.11262-1-its@irrelevant.dk> 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=103.168.172.149; envelope-from=its@irrelevant.dk; helo=fout-a6-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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.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 @irrelevant.dk) X-ZM-MESSAGEID: 1740648684898019100 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Virtualization Management needs sriov-related parameters. Only report support for the command when that conditions are true. Reviewed-by: Jesper Wendel Devantier Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 25 ++++++++++++++++++------- hw/nvme/nvme.h | 4 ++++ include/block/nvme.h | 3 ++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 5a7ccbcc1b80..4ee8588ca9ae 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -266,7 +266,7 @@ static const uint32_t nvme_feature_cap[NVME_FID_MAX] = =3D { [NVME_FDP_EVENTS] =3D NVME_FEAT_CAP_CHANGE | NVME_FEAT_C= AP_NS, }; =20 -static const uint32_t nvme_cse_acs[256] =3D { +static const uint32_t nvme_cse_acs_default[256] =3D { [NVME_ADM_CMD_DELETE_SQ] =3D NVME_CMD_EFF_CSUPP, [NVME_ADM_CMD_CREATE_SQ] =3D NVME_CMD_EFF_CSUPP, [NVME_ADM_CMD_GET_LOG_PAGE] =3D NVME_CMD_EFF_CSUPP, @@ -278,7 +278,6 @@ static const uint32_t nvme_cse_acs[256] =3D { [NVME_ADM_CMD_GET_FEATURES] =3D NVME_CMD_EFF_CSUPP, [NVME_ADM_CMD_ASYNC_EV_REQ] =3D NVME_CMD_EFF_CSUPP, [NVME_ADM_CMD_NS_ATTACHMENT] =3D NVME_CMD_EFF_CSUPP | NVME_CMD_EFF_= NIC, - [NVME_ADM_CMD_VIRT_MNGMT] =3D NVME_CMD_EFF_CSUPP, [NVME_ADM_CMD_DBBUF_CONFIG] =3D NVME_CMD_EFF_CSUPP, [NVME_ADM_CMD_FORMAT_NVM] =3D NVME_CMD_EFF_CSUPP | NVME_CMD_EFF_= LBCC, [NVME_ADM_CMD_DIRECTIVE_RECV] =3D NVME_CMD_EFF_CSUPP, @@ -5174,7 +5173,7 @@ static uint16_t nvme_cmd_effects(NvmeCtrl *n, uint8_t= csi, uint32_t buf_len, } } =20 - memcpy(log.acs, nvme_cse_acs, sizeof(nvme_cse_acs)); + memcpy(log.acs, n->cse.acs, sizeof(log.acs)); =20 if (src_iocs) { memcpy(log.iocs, src_iocs, sizeof(log.iocs)); @@ -7300,7 +7299,7 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeReque= st *req) trace_pci_nvme_admin_cmd(nvme_cid(req), nvme_sqid(req), req->cmd.opcod= e, nvme_adm_opc_str(req->cmd.opcode)); =20 - if (!(nvme_cse_acs[req->cmd.opcode] & NVME_CMD_EFF_CSUPP)) { + if (!(n->cse.acs[req->cmd.opcode] & NVME_CMD_EFF_CSUPP)) { trace_pci_nvme_err_invalid_admin_opc(req->cmd.opcode); return NVME_INVALID_OPCODE | NVME_DNR; } @@ -8740,6 +8739,9 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pc= i_dev) uint64_t cap =3D ldq_le_p(&n->bar.cap); NvmeSecCtrlEntry *sctrl =3D nvme_sctrl(n); uint32_t ctratt; + uint16_t oacs; + + memcpy(n->cse.acs, nvme_cse_acs_default, sizeof(n->cse.acs)); =20 id->vid =3D cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID)); id->ssvid =3D cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR= _ID)); @@ -8770,9 +8772,18 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *p= ci_dev) =20 id->mdts =3D n->params.mdts; id->ver =3D cpu_to_le32(NVME_SPEC_VER); - id->oacs =3D - cpu_to_le16(NVME_OACS_NS_MGMT | NVME_OACS_FORMAT | NVME_OACS_DBBUF= | - NVME_OACS_DIRECTIVES); + + oacs =3D NVME_OACS_NMS | NVME_OACS_FORMAT | NVME_OACS_DBBUF | + NVME_OACS_DIRECTIVES; + + if (n->params.sriov_max_vfs) { + oacs |=3D NVME_OACS_VMS; + + n->cse.acs[NVME_ADM_CMD_VIRT_MNGMT] =3D NVME_CMD_EFF_CSUPP; + } + + id->oacs =3D cpu_to_le16(oacs); + id->cntrltype =3D 0x1; =20 /* diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index e307e733e46a..b86cad388f5a 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -584,6 +584,10 @@ typedef struct NvmeCtrl { uint64_t dbbuf_eis; bool dbbuf_enabled; =20 + struct { + uint32_t acs[256]; + } cse; + struct { MemoryRegion mem; uint8_t *buf; diff --git a/include/block/nvme.h b/include/block/nvme.h index 975d321c5c08..80fbcb420d48 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -1232,8 +1232,9 @@ enum NvmeIdCtrlOacs { NVME_OACS_SECURITY =3D 1 << 0, NVME_OACS_FORMAT =3D 1 << 1, NVME_OACS_FW =3D 1 << 2, - NVME_OACS_NS_MGMT =3D 1 << 3, + NVME_OACS_NMS =3D 1 << 3, NVME_OACS_DIRECTIVES =3D 1 << 5, + NVME_OACS_VMS =3D 1 << 7, NVME_OACS_DBBUF =3D 1 << 8, }; =20 --=20 2.47.2