DPDK  22.03.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 <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 uint32_t head;
70  volatile uint32_t tail;
72  union {
76  uint32_t single;
77  };
78 };
79 
80 union __rte_ring_rts_poscnt {
82  uint64_t raw __rte_aligned(8);
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  uint64_t raw __rte_aligned(8);
99  struct {
100  uint32_t head;
101  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 {
123  int flags;
124  const struct rte_memzone *memzone;
126  uint32_t size;
127  uint32_t mask;
128  uint32_t capacity;
134  union {
135  struct rte_ring_headtail prod;
136  struct rte_ring_hts_headtail hts_prod;
137  struct rte_ring_rts_headtail rts_prod;
139 
144  union {
145  struct rte_ring_headtail cons;
146  struct rte_ring_hts_headtail hts_cons;
147  struct rte_ring_rts_headtail rts_cons;
149 
151 };
152 
153 #define RING_F_SP_ENQ 0x0001
154 #define RING_F_SC_DEQ 0x0002
163 #define RING_F_EXACT_SZ 0x0004
164 #define RTE_RING_SZ_MASK (0x7fffffffU)
166 #define RING_F_MP_RTS_ENQ 0x0008
167 #define RING_F_MC_RTS_DEQ 0x0010
169 #define RING_F_MP_HTS_ENQ 0x0020
170 #define RING_F_MC_HTS_DEQ 0x0040
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif /* _RTE_RING_CORE_H_ */
volatile uint32_t head
Definition: rte_ring_core.h:69
const struct rte_memzone * memzone
rte_ring_queue_behavior
Definition: rte_ring_core.h:43
char pad2 __rte_cache_aligned
char name [RTE_RING_NAMESIZE] __rte_cache_aligned
#define RTE_RING_NAMESIZE
Definition: rte_ring_core.h:52
char pad0 __rte_cache_aligned
uint32_t size
char pad1 __rte_cache_aligned
rte_ring_sync_type
Definition: rte_ring_core.h:56
#define __rte_cache_aligned
Definition: rte_common.h:402
#define RTE_STD_C11
Definition: rte_common.h:42
uint32_t mask
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:74
uint32_t capacity
volatile uint32_t tail
Definition: rte_ring_core.h:70
#define __rte_aligned(a)
Definition: rte_common.h:71