DPDK  23.03.0
rte_ring_rts.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_RTS_H_
11 #define _RTE_RING_RTS_H_
12 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #include <rte_ring_rts_elem_pvt.h>
59 
79 static __rte_always_inline unsigned int
80 rte_ring_mp_rts_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,
81  unsigned int esize, unsigned int n, unsigned int *free_space)
82 {
83  return __rte_ring_do_rts_enqueue_elem(r, obj_table, esize, n,
84  RTE_RING_QUEUE_FIXED, free_space);
85 }
86 
106 static __rte_always_inline unsigned int
107 rte_ring_mc_rts_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,
108  unsigned int esize, unsigned int n, unsigned int *available)
109 {
110  return __rte_ring_do_rts_dequeue_elem(r, obj_table, esize, n,
111  RTE_RING_QUEUE_FIXED, available);
112 }
113 
133 static __rte_always_inline unsigned int
134 rte_ring_mp_rts_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,
135  unsigned int esize, unsigned int n, unsigned int *free_space)
136 {
137  return __rte_ring_do_rts_enqueue_elem(r, obj_table, esize, n,
138  RTE_RING_QUEUE_VARIABLE, free_space);
139 }
140 
162 static __rte_always_inline unsigned int
163 rte_ring_mc_rts_dequeue_burst_elem(struct rte_ring *r, void *obj_table,
164  unsigned int esize, unsigned int n, unsigned int *available)
165 {
166  return __rte_ring_do_rts_dequeue_elem(r, obj_table, esize, n,
167  RTE_RING_QUEUE_VARIABLE, available);
168 }
169 
185 static __rte_always_inline unsigned int
186 rte_ring_mp_rts_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
187  unsigned int n, unsigned int *free_space)
188 {
189  return rte_ring_mp_rts_enqueue_bulk_elem(r, obj_table,
190  sizeof(uintptr_t), n, free_space);
191 }
192 
208 static __rte_always_inline unsigned int
209 rte_ring_mc_rts_dequeue_bulk(struct rte_ring *r, void **obj_table,
210  unsigned int n, unsigned int *available)
211 {
212  return rte_ring_mc_rts_dequeue_bulk_elem(r, obj_table,
213  sizeof(uintptr_t), n, available);
214 }
215 
231 static __rte_always_inline unsigned int
232 rte_ring_mp_rts_enqueue_burst(struct rte_ring *r, void * const *obj_table,
233  unsigned int n, unsigned int *free_space)
234 {
235  return rte_ring_mp_rts_enqueue_burst_elem(r, obj_table,
236  sizeof(uintptr_t), n, free_space);
237 }
238 
256 static __rte_always_inline unsigned int
257 rte_ring_mc_rts_dequeue_burst(struct rte_ring *r, void **obj_table,
258  unsigned int n, unsigned int *available)
259 {
260  return rte_ring_mc_rts_dequeue_burst_elem(r, obj_table,
261  sizeof(uintptr_t), n, available);
262 }
263 
273 static inline uint32_t
275 {
276  if (r->prod.sync_type == RTE_RING_SYNC_MT_RTS)
277  return r->rts_prod.htd_max;
278  return UINT32_MAX;
279 }
280 
292 static inline int
293 rte_ring_set_prod_htd_max(struct rte_ring *r, uint32_t v)
294 {
295  if (r->prod.sync_type != RTE_RING_SYNC_MT_RTS)
296  return -ENOTSUP;
297 
298  r->rts_prod.htd_max = v;
299  return 0;
300 }
301 
311 static inline uint32_t
313 {
314  if (r->cons.sync_type == RTE_RING_SYNC_MT_RTS)
315  return r->rts_cons.htd_max;
316  return UINT32_MAX;
317 }
318 
330 static inline int
331 rte_ring_set_cons_htd_max(struct rte_ring *r, uint32_t v)
332 {
333  if (r->cons.sync_type != RTE_RING_SYNC_MT_RTS)
334  return -ENOTSUP;
335 
336  r->rts_cons.htd_max = v;
337  return 0;
338 }
339 
340 #ifdef __cplusplus
341 }
342 #endif
343 
344 #endif /* _RTE_RING_RTS_H_ */
#define __rte_always_inline
Definition: rte_common.h:255
static uint32_t rte_ring_get_prod_htd_max(const struct rte_ring *r)
Definition: rte_ring_rts.h:274
static __rte_always_inline unsigned int rte_ring_mc_rts_dequeue_bulk_elem(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
Definition: rte_ring_rts.h:107
static __rte_always_inline unsigned int rte_ring_mc_rts_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring_rts.h:209
static uint32_t rte_ring_get_cons_htd_max(const struct rte_ring *r)
Definition: rte_ring_rts.h:312
static __rte_always_inline unsigned int rte_ring_mc_rts_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring_rts.h:257
static __rte_always_inline unsigned int rte_ring_mc_rts_dequeue_burst_elem(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
Definition: rte_ring_rts.h:163
static int rte_ring_set_prod_htd_max(struct rte_ring *r, uint32_t v)
Definition: rte_ring_rts.h:293
static int rte_ring_set_cons_htd_max(struct rte_ring *r, uint32_t v)
Definition: rte_ring_rts.h:331
static __rte_always_inline unsigned int rte_ring_mp_rts_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring_rts.h:232
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:74
static __rte_always_inline unsigned int rte_ring_mp_rts_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
Definition: rte_ring_rts.h:80
static __rte_always_inline unsigned int rte_ring_mp_rts_enqueue_burst_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
Definition: rte_ring_rts.h:134
static __rte_always_inline unsigned int rte_ring_mp_rts_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring_rts.h:186