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 static __rte_always_inline uint64_t
25 otx2_atomic64_add_nosync(int64_t incr, int64_t *ptr)
29 /* Atomic add with no ordering */
32 "ldadd %x[i], %x[r], [%[b]]"
33 : [r] "=r" (result), "+m" (*ptr)
34 : [i] "r" (incr), [b] "r" (ptr)
39 static __rte_always_inline uint64_t
40 otx2_atomic64_add_sync(int64_t incr, int64_t *ptr)
44 /* Atomic add with ordering */
47 "ldadda %x[i], %x[r], [%[b]]"
48 : [r] "=r" (result), "+m" (*ptr)
49 : [i] "r" (incr), [b] "r" (ptr)
54 static __rte_always_inline uint64_t
55 otx2_lmt_submit(rte_iova_t io_address)
61 "ldeor xzr,%x[rf],[%[rs]]" :
62 [rf] "=r"(result): [rs] "r"(io_address));
66 static __rte_always_inline void
67 otx2_lmt_mov(void *out, const void *in, const uint32_t lmtext)
69 volatile const __uint128_t *src128 = (const __uint128_t *)in;
70 volatile __uint128_t *dst128 = (__uint128_t *)out;
71 dst128[0] = src128[0];
72 dst128[1] = src128[1];
73 /* lmtext receives following value:
74 * 1: NIX_SUBDC_EXT needed i.e. tx vlan case
75 * 2: NIX_SUBDC_EXT + NIX_SUBDC_MEM i.e. tstamp case
78 dst128[2] = src128[2];
80 dst128[3] = src128[3];
84 static __rte_always_inline void
85 otx2_lmt_mov_seg(void *out, const void *in, const uint16_t segdw)
87 volatile const __uint128_t *src128 = (const __uint128_t *)in;
88 volatile __uint128_t *dst128 = (__uint128_t *)out;
91 for (i = 0; i < segdw; i++)
92 dst128[i] = src128[i];
95 #endif /* _OTX2_IO_ARM64_H_ */