* [PATCH 1/3] compressdev: support for dictionaries and PDCP checksum
@ 2025-09-19 17:34 Sameer Vaze
2025-09-19 17:34 ` [PATCH 2/3] compress/zlib: " Sameer Vaze
2025-09-19 17:34 ` [PATCH 3/3] app/compress-perf: " Sameer Vaze
0 siblings, 2 replies; 5+ messages in thread
From: Sameer Vaze @ 2025-09-19 17:34 UTC (permalink / raw)
To: Fan Zhang, Ashish Gupta; +Cc: dev, Sameer Vaze
Adds definitions for PDCP checksums and apis to pass in
dictionaries
Signed-off-by: Sameer Vaze <svaze@qti.qualcomm.com>
---
lib/compressdev/rte_comp.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/lib/compressdev/rte_comp.h b/lib/compressdev/rte_comp.h
index 96d9b276dd..169d3d960e 100644
--- a/lib/compressdev/rte_comp.h
+++ b/lib/compressdev/rte_comp.h
@@ -101,6 +101,10 @@ enum rte_comp_op_status {
* is not an error case. Output data up to op.produced can be used and
* next op in the stream should continue on from op.consumed+1.
*/
+ RTE_COMP_OP_STATUS_CHECK_SUM_VALIDATION_FAILED,
+ /**< Checksum validation failed. Either calculated does checksum not match
+ * the one provided or there was an error calculating the checksum
+ */
};
/** Compression Algorithms */
@@ -166,6 +170,10 @@ enum rte_comp_checksum_type {
/**< Generates a xxHash-32 checksum, as used by LZ4.
* https://github.com/Cyan4973/xxHash/blob/dev/doc/xxhash_spec.md
*/
+ RTE_COMP_CHECKSUM_3GPP_PDCP_UDC,
+ /**< Generates checksum as defined under Uplink Data Compression
+ * checksum as defined in the 3GPP PDCP specification
+ */
};
/** Compression Huffman Type - used by DEFLATE algorithm */
@@ -201,6 +209,11 @@ enum rte_comp_flush_flag {
*/
};
+#define DEFLATE_MAX_WINDOW_SIZE (1ULL << 15)
+
+#define DEFLATE_MIN_WINDOW_SIZE (1ULL << 8)
+
+
/** Compression transform types */
enum rte_comp_xform_type {
RTE_COMP_COMPRESS,
@@ -305,6 +318,15 @@ struct rte_comp_compress_xform {
/**< Hash algorithm to be used with compress operation. Hash is always
* done on plaintext.
*/
+ uint8_t *dictionary;
+ /**<
+ * Pointer to memory containing dictionary to be used for inflate
+ * and deflate operations
+ */
+ uint16_t dictionary_len;
+ /**<
+ * Length of dictionary to be used
+ */
};
/**
@@ -328,6 +350,15 @@ struct rte_comp_decompress_xform {
/**< Hash algorithm to be used with decompress operation. Hash is always
* done on plaintext.
*/
+ uint8_t *dictionary;
+ /**<
+ * Pointer to memory containing dictionary to be used for inflate
+ * and deflate operations
+ */
+ uint16_t dictionary_len;
+ /**<
+ * Length of dictionary to be used
+ */
};
/**
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] compress/zlib: support for dictionaries and PDCP checksum
2025-09-19 17:34 [PATCH 1/3] compressdev: support for dictionaries and PDCP checksum Sameer Vaze
@ 2025-09-19 17:34 ` Sameer Vaze
2025-09-19 17:34 ` [PATCH 3/3] app/compress-perf: " Sameer Vaze
1 sibling, 0 replies; 5+ messages in thread
From: Sameer Vaze @ 2025-09-19 17:34 UTC (permalink / raw)
To: Sunila Sahu, Fan Zhang, Ashish Gupta; +Cc: dev, Sameer Vaze
Support to calculate PDCP checksums. Includes changes to
pass in dictionaries. Adds support for sync flush
Signed-off-by: Sameer Vaze <svaze@qti.qualcomm.com>
---
drivers/compress/zlib/zlib_pmd.c | 171 +++++++++++++++++++++--
drivers/compress/zlib/zlib_pmd_private.h | 8 ++
2 files changed, 170 insertions(+), 9 deletions(-)
diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c
index 92e808e78c..65f3999428 100644
--- a/drivers/compress/zlib/zlib_pmd.c
+++ b/drivers/compress/zlib/zlib_pmd.c
@@ -4,6 +4,7 @@
#include <bus_vdev_driver.h>
#include <rte_common.h>
+#include <rte_malloc.h>
#include "zlib_pmd_private.h"
@@ -15,6 +16,118 @@
(data = rte_pktmbuf_mtod(mbuf, uint8_t *)), \
(len = rte_pktmbuf_data_len(mbuf)) : 0)
+#define BOTTOM_NIBBLE_OF_BYTE 0xf
+#define TOP_NIBBLE_OF_BYTE 0xf0
+
+static void
+process_zlib_deflate_chksum(struct rte_comp_op *op,
+ z_stream *strm, enum rte_comp_checksum_type chksum)
+{
+ uint32_t dictionary_len = 0;
+ op->status = RTE_COMP_OP_STATUS_SUCCESS;
+
+ switch (chksum) {
+ case RTE_COMP_CHECKSUM_3GPP_PDCP_UDC:
+ {
+ uint8_t *dictionary = malloc(DEFLATE_MAX_WINDOW_SIZE);
+
+ if (!dictionary) {
+ ZLIB_PMD_ERR("Unable to fetch dictionary");
+ op->status = RTE_COMP_OP_STATUS_ERROR;
+ return;
+ }
+
+ if (deflateGetDictionary(strm, dictionary, &dictionary_len)) {
+ ZLIB_PMD_ERR("Unable to fetch dictionary");
+ op->status = RTE_COMP_OP_STATUS_CHECK_SUM_VALIDATION_FAILED;
+ rte_free(dictionary);
+ return;
+ }
+
+ uint32_t dictionary_start = (uint32_t)(*dictionary);
+ uint32_t dictionary_end = (uint32_t)(*(dictionary + dictionary_len - 4));
+ uint32_t sum = (dictionary_start & 0x0F0F0F0F)
+ + (dictionary_start & (0xF0F0F0F0 >> 4))
+ + (dictionary_end & 0x0F0F0F0F)
+ + (dictionary_end & (0xF0F0F0F0 >> 4));
+ uint8_t *sum_bytes = (uint8_t *)∑
+
+ op->output_chksum = ~(sum_bytes[0] + sum_bytes[1] + sum_bytes[2] + sum_bytes[3])
+ & BOTTOM_NIBBLE_OF_BYTE;
+
+ rte_free(dictionary);
+
+ break;
+ }
+ case RTE_COMP_CHECKSUM_NONE:
+ case RTE_COMP_CHECKSUM_CRC32:
+ case RTE_COMP_CHECKSUM_ADLER32:
+ case RTE_COMP_CHECKSUM_CRC32_ADLER32:
+ default:
+ ZLIB_PMD_ERR("Checksum not supported");
+ op->status = RTE_COMP_OP_STATUS_INVALID_ARGS;
+ return;
+ }
+}
+
+static void
+process_zlib_inflate_chksum(struct rte_comp_op *op,
+ z_stream *strm,
+ enum rte_comp_checksum_type chksum)
+{
+ uint32_t dictionary_len = 0;
+ op->status = RTE_COMP_OP_STATUS_SUCCESS;
+
+ switch (chksum) {
+ case RTE_COMP_CHECKSUM_3GPP_PDCP_UDC:
+ {
+ uint8_t *dictionary = malloc(DEFLATE_MAX_WINDOW_SIZE);
+
+ if (!dictionary) {
+ ZLIB_PMD_ERR("Unable to fetch dictionary");
+ op->status = RTE_COMP_OP_STATUS_ERROR;
+ return;
+ }
+
+ if (inflateGetDictionary(strm, dictionary, &dictionary_len)) {
+ ZLIB_PMD_ERR("Unable to fetch dictionary");
+ op->status = RTE_COMP_OP_STATUS_CHECK_SUM_VALIDATION_FAILED;
+ rte_free(dictionary);
+ return;
+ }
+
+ uint32_t dictionary_start = (uint32_t)(*dictionary);
+ uint32_t dictionary_end = (uint32_t)(*(dictionary + dictionary_len - 4));
+ uint32_t sum = (dictionary_start & 0x0F0F0F0F)
+ + (dictionary_start & (0xF0F0F0F0 >> 4))
+ + (dictionary_end & 0x0F0F0F0F)
+ + (dictionary_end & (0xF0F0F0F0 >> 4));
+ uint8_t *sum_bytes = (uint8_t *)∑
+
+ op->output_chksum = ~(sum_bytes[0] + sum_bytes[1] + sum_bytes[2] + sum_bytes[3])
+ & BOTTOM_NIBBLE_OF_BYTE;
+
+ if (op->input_chksum != op->output_chksum) {
+ ZLIB_PMD_ERR("Checksum does not match");
+ op->status = RTE_COMP_OP_STATUS_CHECK_SUM_VALIDATION_FAILED;
+ rte_free(dictionary);
+ return;
+ }
+ rte_free(dictionary);
+
+ break;
+ }
+ case RTE_COMP_CHECKSUM_NONE:
+ case RTE_COMP_CHECKSUM_CRC32:
+ case RTE_COMP_CHECKSUM_ADLER32:
+ case RTE_COMP_CHECKSUM_CRC32_ADLER32:
+ default:
+ ZLIB_PMD_ERR("Checksum not supported");
+ op->status = RTE_COMP_OP_STATUS_INVALID_ARGS;
+ return;
+ }
+}
+
static void
process_zlib_deflate(struct rte_comp_op *op, z_stream *strm)
{
@@ -27,6 +140,9 @@ process_zlib_deflate(struct rte_comp_op *op, z_stream *strm)
case RTE_COMP_FLUSH_FINAL:
fin_flush = Z_FINISH;
break;
+ case RTE_COMP_FLUSH_SYNC:
+ fin_flush = Z_SYNC_FLUSH;
+ break;
default:
op->status = RTE_COMP_OP_STATUS_INVALID_ARGS;
ZLIB_PMD_ERR("Invalid flush value");
@@ -49,6 +165,9 @@ process_zlib_deflate(struct rte_comp_op *op, z_stream *strm)
strm->avail_out = rte_pktmbuf_data_len(mbuf_dst) - op->dst.offset;
+ uLong total_in_at_start = strm->total_in;
+ uLong total_out_at_start = strm->total_out;
+
/* Set flush value to NO_FLUSH unless it is last mbuf */
flush = Z_NO_FLUSH;
/* Initialize status to SUCCESS */
@@ -56,8 +175,8 @@ process_zlib_deflate(struct rte_comp_op *op, z_stream *strm)
do {
/* Set flush value to Z_FINISH for last block */
- if ((op->src.length - strm->total_in) <= strm->avail_in) {
- strm->avail_in = (op->src.length - strm->total_in);
+ if ((op->src.length - (strm->total_in - total_in_at_start)) <= strm->avail_in) {
+ strm->avail_in = (op->src.length - (strm->total_in - total_in_at_start));
flush = fin_flush;
}
do {
@@ -92,17 +211,18 @@ process_zlib_deflate(struct rte_comp_op *op, z_stream *strm)
/* Update op stats */
switch (op->status) {
case RTE_COMP_OP_STATUS_SUCCESS:
- op->consumed += strm->total_in;
+ op->consumed += strm->total_in - total_in_at_start;
/* Fall-through */
case RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED:
- op->produced += strm->total_out;
+ op->produced += strm->total_out - total_out_at_start;
break;
default:
ZLIB_PMD_ERR("stats not updated for status:%d",
op->status);
}
- deflateReset(strm);
+ if (op->flush_flag != RTE_COMP_FLUSH_SYNC)
+ deflateReset(strm);
}
static void
@@ -127,6 +247,9 @@ process_zlib_inflate(struct rte_comp_op *op, z_stream *strm)
strm->avail_out = rte_pktmbuf_data_len(mbuf_dst) - op->dst.offset;
+ uLong total_in_at_start = strm->total_in;
+ uLong total_out_at_start = strm->total_out;
+
/** Ignoring flush value provided from application for decompression */
flush = Z_NO_FLUSH;
/* initialize status to SUCCESS */
@@ -178,17 +301,18 @@ process_zlib_inflate(struct rte_comp_op *op, z_stream *strm)
/* Update op stats */
switch (op->status) {
case RTE_COMP_OP_STATUS_SUCCESS:
- op->consumed += strm->total_in;
+ op->consumed += strm->total_in - total_in_at_start;
/* Fall-through */
case RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED:
- op->produced += strm->total_out;
+ op->produced += strm->total_out - total_out_at_start;
break;
default:
ZLIB_PMD_ERR("stats not produced for status:%d",
op->status);
}
- inflateReset(strm);
+ if (op->flush_flag != RTE_COMP_FLUSH_SYNC)
+ inflateReset(strm);
}
/** Process comp operation for mbuf */
@@ -203,10 +327,14 @@ process_zlib_op(struct zlib_qp *qp, struct rte_comp_op *op)
(op->dst.offset > rte_pktmbuf_data_len(op->m_dst))) {
op->status = RTE_COMP_OP_STATUS_INVALID_ARGS;
ZLIB_PMD_ERR("Invalid source or destination buffers or "
- "invalid Operation requested");
+ "invalid Operation requested");
} else {
private_xform = (struct zlib_priv_xform *)op->private_xform;
stream = &private_xform->stream;
+ stream->chksum(op, &stream->strm, stream->chksum_type);
+ if (op->status != RTE_COMP_OP_STATUS_SUCCESS)
+ return -1;
+
stream->comp(op, &stream->strm);
}
/* whatever is out of op, put it into completion queue with
@@ -232,6 +360,7 @@ zlib_set_stream_parameters(const struct rte_comp_xform *xform,
case RTE_COMP_COMPRESS:
stream->comp = process_zlib_deflate;
stream->free = deflateEnd;
+ stream->chksum = process_zlib_deflate_chksum;
/** Compression window bits */
switch (xform->compress.algo) {
case RTE_COMP_ALGO_DEFLATE:
@@ -281,17 +410,30 @@ zlib_set_stream_parameters(const struct rte_comp_xform *xform,
ZLIB_PMD_ERR("Compression strategy not supported");
return -1;
}
+
+ /** Checksum used */
+ stream->chksum_type = xform->compress.chksum;
+
if (deflateInit2(strm, level,
Z_DEFLATED, wbits,
DEF_MEM_LEVEL, strategy) != Z_OK) {
ZLIB_PMD_ERR("Deflate init failed");
return -1;
}
+
+ if (xform->compress.dictionary) {
+ if (deflateSetDictionary(strm, xform->compress.dictionary,
+ xform->compress.dictionary_len)) {
+ ZLIB_PMD_ERR("Deflate set dictionary failed");
+ return -1;
+ }
+ }
break;
case RTE_COMP_DECOMPRESS:
stream->comp = process_zlib_inflate;
stream->free = inflateEnd;
+ stream->chksum = process_zlib_inflate_chksum;
/** window bits */
switch (xform->decompress.algo) {
case RTE_COMP_ALGO_DEFLATE:
@@ -302,10 +444,21 @@ zlib_set_stream_parameters(const struct rte_comp_xform *xform,
return -1;
}
+ /** Checksum used */
+ stream->chksum_type = xform->decompress.chksum;
+
if (inflateInit2(strm, wbits) != Z_OK) {
ZLIB_PMD_ERR("Inflate init failed");
return -1;
}
+
+ if (xform->decompress.dictionary) {
+ if (inflateSetDictionary(strm, xform->decompress.dictionary,
+ xform->decompress.dictionary_len)) {
+ ZLIB_PMD_ERR("inflate set dictionary failed");
+ return -1;
+ }
+ }
break;
default:
return -1;
diff --git a/drivers/compress/zlib/zlib_pmd_private.h b/drivers/compress/zlib/zlib_pmd_private.h
index fd8c4c55a4..99bfdc9a76 100644
--- a/drivers/compress/zlib/zlib_pmd_private.h
+++ b/drivers/compress/zlib/zlib_pmd_private.h
@@ -46,6 +46,10 @@ typedef void (*comp_func_t)(struct rte_comp_op *op, z_stream *strm);
typedef int (*comp_free_t)(z_stream *strm);
+typedef void (*chksum_func_t)
+ (struct rte_comp_op *op, z_stream *strm, enum rte_comp_checksum_type chksum);
+
+
/** ZLIB Stream structure */
struct __rte_cache_aligned zlib_stream {
z_stream strm;
@@ -54,6 +58,10 @@ struct __rte_cache_aligned zlib_stream {
/**< Operation (compression/decompression) */
comp_free_t free;
/**< Free Operation (compression/decompression) */
+ chksum_func_t chksum;
+ /**< Checksum Operation (compression/decompression) */
+ enum rte_comp_checksum_type chksum_type;
+ /**< Type of checksum to generate on the uncompressed data */
};
/** ZLIB private xform structure */
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] app/compress-perf: support for dictionaries and PDCP checksum
2025-09-19 17:34 [PATCH 1/3] compressdev: support for dictionaries and PDCP checksum Sameer Vaze
2025-09-19 17:34 ` [PATCH 2/3] compress/zlib: " Sameer Vaze
@ 2025-09-19 17:34 ` Sameer Vaze
1 sibling, 0 replies; 5+ messages in thread
From: Sameer Vaze @ 2025-09-19 17:34 UTC (permalink / raw)
Cc: dev, Sameer Vaze
Adds support to read and apply dictionaries.
Signed-off-by: Sameer Vaze <svaze@qti.qualcomm.com>
---
app/test-compress-perf/comp_perf_options.h | 4 +
.../comp_perf_options_parse.c | 16 ++++
.../comp_perf_test_verify.c | 37 +++++++-
app/test-compress-perf/main.c | 90 +++++++++++++++++++
4 files changed, 144 insertions(+), 3 deletions(-)
diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h
index 828a7309d8..4c34dcd8aa 100644
--- a/app/test-compress-perf/comp_perf_options.h
+++ b/app/test-compress-perf/comp_perf_options.h
@@ -21,6 +21,7 @@ enum cleanup_st {
ST_TEST_DATA,
ST_COMPDEV,
ST_INPUT_DATA,
+ ST_DICTIONARY_DATA,
ST_MEMORY_ALLOC,
ST_DURING_TEST
};
@@ -48,10 +49,13 @@ struct range_list {
struct comp_test_data {
char driver_name[RTE_DEV_NAME_MAX_LEN];
char input_file[PATH_MAX];
+ char dictionary_file[PATH_MAX];
enum cperf_test_type test;
uint8_t *input_data;
size_t input_data_sz;
+ uint8_t *dictionary_data;
+ size_t dictionary_data_sz;
uint16_t nb_qps;
uint16_t seg_sz;
uint16_t out_seg_sz;
diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c
index 6d8c370fc2..37205ad806 100644
--- a/app/test-compress-perf/comp_perf_options_parse.c
+++ b/app/test-compress-perf/comp_perf_options_parse.c
@@ -31,6 +31,7 @@
#define CPERF_LEVEL ("compress-level")
#define CPERF_WINDOW_SIZE ("window-sz")
#define CPERF_EXTERNAL_MBUFS ("external-mbufs")
+#define CPERF_DICTIONARY ("dictionary")
/* cyclecount-specific options */
#define CPERF_CYCLECOUNT_DELAY_US ("cc-delay-us")
@@ -71,6 +72,7 @@ usage(char *progname)
" keeping the data directly in mbuf area\n"
" --cc-delay-us N: delay between enqueue and dequeue operations in microseconds\n"
" valid only for cyclecount perf test (default: 500 us)\n"
+ " --dictionary NAME: file with dictionary\n"
" -h: prints this help\n",
progname);
}
@@ -609,6 +611,18 @@ parse_external_mbufs(struct comp_test_data *test_data,
return 0;
}
+static int
+parse_dictionary_file(struct comp_test_data *test_data, const char *arg)
+{
+ if (strlen(arg) > (sizeof(test_data->dictionary_file) - 1))
+ return -1;
+
+ strlcpy(test_data->dictionary_file, arg, sizeof(test_data->dictionary_file));
+
+ return 0;
+}
+
+
static int
parse_cyclecount_delay_us(struct comp_test_data *test_data,
const char *arg)
@@ -647,6 +661,7 @@ static struct option lgopts[] = {
{ CPERF_LEVEL, required_argument, 0, 0 },
{ CPERF_WINDOW_SIZE, required_argument, 0, 0 },
{ CPERF_EXTERNAL_MBUFS, 0, 0, 0 },
+ { CPERF_DICTIONARY, required_argument, 0, 0 },
{ CPERF_CYCLECOUNT_DELAY_US, required_argument, 0, 0 },
{ NULL, 0, 0, 0 }
};
@@ -671,6 +686,7 @@ comp_perf_opts_parse_long(int opt_idx, struct comp_test_data *test_data)
{ CPERF_LEVEL, parse_level },
{ CPERF_WINDOW_SIZE, parse_window_sz },
{ CPERF_EXTERNAL_MBUFS, parse_external_mbufs },
+ { CPERF_DICTIONARY, parse_dictionary_file },
{ CPERF_CYCLECOUNT_DELAY_US, parse_cyclecount_delay_us },
};
unsigned int i;
diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c
index 09d97c5cf7..f1d02afa6e 100644
--- a/app/test-compress-perf/comp_perf_test_verify.c
+++ b/app/test-compress-perf/comp_perf_test_verify.c
@@ -64,6 +64,7 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
int res = 0;
int allocated = 0;
uint32_t out_seg_sz;
+ uint8_t dict[DEFLATE_MAX_WINDOW_SIZE] = {0};
if (test_data == NULL || !test_data->burst_sz) {
RTE_LOG(ERR, USER1,
@@ -71,6 +72,22 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
return -1;
}
+ uint16_t window_size = (1ULL << test_data->window_sz);
+
+ if (test_data->dictionary_data) {
+ if (test_data->dictionary_data_sz >= window_size) {
+ memcpy(dict,
+ test_data->dictionary_data
+ + (test_data->dictionary_data_sz - window_size),
+ window_size);
+ } else if (test_data->dictionary_data_sz < window_size) {
+ memcpy(dict + (window_size - test_data->dictionary_data_sz),
+ test_data->dictionary_data,
+ test_data->dictionary_data_sz);
+ }
+ }
+
+
ops = rte_zmalloc_socket(NULL,
2 * mem->total_bufs * sizeof(struct rte_comp_op *),
0, rte_socket_id());
@@ -91,7 +108,9 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
.level = test_data->level,
.window_size = test_data->window_sz,
.chksum = RTE_COMP_CHECKSUM_NONE,
- .hash_algo = RTE_COMP_HASH_ALGO_NONE
+ .hash_algo = RTE_COMP_HASH_ALGO_NONE,
+ .dictionary = dict,
+ .dictionary_len = window_size
}
};
if (test_data->test_algo == RTE_COMP_ALGO_DEFLATE)
@@ -110,7 +129,9 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
.algo = test_data->test_algo,
.chksum = RTE_COMP_CHECKSUM_NONE,
.window_size = test_data->window_sz,
- .hash_algo = RTE_COMP_HASH_ALGO_NONE
+ .hash_algo = RTE_COMP_HASH_ALGO_NONE,
+ .dictionary = dict,
+ .dictionary_len = window_size
}
};
if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
@@ -194,7 +215,17 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
rte_pktmbuf_pkt_len(input_bufs[buf_id]);
ops[op_id]->dst.offset = 0;
ops[op_id]->flush_flag = RTE_COMP_FLUSH_FINAL;
- ops[op_id]->input_chksum = buf_id;
+ if ((xform.type == RTE_COMP_DECOMPRESS) &&
+ (xform.decompress.chksum
+ == RTE_COMP_CHECKSUM_3GPP_PDCP_UDC)) {
+ uint8_t *udc_header
+ = rte_pktmbuf_mtod(ops[op_id]->m_src, uint8_t *);
+ ops[op_id]->input_chksum = *udc_header & 0xf;
+ ops[op_id]->src.offset = 1;
+ } else {
+ ops[op_id]->input_chksum = buf_id;
+ ops[op_id]->src.offset = 0;
+ }
ops[op_id]->private_xform = priv_xform;
}
diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index 70ce4316cc..693a7cc31b 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -335,6 +335,86 @@ comp_perf_dump_input_data(struct comp_test_data *test_data)
return ret;
}
+static int
+comp_perf_dump_dictionary_data(struct comp_test_data *test_data)
+{
+ FILE *f = fopen(test_data->dictionary_file, "r");
+ int ret = -1;
+
+ if (f == NULL) {
+ RTE_LOG(ERR, USER1, "Dictionary file not specified\n");
+ test_data->dictionary_data_sz = 0;
+ test_data->dictionary_data = NULL;
+ ret = 0;
+ goto end;
+ }
+
+ if (fseek(f, 0, SEEK_END) != 0) {
+ RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
+ goto end;
+ }
+ size_t actual_file_sz = ftell(f);
+ /* If extended input data size has not been set,
+ * input data size = file size
+ */
+
+ if (test_data->dictionary_data_sz == 0)
+ test_data->dictionary_data_sz = actual_file_sz;
+
+ if (test_data->dictionary_data_sz <= 0 || actual_file_sz <= 0 ||
+ fseek(f, 0, SEEK_SET) != 0) {
+ RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
+ goto end;
+ }
+
+ test_data->dictionary_data = rte_zmalloc_socket(NULL,
+ test_data->dictionary_data_sz, 0, rte_socket_id());
+
+ if (test_data->dictionary_data == NULL) {
+ RTE_LOG(ERR, USER1, "Memory to hold the data from the dictionary "
+ "file could not be allocated\n");
+ goto end;
+ }
+
+ size_t remaining_data = test_data->dictionary_data_sz;
+ uint8_t *data = test_data->dictionary_data;
+
+ while (remaining_data > 0) {
+ size_t data_to_read = RTE_MIN(remaining_data, actual_file_sz);
+
+ if (fread(data, data_to_read, 1, f) != 1) {
+ RTE_LOG(ERR, USER1, "Input file could not be read\n");
+ goto end;
+ }
+ if (fseek(f, 0, SEEK_SET) != 0) {
+ RTE_LOG(ERR, USER1,
+ "Size of input could not be calculated\n");
+ goto end;
+ }
+ remaining_data -= data_to_read;
+ data += data_to_read;
+ }
+
+ printf("\n");
+ if (test_data->dictionary_data_sz > actual_file_sz)
+ RTE_LOG(INFO, USER1,
+ "%zu bytes read from file %s, extending the file %.2f times\n",
+ test_data->dictionary_data_sz, test_data->dictionary_file,
+ (double)test_data->dictionary_data_sz/actual_file_sz);
+ else
+ RTE_LOG(INFO, USER1,
+ "%zu bytes read from file %s\n",
+ test_data->dictionary_data_sz, test_data->dictionary_file);
+
+ ret = 0;
+
+end:
+ if (f)
+ fclose(f);
+
+ return ret;
+}
+
static void
comp_perf_cleanup_on_signal(int signalNumber __rte_unused)
{
@@ -407,6 +487,13 @@ main(int argc, char **argv)
}
test_data->cleanup = ST_INPUT_DATA;
+ if (comp_perf_dump_dictionary_data(test_data) < 0) {
+ ret = EXIT_FAILURE;
+ goto end;
+ }
+
+ test_data->cleanup = ST_DICTIONARY_DATA;
+
if (test_data->level_lst.inc != 0)
test_data->level = test_data->level_lst.min;
@@ -496,6 +583,9 @@ main(int argc, char **argv)
i++;
}
/* fallthrough */
+ case ST_DICTIONARY_DATA:
+ rte_free(test_data->dictionary_data);
+ /* fallthrough */
case ST_INPUT_DATA:
rte_free(test_data->input_data);
/* fallthrough */
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] app/compress-perf: support for dictionaries and PDCP checksum
2025-09-19 18:48 [PATCH 1/3] compressdev: " Sameer Vaze
@ 2025-09-19 18:48 ` Sameer Vaze
0 siblings, 0 replies; 5+ messages in thread
From: Sameer Vaze @ 2025-09-19 18:48 UTC (permalink / raw)
Cc: dev, Sameer Vaze
Adds support to read and apply dictionaries
Signed-off-by: Sameer Vaze <svaze@qti.qualcomm.com>
---
app/test-compress-perf/comp_perf_options.h | 4 +
.../comp_perf_options_parse.c | 16 ++++
.../comp_perf_test_verify.c | 37 +++++++-
app/test-compress-perf/main.c | 90 +++++++++++++++++++
4 files changed, 144 insertions(+), 3 deletions(-)
diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h
index 828a7309d8..4c34dcd8aa 100644
--- a/app/test-compress-perf/comp_perf_options.h
+++ b/app/test-compress-perf/comp_perf_options.h
@@ -21,6 +21,7 @@ enum cleanup_st {
ST_TEST_DATA,
ST_COMPDEV,
ST_INPUT_DATA,
+ ST_DICTIONARY_DATA,
ST_MEMORY_ALLOC,
ST_DURING_TEST
};
@@ -48,10 +49,13 @@ struct range_list {
struct comp_test_data {
char driver_name[RTE_DEV_NAME_MAX_LEN];
char input_file[PATH_MAX];
+ char dictionary_file[PATH_MAX];
enum cperf_test_type test;
uint8_t *input_data;
size_t input_data_sz;
+ uint8_t *dictionary_data;
+ size_t dictionary_data_sz;
uint16_t nb_qps;
uint16_t seg_sz;
uint16_t out_seg_sz;
diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c
index 6d8c370fc2..37205ad806 100644
--- a/app/test-compress-perf/comp_perf_options_parse.c
+++ b/app/test-compress-perf/comp_perf_options_parse.c
@@ -31,6 +31,7 @@
#define CPERF_LEVEL ("compress-level")
#define CPERF_WINDOW_SIZE ("window-sz")
#define CPERF_EXTERNAL_MBUFS ("external-mbufs")
+#define CPERF_DICTIONARY ("dictionary")
/* cyclecount-specific options */
#define CPERF_CYCLECOUNT_DELAY_US ("cc-delay-us")
@@ -71,6 +72,7 @@ usage(char *progname)
" keeping the data directly in mbuf area\n"
" --cc-delay-us N: delay between enqueue and dequeue operations in microseconds\n"
" valid only for cyclecount perf test (default: 500 us)\n"
+ " --dictionary NAME: file with dictionary\n"
" -h: prints this help\n",
progname);
}
@@ -609,6 +611,18 @@ parse_external_mbufs(struct comp_test_data *test_data,
return 0;
}
+static int
+parse_dictionary_file(struct comp_test_data *test_data, const char *arg)
+{
+ if (strlen(arg) > (sizeof(test_data->dictionary_file) - 1))
+ return -1;
+
+ strlcpy(test_data->dictionary_file, arg, sizeof(test_data->dictionary_file));
+
+ return 0;
+}
+
+
static int
parse_cyclecount_delay_us(struct comp_test_data *test_data,
const char *arg)
@@ -647,6 +661,7 @@ static struct option lgopts[] = {
{ CPERF_LEVEL, required_argument, 0, 0 },
{ CPERF_WINDOW_SIZE, required_argument, 0, 0 },
{ CPERF_EXTERNAL_MBUFS, 0, 0, 0 },
+ { CPERF_DICTIONARY, required_argument, 0, 0 },
{ CPERF_CYCLECOUNT_DELAY_US, required_argument, 0, 0 },
{ NULL, 0, 0, 0 }
};
@@ -671,6 +686,7 @@ comp_perf_opts_parse_long(int opt_idx, struct comp_test_data *test_data)
{ CPERF_LEVEL, parse_level },
{ CPERF_WINDOW_SIZE, parse_window_sz },
{ CPERF_EXTERNAL_MBUFS, parse_external_mbufs },
+ { CPERF_DICTIONARY, parse_dictionary_file },
{ CPERF_CYCLECOUNT_DELAY_US, parse_cyclecount_delay_us },
};
unsigned int i;
diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c
index 09d97c5cf7..f1d02afa6e 100644
--- a/app/test-compress-perf/comp_perf_test_verify.c
+++ b/app/test-compress-perf/comp_perf_test_verify.c
@@ -64,6 +64,7 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
int res = 0;
int allocated = 0;
uint32_t out_seg_sz;
+ uint8_t dict[DEFLATE_MAX_WINDOW_SIZE] = {0};
if (test_data == NULL || !test_data->burst_sz) {
RTE_LOG(ERR, USER1,
@@ -71,6 +72,22 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
return -1;
}
+ uint16_t window_size = (1ULL << test_data->window_sz);
+
+ if (test_data->dictionary_data) {
+ if (test_data->dictionary_data_sz >= window_size) {
+ memcpy(dict,
+ test_data->dictionary_data
+ + (test_data->dictionary_data_sz - window_size),
+ window_size);
+ } else if (test_data->dictionary_data_sz < window_size) {
+ memcpy(dict + (window_size - test_data->dictionary_data_sz),
+ test_data->dictionary_data,
+ test_data->dictionary_data_sz);
+ }
+ }
+
+
ops = rte_zmalloc_socket(NULL,
2 * mem->total_bufs * sizeof(struct rte_comp_op *),
0, rte_socket_id());
@@ -91,7 +108,9 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
.level = test_data->level,
.window_size = test_data->window_sz,
.chksum = RTE_COMP_CHECKSUM_NONE,
- .hash_algo = RTE_COMP_HASH_ALGO_NONE
+ .hash_algo = RTE_COMP_HASH_ALGO_NONE,
+ .dictionary = dict,
+ .dictionary_len = window_size
}
};
if (test_data->test_algo == RTE_COMP_ALGO_DEFLATE)
@@ -110,7 +129,9 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
.algo = test_data->test_algo,
.chksum = RTE_COMP_CHECKSUM_NONE,
.window_size = test_data->window_sz,
- .hash_algo = RTE_COMP_HASH_ALGO_NONE
+ .hash_algo = RTE_COMP_HASH_ALGO_NONE,
+ .dictionary = dict,
+ .dictionary_len = window_size
}
};
if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
@@ -194,7 +215,17 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
rte_pktmbuf_pkt_len(input_bufs[buf_id]);
ops[op_id]->dst.offset = 0;
ops[op_id]->flush_flag = RTE_COMP_FLUSH_FINAL;
- ops[op_id]->input_chksum = buf_id;
+ if ((xform.type == RTE_COMP_DECOMPRESS) &&
+ (xform.decompress.chksum
+ == RTE_COMP_CHECKSUM_3GPP_PDCP_UDC)) {
+ uint8_t *udc_header
+ = rte_pktmbuf_mtod(ops[op_id]->m_src, uint8_t *);
+ ops[op_id]->input_chksum = *udc_header & 0xf;
+ ops[op_id]->src.offset = 1;
+ } else {
+ ops[op_id]->input_chksum = buf_id;
+ ops[op_id]->src.offset = 0;
+ }
ops[op_id]->private_xform = priv_xform;
}
diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index 70ce4316cc..693a7cc31b 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -335,6 +335,86 @@ comp_perf_dump_input_data(struct comp_test_data *test_data)
return ret;
}
+static int
+comp_perf_dump_dictionary_data(struct comp_test_data *test_data)
+{
+ FILE *f = fopen(test_data->dictionary_file, "r");
+ int ret = -1;
+
+ if (f == NULL) {
+ RTE_LOG(ERR, USER1, "Dictionary file not specified\n");
+ test_data->dictionary_data_sz = 0;
+ test_data->dictionary_data = NULL;
+ ret = 0;
+ goto end;
+ }
+
+ if (fseek(f, 0, SEEK_END) != 0) {
+ RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
+ goto end;
+ }
+ size_t actual_file_sz = ftell(f);
+ /* If extended input data size has not been set,
+ * input data size = file size
+ */
+
+ if (test_data->dictionary_data_sz == 0)
+ test_data->dictionary_data_sz = actual_file_sz;
+
+ if (test_data->dictionary_data_sz <= 0 || actual_file_sz <= 0 ||
+ fseek(f, 0, SEEK_SET) != 0) {
+ RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
+ goto end;
+ }
+
+ test_data->dictionary_data = rte_zmalloc_socket(NULL,
+ test_data->dictionary_data_sz, 0, rte_socket_id());
+
+ if (test_data->dictionary_data == NULL) {
+ RTE_LOG(ERR, USER1, "Memory to hold the data from the dictionary "
+ "file could not be allocated\n");
+ goto end;
+ }
+
+ size_t remaining_data = test_data->dictionary_data_sz;
+ uint8_t *data = test_data->dictionary_data;
+
+ while (remaining_data > 0) {
+ size_t data_to_read = RTE_MIN(remaining_data, actual_file_sz);
+
+ if (fread(data, data_to_read, 1, f) != 1) {
+ RTE_LOG(ERR, USER1, "Input file could not be read\n");
+ goto end;
+ }
+ if (fseek(f, 0, SEEK_SET) != 0) {
+ RTE_LOG(ERR, USER1,
+ "Size of input could not be calculated\n");
+ goto end;
+ }
+ remaining_data -= data_to_read;
+ data += data_to_read;
+ }
+
+ printf("\n");
+ if (test_data->dictionary_data_sz > actual_file_sz)
+ RTE_LOG(INFO, USER1,
+ "%zu bytes read from file %s, extending the file %.2f times\n",
+ test_data->dictionary_data_sz, test_data->dictionary_file,
+ (double)test_data->dictionary_data_sz/actual_file_sz);
+ else
+ RTE_LOG(INFO, USER1,
+ "%zu bytes read from file %s\n",
+ test_data->dictionary_data_sz, test_data->dictionary_file);
+
+ ret = 0;
+
+end:
+ if (f)
+ fclose(f);
+
+ return ret;
+}
+
static void
comp_perf_cleanup_on_signal(int signalNumber __rte_unused)
{
@@ -407,6 +487,13 @@ main(int argc, char **argv)
}
test_data->cleanup = ST_INPUT_DATA;
+ if (comp_perf_dump_dictionary_data(test_data) < 0) {
+ ret = EXIT_FAILURE;
+ goto end;
+ }
+
+ test_data->cleanup = ST_DICTIONARY_DATA;
+
if (test_data->level_lst.inc != 0)
test_data->level = test_data->level_lst.min;
@@ -496,6 +583,9 @@ main(int argc, char **argv)
i++;
}
/* fallthrough */
+ case ST_DICTIONARY_DATA:
+ rte_free(test_data->dictionary_data);
+ /* fallthrough */
case ST_INPUT_DATA:
rte_free(test_data->input_data);
/* fallthrough */
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] app/compress-perf: support for dictionaries and PDCP checksum
2025-09-19 17:28 [PATCH 3/3] app/compres-perf: " Sameer Vaze
@ 2025-09-19 17:30 ` Sameer Vaze
0 siblings, 0 replies; 5+ messages in thread
From: Sameer Vaze @ 2025-09-19 17:30 UTC (permalink / raw)
Cc: dev, Sameer Vaze
Adds support to read and apply dictionaries.
Signed-off-by: Sameer Vaze <svaze@qti.qualcomm.com>
---
app/test-compress-perf/comp_perf_options.h | 4 +
.../comp_perf_options_parse.c | 16 ++++
.../comp_perf_test_verify.c | 37 +++++++-
app/test-compress-perf/main.c | 90 +++++++++++++++++++
4 files changed, 144 insertions(+), 3 deletions(-)
diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h
index 828a7309d8..4c34dcd8aa 100644
--- a/app/test-compress-perf/comp_perf_options.h
+++ b/app/test-compress-perf/comp_perf_options.h
@@ -21,6 +21,7 @@ enum cleanup_st {
ST_TEST_DATA,
ST_COMPDEV,
ST_INPUT_DATA,
+ ST_DICTIONARY_DATA,
ST_MEMORY_ALLOC,
ST_DURING_TEST
};
@@ -48,10 +49,13 @@ struct range_list {
struct comp_test_data {
char driver_name[RTE_DEV_NAME_MAX_LEN];
char input_file[PATH_MAX];
+ char dictionary_file[PATH_MAX];
enum cperf_test_type test;
uint8_t *input_data;
size_t input_data_sz;
+ uint8_t *dictionary_data;
+ size_t dictionary_data_sz;
uint16_t nb_qps;
uint16_t seg_sz;
uint16_t out_seg_sz;
diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c
index 6d8c370fc2..37205ad806 100644
--- a/app/test-compress-perf/comp_perf_options_parse.c
+++ b/app/test-compress-perf/comp_perf_options_parse.c
@@ -31,6 +31,7 @@
#define CPERF_LEVEL ("compress-level")
#define CPERF_WINDOW_SIZE ("window-sz")
#define CPERF_EXTERNAL_MBUFS ("external-mbufs")
+#define CPERF_DICTIONARY ("dictionary")
/* cyclecount-specific options */
#define CPERF_CYCLECOUNT_DELAY_US ("cc-delay-us")
@@ -71,6 +72,7 @@ usage(char *progname)
" keeping the data directly in mbuf area\n"
" --cc-delay-us N: delay between enqueue and dequeue operations in microseconds\n"
" valid only for cyclecount perf test (default: 500 us)\n"
+ " --dictionary NAME: file with dictionary\n"
" -h: prints this help\n",
progname);
}
@@ -609,6 +611,18 @@ parse_external_mbufs(struct comp_test_data *test_data,
return 0;
}
+static int
+parse_dictionary_file(struct comp_test_data *test_data, const char *arg)
+{
+ if (strlen(arg) > (sizeof(test_data->dictionary_file) - 1))
+ return -1;
+
+ strlcpy(test_data->dictionary_file, arg, sizeof(test_data->dictionary_file));
+
+ return 0;
+}
+
+
static int
parse_cyclecount_delay_us(struct comp_test_data *test_data,
const char *arg)
@@ -647,6 +661,7 @@ static struct option lgopts[] = {
{ CPERF_LEVEL, required_argument, 0, 0 },
{ CPERF_WINDOW_SIZE, required_argument, 0, 0 },
{ CPERF_EXTERNAL_MBUFS, 0, 0, 0 },
+ { CPERF_DICTIONARY, required_argument, 0, 0 },
{ CPERF_CYCLECOUNT_DELAY_US, required_argument, 0, 0 },
{ NULL, 0, 0, 0 }
};
@@ -671,6 +686,7 @@ comp_perf_opts_parse_long(int opt_idx, struct comp_test_data *test_data)
{ CPERF_LEVEL, parse_level },
{ CPERF_WINDOW_SIZE, parse_window_sz },
{ CPERF_EXTERNAL_MBUFS, parse_external_mbufs },
+ { CPERF_DICTIONARY, parse_dictionary_file },
{ CPERF_CYCLECOUNT_DELAY_US, parse_cyclecount_delay_us },
};
unsigned int i;
diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c
index 09d97c5cf7..f1d02afa6e 100644
--- a/app/test-compress-perf/comp_perf_test_verify.c
+++ b/app/test-compress-perf/comp_perf_test_verify.c
@@ -64,6 +64,7 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
int res = 0;
int allocated = 0;
uint32_t out_seg_sz;
+ uint8_t dict[DEFLATE_MAX_WINDOW_SIZE] = {0};
if (test_data == NULL || !test_data->burst_sz) {
RTE_LOG(ERR, USER1,
@@ -71,6 +72,22 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
return -1;
}
+ uint16_t window_size = (1ULL << test_data->window_sz);
+
+ if (test_data->dictionary_data) {
+ if (test_data->dictionary_data_sz >= window_size) {
+ memcpy(dict,
+ test_data->dictionary_data
+ + (test_data->dictionary_data_sz - window_size),
+ window_size);
+ } else if (test_data->dictionary_data_sz < window_size) {
+ memcpy(dict + (window_size - test_data->dictionary_data_sz),
+ test_data->dictionary_data,
+ test_data->dictionary_data_sz);
+ }
+ }
+
+
ops = rte_zmalloc_socket(NULL,
2 * mem->total_bufs * sizeof(struct rte_comp_op *),
0, rte_socket_id());
@@ -91,7 +108,9 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
.level = test_data->level,
.window_size = test_data->window_sz,
.chksum = RTE_COMP_CHECKSUM_NONE,
- .hash_algo = RTE_COMP_HASH_ALGO_NONE
+ .hash_algo = RTE_COMP_HASH_ALGO_NONE,
+ .dictionary = dict,
+ .dictionary_len = window_size
}
};
if (test_data->test_algo == RTE_COMP_ALGO_DEFLATE)
@@ -110,7 +129,9 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
.algo = test_data->test_algo,
.chksum = RTE_COMP_CHECKSUM_NONE,
.window_size = test_data->window_sz,
- .hash_algo = RTE_COMP_HASH_ALGO_NONE
+ .hash_algo = RTE_COMP_HASH_ALGO_NONE,
+ .dictionary = dict,
+ .dictionary_len = window_size
}
};
if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
@@ -194,7 +215,17 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
rte_pktmbuf_pkt_len(input_bufs[buf_id]);
ops[op_id]->dst.offset = 0;
ops[op_id]->flush_flag = RTE_COMP_FLUSH_FINAL;
- ops[op_id]->input_chksum = buf_id;
+ if ((xform.type == RTE_COMP_DECOMPRESS) &&
+ (xform.decompress.chksum
+ == RTE_COMP_CHECKSUM_3GPP_PDCP_UDC)) {
+ uint8_t *udc_header
+ = rte_pktmbuf_mtod(ops[op_id]->m_src, uint8_t *);
+ ops[op_id]->input_chksum = *udc_header & 0xf;
+ ops[op_id]->src.offset = 1;
+ } else {
+ ops[op_id]->input_chksum = buf_id;
+ ops[op_id]->src.offset = 0;
+ }
ops[op_id]->private_xform = priv_xform;
}
diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index 70ce4316cc..693a7cc31b 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -335,6 +335,86 @@ comp_perf_dump_input_data(struct comp_test_data *test_data)
return ret;
}
+static int
+comp_perf_dump_dictionary_data(struct comp_test_data *test_data)
+{
+ FILE *f = fopen(test_data->dictionary_file, "r");
+ int ret = -1;
+
+ if (f == NULL) {
+ RTE_LOG(ERR, USER1, "Dictionary file not specified\n");
+ test_data->dictionary_data_sz = 0;
+ test_data->dictionary_data = NULL;
+ ret = 0;
+ goto end;
+ }
+
+ if (fseek(f, 0, SEEK_END) != 0) {
+ RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
+ goto end;
+ }
+ size_t actual_file_sz = ftell(f);
+ /* If extended input data size has not been set,
+ * input data size = file size
+ */
+
+ if (test_data->dictionary_data_sz == 0)
+ test_data->dictionary_data_sz = actual_file_sz;
+
+ if (test_data->dictionary_data_sz <= 0 || actual_file_sz <= 0 ||
+ fseek(f, 0, SEEK_SET) != 0) {
+ RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
+ goto end;
+ }
+
+ test_data->dictionary_data = rte_zmalloc_socket(NULL,
+ test_data->dictionary_data_sz, 0, rte_socket_id());
+
+ if (test_data->dictionary_data == NULL) {
+ RTE_LOG(ERR, USER1, "Memory to hold the data from the dictionary "
+ "file could not be allocated\n");
+ goto end;
+ }
+
+ size_t remaining_data = test_data->dictionary_data_sz;
+ uint8_t *data = test_data->dictionary_data;
+
+ while (remaining_data > 0) {
+ size_t data_to_read = RTE_MIN(remaining_data, actual_file_sz);
+
+ if (fread(data, data_to_read, 1, f) != 1) {
+ RTE_LOG(ERR, USER1, "Input file could not be read\n");
+ goto end;
+ }
+ if (fseek(f, 0, SEEK_SET) != 0) {
+ RTE_LOG(ERR, USER1,
+ "Size of input could not be calculated\n");
+ goto end;
+ }
+ remaining_data -= data_to_read;
+ data += data_to_read;
+ }
+
+ printf("\n");
+ if (test_data->dictionary_data_sz > actual_file_sz)
+ RTE_LOG(INFO, USER1,
+ "%zu bytes read from file %s, extending the file %.2f times\n",
+ test_data->dictionary_data_sz, test_data->dictionary_file,
+ (double)test_data->dictionary_data_sz/actual_file_sz);
+ else
+ RTE_LOG(INFO, USER1,
+ "%zu bytes read from file %s\n",
+ test_data->dictionary_data_sz, test_data->dictionary_file);
+
+ ret = 0;
+
+end:
+ if (f)
+ fclose(f);
+
+ return ret;
+}
+
static void
comp_perf_cleanup_on_signal(int signalNumber __rte_unused)
{
@@ -407,6 +487,13 @@ main(int argc, char **argv)
}
test_data->cleanup = ST_INPUT_DATA;
+ if (comp_perf_dump_dictionary_data(test_data) < 0) {
+ ret = EXIT_FAILURE;
+ goto end;
+ }
+
+ test_data->cleanup = ST_DICTIONARY_DATA;
+
if (test_data->level_lst.inc != 0)
test_data->level = test_data->level_lst.min;
@@ -496,6 +583,9 @@ main(int argc, char **argv)
i++;
}
/* fallthrough */
+ case ST_DICTIONARY_DATA:
+ rte_free(test_data->dictionary_data);
+ /* fallthrough */
case ST_INPUT_DATA:
rte_free(test_data->input_data);
/* fallthrough */
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-19 18:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-19 17:34 [PATCH 1/3] compressdev: support for dictionaries and PDCP checksum Sameer Vaze
2025-09-19 17:34 ` [PATCH 2/3] compress/zlib: " Sameer Vaze
2025-09-19 17:34 ` [PATCH 3/3] app/compress-perf: " Sameer Vaze
-- strict thread matches above, loose matches on Subject: below --
2025-09-19 18:48 [PATCH 1/3] compressdev: " Sameer Vaze
2025-09-19 18:48 ` [PATCH 3/3] app/compress-perf: " Sameer Vaze
2025-09-19 17:28 [PATCH 3/3] app/compres-perf: " Sameer Vaze
2025-09-19 17:30 ` [PATCH 3/3] app/compress-perf: " Sameer Vaze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).