1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Arm Limited
3 */
4
5 #include "test_ring.h"
6 #include "test_ring_stress_impl.h"
7 #include <rte_ring_elem.h>
8
9 static inline uint32_t
_st_ring_dequeue_bulk(struct rte_ring * r,void ** obj,uint32_t n,uint32_t * avail)10 _st_ring_dequeue_bulk(struct rte_ring *r, void **obj, uint32_t n,
11 uint32_t *avail)
12 {
13 uint32_t m;
14 struct rte_ring_zc_data zcd;
15
16 m = rte_ring_dequeue_zc_bulk_start(r, n, &zcd, avail);
17 if (m != 0) {
18 /* Copy the data from the ring */
19 test_ring_copy_from(&zcd, obj, -1, n);
20 rte_ring_dequeue_zc_finish(r, n);
21 }
22
23 return n;
24 }
25
26 static inline uint32_t
_st_ring_enqueue_bulk(struct rte_ring * r,void * const * obj,uint32_t n,uint32_t * free)27 _st_ring_enqueue_bulk(struct rte_ring *r, void * const *obj, uint32_t n,
28 uint32_t *free)
29 {
30 uint32_t m;
31 struct rte_ring_zc_data zcd;
32
33 m = rte_ring_enqueue_zc_bulk_start(r, n, &zcd, free);
34 if (m != 0) {
35 /* Copy the data from the ring */
36 test_ring_copy_to(&zcd, obj, -1, n);
37 rte_ring_enqueue_zc_finish(r, n);
38 }
39
40 return n;
41 }
42
43 static int
_st_ring_init(struct rte_ring * r,const char * name,uint32_t num)44 _st_ring_init(struct rte_ring *r, const char *name, uint32_t num)
45 {
46 return rte_ring_init(r, name, num,
47 RING_F_MP_HTS_ENQ | RING_F_MC_HTS_DEQ);
48 }
49
50 const struct test test_ring_mt_peek_stress_zc = {
51 .name = "MT_PEEK_ZC",
52 .nb_case = RTE_DIM(tests),
53 .cases = tests,
54 };
55