#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");