From: Jan Blunck <jblu...@infradead.org> Signed-off-by: Jan Blunck <jblu...@infradead.org> Signed-off-by: Gaetan Rivet <gaetan.ri...@6wind.com> --- lib/librte_eal/common/include/rte_bus.h | 7 +++++++ lib/librte_eal/common/include/rte_dev.h | 17 +++++++++++++++++ 2 files changed, 24 insertions(+)
diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 3e26d4b..fe9573f 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -82,6 +82,12 @@ typedef int (*rte_bus_scan_t)(void); typedef int (*rte_bus_probe_t)(void); /** + * Device iterator to find a particular device on a bus. + */ +typedef struct rte_device * (*rte_bus_find_device_t)(rte_dev_cmp_t match, + const void *data); + +/** * A structure describing a generic bus. */ struct rte_bus { @@ -89,6 +95,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 device on bus */ }; /** diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index de20c06..724855e 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -191,6 +191,23 @@ int rte_eal_dev_attach(const char *name, const char *devargs); */ int rte_eal_dev_detach(const char *name); +/** + * Device comparison function. + * + * @param dev + * Device handle. + * + * @param data + * Data to compare against. + * + * @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) \ -- 2.1.4