[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v1 2/3] hw: nvme: ctrl: Initial support for DOE
From: |
Alistair Francis |
Subject: |
[RFC v1 2/3] hw: nvme: ctrl: Initial support for DOE |
Date: |
Tue, 8 Aug 2023 11:51:23 -0400 |
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
hw/nvme/nvme.h | 4 ++++
include/hw/pci/pcie_doe.h | 1 +
hw/nvme/ctrl.c | 20 ++++++++++++++++++++
3 files changed, 25 insertions(+)
diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 209e8f5b4c..e0918516e3 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -20,6 +20,7 @@
#include "qemu/uuid.h"
#include "hw/pci/pci_device.h"
+#include "hw/pci/pcie_doe.h"
#include "hw/block/block.h"
#include "block/nvme.h"
@@ -597,6 +598,9 @@ typedef struct NvmeCtrl {
uint16_t vqrfap;
uint16_t virfap;
} next_pri_ctrl_cap; /* These override pri_ctrl_cap after reset */
+
+ /* DOE */
+ DOECap doe_spdm;
} NvmeCtrl;
typedef enum NvmeResetType {
diff --git a/include/hw/pci/pcie_doe.h b/include/hw/pci/pcie_doe.h
index 87dc17dcef..18e9492977 100644
--- a/include/hw/pci/pcie_doe.h
+++ b/include/hw/pci/pcie_doe.h
@@ -46,6 +46,7 @@ REG32(PCI_DOE_CAP_STATUS, 0)
/* PCI-SIG defined Data Object Types - r6.0 Table 6-32 */
#define PCI_SIG_DOE_DISCOVERY 0x00
+#define PCI_SIG_DOE_SPDM 0x01
#define PCI_DOE_DW_SIZE_MAX (1 << 18)
#define PCI_DOE_PROTOCOL_NUM_MAX 256
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index f2e5a2fa73..ec3d5d3c29 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -202,6 +202,7 @@
#include "sysemu/block-backend.h"
#include "sysemu/hostmem.h"
#include "hw/pci/msix.h"
+#include "hw/pci/pcie_doe.h"
#include "hw/pci/pcie_sriov.h"
#include "migration/vmstate.h"
@@ -8088,6 +8089,13 @@ static int nvme_add_pm_capability(PCIDevice *pci_dev,
uint8_t offset)
return 0;
}
+#ifdef CONFIG_LIBSPDM
+static bool nvme_doe_spdm_rsp(DOECap *doe_cap)
+{
+ return false;
+}
+#endif
+
static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp)
{
ERRP_GUARD();
@@ -8317,6 +8325,13 @@ void nvme_attach_ns(NvmeCtrl *n, NvmeNamespace *ns)
BDRV_REQUEST_MAX_BYTES / nvme_l2b(ns, 1));
}
+#ifdef CONFIG_LIBSPDM
+static DOEProtocol doe_spdm_prot[] = {
+ { PCI_VENDOR_ID_PCI_SIG, PCI_SIG_DOE_SPDM, nvme_doe_spdm_rsp },
+ { }
+};
+#endif
+
static void nvme_realize(PCIDevice *pci_dev, Error **errp)
{
NvmeCtrl *n = NVME(pci_dev);
@@ -8359,6 +8374,11 @@ static void nvme_realize(PCIDevice *pci_dev, Error
**errp)
nvme_attach_ns(n, ns);
}
+
+#ifdef CONFIG_LIBSPDM
+ /* DOE Initailization */
+ pcie_doe_init(pci_dev, &n->doe_spdm, 0x190, doe_spdm_prot, true, 0);
+#endif
}
static void nvme_exit(PCIDevice *pci_dev)
--
2.41.0