4 * Copyright (C) Cavium networks Ltd. 2017.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Cavium networks nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <rte_common.h>
36 #include "ssovf_evdev.h"
46 #define __hot __attribute__((hot))
51 static __rte_always_inline uint16_t
52 ssows_get_work(struct ssows *ws, struct rte_event *ev)
54 uint64_t get_work0, get_work1;
55 uint64_t sched_type_queue;
57 ssovf_load_pair(get_work0, get_work1, ws->getwork);
59 sched_type_queue = (get_work0 >> 32) & 0xfff;
60 ws->cur_tt = sched_type_queue & 0x3;
61 ws->cur_grp = sched_type_queue >> 2;
62 sched_type_queue = sched_type_queue << 38;
64 ev->event = sched_type_queue | (get_work0 & 0xffffffff);
69 static __rte_always_inline void
70 ssows_add_work(struct ssows *ws, const uint64_t event_ptr, const uint32_t tag,
71 const uint8_t new_tt, const uint8_t grp)
75 add_work0 = tag | ((uint64_t)(new_tt) << 32);
76 ssovf_store_pair(add_work0, event_ptr, ws->grps[grp]);
79 static __rte_always_inline void
80 ssows_swtag_full(struct ssows *ws, const uint64_t event_ptr, const uint32_t tag,
81 const uint8_t new_tt, const uint8_t grp)
85 swtag_full0 = tag | ((uint64_t)(new_tt & 0x3) << 32) |
86 ((uint64_t)grp << 34);
87 ssovf_store_pair(swtag_full0, event_ptr, (ws->base +
88 SSOW_VHWS_OP_SWTAG_FULL0));
91 static __rte_always_inline void
92 ssows_swtag_desched(struct ssows *ws, uint32_t tag, uint8_t new_tt, uint8_t grp)
96 val = tag | ((uint64_t)(new_tt & 0x3) << 32) | ((uint64_t)grp << 34);
97 ssovf_write64(val, ws->base + SSOW_VHWS_OP_SWTAG_DESCHED);
100 static __rte_always_inline void
101 ssows_swtag_norm(struct ssows *ws, uint32_t tag, uint8_t new_tt)
105 val = tag | ((uint64_t)(new_tt & 0x3) << 32);
106 ssovf_write64(val, ws->base + SSOW_VHWS_OP_SWTAG_NORM);
109 static __rte_always_inline void
110 ssows_swtag_untag(struct ssows *ws)
112 ssovf_write64(0, ws->base + SSOW_VHWS_OP_SWTAG_UNTAG);
113 ws->cur_tt = SSO_SYNC_UNTAGGED;
116 static __rte_always_inline void
117 ssows_upd_wqp(struct ssows *ws, uint8_t grp, uint64_t event_ptr)
119 ssovf_store_pair((uint64_t)grp << 34, event_ptr, (ws->base +
120 SSOW_VHWS_OP_UPD_WQP_GRP0));
123 static __rte_always_inline void
124 ssows_desched(struct ssows *ws)
126 ssovf_write64(0, ws->base + SSOW_VHWS_OP_DESCHED);
129 static __rte_always_inline void
130 ssows_swtag_wait(struct ssows *ws)
132 /* Wait for the SWTAG/SWTAG_FULL operation */
133 while (ssovf_read64(ws->base + SSOW_VHWS_SWTP))