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