diff options
| -rw-r--r-- | sys/dev/pci/pci.c | [diff] [file] | 25 | ||||
| -rw-r--r-- | sys/dev/pci/pci_iov.c | [diff] [file] | 1 | ||||
| -rw-r--r-- | sys/dev/pci/pci_private.h | [diff] [file] | 1 |
3 files changed, 26 insertions, 1 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index e947d9b4f6b4..becda495f92a 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -4395,9 +4395,22 @@ pci_rescan_method(device_t dev) #ifdef PCI_IOV device_t +pci_iov_get_pf(device_t dev) +{ + struct pci_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + if (dinfo == NULL || (dinfo->cfg.flags & PCICFG_VF) == 0 || + dinfo->cfg.iov == NULL) + return (NULL); + return (dinfo->cfg.iov->iov_pf); +} + +device_t pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid, uint16_t did) { + struct pci_devinfo *pf_dinfo; struct pci_devinfo *vf_dinfo; device_t pcib; int busno, slot, func; @@ -4409,6 +4422,11 @@ pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid, vf_dinfo = pci_fill_devinfo(pcib, bus, pci_get_domain(pcib), busno, slot, func, vid, did); + /* Make the VF-to-PF relationship available to child-added callbacks. */ + pf_dinfo = device_get_ivars(pf); + KASSERT(pf_dinfo->cfg.iov != NULL, + ("SR-IOV PF %s has no IOV state", device_get_nameunit(pf))); + vf_dinfo->cfg.iov = pf_dinfo->cfg.iov; vf_dinfo->cfg.flags |= PCICFG_VF; pci_add_child(bus, vf_dinfo); @@ -4422,6 +4440,13 @@ pci_create_iov_child_method(device_t bus, device_t pf, uint16_t rid, return (pci_add_iov_child(bus, pf, rid, vid, did)); } +#else +device_t +pci_iov_get_pf(device_t dev __unused) +{ + + return (NULL); +} #endif static int diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c index ecae70ca0d4a..60547983277d 100644 --- a/sys/dev/pci/pci_iov.c +++ b/sys/dev/pci/pci_iov.c @@ -658,7 +658,6 @@ pci_iov_enumerate_vfs(struct pci_devinfo *dinfo, const nvlist_t *config, vfinfo = device_get_ivars(vf); - vfinfo->cfg.iov = iov; vfinfo->cfg.vf.index = i; pci_iov_add_bars(iov, vfinfo); diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h index 0b20f20fbb42..9dd03e56bd14 100644 --- a/sys/dev/pci/pci_private.h +++ b/sys/dev/pci/pci_private.h @@ -120,6 +120,7 @@ void pci_add_children(device_t dev, int domain, int busno); void pci_add_child(device_t bus, struct pci_devinfo *dinfo); /* Call after cold enumeration and before attaching the bus's children. */ void pcie_reconcile_link_mps(device_t bus); +device_t pci_iov_get_pf(device_t dev); device_t pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid, uint16_t did); void pci_add_resources(device_t bus, device_t dev, int force, |
