DPDK 23.11.2
Loading...
Searching...
No Matches
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
23extern "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>
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
49
50#define RTE_RING_MZ_PREFIX "RG_"
52#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \
53 sizeof(RTE_RING_MZ_PREFIX) + 1)
54
62
69 volatile RTE_ATOMIC(uint32_t) head;
70 volatile RTE_ATOMIC(uint32_t) tail;
71 union {
75 uint32_t single;
76 };
77};
78
79union __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
88struct rte_ring_rts_headtail {
89 volatile union __rte_ring_rts_poscnt tail;
90 enum rte_ring_sync_type sync_type;
91 uint32_t htd_max;
92 volatile union __rte_ring_rts_poscnt head;
93};
94
95union __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
104struct rte_ring_hts_headtail {
105 volatile union __rte_ring_hts_pos ht;
106 enum rte_ring_sync_type sync_type;
107};
108
119struct 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_ */
#define __rte_aligned(a)
Definition rte_common.h:70
#define RTE_CACHE_GUARD
Definition rte_common.h:541
#define RTE_RING_NAMESIZE
rte_ring_queue_behavior
@ RTE_RING_QUEUE_VARIABLE
@ RTE_RING_QUEUE_FIXED
rte_ring_sync_type
@ RTE_RING_SYNC_MT
@ RTE_RING_SYNC_MT_RTS
@ RTE_RING_SYNC_MT_HTS
@ RTE_RING_SYNC_ST
enum rte_ring_sync_type sync_type
uint32_t capacity
char name[RTE_RING_NAMESIZE] __rte_cache_aligned
uint32_t size
uint32_t mask
const struct rte_memzone * memzone