DPDK  24.03.0-rc1
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 <stdio.h>
27 #include <stdint.h>
28 #include <string.h>
29 #include <errno.h>
30 #include <rte_common.h>
31 #include <rte_config.h>
32 #include <rte_memory.h>
33 #include <rte_lcore.h>
34 #include <rte_atomic.h>
35 #include <rte_branch_prediction.h>
36 #include <rte_memzone.h>
37 #include <rte_pause.h>
38 #include <rte_debug.h>
39 
40 #define RTE_TAILQ_RING_NAME "RTE_RING"
41 
48 };
49 
50 #define RTE_RING_MZ_PREFIX "RG_"
51 
52 #define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \
53  sizeof(RTE_RING_MZ_PREFIX) + 1)
54 
61 };
62 
69  volatile RTE_ATOMIC(uint32_t) head;
70  volatile RTE_ATOMIC(uint32_t) tail;
71  union {
75  uint32_t single;
76  };
77 };
78 
79 union __rte_ring_rts_poscnt {
81  RTE_ATOMIC(uint64_t) raw __rte_aligned(8);
82  struct {
83  uint32_t cnt;
84  uint32_t pos;
85  } val;
86 };
87 
88 struct rte_ring_rts_headtail {
89  volatile union __rte_ring_rts_poscnt tail;
91  uint32_t htd_max;
92  volatile union __rte_ring_rts_poscnt head;
93 };
94 
95 union __rte_ring_hts_pos {
97  RTE_ATOMIC(uint64_t) raw __rte_aligned(8);
98  struct {
99  RTE_ATOMIC(uint32_t) head;
100  RTE_ATOMIC(uint32_t) tail;
101  } pos;
102 };
103 
104 struct rte_ring_hts_headtail {
105  volatile union __rte_ring_hts_pos ht;
107 };
108 
119 struct rte_ring {
122  int flags;
123  const struct rte_memzone *memzone;
125  uint32_t size;
126  uint32_t mask;
127  uint32_t capacity;
130 
132  union {
133  struct rte_ring_headtail prod;
134  struct rte_ring_hts_headtail hts_prod;
135  struct rte_ring_rts_headtail rts_prod;
137 
139 
141  union {
142  struct rte_ring_headtail cons;
143  struct rte_ring_hts_headtail hts_cons;
144  struct rte_ring_rts_headtail rts_cons;
146 
148 };
149 
150 #define RING_F_SP_ENQ 0x0001
151 #define RING_F_SC_DEQ 0x0002
160 #define RING_F_EXACT_SZ 0x0004
161 #define RTE_RING_SZ_MASK (0x7fffffffU)
163 #define RING_F_MP_RTS_ENQ 0x0008
164 #define RING_F_MC_RTS_DEQ 0x0010
166 #define RING_F_MP_HTS_ENQ 0x0020
167 #define RING_F_MC_HTS_DEQ 0x0040
169 #ifdef __cplusplus
170 }
171 #endif
172 
173 #endif /* _RTE_RING_CORE_H_ */
const struct rte_memzone * memzone
rte_ring_queue_behavior
Definition: rte_ring_core.h:43
#define RTE_CACHE_GUARD
Definition: rte_common.h:561
char name [RTE_RING_NAMESIZE] __rte_cache_aligned
#define RTE_RING_NAMESIZE
Definition: rte_ring_core.h:52
uint32_t size
rte_ring_sync_type
Definition: rte_ring_core.h:56
#define __rte_cache_aligned
Definition: rte_common.h:544
uint32_t mask
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:73
uint32_t capacity
#define __rte_aligned(a)
Definition: rte_common.h:71