#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <stdint.h>
#include <inttypes.h>
#include <rte_compat.h>
#include <rte_debug.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
Go to the source code of this file.
|
| int | rte_pci_map_device (struct rte_pci_device *dev) |
| |
| void | rte_pci_unmap_device (struct rte_pci_device *dev) |
| |
| void | rte_pci_dump (FILE *f) |
| |
| __rte_experimental bool | rte_pci_has_capability_list (const struct rte_pci_device *dev) |
| |
| __rte_experimental off_t | rte_pci_find_capability (const struct rte_pci_device *dev, uint8_t cap) |
| |
| __rte_experimental off_t | rte_pci_find_next_capability (const struct rte_pci_device *dev, uint8_t cap, off_t offset) |
| |
| __rte_experimental off_t | rte_pci_find_ext_capability (const struct rte_pci_device *dev, uint32_t cap) |
| |
| __rte_experimental int | rte_pci_set_bus_master (const struct rte_pci_device *dev, bool enable) |
| |
| __rte_internal int | rte_pci_pasid_set_state (const struct rte_pci_device *dev, off_t offset, bool enable) |
| |
| 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) |
| |
| __rte_experimental int | rte_pci_mmio_read (const struct rte_pci_device *device, int bar, void *buf, size_t len, off_t offset) |
| |
| __rte_experimental int | rte_pci_mmio_write (const struct rte_pci_device *device, int bar, 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) |
| |
PCI device & driver interface
Definition in file rte_bus_pci.h.
◆ rte_pci_map_device()
| int rte_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
-
| 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.
◆ rte_pci_unmap_device()
| void rte_pci_unmap_device |
( |
struct rte_pci_device * |
dev | ) |
|
Unmap this device
- Parameters
-
| dev | A pointer to a rte_pci_device structure describing the device to use |
◆ rte_pci_dump()
| void rte_pci_dump |
( |
FILE * |
f | ) |
|
Dump the content of the PCI bus.
- Parameters
-
| f | A pointer to a file for output |
◆ rte_pci_has_capability_list()
| __rte_experimental bool rte_pci_has_capability_list |
( |
const struct rte_pci_device * |
dev | ) |
|
Check whether this device has a PCI capability list.
- Parameters
-
| dev | A pointer to rte_pci_device structure. |
- Returns
- true/false
◆ rte_pci_find_capability()
| __rte_experimental off_t rte_pci_find_capability |
( |
const struct rte_pci_device * |
dev, |
|
|
uint8_t |
cap |
|
) |
| |
Find device's PCI capability.
- Parameters
-
| dev | A pointer to rte_pci_device structure. |
| cap | Capability to be found, which can be any from RTE_PCI_CAP_ID_*, defined in librte_pci. |
- Returns
0: The offset of the next matching capability structure within the device's PCI configuration space. < 0: An error in PCI config space read. = 0: Device does not support it.
◆ rte_pci_find_next_capability()
| __rte_experimental off_t rte_pci_find_next_capability |
( |
const struct rte_pci_device * |
dev, |
|
|
uint8_t |
cap, |
|
|
off_t |
offset |
|
) |
| |
Find device's PCI capability starting from a previous offset in PCI configuration space.
- Parameters
-
| dev | A pointer to rte_pci_device structure. |
| cap | Capability to be found, which can be any from RTE_PCI_CAP_ID_*, defined in librte_pci. |
| offset | An offset in the PCI configuration space from which the capability is looked for. |
- Returns
0: The offset of the next matching capability structure within the device's PCI configuration space. < 0: An error in PCI config space read. = 0: Device does not support it.
◆ rte_pci_find_ext_capability()
| __rte_experimental off_t rte_pci_find_ext_capability |
( |
const struct rte_pci_device * |
dev, |
|
|
uint32_t |
cap |
|
) |
| |
Find device's extended PCI capability.
- Parameters
-
| dev | A pointer to rte_pci_device structure. |
| cap | Extended capability to be found, which can be any from RTE_PCI_EXT_CAP_ID_*, defined in librte_pci. |
- Returns
0: The offset of the next matching extended capability structure within the device's PCI configuration space. < 0: An error in PCI config space read. = 0: Device does not support it.
◆ rte_pci_set_bus_master()
| __rte_experimental int rte_pci_set_bus_master |
( |
const struct rte_pci_device * |
dev, |
|
|
bool |
enable |
|
) |
| |
Enables/Disables Bus Master for device's PCI command register.
- Parameters
-
| dev | A pointer to rte_pci_device structure. |
| enable | Enable or disable Bus Master. |
- Returns
- 0 on success, -1 on error in PCI config space read/write.
◆ rte_pci_pasid_set_state()
| __rte_internal int rte_pci_pasid_set_state |
( |
const struct rte_pci_device * |
dev, |
|
|
off_t |
offset, |
|
|
bool |
enable |
|
) |
| |
Enable/Disable PASID (Process Address Space ID).
- Parameters
-
| dev | A pointer to a rte_pci_device structure. |
| offset | Offset of the PASID external capability structure. |
| enable | Flag to enable or disable PASID. |
- Returns
- 0 on success, -1 on error in PCI config space read/write.
◆ rte_pci_read_config()
| 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 |
- Returns
- Number of bytes read on success, negative on error.
◆ rte_pci_write_config()
| 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 |
◆ rte_pci_mmio_read()
| __rte_experimental int rte_pci_mmio_read |
( |
const struct rte_pci_device * |
device, |
|
|
int |
bar, |
|
|
void * |
buf, |
|
|
size_t |
len, |
|
|
off_t |
offset |
|
) |
| |
- Warning
- EXPERIMENTAL: this API may change without prior notice.
Read from a MMIO PCI resource.
- Parameters
-
| device | A pointer to a rte_pci_device structure describing the device to use. |
| bar | Index of the IO PCI resource we want to access. |
| buf | A data buffer where the bytes should be read into. |
| len | The length of the data buffer. |
| offset | The offset into MMIO space described by bar. |
- Returns
- Number of bytes read on success, negative on error.
◆ rte_pci_mmio_write()
| __rte_experimental int rte_pci_mmio_write |
( |
const struct rte_pci_device * |
device, |
|
|
int |
bar, |
|
|
const void * |
buf, |
|
|
size_t |
len, |
|
|
off_t |
offset |
|
) |
| |
- Warning
- EXPERIMENTAL: this API may change without prior notice.
Write to a MMIO PCI resource.
- Parameters
-
| device | A pointer to a rte_pci_device structure describing the device to use. |
| bar | Index of the IO PCI resource we want to access. |
| buf | A data buffer containing the bytes should be written. |
| len | The length of the data buffer. |
| offset | The offset into MMIO space described by bar. |
- Returns
- Number of bytes written on success, negative on error.
◆ rte_pci_ioport_map()
| int rte_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
-
| 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.
◆ rte_pci_ioport_unmap()
| int rte_pci_ioport_unmap |
( |
struct rte_pci_ioport * |
p | ) |
|
Release any resources used in a rte_pci_ioport object.
- Parameters
-
| p | The rte_pci_ioport object to be uninitialized. |
- Returns
- 0 on success, negative on error.
◆ rte_pci_ioport_read()
| 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. |
◆ rte_pci_ioport_write()
| 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. |