DPDK  20.05.0
rte_pause.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Cavium, Inc
3  * Copyright(c) 2019 Arm Limited
4  */
5 
6 #ifndef _RTE_PAUSE_H_
7 #define _RTE_PAUSE_H_
8 
16 #include <stdint.h>
17 #include <assert.h>
18 #include <rte_common.h>
19 #include <rte_atomic.h>
20 #include <rte_compat.h>
21 
28 static inline void rte_pause(void);
29 
47 __rte_experimental
48 static __rte_always_inline void
49 rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
50  int memorder);
51 
69 __rte_experimental
70 static __rte_always_inline void
71 rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected,
72  int memorder);
73 
91 __rte_experimental
92 static __rte_always_inline void
93 rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
94  int memorder);
95 
96 #ifndef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
97 static __rte_always_inline void
98 rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
99  int memorder)
100 {
101  assert(memorder == __ATOMIC_ACQUIRE || memorder == __ATOMIC_RELAXED);
102 
103  while (__atomic_load_n(addr, memorder) != expected)
104  rte_pause();
105 }
106 
107 static __rte_always_inline void
108 rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected,
109  int memorder)
110 {
111  assert(memorder == __ATOMIC_ACQUIRE || memorder == __ATOMIC_RELAXED);
112 
113  while (__atomic_load_n(addr, memorder) != expected)
114  rte_pause();
115 }
116 
117 static __rte_always_inline void
118 rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
119  int memorder)
120 {
121  assert(memorder == __ATOMIC_ACQUIRE || memorder == __ATOMIC_RELAXED);
122 
123  while (__atomic_load_n(addr, memorder) != expected)
124  rte_pause();
125 }
126 #endif
127 
128 #endif /* _RTE_PAUSE_H_ */
static __rte_experimental __rte_always_inline void rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected, int memorder)
Definition: rte_pause.h:118
#define __rte_always_inline
Definition: rte_common.h:193
static void rte_pause(void)
static __rte_experimental __rte_always_inline void rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected, int memorder)
Definition: rte_pause.h:98
static __rte_experimental __rte_always_inline void rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected, int memorder)
Definition: rte_pause.h:108