DPDK  21.02.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 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #include <rte_ring_rts_elem_pvt.h>
60 
80 __rte_experimental
81 static __rte_always_inline unsigned int
82 rte_ring_mp_rts_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,
83  unsigned int esize, unsigned int n, unsigned int *free_space)
84 {
85  return __rte_ring_do_rts_enqueue_elem(r, obj_table, esize, n,
86  RTE_RING_QUEUE_FIXED, free_space);
87 }
88 
108 __rte_experimental
109 static __rte_always_inline unsigned int
110 rte_ring_mc_rts_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,
111  unsigned int esize, unsigned int n, unsigned int *available)
112 {
113  return __rte_ring_do_rts_dequeue_elem(r, obj_table, esize, n,
114  RTE_RING_QUEUE_FIXED, available);
115 }
116 
136 __rte_experimental
137 static __rte_always_inline unsigned int
138 rte_ring_mp_rts_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,
139  unsigned int esize, unsigned int n, unsigned int *free_space)
140 {
141  return __rte_ring_do_rts_enqueue_elem(r, obj_table, esize, n,
142  RTE_RING_QUEUE_VARIABLE, free_space);
143 }
144 
166 __rte_experimental
167 static __rte_always_inline unsigned int
168 rte_ring_mc_rts_dequeue_burst_elem(struct rte_ring *r, void *obj_table,
169  unsigned int esize, unsigned int n, unsigned int *available)
170 {
171  return __rte_ring_do_rts_dequeue_elem(r, obj_table, esize, n,
172  RTE_RING_QUEUE_VARIABLE, available);
173 }
174 
190 __rte_experimental
191 static __rte_always_inline unsigned int
192 rte_ring_mp_rts_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
193  unsigned int n, unsigned int *free_space)
194 {
195  return rte_ring_mp_rts_enqueue_bulk_elem(r, obj_table,
196  sizeof(uintptr_t), n, free_space);
197 }
198 
214 __rte_experimental
215 static __rte_always_inline unsigned int
216 rte_ring_mc_rts_dequeue_bulk(struct rte_ring *r, void **obj_table,
217  unsigned int n, unsigned int *available)
218 {
219  return rte_ring_mc_rts_dequeue_bulk_elem(r, obj_table,
220  sizeof(uintptr_t), n, available);
221 }
222 
238 __rte_experimental
239 static __rte_always_inline unsigned int
240 rte_ring_mp_rts_enqueue_burst(struct rte_ring *r, void * const *obj_table,
241  unsigned int n, unsigned int *free_space)
242 {
243  return rte_ring_mp_rts_enqueue_burst_elem(r, obj_table,
244  sizeof(uintptr_t), n, free_space);
245 }
246 
264 __rte_experimental
265 static __rte_always_inline unsigned int
266 rte_ring_mc_rts_dequeue_burst(struct rte_ring *r, void **obj_table,
267  unsigned int n, unsigned int *available)
268 {
269  return rte_ring_mc_rts_dequeue_burst_elem(r, obj_table,
270  sizeof(uintptr_t), n, available);
271 }
272 
282 __rte_experimental
283 static inline uint32_t
285 {
286  if (r->prod.sync_type == RTE_RING_SYNC_MT_RTS)
287  return r->rts_prod.htd_max;
288  return UINT32_MAX;
289 }
290 
302 __rte_experimental
303 static inline int
304 rte_ring_set_prod_htd_max(struct rte_ring *r, uint32_t v)
305 {
306  if (r->prod.sync_type != RTE_RING_SYNC_MT_RTS)
307  return -ENOTSUP;
308 
309  r->rts_prod.htd_max = v;
310  return 0;
311 }
312 
322 __rte_experimental
323 static inline uint32_t
325 {
326  if (r->cons.sync_type == RTE_RING_SYNC_MT_RTS)
327  return r->rts_cons.htd_max;
328  return UINT32_MAX;
329 }
330 
342 __rte_experimental
343 static inline int
344 rte_ring_set_cons_htd_max(struct rte_ring *r, uint32_t v)
345 {
346  if (r->cons.sync_type != RTE_RING_SYNC_MT_RTS)
347  return -ENOTSUP;
348 
349  r->rts_cons.htd_max = v;
350  return 0;
351 }
352 
353 #ifdef __cplusplus
354 }
355 #endif
356 
357 #endif /* _RTE_RING_RTS_H_ */
static __rte_experimental __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:216
#define __rte_always_inline
Definition: rte_common.h:226
static __rte_experimental __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:168
static __rte_experimental int rte_ring_set_cons_htd_max(struct rte_ring *r, uint32_t v)
Definition: rte_ring_rts.h:344
static __rte_experimental __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:266
static __rte_experimental __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:110
static __rte_experimental __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:138
static __rte_experimental int rte_ring_set_prod_htd_max(struct rte_ring *r, uint32_t v)
Definition: rte_ring_rts.h:304
static __rte_experimental __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:82
static __rte_experimental __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:192
static __rte_experimental uint32_t rte_ring_get_cons_htd_max(const struct rte_ring *r)
Definition: rte_ring_rts.h:324
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:77
static __rte_experimental __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:240
static __rte_experimental uint32_t rte_ring_get_prod_htd_max(const struct rte_ring *r)
Definition: rte_ring_rts.h:284