xref: /dpdk/drivers/common/cnxk/roc_sso_dp.h (revision 0a09bf3804c961b197c5f5f4c7be7ba3bdc5e985)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2022 Marvell.
3  */
4 
5 #ifndef _ROC_SSO_DP_H_
6 #define _ROC_SSO_DP_H_
7 
8 static __plt_always_inline uint64_t
roc_sso_hws_head_wait(uintptr_t base)9 roc_sso_hws_head_wait(uintptr_t base)
10 {
11 	uintptr_t tag_op = base + SSOW_LF_GWS_TAG;
12 	uint64_t tag;
13 
14 #if defined(__aarch64__)
15 	asm volatile(PLT_CPU_FEATURE_PREAMBLE
16 		     "		ldr %[tag], [%[tag_op]]		\n"
17 		     "		tbnz %[tag], 35, .Ldone%=	\n"
18 		     "		sevl				\n"
19 		     ".Lrty%=:	wfe				\n"
20 		     "		ldr %[tag], [%[tag_op]]		\n"
21 		     "		tbz %[tag], 35, .Lrty%=		\n"
22 		     ".Ldone%=:					\n"
23 		     : [tag] "=&r"(tag)
24 		     : [tag_op] "r"(tag_op));
25 #else
26 	do {
27 		tag = plt_read64(tag_op);
28 	} while (!(tag & BIT_ULL(35)));
29 #endif
30 	return tag;
31 }
32 
33 static __plt_always_inline uint8_t
roc_sso_hws_is_head(uintptr_t base)34 roc_sso_hws_is_head(uintptr_t base)
35 {
36 	uintptr_t tag_op = base + SSOW_LF_GWS_TAG;
37 
38 	return !!(plt_read64(tag_op) & BIT_ULL(35));
39 }
40 
41 #endif /* _ROC_SSO_DP_H_ */
42