FEMU
原版 master 7e238cc
FEMU: Accurate, Scalable and Extensible NVMe SSD Emulator (FAST'18)
|
|
浏览该文件的文档.
96 #include <sys/queue.h>
98 #include <xmmintrin.h>
101 #define __rte_always_inline inline
104 #define RTE_RING_MZ_PREFIX "RG_"
116 #define RTE_NAMESIZE 256
147 #define RING_F_SP_ENQ 0x0001
148 #define RING_F_SC_DEQ 0x0002
157 #define RING_F_EXACT_SZ 0x0004
158 #define RTE_RING_SZ_MASK (unsigned)(0x0fffffff)
166 static inline uint32_t
293 #define ENQUEUE_PTRS(r, ring_start, prod_head, obj_table, n, obj_type) do { \
295 const uint32_t size = (r)->size; \
296 uint32_t idx = prod_head & (r)->mask; \
297 obj_type *ring = (obj_type *)ring_start; \
298 if (idx + n < size) { \
299 for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
300 ring[idx] = obj_table[i]; \
301 ring[idx+1] = obj_table[i+1]; \
302 ring[idx+2] = obj_table[i+2]; \
303 ring[idx+3] = obj_table[i+3]; \
307 ring[idx++] = obj_table[i++]; \
309 ring[idx++] = obj_table[i++]; \
311 ring[idx++] = obj_table[i++]; \
314 for (i = 0; idx < size; i++, idx++)\
315 ring[idx] = obj_table[i]; \
316 for (idx = 0; i < n; i++, idx++) \
317 ring[idx] = obj_table[i]; \
324 #define DEQUEUE_PTRS(r, ring_start, cons_head, obj_table, n, obj_type) do { \
326 uint32_t idx = cons_head & (r)->mask; \
327 const uint32_t size = (r)->size; \
328 obj_type *ring = (obj_type *)ring_start; \
329 if (idx + n < size) { \
330 for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\
331 obj_table[i] = ring[idx]; \
332 obj_table[i+1] = ring[idx+1]; \
333 obj_table[i+2] = ring[idx+2]; \
334 obj_table[i+3] = ring[idx+3]; \
338 obj_table[i++] = ring[idx++]; \
340 obj_table[i++] = ring[idx++]; \
342 obj_table[i++] = ring[idx++]; \
345 for (i = 0; idx < size; i++, idx++) \
346 obj_table[i] = ring[idx]; \
347 for (idx = 0; i < n; i++, idx++) \
348 obj_table[i] = ring[idx]; \
393 uint32_t *old_head, uint32_t *new_head,
394 uint32_t *free_entries)
397 unsigned int max = n;
405 const uint32_t cons_tail = r->
cons.
tail;
412 *free_entries = (
capacity + cons_tail - *old_head);
422 *new_head = *old_head + n;
424 r->
prod.
head = *new_head, success = 1;
427 *old_head, *new_head);
455 int is_sp,
unsigned int *free_space)
457 uint32_t prod_head, prod_next;
458 uint32_t free_entries;
461 &prod_head, &prod_next, &free_entries);
465 ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n,
void *);
470 if (free_space != NULL)
471 *free_space = free_entries - n;
501 uint32_t *old_head, uint32_t *new_head,
504 unsigned int max = n;
513 const uint32_t prod_tail = r->
prod.
tail;
518 *entries = (prod_tail - *old_head);
527 *new_head = *old_head + n;
529 r->
cons.
head = *new_head, success = 1;
533 }
while (success == 0);
560 int is_sc,
unsigned int *available)
562 uint32_t cons_head, cons_next;
566 &cons_head, &cons_next, &entries);
570 DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n,
void *);
576 if (available != NULL)
577 *available = entries - n;
601 unsigned int n,
unsigned int *free_space)
624 unsigned int n,
unsigned int *free_space)
651 unsigned int n,
unsigned int *free_space)
735 unsigned int n,
unsigned int *available)
759 unsigned int n,
unsigned int *available)
786 unsigned int *available)
861 static inline unsigned
866 uint32_t count = (prod_tail - cons_tail) & r->
mask;
878 static inline unsigned
924 static inline unsigned int
938 static inline unsigned int
984 unsigned int n,
unsigned int *free_space)
1007 unsigned int n,
unsigned int *free_space)
1034 unsigned int n,
unsigned int *free_space)
1062 unsigned int n,
unsigned int *available)
1087 unsigned int n,
unsigned int *available)
1114 unsigned int n,
unsigned int *available)
static __rte_always_inline void update_tail(struct rte_ring_headtail *ht, uint32_t old_val, uint32_t new_val, uint32_t single)
Definition: rte_ring.h:353
static __rte_always_inline unsigned int __rte_ring_move_cons_head(struct rte_ring *r, int is_sc, unsigned int n, enum rte_ring_queue_behavior behavior, uint32_t *old_head, uint32_t *new_head, uint32_t *entries)
Definition: rte_ring.h:499
#define __IS_MC
Definition: rte_ring.h:164
Definition: rte_ring.h:111
@ FEMU_RING_TYPE_MP_MC
Definition: rte_ring.h:1124
static int rte_atomic32_cmpset(volatile uint32_t *dst, uint32_t exp, uint32_t src)
Definition: rte_atomic_x86.h:17
static __rte_always_inline unsigned int rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:734
#define __IS_SP
Definition: rte_ring.h:161
#define unlikely(x)
Definition: rte_branch_prediction.h:38
static unsigned int rte_ring_get_size(const struct rte_ring *r)
Definition: rte_ring.h:925
char name[RTE_NAMESIZE]
Definition: rte_ring.h:133
static unsigned rte_ring_count(const struct rte_ring *r)
Definition: rte_ring.h:862
static __rte_always_inline unsigned rte_ring_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:1033
void rte_ring_dump(FILE *f, const struct rte_ring *r)
Definition: rte_ring.c:173
static __rte_always_inline unsigned int rte_ring_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:650
static int rte_ring_empty(const struct rte_ring *r)
Definition: rte_ring.h:909
#define ENQUEUE_PTRS(r, ring_start, prod_head, obj_table, n, obj_type)
Definition: rte_ring.h:293
static __rte_always_inline unsigned int __rte_ring_move_prod_head(struct rte_ring *r, int is_sp, unsigned int n, enum rte_ring_queue_behavior behavior, uint32_t *old_head, uint32_t *new_head, uint32_t *free_entries)
Definition: rte_ring.h:391
static __rte_always_inline unsigned int rte_ring_mp_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:600
int rte_ring_init(struct rte_ring *r, const char *name, unsigned count, unsigned flags)
Definition: rte_ring.c:99
@ RTE_RING_QUEUE_VARIABLE
Definition: rte_ring.h:108
@ FEMU_RING_TYPE_MP_SC
Definition: rte_ring.h:1123
void rte_ring_free(struct rte_ring *r)
Definition: rte_ring.c:164
size_t femu_ring_dequeue(struct rte_ring *ring, void **objs, size_t count)
Definition: rte_ring.c:228
#define rte_smp_rmb()
Definition: rte_atomic_x86.h:36
static __rte_always_inline int rte_ring_mc_dequeue(struct rte_ring *r, void **obj_p)
Definition: rte_ring.h:808
uint32_t size
Definition: rte_ring.h:136
struct rte_ring * rte_ring_lookup(const char *name)
static __rte_always_inline unsigned rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:1113
struct rte_ring * femu_ring_create(enum femu_ring_type type, size_t count)
Definition: rte_ring.c:187
#define __rte_always_inline
Definition: rte_ring.h:101
static __rte_always_inline unsigned int rte_ring_sc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:758
#define rte_smp_wmb()
Definition: rte_atomic_x86.h:34
Definition: rte_ring.h:127
struct rte_ring * rte_ring_create(const char *name, unsigned count, unsigned flags)
Definition: rte_ring.c:132
static __rte_always_inline unsigned rte_ring_sp_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:1006
volatile uint32_t head
Definition: rte_ring.h:112
static __rte_always_inline unsigned int rte_ring_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:785
@ FEMU_RING_TYPE_SP_SC
Definition: rte_ring.h:1122
#define __IS_MP
Definition: rte_ring.h:162
struct rte_ring_headtail cons
Definition: rte_ring.h:144
#define DEQUEUE_PTRS(r, ring_start, cons_head, obj_table, n, obj_type)
Definition: rte_ring.h:324
#define __IS_SC
Definition: rte_ring.h:163
static __rte_always_inline unsigned rte_ring_sc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:1086
#define RTE_NAMESIZE
Definition: rte_ring.h:116
rte_ring_queue_behavior
Definition: rte_ring.h:106
@ RTE_RING_QUEUE_FIXED
Definition: rte_ring.h:107
void femu_ring_free(struct rte_ring *ring)
Definition: rte_ring.c:213
static unsigned rte_ring_free_count(const struct rte_ring *r)
Definition: rte_ring.h:879
size_t femu_ring_enqueue(struct rte_ring *ring, void **objs, size_t count)
Definition: rte_ring.c:223
uint32_t capacity
Definition: rte_ring.h:138
void rte_ring_list_dump(FILE *f)
static __rte_always_inline unsigned int __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table, unsigned int n, enum rte_ring_queue_behavior behavior, int is_sc, unsigned int *available)
Definition: rte_ring.h:558
static __rte_always_inline int rte_ring_dequeue(struct rte_ring *r, void **obj_p)
Definition: rte_ring.h:848
int flags
Definition: rte_ring.h:134
static __rte_always_inline int rte_ring_sc_dequeue(struct rte_ring *r, void **obj_p)
Definition: rte_ring.h:826
static __rte_always_inline int rte_ring_mp_enqueue(struct rte_ring *r, void *obj)
Definition: rte_ring.h:672
ssize_t rte_ring_get_memsize(unsigned count)
Definition: rte_ring.c:87
femu_ring_type
Definition: rte_ring.h:1121
static unsigned int rte_ring_get_capacity(const struct rte_ring *r)
Definition: rte_ring.h:939
static __rte_always_inline unsigned rte_ring_mp_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:983
static __rte_always_inline int rte_ring_sp_enqueue(struct rte_ring *r, void *obj)
Definition: rte_ring.h:689
volatile uint32_t tail
Definition: rte_ring.h:113
static __rte_always_inline int rte_ring_enqueue(struct rte_ring *r, void *obj)
Definition: rte_ring.h:710
static int rte_ring_full(const struct rte_ring *r)
Definition: rte_ring.h:894
size_t femu_ring_count(struct rte_ring *ring)
Definition: rte_ring.c:218
uint32_t mask
Definition: rte_ring.h:137
static __rte_always_inline unsigned int __rte_ring_do_enqueue(struct rte_ring *r, void *const *obj_table, unsigned int n, enum rte_ring_queue_behavior behavior, int is_sp, unsigned int *free_space)
Definition: rte_ring.h:453
static __rte_always_inline unsigned int rte_ring_sp_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:623
static uint32_t rte_align32pow2(uint32_t x)
Definition: rte_ring.h:167
struct rte_ring_headtail prod
Definition: rte_ring.h:141
uint32_t single
Definition: rte_ring.h:114
static __rte_always_inline unsigned rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:1061