DPDK 21.11.9
Data Structures | Macros | Typedefs | Enumerations | Functions
rte_bus.h File Reference
#include <stdio.h>
#include <rte_log.h>
#include <rte_dev.h>

Go to the source code of this file.

Data Structures

struct  rte_bus_conf
 
struct  rte_bus
 

Macros

#define RTE_REGISTER_BUS(nm, bus)
 

Typedefs

typedef int(* rte_bus_scan_t) (void)
 
typedef int(* rte_bus_probe_t) (void)
 
typedef struct rte_device *(* rte_bus_find_device_t) (const struct rte_device *start, rte_dev_cmp_t cmp, const void *data)
 
typedef int(* rte_bus_plug_t) (struct rte_device *dev)
 
typedef int(* rte_bus_unplug_t) (struct rte_device *dev)
 
typedef int(* rte_bus_parse_t) (const char *name, void *addr)
 
typedef int(* rte_bus_devargs_parse_t) (struct rte_devargs *da)
 
typedef int(* rte_dev_dma_map_t) (struct rte_device *dev, void *addr, uint64_t iova, size_t len)
 
typedef int(* rte_dev_dma_unmap_t) (struct rte_device *dev, void *addr, uint64_t iova, size_t len)
 
typedef int(* rte_bus_hot_unplug_handler_t) (struct rte_device *dev)
 
typedef int(* rte_bus_sigbus_handler_t) (const void *failure_addr)
 
typedef enum rte_iova_mode(* rte_bus_get_iommu_class_t) (void)
 
typedef int(* rte_bus_cmp_t) (const struct rte_bus *bus, const void *data)
 

Enumerations

enum  rte_iova_mode
 
enum  rte_bus_scan_mode
 

Functions

 RTE_TAILQ_HEAD (rte_bus_list, rte_bus)
 
void rte_bus_register (struct rte_bus *bus)
 
void rte_bus_unregister (struct rte_bus *bus)
 
int rte_bus_scan (void)
 
int rte_bus_probe (void)
 
void rte_bus_dump (FILE *f)
 
struct rte_busrte_bus_find (const struct rte_bus *start, rte_bus_cmp_t cmp, const void *data)
 
struct rte_busrte_bus_find_by_device (const struct rte_device *dev)
 
struct rte_busrte_bus_find_by_name (const char *busname)
 
enum rte_iova_mode rte_bus_get_iommu_class (void)
 

Detailed Description

DPDK device bus interface

This file exposes API and interfaces for bus abstraction over the devices and drivers in EAL.

Definition in file rte_bus.h.

Macro Definition Documentation

◆ RTE_REGISTER_BUS

#define RTE_REGISTER_BUS (   nm,
  bus 
)
Value:
RTE_INIT_PRIO(businitfn_ ##nm, BUS) \
{\
(bus).name = RTE_STR(nm);\
rte_bus_register(&bus); \
}
#define RTE_STR(x)
Definition: rte_common.h:821
#define RTE_INIT_PRIO(func, prio)
Definition: rte_common.h:185

Helper for Bus registration. The constructor has higher priority than PMD constructors.

Definition at line 394 of file rte_bus.h.

Typedef Documentation

◆ rte_bus_scan_t

typedef int(* rte_bus_scan_t) (void)

Bus specific scan for devices attached on the bus. For each bus object, the scan would be responsible for finding devices and adding them to its private device list.

A bus should mandatorily implement this method.

Returns
0 for successful scan <0 for unsuccessful scan with error value

Definition at line 55 of file rte_bus.h.

◆ rte_bus_probe_t

typedef int(* rte_bus_probe_t) (void)

Implementation specific probe function which is responsible for linking devices on that bus with applicable drivers.

This is called while iterating over each registered bus.

Returns
0 for successful probe !0 for any error while probing

Definition at line 67 of file rte_bus.h.

◆ rte_bus_find_device_t

typedef struct rte_device *(* rte_bus_find_device_t) (const struct rte_device *start, rte_dev_cmp_t cmp, const void *data)

Device iterator to find a device on a bus.

This function returns an rte_device if one of those held by the bus matches the data passed as parameter.

If the comparison function returns zero this function should stop iterating over any more devices. To continue a search the device of a previous search can be passed via the start parameter.

Parameters
cmpComparison function.
dataData to compare each device against.
startstarting point for the iteration
Returns
The first device matching the data, NULL if none exists.

Definition at line 67 of file rte_bus.h.

◆ rte_bus_plug_t

typedef int(* rte_bus_plug_t) (struct rte_device *dev)

Implementation specific probe function which is responsible for linking devices on that bus with applicable drivers.

Parameters
devDevice pointer that was returned by a previous call to find_device.
Returns
0 on success. !0 on error.

Definition at line 106 of file rte_bus.h.

◆ rte_bus_unplug_t

typedef int(* rte_bus_unplug_t) (struct rte_device *dev)

Implementation specific remove function which is responsible for unlinking devices on that bus from assigned driver.

Parameters
devDevice pointer that was returned by a previous call to find_device.
Returns
0 on success. !0 on error.

Definition at line 119 of file rte_bus.h.

◆ rte_bus_parse_t

typedef int(* rte_bus_parse_t) (const char *name, void *addr)

Bus specific parsing function. Validates the syntax used in the textual representation of a device, If the syntax is valid and addr is not NULL, writes the bus-specific device representation to addr.

Parameters
[in]namedevice textual description
[out]addrdevice information location address, into which parsed info should be written. If NULL, nothing should be written, which is not an error.
Returns
0 if parsing was successful. !0 for any error.

Definition at line 139 of file rte_bus.h.

◆ rte_bus_devargs_parse_t

typedef int(* rte_bus_devargs_parse_t) (struct rte_devargs *da)

Parse bus part of the device arguments.

The field name of the struct rte_devargs will be set.

Parameters
daPointer to the devargs to parse.
Returns
0 on successful parsing, otherwise rte_errno is set. -EINVAL: on parsing error. -ENODEV: if no key matching a device argument is specified. -E2BIG: device name is too long.

Definition at line 155 of file rte_bus.h.

◆ rte_dev_dma_map_t

typedef int(* rte_dev_dma_map_t) (struct rte_device *dev, void *addr, uint64_t iova, size_t len)

Device level DMA map function. After a successful call, the memory segment will be mapped to the given device.

Parameters
devDevice pointer.
addrVirtual address to map.
iovaIOVA address to map.
lenLength of the memory segment being mapped.
Returns
0 if mapping was successful. Negative value and rte_errno is set otherwise.

Definition at line 175 of file rte_bus.h.

◆ rte_dev_dma_unmap_t

typedef int(* rte_dev_dma_unmap_t) (struct rte_device *dev, void *addr, uint64_t iova, size_t len)

Device level DMA unmap function. After a successful call, the memory segment will no longer be accessible by the given device.

Parameters
devDevice pointer.
addrVirtual address to unmap.
iovaIOVA address to unmap.
lenLength of the memory segment being mapped.
Returns
0 if un-mapping was successful. Negative value and rte_errno is set otherwise.

Definition at line 196 of file rte_bus.h.

◆ rte_bus_hot_unplug_handler_t

typedef int(* rte_bus_hot_unplug_handler_t) (struct rte_device *dev)

Implement a specific hot-unplug handler, which is responsible for handle the failure when device be hot-unplugged. When the event of hot-unplug be detected, it could call this function to handle the hot-unplug failure and avoid app crash.

Parameters
devPointer of the device structure.
Returns
0 on success. !0 on error.

Definition at line 211 of file rte_bus.h.

◆ rte_bus_sigbus_handler_t

typedef int(* rte_bus_sigbus_handler_t) (const void *failure_addr)

Implement a specific sigbus handler, which is responsible for handling the sigbus error which is either original memory error, or specific memory error that caused of device be hot-unplugged. When sigbus error be captured, it could call this function to handle sigbus error.

Parameters
failure_addrPointer of the fault address of the sigbus error.
Returns
0 for success handle the sigbus for hot-unplug. 1 for not process it, because it is a generic sigbus error. -1 for failed to handle the sigbus for hot-unplug.

Definition at line 226 of file rte_bus.h.

◆ rte_bus_get_iommu_class_t

typedef enum rte_iova_mode(* rte_bus_get_iommu_class_t) (void)

Get common iommu class of the all the devices on the bus. The bus may check that those devices are attached to iommu driver. If no devices are attached to the bus. The bus may return with don't care (_DC) value. Otherwise, The bus will return appropriate _pa or _va iova mode.

Returns
enum rte_iova_mode value.

Definition at line 226 of file rte_bus.h.

◆ rte_bus_cmp_t

typedef int(* rte_bus_cmp_t) (const struct rte_bus *bus, const void *data)

Bus comparison function.

Parameters
busBus under test.
dataData to compare against.
Returns
0 if the bus matches the data. !0 if the bus does not match. <0 if ordering is possible and the bus is lower than the data. >0 if ordering is possible and the bus is greater than the data.

Definition at line 343 of file rte_bus.h.

Enumeration Type Documentation

◆ rte_iova_mode

IOVA mapping mode.

IOVA mapping mode is iommu programming mode of a device. That device (for example: IOMMU backed DMA device) based on rte_iova_mode will generate physical or virtual address.

Definition at line 38 of file rte_bus.h.

◆ rte_bus_scan_mode

Bus scan policies

Definition at line 231 of file rte_bus.h.

Function Documentation

◆ RTE_TAILQ_HEAD()

RTE_TAILQ_HEAD ( rte_bus_list  ,
rte_bus   
)

Double linked list of buses

◆ rte_bus_register()

void rte_bus_register ( struct rte_bus bus)

Register a Bus handler.

Parameters
busA pointer to a rte_bus structure describing the bus to be registered.

◆ rte_bus_unregister()

void rte_bus_unregister ( struct rte_bus bus)

Unregister a Bus handler.

Parameters
busA pointer to a rte_bus structure describing the bus to be unregistered.

◆ rte_bus_scan()

int rte_bus_scan ( void  )

Scan all the buses.

Returns
0 in case of success in scanning all buses !0 in case of failure to scan

◆ rte_bus_probe()

int rte_bus_probe ( void  )

For each device on the buses, perform a driver 'match' and call the driver-specific probe for device initialization.

Returns
0 for successful match/probe !0 otherwise

◆ rte_bus_dump()

void rte_bus_dump ( FILE *  f)

Dump information of all the buses registered with EAL.

Parameters
fA valid and open output stream handle

◆ rte_bus_find()

struct rte_bus * rte_bus_find ( const struct rte_bus start,
rte_bus_cmp_t  cmp,
const void *  data 
)

Bus iterator to find a particular bus.

This function compares each registered bus to find one that matches the data passed as parameter.

If the comparison function returns zero this function will stop iterating over any more buses. To continue a search the bus of a previous search can be passed via the start parameter.

Parameters
startStarting point for the iteration.
cmpComparison function.
dataData to pass to comparison function.
Returns
A pointer to a rte_bus structure or NULL in case no bus matches

◆ rte_bus_find_by_device()

struct rte_bus * rte_bus_find_by_device ( const struct rte_device dev)

Find the registered bus for a particular device.

Examples
examples/ethtool/lib/rte_ethtool.c, and examples/ip_pipeline/kni.c.

◆ rte_bus_find_by_name()

struct rte_bus * rte_bus_find_by_name ( const char *  busname)

Find the registered bus for a given name.

◆ rte_bus_get_iommu_class()

enum rte_iova_mode rte_bus_get_iommu_class ( void  )

Get the common iommu class of devices bound on to buses available in the system. RTE_IOVA_DC means that no preference has been expressed.

Returns
enum rte_iova_mode value.