source: lib/data-struct/buckets.h @ e63d80d

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivelibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since e63d80d was e63d80d, checked in by Shane Alcock <salcock@…>, 6 years ago

Add bucket data structure for keeping track of packet buffers

A bucket can contain anywhere from 1 to N packets and will point to a
buffer owned by libtrace. Libtrace can signal that it is finished with an
individual packet and when all packets associated with the buffer are
finished, the buffer will be freed automatically.

This should make buffer management easier for formats like bpf and RT where
multiple packets can be read at once and will allow us to retain zero-copy
behaviour (aside from the initial read) in a parallel libtrace program.

  • Property mode set to 100644
File size: 840 bytes
Line 
1#ifndef LIBTRACE_BUCKET_H_
2#define LIBTRACE_BUCKET_H_
3
4#include <pthread.h>
5#include "linked_list.h"
6
7typedef struct bucket_node {
8        uint64_t startindex;
9        uint8_t *released;
10        uint16_t activemembers;
11        uint16_t slots;
12        void *buffer;
13} libtrace_bucket_node_t;
14
15typedef struct buckets {
16        uint64_t nextid;
17        libtrace_bucket_node_t *node;
18        libtrace_bucket_node_t **packets;
19        libtrace_list_t *nodelist;
20        pthread_mutex_t lock;
21        pthread_cond_t cond;
22} libtrace_bucket_t;
23
24libtrace_bucket_t *libtrace_bucket_init(void);
25void libtrace_bucket_destroy(libtrace_bucket_t *b);
26void libtrace_create_new_bucket(libtrace_bucket_t *b, void *buffer);
27uint64_t libtrace_push_into_bucket(libtrace_bucket_t *b);
28void libtrace_release_bucket_id(libtrace_bucket_t *b, uint64_t id);
29
30#endif
Note: See TracBrowser for help on using the repository browser.