hw/nvme: support smart AEN
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
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
@@ -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
PATCH 2/2 hw/nvme: support smart AEN
In reply to zhenwei piSupport 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
@@ -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
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/#tTest the two series together, works fine.
Quoted 8 lines
Zhenwei Pi (2):
hw/nvme: introduce smart bits of aen cfg
hw/nvme: support smart AENhw/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.
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/#tTest the two series together, works fine.
Quoted 8 lines
Zhenwei Pi (2):
hw/nvme: introduce smart bits of aen cfg
hw/nvme: support smart AENhw/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