dpdk/app/test/test_ring_st_peek_stress_zc.c
<<
>>
Prefs
   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
   9static inline uint32_t
  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        static rte_spinlock_t lck = RTE_SPINLOCK_INITIALIZER;
  17
  18        rte_spinlock_lock(&lck);
  19
  20        m = rte_ring_dequeue_zc_bulk_start(r, n, &zcd, avail);
  21        if (m != 0) {
  22                /* Copy the data from the ring */
  23                test_ring_copy_from(&zcd, obj, -1, m);
  24                rte_ring_dequeue_zc_finish(r, m);
  25        }
  26
  27        rte_spinlock_unlock(&lck);
  28        return m;
  29}
  30
  31static inline uint32_t
  32_st_ring_enqueue_bulk(struct rte_ring *r, void * const *obj, uint32_t n,
  33        uint32_t *free)
  34{
  35        uint32_t m;
  36        struct rte_ring_zc_data zcd;
  37
  38        static rte_spinlock_t lck = RTE_SPINLOCK_INITIALIZER;
  39
  40        rte_spinlock_lock(&lck);
  41
  42        m = rte_ring_enqueue_zc_bulk_start(r, n, &zcd, free);
  43        if (m != 0) {
  44                /* Copy the data from the ring */
  45                test_ring_copy_to(&zcd, obj, -1, m);
  46                rte_ring_enqueue_zc_finish(r, m);
  47        }
  48
  49        rte_spinlock_unlock(&lck);
  50        return m;
  51}
  52
  53static int
  54_st_ring_init(struct rte_ring *r, const char *name, uint32_t num)
  55{
  56        return rte_ring_init(r, name, num, RING_F_SP_ENQ | RING_F_SC_DEQ);
  57}
  58
  59const struct test test_ring_st_peek_stress_zc = {
  60        .name = "ST_PEEK_ZC",
  61        .nb_case = RTE_DIM(tests),
  62        .cases = tests,
  63};
  64