blob: 276c91e95c21ff23075ea363f533a5c282df0e81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2018 Gaëtan Rivet
*/
#ifndef _RTE_CLASS_H_
#define _RTE_CLASS_H_
/**
* @file
*
* DPDK device class interface.
*
* This file describes the interface of the device class
* abstraction layer.
*
* A device class defines the type of function a device
* will be used for e.g.: Ethernet adapter (eth),
* cryptographic coprocessor (crypto), etc.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/queue.h>
#include <rte_dev.h>
/** Double linked list of classes */
TAILQ_HEAD(rte_class_list, rte_class);
/**
* A structure describing a generic device class.
*/
struct rte_class {
TAILQ_ENTRY(rte_class) next; /**< Next device class in linked list */
const char *name; /**< Name of the class */
rte_dev_iterate_t dev_iterate; /**< Device iterator. */
};
/**
* Class comparison function.
*
* @param cls
* Class under test.
*
* @param data
* Data to compare against.
*
* @return
* 0 if the class matches the data.
* !0 if the class does not match.
* <0 if ordering is possible and the class is lower than the data.
* >0 if ordering is possible and the class is greater than the data.
*/
typedef int (*rte_class_cmp_t)(const struct rte_class *cls, const void *data);
/**
* Class iterator to find a particular class.
*
* This function compares each registered class to find one that matches
* the data passed as parameter.
*
* If the comparison function returns zero this function will stop iterating
* over any more classes. To continue a search the class of a previous search
* can be passed via the start parameter.
*
* @param start
* Starting point for the iteration.
*
* @param cmp
* Comparison function.
*
* @param data
* Data to pass to comparison function.
*
* @return
* A pointer to a rte_class structure or NULL in case no class matches
*/
__rte_experimental
struct rte_class *
rte_class_find(const struct rte_class *start, rte_class_cmp_t cmp,
const void *data);
/**
* Find the registered class for a given name.
*/
__rte_experimental
struct rte_class *
rte_class_find_by_name(const char *name);
/**
* Register a Class handle.
*
* @param cls
* A pointer to a rte_class structure describing the class
* to be registered.
*/
__rte_experimental
void rte_class_register(struct rte_class *cls);
/**
* Unregister a Class handle.
*
* @param cls
* A pointer to a rte_class structure describing the class
* to be unregistered.
*/
__rte_experimental
void rte_class_unregister(struct rte_class *cls);
/**
* Helper for Class registration.
* The constructor has lower priority than Bus constructors.
* The constructor has higher priority than PMD constructors.
*/
#define RTE_REGISTER_CLASS(nm, cls) \
RTE_INIT_PRIO(classinitfn_ ##nm, CLASS) \
{\
(cls).name = RTE_STR(nm); \
rte_class_register(&cls); \
}
#define RTE_UNREGISTER_CLASS(nm, cls) \
RTE_FINI_PRIO(classfinifn_ ##nm, CLASS) \
{ \
rte_class_unregister(&cls); \
}
#ifdef __cplusplus
}
#endif
#endif /* _RTE_CLASS_H_ */
|