xref: /dpdk/lib/eal/loongarch/include/rte_spinlock.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
129631ee5SMin Zhou /* SPDX-License-Identifier: BSD-3-Clause
229631ee5SMin Zhou  * Copyright(c) 2022 Loongson Technology Corporation Limited
329631ee5SMin Zhou  */
429631ee5SMin Zhou 
529631ee5SMin Zhou #ifndef RTE_SPINLOCK_LOONGARCH_H
629631ee5SMin Zhou #define RTE_SPINLOCK_LOONGARCH_H
729631ee5SMin Zhou 
8*719834a6SMattias Rönnblom #include <rte_common.h>
9*719834a6SMattias Rönnblom #include "generic/rte_spinlock.h"
10*719834a6SMattias Rönnblom 
1129631ee5SMin Zhou #ifdef __cplusplus
1229631ee5SMin Zhou extern "C" {
1329631ee5SMin Zhou #endif
1429631ee5SMin Zhou 
1529631ee5SMin Zhou #ifndef RTE_FORCE_INTRINSICS
1629631ee5SMin Zhou #  error Platform must be built with RTE_FORCE_INTRINSICS
1729631ee5SMin Zhou #endif
1829631ee5SMin Zhou 
1929631ee5SMin Zhou static inline int rte_tm_supported(void)
2029631ee5SMin Zhou {
2129631ee5SMin Zhou 	return 0;
2229631ee5SMin Zhou }
2329631ee5SMin Zhou 
2429631ee5SMin Zhou static inline void
2529631ee5SMin Zhou rte_spinlock_lock_tm(rte_spinlock_t *sl)
2629631ee5SMin Zhou {
2729631ee5SMin Zhou 	rte_spinlock_lock(sl); /* fall-back */
2829631ee5SMin Zhou }
2929631ee5SMin Zhou 
3029631ee5SMin Zhou static inline int
3129631ee5SMin Zhou rte_spinlock_trylock_tm(rte_spinlock_t *sl)
3229631ee5SMin Zhou {
3329631ee5SMin Zhou 	return rte_spinlock_trylock(sl);
3429631ee5SMin Zhou }
3529631ee5SMin Zhou 
3629631ee5SMin Zhou static inline void
3729631ee5SMin Zhou rte_spinlock_unlock_tm(rte_spinlock_t *sl)
3829631ee5SMin Zhou {
3929631ee5SMin Zhou 	rte_spinlock_unlock(sl);
4029631ee5SMin Zhou }
4129631ee5SMin Zhou 
4229631ee5SMin Zhou static inline void
4329631ee5SMin Zhou rte_spinlock_recursive_lock_tm(rte_spinlock_recursive_t *slr)
4429631ee5SMin Zhou {
4529631ee5SMin Zhou 	rte_spinlock_recursive_lock(slr); /* fall-back */
4629631ee5SMin Zhou }
4729631ee5SMin Zhou 
4829631ee5SMin Zhou static inline void
4929631ee5SMin Zhou rte_spinlock_recursive_unlock_tm(rte_spinlock_recursive_t *slr)
5029631ee5SMin Zhou {
5129631ee5SMin Zhou 	rte_spinlock_recursive_unlock(slr);
5229631ee5SMin Zhou }
5329631ee5SMin Zhou 
5429631ee5SMin Zhou static inline int
5529631ee5SMin Zhou rte_spinlock_recursive_trylock_tm(rte_spinlock_recursive_t *slr)
5629631ee5SMin Zhou {
5729631ee5SMin Zhou 	return rte_spinlock_recursive_trylock(slr);
5829631ee5SMin Zhou }
5929631ee5SMin Zhou 
6029631ee5SMin Zhou #ifdef __cplusplus
6129631ee5SMin Zhou }
6229631ee5SMin Zhou #endif
6329631ee5SMin Zhou 
6429631ee5SMin Zhou #endif /* RTE_SPINLOCK_LOONGARCH_H */
65