1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 Gaƫtan Rivet
11 * DPDK device class interface.
13 * This file describes the interface of the device class
16 * A device class defines the type of function a device
17 * will be used for e.g.: Ethernet adapter (eth),
18 * cryptographic co-processor (crypto), etc.
25 #include <sys/queue.h>
29 /** Double linked list of classes */
30 TAILQ_HEAD(rte_class_list, rte_class);
33 * A structure describing a generic device class.
36 TAILQ_ENTRY(rte_class) next; /**< Next device class in linked list */
37 const char *name; /**< Name of the class */
38 rte_dev_iterate_t dev_iterate; /**< Device iterator. */
42 * Class comparison function.
48 * Data to compare against.
51 * 0 if the class matches the data.
52 * !0 if the class does not match.
53 * <0 if ordering is possible and the class is lower than the data.
54 * >0 if ordering is possible and the class is greater than the data.
56 typedef int (*rte_class_cmp_t)(const struct rte_class *cls, const void *data);
59 * Class iterator to find a particular class.
61 * This function compares each registered class to find one that matches
62 * the data passed as parameter.
64 * If the comparison function returns zero this function will stop iterating
65 * over any more classes. To continue a search the class of a previous search
66 * can be passed via the start parameter.
69 * Starting point for the iteration.
72 * Comparison function.
75 * Data to pass to comparison function.
78 * A pointer to a rte_class structure or NULL in case no class matches
82 rte_class_find(const struct rte_class *start, rte_class_cmp_t cmp,
86 * Find the registered class for a given name.
90 rte_class_find_by_name(const char *name);
93 * Register a Class handle.
96 * A pointer to a rte_class structure describing the class
100 void rte_class_register(struct rte_class *cls);
103 * Unregister a Class handle.
106 * A pointer to a rte_class structure describing the class
107 * to be unregistered.
110 void rte_class_unregister(struct rte_class *cls);
113 * Helper for Class registration.
114 * The constructor has lower priority than Bus constructors.
115 * The constructor has higher priority than PMD constructors.
117 #define RTE_REGISTER_CLASS(nm, cls) \
118 RTE_INIT_PRIO(classinitfn_ ##nm, CLASS) \
120 (cls).name = RTE_STR(nm); \
121 rte_class_register(&cls); \
124 #define RTE_UNREGISTER_CLASS(nm, cls) \
125 RTE_FINI_PRIO(classfinifn_ ##nm, CLASS) \
127 rte_class_unregister(&cls); \
134 #endif /* _RTE_CLASS_H_ */