1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 Gaƫtan Rivet
10 #include <rte_debug.h>
12 static struct rte_class_list rte_class_list =
13 TAILQ_HEAD_INITIALIZER(rte_class_list);
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);
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);
33 rte_class_find(const struct rte_class *start, rte_class_cmp_t cmp,
36 struct rte_class *cls;
39 cls = TAILQ_NEXT(start, next);
41 cls = TAILQ_FIRST(&rte_class_list);
43 if (cmp(cls, data) == 0)
45 cls = TAILQ_NEXT(cls, next);
51 cmp_class_name(const struct rte_class *class, const void *_name)
53 const char *name = _name;
55 return strcmp(class->name, name);
59 rte_class_find_by_name(const char *name)
61 return rte_class_find(NULL, cmp_class_name, (const void *)name);