Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2016 Cavium, Inc
3 : : */
4 : :
5 : : #ifndef _RTE_IO_X86_H_
6 : : #define _RTE_IO_X86_H_
7 : :
8 : : #include <rte_compat.h>
9 : : #include "rte_cpuflags.h"
10 : :
11 : : #define RTE_NATIVE_WRITE32_WC
12 : : #include "generic/rte_io.h"
13 : :
14 : : #ifdef __cplusplus
15 : : extern "C" {
16 : : #endif
17 : :
18 : : /**
19 : : * @internal
20 : : * MOVDIRI wrapper.
21 : : */
22 : : static __rte_always_inline void
23 : : __rte_x86_movdiri(uint32_t value, volatile void *addr)
24 : : {
25 : 0 : asm volatile(
26 : : /* MOVDIRI */
27 : : ".byte 0x0f, 0x38, 0xf9, 0x02"
28 : : :
29 : : : "a" (value), "d" (addr));
30 : 0 : }
31 : :
32 : : __rte_experimental
33 : : static __rte_always_inline void
34 : : rte_write32_wc_relaxed(uint32_t value, volatile void *addr)
35 : : {
36 : : static int _x86_movdiri_flag = -1;
37 : :
38 [ # # # # : 0 : if (_x86_movdiri_flag == 1) {
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
39 : : __rte_x86_movdiri(value, addr);
40 [ # # # # : 0 : } else if (_x86_movdiri_flag == 0) {
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
41 : : rte_write32_relaxed(value, addr);
42 : : } else {
43 : 0 : _x86_movdiri_flag =
44 : 0 : (rte_cpu_get_flag_enabled(RTE_CPUFLAG_MOVDIRI) > 0);
45 [ # # # # : 0 : if (_x86_movdiri_flag == 1)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
46 : : __rte_x86_movdiri(value, addr);
47 : : else
48 : : rte_write32_relaxed(value, addr);
49 : : }
50 : : }
51 : :
52 : : __rte_experimental
53 : : static __rte_always_inline void
54 : : rte_write32_wc(uint32_t value, volatile void *addr)
55 : : {
56 : : /* gcc complains about calling this experimental function even
57 : : * when not using it. Hide it with ALLOW_EXPERIMENTAL_API.
58 : : */
59 : : #ifdef ALLOW_EXPERIMENTAL_API
60 : : rte_wmb();
61 : : rte_write32_wc_relaxed(value, addr);
62 : : #else
63 : : rte_write32(value, addr);
64 : : #endif
65 : : }
66 : :
67 : : #ifdef __cplusplus
68 : : }
69 : : #endif
70 : :
71 : : #endif /* _RTE_IO_X86_H_ */
|