1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
5 #include "otx2_worker.h"
7 static __rte_noinline uint8_t
8 otx2_ssogws_new_event(struct otx2_ssogws *ws, const struct rte_event *ev)
10 const uint32_t tag = (uint32_t)ev->event;
11 const uint8_t new_tt = ev->sched_type;
12 const uint64_t event_ptr = ev->u64;
13 const uint16_t grp = ev->queue_id;
15 if (ws->xaq_lmt <= *ws->fc_mem)
18 otx2_ssogws_add_work(ws, event_ptr, tag, new_tt, grp);
23 static __rte_always_inline void
24 otx2_ssogws_fwd_swtag(struct otx2_ssogws *ws, const struct rte_event *ev)
26 const uint32_t tag = (uint32_t)ev->event;
27 const uint8_t new_tt = ev->sched_type;
28 const uint8_t cur_tt = ws->cur_tt;
31 * cur_tt/new_tt SSO_SYNC_ORDERED SSO_SYNC_ATOMIC SSO_SYNC_UNTAGGED
33 * SSO_SYNC_ORDERED norm norm untag
34 * SSO_SYNC_ATOMIC norm norm untag
35 * SSO_SYNC_UNTAGGED norm norm NOOP
38 if (new_tt == SSO_SYNC_UNTAGGED) {
39 if (cur_tt != SSO_SYNC_UNTAGGED)
40 otx2_ssogws_swtag_untag(ws);
42 otx2_ssogws_swtag_norm(ws, tag, new_tt);
48 static __rte_always_inline void
49 otx2_ssogws_fwd_group(struct otx2_ssogws *ws, const struct rte_event *ev,
52 const uint32_t tag = (uint32_t)ev->event;
53 const uint8_t new_tt = ev->sched_type;
55 otx2_write64(ev->u64, OTX2_SSOW_GET_BASE_ADDR(ws->getwrk_op) +
56 SSOW_LF_GWS_OP_UPD_WQP_GRP1);
58 otx2_ssogws_swtag_desched(ws, tag, new_tt, grp);
61 static __rte_always_inline void
62 otx2_ssogws_forward_event(struct otx2_ssogws *ws, const struct rte_event *ev)
64 const uint8_t grp = ev->queue_id;
66 /* Group hasn't changed, Use SWTAG to forward the event */
67 if (ws->cur_grp == grp)
68 otx2_ssogws_fwd_swtag(ws, ev);
71 * Group has been changed for group based work pipelining,
72 * Use deschedule/add_work operation to transfer the event to
75 otx2_ssogws_fwd_group(ws, ev, grp);
78 static __rte_always_inline void
79 otx2_ssogws_release_event(struct otx2_ssogws *ws)
81 otx2_ssogws_swtag_flush(ws);
85 otx2_ssogws_deq(void *port, struct rte_event *ev, uint64_t timeout_ticks)
87 struct otx2_ssogws *ws = port;
89 RTE_SET_USED(timeout_ticks);
93 otx2_ssogws_swtag_wait(ws);
97 return otx2_ssogws_get_work(ws, ev);
101 otx2_ssogws_deq_burst(void *port, struct rte_event ev[], uint16_t nb_events,
102 uint64_t timeout_ticks)
104 RTE_SET_USED(nb_events);
106 return otx2_ssogws_deq(port, ev, timeout_ticks);
110 otx2_ssogws_deq_timeout(void *port, struct rte_event *ev,
111 uint64_t timeout_ticks)
113 struct otx2_ssogws *ws = port;
119 otx2_ssogws_swtag_wait(ws);
123 ret = otx2_ssogws_get_work(ws, ev);
124 for (iter = 1; iter < timeout_ticks && (ret == 0); iter++)
125 ret = otx2_ssogws_get_work(ws, ev);
131 otx2_ssogws_deq_timeout_burst(void *port, struct rte_event ev[],
132 uint16_t nb_events, uint64_t timeout_ticks)
134 RTE_SET_USED(nb_events);
136 return otx2_ssogws_deq_timeout(port, ev, timeout_ticks);
140 otx2_ssogws_enq(void *port, const struct rte_event *ev)
142 struct otx2_ssogws *ws = port;
145 case RTE_EVENT_OP_NEW:
147 return otx2_ssogws_new_event(ws, ev);
148 case RTE_EVENT_OP_FORWARD:
149 otx2_ssogws_forward_event(ws, ev);
151 case RTE_EVENT_OP_RELEASE:
152 otx2_ssogws_release_event(ws);
162 otx2_ssogws_enq_burst(void *port, const struct rte_event ev[],
165 RTE_SET_USED(nb_events);
166 return otx2_ssogws_enq(port, ev);
170 otx2_ssogws_enq_new_burst(void *port, const struct rte_event ev[],
173 struct otx2_ssogws *ws = port;
177 if (ws->xaq_lmt <= *ws->fc_mem)
180 for (i = 0; i < nb_events && rc; i++)
181 rc = otx2_ssogws_new_event(ws, &ev[i]);
187 otx2_ssogws_enq_fwd_burst(void *port, const struct rte_event ev[],
190 struct otx2_ssogws *ws = port;
192 RTE_SET_USED(nb_events);
193 otx2_ssogws_forward_event(ws, ev);