dpdk/drivers/compress/qat/qat_comp.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: BSD-3-Clause
   2 * Copyright(c) 2015-2019 Intel Corporation
   3 */
   4
   5#ifndef _QAT_COMP_H_
   6#define _QAT_COMP_H_
   7
   8#ifdef RTE_LIB_COMPRESSDEV
   9
  10#include <rte_compressdev.h>
  11#include <rte_compressdev_pmd.h>
  12
  13#include "qat_common.h"
  14#include "qat_qp.h"
  15#include "icp_qat_hw.h"
  16#include "icp_qat_fw_comp.h"
  17#include "icp_qat_fw_la.h"
  18
  19#define QAT_64_BYTE_ALIGN_MASK (~0x3f)
  20#define QAT_64_BYTE_ALIGN (64)
  21#define QAT_NUM_BUFS_IN_IM_SGL 1
  22
  23#define ERR_CODE_QAT_COMP_WRONG_FW -99
  24
  25/* fallback to fixed compression threshold */
  26#define QAT_FALLBACK_THLD ((uint32_t)(RTE_PMD_QAT_COMP_IM_BUFFER_SIZE / 1.3))
  27
  28#define QAT_MIN_OUT_BUF_SIZE 46
  29
  30/* maximum size of the state registers */
  31#define QAT_STATE_REGISTERS_MAX_SIZE 256 /* 64 bytes for GEN1-3, 256 for GEN4 */
  32
  33/* decompressor context size */
  34#define QAT_INFLATE_CONTEXT_SIZE_GEN1 36864
  35#define QAT_INFLATE_CONTEXT_SIZE_GEN2 34032
  36#define QAT_INFLATE_CONTEXT_SIZE_GEN3 34032
  37#define QAT_INFLATE_CONTEXT_SIZE_GEN4 36864
  38#define QAT_INFLATE_CONTEXT_SIZE RTE_MAX(RTE_MAX(RTE_MAX(\
  39                QAT_INFLATE_CONTEXT_SIZE_GEN1, QAT_INFLATE_CONTEXT_SIZE_GEN2), \
  40                QAT_INFLATE_CONTEXT_SIZE_GEN3), QAT_INFLATE_CONTEXT_SIZE_GEN4)
  41
  42enum qat_comp_request_type {
  43        QAT_COMP_REQUEST_FIXED_COMP_STATELESS,
  44        QAT_COMP_REQUEST_DYNAMIC_COMP_STATELESS,
  45        QAT_COMP_REQUEST_DECOMPRESS,
  46        REQ_COMP_END
  47};
  48
  49struct array_of_ptrs {
  50        phys_addr_t pointer[0];
  51};
  52
  53struct qat_inter_sgl {
  54        qat_sgl_hdr;
  55        struct qat_flat_buf buffers[QAT_NUM_BUFS_IN_IM_SGL];
  56} __rte_packed __rte_cache_aligned;
  57
  58
  59struct qat_comp_op_cookie {
  60        phys_addr_t qat_sgl_src_phys_addr;
  61        phys_addr_t qat_sgl_dst_phys_addr;
  62        /* dynamically created SGLs */
  63        uint8_t error;
  64        uint8_t socket_id;
  65        uint16_t src_nb_elems;
  66        uint16_t dst_nb_elems;
  67        struct qat_sgl *qat_sgl_src_d;
  68        struct qat_sgl *qat_sgl_dst_d;
  69        struct qat_qp *qp;
  70        uint32_t cookie_index;
  71
  72        /* QAT IM buffer too small handling: */
  73        uint8_t split_op;
  74        uint8_t nb_children;
  75
  76        /* used by the parent only */
  77        uint8_t nb_child_responses;
  78        uint32_t total_consumed;
  79        uint32_t total_produced;
  80        const struct rte_memzone **dst_memzones;
  81        struct rte_mbuf *dst_data;
  82        uint32_t dst_data_offset;
  83
  84        /* used by the child only */
  85        struct qat_comp_op_cookie *parent_cookie;
  86        void *dest_buffer;
  87};
  88
  89struct qat_comp_xform {
  90        struct icp_qat_fw_comp_req qat_comp_req_tmpl;
  91        enum qat_comp_request_type qat_comp_request_type;
  92        enum rte_comp_checksum_type checksum_type;
  93};
  94
  95struct qat_comp_stream {
  96        struct qat_comp_xform qat_xform;
  97        void *state_registers_decomp;
  98        phys_addr_t state_registers_decomp_phys;
  99        void *inflate_context;
 100        phys_addr_t inflate_context_phys;
 101        const struct rte_memzone *memzone;
 102        uint8_t start_of_packet;
 103        volatile uint8_t op_in_progress;
 104};
 105
 106int
 107qat_comp_build_request(void *in_op, uint8_t *out_msg, void *op_cookie,
 108                       enum qat_device_gen qat_dev_gen __rte_unused);
 109
 110int
 111qat_comp_build_multiple_requests(void *in_op, struct qat_qp *qp,
 112                                 uint32_t parent_tail, int nb_descr);
 113
 114void
 115qat_comp_free_split_op_memzones(struct qat_comp_op_cookie *cookie,
 116                                unsigned int nb_children);
 117
 118int
 119qat_comp_process_response(void **op, uint8_t *resp, void *op_cookie,
 120                          uint64_t *dequeue_err_count);
 121
 122int
 123qat_comp_private_xform_create(struct rte_compressdev *dev,
 124                              const struct rte_comp_xform *xform,
 125                              void **private_xform);
 126
 127int
 128qat_comp_private_xform_free(struct rte_compressdev *dev, void *private_xform);
 129
 130unsigned int
 131qat_comp_xform_size(void);
 132
 133unsigned int
 134qat_comp_stream_size(void);
 135
 136int
 137qat_comp_stream_create(struct rte_compressdev *dev,
 138                       const struct rte_comp_xform *xform,
 139                       void **stream);
 140
 141int
 142qat_comp_stream_free(struct rte_compressdev *dev, void *stream);
 143
 144#endif
 145#endif
 146