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

Go to the source code of this file.

Data Structures

struct  rte_pci_id
 
struct  rte_pci_addr
 
struct  rte_pci_device
 
struct  rte_pci_driver
 
struct  pci_map
 
struct  mapped_pci_resource
 
struct  rte_pci_ioport
 

Macros

#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 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
 
#define RTE_PMD_REGISTER_PCI(nm, pci_drv)
 

Typedefs

typedef int( pci_probe_t) (struct rte_pci_driver *, struct rte_pci_device *)
 
typedef int( pci_remove_t) (struct rte_pci_device *)
 

Functions

 TAILQ_HEAD (pci_device_list, rte_pci_device)
 
 TAILQ_HEAD (pci_driver_list, rte_pci_driver)
 
const char * pci_get_sysfs_path (void)
 
 TAILQ_HEAD (mapped_pci_res_list, mapped_pci_resource)
 
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 void rte_eal_pci_device_name (const struct rte_pci_addr *addr, char *output, size_t size)
 
static int rte_eal_compare_pci_addr (const struct rte_pci_addr *addr, const struct rte_pci_addr *addr2)
 
int rte_eal_pci_scan (void)
 
int rte_eal_pci_probe (void)
 
int rte_eal_pci_map_device (struct rte_pci_device *dev)
 
void rte_eal_pci_unmap_device (struct rte_pci_device *dev)
 
int rte_eal_pci_probe_one (const struct rte_pci_addr *addr)
 
int rte_eal_pci_detach (const struct rte_pci_addr *addr)
 
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)
 
int rte_eal_pci_read_config (const struct rte_pci_device *device, void *buf, size_t len, off_t offset)
 
int rte_eal_pci_write_config (const struct rte_pci_device *device, const void *buf, size_t len, off_t offset)
 
int rte_eal_pci_ioport_map (struct rte_pci_device *dev, int bar, struct rte_pci_ioport *p)
 
int rte_eal_pci_ioport_unmap (struct rte_pci_ioport *p)
 
void rte_eal_pci_ioport_read (struct rte_pci_ioport *p, void *data, size_t len, off_t offset)
 
void rte_eal_pci_ioport_write (struct rte_pci_ioport *p, const void *data, size_t len, off_t offset)
 

Variables

struct pci_driver_list pci_driver_list
 
struct pci_device_list pci_device_list
 

Detailed Description

RTE PCI Interface

Definition in file rte_pci.h.

Macro Definition Documentation

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

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

Definition at line 99 of file rte_pci.h.

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

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

Definition at line 103 of file rte_pci.h.

#define PCI_FMT_NVAL   4

Nb. of values in PCI device identifier format string.

Definition at line 106 of file rte_pci.h.

#define PCI_RESOURCE_FMT_NVAL   3

Nb. of values in PCI resource format.

Definition at line 109 of file rte_pci.h.

#define PCI_MAX_RESOURCE   6

Maximum number of PCI resources.

Definition at line 112 of file rte_pci.h.

#define PCI_ANY_ID   (0xffff)

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

Definition at line 164 of file rte_pci.h.

#define RTE_PCI_DEVICE (   vend,
  dev 
)
Value:
.class_id = RTE_CLASS_ANY_ID, \
.vendor_id = (vend), \
.device_id = (dev), \
.subsystem_vendor_id = PCI_ANY_ID, \
.subsystem_device_id = PCI_ANY_ID
#define PCI_ANY_ID
Definition: rte_pci.h:164

Macro used to help building up tables of device IDs

Definition at line 177 of file rte_pci.h.

#define RTE_PCI_DRV_NEED_MAPPING   0x0001

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

Definition at line 210 of file rte_pci.h.

#define RTE_PCI_DRV_FORCE_UNBIND   0x0004

Device needs to be unbound even if no module is provided

Definition at line 212 of file rte_pci.h.

#define RTE_PCI_DRV_INTR_LSC   0x0008

Device driver supports link state interrupt

Definition at line 214 of file rte_pci.h.

#define RTE_PCI_DRV_DETACHABLE   0x0010

Device driver supports detaching capability

Definition at line 216 of file rte_pci.h.

#define RTE_PMD_REGISTER_PCI (   nm,
  pci_drv 
)
Value:
RTE_INIT(pciinitfn_ ##nm); \
static void pciinitfn_ ##nm(void) \
{\
(pci_drv).driver.name = RTE_STR(nm);\
} \
RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
void rte_eal_pci_register(struct rte_pci_driver *driver)
#define RTE_STR(x)
Definition: rte_common.h:344

Helper for PCI device registration from driver (eth, crypto) instance

Definition at line 492 of file rte_pci.h.

Typedef Documentation

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

Initialisation function for the driver called during PCI probing.

Definition at line 190 of file rte_pci.h.

typedef int( pci_remove_t) (struct rte_pci_device *)

Uninitialisation function for the driver called during hotplugging.

Definition at line 195 of file rte_pci.h.

Function Documentation

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.

const char* pci_get_sysfs_path ( void  )

Pathname of PCI devices directory.

TAILQ_HEAD ( mapped_pci_res_list  ,
mapped_pci_resource   
)

mapped pci device list Internal use only - Macro used by pci addr parsing functions

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.

Definition at line 275 of file rte_pci.h.

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.

Definition at line 297 of file rte_pci.h.

static void rte_eal_pci_device_name ( const struct rte_pci_addr addr,
char *  output,
size_t  size 
)
inlinestatic

Utility function to write a pci device name, this device name can later be used to retrieve the corresponding rte_pci_addr using eal_parse_pci_* BDF helpers.

Parameters
addrThe PCI Bus-Device-Function address
outputThe output buffer string
sizeThe output buffer size

Definition at line 320 of file rte_pci.h.

static int rte_eal_compare_pci_addr ( const struct rte_pci_addr addr,
const 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.

Definition at line 343 of file rte_pci.h.

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
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.
int rte_eal_pci_map_device ( struct rte_pci_device dev)

Map the PCI device resources in user space virtual memory address

Note that driver should not call this function when flag RTE_PCI_DRV_NEED_MAPPING is set, as EAL will do that for you when it's on.

Parameters
devA pointer to a rte_pci_device structure describing the device to use
Returns
0 on success, negative on error and positive if no driver is found for the device.
void rte_eal_pci_unmap_device ( struct rte_pci_device dev)

Unmap this device

Parameters
devA pointer to a rte_pci_device structure describing the device to use
int rte_eal_pci_probe_one ( const struct rte_pci_addr addr)

Probe the single PCI device.

Scan the content of the PCI bus, and find the pci device specified by pci address, then call the probe() function for registered driver that has a matching entry in its id_table for discovered device.

Parameters
addrThe PCI Bus-Device-Function address to probe.
Returns
  • 0 on success.
  • Negative on error.
int rte_eal_pci_detach ( const struct rte_pci_addr addr)

Close the single PCI device.

Scan the content of the PCI bus, and find the pci device specified by pci address, then call the remove() function for registered driver that has a matching entry in its id_table for discovered device.

Parameters
addrThe PCI Bus-Device-Function address to close.
Returns
  • 0 on success.
  • Negative on error.
void rte_eal_pci_dump ( FILE *  f)

Dump the content of the PCI bus.

Parameters
fA pointer to a file for output
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.
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.
int rte_eal_pci_read_config ( const struct rte_pci_device device,
void *  buf,
size_t  len,
off_t  offset 
)

Read PCI config space.

Parameters
deviceA pointer to a rte_pci_device structure describing the device to use
bufA data buffer where the bytes should be read into
lenThe length of the data buffer.
offsetThe offset into PCI config space
int rte_eal_pci_write_config ( const struct rte_pci_device device,
const void *  buf,
size_t  len,
off_t  offset 
)

Write PCI config space.

Parameters
deviceA pointer to a rte_pci_device structure describing the device to use
bufA data buffer containing the bytes should be written
lenThe length of the data buffer.
offsetThe offset into PCI config space
int rte_eal_pci_ioport_map ( struct rte_pci_device dev,
int  bar,
struct rte_pci_ioport p 
)

Initialize a rte_pci_ioport object for a pci device io resource.

This object is then used to gain access to those io resources (see below).

Parameters
devA pointer to a rte_pci_device structure describing the device to use.
barIndex of the io pci resource we want to access.
pThe rte_pci_ioport object to be initialized.
Returns
0 on success, negative on error.
int rte_eal_pci_ioport_unmap ( struct rte_pci_ioport p)

Release any resources used in a rte_pci_ioport object.

Parameters
pThe rte_pci_ioport object to be uninitialized.
Returns
0 on success, negative on error.
void rte_eal_pci_ioport_read ( struct rte_pci_ioport p,
void *  data,
size_t  len,
off_t  offset 
)

Read from a io pci resource.

Parameters
pThe rte_pci_ioport object from which we want to read.
dataA data buffer where the bytes should be read into
lenThe length of the data buffer.
offsetThe offset into the pci io resource.
void rte_eal_pci_ioport_write ( struct rte_pci_ioport p,
const void *  data,
size_t  len,
off_t  offset 
)

Write to a io pci resource.

Parameters
pThe rte_pci_ioport object to which we want to write.
dataA data buffer where the bytes should be read into
lenThe length of the data buffer.
offsetThe offset into the pci io resource.

Variable Documentation

struct pci_driver_list pci_driver_list

Global list of PCI drivers.

struct pci_device_list pci_device_list

Global list of PCI devices.