DPDK  24.11.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 #include <stdalign.h>
23 #include <stdio.h>
24 #include <stdint.h>
25 #include <string.h>
26 #include <errno.h>
27 #include <rte_common.h>
28 #include <rte_config.h>
29 #include <rte_memory.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
33 #include <rte_memzone.h>
34 #include <rte_pause.h>
35 #include <rte_debug.h>
36 
37 #define RTE_TAILQ_RING_NAME "RTE_RING"
38 
45 };
46 
47 #define RTE_RING_MZ_PREFIX "RG_"
48 
49 #define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \
50  sizeof(RTE_RING_MZ_PREFIX) + 1)
51 
58 };
59 
66  volatile RTE_ATOMIC(uint32_t) head;
67  volatile RTE_ATOMIC(uint32_t) tail;
68  union {
72  uint32_t single;
73  };
74 };
75 
76 union __rte_ring_rts_poscnt {
78  alignas(sizeof(uint64_t)) RTE_ATOMIC(uint64_t) raw;
79  struct {
80  uint32_t cnt;
81  uint32_t pos;
82  } val;
83 };
84 
85 struct rte_ring_rts_headtail {
86  volatile union __rte_ring_rts_poscnt tail;
88  uint32_t htd_max;
89  volatile union __rte_ring_rts_poscnt head;
90 };
91 
92 union __rte_ring_hts_pos {
94  alignas(sizeof(uint64_t)) RTE_ATOMIC(uint64_t) raw;
95  struct {
96  RTE_ATOMIC(uint32_t) head;
97  RTE_ATOMIC(uint32_t) tail;
98  } pos;
99 };
100 
101 struct rte_ring_hts_headtail {
102  volatile union __rte_ring_hts_pos ht;
104 };
105 
116 struct rte_ring {
117  alignas(RTE_CACHE_LINE_SIZE) char name[RTE_RING_NAMESIZE];
119  int flags;
120  const struct rte_memzone *memzone;
122  uint32_t size;
123  uint32_t mask;
124  uint32_t capacity;
127 
130  struct rte_ring_headtail prod;
131  struct rte_ring_hts_headtail hts_prod;
132  struct rte_ring_rts_headtail rts_prod;
133  };
134 
136 
138  union __rte_cache_aligned {
139  struct rte_ring_headtail cons;
140  struct rte_ring_hts_headtail hts_cons;
141  struct rte_ring_rts_headtail rts_cons;
142  };
143 
145 };
146 
147 #define RING_F_SP_ENQ 0x0001
148 #define RING_F_SC_DEQ 0x0002
157 #define RING_F_EXACT_SZ 0x0004
158 #define RTE_RING_SZ_MASK (0x7fffffffU)
160 #define RING_F_MP_RTS_ENQ 0x0008
161 #define RING_F_MC_RTS_DEQ 0x0010
163 #define RING_F_MP_HTS_ENQ 0x0020
164 #define RING_F_MC_HTS_DEQ 0x0040
166 #endif /* _RTE_RING_CORE_H_ */
const struct rte_memzone * memzone
rte_ring_queue_behavior
Definition: rte_ring_core.h:40
#define RTE_CACHE_GUARD
Definition: rte_common.h:618
#define RTE_RING_NAMESIZE
Definition: rte_ring_core.h:49
uint32_t size
rte_ring_sync_type
Definition: rte_ring_core.h:53
uint32_t mask
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:70
uint32_t capacity