1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
5 #ifndef __CN10K_WORKER_H__
6 #define __CN10K_WORKER_H__
8 #include "cnxk_ethdev.h"
9 #include "cnxk_eventdev.h"
10 #include "cnxk_worker.h"
12 #include "cn10k_ethdev.h"
17 static __rte_always_inline uint8_t
18 cn10k_sso_hws_new_event(struct cn10k_sso_hws *ws, const struct rte_event *ev)
20 const uint32_t tag = (uint32_t)ev->event;
21 const uint8_t new_tt = ev->sched_type;
22 const uint64_t event_ptr = ev->u64;
23 const uint16_t grp = ev->queue_id;
25 rte_atomic_thread_fence(__ATOMIC_ACQ_REL);
26 if (ws->xaq_lmt <= *ws->fc_mem)
29 cnxk_sso_hws_add_work(event_ptr, tag, new_tt, ws->grps_base[grp]);
33 static __rte_always_inline void
34 cn10k_sso_hws_fwd_swtag(struct cn10k_sso_hws *ws, const struct rte_event *ev)
36 const uint32_t tag = (uint32_t)ev->event;
37 const uint8_t new_tt = ev->sched_type;
38 const uint8_t cur_tt =
39 CNXK_TT_FROM_TAG(plt_read64(ws->base + SSOW_LF_GWS_WQE0));
42 * cur_tt/new_tt SSO_TT_ORDERED SSO_TT_ATOMIC SSO_TT_UNTAGGED
44 * SSO_TT_ORDERED norm norm untag
45 * SSO_TT_ATOMIC norm norm untag
46 * SSO_TT_UNTAGGED norm norm NOOP
49 if (new_tt == SSO_TT_UNTAGGED) {
50 if (cur_tt != SSO_TT_UNTAGGED)
51 cnxk_sso_hws_swtag_untag(ws->base +
52 SSOW_LF_GWS_OP_SWTAG_UNTAG);
54 cnxk_sso_hws_swtag_norm(tag, new_tt,
55 ws->base + SSOW_LF_GWS_OP_SWTAG_NORM);
60 static __rte_always_inline void
61 cn10k_sso_hws_fwd_group(struct cn10k_sso_hws *ws, const struct rte_event *ev,
64 const uint32_t tag = (uint32_t)ev->event;
65 const uint8_t new_tt = ev->sched_type;
67 plt_write64(ev->u64, ws->base + SSOW_LF_GWS_OP_UPD_WQP_GRP1);
68 cnxk_sso_hws_swtag_desched(tag, new_tt, grp,
69 ws->base + SSOW_LF_GWS_OP_SWTAG_DESCHED);
72 static __rte_always_inline void
73 cn10k_sso_hws_forward_event(struct cn10k_sso_hws *ws,
74 const struct rte_event *ev)
76 const uint8_t grp = ev->queue_id;
78 /* Group hasn't changed, Use SWTAG to forward the event */
79 if (CNXK_GRP_FROM_TAG(plt_read64(ws->base + SSOW_LF_GWS_WQE0)) == grp)
80 cn10k_sso_hws_fwd_swtag(ws, ev);
83 * Group has been changed for group based work pipelining,
84 * Use deschedule/add_work operation to transfer the event to
87 cn10k_sso_hws_fwd_group(ws, ev, grp);
90 static __rte_always_inline uint16_t
91 cn10k_sso_hws_get_work(struct cn10k_sso_hws *ws, struct rte_event *ev)
98 gw.get_work = ws->gw_wdata;
99 #if defined(RTE_ARCH_ARM64) && !defined(__clang__)
101 PLT_CPU_FEATURE_PREAMBLE
102 "caspl %[wdata], %H[wdata], %[wdata], %H[wdata], [%[gw_loc]]\n"
103 : [wdata] "+r"(gw.get_work)
104 : [gw_loc] "r"(ws->base + SSOW_LF_GWS_OP_GET_WORK0)
107 plt_write64(gw.u64[0], ws->base + SSOW_LF_GWS_OP_GET_WORK0);
109 roc_load_pair(gw.u64[0], gw.u64[1],
110 ws->base + SSOW_LF_GWS_WQE0);
111 } while (gw.u64[0] & BIT_ULL(63));
113 gw.u64[0] = (gw.u64[0] & (0x3ull << 32)) << 6 |
114 (gw.u64[0] & (0x3FFull << 36)) << 4 |
115 (gw.u64[0] & 0xffffffff);
117 ev->event = gw.u64[0];
123 /* Used in cleaning up workslot. */
124 static __rte_always_inline uint16_t
125 cn10k_sso_hws_get_work_empty(struct cn10k_sso_hws *ws, struct rte_event *ev)
128 __uint128_t get_work;
132 #ifdef RTE_ARCH_ARM64
133 asm volatile(PLT_CPU_FEATURE_PREAMBLE
134 " ldp %[tag], %[wqp], [%[tag_loc]] \n"
135 " tbz %[tag], 63, done%= \n"
138 " ldp %[tag], %[wqp], [%[tag_loc]] \n"
139 " tbnz %[tag], 63, rty%= \n"
141 : [tag] "=&r"(gw.u64[0]), [wqp] "=&r"(gw.u64[1])
142 : [tag_loc] "r"(ws->base + SSOW_LF_GWS_WQE0)
146 roc_load_pair(gw.u64[0], gw.u64[1],
147 ws->base + SSOW_LF_GWS_WQE0);
148 } while (gw.u64[0] & BIT_ULL(63));
151 gw.u64[0] = (gw.u64[0] & (0x3ull << 32)) << 6 |
152 (gw.u64[0] & (0x3FFull << 36)) << 4 |
153 (gw.u64[0] & 0xffffffff);
155 ev->event = gw.u64[0];
161 /* CN10K Fastpath functions. */
162 uint16_t __rte_hot cn10k_sso_hws_enq(void *port, const struct rte_event *ev);
163 uint16_t __rte_hot cn10k_sso_hws_enq_burst(void *port,
164 const struct rte_event ev[],
166 uint16_t __rte_hot cn10k_sso_hws_enq_new_burst(void *port,
167 const struct rte_event ev[],
169 uint16_t __rte_hot cn10k_sso_hws_enq_fwd_burst(void *port,
170 const struct rte_event ev[],
173 uint16_t __rte_hot cn10k_sso_hws_deq(void *port, struct rte_event *ev,
174 uint64_t timeout_ticks);
175 uint16_t __rte_hot cn10k_sso_hws_deq_burst(void *port, struct rte_event ev[],
177 uint64_t timeout_ticks);
178 uint16_t __rte_hot cn10k_sso_hws_tmo_deq(void *port, struct rte_event *ev,
179 uint64_t timeout_ticks);
180 uint16_t __rte_hot cn10k_sso_hws_tmo_deq_burst(void *port,
181 struct rte_event ev[],
183 uint64_t timeout_ticks);