55 struct doca_buf *src_doca_buf;
56 struct doca_buf *dst_doca_buf;
58 uint32_t max_bufs = 2;
59 uint64_t output_checksum = 0;
61 size_t data_len, written_len;
64 uint32_t source_adler_checksum, computed_adler_checksum;
65 uint64_t max_buf_size;
67 bool zlib_compatible =
cfg->is_with_frame;
70 if (zlib_compatible) {
72 DOCA_LOG_ERR(
"Input file length is too short, must be at least %d bytes",
84 out_file = fopen(
cfg->output_path,
"wr");
85 if (out_file ==
NULL) {
102 goto destroy_resources;
104 if (file_size > max_buf_size) {
105 DOCA_LOG_ERR(
"Invalid file size. Should be smaller then %lu", max_buf_size);
107 goto destroy_resources;
113 goto destroy_resources;
116 dst_buffer = calloc(1, max_buf_size);
117 if (dst_buffer ==
NULL) {
120 goto destroy_resources;
150 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing source buffer: %s",
162 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing destination buffer: %s",
164 goto destroy_src_buf;
168 if (zlib_compatible) {
174 DOCA_LOG_ERR(
"Unable to get data length in the DOCA buffer representing source buffer: %s",
176 goto destroy_dst_buf;
181 DOCA_LOG_ERR(
"Unable to get data length in the DOCA buffer representing source buffer: %s",
183 goto destroy_dst_buf;
188 if (
cfg->output_checksum || zlib_compatible) {
192 goto destroy_dst_buf;
198 goto destroy_dst_buf;
203 if (zlib_compatible) {
204 source_adler_checksum = be32toh(*(uint32_t *)((uint8_t *)file_data + file_size -
ZLIB_TRAILER_SIZE));
207 if (source_adler_checksum != computed_adler_checksum) {
209 "The given Adler checksum=%u, doesn't match the computed Adler checksum=%u. Data may be corrupt",
210 source_adler_checksum,
211 computed_adler_checksum);
213 goto destroy_dst_buf;
220 DOCA_LOG_ERR(
"Unable to get DOCA buffer data length for destination buffer: %s",
222 goto destroy_src_buf;
225 written_len = fwrite(dst_buffer,
sizeof(uint8_t), data_len, out_file);
226 if (written_len != data_len) {
227 DOCA_LOG_ERR(
"Failed to write the DOCA buffer representing destination buffer into a file");
229 goto destroy_dst_buf;
232 DOCA_LOG_INFO(
"File was decompressed successfully and saved in: %s",
cfg->output_path);
233 if (
cfg->output_checksum)
239 DOCA_LOG_ERR(
"Failed to decrease DOCA destination buffer reference count: %s",
246 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 allocate_compress_resources(const char *pci_addr, uint32_t max_bufs, struct compress_resources *resources)
doca_error_t submit_decompress_deflate_task(struct compress_resources *resources, struct doca_buf *src_buf, struct doca_buf *dst_buf, uint64_t *output_checksum)
doca_error_t verify_compress_zlib_header(struct compress_zlib_header *zlib_header)
@ COMPRESS_MODE_DECOMPRESS_DEFLATE
#define ZLIB_TRAILER_SIZE
#define ZLIB_COMPATIBILITY_ADDITIONAL_MEMORY
#define ADLER_CHECKSUM_SHIFT
DOCA_LOG_REGISTER(DECOMPRESS_DEFLATE)
doca_error_t decompress_deflate(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...
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_STABLE doca_error_t doca_buf_set_data(struct doca_buf *buf, void *data, size_t data_len)
DOCA_EXPERIMENTAL doca_error_t doca_compress_cap_task_decompress_deflate_get_max_buf_size(const struct doca_devinfo *devinfo, uint64_t *max_buffer_size)
Get decompress deflate 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