Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2020 Intel Corporation
3 : : */
4 : :
5 : : #include "test_ring_stress_impl.h"
6 : : #include <rte_ring_elem.h>
7 : :
8 : : static inline uint32_t
9 : 0 : _st_ring_dequeue_bulk(struct rte_ring *r, void **obj, uint32_t n,
10 : : uint32_t *avail)
11 : : {
12 : : uint32_t m;
13 : :
14 : : static rte_spinlock_t lck = RTE_SPINLOCK_INITIALIZER;
15 : :
16 : : rte_spinlock_lock(&lck);
17 : :
18 : : m = rte_ring_dequeue_bulk_start(r, obj, n, avail);
19 [ # # ]: 0 : n = (m == n) ? n : 0;
20 : : rte_ring_dequeue_finish(r, n);
21 : :
22 : : rte_spinlock_unlock(&lck);
23 : 0 : return n;
24 : : }
25 : :
26 : : static inline uint32_t
27 : 0 : _st_ring_enqueue_bulk(struct rte_ring *r, void * const *obj, uint32_t n,
28 : : uint32_t *free)
29 : : {
30 : : uint32_t m;
31 : :
32 : : static rte_spinlock_t lck = RTE_SPINLOCK_INITIALIZER;
33 : :
34 : : rte_spinlock_lock(&lck);
35 : :
36 : : m = rte_ring_enqueue_bulk_start(r, n, free);
37 [ # # ]: 0 : n = (m == n) ? n : 0;
38 : : rte_ring_enqueue_finish(r, obj, n);
39 : :
40 : : rte_spinlock_unlock(&lck);
41 : 0 : return n;
42 : : }
43 : :
44 : : static int
45 : : _st_ring_init(struct rte_ring *r, const char *name, uint32_t num)
46 : : {
47 : 0 : return rte_ring_init(r, name, num, RING_F_SP_ENQ | RING_F_SC_DEQ);
48 : : }
49 : :
50 : : const struct test test_ring_st_peek_stress = {
51 : : .name = "ST_PEEK",
52 : : .nb_case = RTE_DIM(tests),
53 : : .cases = tests,
54 : : };
|