DPDK  19.08.2
rte_tailq.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef _RTE_TAILQ_H_
6 #define _RTE_TAILQ_H_
7 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #include <sys/queue.h>
19 #include <stdio.h>
20 #include <rte_debug.h>
21 
25  void *data;
26 };
28 TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry);
29 
30 #define RTE_TAILQ_NAMESIZE 32
31 
41  struct rte_tailq_entry_head tailq_head;
42  char name[RTE_TAILQ_NAMESIZE];
43 };
44 
45 struct rte_tailq_elem {
50  struct rte_tailq_head *head;
51  TAILQ_ENTRY(rte_tailq_elem) next;
52  const char name[RTE_TAILQ_NAMESIZE];
53 };
54 
58 #define RTE_TAILQ_CAST(tailq_entry, struct_name) \
59  (struct struct_name *)&(tailq_entry)->tailq_head
60 
77 #define RTE_TAILQ_LOOKUP(name, struct_name) \
78  RTE_TAILQ_CAST(rte_eal_tailq_lookup(name), struct_name)
79 
86 void rte_dump_tailq(FILE *f);
87 
101 struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
102 
119 int rte_eal_tailq_register(struct rte_tailq_elem *t);
120 
121 #define EAL_REGISTER_TAILQ(t) \
122 RTE_INIT(tailqinitfn_ ##t) \
123 { \
124  if (rte_eal_tailq_register(&t) < 0) \
125  rte_panic("Cannot initialize tailq: %s\n", t.name); \
126 }
127 
128 /* This macro permits both remove and free var within the loop safely.*/
129 #ifndef TAILQ_FOREACH_SAFE
130 #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
131  for ((var) = TAILQ_FIRST((head)); \
132  (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
133  (var) = (tvar))
134 #endif
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif /* _RTE_TAILQ_H_ */
struct rte_tailq_entry_head tailq_head
Definition: rte_tailq.h:41
struct rte_tailq_head * rte_eal_tailq_lookup(const char *name)
void * data
Definition: rte_tailq.h:25
void rte_dump_tailq(FILE *f)
int rte_eal_tailq_register(struct rte_tailq_elem *t)
TAILQ_ENTRY(rte_tailq_entry) next
Definition: rte_tailq.h:23
TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry)