DPDK 22.11.6
rte_ring_elem.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright (c) 2019 Arm Limited
4 * Copyright (c) 2010-2017 Intel Corporation
5 * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
6 * All rights reserved.
7 * Derived from FreeBSD's bufring.h
8 * Used as BSD-3 Licensed with permission from Kip Macy.
9 */
10
11#ifndef _RTE_RING_ELEM_H_
12#define _RTE_RING_ELEM_H_
13
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <rte_ring_core.h>
24#include <rte_ring_elem_pvt.h>
25
44ssize_t rte_ring_get_memsize_elem(unsigned int esize, unsigned int count);
45
105struct rte_ring *rte_ring_create_elem(const char *name, unsigned int esize,
106 unsigned int count, int socket_id, unsigned int flags);
107
130static __rte_always_inline unsigned int
131rte_ring_mp_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,
132 unsigned int esize, unsigned int n, unsigned int *free_space)
133{
134 return __rte_ring_do_enqueue_elem(r, obj_table, esize, n,
136}
137
159static __rte_always_inline unsigned int
160rte_ring_sp_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,
161 unsigned int esize, unsigned int n, unsigned int *free_space)
162{
163 return __rte_ring_do_enqueue_elem(r, obj_table, esize, n,
165}
166
167#include <rte_ring_hts.h>
168#include <rte_ring_rts.h>
169
193static __rte_always_inline unsigned int
194rte_ring_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,
195 unsigned int esize, unsigned int n, unsigned int *free_space)
196{
197 switch (r->prod.sync_type) {
198 case RTE_RING_SYNC_MT:
199 return rte_ring_mp_enqueue_bulk_elem(r, obj_table, esize, n,
200 free_space);
201 case RTE_RING_SYNC_ST:
202 return rte_ring_sp_enqueue_bulk_elem(r, obj_table, esize, n,
203 free_space);
205 return rte_ring_mp_rts_enqueue_bulk_elem(r, obj_table, esize, n,
206 free_space);
208 return rte_ring_mp_hts_enqueue_bulk_elem(r, obj_table, esize, n,
209 free_space);
210 }
211
212 /* valid ring should never reach this point */
213 RTE_ASSERT(0);
214 if (free_space != NULL)
215 *free_space = 0;
216 return 0;
217}
218
237static __rte_always_inline int
238rte_ring_mp_enqueue_elem(struct rte_ring *r, void *obj, unsigned int esize)
239{
240 return rte_ring_mp_enqueue_bulk_elem(r, obj, esize, 1, NULL) ? 0 :
241 -ENOBUFS;
242}
243
261static __rte_always_inline int
262rte_ring_sp_enqueue_elem(struct rte_ring *r, void *obj, unsigned int esize)
263{
264 return rte_ring_sp_enqueue_bulk_elem(r, obj, esize, 1, NULL) ? 0 :
265 -ENOBUFS;
266}
267
287static __rte_always_inline int
288rte_ring_enqueue_elem(struct rte_ring *r, void *obj, unsigned int esize)
289{
290 return rte_ring_enqueue_bulk_elem(r, obj, esize, 1, NULL) ? 0 :
291 -ENOBUFS;
292}
293
316static __rte_always_inline unsigned int
317rte_ring_mc_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,
318 unsigned int esize, unsigned int n, unsigned int *available)
319{
320 return __rte_ring_do_dequeue_elem(r, obj_table, esize, n,
322}
323
344static __rte_always_inline unsigned int
345rte_ring_sc_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,
346 unsigned int esize, unsigned int n, unsigned int *available)
347{
348 return __rte_ring_do_dequeue_elem(r, obj_table, esize, n,
350}
351
375static __rte_always_inline unsigned int
376rte_ring_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,
377 unsigned int esize, unsigned int n, unsigned int *available)
378{
379 switch (r->cons.sync_type) {
380 case RTE_RING_SYNC_MT:
381 return rte_ring_mc_dequeue_bulk_elem(r, obj_table, esize, n,
382 available);
383 case RTE_RING_SYNC_ST:
384 return rte_ring_sc_dequeue_bulk_elem(r, obj_table, esize, n,
385 available);
387 return rte_ring_mc_rts_dequeue_bulk_elem(r, obj_table, esize,
388 n, available);
390 return rte_ring_mc_hts_dequeue_bulk_elem(r, obj_table, esize,
391 n, available);
392 }
393
394 /* valid ring should never reach this point */
395 RTE_ASSERT(0);
396 if (available != NULL)
397 *available = 0;
398 return 0;
399}
400
420static __rte_always_inline int
421rte_ring_mc_dequeue_elem(struct rte_ring *r, void *obj_p,
422 unsigned int esize)
423{
424 return rte_ring_mc_dequeue_bulk_elem(r, obj_p, esize, 1, NULL) ? 0 :
425 -ENOENT;
426}
427
444static __rte_always_inline int
445rte_ring_sc_dequeue_elem(struct rte_ring *r, void *obj_p,
446 unsigned int esize)
447{
448 return rte_ring_sc_dequeue_bulk_elem(r, obj_p, esize, 1, NULL) ? 0 :
449 -ENOENT;
450}
451
472static __rte_always_inline int
473rte_ring_dequeue_elem(struct rte_ring *r, void *obj_p, unsigned int esize)
474{
475 return rte_ring_dequeue_bulk_elem(r, obj_p, esize, 1, NULL) ? 0 :
476 -ENOENT;
477}
478
501static __rte_always_inline unsigned int
502rte_ring_mp_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,
503 unsigned int esize, unsigned int n, unsigned int *free_space)
504{
505 return __rte_ring_do_enqueue_elem(r, obj_table, esize, n,
507}
508
530static __rte_always_inline unsigned int
531rte_ring_sp_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,
532 unsigned int esize, unsigned int n, unsigned int *free_space)
533{
534 return __rte_ring_do_enqueue_elem(r, obj_table, esize, n,
536}
537
561static __rte_always_inline unsigned int
562rte_ring_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,
563 unsigned int esize, unsigned int n, unsigned int *free_space)
564{
565 switch (r->prod.sync_type) {
566 case RTE_RING_SYNC_MT:
567 return rte_ring_mp_enqueue_burst_elem(r, obj_table, esize, n,
568 free_space);
569 case RTE_RING_SYNC_ST:
570 return rte_ring_sp_enqueue_burst_elem(r, obj_table, esize, n,
571 free_space);
573 return rte_ring_mp_rts_enqueue_burst_elem(r, obj_table, esize,
574 n, free_space);
576 return rte_ring_mp_hts_enqueue_burst_elem(r, obj_table, esize,
577 n, free_space);
578 }
579
580 /* valid ring should never reach this point */
581 RTE_ASSERT(0);
582 if (free_space != NULL)
583 *free_space = 0;
584 return 0;
585}
586
611static __rte_always_inline unsigned int
612rte_ring_mc_dequeue_burst_elem(struct rte_ring *r, void *obj_table,
613 unsigned int esize, unsigned int n, unsigned int *available)
614{
615 return __rte_ring_do_dequeue_elem(r, obj_table, esize, n,
617}
618
640static __rte_always_inline unsigned int
641rte_ring_sc_dequeue_burst_elem(struct rte_ring *r, void *obj_table,
642 unsigned int esize, unsigned int n, unsigned int *available)
643{
644 return __rte_ring_do_dequeue_elem(r, obj_table, esize, n,
646}
647
671static __rte_always_inline unsigned int
672rte_ring_dequeue_burst_elem(struct rte_ring *r, void *obj_table,
673 unsigned int esize, unsigned int n, unsigned int *available)
674{
675 switch (r->cons.sync_type) {
676 case RTE_RING_SYNC_MT:
677 return rte_ring_mc_dequeue_burst_elem(r, obj_table, esize, n,
678 available);
679 case RTE_RING_SYNC_ST:
680 return rte_ring_sc_dequeue_burst_elem(r, obj_table, esize, n,
681 available);
683 return rte_ring_mc_rts_dequeue_burst_elem(r, obj_table, esize,
684 n, available);
686 return rte_ring_mc_hts_dequeue_burst_elem(r, obj_table, esize,
687 n, available);
688 }
689
690 /* valid ring should never reach this point */
691 RTE_ASSERT(0);
692 if (available != NULL)
693 *available = 0;
694 return 0;
695}
696
697#include <rte_ring_peek.h>
698#include <rte_ring_peek_zc.h>
699
700#include <rte_ring.h>
701
702#ifdef __cplusplus
703}
704#endif
705
706#endif /* _RTE_RING_ELEM_H_ */
#define __rte_always_inline
Definition: rte_common.h:255
@ RTE_RING_QUEUE_VARIABLE
Definition: rte_ring_core.h:47
@ RTE_RING_QUEUE_FIXED
Definition: rte_ring_core.h:45
@ RTE_RING_SYNC_MT
Definition: rte_ring_core.h:57
@ RTE_RING_SYNC_MT_RTS
Definition: rte_ring_core.h:59
@ RTE_RING_SYNC_MT_HTS
Definition: rte_ring_core.h:60
@ RTE_RING_SYNC_ST
Definition: rte_ring_core.h:58
static __rte_always_inline int rte_ring_sp_enqueue_elem(struct rte_ring *r, void *obj, unsigned int esize)
static __rte_always_inline int rte_ring_mc_dequeue_elem(struct rte_ring *r, void *obj_p, unsigned int esize)
static __rte_always_inline unsigned int rte_ring_sc_dequeue_burst_elem(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(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
static __rte_always_inline unsigned int rte_ring_mc_dequeue_bulk_elem(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
static __rte_always_inline int rte_ring_enqueue_elem(struct rte_ring *r, void *obj, unsigned int esize)
struct rte_ring * rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count, int socket_id, unsigned int flags)
static __rte_always_inline int rte_ring_sc_dequeue_elem(struct rte_ring *r, void *obj_p, unsigned int esize)
static __rte_always_inline int rte_ring_dequeue_elem(struct rte_ring *r, void *obj_p, unsigned int esize)
static __rte_always_inline unsigned int rte_ring_mc_dequeue_burst_elem(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(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
static __rte_always_inline int rte_ring_mp_enqueue_elem(struct rte_ring *r, void *obj, unsigned int esize)
static __rte_always_inline unsigned int rte_ring_sc_dequeue_bulk_elem(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
static __rte_always_inline unsigned int rte_ring_mp_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
static __rte_always_inline unsigned int rte_ring_mp_enqueue_burst_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
ssize_t rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
static __rte_always_inline unsigned int rte_ring_sp_enqueue_burst_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
static __rte_always_inline unsigned int rte_ring_dequeue_burst_elem(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_burst_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
static __rte_always_inline unsigned int rte_ring_sp_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
static __rte_always_inline unsigned int rte_ring_mc_hts_dequeue_burst_elem(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
Definition: rte_ring_hts.h:136
static __rte_always_inline unsigned int rte_ring_mp_hts_enqueue_burst_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
Definition: rte_ring_hts.h:107
static __rte_always_inline unsigned int rte_ring_mp_hts_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
Definition: rte_ring_hts.h:53
static __rte_always_inline unsigned int rte_ring_mc_hts_dequeue_bulk_elem(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
Definition: rte_ring_hts.h:80
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_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 __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_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
enum rte_ring_sync_type sync_type
Definition: rte_ring_core.h:74