#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>
#include <rte_bus.h>
Go to the source code of this file.
Functions |
const char * | pci_get_sysfs_path (void) |
| TAILQ_HEAD (rte_pci_device_list, rte_pci_device) |
| TAILQ_HEAD (rte_pci_driver_list, rte_pci_driver) |
| 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_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_pci_scan (void) |
int | rte_pci_probe (void) |
int | rte_pci_map_device (struct rte_pci_device *dev) |
void | rte_pci_unmap_device (struct rte_pci_device *dev) |
int | rte_pci_probe_one (const struct rte_pci_addr *addr) |
int | rte_pci_detach (const struct rte_pci_addr *addr) |
void | rte_pci_dump (FILE *f) |
void | rte_pci_register (struct rte_pci_driver *driver) |
void | rte_pci_unregister (struct rte_pci_driver *driver) |
int | rte_pci_read_config (const struct rte_pci_device *device, void *buf, size_t len, off_t offset) |
int | rte_pci_write_config (const struct rte_pci_device *device, const void *buf, size_t len, off_t offset) |
int | rte_pci_ioport_map (struct rte_pci_device *dev, int bar, struct rte_pci_ioport *p) |
int | rte_pci_ioport_unmap (struct rte_pci_ioport *p) |
void | rte_pci_ioport_read (struct rte_pci_ioport *p, void *data, size_t len, off_t offset) |
void | rte_pci_ioport_write (struct rte_pci_ioport *p, const void *data, size_t len, off_t offset) |
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 94 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 98 of file rte_pci.h.
Nb. of values in PCI device identifier format string.
Definition at line 101 of file rte_pci.h.
#define PCI_RESOURCE_FMT_NVAL 3 |
Nb. of values in PCI resource format.
Definition at line 104 of file rte_pci.h.
#define PCI_MAX_RESOURCE 6 |
Maximum number of PCI resources.
Definition at line 107 of file rte_pci.h.
#define PCI_BUS_NAME "PCI" |
#define PCI_ANY_ID (0xffff) |
Any PCI device identifier (vendor, device, ...)
Definition at line 185 of file rte_pci.h.
#define RTE_PCI_DEVICE |
( |
|
vend, |
|
|
|
dev |
|
) |
| |
Value:.class_id = RTE_CLASS_ANY_ID, \
.vendor_id = (vend), \
.device_id = (dev), \
Macro used to help building up tables of device IDs
Definition at line 198 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 239 of file rte_pci.h.
#define RTE_PCI_DRV_INTR_LSC 0x0008 |
Device driver supports link state interrupt
Definition at line 241 of file rte_pci.h.
#define RTE_PCI_DRV_INTR_RMV 0x0010 |
Device driver supports device removal interrupt
Definition at line 243 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_pci_register(&pci_drv); \
} \
RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
Helper for PCI device registration from driver (eth, crypto) instance
Definition at line 514 of file rte_pci.h.
Typedef Documentation
Initialisation function for the driver called during PCI probing.
Definition at line 209 of file rte_pci.h.
Uninitialisation function for the driver called during hotplugging.
Definition at line 214 of file rte_pci.h.
Function Documentation
const char* pci_get_sysfs_path |
( |
void |
| ) |
|
Pathname of PCI devices directory.
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
-
input | The input string to be parsed. Should have the format XX:XX.X |
dev_addr | The 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 300 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
-
input | The input string to be parsed. Should have the format XXXX:XX:XX.X |
dev_addr | The PCI Bus-Device-Function address to be returned |
- Returns
- 0 on success, negative on error.
Definition at line 322 of file rte_pci.h.
static void rte_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
-
addr | The PCI Bus-Device-Function address |
output | The output buffer string |
size | The output buffer size |
Definition at line 345 of file rte_pci.h.
Utility function to compare two PCI device addresses.
- Parameters
-
addr | The PCI Bus-Device-Function address to compare |
addr2 | The 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 368 of file rte_pci.h.
int rte_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_pci_probe |
( |
void |
| ) |
|
Probe the PCI bus
- Returns
- 0 on success.
- !0 on error.
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
-
dev | A 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.
Unmap this device
- Parameters
-
dev | A pointer to a rte_pci_device structure describing the device to use |
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
-
addr | The PCI Bus-Device-Function address to probe. |
- Returns
- 0 on success.
- Negative on error.
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
-
addr | The PCI Bus-Device-Function address to close. |
- Returns
- 0 on success.
- Negative on error.
void rte_pci_dump |
( |
FILE * |
f | ) |
|
Dump the content of the PCI bus.
- Parameters
-
f | A pointer to a file for output |
Register a PCI driver.
- Parameters
-
driver | A pointer to a rte_pci_driver structure describing the driver to be registered. |
Unregister a PCI driver.
- Parameters
-
driver | A pointer to a rte_pci_driver structure describing the driver to be unregistered. |
int rte_pci_read_config |
( |
const struct rte_pci_device * |
device, |
|
|
void * |
buf, |
|
|
size_t |
len, |
|
|
off_t |
offset |
|
) |
| |
Read PCI config space.
- Parameters
-
device | A pointer to a rte_pci_device structure describing the device to use |
buf | A data buffer where the bytes should be read into |
len | The length of the data buffer. |
offset | The offset into PCI config space |
int rte_pci_write_config |
( |
const struct rte_pci_device * |
device, |
|
|
const void * |
buf, |
|
|
size_t |
len, |
|
|
off_t |
offset |
|
) |
| |
Write PCI config space.
- Parameters
-
device | A pointer to a rte_pci_device structure describing the device to use |
buf | A data buffer containing the bytes should be written |
len | The length of the data buffer. |
offset | The offset into PCI config space |
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
-
dev | A pointer to a rte_pci_device structure describing the device to use. |
bar | Index of the io pci resource we want to access. |
p | The rte_pci_ioport object to be initialized. |
- Returns
- 0 on success, negative on error.
Release any resources used in a rte_pci_ioport object.
- Parameters
-
- Returns
- 0 on success, negative on error.
void rte_pci_ioport_read |
( |
struct rte_pci_ioport * |
p, |
|
|
void * |
data, |
|
|
size_t |
len, |
|
|
off_t |
offset |
|
) |
| |
Read from a io pci resource.
- Parameters
-
p | The rte_pci_ioport object from which we want to read. |
data | A data buffer where the bytes should be read into |
len | The length of the data buffer. |
offset | The offset into the pci io resource. |
void rte_pci_ioport_write |
( |
struct rte_pci_ioport * |
p, |
|
|
const void * |
data, |
|
|
size_t |
len, |
|
|
off_t |
offset |
|
) |
| |
Write to a io pci resource.
- Parameters
-
p | The rte_pci_ioport object to which we want to write. |
data | A data buffer where the bytes should be read into |
len | The length of the data buffer. |
offset | The offset into the pci io resource. |