* [dpdk-dev] [PATCH] test/compress: add offset tests
@ 2018-07-24 14:06 Lee Daly
2018-07-31 15:01 ` Thomas Monjalon
2018-11-27 10:30 ` [dpdk-dev] [PATCH v2] test/compress: add mbuf offset unit test Lee Daly
0 siblings, 2 replies; 10+ messages in thread
From: Lee Daly @ 2018-07-24 14:06 UTC (permalink / raw)
To: pablo.de.lara.guarch; +Cc: fiona.trahe, dev, Daly, Lee
From: "Daly, Lee" <lee.daly@intel.com>
Added offset test, which tests compression/decompression with a buffer
containing an offset spanning across multiple segments.
Signed-off-by: Lee Daly <lee.daly@intel.com>
---
test/test/test_compressdev.c | 233 +++++++++++++++++++++++++++++++++++--------
1 file changed, 189 insertions(+), 44 deletions(-)
diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c
index 8645388..a5f962f 100644
--- a/test/test/test_compressdev.c
+++ b/test/test/test_compressdev.c
@@ -34,6 +34,7 @@
#define NUM_MAX_XFORMS 16
#define NUM_MAX_INFLIGHT_OPS 128
#define CACHE_SIZE 0
+#define OFFSET 800
const char *
huffman_type_strings[] = {
@@ -346,8 +347,9 @@ compress_zlib(struct rte_comp_op *op,
RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
goto exit;
}
- if (rte_pktmbuf_read(op->m_src, 0,
- rte_pktmbuf_pkt_len(op->m_src),
+ if (rte_pktmbuf_read(op->m_src, op->src.offset,
+ rte_pktmbuf_pkt_len(op->m_src) -
+ op->src.offset,
single_src_buf) == NULL) {
RTE_LOG(ERR, USER1,
"Buffer could not be read entirely\n");
@@ -361,9 +363,11 @@ compress_zlib(struct rte_comp_op *op,
} else {
stream.avail_in = op->src.length;
- stream.next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
+ stream.next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *,
+ op->src.offset);
stream.avail_out = op->m_dst->data_len;
- stream.next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
+ stream.next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *,
+ op->dst.offset);
}
/* Stateless operation, all buffer will be compressed in one go */
zlib_flush = map_zlib_flush_flag(op->flush_flag);
@@ -383,9 +387,26 @@ compress_zlib(struct rte_comp_op *op,
uint8_t *src_data = single_dst_buf;
struct rte_mbuf *dst_buf = op->m_dst;
+ uint32_t remaining_offset = op->dst.offset;
+ while (remaining_offset >= dst_buf->data_len) {
+ remaining_offset -= dst_buf->data_len;
+ dst_buf = dst_buf->next;
+ }
+
+ /* First Segment */
+ uint8_t *dst_data = rte_pktmbuf_mtod_offset(dst_buf, uint8_t *,
+ op->dst.offset % dst_buf->data_len);
+ memcpy(dst_data, src_data, dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len));
+ remaining_data -= dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ src_data += dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ dst_buf = dst_buf->next;
+
+
while (remaining_data > 0) {
- uint8_t *dst_data = rte_pktmbuf_mtod(dst_buf,
- uint8_t *);
+ dst_data = rte_pktmbuf_mtod(dst_buf, uint8_t *);
/* Last segment */
if (remaining_data < dst_buf->data_len) {
memcpy(dst_data, src_data, remaining_data);
@@ -414,6 +435,7 @@ compress_zlib(struct rte_comp_op *op,
return ret;
}
+
static int
decompress_zlib(struct rte_comp_op *op,
const struct rte_comp_xform *xform)
@@ -458,8 +480,9 @@ decompress_zlib(struct rte_comp_op *op,
RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
goto exit;
}
- if (rte_pktmbuf_read(op->m_src, 0,
- rte_pktmbuf_pkt_len(op->m_src),
+ if (rte_pktmbuf_read(op->m_src, op->src.offset,
+ rte_pktmbuf_pkt_len(op->m_src) -
+ op->src.offset,
single_src_buf) == NULL) {
RTE_LOG(ERR, USER1,
"Buffer could not be read entirely\n");
@@ -473,9 +496,11 @@ decompress_zlib(struct rte_comp_op *op,
} else {
stream.avail_in = op->src.length;
- stream.next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
+ stream.next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *,
+ op->src.offset);
stream.avail_out = op->m_dst->data_len;
- stream.next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
+ stream.next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *,
+ op->dst.offset);
}
/* Stateless operation, all buffer will be compressed in one go */
@@ -495,8 +520,25 @@ decompress_zlib(struct rte_comp_op *op,
uint8_t *src_data = single_dst_buf;
struct rte_mbuf *dst_buf = op->m_dst;
+ uint32_t remaining_offset = op->dst.offset;
+ while (remaining_offset >= dst_buf->data_len) {
+ remaining_offset -= dst_buf->data_len;
+ dst_buf = dst_buf->next;
+ }
+
+ uint8_t *dst_data = rte_pktmbuf_mtod_offset(dst_buf, uint8_t *,
+ op->dst.offset % dst_buf->data_len);
+ memcpy(dst_data, src_data, dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len));
+ remaining_data -= dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ src_data += dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ dst_buf = dst_buf->next;
+
+
while (remaining_data > 0) {
- uint8_t *dst_data = rte_pktmbuf_mtod(dst_buf,
+ dst_data = rte_pktmbuf_mtod(dst_buf,
uint8_t *);
/* Last segment */
if (remaining_data < dst_buf->data_len) {
@@ -529,10 +571,12 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
uint32_t total_data_size,
struct rte_mempool *small_mbuf_pool,
struct rte_mempool *large_mbuf_pool,
- uint8_t limit_segs_in_sgl)
+ uint8_t limit_segs_in_sgl,
+ uint16_t offset)
{
uint32_t remaining_data = total_data_size;
- uint16_t num_remaining_segs = DIV_CEIL(remaining_data, SMALL_SEG_SIZE);
+ uint16_t num_remaining_segs = DIV_CEIL(remaining_data + offset,
+ SMALL_SEG_SIZE);
struct rte_mempool *pool;
struct rte_mbuf *next_seg;
uint32_t data_size;
@@ -559,12 +603,12 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
return -1;
}
- if (data_ptr != NULL) {
+ if (data_ptr != NULL && offset < data_size) {
/* Copy characters without NULL terminator */
- strncpy(buf_ptr, data_ptr, data_size);
- data_ptr += data_size;
+ strncpy(buf_ptr + offset, data_ptr, data_size - offset);
+ data_ptr += data_size - offset;
+ remaining_data -= data_size - offset;
}
- remaining_data -= data_size;
num_remaining_segs--;
/*
@@ -601,10 +645,21 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
}
if (data_ptr != NULL) {
/* Copy characters without NULL terminator */
- strncpy(buf_ptr, data_ptr, data_size);
- data_ptr += data_size;
+ if (remaining_data == total_data_size) {
+ strncpy(buf_ptr + (offset % SMALL_SEG_SIZE),
+ data_ptr,
+ data_size -
+ (offset % SMALL_SEG_SIZE));
+ data_ptr += data_size -
+ (offset % SMALL_SEG_SIZE);
+ remaining_data -= data_size -
+ (offset % SMALL_SEG_SIZE);
+ } else {
+ strncpy(buf_ptr, data_ptr, data_size);
+ data_ptr += data_size;
+ remaining_data -= data_size;
+ }
}
- remaining_data -= data_size;
ret = rte_pktmbuf_chain(head_buf, next_seg);
if (ret != 0) {
@@ -630,7 +685,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
unsigned int num_xforms,
enum rte_comp_op_type state,
unsigned int sgl,
- enum zlib_direction zlib_dir)
+ enum zlib_direction zlib_dir,
+ uint16_t offset)
{
struct comp_testsuite_params *ts_params = &testsuite_params;
int ret_status = -1;
@@ -681,14 +737,17 @@ test_deflate_comp_decomp(const char * const test_bufs[],
data_size,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ offset) < 0)
goto exit;
}
} else {
for (i = 0; i < num_bufs; i++) {
data_size = strlen(test_bufs[i]) + 1;
- buf_ptr = rte_pktmbuf_append(uncomp_bufs[i], data_size);
- snprintf(buf_ptr, data_size, "%s", test_bufs[i]);
+ buf_ptr = rte_pktmbuf_append(uncomp_bufs[i],
+ data_size + offset);
+ snprintf(buf_ptr + offset, data_size, "%s",
+ test_bufs[i]);
}
}
@@ -709,7 +768,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
data_size,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ 0) < 0)
goto exit;
}
@@ -733,9 +793,9 @@ test_deflate_comp_decomp(const char * const test_bufs[],
for (i = 0; i < num_bufs; i++) {
ops[i]->m_src = uncomp_bufs[i];
ops[i]->m_dst = comp_bufs[i];
- ops[i]->src.offset = 0;
- ops[i]->src.length = rte_pktmbuf_pkt_len(uncomp_bufs[i]);
- ops[i]->dst.offset = 0;
+ ops[i]->src.offset = offset;
+ ops[i]->src.length = strlen(test_bufs[i]) + 1;
+ ops[i]->dst.offset = offset;
if (state == RTE_COMP_OP_STATELESS) {
ops[i]->flush_flag = RTE_COMP_FLUSH_FINAL;
} else {
@@ -898,10 +958,11 @@ test_deflate_comp_decomp(const char * const test_bufs[],
(ops_processed[i] + 1);
data_size = strlen(test_bufs[priv_data->orig_idx]) + 1;
if (prepare_sgl_bufs(NULL, uncomp_bufs[i],
- data_size,
+ data_size + offset,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ 0) < 0)
goto exit;
}
@@ -910,7 +971,7 @@ test_deflate_comp_decomp(const char * const test_bufs[],
priv_data = (struct priv_op_data *)
(ops_processed[i] + 1);
data_size = strlen(test_bufs[priv_data->orig_idx]) + 1;
- rte_pktmbuf_append(uncomp_bufs[i], data_size);
+ rte_pktmbuf_append(uncomp_bufs[i], data_size + offset);
}
}
@@ -927,13 +988,13 @@ test_deflate_comp_decomp(const char * const test_bufs[],
for (i = 0; i < num_bufs; i++) {
ops[i]->m_src = ops_processed[i]->m_dst;
ops[i]->m_dst = uncomp_bufs[i];
- ops[i]->src.offset = 0;
+ ops[i]->src.offset = offset;
/*
* Set the length of the compressed data to the
* number of bytes that were produced in the previous stage
*/
ops[i]->src.length = ops_processed[i]->produced;
- ops[i]->dst.offset = 0;
+ ops[i]->dst.offset = offset;
if (state == RTE_COMP_OP_STATELESS) {
ops[i]->flush_flag = RTE_COMP_FLUSH_FINAL;
} else {
@@ -1094,7 +1155,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
goto exit;
}
- buf2 = rte_pktmbuf_read(ops_processed[i]->m_dst, 0,
+ buf2 = rte_pktmbuf_read(ops_processed[i]->m_dst,
+ ops_processed[0]->dst.offset,
ops_processed[i]->produced, contig_buf);
if (compare_buffers(buf1, strlen(buf1) + 1,
@@ -1164,7 +1226,8 @@ test_compressdev_deflate_stateless_fixed(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1177,7 +1240,8 @@ test_compressdev_deflate_stateless_fixed(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0) {
+ ZLIB_COMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1230,7 +1294,8 @@ test_compressdev_deflate_stateless_dynamic(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1243,7 +1308,8 @@ test_compressdev_deflate_stateless_dynamic(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0) {
+ ZLIB_COMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1275,7 +1341,8 @@ test_compressdev_deflate_stateless_multi_op(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0)
+ ZLIB_DECOMPRESS,
+ 0) < 0)
return TEST_FAILED;
/* Compress with Zlib, decompress with compressdev */
@@ -1286,7 +1353,8 @@ test_compressdev_deflate_stateless_multi_op(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0)
+ ZLIB_COMPRESS,
+ 0) < 0)
return TEST_FAILED;
return TEST_SUCCESS;
@@ -1326,7 +1394,8 @@ test_compressdev_deflate_stateless_multi_level(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1397,7 +1466,8 @@ test_compressdev_deflate_stateless_multi_xform(void)
NUM_XFORMS,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1436,7 +1506,8 @@ test_compressdev_deflate_stateless_sgl(void)
1,
RTE_COMP_OP_STATELESS,
1,
- ZLIB_DECOMPRESS) < 0)
+ ZLIB_COMPRESS,
+ 0) < 0)
return TEST_FAILED;
/* Compress with Zlib, decompress with compressdev */
@@ -1447,7 +1518,79 @@ test_compressdev_deflate_stateless_sgl(void)
1,
RTE_COMP_OP_STATELESS,
1,
- ZLIB_COMPRESS) < 0)
+ ZLIB_DECOMPRESS,
+ 0) < 0)
+ return TEST_FAILED;
+ }
+
+ return TEST_SUCCESS;
+}
+
+static int
+test_compressdev_deflate_stateless_offset(void)
+{
+ struct comp_testsuite_params *ts_params = &testsuite_params;
+ uint16_t i;
+ const char *test_buffer;
+ const struct rte_compressdev_capabilities *capab;
+
+ capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
+ TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
+
+ if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 1) {
+
+ for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+ test_buffer = compress_test_bufs[i];
+ /* Compress with compressdev, decompress with Zlib */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 1,
+ ZLIB_DECOMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+
+ /* Compress with Zlib, decompress with compressdev */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 1,
+ ZLIB_COMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+ }
+ }
+
+ for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+ test_buffer = compress_test_bufs[i];
+ /* Compress with compressdev, decompress with Zlib */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 0,
+ ZLIB_DECOMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+
+ /* Compress with Zlib, decompress with compressdev */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 0,
+ ZLIB_COMPRESS,
+ OFFSET) < 0)
return TEST_FAILED;
}
@@ -1473,6 +1616,8 @@ static struct unit_test_suite compressdev_testsuite = {
test_compressdev_deflate_stateless_multi_xform),
TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
test_compressdev_deflate_stateless_sgl),
+ TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
+ test_compressdev_deflate_stateless_offset),
TEST_CASES_END() /**< NULL terminate unit test array */
}
};
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH] test/compress: add offset tests
2018-07-24 14:06 [dpdk-dev] [PATCH] test/compress: add offset tests Lee Daly
@ 2018-07-31 15:01 ` Thomas Monjalon
2018-07-31 15:05 ` Daly, Lee
2018-11-27 10:30 ` [dpdk-dev] [PATCH v2] test/compress: add mbuf offset unit test Lee Daly
1 sibling, 1 reply; 10+ messages in thread
From: Thomas Monjalon @ 2018-07-31 15:01 UTC (permalink / raw)
To: Lee Daly; +Cc: dev, pablo.de.lara.guarch, fiona.trahe
24/07/2018 16:06, Lee Daly:
> From: "Daly, Lee" <lee.daly@intel.com>
>
> Added offset test, which tests compression/decompression with a buffer
> containing an offset spanning across multiple segments.
>
> Signed-off-by: Lee Daly <lee.daly@intel.com>
There is a compilation error (with GCC 8).
> + if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 1) {
test_compressdev.c:1540:67: error:
bitwise comparison always evaluates to false [-Werror=tautological-compare]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH] test/compress: add offset tests
2018-07-31 15:01 ` Thomas Monjalon
@ 2018-07-31 15:05 ` Daly, Lee
0 siblings, 0 replies; 10+ messages in thread
From: Daly, Lee @ 2018-07-31 15:05 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev, De Lara Guarch, Pablo, Trahe, Fiona
This test will not be up streamed in 18.08.
V2, containing a fix for this error, will be sent for 18.11.
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Tuesday, July 31, 2018 4:02 PM
> To: Daly, Lee <lee.daly@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> Trahe, Fiona <fiona.trahe@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] test/compress: add offset tests
>
> 24/07/2018 16:06, Lee Daly:
> > From: "Daly, Lee" <lee.daly@intel.com>
> >
> > Added offset test, which tests compression/decompression with a buffer
> > containing an offset spanning across multiple segments.
> >
> > Signed-off-by: Lee Daly <lee.daly@intel.com>
>
> There is a compilation error (with GCC 8).
>
> > + if ((capab->comp_feature_flags &
> RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) ==
> > +1) {
>
> test_compressdev.c:1540:67: error:
> bitwise comparison always evaluates to false [-Werror=tautological-
> compare]
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v2] test/compress: add mbuf offset unit test
2018-07-24 14:06 [dpdk-dev] [PATCH] test/compress: add offset tests Lee Daly
2018-07-31 15:01 ` Thomas Monjalon
@ 2018-11-27 10:30 ` Lee Daly
2018-12-05 14:38 ` [dpdk-dev] [PATCH v3] " Lee Daly
1 sibling, 1 reply; 10+ messages in thread
From: Lee Daly @ 2018-11-27 10:30 UTC (permalink / raw)
To: fiona.trahe; +Cc: dev, Lee Daly
added mbuf offset test to compressdev test suite, which tests compression/
decompression with a mbuf containing an offset spanning across mulitple segments
Signed-off-by: Lee Daly <lee.daly@intel.com>
---
test/test/test_compressdev.c | 241 ++++++++++++++++++++++++++++++++++---------
1 file changed, 193 insertions(+), 48 deletions(-)
diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c
index 5d5e519..91dd636 100644
--- a/test/test/test_compressdev.c
+++ b/test/test/test_compressdev.c
@@ -35,6 +35,7 @@
#define NUM_MAX_XFORMS 16
#define NUM_MAX_INFLIGHT_OPS 128
#define CACHE_SIZE 0
+#define OFFSET 800
const char *
huffman_type_strings[] = {
@@ -93,7 +94,7 @@ testsuite_setup(void)
for (i = 0; i < RTE_DIM(compress_test_bufs); i++)
max_buf_size = RTE_MAX(max_buf_size,
- strlen(compress_test_bufs[i]) + 1);
+ (strlen(compress_test_bufs[i]) + OFFSET + 1));
/*
* Buffers to be used in compression and decompression.
@@ -347,8 +348,9 @@ compress_zlib(struct rte_comp_op *op,
RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
goto exit;
}
- if (rte_pktmbuf_read(op->m_src, 0,
- rte_pktmbuf_pkt_len(op->m_src),
+ if (rte_pktmbuf_read(op->m_src, op->src.offset,
+ rte_pktmbuf_pkt_len(op->m_src) -
+ op->src.offset,
single_src_buf) == NULL) {
RTE_LOG(ERR, USER1,
"Buffer could not be read entirely\n");
@@ -362,9 +364,11 @@ compress_zlib(struct rte_comp_op *op,
} else {
stream.avail_in = op->src.length;
- stream.next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
+ stream.next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *,
+ op->src.offset);
stream.avail_out = op->m_dst->data_len;
- stream.next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
+ stream.next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *,
+ op->dst.offset);
}
/* Stateless operation, all buffer will be compressed in one go */
zlib_flush = map_zlib_flush_flag(op->flush_flag);
@@ -384,9 +388,26 @@ compress_zlib(struct rte_comp_op *op,
uint8_t *src_data = single_dst_buf;
struct rte_mbuf *dst_buf = op->m_dst;
+ uint32_t remaining_offset = op->dst.offset;
+ while (remaining_offset >= dst_buf->data_len) {
+ remaining_offset -= dst_buf->data_len;
+ dst_buf = dst_buf->next;
+ }
+
+ /* First Segment */
+ uint8_t *dst_data = rte_pktmbuf_mtod_offset(dst_buf, uint8_t *,
+ op->dst.offset % dst_buf->data_len);
+ memcpy(dst_data, src_data, dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len));
+ remaining_data -= dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ src_data += dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ dst_buf = dst_buf->next;
+
+
while (remaining_data > 0) {
- uint8_t *dst_data = rte_pktmbuf_mtod(dst_buf,
- uint8_t *);
+ dst_data = rte_pktmbuf_mtod(dst_buf, uint8_t *);
/* Last segment */
if (remaining_data < dst_buf->data_len) {
memcpy(dst_data, src_data, remaining_data);
@@ -459,8 +480,9 @@ decompress_zlib(struct rte_comp_op *op,
RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
goto exit;
}
- if (rte_pktmbuf_read(op->m_src, 0,
- rte_pktmbuf_pkt_len(op->m_src),
+ if (rte_pktmbuf_read(op->m_src, op->src.offset,
+ rte_pktmbuf_pkt_len(op->m_src) -
+ op->src.offset,
single_src_buf) == NULL) {
RTE_LOG(ERR, USER1,
"Buffer could not be read entirely\n");
@@ -474,9 +496,11 @@ decompress_zlib(struct rte_comp_op *op,
} else {
stream.avail_in = op->src.length;
- stream.next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
+ stream.next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *,
+ op->src.offset);
stream.avail_out = op->m_dst->data_len;
- stream.next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
+ stream.next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *,
+ op->dst.offset);
}
/* Stateless operation, all buffer will be compressed in one go */
@@ -496,8 +520,25 @@ decompress_zlib(struct rte_comp_op *op,
uint8_t *src_data = single_dst_buf;
struct rte_mbuf *dst_buf = op->m_dst;
+ uint32_t remaining_offset = op->dst.offset;
+ while (remaining_offset >= dst_buf->data_len) {
+ remaining_offset -= dst_buf->data_len;
+ dst_buf = dst_buf->next;
+ }
+
+ uint8_t *dst_data = rte_pktmbuf_mtod_offset(dst_buf, uint8_t *,
+ op->dst.offset % dst_buf->data_len);
+ memcpy(dst_data, src_data, dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len));
+ remaining_data -= dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ src_data += dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ dst_buf = dst_buf->next;
+
+
while (remaining_data > 0) {
- uint8_t *dst_data = rte_pktmbuf_mtod(dst_buf,
+ dst_data = rte_pktmbuf_mtod(dst_buf,
uint8_t *);
/* Last segment */
if (remaining_data < dst_buf->data_len) {
@@ -530,17 +571,19 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
uint32_t total_data_size,
struct rte_mempool *small_mbuf_pool,
struct rte_mempool *large_mbuf_pool,
- uint8_t limit_segs_in_sgl)
+ uint8_t limit_segs_in_sgl,
+ uint16_t offset)
{
uint32_t remaining_data = total_data_size;
- uint16_t num_remaining_segs = DIV_CEIL(remaining_data, SMALL_SEG_SIZE);
+ uint16_t num_remaining_segs = DIV_CEIL(remaining_data + offset,
+ SMALL_SEG_SIZE);
struct rte_mempool *pool;
struct rte_mbuf *next_seg;
uint32_t data_size;
char *buf_ptr;
const char *data_ptr = test_buf;
uint16_t i;
- int ret;
+ int ret, remaining_offset;
if (limit_segs_in_sgl != 0 && num_remaining_segs > limit_segs_in_sgl)
num_remaining_segs = limit_segs_in_sgl - 1;
@@ -560,13 +603,14 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
return -1;
}
- if (data_ptr != NULL) {
+ if (data_ptr != NULL && offset < data_size) {
/* Copy characters without NULL terminator */
- strncpy(buf_ptr, data_ptr, data_size);
- data_ptr += data_size;
+ strncpy(buf_ptr + offset, data_ptr, data_size - offset);
+ data_ptr += data_size - offset;
+ remaining_data -= data_size - offset;
}
- remaining_data -= data_size;
num_remaining_segs--;
+ remaining_offset = offset - data_size;
/*
* Allocate the rest of the segments,
@@ -600,12 +644,21 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
rte_pktmbuf_free(next_seg);
return -1;
}
- if (data_ptr != NULL) {
+ if (data_ptr != NULL && remaining_offset < (int)data_size) {
/* Copy characters without NULL terminator */
- strncpy(buf_ptr, data_ptr, data_size);
- data_ptr += data_size;
+ if (remaining_data == total_data_size) {
+ strncpy(buf_ptr + remaining_offset, data_ptr,
+ data_size - remaining_offset);
+ data_ptr += data_size - remaining_offset;
+ remaining_data -= data_size - remaining_offset;
+ } else {
+ strncpy(buf_ptr, data_ptr, data_size);
+ data_ptr += data_size;
+ remaining_data -= data_size;
+ }
}
- remaining_data -= data_size;
+ if (remaining_data == total_data_size)
+ remaining_offset -= data_size;
ret = rte_pktmbuf_chain(head_buf, next_seg);
if (ret != 0) {
@@ -631,7 +684,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
unsigned int num_xforms,
enum rte_comp_op_type state,
unsigned int sgl,
- enum zlib_direction zlib_dir)
+ enum zlib_direction zlib_dir,
+ uint16_t offset)
{
struct comp_testsuite_params *ts_params = &testsuite_params;
int ret_status = -1;
@@ -682,14 +736,17 @@ test_deflate_comp_decomp(const char * const test_bufs[],
data_size,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ offset) < 0)
goto exit;
}
} else {
for (i = 0; i < num_bufs; i++) {
data_size = strlen(test_bufs[i]) + 1;
- buf_ptr = rte_pktmbuf_append(uncomp_bufs[i], data_size);
- snprintf(buf_ptr, data_size, "%s", test_bufs[i]);
+ buf_ptr = rte_pktmbuf_append(uncomp_bufs[i],
+ data_size + offset);
+ snprintf(buf_ptr + offset, data_size, "%s",
+ test_bufs[i]);
}
}
@@ -710,7 +767,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
data_size,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ offset) < 0)
goto exit;
}
@@ -718,7 +776,7 @@ test_deflate_comp_decomp(const char * const test_bufs[],
for (i = 0; i < num_bufs; i++) {
data_size = strlen(test_bufs[i]) *
COMPRESS_BUF_SIZE_RATIO;
- rte_pktmbuf_append(comp_bufs[i], data_size);
+ rte_pktmbuf_append(comp_bufs[i], data_size + offset);
}
}
@@ -734,9 +792,9 @@ test_deflate_comp_decomp(const char * const test_bufs[],
for (i = 0; i < num_bufs; i++) {
ops[i]->m_src = uncomp_bufs[i];
ops[i]->m_dst = comp_bufs[i];
- ops[i]->src.offset = 0;
- ops[i]->src.length = rte_pktmbuf_pkt_len(uncomp_bufs[i]);
- ops[i]->dst.offset = 0;
+ ops[i]->src.offset = offset;
+ ops[i]->src.length = strlen(test_bufs[i]) + 1;
+ ops[i]->dst.offset = offset;
if (state == RTE_COMP_OP_STATELESS) {
ops[i]->flush_flag = RTE_COMP_FLUSH_FINAL;
} else {
@@ -906,10 +964,11 @@ test_deflate_comp_decomp(const char * const test_bufs[],
(ops_processed[i] + 1);
data_size = strlen(test_bufs[priv_data->orig_idx]) + 1;
if (prepare_sgl_bufs(NULL, uncomp_bufs[i],
- data_size,
+ data_size + offset,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ 0) < 0)
goto exit;
}
@@ -918,7 +977,7 @@ test_deflate_comp_decomp(const char * const test_bufs[],
priv_data = (struct priv_op_data *)
(ops_processed[i] + 1);
data_size = strlen(test_bufs[priv_data->orig_idx]) + 1;
- rte_pktmbuf_append(uncomp_bufs[i], data_size);
+ rte_pktmbuf_append(uncomp_bufs[i], data_size + offset);
}
}
@@ -935,13 +994,13 @@ test_deflate_comp_decomp(const char * const test_bufs[],
for (i = 0; i < num_bufs; i++) {
ops[i]->m_src = ops_processed[i]->m_dst;
ops[i]->m_dst = uncomp_bufs[i];
- ops[i]->src.offset = 0;
+ ops[i]->src.offset = offset;
/*
* Set the length of the compressed data to the
* number of bytes that were produced in the previous stage
*/
ops[i]->src.length = ops_processed[i]->produced;
- ops[i]->dst.offset = 0;
+ ops[i]->dst.offset = offset;
if (state == RTE_COMP_OP_STATELESS) {
ops[i]->flush_flag = RTE_COMP_FLUSH_FINAL;
} else {
@@ -1108,7 +1167,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
goto exit;
}
- buf2 = rte_pktmbuf_read(ops_processed[i]->m_dst, 0,
+ buf2 = rte_pktmbuf_read(ops_processed[i]->m_dst,
+ ops_processed[i]->dst.offset,
ops_processed[i]->produced, contig_buf);
if (compare_buffers(buf1, strlen(buf1) + 1,
@@ -1178,7 +1238,8 @@ test_compressdev_deflate_stateless_fixed(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1191,7 +1252,8 @@ test_compressdev_deflate_stateless_fixed(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0) {
+ ZLIB_COMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1244,7 +1306,8 @@ test_compressdev_deflate_stateless_dynamic(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1257,7 +1320,8 @@ test_compressdev_deflate_stateless_dynamic(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0) {
+ ZLIB_COMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1289,7 +1353,8 @@ test_compressdev_deflate_stateless_multi_op(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0)
+ ZLIB_DECOMPRESS,
+ 0) < 0)
return TEST_FAILED;
/* Compress with Zlib, decompress with compressdev */
@@ -1300,7 +1365,8 @@ test_compressdev_deflate_stateless_multi_op(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0)
+ ZLIB_COMPRESS,
+ 0) < 0)
return TEST_FAILED;
return TEST_SUCCESS;
@@ -1340,7 +1406,8 @@ test_compressdev_deflate_stateless_multi_level(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1411,7 +1478,8 @@ test_compressdev_deflate_stateless_multi_xform(void)
NUM_XFORMS,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1450,7 +1518,8 @@ test_compressdev_deflate_stateless_sgl(void)
1,
RTE_COMP_OP_STATELESS,
1,
- ZLIB_DECOMPRESS) < 0)
+ ZLIB_COMPRESS,
+ 0) < 0)
return TEST_FAILED;
/* Compress with Zlib, decompress with compressdev */
@@ -1461,7 +1530,81 @@ test_compressdev_deflate_stateless_sgl(void)
1,
RTE_COMP_OP_STATELESS,
1,
- ZLIB_COMPRESS) < 0)
+ ZLIB_DECOMPRESS,
+ 0) < 0)
+ return TEST_FAILED;
+ }
+
+ return TEST_SUCCESS;
+}
+
+static int
+test_compressdev_deflate_stateless_offset(void)
+{
+ struct comp_testsuite_params *ts_params = &testsuite_params;
+ uint16_t i;
+ const char *test_buffer;
+ const struct rte_compressdev_capabilities *capab;
+
+ capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
+ TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
+
+ if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT)) {
+
+ /* Test SGL with offset, which spans across multiple segments */
+ for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+ test_buffer = compress_test_bufs[i];
+ /* Compress with compressdev, decompress with Zlib */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 1,
+ ZLIB_DECOMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+
+ /* Compress with Zlib, decompress with compressdev */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 1,
+ ZLIB_COMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+ }
+ }
+
+ /* Test linear buffer with offset */
+ for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+ test_buffer = compress_test_bufs[i];
+ /* Compress with compressdev, decompress with Zlib */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 0,
+ ZLIB_DECOMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+
+ /* Compress with Zlib, decompress with compressdev */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 0,
+ ZLIB_COMPRESS,
+ OFFSET) < 0)
return TEST_FAILED;
}
@@ -1487,6 +1630,8 @@ static struct unit_test_suite compressdev_testsuite = {
test_compressdev_deflate_stateless_multi_xform),
TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
test_compressdev_deflate_stateless_sgl),
+ TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
+ test_compressdev_deflate_stateless_offset),
TEST_CASES_END() /**< NULL terminate unit test array */
}
};
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v3] test/compress: add mbuf offset unit test
2018-11-27 10:30 ` [dpdk-dev] [PATCH v2] test/compress: add mbuf offset unit test Lee Daly
@ 2018-12-05 14:38 ` Lee Daly
2018-12-05 15:18 ` Jozwiak, TomaszX
2019-02-24 22:59 ` Thomas Monjalon
0 siblings, 2 replies; 10+ messages in thread
From: Lee Daly @ 2018-12-05 14:38 UTC (permalink / raw)
To: akhil.goyal, tomaszx.jozwiak, fiona.trahe; +Cc: dev, Lee Daly
added mbuf offset test to compressdev test suite, which tests
compression/decompression with a mbuf containing
an offset spanning across mulitple segments.
V2:
- Change how test checks capalilites structure.
V3:
- Change commit message.
Signed-off-by: Lee Daly <lee.daly@intel.com>
---
test/test/test_compressdev.c | 241 ++++++++++++++++++++++++++++++++++---------
1 file changed, 193 insertions(+), 48 deletions(-)
diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c
index dab3c12..4b98001 100644
--- a/test/test/test_compressdev.c
+++ b/test/test/test_compressdev.c
@@ -35,6 +35,7 @@
#define NUM_MAX_XFORMS 16
#define NUM_MAX_INFLIGHT_OPS 128
#define CACHE_SIZE 0
+#define OFFSET 800
const char *
huffman_type_strings[] = {
@@ -93,7 +94,7 @@ testsuite_setup(void)
for (i = 0; i < RTE_DIM(compress_test_bufs); i++)
max_buf_size = RTE_MAX(max_buf_size,
- strlen(compress_test_bufs[i]) + 1);
+ (strlen(compress_test_bufs[i]) + OFFSET + 1));
/*
* Buffers to be used in compression and decompression.
@@ -347,8 +348,9 @@ compress_zlib(struct rte_comp_op *op,
RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
goto exit;
}
- if (rte_pktmbuf_read(op->m_src, 0,
- rte_pktmbuf_pkt_len(op->m_src),
+ if (rte_pktmbuf_read(op->m_src, op->src.offset,
+ rte_pktmbuf_pkt_len(op->m_src) -
+ op->src.offset,
single_src_buf) == NULL) {
RTE_LOG(ERR, USER1,
"Buffer could not be read entirely\n");
@@ -362,9 +364,11 @@ compress_zlib(struct rte_comp_op *op,
} else {
stream.avail_in = op->src.length;
- stream.next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
+ stream.next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *,
+ op->src.offset);
stream.avail_out = op->m_dst->data_len;
- stream.next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
+ stream.next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *,
+ op->dst.offset);
}
/* Stateless operation, all buffer will be compressed in one go */
zlib_flush = map_zlib_flush_flag(op->flush_flag);
@@ -384,9 +388,26 @@ compress_zlib(struct rte_comp_op *op,
uint8_t *src_data = single_dst_buf;
struct rte_mbuf *dst_buf = op->m_dst;
+ uint32_t remaining_offset = op->dst.offset;
+ while (remaining_offset >= dst_buf->data_len) {
+ remaining_offset -= dst_buf->data_len;
+ dst_buf = dst_buf->next;
+ }
+
+ /* First Segment */
+ uint8_t *dst_data = rte_pktmbuf_mtod_offset(dst_buf, uint8_t *,
+ op->dst.offset % dst_buf->data_len);
+ memcpy(dst_data, src_data, dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len));
+ remaining_data -= dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ src_data += dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ dst_buf = dst_buf->next;
+
+
while (remaining_data > 0) {
- uint8_t *dst_data = rte_pktmbuf_mtod(dst_buf,
- uint8_t *);
+ dst_data = rte_pktmbuf_mtod(dst_buf, uint8_t *);
/* Last segment */
if (remaining_data < dst_buf->data_len) {
memcpy(dst_data, src_data, remaining_data);
@@ -459,8 +480,9 @@ decompress_zlib(struct rte_comp_op *op,
RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
goto exit;
}
- if (rte_pktmbuf_read(op->m_src, 0,
- rte_pktmbuf_pkt_len(op->m_src),
+ if (rte_pktmbuf_read(op->m_src, op->src.offset,
+ rte_pktmbuf_pkt_len(op->m_src) -
+ op->src.offset,
single_src_buf) == NULL) {
RTE_LOG(ERR, USER1,
"Buffer could not be read entirely\n");
@@ -474,9 +496,11 @@ decompress_zlib(struct rte_comp_op *op,
} else {
stream.avail_in = op->src.length;
- stream.next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
+ stream.next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *,
+ op->src.offset);
stream.avail_out = op->m_dst->data_len;
- stream.next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
+ stream.next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *,
+ op->dst.offset);
}
/* Stateless operation, all buffer will be compressed in one go */
@@ -496,8 +520,25 @@ decompress_zlib(struct rte_comp_op *op,
uint8_t *src_data = single_dst_buf;
struct rte_mbuf *dst_buf = op->m_dst;
+ uint32_t remaining_offset = op->dst.offset;
+ while (remaining_offset >= dst_buf->data_len) {
+ remaining_offset -= dst_buf->data_len;
+ dst_buf = dst_buf->next;
+ }
+
+ uint8_t *dst_data = rte_pktmbuf_mtod_offset(dst_buf, uint8_t *,
+ op->dst.offset % dst_buf->data_len);
+ memcpy(dst_data, src_data, dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len));
+ remaining_data -= dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ src_data += dst_buf->data_len -
+ (op->dst.offset % dst_buf->data_len);
+ dst_buf = dst_buf->next;
+
+
while (remaining_data > 0) {
- uint8_t *dst_data = rte_pktmbuf_mtod(dst_buf,
+ dst_data = rte_pktmbuf_mtod(dst_buf,
uint8_t *);
/* Last segment */
if (remaining_data < dst_buf->data_len) {
@@ -530,17 +571,19 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
uint32_t total_data_size,
struct rte_mempool *small_mbuf_pool,
struct rte_mempool *large_mbuf_pool,
- uint8_t limit_segs_in_sgl)
+ uint8_t limit_segs_in_sgl,
+ uint16_t offset)
{
uint32_t remaining_data = total_data_size;
- uint16_t num_remaining_segs = DIV_CEIL(remaining_data, SMALL_SEG_SIZE);
+ uint16_t num_remaining_segs = DIV_CEIL(remaining_data + offset,
+ SMALL_SEG_SIZE);
struct rte_mempool *pool;
struct rte_mbuf *next_seg;
uint32_t data_size;
char *buf_ptr;
const char *data_ptr = test_buf;
uint16_t i;
- int ret;
+ int ret, remaining_offset;
if (limit_segs_in_sgl != 0 && num_remaining_segs > limit_segs_in_sgl)
num_remaining_segs = limit_segs_in_sgl - 1;
@@ -560,13 +603,14 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
return -1;
}
- if (data_ptr != NULL) {
+ if (data_ptr != NULL && offset < data_size) {
/* Copy characters without NULL terminator */
- strncpy(buf_ptr, data_ptr, data_size);
- data_ptr += data_size;
+ strncpy(buf_ptr + offset, data_ptr, data_size - offset);
+ data_ptr += data_size - offset;
+ remaining_data -= data_size - offset;
}
- remaining_data -= data_size;
num_remaining_segs--;
+ remaining_offset = offset - data_size;
/*
* Allocate the rest of the segments,
@@ -600,12 +644,21 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
rte_pktmbuf_free(next_seg);
return -1;
}
- if (data_ptr != NULL) {
+ if (data_ptr != NULL && remaining_offset < (int)data_size) {
/* Copy characters without NULL terminator */
- strncpy(buf_ptr, data_ptr, data_size);
- data_ptr += data_size;
+ if (remaining_data == total_data_size) {
+ strncpy(buf_ptr + remaining_offset, data_ptr,
+ data_size - remaining_offset);
+ data_ptr += data_size - remaining_offset;
+ remaining_data -= data_size - remaining_offset;
+ } else {
+ strncpy(buf_ptr, data_ptr, data_size);
+ data_ptr += data_size;
+ remaining_data -= data_size;
+ }
}
- remaining_data -= data_size;
+ if (remaining_data == total_data_size)
+ remaining_offset -= data_size;
ret = rte_pktmbuf_chain(head_buf, next_seg);
if (ret != 0) {
@@ -631,7 +684,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
unsigned int num_xforms,
enum rte_comp_op_type state,
unsigned int sgl,
- enum zlib_direction zlib_dir)
+ enum zlib_direction zlib_dir,
+ uint16_t offset)
{
struct comp_testsuite_params *ts_params = &testsuite_params;
int ret_status = -1;
@@ -682,14 +736,17 @@ test_deflate_comp_decomp(const char * const test_bufs[],
data_size,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ offset) < 0)
goto exit;
}
} else {
for (i = 0; i < num_bufs; i++) {
data_size = strlen(test_bufs[i]) + 1;
- buf_ptr = rte_pktmbuf_append(uncomp_bufs[i], data_size);
- snprintf(buf_ptr, data_size, "%s", test_bufs[i]);
+ buf_ptr = rte_pktmbuf_append(uncomp_bufs[i],
+ data_size + offset);
+ snprintf(buf_ptr + offset, data_size, "%s",
+ test_bufs[i]);
}
}
@@ -710,7 +767,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
data_size,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ offset) < 0)
goto exit;
}
@@ -718,7 +776,7 @@ test_deflate_comp_decomp(const char * const test_bufs[],
for (i = 0; i < num_bufs; i++) {
data_size = strlen(test_bufs[i]) *
COMPRESS_BUF_SIZE_RATIO;
- rte_pktmbuf_append(comp_bufs[i], data_size);
+ rte_pktmbuf_append(comp_bufs[i], data_size + offset);
}
}
@@ -734,9 +792,9 @@ test_deflate_comp_decomp(const char * const test_bufs[],
for (i = 0; i < num_bufs; i++) {
ops[i]->m_src = uncomp_bufs[i];
ops[i]->m_dst = comp_bufs[i];
- ops[i]->src.offset = 0;
- ops[i]->src.length = rte_pktmbuf_pkt_len(uncomp_bufs[i]);
- ops[i]->dst.offset = 0;
+ ops[i]->src.offset = offset;
+ ops[i]->src.length = strlen(test_bufs[i]) + 1;
+ ops[i]->dst.offset = offset;
if (state == RTE_COMP_OP_STATELESS) {
ops[i]->flush_flag = RTE_COMP_FLUSH_FINAL;
} else {
@@ -904,10 +962,11 @@ test_deflate_comp_decomp(const char * const test_bufs[],
(ops_processed[i] + 1);
data_size = strlen(test_bufs[priv_data->orig_idx]) + 1;
if (prepare_sgl_bufs(NULL, uncomp_bufs[i],
- data_size,
+ data_size + offset,
ts_params->small_mbuf_pool,
ts_params->large_mbuf_pool,
- MAX_SEGS) < 0)
+ MAX_SEGS,
+ 0) < 0)
goto exit;
}
@@ -916,7 +975,7 @@ test_deflate_comp_decomp(const char * const test_bufs[],
priv_data = (struct priv_op_data *)
(ops_processed[i] + 1);
data_size = strlen(test_bufs[priv_data->orig_idx]) + 1;
- rte_pktmbuf_append(uncomp_bufs[i], data_size);
+ rte_pktmbuf_append(uncomp_bufs[i], data_size + offset);
}
}
@@ -933,13 +992,13 @@ test_deflate_comp_decomp(const char * const test_bufs[],
for (i = 0; i < num_bufs; i++) {
ops[i]->m_src = ops_processed[i]->m_dst;
ops[i]->m_dst = uncomp_bufs[i];
- ops[i]->src.offset = 0;
+ ops[i]->src.offset = offset;
/*
* Set the length of the compressed data to the
* number of bytes that were produced in the previous stage
*/
ops[i]->src.length = ops_processed[i]->produced;
- ops[i]->dst.offset = 0;
+ ops[i]->dst.offset = offset;
if (state == RTE_COMP_OP_STATELESS) {
ops[i]->flush_flag = RTE_COMP_FLUSH_FINAL;
} else {
@@ -1104,7 +1163,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
goto exit;
}
- buf2 = rte_pktmbuf_read(ops_processed[i]->m_dst, 0,
+ buf2 = rte_pktmbuf_read(ops_processed[i]->m_dst,
+ ops_processed[i]->dst.offset,
ops_processed[i]->produced, contig_buf);
if (compare_buffers(buf1, strlen(buf1) + 1,
@@ -1174,7 +1234,8 @@ test_compressdev_deflate_stateless_fixed(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1187,7 +1248,8 @@ test_compressdev_deflate_stateless_fixed(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0) {
+ ZLIB_COMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1240,7 +1302,8 @@ test_compressdev_deflate_stateless_dynamic(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1253,7 +1316,8 @@ test_compressdev_deflate_stateless_dynamic(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0) {
+ ZLIB_COMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1285,7 +1349,8 @@ test_compressdev_deflate_stateless_multi_op(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0)
+ ZLIB_DECOMPRESS,
+ 0) < 0)
return TEST_FAILED;
/* Compress with Zlib, decompress with compressdev */
@@ -1296,7 +1361,8 @@ test_compressdev_deflate_stateless_multi_op(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_COMPRESS) < 0)
+ ZLIB_COMPRESS,
+ 0) < 0)
return TEST_FAILED;
return TEST_SUCCESS;
@@ -1336,7 +1402,8 @@ test_compressdev_deflate_stateless_multi_level(void)
1,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1407,7 +1474,8 @@ test_compressdev_deflate_stateless_multi_xform(void)
NUM_XFORMS,
RTE_COMP_OP_STATELESS,
0,
- ZLIB_DECOMPRESS) < 0) {
+ ZLIB_DECOMPRESS,
+ 0) < 0) {
ret = TEST_FAILED;
goto exit;
}
@@ -1446,7 +1514,8 @@ test_compressdev_deflate_stateless_sgl(void)
1,
RTE_COMP_OP_STATELESS,
1,
- ZLIB_DECOMPRESS) < 0)
+ ZLIB_COMPRESS,
+ 0) < 0)
return TEST_FAILED;
/* Compress with Zlib, decompress with compressdev */
@@ -1457,7 +1526,81 @@ test_compressdev_deflate_stateless_sgl(void)
1,
RTE_COMP_OP_STATELESS,
1,
- ZLIB_COMPRESS) < 0)
+ ZLIB_DECOMPRESS,
+ 0) < 0)
+ return TEST_FAILED;
+ }
+
+ return TEST_SUCCESS;
+}
+
+static int
+test_compressdev_deflate_stateless_offset(void)
+{
+ struct comp_testsuite_params *ts_params = &testsuite_params;
+ uint16_t i;
+ const char *test_buffer;
+ const struct rte_compressdev_capabilities *capab;
+
+ capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
+ TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
+
+ if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT)) {
+
+ /* Test SGL with offset, which spans across multiple segments */
+ for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+ test_buffer = compress_test_bufs[i];
+ /* Compress with compressdev, decompress with Zlib */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 1,
+ ZLIB_DECOMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+
+ /* Compress with Zlib, decompress with compressdev */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 1,
+ ZLIB_COMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+ }
+ }
+
+ /* Test linear buffer with offset */
+ for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+ test_buffer = compress_test_bufs[i];
+ /* Compress with compressdev, decompress with Zlib */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 0,
+ ZLIB_DECOMPRESS,
+ OFFSET) < 0)
+ return TEST_FAILED;
+
+ /* Compress with Zlib, decompress with compressdev */
+ if (test_deflate_comp_decomp(&test_buffer, 1,
+ &i,
+ &ts_params->def_comp_xform,
+ &ts_params->def_decomp_xform,
+ 1,
+ RTE_COMP_OP_STATELESS,
+ 0,
+ ZLIB_COMPRESS,
+ OFFSET) < 0)
return TEST_FAILED;
}
@@ -1483,6 +1626,8 @@ static struct unit_test_suite compressdev_testsuite = {
test_compressdev_deflate_stateless_multi_xform),
TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
test_compressdev_deflate_stateless_sgl),
+ TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
+ test_compressdev_deflate_stateless_offset),
TEST_CASES_END() /**< NULL terminate unit test array */
}
};
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v3] test/compress: add mbuf offset unit test
2018-12-05 14:38 ` [dpdk-dev] [PATCH v3] " Lee Daly
@ 2018-12-05 15:18 ` Jozwiak, TomaszX
2019-02-24 22:59 ` Thomas Monjalon
1 sibling, 0 replies; 10+ messages in thread
From: Jozwiak, TomaszX @ 2018-12-05 15:18 UTC (permalink / raw)
To: Daly, Lee, akhil.goyal, Trahe, Fiona; +Cc: dev
> -----Original Message-----
> From: Daly, Lee
> Sent: Wednesday, December 5, 2018 3:39 PM
> To: akhil.goyal@nxp.com; Jozwiak, TomaszX <tomaszx.jozwiak@intel.com>;
> Trahe, Fiona <fiona.trahe@intel.com>
> Cc: dev@dpdk.org; Daly, Lee <lee.daly@intel.com>
> Subject: [PATCH v3] test/compress: add mbuf offset unit test
>
> added mbuf offset test to compressdev test suite, which tests
> compression/decompression with a mbuf containing an offset spanning
> across mulitple segments.
>
> V2:
> - Change how test checks capalilites structure.
>
> V3:
> - Change commit message.
>
> Signed-off-by: Lee Daly <lee.daly@intel.com>
> ---
Acked-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v3] test/compress: add mbuf offset unit test
2018-12-05 14:38 ` [dpdk-dev] [PATCH v3] " Lee Daly
2018-12-05 15:18 ` Jozwiak, TomaszX
@ 2019-02-24 22:59 ` Thomas Monjalon
2019-02-25 8:56 ` Daly, Lee
1 sibling, 1 reply; 10+ messages in thread
From: Thomas Monjalon @ 2019-02-24 22:59 UTC (permalink / raw)
To: Lee Daly; +Cc: dev, akhil.goyal, tomaszx.jozwiak, fiona.trahe
05/12/2018 15:38, Lee Daly:
> added mbuf offset test to compressdev test suite, which tests
> compression/decompression with a mbuf containing
> an offset spanning across mulitple segments.
>
> V2:
> - Change how test checks capalilites structure.
>
> V3:
> - Change commit message.
Better to move the changelog after --- so it is skipped by git.
> Signed-off-by: Lee Daly <lee.daly@intel.com>
Please, could you rebase this patch?
Thanks
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v3] test/compress: add mbuf offset unit test
2019-02-24 22:59 ` Thomas Monjalon
@ 2019-02-25 8:56 ` Daly, Lee
2019-02-25 9:32 ` Thomas Monjalon
0 siblings, 1 reply; 10+ messages in thread
From: Daly, Lee @ 2019-02-25 8:56 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev, akhil.goyal, Jozwiak, TomaszX, Trahe, Fiona
Hi Thomas,
This patch was deferred to a later release,
Patchwork did not reflect this so I have now changed it.
Rgds,
Lee.
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Sunday, February 24, 2019 10:59 PM
> To: Daly, Lee <lee.daly@intel.com>
> Cc: dev@dpdk.org; akhil.goyal@nxp.com; Jozwiak, TomaszX
> <tomaszx.jozwiak@intel.com>; Trahe, Fiona <fiona.trahe@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v3] test/compress: add mbuf offset unit test
>
> 05/12/2018 15:38, Lee Daly:
> > added mbuf offset test to compressdev test suite, which tests
> > compression/decompression with a mbuf containing an offset spanning
> > across mulitple segments.
> >
> > V2:
> > - Change how test checks capalilites structure.
> >
> > V3:
> > - Change commit message.
>
> Better to move the changelog after --- so it is skipped by git.
>
> > Signed-off-by: Lee Daly <lee.daly@intel.com>
>
> Please, could you rebase this patch?
> Thanks
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v3] test/compress: add mbuf offset unit test
2019-02-25 8:56 ` Daly, Lee
@ 2019-02-25 9:32 ` Thomas Monjalon
2019-02-25 9:39 ` Daly, Lee
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Monjalon @ 2019-02-25 9:32 UTC (permalink / raw)
To: Daly, Lee; +Cc: dev, akhil.goyal, Jozwiak, TomaszX, Trahe, Fiona
25/02/2019 09:56, Daly, Lee:
> Hi Thomas,
> This patch was deferred to a later release,
> Patchwork did not reflect this so I have now changed it.
You mean you don't want this patch in DPDK 19.05?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v3] test/compress: add mbuf offset unit test
2019-02-25 9:32 ` Thomas Monjalon
@ 2019-02-25 9:39 ` Daly, Lee
0 siblings, 0 replies; 10+ messages in thread
From: Daly, Lee @ 2019-02-25 9:39 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev, akhil.goyal, Jozwiak, TomaszX, Trahe, Fiona
Not in its current state.
-Fiona: Does the current team plan on sending another version of membuf_offset UT for 19.05?
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Monday, February 25, 2019 9:32 AM
> To: Daly, Lee <lee.daly@intel.com>
> Cc: dev@dpdk.org; akhil.goyal@nxp.com; Jozwiak, TomaszX
> <tomaszx.jozwiak@intel.com>; Trahe, Fiona <fiona.trahe@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v3] test/compress: add mbuf offset unit test
>
> 25/02/2019 09:56, Daly, Lee:
> > Hi Thomas,
> > This patch was deferred to a later release, Patchwork did not reflect
> > this so I have now changed it.
>
> You mean you don't want this patch in DPDK 19.05?
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-02-25 9:39 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24 14:06 [dpdk-dev] [PATCH] test/compress: add offset tests Lee Daly
2018-07-31 15:01 ` Thomas Monjalon
2018-07-31 15:05 ` Daly, Lee
2018-11-27 10:30 ` [dpdk-dev] [PATCH v2] test/compress: add mbuf offset unit test Lee Daly
2018-12-05 14:38 ` [dpdk-dev] [PATCH v3] " Lee Daly
2018-12-05 15:18 ` Jozwiak, TomaszX
2019-02-24 22:59 ` Thomas Monjalon
2019-02-25 8:56 ` Daly, Lee
2019-02-25 9:32 ` Thomas Monjalon
2019-02-25 9:39 ` Daly, Lee
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).