event/cnxk: store and reuse workslot status
[dpdk.git] / drivers / event / cnxk / cnxk_worker.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef __CNXK_WORKER_H__
6 #define __CNXK_WORKER_H__
7
8 #include "cnxk_eventdev.h"
9
10 /* SSO Operations */
11
12 static __rte_always_inline void
13 cnxk_sso_hws_add_work(const uint64_t event_ptr, const uint32_t tag,
14                       const uint8_t new_tt, const uintptr_t grp_base)
15 {
16         uint64_t add_work0;
17
18         add_work0 = tag | ((uint64_t)(new_tt) << 32);
19         roc_store_pair(add_work0, event_ptr, grp_base);
20 }
21
22 static __rte_always_inline void
23 cnxk_sso_hws_swtag_desched(uint32_t tag, uint8_t new_tt, uint16_t grp,
24                            uintptr_t swtag_desched_op)
25 {
26         uint64_t val;
27
28         val = tag | ((uint64_t)(new_tt & 0x3) << 32) | ((uint64_t)grp << 34);
29         __atomic_store_n((uint64_t *)swtag_desched_op, val, __ATOMIC_RELEASE);
30 }
31
32 static __rte_always_inline void
33 cnxk_sso_hws_swtag_norm(uint32_t tag, uint8_t new_tt, uintptr_t swtag_norm_op)
34 {
35         uint64_t val;
36
37         val = tag | ((uint64_t)(new_tt & 0x3) << 32);
38         plt_write64(val, swtag_norm_op);
39 }
40
41 static __rte_always_inline void
42 cnxk_sso_hws_swtag_untag(uintptr_t swtag_untag_op)
43 {
44         plt_write64(0, swtag_untag_op);
45 }
46
47 static __rte_always_inline void
48 cnxk_sso_hws_swtag_flush(uint64_t tag_op, uint64_t flush_op)
49 {
50         if (CNXK_TT_FROM_TAG(plt_read64(tag_op)) == SSO_TT_EMPTY)
51                 return;
52         plt_write64(0, flush_op);
53 }
54
55 static __rte_always_inline uint64_t
56 cnxk_sso_hws_swtag_wait(uintptr_t tag_op)
57 {
58         uint64_t swtp;
59 #ifdef RTE_ARCH_ARM64
60
61         asm volatile(PLT_CPU_FEATURE_PREAMBLE
62                      "          ldr %[swtb], [%[swtp_loc]]      \n"
63                      "          tbz %[swtb], 62, done%=         \n"
64                      "          sevl                            \n"
65                      "rty%=:    wfe                             \n"
66                      "          ldr %[swtb], [%[swtp_loc]]      \n"
67                      "          tbnz %[swtb], 62, rty%=         \n"
68                      "done%=:                                   \n"
69                      : [swtb] "=&r"(swtp)
70                      : [swtp_loc] "r"(tag_op));
71 #else
72         /* Wait for the SWTAG/SWTAG_FULL operation */
73         do {
74                 swtp = plt_read64(tag_op);
75         } while (swtp & BIT_ULL(62));
76 #endif
77
78         return swtp;
79 }
80
81 #endif