DPDK  22.03.0
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 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #include <rte_ring_peek_elem_pvt.h>
51 
69 static __rte_always_inline unsigned int
70 rte_ring_enqueue_bulk_elem_start(struct rte_ring *r, unsigned int n,
71  unsigned int *free_space)
72 {
73  return __rte_ring_do_enqueue_start(r, n, RTE_RING_QUEUE_FIXED,
74  free_space);
75 }
76 
94 static __rte_always_inline unsigned int
95 rte_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 
118 static __rte_always_inline unsigned int
119 rte_ring_enqueue_burst_elem_start(struct rte_ring *r, unsigned int n,
120  unsigned int *free_space)
121 {
122  return __rte_ring_do_enqueue_start(r, n, RTE_RING_QUEUE_VARIABLE,
123  free_space);
124 }
125 
143 static __rte_always_inline unsigned int
144 rte_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 
166 static __rte_always_inline void
167 rte_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 
205 static __rte_always_inline void
206 rte_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 
233 static __rte_always_inline unsigned int
234 rte_ring_dequeue_bulk_elem_start(struct rte_ring *r, void *obj_table,
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 
258 static __rte_always_inline unsigned int
259 rte_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 
287 static __rte_always_inline unsigned int
288 rte_ring_dequeue_burst_elem_start(struct rte_ring *r, void *obj_table,
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 
312 static __rte_always_inline unsigned int
313 rte_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 
330 static __rte_always_inline void
331 rte_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 
362 static __rte_always_inline void
363 rte_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:228
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 void rte_ring_dequeue_elem_finish(struct rte_ring *r, unsigned int n)
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 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_dequeue_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)
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_dequeue_bulk_elem_start(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:74
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_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)