DPDK  20.11.3
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 
44 static __rte_always_inline void
45 rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
46  int memorder);
47 
62 static __rte_always_inline void
63 rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected,
64  int memorder);
65 
80 static __rte_always_inline void
81 rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
82  int memorder);
83 
84 #ifndef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
85 static __rte_always_inline void
86 rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
87  int memorder)
88 {
89  assert(memorder == __ATOMIC_ACQUIRE || memorder == __ATOMIC_RELAXED);
90 
91  while (__atomic_load_n(addr, memorder) != expected)
92  rte_pause();
93 }
94 
95 static __rte_always_inline void
96 rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected,
97  int memorder)
98 {
99  assert(memorder == __ATOMIC_ACQUIRE || memorder == __ATOMIC_RELAXED);
100 
101  while (__atomic_load_n(addr, memorder) != expected)
102  rte_pause();
103 }
104 
105 static __rte_always_inline void
106 rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
107  int memorder)
108 {
109  assert(memorder == __ATOMIC_ACQUIRE || memorder == __ATOMIC_RELAXED);
110 
111  while (__atomic_load_n(addr, memorder) != expected)
112  rte_pause();
113 }
114 #endif
115 
116 #endif /* _RTE_PAUSE_H_ */
static __rte_always_inline void rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected, int memorder)
Definition: rte_pause.h:106
#define __rte_always_inline
Definition: rte_common.h:226
static void rte_pause(void)
static __rte_always_inline void rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected, int memorder)
Definition: rte_pause.h:86
static __rte_always_inline void rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected, int memorder)
Definition: rte_pause.h:96