Skip to contentSkip to conversation

hw/nvme: support smart AEN

PATCH In review zhenwei pi 2 participants 5 messages May 7, 2022 – May 9, 2022

lore
Share & tools
lore

zhenwei pi

author
#0 lore raw

cover hw/nvme: support smart AEN

Hi,
In this series, firstly introduce smart related bits of aen cfg, then support this in oaes.

Linux guest does not support this currently, I also send a series to enable smart AEN:
https://lore.kernel.org/lkml/[email protected]/T/#t

Test the two series together, works fine.

Zhenwei Pi (2):
hw/nvme: introduce smart bits of aen cfg
hw/nvme: support smart AEN

 hw/nvme/ctrl.c       | 9 ++++++++-
 include/block/nvme.h | 8 +++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 1/2 hw/nvme: introduce smart bits of aen cfg

According to NVM Express v1.4, Section 5.21.1.11 (Asynchronous Event Configuration), introduce bit 0 ~ bit 5.

---
 include/block/nvme.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
include/block/nvme.h +7 -1
index 3737351cc8..d92912f9ad 100644
@@ -1122,7 +1122,13 @@ typedef struct NvmeIdCtrlNvm {
 } NvmeIdCtrlNvm;
 
 enum NvmeIdCtrlOaes {
-    NVME_OAES_NS_ATTR   = 1 << 8,
+    NVME_OAES_SMART_SPARE                 = NVME_SMART_SPARE,
+    NVME_OAES_SMART_TEMPERATURE           = NVME_SMART_TEMPERATURE,
+    NVME_OAES_SMART_RELIABILITY           = NVME_SMART_RELIABILITY,
+    NVME_OAES_SMART_MEDIA_READ_ONLY       = NVME_SMART_MEDIA_READ_ONLY,
+    NVME_OAES_SMART_FAILED_VOLATILE_MEDIA = NVME_SMART_FAILED_VOLATILE_MEDIA,
+    NVME_OAES_SMART_PMR_UNRELIABLE        = NVME_SMART_PMR_UNRELIABLE,
+    NVME_OAES_NS_ATTR                     = 1 << 8,
 };
 
 enum NvmeIdCtrlCtratt {
Signature · 1 line
2.20.1
author
#2 lore raw

PATCH 2/2 hw/nvme: support smart AEN

In reply to zhenwei pi

Support smart AEN on controller side, if the guest side enables this feature, after injecting smart critical warning, also raise AER.

This can be tested by:
virsh qemu-monitor-command vm '{ "execute": "qom-set", "arguments":
{ "path": "/machine/peripheral/nvme0",
"property": "smart_critical_warning", "value":1 } }'

---
 hw/nvme/ctrl.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/nvme/ctrl.c +8 -1
index 03760ddeae..8236a746c8 100644
@@ -6707,6 +6707,7 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
     NvmeIdCtrl *id = &n->id_ctrl;
     uint8_t *pci_conf = pci_dev->config;
     uint64_t cap = ldq_le_p(&n->bar.cap);
+    uint32_t supported_oaes;
 
     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));
@@ -6716,7 +6717,13 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
 
     id->cntlid = cpu_to_le16(n->cntlid);
 
-    id->oaes = cpu_to_le32(NVME_OAES_NS_ATTR);
+    supported_oaes = NVME_OAES_SMART_SPARE | NVME_OAES_SMART_TEMPERATURE |
+                     NVME_OAES_SMART_RELIABILITY |
+                     NVME_OAES_SMART_MEDIA_READ_ONLY |
+                     NVME_OAES_SMART_FAILED_VOLATILE_MEDIA |
+                     NVME_OAES_SMART_PMR_UNRELIABLE |
+                     NVME_OAES_NS_ATTR;
+    id->oaes = cpu_to_le32(supported_oaes);
     id->ctratt |= cpu_to_le32(NVME_CTRATT_ELBAS);
 
     id->rab = 6;
Signature · 1 line
2.20.1
#3 lore raw
In reply to zhenwei pi
Quoted 10 lines · zhenwei pi

Hi,
In this series, firstly introduce smart related bits of aen cfg, then support this in oaes.

Linux guest does not support this currently, I also send a series to enable smart AEN:
https://lore.kernel.org/lkml/[email protected]/T/#t

Test the two series together, works fine.

Quoted 8 lines

Zhenwei Pi (2):
hw/nvme: introduce smart bits of aen cfg
hw/nvme: support smart AEN

 hw/nvme/ctrl.c       | 9 ++++++++-
 include/block/nvme.h | 8 +++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

I'm not quite sure what you are trying to achieve here. Bits 0 through 7 are reserved in OAES, they are not optional.

We already simply accept whatever the host configured with the Asynchronous Event Configuration feature. And you added the support for triggering custom AENs for those through the monitor.

author
#4 lore raw
Quoted 20 lines · Klaus Jensen
Quoted 10 lines · zhenwei pi

Hi,
In this series, firstly introduce smart related bits of aen cfg, then support this in oaes.

Linux guest does not support this currently, I also send a series to enable smart AEN:
https://lore.kernel.org/lkml/[email protected]/T/#t

Test the two series together, works fine.

Quoted 8 lines

Zhenwei Pi (2):
hw/nvme: introduce smart bits of aen cfg
hw/nvme: support smart AEN

  hw/nvme/ctrl.c       | 9 ++++++++-
  include/block/nvme.h | 8 +++++++-
  2 files changed, 15 insertions(+), 2 deletions(-)
Quoted 6 lines

I'm not quite sure what you are trying to achieve here. Bits 0 through 7 are reserved in OAES, they are not optional.

We already simply accept whatever the host configured with the Asynchronous Event Configuration feature. And you added the support for triggering custom AENs for those through the monitor.

Oh, sorry, I misunderstand OAES[7:0]. Thanks for pointing this out!

Signature · 1 line
zhenwei pi