55 struct doca_buf *src_doca_buf;
56 struct doca_buf *dst_doca_buf;
58 uint32_t max_bufs = 2;
59 uint32_t output_crc_checksum = 0;
60 uint32_t output_xxh_checksum = 0;
61 uint32_t expected_output_xxh_checksum = 0;
62 bool has_content_checksum =
false;
64 size_t data_len, written_len;
67 uint64_t max_buf_size;
69 out_file = fopen(
cfg->output_path,
"wr");
70 if (out_file ==
NULL) {
87 goto destroy_resources;
89 if (file_size > max_buf_size) {
90 DOCA_LOG_ERR(
"Invalid file size. Should be smaller then %lu", max_buf_size);
92 goto destroy_resources;
98 goto destroy_resources;
101 dst_buffer = calloc(1, max_buf_size);
102 if (dst_buffer ==
NULL) {
105 goto destroy_resources;
135 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing source buffer: %s",
147 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing destination buffer: %s",
149 goto destroy_src_buf;
152 if (
cfg->is_with_frame) {
156 goto destroy_src_buf;
162 cfg->has_block_checksum,
163 cfg->are_blocks_independent,
166 &output_crc_checksum,
167 &output_xxh_checksum);
170 goto destroy_dst_buf;
173 if (has_content_checksum && (output_xxh_checksum != expected_output_xxh_checksum)) {
174 DOCA_LOG_ERR(
"Decompress task failed: output checksum %x, doesn't match expected=%x",
176 expected_output_xxh_checksum);
178 goto destroy_dst_buf;
184 DOCA_LOG_ERR(
"Unable to get DOCA buffer data length for destination buffer: %s",
186 goto destroy_src_buf;
189 written_len = fwrite(dst_buffer,
sizeof(uint8_t), data_len, out_file);
190 if (written_len != data_len) {
191 DOCA_LOG_ERR(
"Failed to write the DOCA buffer representing destination buffer into a file");
193 goto destroy_dst_buf;
196 DOCA_LOG_INFO(
"File was decompressed successfully and saved in: %s",
cfg->output_path);
197 if (
cfg->output_checksum) {
198 DOCA_LOG_INFO(
"The CRC Checksum is %u", output_crc_checksum);
199 DOCA_LOG_INFO(
"The xxHash Checksum is %u", output_xxh_checksum);
205 DOCA_LOG_ERR(
"Failed to decrease DOCA destination buffer reference count: %s",
212 DOCA_LOG_ERR(
"Failed to decrease DOCA source buffer reference count: %s",
doca_error_t destroy_compress_resources(struct compress_resources *resources)
doca_error_t parse_lz4_frame(struct doca_buf *src_buf, struct compress_cfg *cfg, bool *has_content_checksum, uint32_t *content_checksum)
doca_error_t submit_decompress_lz4_stream_task(struct compress_resources *resources, uint8_t has_block_checksum, uint8_t are_blocks_independent, struct doca_buf *src_buf, struct doca_buf *dst_buf, uint32_t *output_crc_checksum, uint32_t *output_xxh_checksum)
doca_error_t allocate_compress_resources(const char *pci_addr, uint32_t max_bufs, struct compress_resources *resources)
@ COMPRESS_MODE_DECOMPRESS_LZ4_STREAM
DOCA_LOG_REGISTER(DECOMPRESS_LZ4_STREAM)
doca_error_t decompress_lz4_stream(struct compress_cfg *cfg, char *file_data, size_t file_size)
struct rdma_resources resources
static doca_error_t doca_buf_inventory_buf_get_by_addr(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *addr, size_t len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by addr & len argume...
static doca_error_t doca_buf_inventory_buf_get_by_data(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *data, size_t data_len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by data & data_len a...
DOCA_STABLE doca_error_t doca_buf_dec_refcount(struct doca_buf *buf, uint16_t *refcount)
Decrease the object reference count by 1, if 0 reached, return the element back to the inventory.
DOCA_STABLE doca_error_t doca_buf_get_data_len(const struct doca_buf *buf, size_t *data_len)
Get buffer's data length.
DOCA_EXPERIMENTAL doca_error_t doca_compress_cap_task_decompress_lz4_stream_get_max_buf_size(const struct doca_devinfo *devinfo, uint64_t *max_buffer_size)
Get decompress LZ4 stream max size.
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_STABLE struct doca_devinfo * doca_dev_as_devinfo(const struct doca_dev *dev)
Get local device info from device. This should be useful when wanting to query information about devi...
#define DOCA_ERROR_PROPAGATE(r, t)
Save the first encountered doca_error_t.
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
@ DOCA_ERROR_OPERATING_SYSTEM
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
DOCA_STABLE doca_error_t doca_mmap_set_memrange(struct doca_mmap *mmap, void *addr, size_t len)
Set the memory range of DOCA memory map.
DOCA_STABLE doca_error_t doca_mmap_start(struct doca_mmap *mmap)
Start DOCA Memory Map.
const struct ip_frag_config * cfg
struct doca_mmap * src_mmap
struct doca_buf_inventory * buf_inv
struct doca_mmap * dst_mmap