[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 27/43] hw/block/nvme: add msix_qsize parameter
From: |
Kevin Wolf |
Subject: |
[PULL 27/43] hw/block/nvme: add msix_qsize parameter |
Date: |
Wed, 17 Jun 2020 16:48:53 +0200 |
From: Klaus Jensen <k.jensen@samsung.com>
Decouple the requested maximum number of ioqpairs (param max_ioqpairs)
from the number of MSI-X interrupt vectors by introducing a new
msix_qsize parameter and initialize MSI-X with that. This allows
emulating a device that has fewer vectors than I/O queue pairs and also
allows more than 2048 queue pairs. To keep the device behaving as
previously, use a msix_qsize default of 65 (default max_ioqpairs + 1).
This decoupling was actually suggested by Maxim some time ago in a
slightly different context, so adding a Suggested-by.
Suggested-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Message-Id: <20200609190333.59390-22-its@irrelevant.dk>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/block/nvme.h | 1 +
hw/block/nvme.c | 17 +++++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index 61dd9b23b8..1d30c0bca2 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -7,6 +7,7 @@ typedef struct NvmeParams {
char *serial;
uint32_t num_queues; /* deprecated since 5.1 */
uint32_t max_ioqpairs;
+ uint16_t msix_qsize;
uint32_t cmb_size_mb;
} NvmeParams;
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index fe17aa5d70..acc6dbc900 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -54,6 +54,7 @@
#include "trace.h"
#include "nvme.h"
+#define NVME_MAX_IOQPAIRS 0xffff
#define NVME_REG_SIZE 0x1000
#define NVME_DB_SIZE 4
#define NVME_CMB_BIR 2
@@ -662,7 +663,7 @@ static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeCmd *cmd)
trace_pci_nvme_err_invalid_create_cq_vector(vector);
return NVME_INVALID_IRQ_VECTOR | NVME_DNR;
}
- if (unlikely(vector > n->params.max_ioqpairs)) {
+ if (unlikely(vector >= n->params.msix_qsize)) {
trace_pci_nvme_err_invalid_create_cq_vector(vector);
return NVME_INVALID_IRQ_VECTOR | NVME_DNR;
}
@@ -1371,9 +1372,16 @@ static void nvme_check_constraints(NvmeCtrl *n, Error
**errp)
}
if (params->max_ioqpairs < 1 ||
- params->max_ioqpairs > PCI_MSIX_FLAGS_QSIZE) {
+ params->max_ioqpairs > NVME_MAX_IOQPAIRS) {
error_setg(errp, "max_ioqpairs must be between 1 and %d",
- PCI_MSIX_FLAGS_QSIZE);
+ NVME_MAX_IOQPAIRS);
+ return;
+ }
+
+ if (params->msix_qsize < 1 ||
+ params->msix_qsize > PCI_MSIX_FLAGS_QSIZE + 1) {
+ error_setg(errp, "msix_qsize must be between 1 and %d",
+ PCI_MSIX_FLAGS_QSIZE + 1);
return;
}
@@ -1527,7 +1535,7 @@ static void nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev)
n->reg_size);
pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64, &n->iomem);
- msix_init_exclusive_bar(pci_dev, n->params.max_ioqpairs + 1, 4, NULL);
+ msix_init_exclusive_bar(pci_dev, n->params.msix_qsize, 4, NULL);
if (n->params.cmb_size_mb) {
nvme_init_cmb(n, pci_dev);
@@ -1634,6 +1642,7 @@ static Property nvme_props[] = {
DEFINE_PROP_UINT32("cmb_size_mb", NvmeCtrl, params.cmb_size_mb, 0),
DEFINE_PROP_UINT32("num_queues", NvmeCtrl, params.num_queues, 0),
DEFINE_PROP_UINT32("max_ioqpairs", NvmeCtrl, params.max_ioqpairs, 64),
+ DEFINE_PROP_UINT16("msix_qsize", NvmeCtrl, params.msix_qsize, 65),
DEFINE_PROP_END_OF_LIST(),
};
--
2.25.4
- [PULL 20/43] hw/block/nvme: factor out namespace setup, (continued)
- [PULL 20/43] hw/block/nvme: factor out namespace setup, Kevin Wolf, 2020/06/17
- [PULL 22/43] hw/block/nvme: factor out cmb setup, Kevin Wolf, 2020/06/17
- [PULL 25/43] hw/block/nvme: factor out controller identify setup, Kevin Wolf, 2020/06/17
- [PULL 21/43] hw/block/nvme: factor out pci setup, Kevin Wolf, 2020/06/17
- [PULL 23/43] hw/block/nvme: factor out pmr setup, Kevin Wolf, 2020/06/17
- [PULL 24/43] hw/block/nvme: do cmb/pmr init as part of pci init, Kevin Wolf, 2020/06/17
- [PULL 26/43] hw/block/nvme: Verify msix_vector_use() returned value, Kevin Wolf, 2020/06/17
- [PULL 28/43] hw/block/nvme: verify msix_init_exclusive_bar() return value, Kevin Wolf, 2020/06/17
- [PULL 30/43] virtio-blk: store opt_io_size with correct size, Kevin Wolf, 2020/06/17
- [PULL 32/43] qdev-properties: blocksize: use same limits in code and description, Kevin Wolf, 2020/06/17
- [PULL 27/43] hw/block/nvme: add msix_qsize parameter,
Kevin Wolf <=
- [PULL 31/43] block: consolidate blocksize properties consistency checks, Kevin Wolf, 2020/06/17
- [PULL 29/43] .gitignore: Ignore storage-daemon files, Kevin Wolf, 2020/06/17
- [PULL 34/43] qdev-properties: make blocksize accept size suffixes, Kevin Wolf, 2020/06/17
- [PULL 33/43] qdev-properties: add size32 property type, Kevin Wolf, 2020/06/17
- [PULL 35/43] block: make BlockConf size props 32bit and accept size suffixes, Kevin Wolf, 2020/06/17
- [PULL 36/43] qdev-properties: add getter for size32 and blocksize, Kevin Wolf, 2020/06/17
- [PULL 38/43] iotests.py: Add skip_for_formats() decorator, Kevin Wolf, 2020/06/17
- [PULL 40/43] iotests/292: data_file is unsupported, Kevin Wolf, 2020/06/17
- [PULL 37/43] block: lift blocksize property limit to 2 MiB, Kevin Wolf, 2020/06/17
- [PULL 41/43] iotests/229: data_file is unsupported, Kevin Wolf, 2020/06/17