55 struct doca_buf *src_doca_buf =
NULL;
56 struct doca_buf *dst_doca_buf =
NULL;
57 uint32_t max_bufs =
cfg->num_dst_buf +
cfg->num_src_buf;
58 char *dst_buffer =
NULL;
59 uint8_t *resp_head =
NULL;
62 FILE *out_file =
NULL;
63 struct doca_aes_gcm_key *key =
NULL;
66 uint64_t max_encrypt_buf_size = 0;
68 out_file = fopen(
cfg->output_path,
"wr");
69 if (out_file ==
NULL) {
87 goto destroy_resources;
90 if (file_size > max_encrypt_buf_size) {
91 DOCA_LOG_ERR(
"File size %zu > max buffer size %zu", file_size, max_encrypt_buf_size);
92 goto destroy_resources;
99 goto destroy_resources;
102 dst_buffer = calloc(1, max_encrypt_buf_size);
103 if (dst_buffer ==
NULL) {
106 goto destroy_resources;
141 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing source buffer: %s",
150 max_encrypt_buf_size,
155 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing destination buffer: %s",
157 goto destroy_src_buf;
164 goto destroy_dst_buf;
184 fwrite(resp_head,
sizeof(uint8_t), data_len, out_file);
185 DOCA_LOG_INFO(
"File was encrypted successfully and saved in: %s",
cfg->output_path);
188 dump =
hex_dump(resp_head, data_len);
190 DOCA_LOG_ERR(
"Failed to allocate memory for printing buffer content");
207 DOCA_LOG_ERR(
"Failed to decrease DOCA destination buffer reference count: %s",
214 DOCA_LOG_ERR(
"Failed to decrease DOCA source buffer reference count: %s",
doca_error_t submit_aes_gcm_encrypt_task(struct aes_gcm_resources *resources, struct doca_buf *src_buf, struct doca_buf *dst_buf, struct doca_aes_gcm_key *key, const uint8_t *iv, uint32_t iv_length, uint32_t tag_size, uint32_t aad_size)
doca_error_t destroy_aes_gcm_resources(struct aes_gcm_resources *resources)
doca_error_t allocate_aes_gcm_resources(const char *pci_addr, uint32_t max_bufs, struct aes_gcm_resources *resources)
doca_error_t aes_gcm_encrypt(struct aes_gcm_cfg *cfg, char *file_data, size_t file_size)
DOCA_LOG_REGISTER(AES_GCM_ENCRYPT)
doca_error_t allocat_doca_buf_list(struct doca_buf_inventory *buf_inv, struct doca_mmap *mmap, void *buf_addr, size_t buf_len, int num_buf, bool set_data_pos, struct doca_buf **dbuf)
struct rdma_resources resources
DOCA_EXPERIMENTAL doca_error_t doca_aes_gcm_key_create(struct doca_aes_gcm *aes_gcm, const void *raw_key, enum doca_aes_gcm_key_type raw_key_type, struct doca_aes_gcm_key **key)
Create an AES-GCM key from the user raw key to send with the task to allow encrypt/decrypt operations...
DOCA_EXPERIMENTAL doca_error_t doca_aes_gcm_cap_task_encrypt_get_max_buf_size(const struct doca_devinfo *devinfo, uint64_t *max_buffer_size)
Get aes_gcm encrypt max buffer size.
DOCA_EXPERIMENTAL doca_error_t doca_aes_gcm_key_destroy(struct doca_aes_gcm_key *key)
Destroy AES-GCM key that was created in doca_aes_gcm_key_create.
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_get_head(const struct doca_buf *buf, void **head)
Get the buffer's head.
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.
#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
char * hex_dump(const void *data, size_t size)
struct doca_mmap * src_mmap
struct doca_buf_inventory * buf_inv
struct doca_mmap * dst_mmap