FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
pci.c File Reference
+ Include dependency graph for pci.c:

Go to the source code of this file.

Data Structures

struct  linux_pci_region_t
 
struct  linux_pci_irq_t
 
struct  linux_pci_device_t
 
struct  linux_pci_main_t
 

Macros

#define pci_log_debug(vm, dev, f, ...)
 
#define pci_log_err(vm, dev, f, ...)
 

Enumerations

enum  linux_pci_device_type_t { LINUX_PCI_DEVICE_TYPE_UNKNOWN, LINUX_PCI_DEVICE_TYPE_UIO, LINUX_PCI_DEVICE_TYPE_VFIO }
 

Functions

static linux_pci_device_tlinux_pci_get_device (vlib_pci_dev_handle_t h)
 
uword vlib_pci_get_private_data (vlib_main_t *vm, vlib_pci_dev_handle_t h)
 
void vlib_pci_set_private_data (vlib_main_t *vm, vlib_pci_dev_handle_t h, uword private_data)
 
vlib_pci_addr_t * vlib_pci_get_addr (vlib_main_t *vm, vlib_pci_dev_handle_t h)
 
u32 vlib_pci_get_numa_node (vlib_main_t *vm, vlib_pci_dev_handle_t h)
 
u32 vlib_pci_get_num_msix_interrupts (vlib_main_t *vm, vlib_pci_dev_handle_t h)
 
clib_error_tpci_bus_init (vlib_main_t *vm)
 
vlib_pci_device_info_tvlib_pci_get_device_info (vlib_main_t *vm, vlib_pci_addr_t *addr, clib_error_t **error)
 
static int directory_exists (char *path)
 
clib_error_tvlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr, char *uio_drv_name)
 
static clib_error_tscan_uio_dir (void *arg, u8 *path_name, u8 *file_name)
 
static clib_error_tvfio_set_irqs (vlib_main_t *vm, linux_pci_device_t *p, u32 index, u32 start, u32 count, u32 flags, int *efds)
 
static clib_error_tlinux_pci_uio_read_ready (clib_file_t *uf)
 
static clib_error_tlinux_pci_vfio_unmask_intx (vlib_main_t *vm, linux_pci_device_t *d)
 
static clib_error_tlinux_pci_uio_error_ready (clib_file_t *uf)
 
static clib_error_tlinux_pci_vfio_msix_read_ready (clib_file_t *uf)
 
static clib_error_tlinux_pci_vfio_intx_read_ready (clib_file_t *uf)
 
static clib_error_tlinux_pci_vfio_error_ready (clib_file_t *uf)
 
static clib_error_tadd_device_uio (vlib_main_t *vm, linux_pci_device_t *p, vlib_pci_device_info_t *di, pci_device_registration_t *r)
 
clib_error_tvlib_pci_register_intx_handler (vlib_main_t *vm, vlib_pci_dev_handle_t h, pci_intx_handler_function_t *intx_handler)
 
clib_error_tvlib_pci_register_msix_handler (vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 start, u32 count, pci_msix_handler_function_t *msix_handler)
 
clib_error_tvlib_pci_enable_msix_irq (vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 start, u16 count)
 
clib_error_tvlib_pci_disable_msix_irq (vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 start, u16 count)
 
static clib_error_tadd_device_vfio (vlib_main_t *vm, linux_pci_device_t *p, vlib_pci_device_info_t *di, pci_device_registration_t *r)
 
clib_error_tvlib_pci_read_write_config (vlib_main_t *vm, vlib_pci_dev_handle_t h, vlib_read_or_write_t read_or_write, uword address, void *data, u32 n_bytes)
 
static clib_error_tvlib_pci_region (vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 bar, int *fd, u64 *size, u64 *offset)
 
static clib_error_tvlib_pci_map_region_int (vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 bar, u8 *addr, void **result)
 
clib_error_tvlib_pci_map_region (vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 resource, void **result)
 
clib_error_tvlib_pci_map_region_fixed (vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 resource, u8 *addr, void **result)
 
clib_error_tvlib_pci_io_region (vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 resource)
 
clib_error_tvlib_pci_read_write_io (vlib_main_t *vm, vlib_pci_dev_handle_t h, vlib_read_or_write_t read_or_write, uword offset, void *data, u32 length)
 
clib_error_tvlib_pci_map_dma (vlib_main_t *vm, vlib_pci_dev_handle_t h, void *ptr)
 
int vlib_pci_supports_virtual_addr_dma (vlib_main_t *vm, vlib_pci_dev_handle_t h)
 
clib_error_tvlib_pci_device_open (vlib_main_t *vm, vlib_pci_addr_t *addr, pci_device_id_t ids[], vlib_pci_dev_handle_t *handle)
 
void vlib_pci_device_close (vlib_main_t *vm, vlib_pci_dev_handle_t h)
 
void init_device_from_registered (vlib_main_t *vm, vlib_pci_device_info_t *di)
 
static clib_error_tscan_pci_addr (void *arg, u8 *dev_dir_name, u8 *ignored)
 
static int pci_addr_cmp (void *v1, void *v2)
 
vlib_pci_addr_t * vlib_pci_get_all_dev_addrs ()
 
clib_error_tlinux_pci_init (vlib_main_t *vm)
 

Variables

static const char * sysfs_pci_dev_path = "/sys/bus/pci/devices"
 
static const char * sysfs_pci_drv_path = "/sys/bus/pci/drivers"
 
static char * sysfs_mod_vfio_noiommu
 
linux_pci_main_t linux_pci_main
 

Macro Definition Documentation

◆ pci_log_debug

#define pci_log_debug (   vm,
  dev,
  f,
  ... 
)
Value:
vlib_log(VLIB_LOG_LEVEL_DEBUG, pci_main.log_default, "%U: " f, \
format_vlib_pci_addr(), vlib_pci_get_addr(vm, dev->handle), ## __VA_ARGS__)
vlib_pci_main_t pci_main
Definition: pci.c:53
u8 * format_vlib_pci_addr(u8 *s, va_list *va)
Definition: pci.c:141
vlib_main_t * vm
Definition: buffer.c:323
void vlib_log(vlib_log_level_t level, vlib_log_class_t class, char *fmt,...)
Definition: log.c:87
vlib_pci_addr_t * vlib_pci_get_addr(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:163
vlib_log_class_t log_default
Definition: pci.h:158

Definition at line 63 of file pci.c.

◆ pci_log_err

#define pci_log_err (   vm,
  dev,
  f,
  ... 
)
Value:
vlib_log(VLIB_LOG_LEVEL_ERR, pci_main.log_default, "%U: " f, \
format_vlib_pci_addr(), vlib_pci_get_addr(vm, dev->handle), ## __VA_ARGS__)
vlib_pci_main_t pci_main
Definition: pci.c:53
u8 * format_vlib_pci_addr(u8 *s, va_list *va)
Definition: pci.c:141
vlib_main_t * vm
Definition: buffer.c:323
void vlib_log(vlib_log_level_t level, vlib_log_class_t class, char *fmt,...)
Definition: log.c:87
vlib_pci_addr_t * vlib_pci_get_addr(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:163
vlib_log_class_t log_default
Definition: pci.h:158

Definition at line 66 of file pci.c.

Enumeration Type Documentation

◆ linux_pci_device_type_t

Enumerator
LINUX_PCI_DEVICE_TYPE_UNKNOWN 
LINUX_PCI_DEVICE_TYPE_UIO 
LINUX_PCI_DEVICE_TYPE_VFIO 

Definition at line 88 of file pci.c.

Function Documentation

◆ add_device_uio()

static clib_error_t* add_device_uio ( vlib_main_t vm,
linux_pci_device_t p,
vlib_pci_device_info_t di,
pci_device_registration_t r 
)
static

Definition at line 730 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_device_vfio()

static clib_error_t* add_device_vfio ( vlib_main_t vm,
linux_pci_device_t p,
vlib_pci_device_info_t di,
pci_device_registration_t r 
)
static

Definition at line 934 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ directory_exists()

static int directory_exists ( char *  path)
static

Definition at line 387 of file pci.c.

+ Here is the caller graph for this function:

◆ init_device_from_registered()

void init_device_from_registered ( vlib_main_t vm,
vlib_pci_device_info_t di 
)

Definition at line 1354 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ linux_pci_get_device()

static linux_pci_device_t* linux_pci_get_device ( vlib_pci_dev_handle_t  h)
static

Definition at line 141 of file pci.c.

+ Here is the caller graph for this function:

◆ linux_pci_init()

clib_error_t* linux_pci_init ( vlib_main_t vm)

Definition at line 1459 of file pci.c.

+ Here is the call graph for this function:

◆ linux_pci_uio_error_ready()

static clib_error_t* linux_pci_uio_error_ready ( clib_file_t uf)
static

Definition at line 675 of file pci.c.

+ Here is the caller graph for this function:

◆ linux_pci_uio_read_ready()

static clib_error_t* linux_pci_uio_read_ready ( clib_file_t uf)
static

Definition at line 648 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ linux_pci_vfio_error_ready()

static clib_error_t* linux_pci_vfio_error_ready ( clib_file_t uf)
static

Definition at line 722 of file pci.c.

+ Here is the caller graph for this function:

◆ linux_pci_vfio_intx_read_ready()

static clib_error_t* linux_pci_vfio_intx_read_ready ( clib_file_t uf)
static

Definition at line 702 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ linux_pci_vfio_msix_read_ready()

static clib_error_t* linux_pci_vfio_msix_read_ready ( clib_file_t uf)
static

Definition at line 683 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ linux_pci_vfio_unmask_intx()

static clib_error_t* linux_pci_vfio_unmask_intx ( vlib_main_t vm,
linux_pci_device_t d 
)
static

Definition at line 668 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pci_addr_cmp()

static int pci_addr_cmp ( void *  v1,
void *  v2 
)
static

Definition at line 1416 of file pci.c.

+ Here is the caller graph for this function:

◆ pci_bus_init()

clib_error_t* pci_bus_init ( vlib_main_t vm)

Definition at line 252 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scan_pci_addr()

static clib_error_t* scan_pci_addr ( void *  arg,
u8 dev_dir_name,
u8 ignored 
)
static

Definition at line 1393 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scan_uio_dir()

static clib_error_t* scan_uio_dir ( void *  arg,
u8 path_name,
u8 file_name 
)
static

Definition at line 577 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vfio_set_irqs()

static clib_error_t* vfio_set_irqs ( vlib_main_t vm,
linux_pci_device_t p,
u32  index,
u32  start,
u32  count,
u32  flags,
int *  efds 
)
static

Definition at line 592 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_bind_to_uio()

clib_error_t* vlib_pci_bind_to_uio ( vlib_main_t vm,
vlib_pci_addr_t *  addr,
char *  uio_drv_name 
)

Definition at line 397 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_device_close()

void vlib_pci_device_close ( vlib_main_t vm,
vlib_pci_dev_handle_t  h 
)

Definition at line 1286 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_device_open()

clib_error_t* vlib_pci_device_open ( vlib_main_t vm,
vlib_pci_addr_t *  addr,
pci_device_id_t  ids[],
vlib_pci_dev_handle_t handle 
)

Definition at line 1226 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_disable_msix_irq()

clib_error_t* vlib_pci_disable_msix_irq ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
u16  start,
u16  count 
)

Definition at line 916 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_enable_msix_irq()

clib_error_t* vlib_pci_enable_msix_irq ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
u16  start,
u16  count 
)

Definition at line 894 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_get_addr()

vlib_pci_addr_t* vlib_pci_get_addr ( vlib_main_t vm,
vlib_pci_dev_handle_t  h 
)

Definition at line 163 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_get_all_dev_addrs()

vlib_pci_addr_t* vlib_pci_get_all_dev_addrs ( )

Definition at line 1441 of file pci.c.

+ Here is the caller graph for this function:

◆ vlib_pci_get_device_info()

vlib_pci_device_info_t* vlib_pci_get_device_info ( vlib_main_t vm,
vlib_pci_addr_t *  addr,
clib_error_t **  error 
)

Definition at line 202 of file pci.c.

+ Here is the caller graph for this function:

◆ vlib_pci_get_num_msix_interrupts()

u32 vlib_pci_get_num_msix_interrupts ( vlib_main_t vm,
vlib_pci_dev_handle_t  h 
)

Definition at line 177 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_get_numa_node()

u32 vlib_pci_get_numa_node ( vlib_main_t vm,
vlib_pci_dev_handle_t  h 
)

Definition at line 170 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_get_private_data()

uword vlib_pci_get_private_data ( vlib_main_t vm,
vlib_pci_dev_handle_t  h 
)

Definition at line 148 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_io_region()

clib_error_t* vlib_pci_io_region ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
u32  resource 
)

Definition at line 1171 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_map_dma()

clib_error_t* vlib_pci_map_dma ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
void *  ptr 
)

Definition at line 1207 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_map_region()

clib_error_t* vlib_pci_map_region ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
u32  resource,
void **  result 
)

Definition at line 1157 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_map_region_fixed()

clib_error_t* vlib_pci_map_region_fixed ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
u32  resource,
u8 addr,
void **  result 
)

Definition at line 1164 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_map_region_int()

static clib_error_t* vlib_pci_map_region_int ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
u32  bar,
u8 addr,
void **  result 
)
static

Definition at line 1119 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_read_write_config()

clib_error_t* vlib_pci_read_write_config ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
vlib_read_or_write_t  read_or_write,
uword  address,
void *  data,
u32  n_bytes 
)

Definition at line 1028 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_read_write_io()

clib_error_t* vlib_pci_read_write_io ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
vlib_read_or_write_t  read_or_write,
uword  offset,
void *  data,
u32  length 
)

Definition at line 1187 of file pci.c.

+ Here is the call graph for this function:

◆ vlib_pci_region()

static clib_error_t* vlib_pci_region ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
u32  bar,
int *  fd,
u64 size,
u64 offset 
)
static

Definition at line 1049 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_register_intx_handler()

clib_error_t* vlib_pci_register_intx_handler ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
pci_intx_handler_function_t intx_handler 
)

Definition at line 786 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_register_msix_handler()

clib_error_t* vlib_pci_register_msix_handler ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
u32  start,
u32  count,
pci_msix_handler_function_t msix_handler 
)

Definition at line 837 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_set_private_data()

void vlib_pci_set_private_data ( vlib_main_t vm,
vlib_pci_dev_handle_t  h,
uword  private_data 
)

Definition at line 155 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlib_pci_supports_virtual_addr_dma()

int vlib_pci_supports_virtual_addr_dma ( vlib_main_t vm,
vlib_pci_dev_handle_t  h 
)

Definition at line 1218 of file pci.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ linux_pci_main

linux_pci_main_t linux_pci_main

Definition at line 199 of file pci.c.

◆ sysfs_mod_vfio_noiommu

char* sysfs_mod_vfio_noiommu
static
Initial value:
=
"/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"

Definition at line 60 of file pci.c.

◆ sysfs_pci_dev_path

const char* sysfs_pci_dev_path = "/sys/bus/pci/devices"
static

Definition at line 58 of file pci.c.

◆ sysfs_pci_drv_path

const char* sysfs_pci_drv_path = "/sys/bus/pci/drivers"
static

Definition at line 59 of file pci.c.