MCPcopy Create free account
hub / github.com/F-Stack/f-stack / compress_zlib

Function compress_zlib

dpdk/app/test/test_compressdev.c:422–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422static int
423compress_zlib(struct rte_comp_op *op,
424 const struct rte_comp_xform *xform, int mem_level)
425{
426 z_stream stream;
427 int zlib_flush;
428 int strategy, window_bits, comp_level;
429 int ret = TEST_FAILED;
430 uint8_t *single_src_buf = NULL;
431 uint8_t *single_dst_buf = NULL;
432
433 /* initialize zlib stream */
434 stream.zalloc = Z_NULL;
435 stream.zfree = Z_NULL;
436 stream.opaque = Z_NULL;
437
438 if (xform->compress.deflate.huffman == RTE_COMP_HUFFMAN_FIXED)
439 strategy = Z_FIXED;
440 else
441 strategy = Z_DEFAULT_STRATEGY;
442
443 /*
444 * Window bits is the base two logarithm of the window size (in bytes).
445 * When doing raw DEFLATE, this number will be negative.
446 */
447 window_bits = -(xform->compress.window_size);
448 if (xform->compress.chksum == RTE_COMP_CHECKSUM_ADLER32)
449 window_bits *= -1;
450 else if (xform->compress.chksum == RTE_COMP_CHECKSUM_CRC32)
451 window_bits = ZLIB_CRC_CHECKSUM_WINDOW_BITS;
452
453 comp_level = xform->compress.level;
454
455 if (comp_level != RTE_COMP_LEVEL_NONE)
456 ret = deflateInit2(&stream, comp_level, Z_DEFLATED,
457 window_bits, mem_level, strategy);
458 else
459 ret = deflateInit(&stream, Z_NO_COMPRESSION);
460
461 if (ret != Z_OK) {
462 printf("Zlib deflate could not be initialized\n");
463 goto exit;
464 }
465
466 /* Assuming stateless operation */
467 /* SGL Input */
468 if (op->m_src->nb_segs > 1) {
469 single_src_buf = rte_malloc(NULL,
470 rte_pktmbuf_pkt_len(op->m_src), 0);
471 if (single_src_buf == NULL) {
472 RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
473 goto exit;
474 }
475
476 if (rte_pktmbuf_read(op->m_src, op->src.offset,
477 rte_pktmbuf_pkt_len(op->m_src) -
478 op->src.offset,
479 single_src_buf) == NULL) {

Callers 1

test_deflate_comp_runFunction · 0.85

Calls 11

rte_mallocFunction · 0.85
rte_pktmbuf_readFunction · 0.85
map_zlib_flush_flagFunction · 0.85
deflateFunction · 0.85
rte_pktmbuf_adjFunction · 0.85
rte_pktmbuf_trimFunction · 0.85
deflateResetFunction · 0.85
deflateEndFunction · 0.85
rte_freeFunction · 0.85
printfFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected