Skip to contentSkip to conversation

hw/nvme: move nvme emulation out of hw/block

PATCH In review Klaus Jensen 2 participants 4 messages Mar 1, 2021 – Mar 8, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/nvme: move nvme emulation out of hw/block

From: Klaus Jensen <[email protected]>

With the introduction of the nvme-subsystem device we are really cluttering up the hw/block directory.

As suggested by Philippe previously, move the nvme emulation to hw/nvme.

---
v2:
* rebased on nvme-next
* got rid of the second patch (Minwoo)

 meson.build                               |   1 +
 hw/block/nvme-ns.h                        | 193 ---------------------
 hw/block/nvme-subsys.h                    |  32 ----
 hw/{block => nvme}/nvme.h                 | 198 +++++++++++++++++++++-
 hw/nvme/trace.h                           |   1 +
 hw/{block/nvme.c => nvme/ctrl.c}          |   1 -
 hw/{block/nvme-ns.c => nvme/ns.c}         |   1 -
 hw/{block/nvme-subsys.c => nvme/subsys.c} |   2 +-
 MAINTAINERS                               |   2 +-
 hw/Kconfig                                |   1 +
 hw/block/Kconfig                          |   5 -
 hw/block/meson.build                      |   1 -
 hw/block/trace-events                     | 182 --------------------
 hw/meson.build                            |   1 +
 hw/nvme/Kconfig                           |   4 +
 hw/nvme/meson.build                       |   1 +
 hw/nvme/trace-events                      | 180 ++++++++++++++++++++
 17 files changed, 387 insertions(+), 419 deletions(-)
 delete mode 100644 hw/block/nvme-ns.h
 delete mode 100644 hw/block/nvme-subsys.h
 rename hw/{block => nvme}/nvme.h (55%)
 create mode 100644 hw/nvme/trace.h
 rename hw/{block/nvme.c => nvme/ctrl.c} (99%)
 rename hw/{block/nvme-ns.c => nvme/ns.c} (99%)
 rename hw/{block/nvme-subsys.c => nvme/subsys.c} (98%)
 create mode 100644 hw/nvme/Kconfig
 create mode 100644 hw/nvme/meson.build
 create mode 100644 hw/nvme/trace-events
meson.build +1 -0
index a923f249d89e..59507b125cfe 100644
@@ -1793,6 +1793,7 @@ if have_system
     'hw/misc/macio',
     'hw/net',
     'hw/net/can',
+    'hw/nvme',
     'hw/nvram',
     'hw/pci',
     'hw/pci-host',
hw/block/nvme-ns.h deleted +0 -193

193 lines not on this page · raw message

hw/block/nvme-subsys.h deleted +0 -32
deleted file mode 100644
index ccf6a71398d3..000000000000
@@ -1,32 +0,0 @@
-/*
- * QEMU NVM Express Subsystem: nvme-subsys
- *
- * Copyright (c) 2021 Minwoo Im <[email protected]>
- *
- * 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
-#define NVME_SUBSYS_MAX_NAMESPACES  32
-
-typedef struct NvmeCtrl NvmeCtrl;
-typedef struct NvmeNamespace NvmeNamespace;
-typedef struct NvmeSubsystem {
-    DeviceState parent_obj;
-    uint8_t     subnqn[256];
-
-    NvmeCtrl    *ctrls[NVME_SUBSYS_MAX_CTRLS];
-    NvmeNamespace *namespaces[NVME_SUBSYS_MAX_NAMESPACES];
-} NvmeSubsystem;
-
-int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp);
-int nvme_subsys_register_ns(NvmeNamespace *ns, Error **errp);
-
-#endif /* NVME_SUBSYS_H */
hw/nvme/nvme.h renamed from hw/block/nvme.h +196 -2

210 lines not on this page · raw message

hw/nvme/trace.h new file +1 -0
new file mode 100644
index 000000000000..b398ea107f59
@@ -0,0 +1 @@
+#include "trace/trace-hw_nvme.h"
hw/nvme/ctrl.c renamed from hw/block/nvme.c +0 -1
similarity index 99%
rename from hw/block/nvme.c
rename to hw/nvme/ctrl.c
index edd0b85c10ce..71db14ce9b4b 100644
@@ -127,7 +127,6 @@
 #include "qemu/cutils.h"
 #include "trace.h"
 #include "nvme.h"
-#include "nvme-ns.h"
 
 #define NVME_MAX_IOQPAIRS 0xffff
 #define NVME_DB_SIZE  4
hw/nvme/ns.c renamed from hw/block/nvme-ns.c +0 -1
similarity index 99%
rename from hw/block/nvme-ns.c
rename to hw/nvme/ns.c
index 0e8760020483..07369d121e8f 100644
@@ -28,7 +28,6 @@
 
 #include "trace.h"
 #include "nvme.h"
-#include "nvme-ns.h"
 
 #define MIN_DISCARD_GRANULARITY (4 * KiB)
 
hw/nvme/subsys.c renamed from hw/block/nvme-subsys.c +1 -1
similarity index 98%
rename from hw/block/nvme-subsys.c
rename to hw/nvme/subsys.c
index 641de33e99fc..e5f12ed5aa16 100644
@@ -19,8 +19,8 @@
 #include "block/accounting.h"
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
+
 #include "nvme.h"
-#include "nvme-subsys.h"
 
 int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp)
 {
MAINTAINERS +1 -1
index e6f1eca30fb7..e975c5c307d4 100644
@@ -1920,7 +1920,7 @@ M: Keith Busch <[email protected]>
 M: Klaus Jensen <[email protected]>
 L: [email protected]
 S: Supported
-F: hw/block/nvme*
+F: hw/nvme/*
 F: include/block/nvme.h
 F: tests/qtest/nvme-test.c
 F: docs/specs/nvme.txt
hw/Kconfig +1 -0
index 8ea26479c485..09bf2c49113f 100644
@@ -21,6 +21,7 @@ source mem/Kconfig
 source misc/Kconfig
 source net/Kconfig
 source nubus/Kconfig
+source nvme/Kconfig
 source nvram/Kconfig
 source pci-bridge/Kconfig
 source pci-host/Kconfig
hw/block/Kconfig +0 -5
index 2d17f481adc6..c2213173ffe5 100644
@@ -22,11 +22,6 @@ config ECC
 config ONENAND
     bool
 
-config NVME_PCI
-    bool
-    default y if PCI_DEVICES
-    depends on PCI
-
 config VIRTIO_BLK
     bool
     default y
hw/block/meson.build +0 -1
index 83ea2d37978d..96697f739c09 100644
@@ -13,7 +13,6 @@ 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', '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'))
hw/block/trace-events +0 -182

188 lines not on this page · raw message

hw/meson.build +1 -0
index e615d72d4dff..e1c20db3a45d 100644
@@ -21,6 +21,7 @@ subdir('mem')
 subdir('misc')
 subdir('net')
 subdir('nubus')
+subdir('nvme')
 subdir('nvram')
 subdir('pci')
 subdir('pci-bridge')
hw/nvme/Kconfig new file +4 -0
new file mode 100644
index 000000000000..8ac90942e55e
@@ -0,0 +1,4 @@
+config NVME_PCI
+    bool
+    default y if PCI_DEVICES
+    depends on PCI
hw/nvme/meson.build new file +1 -0
new file mode 100644
index 000000000000..15c6feb8cfc4
@@ -0,0 +1 @@
+softmmu_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'ns.c', 'subsys.c'))
hw/nvme/trace-events new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
2.30.1
#1 lore raw
Quoted 8 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

With the introduction of the nvme-subsystem device we are really cluttering up the hw/block directory.

As suggested by Philippe previously, move the nvme emulation to hw/nvme.

Quoted 7 lines

---
v2:
* rebased on nvme-next
* got rid of the second patch (Minwoo)

Argh. I forgot to add Minwoo's Acked-by and the change to the commit messages that was suggested.

Anyway, would be nice to get this merged before I post v4 of the eedp series since that will add yet another file in the hw/block directory.

#2 lore raw
In reply to Klaus Jensen

Hi Klaus,

Quoted 7 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

With the introduction of the nvme-subsystem device we are really cluttering up the hw/block directory.

As suggested by Philippe previously, move the nvme emulation to hw/nvme.

Maybe type "NVMe" when talking about the technology and keep lowercase "nvme" only in paths?

Quoted 8 lines

---
v2:
* rebased on nvme-next
* got rid of the second patch (Minwoo)

Quoted 4 lines
 meson.build                               |   1 +
 hw/block/nvme-ns.h                        | 193 ---------------------
 hw/block/nvme-subsys.h                    |  32 ----
 hw/{block => nvme}/nvme.h                 | 198 +++++++++++++++++++++-

I'd split this patch in 3:

1: Add missing license in hw/block/nvme.h header

Quoted 8 lines
 hw/nvme/trace.h                           |   1 +
 hw/{block/nvme.c => nvme/ctrl.c}          |   1 -
 hw/{block/nvme-ns.c => nvme/ns.c}         |   1 -
 hw/{block/nvme-subsys.c => nvme/subsys.c} |   2 +-
 MAINTAINERS                               |   2 +-
 hw/Kconfig                                |   1 +
 hw/block/Kconfig                          |   5 -
 hw/block/meson.build                      |   1 -
Quoted 8 lines
 hw/block/trace-events                     | 182 --------------------
 hw/meson.build                            |   1 +
 hw/nvme/Kconfig                           |   4 +
 hw/nvme/meson.build                       |   1 +
 hw/nvme/trace-events                      | 180 ++++++++++++++++++++
 17 files changed, 387 insertions(+), 419 deletions(-)
 delete mode 100644 hw/block/nvme-ns.h
 delete mode 100644 hw/block/nvme-subsys.h

2: Merge nvme-ns.h & nvme-subsys.h to hw/block/nvme.h, adding
Minwoo Im (c).

Quoted 8 lines
 rename hw/{block => nvme}/nvme.h (55%)
 create mode 100644 hw/nvme/trace.h
 rename hw/{block/nvme.c => nvme/ctrl.c} (99%)
 rename hw/{block/nvme-ns.c => nvme/ns.c} (99%)
 rename hw/{block/nvme-subsys.c => nvme/subsys.c} (98%)
 create mode 100644 hw/nvme/Kconfig
 create mode 100644 hw/nvme/meson.build
 create mode 100644 hw/nvme/trace-events

3: The rest (basically this patch).

Regards,

Phil.

#3 lore raw
Quoted 60 lines · Philippe Mathieu-Daudé

Hi Klaus,

Quoted 7 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

With the introduction of the nvme-subsystem device we are really cluttering up the hw/block directory.

As suggested by Philippe previously, move the nvme emulation to hw/nvme.

Maybe type "NVMe" when talking about the technology and keep lowercase "nvme" only in paths?

Quoted 8 lines

---
v2:
* rebased on nvme-next
* got rid of the second patch (Minwoo)

Quoted 4 lines
 meson.build                               |   1 +
 hw/block/nvme-ns.h                        | 193 ---------------------
 hw/block/nvme-subsys.h                    |  32 ----
 hw/{block => nvme}/nvme.h                 | 198 +++++++++++++++++++++-

I'd split this patch in 3:

1: Add missing license in hw/block/nvme.h header

Quoted 8 lines
 hw/nvme/trace.h                           |   1 +
 hw/{block/nvme.c => nvme/ctrl.c}          |   1 -
 hw/{block/nvme-ns.c => nvme/ns.c}         |   1 -
 hw/{block/nvme-subsys.c => nvme/subsys.c} |   2 +-
 MAINTAINERS                               |   2 +-
 hw/Kconfig                                |   1 +
 hw/block/Kconfig                          |   5 -
 hw/block/meson.build                      |   1 -
Quoted 8 lines
 hw/block/trace-events                     | 182 --------------------
 hw/meson.build                            |   1 +
 hw/nvme/Kconfig                           |   4 +
 hw/nvme/meson.build                       |   1 +
 hw/nvme/trace-events                      | 180 ++++++++++++++++++++
 17 files changed, 387 insertions(+), 419 deletions(-)
 delete mode 100644 hw/block/nvme-ns.h
 delete mode 100644 hw/block/nvme-subsys.h

2: Merge nvme-ns.h & nvme-subsys.h to hw/block/nvme.h, adding
Minwoo Im (c).

Quoted 8 lines
 rename hw/{block => nvme}/nvme.h (55%)
 create mode 100644 hw/nvme/trace.h
 rename hw/{block/nvme.c => nvme/ctrl.c} (99%)
 rename hw/{block/nvme-ns.c => nvme/ns.c} (99%)
 rename hw/{block/nvme-subsys.c => nvme/subsys.c} (98%)
 create mode 100644 hw/nvme/Kconfig
 create mode 100644 hw/nvme/meson.build
 create mode 100644 hw/nvme/trace-events
Quoted 7 lines

3: The rest (basically this patch).

Regards,

Phil.

Thanks! Good suggestions, I'll respin it!