DPDK  22.03.0
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 <stdio.h>
19 #include <rte_debug.h>
20 
24  void *data;
25 };
27 RTE_TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry);
28 
29 #define RTE_TAILQ_NAMESIZE 32
30 
40  struct rte_tailq_entry_head tailq_head;
41  char name[RTE_TAILQ_NAMESIZE];
42 };
43 
44 struct rte_tailq_elem {
49  struct rte_tailq_head *head;
50  RTE_TAILQ_ENTRY(rte_tailq_elem) next;
51  const char name[RTE_TAILQ_NAMESIZE];
52 };
53 
57 #define RTE_TAILQ_CAST(tailq_entry, struct_name) \
58  (struct struct_name *)&(tailq_entry)->tailq_head
59 
76 #define RTE_TAILQ_LOOKUP(name, struct_name) \
77  RTE_TAILQ_CAST(rte_eal_tailq_lookup(name), struct_name)
78 
85 void rte_dump_tailq(FILE *f);
86 
100 struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
101 
118 int rte_eal_tailq_register(struct rte_tailq_elem *t);
119 
120 #define EAL_REGISTER_TAILQ(t) \
121 RTE_INIT(tailqinitfn_ ##t) \
122 { \
123  if (rte_eal_tailq_register(&t) < 0) \
124  rte_panic("Cannot initialize tailq: %s\n", t.name); \
125 }
126 
127 /* This macro permits both remove and free var within the loop safely.*/
128 #define RTE_TAILQ_FOREACH_SAFE(var, head, field, tvar) \
129  for ((var) = RTE_TAILQ_FIRST((head)); \
130  (var) && ((tvar) = RTE_TAILQ_NEXT((var), field), 1); \
131  (var) = (tvar))
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* _RTE_TAILQ_H_ */
RTE_TAILQ_ENTRY(rte_tailq_entry) next
struct rte_tailq_head * rte_eal_tailq_lookup(const char *name)
void * data
Definition: rte_tailq.h:24
void rte_dump_tailq(FILE *f)
int rte_eal_tailq_register(struct rte_tailq_elem *t)
Definition: rte_tailq.h:22
RTE_TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry)