FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
queue.c File Reference
+ Include dependency graph for queue.c:

Go to the source code of this file.

Functions

svm_queue_tsvm_queue_init (void *base, int nels, int elsize)
 
svm_queue_tsvm_queue_alloc_and_init (int nels, int elsize, int consumer_pid)
 Allocate and initialize svm queue. More...
 
void svm_queue_free (svm_queue_t *q)
 
void svm_queue_lock (svm_queue_t *q)
 
static int svm_queue_trylock (svm_queue_t *q)
 
void svm_queue_unlock (svm_queue_t *q)
 
int svm_queue_is_full (svm_queue_t *q)
 
static void svm_queue_send_signal_inline (svm_queue_t *q, u8 is_prod)
 
void svm_queue_send_signal (svm_queue_t *q, u8 is_prod)
 
static void svm_queue_wait_inline (svm_queue_t *q)
 
void svm_queue_wait (svm_queue_t *q)
 Wait for queue event. More...
 
static int svm_queue_timedwait_inline (svm_queue_t *q, double timeout)
 
int svm_queue_timedwait (svm_queue_t *q, double timeout)
 Timed wait for queue event. More...
 
int svm_queue_add_nolock (svm_queue_t *q, u8 *elem)
 
void svm_queue_add_raw (svm_queue_t *q, u8 *elem)
 Add element to queue with mutex held. More...
 
int svm_queue_add (svm_queue_t *q, u8 *elem, int nowait)
 
int svm_queue_add2 (svm_queue_t *q, u8 *elem, u8 *elem2, int nowait)
 
int svm_queue_sub (svm_queue_t *q, u8 *elem, svm_q_conditional_wait_t cond, u32 time)
 
int svm_queue_sub2 (svm_queue_t *q, u8 *elem)
 
int svm_queue_sub_raw (svm_queue_t *q, u8 *elem)
 
void svm_queue_set_producer_event_fd (svm_queue_t *q, int fd)
 Set producer's event fd. More...
 
void svm_queue_set_consumer_event_fd (svm_queue_t *q, int fd)
 Set consumer's event fd. More...
 

Function Documentation

◆ svm_queue_add()

int svm_queue_add ( svm_queue_t q,
u8 elem,
int  nowait 
)

Definition at line 260 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_queue_add2()

int svm_queue_add2 ( svm_queue_t q,
u8 elem,
u8 elem2,
int  nowait 
)

Definition at line 310 of file queue.c.

+ Here is the call graph for this function:

◆ svm_queue_add_nolock()

int svm_queue_add_nolock ( svm_queue_t q,
u8 elem 
)

Definition at line 213 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_queue_add_raw()

void svm_queue_add_raw ( svm_queue_t q,
u8 elem 
)

Add element to queue with mutex held.

Parameters
qqueue
elempointer element data to add

Definition at line 241 of file queue.c.

+ Here is the call graph for this function:

◆ svm_queue_alloc_and_init()

svm_queue_t* svm_queue_alloc_and_init ( int  nels,
int  elsize,
int  consumer_pid 
)

Allocate and initialize svm queue.

Parameters
nelsnumber of elements on the queue
elsizeelement size, presumably 4 and cacheline-size will be popular choices.
pidconsumer pid
Returns
a newly initialized svm queue

The idea is to call this function in the queue consumer, and e-mail the queue pointer to the producer(s).

The vpp process / main thread allocates one of these at startup; its main input queue. The vpp main input queue has a pointer to it in the shared memory segment header.

You probably want to be on an svm data heap before calling this function.

Definition at line 74 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_queue_free()

void svm_queue_free ( svm_queue_t q)

Definition at line 91 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_queue_init()

svm_queue_t* svm_queue_init ( void *  base,
int  nels,
int  elsize 
)

Definition at line 33 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_queue_is_full()

int svm_queue_is_full ( svm_queue_t q)

Definition at line 122 of file queue.c.

◆ svm_queue_lock()

void svm_queue_lock ( svm_queue_t q)

Definition at line 99 of file queue.c.

+ Here is the caller graph for this function:

◆ svm_queue_send_signal()

void svm_queue_send_signal ( svm_queue_t q,
u8  is_prod 
)

Definition at line 147 of file queue.c.

+ Here is the call graph for this function:

◆ svm_queue_send_signal_inline()

static void svm_queue_send_signal_inline ( svm_queue_t q,
u8  is_prod 
)
inlinestatic

Definition at line 128 of file queue.c.

+ Here is the caller graph for this function:

◆ svm_queue_set_consumer_event_fd()

void svm_queue_set_consumer_event_fd ( svm_queue_t q,
int  fd 
)

Set consumer's event fd.

When the consumer must generate an event it writes 1 to the provided fd. Although in practice the two fds point to the same underlying file description, because the producer and consumer are different processes the descriptors will be different. It's the caller's responsibility to ensure the file descriptors are properly exchanged between the two peers.

Definition at line 496 of file queue.c.

◆ svm_queue_set_producer_event_fd()

void svm_queue_set_producer_event_fd ( svm_queue_t q,
int  fd 
)

Set producer's event fd.

When the producer must generate an event it writes 1 to the provided fd. Once this is set, condvars are not used anymore for signaling.

Definition at line 490 of file queue.c.

◆ svm_queue_sub()

int svm_queue_sub ( svm_queue_t q,
u8 elem,
svm_q_conditional_wait_t  cond,
u32  time 
)

Definition at line 369 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_queue_sub2()

int svm_queue_sub2 ( svm_queue_t q,
u8 elem 
)

Definition at line 434 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_queue_sub_raw()

int svm_queue_sub_raw ( svm_queue_t q,
u8 elem 
)

Definition at line 464 of file queue.c.

+ Here is the call graph for this function:

◆ svm_queue_timedwait()

int svm_queue_timedwait ( svm_queue_t q,
double  timeout 
)

Timed wait for queue event.

Must be called with mutex held.

Parameters
qsvm queue
timeouttime in seconds
Returns
0 on success, ETIMEDOUT on timeout or an error

Definition at line 204 of file queue.c.

+ Here is the call graph for this function:

◆ svm_queue_timedwait_inline()

static int svm_queue_timedwait_inline ( svm_queue_t q,
double  timeout 
)
inlinestatic

Definition at line 178 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_queue_trylock()

static int svm_queue_trylock ( svm_queue_t q)
static

Definition at line 107 of file queue.c.

+ Here is the caller graph for this function:

◆ svm_queue_unlock()

void svm_queue_unlock ( svm_queue_t q)

Definition at line 116 of file queue.c.

+ Here is the caller graph for this function:

◆ svm_queue_wait()

void svm_queue_wait ( svm_queue_t q)

Wait for queue event.

Must be called with mutex held.

Definition at line 172 of file queue.c.

+ Here is the call graph for this function:

◆ svm_queue_wait_inline()

static void svm_queue_wait_inline ( svm_queue_t q)
inlinestatic

Definition at line 153 of file queue.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: