mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
hw/nvme: Add support for Secondary Controller List
Introduce handling for Secondary Controller List (Identify command with CNS value of 15h). Secondary controller ids are unique in the subsystem, hence they are reserved by it upon initialization of the primary controller to the number of sriov_max_vfs. ID reservation requires the addition of an intermediate controller slot state, so the reserved controller has the address 0xFFFF. A secondary controller is in the reserved state when it has no virtual function assigned, but its primary controller is realized. Secondary controller reservations are released to NULL when its primary controller is unregistered. Signed-off-by: Lukasz Maniak <lukasz.maniak@linux.intel.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Klaus Jensen <k.jensen@samsung.com> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
This commit is contained in:
parent
5e6f963f01
commit
99f48ae7ae
6 changed files with 141 additions and 10 deletions
|
@ -43,6 +43,7 @@ typedef struct NvmeBus {
|
|||
#define TYPE_NVME_SUBSYS "nvme-subsys"
|
||||
#define NVME_SUBSYS(obj) \
|
||||
OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS)
|
||||
#define SUBSYS_SLOT_RSVD (void *)0xFFFF
|
||||
|
||||
typedef struct NvmeSubsystem {
|
||||
DeviceState parent_obj;
|
||||
|
@ -68,6 +69,10 @@ static inline NvmeCtrl *nvme_subsys_ctrl(NvmeSubsystem *subsys,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (subsys->ctrls[cntlid] == SUBSYS_SLOT_RSVD) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return subsys->ctrls[cntlid];
|
||||
}
|
||||
|
||||
|
@ -480,6 +485,7 @@ typedef struct NvmeCtrl {
|
|||
} features;
|
||||
|
||||
NvmePriCtrlCap pri_ctrl_cap;
|
||||
NvmeSecCtrlList sec_ctrl_list;
|
||||
} NvmeCtrl;
|
||||
|
||||
static inline NvmeNamespace *nvme_ns(NvmeCtrl *n, uint32_t nsid)
|
||||
|
@ -514,6 +520,18 @@ static inline uint16_t nvme_cid(NvmeRequest *req)
|
|||
return le16_to_cpu(req->cqe.cid);
|
||||
}
|
||||
|
||||
static inline NvmeSecCtrlEntry *nvme_sctrl(NvmeCtrl *n)
|
||||
{
|
||||
PCIDevice *pci_dev = &n->parent_obj;
|
||||
NvmeCtrl *pf = NVME(pcie_sriov_get_pf(pci_dev));
|
||||
|
||||
if (pci_is_vf(pci_dev)) {
|
||||
return &pf->sec_ctrl_list.sec[pcie_sriov_vf_number(pci_dev)];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void nvme_attach_ns(NvmeCtrl *n, NvmeNamespace *ns);
|
||||
uint16_t nvme_bounce_data(NvmeCtrl *n, void *ptr, uint32_t len,
|
||||
NvmeTxDirection dir, NvmeRequest *req);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue