From nobody Mon Nov 25 09:30:54 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=1715171600; cv=none; d=zohomail.com; s=zohoarc; b=SHOx8pEAlA7m6glPJ1T6CSiCMqnZ562QzJ5OrQ1S4f8Ic/Diiek2yM6lxI8wDbMv7KhC8p5do62TBytRU5ZWqmWRDywwrDvRphVbKsjUUbaFDImHVTrA/mthR1/yv0m6Dt/UpyXoZWinYV4ZYk33hPc2ujachuYYSMwlIdcrx6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715171600; 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=41zciqobW1lSQYD67CMpHII/+O0mLdb6RkZbAdkYnvw=; b=IAhp63Zz3E1HIu5GPzgN/yXvA6S7bbekNghQsMT78xkBg/r6jLTJuasvRJ5Lr3pgFmNjDlykyrm426xlFhLqGfyJHHIi53Gi+G0L0IaIm+BQr1cMbDpJWAAy5/1FYCQ6+U47LPVT6sncNNXgleaicsKZyDLJr5owMOy7FCdQUpA= 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 1715171600267222.1442334506561; Wed, 8 May 2024 05:33:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4gS7-0005bf-AN; Wed, 08 May 2024 08:31:19 -0400 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 1s4gS5-0005bA-Lb; Wed, 08 May 2024 08:31:17 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4gS3-00039t-Vh; Wed, 08 May 2024 08:31:17 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e651a9f3ffso22166615ad.1; Wed, 08 May 2024 05:31:15 -0700 (PDT) Received: from localhost ([116.121.76.56]) by smtp.gmail.com with ESMTPSA id b3-20020a170902d30300b001e2a479954dsm11741336plc.181.2024.05.08.05.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 05:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715171474; x=1715776274; 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=41zciqobW1lSQYD67CMpHII/+O0mLdb6RkZbAdkYnvw=; b=aWQpjIWgUwGFPb5a8dylvy6UO1mWnn3SXcPHXFlddfQ7UzaCz419gYza2QW2Xa48ej ZzQRpuPMFtruZhuXrqVIk7l8UIPkwsmka7v2qFA8i1YX0XND5TJ2k2MZZ0IJTQS5bWtJ 6ptex7yjwGyaHDiv5YORCCANIwcCGaueFcncb93IRFm4h6gP55C/haAoRZUxdOD46oeP zhbLk3ovogYQPWxigXwny2jWHgATeOpiKapYf/3whRC4fZe9EAzUBzUEaZ2IKzJqhU13 9vygKat985uMB/k3Wx+KtsWlAgilX5hrFqM7RzCleMjvCm++paoxHvkq8dyByGHqQXR7 IOLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715171474; x=1715776274; 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=41zciqobW1lSQYD67CMpHII/+O0mLdb6RkZbAdkYnvw=; b=bIfOcGvKh0OExYVq9k9rfiPU+HpI5Y6u7rK2i0oboYUINUgDaPIu437amjSmopq6X1 jFmiZDZMFJHGJXYv5f6262L28tG7y0wbraNicZ9PKQ+VXpXt0MHbUTF8u5vgrx6q39YG D3b2+cox2D1aPN2dd3R0VwwmoMS5Nx8OzCFZEjpJZ9AMadFvbCSIYPxihLslEeVTOJYf rowsdaKIacrqQFvFWWK65Z7/qq5yMyrtLGIsBALvZIX8trIb9SfpWr5XsISA8R8huViu zPNgekZBSfO3Oiw1Fwdanncipq2Z8kFY4IrjjVWwN70rg9XTHkuPhCdAspyCc8HAFdaB wV4Q== X-Forwarded-Encrypted: i=1; AJvYcCVpFkdJ8nZutuZ5l6HqF4JttoIqfuPa8o9xy192Z5vVT0Y8junc1+5VbjrjT7boKspIryuwgtXCvsbzuKUCXvEwOHzMZoo= X-Gm-Message-State: AOJu0YyR/BwF2pOeJzJ67L0Zx5lx8J2fb6WlQQsu8xPqd+oS/xfZA89X T6SFya2r39ME0nas16Z0+o67TKtxZghT+69gzNnXSQiPOJ7ivq42R+aAWQ== X-Google-Smtp-Source: AGHT+IGNcVh4SAxQDXmWeZr40KH95b2x0M7A7hh1Zzq+UlNU4mzN1qV6EhOobm6wZCrX14M6J1c/1w== X-Received: by 2002:a17:902:ce8a:b0:1e1:1791:3681 with SMTP id d9443c01a7336-1eeb0796948mr29718035ad.61.1715171473939; Wed, 08 May 2024 05:31:13 -0700 (PDT) From: Minwoo Im To: Klaus Jensen , Keith Busch Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Minwoo Im , Klaus Jensen Subject: [PATCH v3 1/4] hw/nvme: add Identify Endurance Group List Date: Wed, 8 May 2024 21:31:04 +0900 Message-Id: <20240508123107.87919-2-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240508123107.87919-1-minwoo.im.dev@gmail.com> References: <20240508123107.87919-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::631; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pl1-x631.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.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: 1715171601581100001 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 127c3d238346..18672f66193f 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; @@ -5744,6 +5764,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 From nobody Mon Nov 25 09:30:54 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=1715171538; cv=none; d=zohomail.com; s=zohoarc; b=DF/qIW/8M09BCKn6/uTQKn/HKtkD9Aj/VR4rDPvR3yIkLMcrT4lsjEvvKUl9y622v5ni01xvkST+Dd/bg/NP1AdVzWEPzAV9Qvv5vTuJAeZ8+LUN0RNXLoKbpY+ZH6vjvpdQofLxxhZLU+olX7VnuJEMgKK0+4hm/VvTXMwMbzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715171538; 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=6HoXn8Mk/Gcs09/vO/7dO0ihbgiIg45aLeVlxtEb0Kk=; b=eU2bXZybB1ZzNmpHnhOfFZtageanQLm61AYpL4q+x3FQFnC/tiS/hxYCQchbhYwuACmc1LLoC4rUkv98hlY8bc6y5frewQriJ8qDWsDuKUgF3IuLEr8ze23CO6irzb5WRagznvlJb3oeHgjnIMo1Zg/mEdaiucrS3Aws3s0nrWI= 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 1715171538136938.2327962744176; Wed, 8 May 2024 05:32:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4gS9-0005dY-UR; Wed, 08 May 2024 08:31:21 -0400 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 1s4gS8-0005d6-JH; Wed, 08 May 2024 08:31:20 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4gS6-0003AB-Kf; Wed, 08 May 2024 08:31:20 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6ed3cafd766so3343450b3a.0; Wed, 08 May 2024 05:31:17 -0700 (PDT) Received: from localhost ([116.121.76.56]) by smtp.gmail.com with ESMTPSA id p4-20020a056a0026c400b006f448272ae0sm9794621pfw.4.2024.05.08.05.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 05:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715171477; x=1715776277; 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=6HoXn8Mk/Gcs09/vO/7dO0ihbgiIg45aLeVlxtEb0Kk=; b=gEpNDtl8lh/1gq492yPDxZ8rxYFePaaotk1puyGFzX8ALr26TLcZEz/jJIp5A4KAfM N5ptSqQpe/7xp2qpQGx5qdYyhyuKi8yeCmsDKmtIX95RNPgYmdgwXDW/hrvLPSQcXpj7 FDdbWfJCvEkRHnLEgblgISOBBF5ykahiq5Ph3zDMHnj/xT/OPMQ1YFv3k7+KYzClycVW oGGISGmBw83Ja+wBec9RttnLC7+mXiU7BT7+8xCpCZe0xcIb3MHzCb/+JGzijYELfmoY qq1/j+XVLYfAtCRmnMLNf+fgjSDbNM5nZxUNVQJxfssMrkgNkwrU9zJUtHWZrt2ypFz5 hWcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715171477; x=1715776277; 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=6HoXn8Mk/Gcs09/vO/7dO0ihbgiIg45aLeVlxtEb0Kk=; b=T20Q9xWcMUAdlODuXM5f8rdExpdx+cr+7o7KT231VqfLWnCXNCnjrIYfKAq5JEUq1W 5dG2Tb7IebbS0WZ9G3KDclafZMQ6wTeDlla1lE2vwmQ16MiNEh3857V5GRjbwBLROqUc aFif+1caXuUb5bUooEmbotTzofqq98uRQ+dUTGAEeO25sxwi0+kavXT5aVr+cX6sdaeE XUrOT5R5glYaIJgTrndxrnXX5p6LFleluyNk6twqJIirFbhCCOzbbeAJlv9lapmQJfFM 4pk8KW/RLXvjSAr3VagL9zHt8hxm5TPdpyHkx503mu3CPI6lgVuf+FUvDyY4V08q3Jlm Rb8Q== X-Forwarded-Encrypted: i=1; AJvYcCWWu7Ihc5wgdHabk9eEK9UgAq6UFw0XG7FH2lPIjFCAMGjsH4shkacNGUQgO2776x+uax/Ct/ZVh2KVMwuOZHSuK3xCFa0= X-Gm-Message-State: AOJu0YxvYT1vL4rSQ7PajD5cSEILT5VigtHtyMcGvLuU4LjuwznGQ4Cq THq2EwHLXCmb01pK9rQD5PScysXTM/0lYfQz0Uva6kzgC2JmyIqk X-Google-Smtp-Source: AGHT+IHIbxD5ij1CxUeyNExWah7Gtt2TATt5ozvSjSHQ32xafeJHKpgR8o0+8b6KsgYVIPRYPFV9Nw== X-Received: by 2002:a05:6a00:4e8b:b0:6ea:ed70:46b4 with SMTP id d2e1a72fcca58-6f49c2afde9mr2278878b3a.29.1715171476642; Wed, 08 May 2024 05:31:16 -0700 (PDT) From: Minwoo Im To: Klaus Jensen , Keith Busch Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Minwoo Im Subject: [PATCH v3 2/4] hw/nvme: separate identify data for sec. ctrl list Date: Wed, 8 May 2024 21:31:05 +0900 Message-Id: <20240508123107.87919-3-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240508123107.87919-1-minwoo.im.dev@gmail.com> References: <20240508123107.87919-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::42c; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pf1-x42c.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.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: 1715171539306100001 Content-Type: text/plain; charset="utf-8" From: Minwoo Im Secondary controller list for virtualization has been managed by Identify Secondary Controller List data structure with NvmeSecCtrlList where up to 127 secondary controller entries can be managed. The problem hasn't arisen so far because NVME_MAX_VFS has been 127. This patch separated identify data itself from the actual secondary controller list managed by controller to support more than 127 secondary controllers with the following patch. This patch reused NvmeSecCtrlEntry structure to manage all the possible secondary controllers, and copy entries to identify data structure when the command comes in. Signed-off-by: Minwoo Im --- hw/nvme/ctrl.c | 21 ++++++++++----------- hw/nvme/nvme.h | 14 ++++++++------ hw/nvme/subsys.c | 8 ++++---- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 18672f66193f..7cf1e8e384b7 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -219,7 +219,6 @@ #define NVME_TEMPERATURE_CRITICAL 0x175 #define NVME_NUM_FW_SLOTS 1 #define NVME_DEFAULT_MAX_ZA_SIZE (128 * KiB) -#define NVME_MAX_VFS 127 #define NVME_VF_RES_GRANULARITY 1 #define NVME_VF_OFFSET 0x1 #define NVME_VF_STRIDE 1 @@ -5480,14 +5479,14 @@ static uint16_t nvme_identify_sec_ctrl_list(NvmeCtr= l *n, NvmeRequest *req) NvmeIdentify *c =3D (NvmeIdentify *)&req->cmd; uint16_t pri_ctrl_id =3D le16_to_cpu(n->pri_ctrl_cap.cntlid); uint16_t min_id =3D le16_to_cpu(c->ctrlid); - uint8_t num_sec_ctrl =3D n->sec_ctrl_list.numcntl; + uint8_t num_sec_ctrl =3D n->nr_sec_ctrls; NvmeSecCtrlList list =3D {0}; uint8_t i; =20 for (i =3D 0; i < num_sec_ctrl; i++) { - if (n->sec_ctrl_list.sec[i].scid >=3D min_id) { - list.numcntl =3D num_sec_ctrl - i; - memcpy(&list.sec, n->sec_ctrl_list.sec + i, + if (n->sec_ctrl_list[i].scid >=3D min_id) { + list.numcntl =3D MIN(num_sec_ctrl - i, 127); + memcpy(&list.sec, n->sec_ctrl_list + i, list.numcntl * sizeof(NvmeSecCtrlEntry)); break; } @@ -7144,8 +7143,8 @@ static void nvme_ctrl_reset(NvmeCtrl *n, NvmeResetTyp= e rst) =20 if (n->params.sriov_max_vfs) { if (!pci_is_vf(pci_dev)) { - for (i =3D 0; i < n->sec_ctrl_list.numcntl; i++) { - sctrl =3D &n->sec_ctrl_list.sec[i]; + for (i =3D 0; i < n->nr_sec_ctrls; i++) { + sctrl =3D &n->sec_ctrl_list[i]; nvme_virt_set_state(n, le16_to_cpu(sctrl->scid), false); } } @@ -7934,7 +7933,7 @@ static bool nvme_check_params(NvmeCtrl *n, Error **er= rp) static void nvme_init_state(NvmeCtrl *n) { NvmePriCtrlCap *cap =3D &n->pri_ctrl_cap; - NvmeSecCtrlList *list =3D &n->sec_ctrl_list; + NvmeSecCtrlEntry *list =3D n->sec_ctrl_list; NvmeSecCtrlEntry *sctrl; PCIDevice *pci =3D PCI_DEVICE(n); uint8_t max_vfs; @@ -7959,9 +7958,9 @@ static void nvme_init_state(NvmeCtrl *n) n->aer_reqs =3D g_new0(NvmeRequest *, n->params.aerl + 1); QTAILQ_INIT(&n->aer_queue); =20 - list->numcntl =3D max_vfs; + n->nr_sec_ctrls =3D max_vfs; for (i =3D 0; i < max_vfs; i++) { - sctrl =3D &list->sec[i]; + sctrl =3D &list[i]; sctrl->pcid =3D cpu_to_le16(n->cntlid); sctrl->vfn =3D cpu_to_le16(i + 1); } @@ -8534,7 +8533,7 @@ static void nvme_sriov_post_write_config(PCIDevice *d= ev, uint16_t old_num_vfs) int i; =20 for (i =3D pcie_sriov_num_vfs(dev); i < old_num_vfs; i++) { - sctrl =3D &n->sec_ctrl_list.sec[i]; + sctrl =3D &n->sec_ctrl_list[i]; nvme_virt_set_state(n, le16_to_cpu(sctrl->scid), false); } } diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index bed8191bd5fd..485b42c104ea 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -26,6 +26,7 @@ =20 #define NVME_MAX_CONTROLLERS 256 #define NVME_MAX_NAMESPACES 256 +#define NVME_MAX_VFS 127 #define NVME_EUI64_DEFAULT ((uint64_t)0x5254000000000000) #define NVME_FDP_MAX_EVENTS 63 #define NVME_FDP_MAXPIDS 128 @@ -612,7 +613,8 @@ typedef struct NvmeCtrl { } features; =20 NvmePriCtrlCap pri_ctrl_cap; - NvmeSecCtrlList sec_ctrl_list; + uint32_t nr_sec_ctrls; + NvmeSecCtrlEntry sec_ctrl_list[NVME_MAX_VFS]; struct { uint16_t vqrfap; uint16_t virfap; @@ -662,7 +664,7 @@ static inline NvmeSecCtrlEntry *nvme_sctrl(NvmeCtrl *n) NvmeCtrl *pf =3D NVME(pcie_sriov_get_pf(pci_dev)); =20 if (pci_is_vf(pci_dev)) { - return &pf->sec_ctrl_list.sec[pcie_sriov_vf_number(pci_dev)]; + return &pf->sec_ctrl_list[pcie_sriov_vf_number(pci_dev)]; } =20 return NULL; @@ -671,12 +673,12 @@ static inline NvmeSecCtrlEntry *nvme_sctrl(NvmeCtrl *= n) static inline NvmeSecCtrlEntry *nvme_sctrl_for_cntlid(NvmeCtrl *n, uint16_t cntlid) { - NvmeSecCtrlList *list =3D &n->sec_ctrl_list; + NvmeSecCtrlEntry *list =3D n->sec_ctrl_list; uint8_t i; =20 - for (i =3D 0; i < list->numcntl; i++) { - if (le16_to_cpu(list->sec[i].scid) =3D=3D cntlid) { - return &list->sec[i]; + for (i =3D 0; i < n->nr_sec_ctrls; i++) { + if (le16_to_cpu(list[i].scid) =3D=3D cntlid) { + return &list[i]; } } =20 diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index d30bb8bfd5b4..561ed04a5317 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -17,13 +17,13 @@ static int nvme_subsys_reserve_cntlids(NvmeCtrl *n, int start, int num) { NvmeSubsystem *subsys =3D n->subsys; - NvmeSecCtrlList *list =3D &n->sec_ctrl_list; + NvmeSecCtrlEntry *list =3D n->sec_ctrl_list; NvmeSecCtrlEntry *sctrl; int i, cnt =3D 0; =20 for (i =3D start; i < ARRAY_SIZE(subsys->ctrls) && cnt < num; i++) { if (!subsys->ctrls[i]) { - sctrl =3D &list->sec[cnt]; + sctrl =3D &list[cnt]; sctrl->scid =3D cpu_to_le16(i); subsys->ctrls[i] =3D SUBSYS_SLOT_RSVD; cnt++; @@ -36,12 +36,12 @@ static int nvme_subsys_reserve_cntlids(NvmeCtrl *n, int= start, int num) static void nvme_subsys_unreserve_cntlids(NvmeCtrl *n) { NvmeSubsystem *subsys =3D n->subsys; - NvmeSecCtrlList *list =3D &n->sec_ctrl_list; + NvmeSecCtrlEntry *list =3D n->sec_ctrl_list; NvmeSecCtrlEntry *sctrl; int i, cntlid; =20 for (i =3D 0; i < n->params.sriov_max_vfs; i++) { - sctrl =3D &list->sec[i]; + sctrl =3D &list[i]; cntlid =3D le16_to_cpu(sctrl->scid); =20 if (cntlid) { --=20 2.34.1 From nobody Mon Nov 25 09:30:54 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=1715171554; cv=none; d=zohomail.com; s=zohoarc; b=TnqH2incyHgPZrKVCqZ7esk5co6WqFxAYwnZs5V8OJ6ALFJ+4oBUtjBPfM/aedgNSwO7oexiuBtP8edErVtA4ge81VeCkKWlD0lk+8iOlFSTU/F2tZio41F6Kr2jDQn8JMHUvF9P6vhX5EQMzYVXRFZzVUYjxHgOcTEMYQ/0RBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715171554; 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=Ndv57RH03iIiitXdceTxAwpyOl6hTRdMizLr7f5jGsg=; b=GsSflHfA2KygWCIOlb11XlW6iR6+Ocpdf2LPBL9y9y28z63bb0rPWMIDXpqw/dg5pDBz79t0pzo/Iow14Fc/W3Mx1m3hIOQVAiInznYuebG33MWPnYtJZ9d98RR7tI+4WLdNEd4IPvpWE7DXkh62K0mkYI4XhyzwmCkwz6Dwp4E= 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 1715171554024932.6035916089165; Wed, 8 May 2024 05:32:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4gSI-0005fQ-FG; Wed, 08 May 2024 08:31:30 -0400 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 1s4gSD-0005eT-QE; Wed, 08 May 2024 08:31:25 -0400 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 1s4gSA-0003AS-3G; Wed, 08 May 2024 08:31:24 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6f45f1179c3so3281205b3a.3; Wed, 08 May 2024 05:31:21 -0700 (PDT) Received: from localhost ([116.121.76.56]) by smtp.gmail.com with ESMTPSA id bf5-20020a656d05000000b0062070308b0esm6922317pgb.46.2024.05.08.05.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 05:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715171480; x=1715776280; 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=Ndv57RH03iIiitXdceTxAwpyOl6hTRdMizLr7f5jGsg=; b=TwqNuGr4qIdxjpvuQUKvylEHgW6T2PnkOlUFvznhvPnmv6VerEmn51HZVk0vuGKqo7 ut2ytZ6taxIBzObyi1g82ctbbeXQENAtezw05GVi1CNyQzXHQAdKdbPaFMRnkdGptyDR nmFPQLqvUZawQyAK5NlnfORQK++tRewvZv6AQIWU3qU6YiSMmE582cV7jzEc8X++rixT FWNQlYFdoymZigw4eosfPetpEQfqU4IWk4YZdohQ68j0hHeXpf+9UgdsuOHf7mCViMHV jUXmaecPuxD5c2gcZFbu7HwuYfLui1gnQkM65xrDdHnHRkj6Pn5UA2cmAgOON2pkl7g0 Q9rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715171480; x=1715776280; 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=Ndv57RH03iIiitXdceTxAwpyOl6hTRdMizLr7f5jGsg=; b=QH/LY6iOim686NFWFljCXWbbBMsDrIi7Y60KIugRd4ksCTLuip5nWWTmZOctZG/N5k RKaAwlfGhJRmg8rZkhcALGzd97E+Tw2H6oDaP/++nvLZcswZUU7X4fEVp/X4U4DcxHWq UObGTD7z4MhG/Noqi5tf8Ja2mOuiqRZBrs1sWuvMG6Dle7ynlRFh9O6OqzlgLv8HD1un NGuSPd4YxFuukDO80O8NaI77xDHiZGjQB4tXu2En52Juhz/UCzH6nO21vzeOOJTrSf+z YvFInsoQKgmN5nG3lY6xkCEjrY1mDRijkfEj+J5N+kaJWQEmDL+yISksA9sBGSTCa7+b TcqQ== X-Forwarded-Encrypted: i=1; AJvYcCVzOYEcNk/jLlhy0MxHlw8dTmN1zIs4txQW+DtWoiJpDxTTQ/FFFlwMlEe7Op/pHsEIaIqLXyKBE2UCa7Dnfo1MzWxxB3E= X-Gm-Message-State: AOJu0Yy58gw5exvmCdk80rV/UW/O3x1mZwr07AbpPFHpTcXtQcLpd1Ms bcgM+xAgTNrrgxc3edN7OwYVLFYqF3oaUjCNrhUa0OiSysm563pw X-Google-Smtp-Source: AGHT+IEJ7kkrraMPmwlVk9h3wy5ZUoC0ChT6xWRa6783DpajgzkhqB7wDZVxTyDSPkiXkV7XWrfJbA== X-Received: by 2002:a05:6a21:6da4:b0:1af:8e88:2834 with SMTP id adf61e73a8af0-1afc8db7ebdmr3107623637.46.1715171479959; Wed, 08 May 2024 05:31:19 -0700 (PDT) From: Minwoo Im To: Klaus Jensen , Keith Busch Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Minwoo Im Subject: [PATCH v3 3/4] hw/nvme: Allocate sec-ctrl-list as a dynamic array Date: Wed, 8 May 2024 21:31:06 +0900 Message-Id: <20240508123107.87919-4-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240508123107.87919-1-minwoo.im.dev@gmail.com> References: <20240508123107.87919-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 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: 1715171555379100001 Content-Type: text/plain; charset="utf-8" From: Minwoo Im To prevent further bumping up the number of maximum VF te support, this patch allocates a dynamic array (NvmeCtrl *)->sec_ctrl_list based on number of VF supported by sriov_max_vfs property. Signed-off-by: Minwoo Im --- hw/nvme/ctrl.c | 8 +------- hw/nvme/nvme.h | 5 ++--- hw/nvme/subsys.c | 2 ++ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 7cf1e8e384b7..8db6828ab2a9 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -7863,12 +7863,6 @@ static bool nvme_check_params(NvmeCtrl *n, Error **e= rrp) return false; } =20 - if (params->sriov_max_vfs > NVME_MAX_VFS) { - error_setg(errp, "sriov_max_vfs must be between 0 and %d", - NVME_MAX_VFS); - return false; - } - if (params->cmb_size_mb) { error_setg(errp, "CMB is not supported with SR-IOV"); return false; @@ -8461,7 +8455,7 @@ static Property nvme_props[] =3D { DEFINE_PROP_UINT8("zoned.zasl", NvmeCtrl, params.zasl, 0), DEFINE_PROP_BOOL("zoned.auto_transition", NvmeCtrl, params.auto_transition_zones, true), - DEFINE_PROP_UINT8("sriov_max_vfs", NvmeCtrl, params.sriov_max_vfs, 0), + DEFINE_PROP_UINT32("sriov_max_vfs", NvmeCtrl, params.sriov_max_vfs, 0), DEFINE_PROP_UINT16("sriov_vq_flexible", NvmeCtrl, params.sriov_vq_flexible, 0), DEFINE_PROP_UINT16("sriov_vi_flexible", NvmeCtrl, diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 485b42c104ea..cc6b4a3a64c2 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -26,7 +26,6 @@ =20 #define NVME_MAX_CONTROLLERS 256 #define NVME_MAX_NAMESPACES 256 -#define NVME_MAX_VFS 127 #define NVME_EUI64_DEFAULT ((uint64_t)0x5254000000000000) #define NVME_FDP_MAX_EVENTS 63 #define NVME_FDP_MAXPIDS 128 @@ -532,7 +531,7 @@ typedef struct NvmeParams { bool auto_transition_zones; bool legacy_cmb; bool ioeventfd; - uint8_t sriov_max_vfs; + uint32_t sriov_max_vfs; uint16_t sriov_vq_flexible; uint16_t sriov_vi_flexible; uint8_t sriov_max_vq_per_vf; @@ -614,7 +613,7 @@ typedef struct NvmeCtrl { =20 NvmePriCtrlCap pri_ctrl_cap; uint32_t nr_sec_ctrls; - NvmeSecCtrlEntry sec_ctrl_list[NVME_MAX_VFS]; + NvmeSecCtrlEntry *sec_ctrl_list; struct { uint16_t vqrfap; uint16_t virfap; diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index 561ed04a5317..77deaf2c2c97 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -61,6 +61,8 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) if (pci_is_vf(&n->parent_obj)) { cntlid =3D le16_to_cpu(sctrl->scid); } else { + n->sec_ctrl_list =3D g_new0(NvmeSecCtrlEntry, num_vfs); + for (cntlid =3D 0; cntlid < ARRAY_SIZE(subsys->ctrls); cntlid++) { if (!subsys->ctrls[cntlid]) { break; --=20 2.34.1 From nobody Mon Nov 25 09:30:54 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=1715171533; cv=none; d=zohomail.com; s=zohoarc; b=HjUVTKSM+sXi7IU3Xtito8rztUZcETd5CZQ1IXxPv4+m3+qEPYhgNaVhHdPguN2Rljy2ESt7fIx6rIAT8610aSVmIeU2Of4ShRGVRJIYIFG/Qc9RluJtFtBPhaAnVqNwGxLTjc+/a7H+93z0+tmehQaCjNwHoJBLX3mw7+NhPeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715171533; 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=RXQz1dwRLC7iNrSUqXMbmSa+SmczD7+CTqmM7iOnNMU=; b=CZ6HN8WeAf7gOLm8tsuOVLviApNs3qZBMHlsKVygIxStGkZDcnK4jNrAMew7ejLjIUJSdP6SwtE14SE25jsR8hhL/VLLM6eBhYMr44nPT9qLVS9OCb3nqc0xqUParlN+oWlJrFATeQT4FMuXtihxMBTMjoyxZKYN7Xb6RPCYZe4= 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 17151715338391010.1058831112651; Wed, 8 May 2024 05:32:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4gSM-0005iS-Sg; Wed, 08 May 2024 08:31:34 -0400 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 1s4gSL-0005gV-CN; Wed, 08 May 2024 08:31:33 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4gSC-0003Aw-Ia; Wed, 08 May 2024 08:31:33 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ee5235f5c9so21834755ad.2; Wed, 08 May 2024 05:31:23 -0700 (PDT) Received: from localhost ([116.121.76.56]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001ebd73f61fcsm11708026plg.121.2024.05.08.05.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 05:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715171483; x=1715776283; 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=RXQz1dwRLC7iNrSUqXMbmSa+SmczD7+CTqmM7iOnNMU=; b=PDQuUlycWAcq4rW1FJ9YE4RiuL3Dk7Kp5Xj2AAG+Wp8SGLTNcu20IHWniZfui0V2aF fm4P193EW5Q2FO10BnDaN4z2BDyIQtGye3WHdjH7qmBTqZqLokNa39f59/+mSeOxZbUd VHCNCziaHCsQh8+5DUCPoqkEK4S+oWrv+TKvtP3rOY0HII8ti7hzyOVwTPj/VYCDeNgi noBPo+zjy2GNZYo+BpiMDbnmPppqRWc+k/KAGlII0LUyNXg+JwWnzaoTzu5Gy+UBn88y KOsZ9E2CMj7iGME+lkJAd2LIu3zNRCzkT/GQN+2RYOVK8t8fushNW30dzrq0SeKkz7m8 nU3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715171483; x=1715776283; 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=RXQz1dwRLC7iNrSUqXMbmSa+SmczD7+CTqmM7iOnNMU=; b=fnvYJ4VbmbIU+ebh88sCF9+hmegL1nCaDSGU4EB6iVIn8CeikBP1Z7PKf7zhqJ+RKT OHWrAd2AahU0aSo7JfuC0J54GpXkgdhbuZ0PQCAvO/3MRYJ76IsnZ7/zwtl731dd41hH zCyLgzUdrPHiPeBqinH0f4OlsFvlFZbW7xT3zpNesgKvzFWKoFH+fkd2M/tSOLfoIgo0 JaWo5MR5efwFUNwFjjMLt/qdf+M+Wjzz3x52lPz53+EDhIaR7POQ+7cehhSqjjfV67Nr YxW5fDa20SHjMumhc8ZN9RKL0YP/RwS05lg59KkNZ3XtgFZdFryLNRhKzDrsvN15oJqJ 8Vmw== X-Forwarded-Encrypted: i=1; AJvYcCUvoQHnVU1vliBxravUnnMU23+YvPpXLEuDo4d6+eWKD39AgXSUelSKuYEXmj4q/v4PIiHA7R/fQh7j4t3bAImM8rmrIgU= X-Gm-Message-State: AOJu0YzXCR+/I0SD9veQuaU6h6pkKzX4TOL9YSnkYb5LoTTyV5QszYIa 5IxVnu7wqGyV4PWNgArjEtUg25d2N28pJdyR0YrH7TALlhiIBPul X-Google-Smtp-Source: AGHT+IGkqU8PlSae/qWJE8ew/mjttkZD0XyX5fXU2OI2ATvXVkYSBp+Lnuic/fJYGsjtPCEXqcKq+w== X-Received: by 2002:a17:902:eb87:b0:1eb:152a:5a6e with SMTP id d9443c01a7336-1eeb03a6a3bmr30119205ad.3.1715171482695; Wed, 08 May 2024 05:31:22 -0700 (PDT) From: Minwoo Im To: Klaus Jensen , Keith Busch Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Minwoo Im , Klaus Jensen Subject: [PATCH v3 4/4] hw/nvme: Expand VI/VQ resource to uint32 Date: Wed, 8 May 2024 21:31:07 +0900 Message-Id: <20240508123107.87919-5-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240508123107.87919-1-minwoo.im.dev@gmail.com> References: <20240508123107.87919-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::62b; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pl1-x62b.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, 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.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: 1715171535528100002 Content-Type: text/plain; charset="utf-8" From: Minwoo Im VI and VQ resources cover queue resources in each VFs in SR-IOV. Current maximum I/O queue pair size is 0xffff, we can expand them to cover the full number of I/O queue pairs. This patch also fixed Identify Secondary Controller List overflow due to expand of number of secondary controllers. Signed-off-by: Minwoo Im Reviewed-by: Klaus Jensen --- hw/nvme/ctrl.c | 8 ++++---- hw/nvme/nvme.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 8db6828ab2a9..5a94f47b1cf1 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8460,10 +8460,10 @@ static Property nvme_props[] =3D { params.sriov_vq_flexible, 0), DEFINE_PROP_UINT16("sriov_vi_flexible", NvmeCtrl, params.sriov_vi_flexible, 0), - DEFINE_PROP_UINT8("sriov_max_vi_per_vf", NvmeCtrl, - params.sriov_max_vi_per_vf, 0), - DEFINE_PROP_UINT8("sriov_max_vq_per_vf", NvmeCtrl, - params.sriov_max_vq_per_vf, 0), + DEFINE_PROP_UINT32("sriov_max_vi_per_vf", NvmeCtrl, + params.sriov_max_vi_per_vf, 0), + DEFINE_PROP_UINT32("sriov_max_vq_per_vf", NvmeCtrl, + params.sriov_max_vq_per_vf, 0), DEFINE_PROP_BOOL("msix-exclusive-bar", NvmeCtrl, params.msix_exclusive= _bar, false), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index cc6b4a3a64c2..aa708725c875 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -534,8 +534,8 @@ typedef struct NvmeParams { uint32_t sriov_max_vfs; uint16_t sriov_vq_flexible; uint16_t sriov_vi_flexible; - uint8_t sriov_max_vq_per_vf; - uint8_t sriov_max_vi_per_vf; + uint32_t sriov_max_vq_per_vf; + uint32_t sriov_max_vi_per_vf; bool msix_exclusive_bar; } NvmeParams; =20 --=20 2.34.1