Lines Matching full:packet
3 Multi Producer Single Consumer Packet Buffer
6 A :dfn:`Multi Producer Single Consumer Packet Buffer (MPSC_PBUF)` is a circular
8 packets are stored in the buffer. Packet buffer works under assumption that there
11 Packet is produced in two steps: first requested amount of data is allocated,
12 producer fills the data and commits it. Consuming a packet is also performed in
13 two steps: consumer claims the packet, gets pointer to it and length and later
14 on packet is freed. This approach reduces memory copying.
16 A :dfn:`MPSC Packet Buffer` has the following key properties:
18 * Allocate, commit scheme used for packet producing.
19 * Claim, free scheme used for packet consuming.
24 be allocated. For each dropped packet user callback is called.
33 Each packet in the buffer contains ``MPSC_PBUF`` specific header which is used
39 * valid - bit set to one when packet contains valid user packet
40 * busy - bit set when packet is being consumed (claimed but not free)
49 | 1 | 0 | valid packet |
51 | 1 | 1 | claimed valid packet |
53 | 0 | 1 | internal skip packet |
56 Packet buffer space contains free space, valid user packets and internal skip
64 within buffer is returned. Packet header is reset. If allocation required
65 wrapping of the write index, a skip packet is added to the end of buffer. If
74 header to ensure that currently consumed packet is not overwritten. In that case,
75 skip packet is added before busy packet and packets following the busy packet
76 are dropped. When busy packet is being freed, such situation is detected and
77 packet is converted to skip packet to avoid double processing.
82 Packet header definition
85 Packet header details can be found in :zephyr_file:`include/zephyr/sys/mpsc_packet.h`.
87 are split to avoid include spam when declaring the packet.
100 Packet buffer configuration
104 callbacks. Following callbacks are used by the packet buffer:
106 * Drop notification - callback called whenever a packet is dropped due to
108 * Get packet length - callback to determine packet length
110 Packet producing
117 foo_packet *packet = mpsc_pbuf_alloc(buffer, len, K_NO_WAIT);
119 fill_data(packet);
121 mpsc_pbuf_commit(buffer, packet);
125 * 32 bit word packet
126 * 32 bit word with pointer packet
136 Packet consuming
143 foo_packet *packet = mpsc_pbuf_claim(buffer);
145 process(packet);
147 mpsc_pbuf_free(buffer, packet);