net/bnxt: fix link during port toggle
[dpdk.git] / lib / librte_eventdev / rte_event_ring.h
index ea9b688..c0861b0 100644 (file)
@@ -1,33 +1,6 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of Intel Corporation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2017 Intel Corporation
+ * Copyright(c) 2019 Arm Limited
  */
 
 /**
@@ -47,6 +20,7 @@
 #include <rte_memory.h>
 #include <rte_malloc.h>
 #include <rte_ring.h>
+#include <rte_ring_elem.h>
 #include "rte_eventdev.h"
 
 #define RTE_TAILQ_EVENT_RING_NAME "RTE_EVENT_RING"
@@ -116,23 +90,17 @@ rte_event_ring_enqueue_burst(struct rte_event_ring *r,
                const struct rte_event *events,
                unsigned int n, uint16_t *free_space)
 {
-       uint32_t prod_head, prod_next;
-       uint32_t free_entries;
-
-       n = __rte_ring_move_prod_head(&r->r, r->r.prod.single, n,
-                       RTE_RING_QUEUE_VARIABLE,
-                       &prod_head, &prod_next, &free_entries);
-       if (n == 0)
-               goto end;
+       unsigned int num;
+       uint32_t space;
 
-       ENQUEUE_PTRS(&r->r, &r[1], prod_head, events, n, struct rte_event);
-       rte_smp_wmb();
+       num = rte_ring_enqueue_burst_elem(&r->r, events,
+                               sizeof(struct rte_event), n,
+                               &space);
 
-       update_tail(&r->r.prod, prod_head, prod_next, 1);
-end:
        if (free_space != NULL)
-               *free_space = free_entries - n;
-       return n;
+               *free_space = space;
+
+       return num;
 }
 
 /**
@@ -158,24 +126,17 @@ rte_event_ring_dequeue_burst(struct rte_event_ring *r,
                struct rte_event *events,
                unsigned int n, uint16_t *available)
 {
-       uint32_t cons_head, cons_next;
-       uint32_t entries;
-
-       n = __rte_ring_move_cons_head(&r->r, r->r.cons.single, n,
-                       RTE_RING_QUEUE_VARIABLE,
-                       &cons_head, &cons_next, &entries);
-       if (n == 0)
-               goto end;
+       unsigned int num;
+       uint32_t remaining;
 
-       DEQUEUE_PTRS(&r->r, &r[1], cons_head, events, n, struct rte_event);
-       rte_smp_rmb();
+       num = rte_ring_dequeue_burst_elem(&r->r, events,
+                               sizeof(struct rte_event), n,
+                               &remaining);
 
-       update_tail(&r->r.cons, cons_head, cons_next, 1);
-
-end:
        if (available != NULL)
-               *available = entries - n;
-       return n;
+               *available = remaining;
+
+       return num;
 }
 
 /*