DPDK 22.11.4
rte_seqlock.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2022 Ericsson AB
3 */
4
5#ifndef _RTE_SEQLOCK_H_
6#define _RTE_SEQLOCK_H_
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
90#include <stdbool.h>
91#include <stdint.h>
92
93#include <rte_atomic.h>
95#include <rte_compat.h>
96#include <rte_seqcount.h>
97#include <rte_spinlock.h>
98
102typedef struct {
106
110#define RTE_SEQLOCK_INITIALIZER \
111 { \
112 .count = RTE_SEQCOUNT_INITIALIZER, \
113 .lock = RTE_SPINLOCK_INITIALIZER \
114 }
115
128__rte_experimental
129static inline void
131{
132 rte_seqcount_init(&seqlock->count);
133 rte_spinlock_init(&seqlock->lock);
134}
135
154__rte_experimental
155static inline uint32_t
157{
158 return rte_seqcount_read_begin(&seqlock->count);
159}
160
180__rte_experimental
181static inline bool
182rte_seqlock_read_retry(const rte_seqlock_t *seqlock, uint32_t begin_sn)
183{
184 return rte_seqcount_read_retry(&seqlock->count, begin_sn);
185}
186
215__rte_experimental
216static inline void
218{
219 /* To synchronize with other writers. */
220 rte_spinlock_lock(&seqlock->lock);
221
223}
224
240__rte_experimental
241static inline void
243{
244 rte_seqcount_write_end(&seqlock->count);
245
246 rte_spinlock_unlock(&seqlock->lock);
247}
248
249#ifdef __cplusplus
250}
251#endif
252
253#endif /* _RTE_SEQLOCK_H_ */
static __rte_experimental void rte_seqcount_write_end(rte_seqcount_t *seqcount)
Definition: rte_seqcount.h:232
static __rte_experimental uint32_t rte_seqcount_read_begin(const rte_seqcount_t *seqcount)
Definition: rte_seqcount.h:106
static __rte_experimental void rte_seqcount_init(rte_seqcount_t *seqcount)
Definition: rte_seqcount.h:53
static __rte_experimental bool rte_seqcount_read_retry(const rte_seqcount_t *seqcount, uint32_t begin_sn)
Definition: rte_seqcount.h:151
static __rte_experimental void rte_seqcount_write_begin(rte_seqcount_t *seqcount)
Definition: rte_seqcount.h:201
static __rte_experimental void rte_seqlock_init(rte_seqlock_t *seqlock)
Definition: rte_seqlock.h:130
static __rte_experimental bool rte_seqlock_read_retry(const rte_seqlock_t *seqlock, uint32_t begin_sn)
Definition: rte_seqlock.h:182
static __rte_experimental uint32_t rte_seqlock_read_begin(const rte_seqlock_t *seqlock)
Definition: rte_seqlock.h:156
static __rte_experimental void rte_seqlock_write_lock(rte_seqlock_t *seqlock)
Definition: rte_seqlock.h:217
static __rte_experimental void rte_seqlock_write_unlock(rte_seqlock_t *seqlock)
Definition: rte_seqlock.h:242
static void rte_spinlock_unlock(rte_spinlock_t *sl)
static void rte_spinlock_lock(rte_spinlock_t *sl)
static void rte_spinlock_init(rte_spinlock_t *sl)
Definition: rte_spinlock.h:46
rte_spinlock_t lock
Definition: rte_seqlock.h:104
rte_seqcount_t count
Definition: rte_seqlock.h:103