| MQ_INIT(9) | Kernel Developer's Manual | MQ_INIT(9) |
mq_init,
mq_enqueue, mq_push,
mq_dequeue, mq_enlist,
mq_delist, mq_dechain,
mq_len, mq_empty,
mq_full, mq_hdatalen,
mq_purge, mq_drops,
mq_set_maxlen,
MBUF_QUEUE_INITIALIZER —
mbuf queue API
#include
<sys/mbuf.h>
void
mq_init(struct
mbuf_queue *mq, unsigned
int maxlen, int
ipl);
int
mq_enqueue(struct
mbuf_queue *mq, struct
mbuf *m);
int
mq_push(struct
mbuf_queue *mq, struct
mbuf *m);
struct mbuf *
mq_dequeue(struct
mbuf_queue *mq);
int
mq_enlist(struct
mbuf_queue *mq, struct
mbuf_list *ml);
void
mq_delist(struct
mbuf_queue *mq, struct
mbuf_list *ml);
struct mbuf *
mq_dechain(struct
mbuf_queue *mq);
unsigned int
mq_len(struct
mbuf_queue *mq);
int
mq_empty(struct
mbuf_queue *mq);
int
mq_full(struct
mbuf_queue *mq);
unsigned int
mq_hdatalen(struct
mbuf_queue *mq);
unsigned int
mq_purge(struct
mbuf_queue *mq);
unsigned int
mq_drops(struct
mbuf_queue *mq);
void
mq_set_maxlen(struct
mbuf_queue *mq, unsigned
int);
struct mbuf_queue
MBUF_QUEUE_INITIALIZER(unsigned
int maxlen, int
ipl);
The mbuf queue API provides implementations of data structures and operations for queueing mbufs and lists of mbufs between contexts.
mbuf_queue data structures provide a superset of the functionality available in mbuf_lists, and protect themselves internally with a mutex(9), making them useful for moving mbufs between contexts or subsystems. Additionally, mbuf_queues provide a limit on the number of mbufs that may be queued.
mbuf_queue structures support the following functionality:
mq_init(struct
mbuf_queue *mq, unsigned int maxlen,
int ipl)MBUF_QUEUE_INITIALIZER(unsigned
int maxlen, int ipl)mq_enqueue(struct
mbuf_queue *mq, struct mbuf *m)mq_push(struct
mbuf_queue *mq, struct mbuf *m)mq_dequeue(struct
mbuf_queue *mq)mq_enlist(struct
mbuf_queue *mq, struct mbuf_list *ml)mq_delist(struct
mbuf_queue *mq, struct mbuf_list *ml)mq_dechain(struct
mbuf_queue *mq)mq_len(struct
mbuf_queue *mq)mq_empty(struct
mbuf_queue *mq)mq_full(struct
mbuf_queue *mq)mq_hdatalen(struct
mbuf_queue *mq)mq_purge(struct
mbuf_queue *mq)mq_drops(struct
mbuf_queue *mq)mq_set_maxlen(struct
mbuf_queue *mq, unsigned int)mq_set_maxlen() will only set a new limit, it will
not free any excess mbufs that may already exist on the queue.mq_init(),
mq_enqueue(), mq_push(),
mq_dequeue(), mq_enlist(),
mq_delist(), mq_dechain(),
mq_len(), mq_empty(),
mq_full(), mq_purge(),
mq_drops(), mq_set_maxlen(),
and MBUF_QUEUE_INITIALIZER() can be called during
autoconf, from process context, or from interrupt context.
mq_dequeue() returns the mbuf that was at
the head of its queue. If the queue was empty, NULL
is returned.
mq_dechain() returns all the mbufs that
were on its queues via a pointer to an mbuf with the chain accessible via
m_nextpkt members. If the queue was empty, NULL is
returned.
mq_len() returns the number of mbufs on
the queue.
mq_empty() returns a non-zero value if the
queue is empty, otherwise 0.
mq_full() returns a non-zero value if the
queue is full, otherwise 0.
mq_enqueue() returns 0 if the mbuf was
successfully queued, or non-zero if the mbuf was freed because it would
cause the queue to exceed its maximum length.
mq_push() returns 0 if there was space on
the queue for the mbuf, or non-zero if the head of the queue was freed to
make space for it.
mq_enlist() returns the number of mbufs
that were dropped from the list if the length of the queue exceeded its
maximum length.
mq_hdatalen() returns the size of a packet
on the queue, or 0 if the queue is empty.
mq_purge() returns the number of mbufs
that were freed.
mq_drops() returns the number of mbufs
that were freed during mq_enqueue() operations that
would have caused the queue to exceed its maximum length.
| August 28, 2020 | Debian |