DPDK  20.05.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 <sys/queue.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 
60 #ifdef ALLOW_EXPERIMENTAL_API
61  RTE_RING_SYNC_MT_RTS,
62  RTE_RING_SYNC_MT_HTS,
63 #endif
64 };
65 
72  volatile uint32_t head;
73  volatile uint32_t tail;
75  union {
79  uint32_t single;
80  };
81 };
82 
83 union __rte_ring_rts_poscnt {
85  uint64_t raw __rte_aligned(8);
86  struct {
87  uint32_t cnt;
88  uint32_t pos;
89  } val;
90 };
91 
92 struct rte_ring_rts_headtail {
93  volatile union __rte_ring_rts_poscnt tail;
94  enum rte_ring_sync_type sync_type;
95  uint32_t htd_max;
96  volatile union __rte_ring_rts_poscnt head;
97 };
98 
99 union __rte_ring_hts_pos {
101  uint64_t raw __rte_aligned(8);
102  struct {
103  uint32_t head;
104  uint32_t tail;
105  } pos;
106 };
107 
108 struct rte_ring_hts_headtail {
109  volatile union __rte_ring_hts_pos ht;
110  enum rte_ring_sync_type sync_type;
111 };
112 
123 struct rte_ring {
124  /*
125  * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI
126  * compatibility requirements, it could be changed to RTE_RING_NAMESIZE
127  * next time the ABI changes
128  */
131  int flags;
132  const struct rte_memzone *memzone;
134  uint32_t size;
135  uint32_t mask;
136  uint32_t capacity;
142  union {
143  struct rte_ring_headtail prod;
144  struct rte_ring_hts_headtail hts_prod;
145  struct rte_ring_rts_headtail rts_prod;
147 
152  union {
153  struct rte_ring_headtail cons;
154  struct rte_ring_hts_headtail hts_cons;
155  struct rte_ring_rts_headtail rts_cons;
157 
159 };
160 
161 #define RING_F_SP_ENQ 0x0001
162 #define RING_F_SC_DEQ 0x0002
171 #define RING_F_EXACT_SZ 0x0004
172 #define RTE_RING_SZ_MASK (0x7fffffffU)
174 #define RING_F_MP_RTS_ENQ 0x0008
175 #define RING_F_MC_RTS_DEQ 0x0010
177 #define RING_F_MP_HTS_ENQ 0x0020
178 #define RING_F_MC_HTS_DEQ 0x0040
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* _RTE_RING_CORE_H_ */
volatile uint32_t head
Definition: rte_ring_core.h:72
const struct rte_memzone * memzone
rte_ring_queue_behavior
Definition: rte_ring_core.h:44
char pad2 __rte_cache_aligned
char name[RTE_MEMZONE_NAMESIZE] __rte_cache_aligned
char pad0 __rte_cache_aligned
uint32_t size
char pad1 __rte_cache_aligned
rte_ring_sync_type
Definition: rte_ring_core.h:57
#define RTE_STD_C11
Definition: rte_common.h:40
uint32_t mask
__extension__ struct rte_eth_link __rte_aligned(8)
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:77
uint32_t capacity
volatile uint32_t tail
Definition: rte_ring_core.h:73
#define RTE_MEMZONE_NAMESIZE
Definition: rte_memzone.h:51