remove experimental tags from all symbol definitions
[dpdk.git] / lib / librte_eal / common / eal_common_class.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018 GaĆ«tan Rivet
3  */
4
5 #include <stdio.h>
6 #include <string.h>
7 #include <sys/queue.h>
8
9 #include <rte_class.h>
10 #include <rte_debug.h>
11
12 static struct rte_class_list rte_class_list =
13         TAILQ_HEAD_INITIALIZER(rte_class_list);
14
15 void
16 rte_class_register(struct rte_class *class)
17 {
18         RTE_VERIFY(class);
19         RTE_VERIFY(class->name && strlen(class->name));
20
21         TAILQ_INSERT_TAIL(&rte_class_list, class, next);
22         RTE_LOG(DEBUG, EAL, "Registered [%s] device class.\n", class->name);
23 }
24
25 void
26 rte_class_unregister(struct rte_class *class)
27 {
28         TAILQ_REMOVE(&rte_class_list, class, next);
29         RTE_LOG(DEBUG, EAL, "Unregistered [%s] device class.\n", class->name);
30 }
31
32 struct rte_class *
33 rte_class_find(const struct rte_class *start, rte_class_cmp_t cmp,
34                const void *data)
35 {
36         struct rte_class *cls;
37
38         if (start != NULL)
39                 cls = TAILQ_NEXT(start, next);
40         else
41                 cls = TAILQ_FIRST(&rte_class_list);
42         while (cls != NULL) {
43                 if (cmp(cls, data) == 0)
44                         break;
45                 cls = TAILQ_NEXT(cls, next);
46         }
47         return cls;
48 }
49
50 static int
51 cmp_class_name(const struct rte_class *class, const void *_name)
52 {
53         const char *name = _name;
54
55         return strcmp(class->name, name);
56 }
57
58 struct rte_class *
59 rte_class_find_by_name(const char *name)
60 {
61         return rte_class_find(NULL, cmp_class_name, (const void *)name);
62 }