DPDK  24.07.0
rte_ring_core.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright (c) 2010-2020 Intel Corporation
4  * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
5  * All rights reserved.
6  * Derived from FreeBSD's bufring.h
7  * Used as BSD-3 Licensed with permission from Kip Macy.
8  */
9 
10 #ifndef _RTE_RING_CORE_H_
11 #define _RTE_RING_CORE_H_
12 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include <stdalign.h>
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <string.h>
30 #include <errno.h>
31 #include <rte_common.h>
32 #include <rte_config.h>
33 #include <rte_memory.h>
34 #include <rte_lcore.h>
35 #include <rte_atomic.h>
36 #include <rte_branch_prediction.h>
37 #include <rte_memzone.h>
38 #include <rte_pause.h>
39 #include <rte_debug.h>
40 
41 #define RTE_TAILQ_RING_NAME "RTE_RING"
42 
49 };
50 
51 #define RTE_RING_MZ_PREFIX "RG_"
52 
53 #define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \
54  sizeof(RTE_RING_MZ_PREFIX) + 1)
55 
62 };
63 
70  volatile RTE_ATOMIC(uint32_t) head;
71  volatile RTE_ATOMIC(uint32_t) tail;
72  union {
76  uint32_t single;
77  };
78 };
79 
80 union __rte_ring_rts_poscnt {
82  alignas(sizeof(uint64_t)) RTE_ATOMIC(uint64_t) raw;
83  struct {
84  uint32_t cnt;
85  uint32_t pos;
86  } val;
87 };
88 
89 struct rte_ring_rts_headtail {
90  volatile union __rte_ring_rts_poscnt tail;
92  uint32_t htd_max;
93  volatile union __rte_ring_rts_poscnt head;
94 };
95 
96 union __rte_ring_hts_pos {
98  alignas(sizeof(uint64_t)) RTE_ATOMIC(uint64_t) raw;
99  struct {
100  RTE_ATOMIC(uint32_t) head;
101  RTE_ATOMIC(uint32_t) tail;
102  } pos;
103 };
104 
105 struct rte_ring_hts_headtail {
106  volatile union __rte_ring_hts_pos ht;
108 };
109 
120 struct rte_ring {
121  alignas(RTE_CACHE_LINE_SIZE) char name[RTE_RING_NAMESIZE];
123  int flags;
124  const struct rte_memzone *memzone;
126  uint32_t size;
127  uint32_t mask;
128  uint32_t capacity;
131 
134  struct rte_ring_headtail prod;
135  struct rte_ring_hts_headtail hts_prod;
136  struct rte_ring_rts_headtail rts_prod;
137  };
138 
140 
142  union __rte_cache_aligned {
143  struct rte_ring_headtail cons;
144  struct rte_ring_hts_headtail hts_cons;
145  struct rte_ring_rts_headtail rts_cons;
146  };
147 
149 };
150 
151 #define RING_F_SP_ENQ 0x0001
152 #define RING_F_SC_DEQ 0x0002
161 #define RING_F_EXACT_SZ 0x0004
162 #define RTE_RING_SZ_MASK (0x7fffffffU)
164 #define RING_F_MP_RTS_ENQ 0x0008
165 #define RING_F_MC_RTS_DEQ 0x0010
167 #define RING_F_MP_HTS_ENQ 0x0020
168 #define RING_F_MC_HTS_DEQ 0x0040
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 #endif /* _RTE_RING_CORE_H_ */
const struct rte_memzone * memzone
rte_ring_queue_behavior
Definition: rte_ring_core.h:44
#define RTE_CACHE_GUARD
Definition: rte_common.h:584
#define RTE_RING_NAMESIZE
Definition: rte_ring_core.h:53
uint32_t size
rte_ring_sync_type
Definition: rte_ring_core.h:57
uint32_t mask
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:74
uint32_t capacity