#include <svm/fifo_segment.h>
#define SFIFO_TEST_I(_cond, _comment, _args...) \
#include <svm/fifo_segment.h>
#define SFIFO_TEST_I(_cond, _comment, _args...) \
SFIFO_TEST (0, "[%d] peeked %u expected %u", j, data_buf[j],
data_pattern[j]);
}
SFIFO_TEST (0, "[%d] peeked %u expected %u", j, data_buf[j],
data_pattern[j]);
}
svm_fifo_dequeue (f, vec_len (data_pattern), data_buf);
if (compare_data
(data_buf, data_pattern, 0, vec_len (data_pattern), &j))
svm_fifo_dequeue (f, vec_len (data_pattern), data_buf);
if (compare_data
(data_buf, data_pattern, 0, vec_len (data_pattern), &j))
int test_n_bytes, deq_bytes, enq_bytes, n_deqs, n_enqs;
svm_fifo_chunk_t *c, *next, *prev;
u8 *test_data = 0, *data_buf = 0;
int test_n_bytes, deq_bytes, enq_bytes, n_deqs, n_enqs;
svm_fifo_chunk_t *c, *next, *prev;
u8 *test_data = 0, *data_buf = 0;
svm_fifo_add_chunk (f, c);
SFIFO_TEST (f->size == fifo_size + 200, "size expected %u is %u",
fifo_size + 200, f->size);
svm_fifo_add_chunk (f, c);
SFIFO_TEST (f->size == fifo_size + 200, "size expected %u is %u",
fifo_size + 200, f->size);
SFIFO_TEST (svm_fifo_max_dequeue (f) == 0, "max deq expected %u is %u",
0, svm_fifo_max_dequeue (f));
svm_fifo_enqueue (f, sizeof (u8), &test_data[0]);
memset (data_buf, 0, vec_len (data_buf));
SFIFO_TEST (svm_fifo_max_dequeue (f) == 0, "max deq expected %u is %u",
0, svm_fifo_max_dequeue (f));
svm_fifo_enqueue (f, sizeof (u8), &test_data[0]);
memset (data_buf, 0, vec_len (data_buf));
- svm_fifo_dequeue (f, deq_bytes, data_buf + i * deq_bytes);
+ {
+ rv = svm_fifo_peek (f, offset, deq_bytes, data_buf + i * deq_bytes);
+ if (rv < 0 || (rv != deq_bytes && i != n_deqs))
+ SFIFO_TEST (0, "unexpected peek %d", rv);
+ offset += rv;
+ }
+ svm_fifo_dequeue_drop (f, offset);
rv = compare_data (data_buf, test_data, 0, vec_len (test_data),
(u32 *) & j);
rv = compare_data (data_buf, test_data, 0, vec_len (test_data),
(u32 *) & j);
svm_fifo_enqueue (f, 200, test_data);
svm_fifo_enqueue_with_offset (f, 50, vec_len (test_data) - 250,
&test_data[250]);
svm_fifo_enqueue (f, 200, test_data);
svm_fifo_enqueue_with_offset (f, 50, vec_len (test_data) - 250,
&test_data[250]);
+static svm_fifo_t *
+fifo_segment_alloc_fifo (fifo_segment_t * fs, u32 data_bytes,
+ fifo_segment_ftype_t ftype)
+{
+ return fifo_segment_alloc_fifo_w_slice (fs, 0, data_bytes, ftype);
+}
+
fifo_segment_create_args_t _a, *a = &_a;
fifo_segment_main_t *sm = &segment_main;
u8 *test_data, *retrieved_data = 0;
fifo_segment_create_args_t _a, *a = &_a;
fifo_segment_main_t *sm = &segment_main;
u8 *test_data, *retrieved_data = 0;
/* Lazy bastards united */
test_data = format (0, "Hello world%c", 0);
/* Lazy bastards united */
test_data = format (0, "Hello world%c", 0);
free_space = fifo_segment_free_bytes (fs);
SFIFO_TEST (free_space <= 256 << 10, "free space expected %u is %u",
256 << 10, free_space);
free_space = fifo_segment_free_bytes (fs);
SFIFO_TEST (free_space <= 256 << 10, "free space expected %u is %u",
256 << 10, free_space);
- rv = fifo_segment_prealloc_fifo_chunks (fs, 4096, 50);
+ rv = fifo_segment_prealloc_fifo_chunks (fs, 0, 4096, 50);
SFIFO_TEST (rv == 0, "chunk prealloc should work");
rv = fifo_segment_num_free_chunks (fs, 4096);
SFIFO_TEST (rv == 50, "prealloc chunks expected %u is %u", 50, rv);
SFIFO_TEST (rv == 0, "chunk prealloc should work");
rv = fifo_segment_num_free_chunks (fs, 4096);
SFIFO_TEST (rv == 50, "prealloc chunks expected %u is %u", 50, rv);
SFIFO_TEST (rv == 0, "fifo hdr prealloc should work");
rv = fifo_segment_num_free_fifos (fs);
SFIFO_TEST (rv == 50, "prealloc fifo hdrs expected %u is %u", 50, rv);
SFIFO_TEST (rv == 0, "fifo hdr prealloc should work");
rv = fifo_segment_num_free_fifos (fs);
SFIFO_TEST (rv == 50, "prealloc fifo hdrs expected %u is %u", 50, rv);
/* Preallocate as many more chunks as possible. Heap is almost full
* so we may not use all the free space*/
alloc = 0;
/* Preallocate as many more chunks as possible. Heap is almost full
* so we may not use all the free space*/
alloc = 0;
- while (!fifo_segment_prealloc_fifo_chunks (fs, 4096, 1))
+ while (!fifo_segment_prealloc_fifo_chunks (fs, 0, 4096, 1))
alloc++;
SFIFO_TEST (alloc, "chunk prealloc should work %u", alloc);
rv = fifo_segment_num_free_chunks (fs, 4096);
alloc++;
SFIFO_TEST (alloc, "chunk prealloc should work %u", alloc);
rv = fifo_segment_num_free_chunks (fs, 4096);
f = fifo_segment_alloc_fifo (fs, 200 << 10, FIFO_SEGMENT_RX_FIFO);
SFIFO_TEST (f == 0, "fifo alloc should fail");
f = fifo_segment_alloc_fifo (fs, 200 << 10, FIFO_SEGMENT_RX_FIFO);
SFIFO_TEST (f == 0, "fifo alloc should fail");
- rv = fifo_segment_prealloc_fifo_chunks (fs, 4096, 50);
+ rv = fifo_segment_prealloc_fifo_chunks (fs, 0, 4096, 50);
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "verbose"))
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "verbose"))