bus: add method to find device
This new method allows buses to expose their devices in a controlled manner. A comparison function is provided by the user to discriminate between devices, using arbitrary data as identifier. It is possible to start an iteration from a specific point, in order to continue a search. Signed-off-by: Jan Blunck <jblunck@infradead.org> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
This commit is contained in:
parent
87bfa873af
commit
3a8f0bc68a
@ -81,6 +81,32 @@ typedef int (*rte_bus_scan_t)(void);
|
||||
*/
|
||||
typedef int (*rte_bus_probe_t)(void);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param cmp
|
||||
* Comparison function.
|
||||
*
|
||||
* @param data
|
||||
* Data to compare each device against.
|
||||
*
|
||||
* @param start
|
||||
* starting point for the iteration
|
||||
*
|
||||
* @return
|
||||
* The first device matching the data, NULL if none exists.
|
||||
*/
|
||||
typedef struct rte_device *
|
||||
(*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* A structure describing a generic bus.
|
||||
*/
|
||||
@ -89,6 +115,7 @@ struct rte_bus {
|
||||
const char *name; /**< Name of the bus */
|
||||
rte_bus_scan_t scan; /**< Scan for devices attached to bus */
|
||||
rte_bus_probe_t probe; /**< Probe devices on bus */
|
||||
rte_bus_find_device_t find_device; /**< Find a device on the bus */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -191,6 +191,27 @@ int rte_eal_dev_attach(const char *name, const char *devargs);
|
||||
*/
|
||||
int rte_eal_dev_detach(const char *name);
|
||||
|
||||
/**
|
||||
* Device comparison function.
|
||||
*
|
||||
* This type of function is used to compare an rte_device with arbitrary
|
||||
* data.
|
||||
*
|
||||
* @param dev
|
||||
* Device handle.
|
||||
*
|
||||
* @param data
|
||||
* Data to compare against. The type of this parameter is determined by
|
||||
* the kind of comparison performed by the function.
|
||||
*
|
||||
* @return
|
||||
* 0 if the device matches the data.
|
||||
* !0 if the device does not match.
|
||||
* <0 if ordering is possible and the device is lower than the data.
|
||||
* >0 if ordering is possible and the device is greater than the data.
|
||||
*/
|
||||
typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
|
||||
|
||||
#define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
|
||||
|
||||
#define RTE_PMD_EXPORT_NAME(name, idx) \
|
||||
|
Loading…
Reference in New Issue
Block a user