1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
5 #ifndef __OTX2_WORKER_DUAL_H__
6 #define __OTX2_WORKER_DUAL_H__
8 #include <rte_branch_prediction.h>
9 #include <rte_common.h>
11 #include <otx2_common.h>
12 #include "otx2_evdev.h"
13 #include "otx2_evdev_crypto_adptr_dp.h"
16 static __rte_always_inline uint16_t
17 otx2_ssogws_dual_get_work(struct otx2_ssogws_state *ws,
18 struct otx2_ssogws_state *ws_pair,
19 struct rte_event *ev, const uint32_t flags,
20 const void * const lookup_mem,
21 struct otx2_timesync_info * const tstamp)
23 const uint64_t set_gw = BIT_ULL(16) | 1;
24 union otx2_sso_event event;
29 if (flags & NIX_RX_OFFLOAD_PTYPE_F)
30 rte_prefetch_non_temporal(lookup_mem);
34 " ldr %[tag], [%[tag_loc]] \n"
35 " ldr %[wqp], [%[wqp_loc]] \n"
36 " tbnz %[tag], 63, rty%= \n"
37 "done%=: str %[gw], [%[pong]] \n"
39 " prfm pldl1keep, [%[wqp], #8]\n"
40 " sub %[mbuf], %[wqp], #0x80 \n"
41 " prfm pldl1keep, [%[mbuf]] \n"
42 : [tag] "=&r" (event.get_work0),
43 [wqp] "=&r" (get_work1),
45 : [tag_loc] "r" (ws->tag_op),
46 [wqp_loc] "r" (ws->wqp_op),
48 [pong] "r" (ws_pair->getwrk_op)
51 event.get_work0 = otx2_read64(ws->tag_op);
52 while ((BIT_ULL(63)) & event.get_work0)
53 event.get_work0 = otx2_read64(ws->tag_op);
54 get_work1 = otx2_read64(ws->wqp_op);
55 otx2_write64(set_gw, ws_pair->getwrk_op);
57 rte_prefetch0((const void *)get_work1);
58 mbuf = (uint64_t)((char *)get_work1 - sizeof(struct rte_mbuf));
59 rte_prefetch0((const void *)mbuf);
61 event.get_work0 = (event.get_work0 & (0x3ull << 32)) << 6 |
62 (event.get_work0 & (0x3FFull << 36)) << 4 |
63 (event.get_work0 & 0xffffffff);
64 ws->cur_tt = event.sched_type;
65 ws->cur_grp = event.queue_id;
67 if (event.sched_type != SSO_TT_EMPTY) {
68 if ((flags & NIX_RX_OFFLOAD_SECURITY_F) &&
69 (event.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
70 get_work1 = otx2_handle_crypto_event(get_work1);
71 } else if (event.event_type == RTE_EVENT_TYPE_ETHDEV) {
72 uint8_t port = event.sub_event_type;
74 event.sub_event_type = 0;
75 otx2_wqe_to_mbuf(get_work1, mbuf, port,
76 event.flow_id, flags, lookup_mem);
77 /* Extracting tstamp, if PTP enabled. CGX will prepend
78 * the timestamp at starting of packet data and it can
79 * be derieved from WQE 9 dword which corresponds to SG
81 * rte_pktmbuf_mtod_offset can be used for this purpose
82 * but it brings down the performance as it reads
83 * mbuf->buf_addr which is not part of cache in general
86 tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)
89 otx2_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp,
90 flags, (uint64_t *)tstamp_ptr);
95 ev->event = event.get_work0;
101 static __rte_always_inline void
102 otx2_ssogws_dual_add_work(struct otx2_ssogws_dual *ws, const uint64_t event_ptr,
103 const uint32_t tag, const uint8_t new_tt,
108 add_work0 = tag | ((uint64_t)(new_tt) << 32);
109 otx2_store_pair(add_work0, event_ptr, ws->grps_base[grp]);