#define MAX_DRIVER_NAME 64
#define MAX_INPUT_FILE_NAME 64
#define MAX_LIST 32
+#define MIN_COMPRESSED_BUF_SIZE 8
+#define EXPANSE_RATIO 1.05
+#define MAX_MBUF_DATA_SIZE (UINT16_MAX - RTE_PKTMBUF_HEADROOM)
+#define MAX_SEG_SIZE ((int)(MAX_MBUF_DATA_SIZE / EXPANSE_RATIO))
enum comp_operation {
COMPRESS_ONLY,
struct rte_mempool *op_pool;
int8_t cdev_id;
uint16_t seg_sz;
+ uint16_t out_seg_sz;
uint16_t burst_sz;
uint32_t pool_sz;
uint32_t num_iter;
return -1;
}
- if (test_data->seg_sz == 0) {
- RTE_LOG(ERR, USER1, "Segment size must be higher than 0\n");
+ if (test_data->seg_sz < MIN_COMPRESSED_BUF_SIZE) {
+ RTE_LOG(ERR, USER1, "Segment size must be higher than %d\n",
+ MIN_COMPRESSED_BUF_SIZE - 1);
+ return -1;
+ }
+
+ if (test_data->seg_sz > MAX_SEG_SIZE) {
+ RTE_LOG(ERR, USER1, "Segment size must be lower than %d\n",
+ MAX_SEG_SIZE + 1);
return -1;
}
struct rte_mbuf **input_bufs, **output_bufs;
int res = 0;
int allocated = 0;
+ uint32_t out_seg_sz;
if (test_data == NULL || !test_data->burst_sz) {
RTE_LOG(ERR, USER1,
};
input_bufs = test_data->decomp_bufs;
output_bufs = test_data->comp_bufs;
+ out_seg_sz = test_data->out_seg_sz;
} else {
xform = (struct rte_comp_xform) {
.type = RTE_COMP_DECOMPRESS,
};
input_bufs = test_data->comp_bufs;
output_bufs = test_data->decomp_bufs;
+ out_seg_sz = test_data->seg_sz;
}
/* Create private xform */
/* Reset all data in output buffers */
struct rte_mbuf *m = output_bufs[buf_id];
- m->pkt_len = test_data->seg_sz * m->nb_segs;
+ m->pkt_len = out_seg_sz * m->nb_segs;
while (m) {
m->data_len = m->buf_len - m->data_off;
m = m->next;
while (remaining_data > 0) {
data_to_append =
RTE_MIN(remaining_data,
- test_data->seg_sz);
+ out_seg_sz);
m->data_len = data_to_append;
remaining_data -=
data_to_append;
while (remaining_data > 0) {
data_to_append =
RTE_MIN(remaining_data,
- test_data->seg_sz);
+ out_seg_sz);
m->data_len = data_to_append;
remaining_data -=
data_to_append;
struct rte_mbuf **input_bufs, **output_bufs;
int res = 0;
int allocated = 0;
+ uint32_t out_seg_sz;
if (test_data == NULL || !test_data->burst_sz) {
RTE_LOG(ERR, USER1,
};
input_bufs = test_data->decomp_bufs;
output_bufs = test_data->comp_bufs;
+ out_seg_sz = test_data->out_seg_sz;
} else {
xform = (struct rte_comp_xform) {
.type = RTE_COMP_DECOMPRESS,
};
input_bufs = test_data->comp_bufs;
output_bufs = test_data->decomp_bufs;
+ out_seg_sz = test_data->seg_sz;
}
/* Create private xform */
/* Reset all data in output buffers */
struct rte_mbuf *m = output_bufs[buf_id];
- m->pkt_len = test_data->seg_sz * m->nb_segs;
+ m->pkt_len = out_seg_sz * m->nb_segs;
while (m) {
m->data_len = m->buf_len - m->data_off;
m = m->next;
while (remaining_data > 0) {
data_to_append =
RTE_MIN(remaining_data,
- test_data->seg_sz);
+ out_seg_sz);
m->data_len = data_to_append;
remaining_data -=
data_to_append;
while (remaining_data > 0) {
data_to_append =
RTE_MIN(remaining_data,
- test_data->seg_sz);
+ out_seg_sz);
m->data_len = data_to_append;
remaining_data -=
data_to_append;
#define NUM_MAX_XFORMS 16
#define NUM_MAX_INFLIGHT_OPS 512
-#define EXPANSE_RATIO 1.05
-#define MIN_COMPRESSED_BUF_SIZE 8
#define DIV_CEIL(a, b) ((a) / (b) + ((a) % (b) != 0))
return 0;
}
+static uint32_t
+find_buf_size(uint32_t input_size)
+{
+ uint32_t i;
+
+ /* From performance point of view the buffer size should be a
+ * power of 2 but also should be enough to store incompressible data
+ */
+
+ /* We're looking for nearest power of 2 buffer size, which is greather
+ * than input_size
+ */
+ uint32_t size =
+ !input_size ? MIN_COMPRESSED_BUF_SIZE : (input_size << 1);
+
+ for (i = UINT16_MAX + 1; !(i & size); i >>= 1)
+ ;
+
+ return i > ((UINT16_MAX + 1) >> 1)
+ ? (uint32_t)((float)input_size * EXPANSE_RATIO)
+ : i;
+}
+
static int
comp_perf_allocate_memory(struct comp_test_data *test_data)
{
+
+ test_data->out_seg_sz = find_buf_size(test_data->seg_sz);
/* Number of segments for input and output
* (compression and decompression)
*/
test_data->seg_sz);
test_data->comp_buf_pool = rte_pktmbuf_pool_create("comp_buf_pool",
total_segs,
- 0, 0, test_data->seg_sz + RTE_PKTMBUF_HEADROOM,
+ 0, 0,
+ test_data->out_seg_sz + RTE_PKTMBUF_HEADROOM,
rte_socket_id());
if (test_data->comp_buf_pool == NULL) {
RTE_LOG(ERR, USER1, "Mbuf mempool could not be created\n");
}
data_addr = (uint8_t *) rte_pktmbuf_append(
test_data->comp_bufs[i],
- test_data->seg_sz);
+ test_data->out_seg_sz);
if (data_addr == NULL) {
RTE_LOG(ERR, USER1, "Could not append data\n");
return -1;
}
data_addr = (uint8_t *)rte_pktmbuf_append(next_seg,
- test_data->seg_sz);
+ test_data->out_seg_sz);
if (data_addr == NULL) {
RTE_LOG(ERR, USER1, "Could not append data\n");