vmd: add attach_device()
This patch implements the callback for attaching devices behind the VMD with a given PCI address. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I07cf92c94cc7e6d3c8e31af7a8615e9a4ca641bf Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13886 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tom Nabarro <tom.nabarro@intel.com>
This commit is contained in:
parent
3b2097f313
commit
ffa9953a14
@ -1423,6 +1423,62 @@ spdk_vmd_hotplug_monitor(void)
|
||||
return num_hotplugs;
|
||||
}
|
||||
|
||||
static int
|
||||
vmd_attach_device(const struct spdk_pci_addr *addr)
|
||||
{
|
||||
struct vmd_pci_bus *bus;
|
||||
struct vmd_adapter *vmd;
|
||||
struct vmd_pci_device *dev;
|
||||
uint32_t i;
|
||||
int rc;
|
||||
|
||||
/* VMD always sets function to zero */
|
||||
if (addr->func != 0) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
for (i = 0; i < g_vmd_container.count; ++i) {
|
||||
vmd = &g_vmd_container.vmd[i];
|
||||
if (vmd->domain != addr->domain) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(bus, &vmd->bus_list, tailq) {
|
||||
if (bus->bus_number != addr->bus) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dev = vmd_alloc_dev(bus, addr->dev);
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Only allow attaching endpoint devices */
|
||||
if (dev->header->common.header_type & PCI_HEADER_TYPE_BRIDGE) {
|
||||
free(dev);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
rc = vmd_init_end_device(dev);
|
||||
if (rc != 0) {
|
||||
free(dev);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static struct spdk_pci_device_provider g_vmd_device_provider = {
|
||||
.name = "vmd",
|
||||
.attach_cb = vmd_attach_device,
|
||||
};
|
||||
|
||||
SPDK_PCI_REGISTER_DEVICE_PROVIDER(vmd, &g_vmd_device_provider);
|
||||
|
||||
int
|
||||
spdk_vmd_init(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user