DPDK  2.0.0
Data Structures | Macros | Typedefs | Functions | Variables
rte_pci.h File Reference
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <sys/queue.h>
#include <stdint.h>
#include <inttypes.h>
#include <rte_interrupts.h>

Data Structures

struct  rte_pci_resource
struct  rte_pci_id
struct  rte_pci_addr
struct  rte_pci_device
struct  rte_pci_driver

Macros

#define SYSFS_PCI_DEVICES   "/sys/bus/pci/devices"
#define PCI_PRI_FMT   "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
#define PCI_SHORT_PRI_FMT   "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
#define PCI_FMT_NVAL   4
#define PCI_RESOURCE_FMT_NVAL   3
#define IORESOURCE_MEM   0x00000200
#define PCI_MAX_RESOURCE   6
#define PCI_ANY_ID   (0xffff)
#define RTE_PCI_DEVICE(vend, dev)
#define RTE_PCI_DRV_NEED_MAPPING   0x0001
#define RTE_PCI_DRV_FORCE_UNBIND   0x0004
#define RTE_PCI_DRV_INTR_LSC   0x0008
#define RTE_PCI_DRV_DETACHABLE   0x0010

Typedefs

typedef int( pci_devinit_t )(struct rte_pci_driver *, struct rte_pci_device *)
typedef int( pci_devuninit_t )(struct rte_pci_device *)

Functions

 TAILQ_HEAD (pci_device_list, rte_pci_device)
 TAILQ_HEAD (pci_driver_list, rte_pci_driver)
static int eal_parse_pci_BDF (const char *input, struct rte_pci_addr *dev_addr)
static int eal_parse_pci_DomBDF (const char *input, struct rte_pci_addr *dev_addr)
static int rte_eal_compare_pci_addr (struct rte_pci_addr *addr, struct rte_pci_addr *addr2)
int rte_eal_pci_scan (void)
int rte_eal_pci_probe (void)
void rte_eal_pci_dump (FILE *f)
void rte_eal_pci_register (struct rte_pci_driver *driver)
void rte_eal_pci_unregister (struct rte_pci_driver *driver)

Variables

struct pci_driver_list pci_driver_list
struct pci_device_list pci_device_list

Detailed Description

RTE PCI Interface

Macro Definition Documentation

#define IORESOURCE_MEM   0x00000200

IO resource type: memory address space

#define PCI_ANY_ID   (0xffff)

Any PCI device identifier (vendor, device, ...)

#define PCI_FMT_NVAL   4

Nb. of values in PCI device identifier format string.

#define PCI_MAX_RESOURCE   6

Maximum number of PCI resources.

#define PCI_PRI_FMT   "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8

Formatting string for PCI device identifier: Ex: 0000:00:01.0

#define PCI_RESOURCE_FMT_NVAL   3

Nb. of values in PCI resource format.

#define PCI_SHORT_PRI_FMT   "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8

Short formatting string, without domain, for PCI device: Ex: 00:01.0

#define RTE_PCI_DEVICE (   vend,
  dev 
)
Value:
.vendor_id = (vend), \
.device_id = (dev), \
.subsystem_vendor_id = PCI_ANY_ID, \
.subsystem_device_id = PCI_ANY_ID

Macro used to help building up tables of device IDs

#define RTE_PCI_DRV_DETACHABLE   0x0010

Device driver supports detaching capability Internal use only - Macro used by pci addr parsing functions

#define RTE_PCI_DRV_FORCE_UNBIND   0x0004

Device driver must be registered several times until failure - deprecated Device needs to be unbound even if no module is provided

#define RTE_PCI_DRV_INTR_LSC   0x0008

Device driver supports link state interrupt

#define RTE_PCI_DRV_NEED_MAPPING   0x0001

Device needs PCI BAR mapping (done with either IGB_UIO or VFIO)

#define SYSFS_PCI_DEVICES   "/sys/bus/pci/devices"

Pathname of PCI devices directory.

Typedef Documentation

typedef int( pci_devinit_t)(struct rte_pci_driver *, struct rte_pci_device *)

Initialisation function for the driver called during PCI probing.

typedef int( pci_devuninit_t)(struct rte_pci_device *)

Uninitialisation function for the driver called during hotplugging.

Function Documentation

static int eal_parse_pci_BDF ( const char *  input,
struct rte_pci_addr dev_addr 
)
inlinestatic

Utility function to produce a PCI Bus-Device-Function value given a string representation. Assumes that the BDF is provided without a domain prefix (i.e. domain returned is always 0)

Parameters
inputThe input string to be parsed. Should have the format XX:XX.X
dev_addrThe PCI Bus-Device-Function address to be returned. Domain will always be returned as 0
Returns
0 on success, negative on error.
static int eal_parse_pci_DomBDF ( const char *  input,
struct rte_pci_addr dev_addr 
)
inlinestatic

Utility function to produce a PCI Bus-Device-Function value given a string representation. Assumes that the BDF is provided including a domain prefix.

Parameters
inputThe input string to be parsed. Should have the format XXXX:XX:XX.X
dev_addrThe PCI Bus-Device-Function address to be returned
Returns
0 on success, negative on error.
static int rte_eal_compare_pci_addr ( struct rte_pci_addr addr,
struct rte_pci_addr addr2 
)
inlinestatic

Utility function to compare two PCI device addresses.

Parameters
addrThe PCI Bus-Device-Function address to compare
addr2The PCI Bus-Device-Function address to compare
Returns
0 on equal PCI address. Positive on addr is greater than addr2. Negative on addr is less than addr2, or error.
void rte_eal_pci_dump ( FILE *  f)

Dump the content of the PCI bus.

Parameters
fA pointer to a file for output
int rte_eal_pci_probe ( void  )

Probe the PCI bus for registered drivers.

Scan the content of the PCI bus, and call the probe() function for all registered drivers that have a matching entry in its id_table for discovered devices.

Returns
  • 0 on success.
  • Negative on error.
void rte_eal_pci_register ( struct rte_pci_driver driver)

Register a PCI driver.

Parameters
driverA pointer to a rte_pci_driver structure describing the driver to be registered.
int rte_eal_pci_scan ( void  )

Scan the content of the PCI bus, and the devices in the devices list

Returns
0 on success, negative on error
void rte_eal_pci_unregister ( struct rte_pci_driver driver)

Unregister a PCI driver.

Parameters
driverA pointer to a rte_pci_driver structure describing the driver to be unregistered.
TAILQ_HEAD ( pci_device_list  ,
rte_pci_device   
)

PCI devices in D-linked Q.

TAILQ_HEAD ( pci_driver_list  ,
rte_pci_driver   
)

PCI drivers in D-linked Q.

Variable Documentation

struct pci_device_list pci_device_list

Global list of PCI devices.

struct pci_driver_list pci_driver_list

Global list of PCI drivers.