Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/pci/pci_iov.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#include <dev/pci/pcireg.h> | #include <dev/pci/pcireg.h> | ||||
#include <dev/pci/pcivar.h> | #include <dev/pci/pcivar.h> | ||||
#include <dev/pci/pci_private.h> | #include <dev/pci/pci_private.h> | ||||
#include <dev/pci/pci_iov_private.h> | #include <dev/pci/pci_iov_private.h> | ||||
#include <dev/pci/schema_private.h> | #include <dev/pci/schema_private.h> | ||||
#include "pci_if.h" | #include "pci_if.h" | ||||
#include "pci_iov_if.h" | |||||
#include "pcib_if.h" | #include "pcib_if.h" | ||||
static MALLOC_DEFINE(M_SRIOV, "sr_iov", "PCI SR-IOV allocations"); | static MALLOC_DEFINE(M_SRIOV, "sr_iov", "PCI SR-IOV allocations"); | ||||
static d_ioctl_t pci_iov_ioctl; | static d_ioctl_t pci_iov_ioctl; | ||||
static struct cdevsw iov_cdevsw = { | static struct cdevsw iov_cdevsw = { | ||||
.d_version = D_VERSION, | .d_version = D_VERSION, | ||||
▲ Show 20 Lines • Show All 409 Lines • ▼ Show 20 Lines | pci_iov_config_page_size(struct pci_devinfo *dinfo) | ||||
if (!(page_size & page_cap)) | if (!(page_size & page_cap)) | ||||
return (ENXIO); | return (ENXIO); | ||||
IOV_WRITE(dinfo, PCIR_SRIOV_PAGE_SIZE, page_size, 4); | IOV_WRITE(dinfo, PCIR_SRIOV_PAGE_SIZE, page_size, 4); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
pci_init_iov(device_t dev, uint16_t num_vfs, const nvlist_t *config) | pci_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *config) | ||||
{ | { | ||||
const nvlist_t *device, *driver_config; | const nvlist_t *device, *driver_config; | ||||
device = nvlist_get_nvlist(config, PF_CONFIG_NAME); | device = nvlist_get_nvlist(config, PF_CONFIG_NAME); | ||||
driver_config = nvlist_get_nvlist(device, DRIVER_CONFIG_NAME); | driver_config = nvlist_get_nvlist(device, DRIVER_CONFIG_NAME); | ||||
return (PCI_INIT_IOV(dev, num_vfs, driver_config)); | return (PCI_IOV_INIT(dev, num_vfs, driver_config)); | ||||
} | } | ||||
static int | static int | ||||
pci_iov_init_rman(device_t pf, struct pcicfg_iov *iov) | pci_iov_init_rman(device_t pf, struct pcicfg_iov *iov) | ||||
{ | { | ||||
int error; | int error; | ||||
iov->rman.rm_start = 0; | iov->rman.rm_start = 0; | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | for (i = 0; i < iov->iov_num_vfs; i++, next_rid += rid_stride) { | ||||
vfinfo = device_get_ivars(vf); | vfinfo = device_get_ivars(vf); | ||||
vfinfo->cfg.iov = iov; | vfinfo->cfg.iov = iov; | ||||
vfinfo->cfg.vf.index = i; | vfinfo->cfg.vf.index = i; | ||||
pci_iov_add_bars(iov, vfinfo); | pci_iov_add_bars(iov, vfinfo); | ||||
error = PCI_ADD_VF(dev, i, driver_config); | error = PCI_IOV_ADD_VF(dev, i, driver_config); | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(dev, "Failed to add VF %d\n", i); | device_printf(dev, "Failed to add VF %d\n", i); | ||||
pci_delete_child(bus, vf); | pci_delete_child(bus, vf); | ||||
} | } | ||||
} | } | ||||
bus_generic_attach(bus); | bus_generic_attach(bus); | ||||
} | } | ||||
Show All 40 Lines | pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg) | ||||
error = pci_iov_config_page_size(dinfo); | error = pci_iov_config_page_size(dinfo); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
error = pci_iov_set_ari(bus); | error = pci_iov_set_ari(bus); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
error = pci_init_iov(dev, num_vfs, config); | error = pci_iov_init(dev, num_vfs, config); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
iov_inited = 1; | iov_inited = 1; | ||||
IOV_WRITE(dinfo, PCIR_SRIOV_NUM_VFS, num_vfs, 2); | IOV_WRITE(dinfo, PCIR_SRIOV_NUM_VFS, num_vfs, 2); | ||||
rid_off = IOV_READ(dinfo, PCIR_SRIOV_VF_OFF, 2); | rid_off = IOV_READ(dinfo, PCIR_SRIOV_VF_OFF, 2); | ||||
rid_stride = IOV_READ(dinfo, PCIR_SRIOV_VF_STRIDE, 2); | rid_stride = IOV_READ(dinfo, PCIR_SRIOV_VF_STRIDE, 2); | ||||
Show All 31 Lines | pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg) | ||||
nvlist_destroy(config); | nvlist_destroy(config); | ||||
iov->iov_flags &= ~IOV_BUSY; | iov->iov_flags &= ~IOV_BUSY; | ||||
mtx_unlock(&Giant); | mtx_unlock(&Giant); | ||||
return (0); | return (0); | ||||
out: | out: | ||||
if (iov_inited) | if (iov_inited) | ||||
PCI_UNINIT_IOV(dev); | IOV_UNINIT(dev); | ||||
rstone: I think that you meant PCI_IOV_UNINIT() here | |||||
for (i = 0; i <= PCIR_MAX_BAR_0; i++) { | for (i = 0; i <= PCIR_MAX_BAR_0; i++) { | ||||
if (iov->iov_bar[i].res != NULL) { | if (iov->iov_bar[i].res != NULL) { | ||||
pci_release_resource(bus, dev, SYS_RES_MEMORY, | pci_release_resource(bus, dev, SYS_RES_MEMORY, | ||||
iov->iov_pos + PCIR_SRIOV_BAR(i), | iov->iov_pos + PCIR_SRIOV_BAR(i), | ||||
iov->iov_bar[i].res); | iov->iov_bar[i].res); | ||||
pci_delete_resource(bus, dev, SYS_RES_MEMORY, | pci_delete_resource(bus, dev, SYS_RES_MEMORY, | ||||
iov->iov_pos + PCIR_SRIOV_BAR(i)); | iov->iov_pos + PCIR_SRIOV_BAR(i)); | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | pci_iov_delete(struct cdev *cdev) | ||||
} | } | ||||
for (i = 0; i < devcount; i++) { | for (i = 0; i < devcount; i++) { | ||||
vf = devlist[i]; | vf = devlist[i]; | ||||
if (pci_iov_is_child_vf(iov, vf)) | if (pci_iov_is_child_vf(iov, vf)) | ||||
pci_delete_child(bus, vf); | pci_delete_child(bus, vf); | ||||
} | } | ||||
PCI_UNINIT_IOV(dev); | PCI_IOV_UNINIT(dev); | ||||
iov_ctl = IOV_READ(dinfo, PCIR_SRIOV_CTL, 2); | iov_ctl = IOV_READ(dinfo, PCIR_SRIOV_CTL, 2); | ||||
iov_ctl &= ~(PCIM_SRIOV_VF_EN | PCIM_SRIOV_VF_MSE); | iov_ctl &= ~(PCIM_SRIOV_VF_EN | PCIM_SRIOV_VF_MSE); | ||||
IOV_WRITE(dinfo, PCIR_SRIOV_CTL, iov_ctl, 2); | IOV_WRITE(dinfo, PCIR_SRIOV_CTL, iov_ctl, 2); | ||||
IOV_WRITE(dinfo, PCIR_SRIOV_NUM_VFS, 0, 2); | IOV_WRITE(dinfo, PCIR_SRIOV_NUM_VFS, 0, 2); | ||||
iov->iov_num_vfs = 0; | iov->iov_num_vfs = 0; | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |
I think that you meant PCI_IOV_UNINIT() here