net/ice: refine debug build option
[dpdk.git] / drivers / common / octeontx2 / otx2_io_arm64.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2019 Marvell International Ltd.
3  */
4
5 #ifndef _OTX2_IO_ARM64_H_
6 #define _OTX2_IO_ARM64_H_
7
8 #define otx2_load_pair(val0, val1, addr) ({             \
9         asm volatile(                                   \
10         "ldp %x[x0], %x[x1], [%x[p1]]"                  \
11         :[x0]"=r"(val0), [x1]"=r"(val1)                 \
12         :[p1]"r"(addr)                                  \
13         ); })
14
15 #define otx2_store_pair(val0, val1, addr) ({            \
16         asm volatile(                                   \
17         "stp %x[x0], %x[x1], [%x[p1],#0]!"              \
18         ::[x0]"r"(val0), [x1]"r"(val1), [p1]"r"(addr)   \
19         ); })
20
21 #define otx2_prefetch_store_keep(ptr) ({\
22         asm volatile("prfm pstl1keep, [%x0]\n" : : "r" (ptr)); })
23
24 #if defined(__ARM_FEATURE_SVE)
25 #define __LSE_PREAMBLE " .cpu  generic+lse+sve\n"
26 #else
27 #define __LSE_PREAMBLE " .cpu  generic+lse\n"
28 #endif
29
30 static __rte_always_inline uint64_t
31 otx2_atomic64_add_nosync(int64_t incr, int64_t *ptr)
32 {
33         uint64_t result;
34
35         /* Atomic add with no ordering */
36         asm volatile (
37                 __LSE_PREAMBLE
38                 "ldadd %x[i], %x[r], [%[b]]"
39                 : [r] "=r" (result), "+m" (*ptr)
40                 : [i] "r" (incr), [b] "r" (ptr)
41                 : "memory");
42         return result;
43 }
44
45 static __rte_always_inline uint64_t
46 otx2_atomic64_add_sync(int64_t incr, int64_t *ptr)
47 {
48         uint64_t result;
49
50         /* Atomic add with ordering */
51         asm volatile (
52                 __LSE_PREAMBLE
53                 "ldadda %x[i], %x[r], [%[b]]"
54                 : [r] "=r" (result), "+m" (*ptr)
55                 : [i] "r" (incr), [b] "r" (ptr)
56                 : "memory");
57         return result;
58 }
59
60 static __rte_always_inline uint64_t
61 otx2_lmt_submit(rte_iova_t io_address)
62 {
63         uint64_t result;
64
65         asm volatile (
66                 __LSE_PREAMBLE
67                 "ldeor xzr,%x[rf],[%[rs]]" :
68                  [rf] "=r"(result): [rs] "r"(io_address));
69         return result;
70 }
71
72 static __rte_always_inline uint64_t
73 otx2_lmt_submit_release(rte_iova_t io_address)
74 {
75         uint64_t result;
76
77         asm volatile (
78                 __LSE_PREAMBLE
79                 "ldeorl xzr,%x[rf],[%[rs]]" :
80                  [rf] "=r"(result) : [rs] "r"(io_address));
81         return result;
82 }
83
84 static __rte_always_inline void
85 otx2_lmt_mov(void *out, const void *in, const uint32_t lmtext)
86 {
87         volatile const __uint128_t *src128 = (const __uint128_t *)in;
88         volatile __uint128_t *dst128 = (__uint128_t *)out;
89         dst128[0] = src128[0];
90         dst128[1] = src128[1];
91         /* lmtext receives following value:
92          * 1: NIX_SUBDC_EXT needed i.e. tx vlan case
93          * 2: NIX_SUBDC_EXT + NIX_SUBDC_MEM i.e. tstamp case
94          */
95         if (lmtext) {
96                 dst128[2] = src128[2];
97                 if (lmtext > 1)
98                         dst128[3] = src128[3];
99         }
100 }
101
102 static __rte_always_inline void
103 otx2_lmt_mov_seg(void *out, const void *in, const uint16_t segdw)
104 {
105         volatile const __uint128_t *src128 = (const __uint128_t *)in;
106         volatile __uint128_t *dst128 = (__uint128_t *)out;
107         uint8_t i;
108
109         for (i = 0; i < segdw; i++)
110                 dst128[i] = src128[i];
111 }
112
113 #undef __LSE_PREAMBLE
114 #endif /* _OTX2_IO_ARM64_H_ */