DPDK 25.03.0-rc0
rte_ring_peek.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_PEEK_H_
11#define _RTE_RING_PEEK_H_
12
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
69static __rte_always_inline unsigned int
71 unsigned int *free_space)
72{
73 return __rte_ring_do_enqueue_start(r, n, RTE_RING_QUEUE_FIXED,
74 free_space);
75}
76
94static __rte_always_inline unsigned int
95rte_ring_enqueue_bulk_start(struct rte_ring *r, unsigned int n,
96 unsigned int *free_space)
97{
98 return rte_ring_enqueue_bulk_elem_start(r, n, free_space);
99}
100
118static __rte_always_inline unsigned int
120 unsigned int *free_space)
121{
122 return __rte_ring_do_enqueue_start(r, n, RTE_RING_QUEUE_VARIABLE,
123 free_space);
124}
125
143static __rte_always_inline unsigned int
144rte_ring_enqueue_burst_start(struct rte_ring *r, unsigned int n,
145 unsigned int *free_space)
146{
147 return rte_ring_enqueue_burst_elem_start(r, n, free_space);
148}
149
166static __rte_always_inline void
167rte_ring_enqueue_elem_finish(struct rte_ring *r, const void *obj_table,
168 unsigned int esize, unsigned int n)
169{
170 uint32_t tail;
171
172 switch (r->prod.sync_type) {
173 case RTE_RING_SYNC_ST:
174 n = __rte_ring_st_get_tail(&r->prod, &tail, n);
175 if (n != 0)
176 __rte_ring_enqueue_elems(r, tail, obj_table, esize, n);
177 __rte_ring_st_set_head_tail(&r->prod, tail, n, 1);
178 break;
180 n = __rte_ring_hts_get_tail(&r->hts_prod, &tail, n);
181 if (n != 0)
182 __rte_ring_enqueue_elems(r, tail, obj_table, esize, n);
183 __rte_ring_hts_set_head_tail(&r->hts_prod, tail, n, 1);
184 break;
185 case RTE_RING_SYNC_MT:
187 default:
188 /* unsupported mode, shouldn't be here */
189 RTE_ASSERT(0);
190 }
191}
192
205static __rte_always_inline void
206rte_ring_enqueue_finish(struct rte_ring *r, void * const *obj_table,
207 unsigned int n)
208{
209 rte_ring_enqueue_elem_finish(r, obj_table, sizeof(uintptr_t), n);
210}
211
233static __rte_always_inline unsigned int
235 unsigned int esize, unsigned int n, unsigned int *available)
236{
237 return __rte_ring_do_dequeue_start(r, obj_table, esize, n,
238 RTE_RING_QUEUE_FIXED, available);
239}
240
258static __rte_always_inline unsigned int
259rte_ring_dequeue_bulk_start(struct rte_ring *r, void **obj_table,
260 unsigned int n, unsigned int *available)
261{
262 return rte_ring_dequeue_bulk_elem_start(r, obj_table, sizeof(uintptr_t),
263 n, available);
264}
265
287static __rte_always_inline unsigned int
289 unsigned int esize, unsigned int n, unsigned int *available)
290{
291 return __rte_ring_do_dequeue_start(r, obj_table, esize, n,
292 RTE_RING_QUEUE_VARIABLE, available);
293}
294
312static __rte_always_inline unsigned int
313rte_ring_dequeue_burst_start(struct rte_ring *r, void **obj_table,
314 unsigned int n, unsigned int *available)
315{
316 return rte_ring_dequeue_burst_elem_start(r, obj_table,
317 sizeof(uintptr_t), n, available);
318}
319
330static __rte_always_inline void
331rte_ring_dequeue_elem_finish(struct rte_ring *r, unsigned int n)
332{
333 uint32_t tail;
334
335 switch (r->cons.sync_type) {
336 case RTE_RING_SYNC_ST:
337 n = __rte_ring_st_get_tail(&r->cons, &tail, n);
338 __rte_ring_st_set_head_tail(&r->cons, tail, n, 0);
339 break;
341 n = __rte_ring_hts_get_tail(&r->hts_cons, &tail, n);
342 __rte_ring_hts_set_head_tail(&r->hts_cons, tail, n, 0);
343 break;
344 case RTE_RING_SYNC_MT:
346 default:
347 /* unsupported mode, shouldn't be here */
348 RTE_ASSERT(0);
349 }
350}
351
362static __rte_always_inline void
363rte_ring_dequeue_finish(struct rte_ring *r, unsigned int n)
364{
366}
367
368#ifdef __cplusplus
369}
370#endif
371
372#endif /* _RTE_RING_PEEK_H_ */
#define __rte_always_inline
Definition: rte_common.h:413
@ RTE_RING_QUEUE_VARIABLE
Definition: rte_ring_core.h:44
@ RTE_RING_QUEUE_FIXED
Definition: rte_ring_core.h:42
@ RTE_RING_SYNC_MT
Definition: rte_ring_core.h:54
@ RTE_RING_SYNC_MT_RTS
Definition: rte_ring_core.h:56
@ RTE_RING_SYNC_MT_HTS
Definition: rte_ring_core.h:57
@ RTE_RING_SYNC_ST
Definition: rte_ring_core.h:55
static __rte_always_inline void rte_ring_dequeue_finish(struct rte_ring *r, unsigned int n)
static __rte_always_inline unsigned int rte_ring_dequeue_burst_elem_start(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
static __rte_always_inline unsigned int rte_ring_dequeue_bulk_elem_start(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
static __rte_always_inline unsigned int rte_ring_enqueue_bulk_elem_start(struct rte_ring *r, unsigned int n, unsigned int *free_space)
Definition: rte_ring_peek.h:70
static __rte_always_inline unsigned int rte_ring_enqueue_bulk_start(struct rte_ring *r, unsigned int n, unsigned int *free_space)
Definition: rte_ring_peek.h:95
static __rte_always_inline void rte_ring_enqueue_elem_finish(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n)
static __rte_always_inline unsigned int rte_ring_dequeue_burst_start(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
static __rte_always_inline unsigned int rte_ring_enqueue_burst_start(struct rte_ring *r, unsigned int n, unsigned int *free_space)
static __rte_always_inline unsigned int rte_ring_enqueue_burst_elem_start(struct rte_ring *r, unsigned int n, unsigned int *free_space)
static __rte_always_inline void rte_ring_enqueue_finish(struct rte_ring *r, void *const *obj_table, unsigned int n)
static __rte_always_inline void rte_ring_dequeue_elem_finish(struct rte_ring *r, unsigned int n)
static __rte_always_inline unsigned int rte_ring_dequeue_bulk_start(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)