DPDK
25.11.0
Toggle main menu visibility
Loading...
Searching...
No Matches
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
85
86
#include <stdbool.h>
87
#include <stdint.h>
88
89
#include <
rte_atomic.h
>
90
#include <
rte_branch_prediction.h
>
91
#include <
rte_seqcount.h
>
92
#include <
rte_spinlock.h
>
93
94
#ifdef __cplusplus
95
extern
"C"
{
96
#endif
97
101
typedef
struct
{
102
rte_seqcount_t
count
;
103
rte_spinlock_t
lock
;
104
}
rte_seqlock_t
;
105
109
#define RTE_SEQLOCK_INITIALIZER \
110
{ \
111
.count = RTE_SEQCOUNT_INITIALIZER, \
112
.lock = RTE_SPINLOCK_INITIALIZER \
113
}
114
124
static
inline
void
125
rte_seqlock_init
(
rte_seqlock_t
*seqlock)
126
{
127
rte_seqcount_init
(&seqlock->
count
);
128
rte_spinlock_init
(&seqlock->
lock
);
129
}
130
145
static
inline
uint32_t
146
rte_seqlock_read_begin
(
const
rte_seqlock_t
*seqlock)
147
{
148
return
rte_seqcount_read_begin
(&seqlock->
count
);
149
}
150
167
static
inline
bool
168
rte_seqlock_read_retry
(
const
rte_seqlock_t
*seqlock, uint32_t begin_sn)
169
{
170
return
rte_seqcount_read_retry
(&seqlock->
count
, begin_sn);
171
}
172
198
static
inline
void
199
rte_seqlock_write_lock
(
rte_seqlock_t
*seqlock)
200
__rte_acquire_capability(&seqlock->lock)
201
{
202
/* To synchronize with other writers. */
203
rte_spinlock_lock
(&seqlock->lock);
204
205
rte_seqcount_write_begin
(&seqlock->count);
206
}
207
220
static
inline
void
221
rte_seqlock_write_unlock
(
rte_seqlock_t
*seqlock)
222
__rte_release_capability(&seqlock->lock)
223
{
224
rte_seqcount_write_end
(&seqlock->count);
225
226
rte_spinlock_unlock
(&seqlock->lock);
227
}
228
229
#ifdef __cplusplus
230
}
231
#endif
232
233
#endif
/* _RTE_SEQLOCK_H_ */
rte_atomic.h
rte_branch_prediction.h
rte_seqcount.h
rte_seqcount_init
static void rte_seqcount_init(rte_seqcount_t *seqcount)
Definition
rte_seqcount.h:49
rte_seqcount_write_end
static void rte_seqcount_write_end(rte_seqcount_t *seqcount)
Definition
rte_seqcount.h:209
rte_seqcount_read_begin
static uint32_t rte_seqcount_read_begin(const rte_seqcount_t *seqcount)
Definition
rte_seqcount.h:97
rte_seqcount_read_retry
static bool rte_seqcount_read_retry(const rte_seqcount_t *seqcount, uint32_t begin_sn)
Definition
rte_seqcount.h:137
rte_seqcount_write_begin
static void rte_seqcount_write_begin(rte_seqcount_t *seqcount)
Definition
rte_seqcount.h:182
rte_seqlock_write_lock
static void rte_seqlock_write_lock(rte_seqlock_t *seqlock)
Definition
rte_seqlock.h:199
rte_seqlock_write_unlock
static void rte_seqlock_write_unlock(rte_seqlock_t *seqlock)
Definition
rte_seqlock.h:221
rte_seqlock_init
static void rte_seqlock_init(rte_seqlock_t *seqlock)
Definition
rte_seqlock.h:125
rte_seqlock_read_retry
static bool rte_seqlock_read_retry(const rte_seqlock_t *seqlock, uint32_t begin_sn)
Definition
rte_seqlock.h:168
rte_seqlock_read_begin
static uint32_t rte_seqlock_read_begin(const rte_seqlock_t *seqlock)
Definition
rte_seqlock.h:146
rte_spinlock.h
rte_spinlock_unlock
static void rte_spinlock_unlock(rte_spinlock_t *sl)
rte_spinlock_lock
static void rte_spinlock_lock(rte_spinlock_t *sl)
rte_spinlock_init
static void rte_spinlock_init(rte_spinlock_t *sl)
Definition
rte_spinlock.h:51
rte_seqcount_t
Definition
rte_seqcount.h:33
rte_seqlock_t
Definition
rte_seqlock.h:101
rte_seqlock_t::lock
rte_spinlock_t lock
Definition
rte_seqlock.h:103
rte_seqlock_t::count
rte_seqcount_t count
Definition
rte_seqlock.h:102
rte_spinlock_t
Definition
rte_spinlock.h:35
lib
eal
include
rte_seqlock.h
Generated by
1.17.0