FEMU  原版 master 7e238cc
FEMU: Accurate, Scalable and Extensible NVMe SSD Emulator (FAST'18)
rte_ring.c 文件参考
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
#include <errno.h>
#include <sys/queue.h>
#include "../inc/rte_ring.h"
rte_ring.c 的引用(Include)关系图:

宏定义

#define POWEROF2(x)   ((((x)-1) & (x)) == 0)
 

函数

ssize_t rte_ring_get_memsize (unsigned count)
 
int rte_ring_init (struct rte_ring *r, const char *name, unsigned count, unsigned flags)
 
struct rte_ringrte_ring_create (const char *name, unsigned count, unsigned flags)
 
void rte_ring_free (struct rte_ring *r)
 
void rte_ring_dump (FILE *f, const struct rte_ring *r)
 
struct rte_ringfemu_ring_create (enum femu_ring_type type, size_t count)
 
void femu_ring_free (struct rte_ring *ring)
 
size_t femu_ring_count (struct rte_ring *ring)
 
size_t femu_ring_enqueue (struct rte_ring *ring, void **objs, size_t count)
 
size_t femu_ring_dequeue (struct rte_ring *ring, void **objs, size_t count)
 

宏定义说明

◆ POWEROF2

#define POWEROF2 (   x)    ((((x)-1) & (x)) == 0)

函数说明

◆ femu_ring_count()

size_t femu_ring_count ( struct rte_ring ring)

Get the number of objects in the ring.

参数
ringthe ring.
返回
the number of objects in the ring.
函数调用图:
这是这个函数的调用关系图:

◆ femu_ring_create()

struct rte_ring* femu_ring_create ( enum femu_ring_type  type,
size_t  count 
)

Create a ring.

参数
typeType for the ring. (FEMU_RING_TYPE_SP_SC or FEMU_RING_TYPE_MP_SC).
countSize of the ring in elements.
socket_idSocket ID to allocate memory on, or FEMU_ENV_SOCKET_ID_ANY for any socket.
返回
a pointer to the created ring.
函数调用图:
这是这个函数的调用关系图:

◆ femu_ring_dequeue()

size_t femu_ring_dequeue ( struct rte_ring ring,
void **  objs,
size_t  count 
)

Dequeue count objects from the ring into the array objs.

参数
ringA pointer to the ring.
objsA pointer to the array to be dequeued.
countMaximum number of elements to be dequeued.
返回
the number of objects dequeued which is less than 'count'.
函数调用图:
这是这个函数的调用关系图:

◆ femu_ring_enqueue()

size_t femu_ring_enqueue ( struct rte_ring ring,
void **  objs,
size_t  count 
)

Queue the array of objects (with length count) on the ring.

参数
ringA pointer to the ring.
objsA pointer to the array to be queued.
countLength count of the array of objects.
返回
the number of objects enqueued.
函数调用图:
这是这个函数的调用关系图:

◆ femu_ring_free()

void femu_ring_free ( struct rte_ring ring)

Free the ring.

参数
ringRing to free.
函数调用图:
这是这个函数的调用关系图:

◆ rte_ring_create()

struct rte_ring* rte_ring_create ( const char *  name,
unsigned  count,
unsigned  flags 
)

Create a new ring named name in memory.

This function uses memzone_reserve() to allocate memory. Then it calls rte_ring_init() to initialize an empty ring.

The new ring size is set to count, which must be a power of two. Water marking is disabled by default. The real usable ring size is count-1 instead of count to differentiate a free ring from an empty ring.

The ring is added in RTE_TAILQ_RING list.

参数
nameThe name of the ring.
countThe size of the ring (must be a power of 2).
socket_idThe socket_id argument is the socket identifier in case of NUMA. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the reserved zone.
flagsAn OR of the following:
返回
On success, the pointer to the new allocated ring. NULL on error with rte_errno set appropriately. Possible errno values include:
  • E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
  • E_RTE_SECONDARY - function was called from a secondary process instance
  • EINVAL - count provided is not a power of 2
  • ENOSPC - the maximum number of memzones has already been allocated
  • EEXIST - a memzone with the same name already exists
  • ENOMEM - no appropriate memory area found in which to create memzone
函数调用图:
这是这个函数的调用关系图:

◆ rte_ring_dump()

void rte_ring_dump ( FILE *  f,
const struct rte_ring r 
)

Dump the status of the ring to a file.

参数
fA pointer to a file for output
rA pointer to the ring structure.
函数调用图:

◆ rte_ring_free()

void rte_ring_free ( struct rte_ring r)

De-allocate all memory used by the ring.

参数
rRing to free
这是这个函数的调用关系图:

◆ rte_ring_get_memsize()

ssize_t rte_ring_get_memsize ( unsigned  count)

Calculate the memory size needed for a ring

This function returns the number of bytes needed for a ring, given the number of elements in it. This value is the sum of the size of the structure rte_ring and the size of the memory needed by the objects pointers. The value is aligned to a cache line size.

参数
countThe number of elements in the ring (must be a power of 2).
返回
  • The memory size needed for the ring on success.
  • -EINVAL if count is not a power of 2.
这是这个函数的调用关系图:

◆ rte_ring_init()

int rte_ring_init ( struct rte_ring r,
const char *  name,
unsigned  count,
unsigned  flags 
)

Initialize a ring structure.

Initialize a ring structure in memory pointed by "r". The size of the memory area must be large enough to store the ring structure and the object table. It is advised to use rte_ring_get_memsize() to get the appropriate size.

The ring size is set to count, which must be a power of two. Water marking is disabled by default. The real usable ring size is count-1 instead of count to differentiate a free ring from an empty ring.

The ring is not added in RTE_TAILQ_RING global list. Indeed, the memory given by the caller may not be shareable among dpdk processes.

参数
rThe pointer to the ring structure followed by the objects table.
nameThe name of the ring.
countThe number of elements in the ring (must be a power of 2).
flagsAn OR of the following:
返回
0 on success, or a negative value on error.
函数调用图:
这是这个函数的调用关系图: