FreeBSD kernel amd64 PCI device code
|
#include <sys/cdefs.h>
#include "opt_bus.h"
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/fcntl.h>
#include <sys/ioccom.h>
#include <sys/iov.h>
#include <sys/linker.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/pciio.h>
#include <sys/queue.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
#include <machine/bus.h>
#include <machine/stdarg.h>
#include <sys/nv.h>
#include <sys/iov_schema.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pci_iov.h>
#include <dev/pci/pci_private.h>
#include <dev/pci/pci_iov_private.h>
#include <dev/pci/schema_private.h>
#include "pcib_if.h"
Go to the source code of this file.
Macros | |
#define | IOV_READ(d, r, w) pci_read_config((d)->cfg.dev, (d)->cfg.iov->iov_pos + r, w) |
#define | IOV_WRITE(d, r, v, w) pci_write_config((d)->cfg.dev, (d)->cfg.iov->iov_pos + r, v, w) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | MALLOC_DEFINE (M_SRIOV, "sr_iov", "PCI SR-IOV allocations") |
SYSCTL_DECL (_hw_pci) | |
SYSCTL_ULONG (_hw_pci, OID_AUTO, iov_max_config, CTLFLAG_RWTUN, &pci_iov_max_config, 0, "Maximum allowed size of SR-IOV configuration.") | |
static nvlist_t * | pci_iov_build_schema (nvlist_t **pf_schema, nvlist_t **vf_schema) |
static void | pci_iov_build_pf_schema (nvlist_t *schema, nvlist_t **driver_schema) |
static void | pci_iov_build_vf_schema (nvlist_t *schema, nvlist_t **driver_schema) |
static int | pci_iov_delete_iov_children (struct pci_devinfo *dinfo) |
static nvlist_t * | pci_iov_get_pf_subsystem_schema (void) |
static nvlist_t * | pci_iov_get_vf_subsystem_schema (void) |
int | pci_iov_attach_name (device_t dev, struct nvlist *pf_schema, struct nvlist *vf_schema, const char *fmt,...) |
int | pci_iov_attach_method (device_t bus, device_t dev, nvlist_t *pf_schema, nvlist_t *vf_schema, const char *name) |
int | pci_iov_detach_method (device_t bus, device_t dev) |
static int | pci_iov_alloc_bar (struct pci_devinfo *dinfo, int bar, pci_addr_t bar_shift) |
static void | pci_iov_add_bars (struct pcicfg_iov *iov, struct pci_devinfo *dinfo) |
static int | pci_iov_parse_config (struct pcicfg_iov *iov, struct pci_iov_arg *arg, nvlist_t **ret) |
static int | pci_iov_set_ari (device_t bus) |
static int | pci_iov_config_page_size (struct pci_devinfo *dinfo) |
static int | pci_iov_init (device_t dev, uint16_t num_vfs, const nvlist_t *config) |
static int | pci_iov_init_rman (device_t pf, struct pcicfg_iov *iov) |
static int | pci_iov_alloc_bar_ea (struct pci_devinfo *dinfo, int bar) |
static int | pci_iov_setup_bars (struct pci_devinfo *dinfo) |
static void | pci_iov_enumerate_vfs (struct pci_devinfo *dinfo, const nvlist_t *config, uint16_t first_rid, uint16_t rid_stride) |
static int | pci_iov_config (struct cdev *cdev, struct pci_iov_arg *arg) |
void | pci_iov_cfg_restore (device_t dev, struct pci_devinfo *dinfo) |
void | pci_iov_cfg_save (device_t dev, struct pci_devinfo *dinfo) |
static int | pci_iov_is_child_vf (struct pcicfg_iov *pf, device_t child) |
static int | pci_iov_delete (struct cdev *cdev) |
static int | pci_iov_get_schema_ioctl (struct cdev *cdev, struct pci_iov_schema *output) |
static int | pci_iov_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) |
struct resource * | pci_vf_alloc_mem_resource (device_t dev, device_t child, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) |
int | pci_vf_release_mem_resource (device_t dev, device_t child, int rid, struct resource *r) |
Variables | |
static d_ioctl_t | pci_iov_ioctl |
static struct cdevsw | iov_cdevsw |
static u_long | pci_iov_max_config = 1024 * 1024 |
#define IOV_READ | ( | d, | |
r, | |||
w | |||
) | pci_read_config((d)->cfg.dev, (d)->cfg.iov->iov_pos + r, w) |
#define IOV_WRITE | ( | d, | |
r, | |||
v, | |||
w | |||
) | pci_write_config((d)->cfg.dev, (d)->cfg.iov->iov_pos + r, v, w) |
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
|
static |
Definition at line 371 of file pci_iov.c.
References pci_iov_bar::bar_shift, pci_iov_bar::bar_size, pcicfg_iov::iov_bar, pci_add_bar(), PCIR_BAR, PCIR_MAX_BAR_0, and pci_iov_bar::res.
Referenced by pci_iov_enumerate_vfs().
|
static |
Definition at line 340 of file pci_iov.c.
References pci_iov_bar::bar_shift, pci_iov_bar::bar_size, bus, dev, pcicfg_iov::iov_bar, pcicfg_iov::iov_num_vfs, pcicfg_iov::iov_pos, pci_alloc_multi_resource(), PCIR_SRIOV_BAR, pci_iov_bar::res, rid, pcicfg_iov::rman, and start.
Referenced by pci_iov_setup_bars().
|
static |
Definition at line 543 of file pci_iov.c.
References pci_iov_bar::bar_shift, pci_iov_bar::bar_size, pcicfg_iov::iov_bar, pcicfg_iov::iov_num_vfs, pcicfg_iov::iov_pos, pci_mapsize(), PCIR_SRIOV_BAR, pci_iov_bar::res, pcicfg_iov::rman, and start.
Referenced by pci_iov_setup_bars().
int pci_iov_attach_method | ( | device_t | bus, |
device_t | dev, | ||
nvlist_t * | pf_schema, | ||
nvlist_t * | vf_schema, | ||
const char * | name | ||
) |
Definition at line 117 of file pci_iov.c.
References dev, pcicfg_iov::iov_cdev, iov_cdevsw, pcicfg_iov::iov_pf, pcicfg_iov::iov_pos, pcicfg_iov::iov_schema, name, PCI_EXTCAP_VER, pci_iov_build_schema(), pci_iov_validate_schema(), PCIZ_SRIOV, pf_schema, and vf_schema.
int pci_iov_attach_name | ( | device_t | dev, |
struct nvlist * | pf_schema, | ||
struct nvlist * | vf_schema, | ||
const char * | fmt, | ||
... | |||
) |
|
static |
Definition at line 261 of file pci_iov.c.
References pcicfg_iov::iov_schema, pci_iov_get_pf_subsystem_schema(), pci_iov_schema_alloc_node(), and pf_schema.
Referenced by pci_iov_build_schema().
|
static |
Definition at line 231 of file pci_iov.c.
References pci_iov_build_pf_schema(), pci_iov_build_vf_schema(), pci_iov_schema_alloc_node(), and pf.
Referenced by pci_iov_attach_method().
|
static |
Definition at line 286 of file pci_iov.c.
References pcicfg_iov::iov_schema, pci_iov_get_vf_subsystem_schema(), pci_iov_schema_alloc_node(), and vf_schema.
Referenced by pci_iov_build_schema().
void pci_iov_cfg_restore | ( | device_t | dev, |
struct pci_devinfo * | dinfo | ||
) |
Definition at line 796 of file pci_iov.c.
References pcicfg_iov::iov_ctl, pcicfg_iov::iov_num_vfs, pcicfg_iov::iov_page_size, IOV_WRITE, PCIR_SRIOV_CTL, PCIR_SRIOV_NUM_VFS, and PCIR_SRIOV_PAGE_SIZE.
Referenced by pci_cfg_restore().
void pci_iov_cfg_save | ( | device_t | dev, |
struct pci_devinfo * | dinfo | ||
) |
Definition at line 808 of file pci_iov.c.
References pcicfg_iov::iov_ctl, pcicfg_iov::iov_page_size, IOV_READ, PCIR_SRIOV_CTL, and PCIR_SRIOV_PAGE_SIZE.
Referenced by pci_cfg_save().
|
static |
Definition at line 676 of file pci_iov.c.
References bus, config, dev, pcicfg_iov::iov_bar, IOV_BUSY, pcicfg_iov::iov_ctl, pcicfg_iov::iov_flags, pcicfg_iov::iov_num_vfs, pcicfg_iov::iov_pos, IOV_READ, IOV_RMAN_INITED, IOV_WRITE, num_vfs, pci_delete_resource(), pci_iov_config_get_num_vfs(), pci_iov_config_page_size(), pci_iov_enumerate_vfs(), pci_iov_init(), pci_iov_init_rman(), pci_iov_parse_config(), pci_iov_set_ari(), pci_iov_setup_bars(), pci_release_resource(), PCI_RID2BUS, PCIM_SRIOV_VF_EN, PCIM_SRIOV_VF_MSE, PCIR_MAX_BAR_0, PCIR_SRIOV_BAR, PCIR_SRIOV_CTL, PCIR_SRIOV_NUM_VFS, PCIR_SRIOV_TOTAL_VFS, PCIR_SRIOV_VF_OFF, PCIR_SRIOV_VF_STRIDE, pci_iov_bar::res, and pcicfg_iov::rman.
Referenced by pci_iov_ioctl().
|
static |
Definition at line 489 of file pci_iov.c.
References IOV_READ, IOV_WRITE, PCI_SRIOV_BASE_PAGE_SHIFT, PCIR_SRIOV_PAGE_CAP, and PCIR_SRIOV_PAGE_SIZE.
Referenced by pci_iov_config().
|
static |
Definition at line 908 of file pci_iov.c.
References IOV_BUSY, pcicfg_iov::iov_flags, pcicfg_iov::iov_num_vfs, and pci_iov_delete_iov_children().
Referenced by pci_iov_ioctl().
|
static |
Definition at line 833 of file pci_iov.c.
References bus, dev, pcicfg_iov::iov_bar, IOV_BUSY, pcicfg_iov::iov_ctl, pcicfg_iov::iov_flags, pcicfg_iov::iov_num_vfs, pcicfg_iov::iov_pos, IOV_READ, IOV_RMAN_INITED, IOV_WRITE, pci_delete_resource(), pci_iov_is_child_vf(), pci_release_resource(), PCIM_SRIOV_VF_EN, PCIM_SRIOV_VF_MSE, PCIR_MAX_BAR_0, PCIR_SRIOV_BAR, PCIR_SRIOV_CTL, PCIR_SRIOV_NUM_VFS, pci_iov_bar::res, and pcicfg_iov::rman.
Referenced by pci_iov_delete(), and pci_iov_detach_method().
int pci_iov_detach_method | ( | device_t | bus, |
device_t | dev | ||
) |
Definition at line 190 of file pci_iov.c.
References dev, IOV_BUSY, pcicfg_iov::iov_cdev, pcicfg_iov::iov_flags, pcicfg_iov::iov_schema, and pci_iov_delete_iov_children().
|
static |
Definition at line 622 of file pci_iov.c.
References bus, config, dev, did, pcicfg_iov::iov_num_vfs, IOV_READ, pci_iov_add_bars(), PCIR_SRIOV_VF_DID, and vid.
Referenced by pci_iov_config().
|
static |
Definition at line 311 of file pci_iov.c.
References pci_iov_schema_add_string(), pci_iov_schema_add_uint16(), pci_iov_schema_alloc_node(), and pf.
Referenced by pci_iov_build_pf_schema().
|
static |
Definition at line 935 of file pci_iov.c.
Referenced by pci_iov_ioctl().
|
static |
Definition at line 326 of file pci_iov.c.
References pci_iov_schema_add_bool(), and pci_iov_schema_alloc_node().
Referenced by pci_iov_build_vf_schema().
|
static |
|
static |
Definition at line 523 of file pci_iov.c.
References pcicfg_iov::iov_flags, IOV_RMAN_INITED, pf, pcicfg_iov::rman, and pcicfg_iov::rman_name.
Referenced by pci_iov_config().
|
static |
Definition at line 980 of file pci_iov.c.
References data, dev, pci_iov_config(), pci_iov_delete(), and pci_iov_get_schema_ioctl().
|
static |
|
static |
Definition at line 390 of file pci_iov.c.
References config, pcicfg_iov::iov_schema, pci_iov_max_config, and pci_iov_schema_validate_config().
Referenced by pci_iov_config().
|
static |
Definition at line 440 of file pci_iov.c.
References bus, PCIM_SRIOV_ARI_EN, PCIR_SRIOV_CTL, and PCIZ_SRIOV.
Referenced by pci_iov_config().
|
static |
Definition at line 574 of file pci_iov.c.
References dev, pcicfg_iov::iov_pos, pci_add_resources_ea(), pci_ea_is_enabled(), pci_iov_alloc_bar(), pci_iov_alloc_bar_ea(), pci_mapsize(), pci_read_bar(), PCIR_MAX_BAR_0, and PCIR_SRIOV_BAR.
Referenced by pci_iov_config().
struct resource * pci_vf_alloc_mem_resource | ( | device_t | dev, |
device_t | child, | ||
int * | rid, | ||
rman_res_t | start, | ||
rman_res_t | end, | ||
rman_res_t | count, | ||
u_int | flags | ||
) |
Definition at line 998 of file pci_iov.c.
References child, count, pci_find_bar(), pci_map::pm_size, pci_map::pm_value, rid, pcicfg_iov::rman, and start.
Referenced by pci_alloc_resource().
int pci_vf_release_mem_resource | ( | device_t | dev, |
device_t | child, | ||
int | rid, | ||
struct resource * | r | ||
) |
Definition at line 1061 of file pci_iov.c.
Referenced by pci_release_resource().
SYSCTL_DECL | ( | _hw_pci | ) |
SYSCTL_ULONG | ( | _hw_pci | , |
OID_AUTO | , | ||
iov_max_config | , | ||
CTLFLAG_RWTUN | , | ||
& | pci_iov_max_config, | ||
0 | , | ||
"Maximum allowed size of SR-IOV configuration." | |||
) |
|
static |
Definition at line 69 of file pci_iov.c.
Referenced by pci_iov_attach_method().
|
static |
Definition at line 82 of file pci_iov.c.
Referenced by pci_iov_parse_config().