1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 Gaƫtan Rivet
10 #include <rte_debug.h>
12 struct rte_class_list rte_class_list =
13 TAILQ_HEAD_INITIALIZER(rte_class_list);
15 __rte_experimental void
16 rte_class_register(struct rte_class *class)
19 RTE_VERIFY(class->name && strlen(class->name));
21 TAILQ_INSERT_TAIL(&rte_class_list, class, next);
22 RTE_LOG(DEBUG, EAL, "Registered [%s] device class.\n", class->name);
25 __rte_experimental void
26 rte_class_unregister(struct rte_class *class)
28 TAILQ_REMOVE(&rte_class_list, class, next);
29 RTE_LOG(DEBUG, EAL, "Unregistered [%s] device class.\n", class->name);
34 rte_class_find(const struct rte_class *start, rte_class_cmp_t cmp,
37 struct rte_class *cls;
40 cls = TAILQ_NEXT(start, next);
42 cls = TAILQ_FIRST(&rte_class_list);
44 if (cmp(cls, data) == 0)
46 cls = TAILQ_NEXT(cls, next);
52 cmp_class_name(const struct rte_class *class, const void *_name)
54 const char *name = _name;
56 return strcmp(class->name, name);
61 rte_class_find_by_name(const char *name)
63 return rte_class_find(NULL, cmp_class_name, (const void *)name);