4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 * Here defines rte_tailq APIs for only internal use
47 #include <sys/queue.h>
50 /** dummy structure type used by the rte_tailq APIs */
51 struct rte_tailq_entry {
52 TAILQ_ENTRY(rte_tailq_entry) next; /**< Pointer entries for a tailq list */
53 void *data; /**< Pointer to the data referenced by this tailq entry */
56 TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry);
58 #define RTE_TAILQ_NAMESIZE 32
61 * The structure defining a tailq header entry for storing
62 * in the rte_config structure in shared memory. Each tailq
63 * is identified by name.
64 * Any library storing a set of objects e.g. rings, mempools, hash-tables,
65 * is recommended to use an entry here, so as to make it easy for
66 * a multi-process app to find already-created elements in shared memory.
68 struct rte_tailq_head {
69 struct rte_tailq_entry_head tailq_head; /**< NOTE: must be first element */
73 * Return the first tailq entry casted to the right struct.
75 #define RTE_TAILQ_CAST(tailq_entry, struct_name) \
76 (struct struct_name *)&(tailq_entry)->tailq_head
79 * Utility macro to make looking up a tailqueue for a particular struct easier.
85 * The name of the list type we are using. (Generally this is the same as the
86 * first parameter passed to TAILQ_HEAD macro)
89 * The return value from rte_eal_tailq_lookup, typecast to the appropriate
90 * structure pointer type.
91 * NULL on error, since the tailq_head is the first
92 * element in the rte_tailq_head structure.
94 #define RTE_TAILQ_LOOKUP(name, struct_name) \
95 RTE_TAILQ_CAST(rte_eal_tailq_lookup(name), struct_name)
98 * Utility macro to make looking up a tailqueue for a particular struct easier.
101 * The tailq idx defined in rte_tail_t to be given to the tail queue.
104 * The name of the list type we are using. (Generally this is the same as the
105 * first parameter passed to TAILQ_HEAD macro)
108 * The return value from rte_eal_tailq_lookup, typecast to the appropriate
109 * structure pointer type.
110 * NULL on error, since the tailq_head is the first
111 * element in the rte_tailq_head structure.
113 #define RTE_TAILQ_LOOKUP_BY_IDX(idx, struct_name) \
114 RTE_TAILQ_CAST(rte_eal_tailq_lookup_by_idx(idx), struct_name)
117 * Dump tail queues to the console.
120 * A pointer to a file for output
122 void rte_dump_tailq(FILE *f);
125 * Lookup for a tail queue.
127 * Get a pointer to a tail queue header of a tail
128 * queue identified by the name given as an argument.
129 * Note: this function is not multi-thread safe, and should only be called from
130 * a single thread at a time
133 * The name of the queue.
135 * A pointer to the tail queue head structure.
137 struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
140 * Lookup for a tail queue.
142 * Get a pointer to a tail queue header of a tail
143 * queue identified by the name given as an argument.
144 * Note: this function is not multi-thread safe, and should only be called from
145 * a single thread at a time
148 * The tailq idx defined in rte_tail_t to be given to the tail queue.
150 * A pointer to the tail queue head structure.
152 struct rte_tailq_head *rte_eal_tailq_lookup_by_idx(const unsigned idx);
158 #endif /* _RTE_TAILQ_H_ */