1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
5 #ifndef _OTX2_IO_ARM64_H_
6 #define _OTX2_IO_ARM64_H_
8 #define otx2_load_pair(val0, val1, addr) ({ \
10 "ldp %x[x0], %x[x1], [%x[p1]]" \
11 :[x0]"=r"(val0), [x1]"=r"(val1) \
15 #define otx2_store_pair(val0, val1, addr) ({ \
17 "stp %x[x0], %x[x1], [%x[p1],#0]!" \
18 ::[x0]"r"(val0), [x1]"r"(val1), [p1]"r"(addr) \
21 #define otx2_prefetch_store_keep(ptr) ({\
22 asm volatile("prfm pstl1keep, [%x0]\n" : : "r" (ptr)); })
24 #if defined(__ARM_FEATURE_SVE)
25 #define __LSE_PREAMBLE " .cpu generic+lse+sve\n"
27 #define __LSE_PREAMBLE " .cpu generic+lse\n"
30 static __rte_always_inline uint64_t
31 otx2_atomic64_add_nosync(int64_t incr, int64_t *ptr)
35 /* Atomic add with no ordering */
38 "ldadd %x[i], %x[r], [%[b]]"
39 : [r] "=r" (result), "+m" (*ptr)
40 : [i] "r" (incr), [b] "r" (ptr)
45 static __rte_always_inline uint64_t
46 otx2_atomic64_add_sync(int64_t incr, int64_t *ptr)
50 /* Atomic add with ordering */
53 "ldadda %x[i], %x[r], [%[b]]"
54 : [r] "=r" (result), "+m" (*ptr)
55 : [i] "r" (incr), [b] "r" (ptr)
60 static __rte_always_inline uint64_t
61 otx2_lmt_submit(rte_iova_t io_address)
67 "ldeor xzr,%x[rf],[%[rs]]" :
68 [rf] "=r"(result): [rs] "r"(io_address));
72 static __rte_always_inline uint64_t
73 otx2_lmt_submit_release(rte_iova_t io_address)
79 "ldeorl xzr,%x[rf],[%[rs]]" :
80 [rf] "=r"(result) : [rs] "r"(io_address));
84 static __rte_always_inline void
85 otx2_lmt_mov(void *out, const void *in, const uint32_t lmtext)
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
96 dst128[2] = src128[2];
98 dst128[3] = src128[3];
102 static __rte_always_inline void
103 otx2_lmt_mov_seg(void *out, const void *in, const uint16_t segdw)
105 volatile const __uint128_t *src128 = (const __uint128_t *)in;
106 volatile __uint128_t *dst128 = (__uint128_t *)out;
109 for (i = 0; i < segdw; i++)
110 dst128[i] = src128[i];
113 #undef __LSE_PREAMBLE
114 #endif /* _OTX2_IO_ARM64_H_ */