Multi producer, single consumer packet buffer API.
More...
|
void | mpsc_pbuf_init (struct mpsc_pbuf_buffer *buffer, const struct mpsc_pbuf_buffer_config *config) |
| Initnialize a packet buffer. More...
|
|
union mpsc_pbuf_generic * | mpsc_pbuf_alloc (struct mpsc_pbuf_buffer *buffer, size_t wlen, k_timeout_t timeout) |
| Allocate a packet. More...
|
|
void | mpsc_pbuf_commit (struct mpsc_pbuf_buffer *buffer, union mpsc_pbuf_generic *packet) |
| Commit a packet. More...
|
|
void | mpsc_pbuf_put_word (struct mpsc_pbuf_buffer *buffer, union mpsc_pbuf_generic word) |
| Put single word packet into a buffer. More...
|
|
void | mpsc_pbuf_put_word_ext (struct mpsc_pbuf_buffer *buffer, union mpsc_pbuf_generic word, void *data) |
| Put a packet consisting of a word and a pointer.
- Function is optimized for storing packet consisting of a word and a pointer. Note that 2 bits of a first word is used by the buffer.
More...
|
|
void | mpsc_pbuf_put_data (struct mpsc_pbuf_buffer *buffer, uint32_t *data, size_t wlen) |
| Put a packet into a buffer. More...
|
|
union mpsc_pbuf_generic * | mpsc_pbuf_claim (struct mpsc_pbuf_buffer *buffer) |
| Claim the first pending packet. More...
|
|
void | mpsc_pbuf_free (struct mpsc_pbuf_buffer *buffer, union mpsc_pbuf_generic *packet) |
| Free a packet. More...
|
|
bool | mpsc_pbuf_is_pending (struct mpsc_pbuf_buffer *buffer) |
| Check if there are any message pending. More...
|
|
Multi producer, single consumer packet buffer API.
◆ mpsc_pbuf_get_wlen
#include <include/sys/mpsc_pbuf.h>
Callback prototype for getting length of a packet.
- Parameters
-
- Returns
- Size of the packet in 32 bit words.
◆ mpsc_pbuf_notify_drop
#include <include/sys/mpsc_pbuf.h>
Callback called when packet is dropped.
- Parameters
-
buffer | Packet buffer. |
packet | Packet that is being dropped. |
◆ mpsc_pbuf_alloc()
#include <include/sys/mpsc_pbuf.h>
Allocate a packet.
If a buffer is configured to overwrite mode then if there is no space to allocated a new buffer, oldest packets are dropped. Otherwise allocation fails and null pointer is returned.
- Parameters
-
buffer | Buffer. |
wlen | Number of words to allocate. |
timeout | Timeout. If called from thread context it will pend for given timeout if packet cannot be allocated before dropping the oldest or returning null. |
- Returns
- Pointer to the allocated space or null if it cannot be allocated.
◆ mpsc_pbuf_claim()
◆ mpsc_pbuf_commit()
◆ mpsc_pbuf_free()
◆ mpsc_pbuf_init()
◆ mpsc_pbuf_is_pending()
#include <include/sys/mpsc_pbuf.h>
Check if there are any message pending.
- Parameters
-
- Return values
-
true | if pending. |
false | if no message is pending. |
◆ mpsc_pbuf_put_data()
#include <include/sys/mpsc_pbuf.h>
Put a packet into a buffer.
Copy data into a buffer. Note that 2 bits of a first word is used by the buffer.
- Parameters
-
buffer | Buffer. |
data | First word of data must contain MPSC_PBUF_HDR with valid set. |
wlen | Packet size in words. |
◆ mpsc_pbuf_put_word()
#include <include/sys/mpsc_pbuf.h>
Put single word packet into a buffer.
Function is optimized for storing a packet which fit into a single word. Note that 2 bits of that word is used by the buffer.
- Parameters
-
buffer | Buffer. |
word | Packet content consisting of MPSC_PBUF_HDR with valid bit set and data on remaining bits. |
◆ mpsc_pbuf_put_word_ext()
#include <include/sys/mpsc_pbuf.h>
Put a packet consisting of a word and a pointer.
- Function is optimized for storing packet consisting of a word and a pointer. Note that 2 bits of a first word is used by the buffer.
- Parameters
-
buffer | Buffer. |
word | First word of a packet consisting of MPSC_PBUF_HDR with valid bit set and data on remaining bits. |
data | User data. |