![]() |
SolarCapture C Bindings User Guide
SF-115721-CD
Issue 1
|
sc_pool: A pool of packet buffers. More...
Functions | |
int | sc_pool_get_packets (struct sc_packet_list *list, struct sc_pool *pool, int min_packets, int max_packets) |
Get packet buffers from a pool. More... | |
void | sc_pool_return_packets (struct sc_pool *pool, struct sc_packet_list *list) |
Return packets to a pool. More... | |
void | sc_pool_on_threshold (struct sc_pool *pool, struct sc_callback *event, int threshold) |
Request a callback when the pool is refilled. More... | |
struct sc_packet * | sc_pool_duplicate_packet (struct sc_pool *pool, struct sc_packet *packet, int snap) |
Duplicate a packet. More... | |
struct sc_packet * | sc_pool_duplicate_packed_packet (struct sc_pool *pool, const struct sc_packed_packet *psp, int snap) |
Duplicate a packed-stream packet. More... | |
int | sc_packet_append_iovec_ptr (struct sc_packet *packet, struct sc_pool *pool, struct sc_iovec_ptr *iovp, int snap) |
Append data to a packet. More... | |
struct sc_node * | sc_pool_set_refill_node (struct sc_pool *pool, struct sc_node *node) |
Set the refill node for a pool. More... | |
int | sc_pool_wraps_node (struct sc_pool *pool, struct sc_node *node) |
Indicate that a pool is used to wrap packets from a node. More... | |
struct sc_object * | sc_pool_to_object (struct sc_pool *pool) |
Convert an sc_pool to an sc_object. More... | |
struct sc_pool * | sc_pool_from_object (struct sc_object *obj) |
Convert an sc_object to an sc_pool. More... | |
uint64_t | sc_pool_get_buffer_size (struct sc_pool *pool) |
Get the minimum buffer size provided by this pool. More... | |
sc_pool: A pool of packet buffers.
int sc_packet_append_iovec_ptr | ( | struct sc_packet * | packet, |
struct sc_pool * | pool, | ||
struct sc_iovec_ptr * | iovp, | ||
int | snap | ||
) |
Append data to a packet.
packet | The packet to append data to |
pool | Packet pool to allocate frag buffers from (optional) |
iovp | Identifies the data to copy in |
snap | The maximum number of bytes to copy in |
If you need to know the number of bytes appended, compare the packet frame_len before and after the call.
struct sc_packet* sc_pool_duplicate_packed_packet | ( | struct sc_pool * | pool, |
const struct sc_packed_packet * | psp, | ||
int | snap | ||
) |
Duplicate a packed-stream packet.
pool | The pool to allocate buffers from |
psp | The packed-stream packet to duplicate |
snap | The maximum number of bytes to copy |
struct sc_packet* sc_pool_duplicate_packet | ( | struct sc_pool * | pool, |
struct sc_packet * | packet, | ||
int | snap | ||
) |
Duplicate a packet.
pool | The pool to allocate buffers from |
packet | The packet to duplicate |
snap | The maximum number of bytes to copy |
struct sc_pool* sc_pool_from_object | ( | struct sc_object * | obj | ) |
uint64_t sc_pool_get_buffer_size | ( | struct sc_pool * | pool | ) |
Get the minimum buffer size provided by this pool.
pool | An sc_pool instance |
If called at prep time, the size returned returned may be less than the size of buffers provided by this pool.
int sc_pool_get_packets | ( | struct sc_packet_list * | list, |
struct sc_pool * | pool, | ||
int | min_packets, | ||
int | max_packets | ||
) |
Get packet buffers from a pool.
list | List where retrieved packets are placed |
pool | The packet pool |
min_packets | Minimum number of buffers to be returned |
max_packets | Maximum number of buffers to be returned |
list
, or -1 if the minimum could not be satisfied.list
must be initialised on entry (and may already contain some packets), but need not be finalised. The list is finalised on return unless an error is returned (in which case the list is not modified).
Each packet returned is initialised as follows: pkt->flags = 0; pkt->frame_len = 0; pkt->iovlen = 1; pkt->iov[0] gives the base and extent of the DMA area The fragment list is empty
The following packet fields have undefined values: ts_sec, ts_nsec.
void sc_pool_on_threshold | ( | struct sc_pool * | pool, |
struct sc_callback * | event, | ||
int | threshold | ||
) |
Request a callback when the pool is refilled.
pool | The packet pool |
event | The event object |
threshold | Event fires when pool has >= threshold buffers |
Registers an event handler that is invoked when the pool fill level reaches the specified threshold. If the pool fill level is already at or above the threshold, the handler will be invoked as soon as possible.
void sc_pool_return_packets | ( | struct sc_pool * | pool, |
struct sc_packet_list * | list | ||
) |
Return packets to a pool.
pool | The packet pool |
list | List of packets to return |
list
must be initialised on entry, but can be empty. The packets on the list can have frags.
Set the refill node for a pool.
pool | A packet pool |
node | A refill node |
node
to be the refill node for pool
. SolarCapture sets up the necessary links so that when packet buffers from pool
are freed, they will be forwarded to node
.It is expected that node
will normally return packets to the pool by calling sc_pool_return_packets.
This call is only needed if some action needs to be taken before returning freed buffers to the pool. The builtin nodes sc_wrap_undo and sc_ref_count_undo can be used as pool refill nodes.
struct sc_object* sc_pool_to_object | ( | struct sc_pool * | pool | ) |
int sc_pool_wraps_node | ( | struct sc_pool * | pool, |
struct sc_node * | node | ||
) |
Indicate that a pool is used to wrap packets from a node.
pool | A packet pool |
node | A node |
This function is used to indicate that packets from pool
are used to wrap packets that are delivered to node
.
This allows SolarCapture to ensure that the packet pools sending packets to node
can be configured appropriately. For example, if these wrapped packets reach an sc_injector, it may be necessary to DMA map the underlying packet buffers.