|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
20 #ifndef SRC_SVM_MESSAGE_QUEUE_H_
21 #define SRC_SVM_MESSAGE_QUEUE_H_
103 #define SVM_MQ_INVALID_MSG { .as_u64 = ~0 }
357 int rv = pthread_mutex_trylock (&mq->
q.
shr->
mutex);
396 pthread_mutex_unlock (&mq->
q.
shr->
mutex);
static u32 svm_msg_q_size(svm_msg_q_t *mq)
Check length of message queue.
u32 n_rings
number of msg rings
int svm_msg_q_sub(svm_msg_q_t *mq, svm_msg_q_msg_t *msg, svm_q_conditional_wait_t cond, u32 time)
Consumer dequeue one message from queue.
void svm_msg_q_attach(svm_msg_q_t *mq, void *smq_base)
void svm_msg_q_add_and_unlock(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Producer enqueue one message to queue with mutex held.
u32 nitems
max size of the ring
svm_msg_q_msg_t svm_msg_q_alloc_msg(svm_msg_q_t *mq, u32 nbytes)
Allocate message buffer.
struct svm_msg_q_queue_ svm_msg_q_queue_t
uword svm_msg_q_size_to_alloc(svm_msg_q_cfg_t *cfg)
int svm_msg_q_add(svm_msg_q_t *mq, svm_msg_q_msg_t *msg, int nowait)
Producer enqueue one message to queue.
static int svm_msg_q_try_lock(svm_msg_q_t *mq)
Try locking message queue.
void svm_msg_q_free_msg(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Free message buffer.
volatile u32 tail
current tail (for enqueue)
int svm_msg_q_sub_raw_batch(svm_msg_q_t *mq, svm_msg_q_msg_t *msg_buf, u32 n_msgs)
Consumer dequeue multiple messages from queue.
int svm_msg_q_wait_prod(svm_msg_q_t *mq)
Wait for message queue event as producer.
u32 q_nitems
msg queue size (not rings)
static int svm_msg_q_lock(svm_msg_q_t *mq)
Lock, or block trying, the message queue.
u32 elt_index
index in ring
int svm_msg_q_sub_raw(svm_msg_q_t *mq, svm_msg_q_msg_t *elem)
Consumer dequeue one message from queue.
struct svm_msg_q_ring_ svm_msg_q_ring_t
int svm_msg_q_wait(svm_msg_q_t *mq, svm_msg_q_wait_type_t type)
Wait for message queue event.
svm_msg_q_shared_queue_t q[0]
queue for exchanging messages
void svm_msg_q_cleanup(svm_msg_q_t *mq)
Cleanup mq's private data.
static u8 svm_msg_q_is_empty(svm_msg_q_t *mq)
Check if message queue is empty.
struct svm_msg_q_shared_ svm_msg_q_shared_t
static u8 svm_msg_q_is_full(svm_msg_q_t *mq)
Check if message queue is full.
svm_msg_q_shared_t * svm_msg_q_alloc(svm_msg_q_cfg_t *cfg)
Allocate message queue.
struct svm_msg_q_shr_queue_ svm_msg_q_shared_queue_t
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static u8 svm_msg_q_msg_is_invalid(svm_msg_q_msg_t *msg)
Check if message is invalid.
u8 data[0]
chunk of memory for msg data
svm_msg_q_shared_queue_t * shr
pointer to shared queue
u32 ring_index
ring index, could be u8
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
svm_msg_q_shared_t * svm_msg_q_init(void *base, svm_msg_q_cfg_t *cfg)
struct svm_msg_q_ring_shared_ svm_msg_q_ring_shared_t
static_always_inline int clib_spinlock_trylock(clib_spinlock_t *p)
int evtfd
producer/consumer eventfd
int svm_msg_q_timedwait(svm_msg_q_t *mq, double timeout)
Timed wait for message queue event.
u32 pad
8 byte alignment for q
svm_msg_q_ring_cfg_t * ring_cfgs
array of ring cfgs
u32 n_rings
number of rings after q
u32 elsize
size of an element
struct svm_msg_q_ svm_msg_q_t
u32 nitems
max size of the ring
svm_msg_q_ring_shared_t * shr
ring in shared memory
void svm_msg_q_free(svm_msg_q_t *mq)
Free message queue.
svm_msg_q_msg_t svm_msg_q_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index)
Allocate message buffer on ring.
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
int svm_msg_q_lock_and_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index, u8 noblock, svm_msg_q_msg_t *msg)
Lock message queue and allocate message buffer on ring.
volatile u32 cursize
current size of the ring
#define clib_atomic_load_relax_n(a)
u32 elsize
size of an element
int svm_msg_q_alloc_eventfd(svm_msg_q_t *mq)
Allocate event fd for queue.
svm_msg_q_ring_t * rings
rings with message data
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
struct svm_msg_q_cfg_ svm_msg_q_cfg_t
int consumer_pid
pid of msg consumer
struct svm_msg_q_ring_cfg_ svm_msg_q_ring_cfg_t
svm_msg_q_ring_t * svm_msg_q_ring(svm_msg_q_t *mq, u32 ring_index)
Get message queue ring.
u8 * format_svm_msg_q(u8 *s, va_list *args)
Format message queue, shows msg count for each ring.
clib_spinlock_t lock
private lock for multi-producer
enum svm_msg_q_wait_type_ svm_msg_q_wait_type_t
static u8 svm_msg_q_ring_is_full(svm_msg_q_t *mq, u32 ring_index)
void svm_msg_q_set_eventfd(svm_msg_q_t *mq, int fd)
Set event fd for queue.
svm_msg_q_queue_t q
queue for exchanging messages
vl_api_fib_path_type_t type
volatile u32 head
current head (for dequeue)
static int svm_msg_q_get_eventfd(svm_msg_q_t *mq)
static void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.